-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.rb
executable file
·79 lines (65 loc) · 2.75 KB
/
build.rb
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
#!/usr/bin/ruby
DOCUMENTATION = <<DOCEND
A help script to build a Smalltalk/X jv-branch (mainly) on a Jenkins CI.
If no TARGET is given, invokes target `jenkins:job`.
Some influential environment variables:
BUILD_TARGET target to build, can be also specified on a command line using
--build-target option.
CC C compiler command (only UNIX builds for now)
CXX C++ compiler command (only UNIX builds for now)
DOCEND
require 'optparse'
def run()
optparse = OptionParser.new do | opts |
opts.banner = "Usage: #{$0} [TARGET1 [TARGET1 [...]]\n"
opts.on('-p', '--project PROJECT', "PROJECT to build. Overrides project specified by the environment variable.") do | value |
ENV['PROJECT'] = value
self.class.const_set('PROJECT', value)
end
opts.on('-t', '--build-target BUILD_TARGET', "Target to build for in form of GNU target triplet (such as 'x86_64-pc-linux-gnu'). Overrides build target specified by the environment variable.") do | value |
ENV['BUILD_TARGET'] = value
self.class.const_set('BUILD_TARGET', value)
end
opts.on(nil, '--help', "Prints this message") do
puts DOCUMENTATION
puts optparse.help()
exit 0
end
end
optparse.parse!
# If run outside a Jenkins build environment (such as from a command line),
# define some variables to make it look more like a proper Jenkins build
# environment.
ENV['WORKSPACE'] ||= '.'
ENV['BUILD_NUMBER'] ||= Time.now.strftime("%Y%m%d")
ENV['JOB_NAME'] ||= 'interactive'
# If no target is given, run target jenkins:job
if ARGV.size == 0 then
ARGV << 'jenkins:job'
end
# Wipe out `reports` directory. This is needed for two reasons:
#
# 1) There's a bug in Cobertura plugin so it does not expand
# variables in .xml file pattern so the pattern cannot include
# BUILD_NUMBER to tell reports for particular build.
# See https://issues.jenkins-ci.org/browse/JENKINS-30647
# 2) More importantly, when additional axis is used (such as JDK
# or Mercurial version) then value of this axis is not reflected
# in report filename. So again, all files, even those from previous
# builds would be matches which is not what we want.
#
# A workaround is to wipe-out `reports` directory before each buld,
# so once this script finishes, all reports there are for this build.
# The downside is that we have to limit number of executors to 1,
reports_dir = File.join(ENV['WORKSPACE'], 'reports')
if File.exist? reports_dir then
require 'fileutils'
FileUtils.rm_rf reports_dir
end
# When run under Jenkins, we do want to see full backtrace if something
# fails.
ARGV << '--trace'
require 'rake'
Rake.application.run
end
run if __FILE__ == $0