upload tizen1.0 source
[sdk/tools/sdk-build.git] / build-svr
1 #!/usr/bin/ruby -d 
2
3 =begin
4  
5  build-svr
6
7 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
8
9 Contact:
10 Taejun Ha <taejun.ha@samsung.com>
11 Jiil Hyoun <jiil.hyoun@samsung.com>
12 Donghyuk Yang <donghyuk.yang@samsung.com>
13 DongHee Yang <donghee.yang@samsung.com>
14
15 Licensed under the Apache License, Version 2.0 (the "License");
16 you may not use this file except in compliance with the License.
17 You may obtain a copy of the License at
18
19 http://www.apache.org/licenses/LICENSE-2.0
20
21 Unless required by applicable law or agreed to in writing, software
22 distributed under the License is distributed on an "AS IS" BASIS,
23 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 See the License for the specific language governing permissions and
25 limitations under the License.
26
27 Contributors:
28 - S-Core Co., Ltd
29 =end
30
31 require 'fileutils'
32 $LOAD_PATH.unshift File.dirname(__FILE__)+"/src/common"
33 $LOAD_PATH.unshift File.dirname(__FILE__)+"/src/build_server"
34 require "utils"
35 require "BuildServerOptionParser"
36 require "BuildServerController"
37
38 #option parsing 
39 begin
40         option = option_parse
41 rescue => e
42         puts "Option parse error"
43         puts e.message
44         exit 0
45 end
46
47
48 # if "--os" is not specified, use host os type
49 if option[:os].nil? then
50     host_os = `uname -s`.strip
51     case host_os
52     when "Linux"
53         option[:os] = "linux"
54     when /MINGW32.*/
55         option[:os] = "windows"
56     when "Darwin"
57         option[:os] = "darwin"
58     else
59         if not option[:os] =~ /^(linux|windows|darwin)$/ then 
60             puts "We have no plan to Buld OS \"#{option[:os]}\" \n please check your option OS "
61             exit 1
62         end
63     end 
64 else
65     if not option[:os] =~ /^(linux|windows|darwin)$/ then 
66         puts "We have no plan to Buld OS \"#{option[:os]}\" \n please check your option OS "
67         exit 1
68     end
69 end 
70
71
72
73 begin
74         case option[:cmd] 
75         when "create" 
76                 BuildServerController.create_server( option[:name], Utils::WORKING_DIR, option[:url], option[:domain], option[:pid] )
77         when "remove"
78                 BuildServerController.remove_server( option[:name] ) 
79         when "start"
80                 BuildServerController.start_server( option[:name], option[:port] ) 
81         when "stop"
82                 BuildServerController.stop_server( option[:name] ) 
83         when "add"
84                 BuildServerController.add_friend_server( option[:name], option[:domain], option[:port] ) 
85         else
86                 raise RuntimeError, "input option incorrect : #{option[:cmd]}"
87         end
88
89         exit 0
90 rescue => e
91         puts e.message
92 end
93
94