#!/usr/bin/ruby -d =begin build-cli Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. Contact: Taejun Ha Jiil Hyoun Donghyuk Yang DongHee Yang Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Contributors: - S-Core Co., Ltd =end require "socket" require 'fileutils' $LOAD_PATH.unshift File.dirname(__FILE__)+"/src/common" $LOAD_PATH.unshift File.dirname(__FILE__)+"/src/build_server" require "utils" require "BuildClientOptionParser" require "BuildComm" #option parsing option = option_parse # if "--os" is not specified, use host os type if option[:os].nil? then option[:os] = Utils::HOST_OS else if not option[:os] =~ /^(linux|windows|darwin)$/ then puts "We have no plan to Buld OS \"#{option[:os]}\" \n please check your option OS " exit 1 end end if option[:domain].nil? then option[:domain] = "127.0.0.1" end if option[:port].nil? then option[:port] = 2222 end begin case option[:cmd] when "build" client = BuildCommClient.create( option[:domain], option[:port]) if not client.nil? then client.send "BUILD,GIT,#{option[:git]},#{option[:commit]},#{option[:os]},,#{option[:async]}" client.print_stream client.terminate end when "resolve" client = BuildCommClient.create( option[:domain], option[:port]) if not client.nil? then client.send "RESOLVE,GIT,#{option[:git]},#{option[:commit]},#{option[:os]},,#{option[:async]}" client.print_stream client.terminate end when "query" # SYSTEM INFO client = BuildCommClient.create( option[:domain], option[:port]) if not client.nil? then client.send "QUERY,SYSTEM" result0 = client.receive_data() if result0.nil? then client.terminate exit(-1) end result0 = result0[0].split(",").map { |x| x.strip } puts "HOST-OS: #{result0[0]}" puts "MAX_WORKING_JOBS: #{result0[1]}" client.terminate end # JOB INFO client = BuildCommClient.create( option[:domain], option[:port]) if not client.nil? then client.send "QUERY,JOB" result1 = client.receive_data() if result0.nil? then client.terminate exit(-1) end puts "* JOB *" for item in result1 tok = item.split(",").map { |x| x.strip } puts "#{tok[1]} #{tok[0]} #{tok[2]}" end end else raise RuntimeError, "input option incorrect : #{option[:cmd]}" end rescue => e puts e.message exit(-1) end exit 0