This repository was archived by the owner on Oct 22, 2020. It is now read-only.
forked from dev4dev/bs_modulo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilder.rb
More file actions
executable file
·98 lines (88 loc) · 2.87 KB
/
builder.rb
File metadata and controls
executable file
·98 lines (88 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env ruby -KU
# encoding: UTF-8
__F__ = if File.symlink? __FILE__ then File.readlink(__FILE__) else File.expand_path(__FILE__) end
BUILDER_DIR = File.expand_path(File.dirname(__F__)) + '/'
$:.unshift "#{BUILDER_DIR}lib/"
require "constants"
require "helpers"
require "runner"
require "settings"
require 'commander/import'
program :name, 'builder'
program :version, '1.0.1'
program :description, 'Build System'
command :install do |c|
c.syntax = ' builder install'
c.description = 'Install builder in system'
c.option '-f', '--force', 'Force install'
c.action do |args, options|
if File.exist?(BIN_PATH) && !options.force
fail "builder is already installed or its default name '#{BIN_PATH}' is already taken by another app\nyou can overwrite it by passing --force option"
elsif options.force
begin
File.delete BIN_PATH
rescue Exception => e
fail "failed while deleting old file/link at #{BIN_PATH}..."
end
end
puts 'Installing...'
puts "...creating [#{BIN_PATH}] symlink..."
File.symlink __F__, BIN_PATH
puts "...creating global configuration file [#{GLOBAL_CONFIG_FILE}]..."
open(GLOBAL_CONFIG_FILE, "w") { |io| io << ''} unless File.exist? GLOBAL_CONFIG_FILE
puts 'Done.'
end
end
command :build do |c|
c.syntax = '[WORKSPACE=/path/to/project] [CONFIGURATION=configuration_name] builder build [build_config_file]'
c.description = 'Run build'
c.action do |args, options|
Runner::run args
end
end
command :branch do |c|
c.syntax = '[WORKSPACE=/path/to/project] [BRANCH=branch_name] builder build'
c.description = 'Switch to BRANCH and fetch all data'
c.option '-c', '--current', 'Update current branch'
c.action do |args, options|
## check input parameters
if options.current
branch = `git rev-parse --abbrev-ref HEAD`
branch.delete!("\n")
else
if ENV['BRANCH']
branch = ENV['BRANCH']
else
branch = 'master'
end
end
if ENV['WORKSPACE']
workspace = real_dir ENV['WORKSPACE']
else
workspace = real_dir Dir::pwd
end
if File.exist?(workspace + '.git')
command = %Q[git reset --hard && git clean -f -d && git fetch origin && git checkout #{branch} && git reset --hard origin/#{branch} && git clean -f -d]
info command
result = system command
else
info %Q[branch skipped]
end
end
end
command :killsim do |c|
c.syntax = 'builder killsim'
c.description = 'Close ios simmulator'
c.action do |args, options|
closeXcode6sim = %Q[killall "iOS Simulator"]
info closeXcode6sim
result = system closeXcode6sim
closeXcode7sim = %Q[killall "Simulator"]
info closeXcode7sim
result = system closeXcode7sim
end
end
# just for tests
# ENV['WORKSPACE'] = '/Users/macuser/Projects/LifelikeClassifieds'
# ENV['CONFIGURATION'] = 'ui_tests'
# Runner::run ['builder.yml']