forked from emk/halyard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildfile.rb
executable file
·224 lines (187 loc) · 7.52 KB
/
buildfile.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# The buildscript library is designed for turning Halyard programs
# into DVDs. Here, we abuse it terribly by turning a Win32
# application into tarballs and a series of git commits. This
# script would be much nicer if we actually modified buildscript to
# better support the things we're asking it to do here.
# Things you will need to install or setup to make this work:
# - The packages described in tools/buildscript/README.txt
# - Cygwin packages: git, autoconf, automake, pkg-config, zip
# - Password-free login to any SSH servers mentioned below
# Add our Halyard-related libraries to our $LOAD_PATH.
$LOAD_PATH << "#{File.dirname(__FILE__)}/runtime/ruby/lib"
require 'buildscript/buildscript'
include Buildscript
require 'buildscript/commands'
require 'find'
git_url = 'ssh://imlsrc.dartmouth.edu/var/lib/git'
release_dir = 'c:/release/halyard'
build_dir = 'c:/build/halyard'
# This quick-and-dirty argument check isn't technically correct, because we
# may have other arguments parsed by buildscript. But it catches the most
# common incorrect command lines.
if ARGV.length == 0 || ARGV.last[0] == "-"[0]
STDERR.puts 'Usage: buildfile.rb <version>'
STDERR.puts 'Version should resolve to a git commit, e.g., v0.5.4'
exit 1
end
# Get our version number.
commit = ARGV.pop
# Versions may contain "-rcN", "-preN", etc., but if they do, they must end
# with a number. This prevents us from releasing tarballs of things like
# "v0.4-stable".
if commit =~ /^v[0-9.]+(-.*[0-9])?$/
# Here, $untagged_build is a global variable so that we can access it
# from inside the function for_release?, below.
$untagged_build = false
version = commit.sub(/^v/, '')
elsif commit =~ /^origin\//
# If specify a version of the form origin/foo, then we want to make an
# untagged build of branch foo.
$untagged_build = true
version = commit.sub(/^origin\//, '')
else
# If we don't have a version of the form "v0.5.1", "v2.5-rc2", etc., then
# don't actually upload the results of this build anywhere.
$untagged_build = true
version = commit
end
# Is this a build we intend to release, or just a test build?
def for_release?
!(dirty_build? || $untagged_build)
end
halyard_url = "#{git_url}/halyard"
# This is the Git repo where we push our binaries for inclusion in our
# programs.
git_bin_url = "#{git_url}/halyard-bin-0.5-2"
# These correspond to the tarballs we would like to release.
src_dir = "halyard-#{version}"
test_dir = "halyard-test-#{version}"
mizzen_dir = "mizzen-#{version}"
# Directory that should be released to Git and our halyard-test
# zipfile as our binaries module.
$release_files_dir = "#{build_dir}/#{src_dir}/test/engine/win32"
# Find all of the top-level files and directories to be released.
def release_files
Dir["#{$release_files_dir}/*"]
end
git_bin_dir = "#{src_dir}-git"
all_archive = "halyard-all-#{version}.tar.gz"
src_archive = "halyard-#{version}.tar.gz"
libs_archive = "halyard-libs-#{version}.tar.gz"
media_archive = "halyard-media-#{version}.tar.gz"
mizzen_archive = "mizzen-#{version}.tar.gz"
test_archive = "halyard-test-#{version}.zip"
lib_dirs = %w(libs/boost libs/curl libs/freetype2 libs/libivorbisdec
libs/libxml2 libs/plt libs/portaudio libs/quake2
libs/sqlite libs/wxWidgets)
media_dir = "test/streaming/media"
web_host = 'iml.dartmouth.edu'
web_ssh_user = 'iml_updater'
web_path = '/var/www/halyard/dist'
web_halyard_dir = "#{web_path}/halyard-#{version}"
web_halyard_test_dir = "#{web_path}/halyard-test"
web_mizzen_dir = "#{web_path}/mizzen"
start_build(:build_dir => build_dir,
:release_dir => release_dir,
:signing_key => 'iml_authenticode_key')
heading 'Check out the source code.', :name => :checkout do
git :clone, halyard_url, src_dir unless dirty_build?
cd src_dir do |d|
git :checkout, commit
git :submodule, 'init'
git :submodule, 'update'
end
end
# Generate configure and Makefile.in for use on Unix platforms. This
# requires autoconf, automake, and pkg-config.
heading "Run autogen.sh.", :name => :autogen do
cd(src_dir) { run "./autogen.sh" }
end
# Build copies of all of our tarballs before we do any builds or testing,
# so we will have clean trees. make_tarball and make_tarball_from_files
# will automatically ignore any .git and .gitignore files.
heading 'Build source tarballs.', :name => :source_tarball do
# Build our halyard-all-x.y.z.tar.gz archive
make_tarball src_dir, :filename => all_archive
# Build our normal source archive, halyard-x.y.z.tar.gz, excluding
# our libraries and media directory.
excludes = lib_dirs + [media_dir]
make_tarball src_dir, :filename => src_archive, :exclude => excludes
# Build our libs tarball.
lib_dirs_full = lib_dirs.map {|d| "#{src_dir}/#{d}"}
make_tarball_from_files lib_dirs_full, :filename => libs_archive
# Build our media tarball.
make_tarball "#{src_dir}/#{media_dir}", :filename => media_archive
# Build our mizzen tarball
cp_r "#{src_dir}/runtime/collects/mizzen", mizzen_dir
make_tarball mizzen_dir, :filename => mizzen_archive
# Copy out clean copy of halyard/test before doing rake test; we will
# build the zipfile for this after building the engine and copying
# it in.
rm_rf test_dir if dirty_build?
cp_r "#{src_dir}/test", test_dir
end
heading 'Building and testing engine.', :name => :build do
cd src_dir do |d|
run 'rake', 'test/binaries/gpgv.exe'
run 'rake', 'libs'
run 'rake', 'test'
# Sign the binaries. The update installer is the most important file
# here.
Dir['runtime/*.{exe,dll}'].each do |file|
if file =~ /UpdateInstaller/
sign_file(file, 'Software update installer',
'http://iml.dartmouth.edu/halyard/')
else
sign_file(file, 'Halyard multimedia engine',
'http://iml.dartmouth.edu/halyard/')
end
end
# Freeze our runtime into test/engine/win32, which we can then use
# as a basis for releasing to Git and halyard-test.
cd 'test' do |d|
run 'rake', 'halyard:freeze'
end
end
end
heading 'Tagging runtime and binaries in Git.', :name => :push_git do
rm_rf git_bin_dir if dirty_build?
git :clone, git_bin_url, git_bin_dir
cd git_bin_dir do |d|
release_files.each do |path|
cp_r path, "."
git :add, File.basename(path)
end
git :commit, '-m', "Pushing binaries for release #{version}."
git :tag, "v#{version}"
git :push if for_release?
git :push, '--tags' if for_release?
end
end
heading 'Releasing binaries to test project.', :name => :release_to_test do
cp "#{src_dir}/LICENSE.txt", test_dir
mkdir_p "#{test_dir}/engine"
cp_r $release_files_dir, "#{test_dir}/engine/win32"
end
heading 'Building Halyard Test ZIP archive.', :name => :build_test_zip do
make_zipfile test_dir, :filename => test_archive
end
heading 'Uploading tarballs to website.', :name => :upload do
if for_release?
server = remote_host(web_host, :user => web_ssh_user)
server.run 'mkdir', '-p', web_halyard_dir
# TODO - we should base this on information in release_infos, but
# that needs a bit of refactoring before it will be able to do what
# we want.
# TODO - server.upload does rsync, while we only need scp. We might want
# to distinguish them.
[all_archive, src_archive, libs_archive, media_archive].each do |file|
server.upload file, web_halyard_dir
end
server.upload test_archive, web_halyard_test_dir
server.upload mizzen_archive, web_mizzen_dir
server.upload "#{src_dir}/Release-Notes.txt", web_path
end
end
# Finish the build.
finish_build_and_upload_files