-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
275 lines (231 loc) · 9.1 KB
/
Rakefile
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
PRODUCT = "bbwifimusicsync"
PRODUCT_LONG = "Wireless Music Sync"
DESCRIPTION = "An Application to wirelessly Sync iTunes playlists."
VERSION = "0.3.1" # We omit the build segment of the version number.
AUTHORS = "Nithin Philips"
COPYRIGHT = "(c) 2011 #{AUTHORS}"
PROJECT_URL = "https://sourceforge.net/projects/bbwifimusicsync/"
TRADEMARKS = "BlackBerry(r) is a registered trademark of Research in Motion"
CONFIGURATION = "Release"
BUILD_DIR = File.expand_path("build")
BB_BUILD_DIR = "BlackberryClient/WifiMusicSync/deliverables"
OUTPUT_DIR = "#{BUILD_DIR}/out"
BIN_DIR = "#{BUILD_DIR}/bin"
SRC_DIR = "#{BUILD_DIR}/src"
NUGET_DIR = "#{BUILD_DIR}/nug"
PACKAGES_DIR = "packages"
PACKAGE = "#{PRODUCT}-#{VERSION}"
BIN_PACKAGE = "#{PACKAGE}-bin"
SRC_PACKAGE = "#{PACKAGE}-src"
INS_PACKAGE = "#{PACKAGE}-setup"
require 'albacore'
FileList["./albacore/*.rb"].each { |f| require f }
require 'rgl/dot'
require 'rgl/implicit'
require 'zip/zip'
require 'zip/zipfilesystem'
task :default => [:dist]
task :dist => [:clean, :dist_zip, :dist_src, :installer, :test]
task :dist_with_log => [:clean, :copylogconfig, :dist_zip, :dist_src, :installer, :test]
Albacore.configure do |config|
config.rapcmanifest.output = config.rapc.output = PRODUCT
config.rapcmanifest.destdir = config.rapc.destdir = BB_BUILD_DIR
config.rapc.createweb = true
config.rapc.nowarn = true
config.rapcmanifest do |m|
m.title = m.name = PRODUCT_LONG
m.version = VERSION
m.vendor = AUTHORS
m.description = DESCRIPTION
m.type = :CLDC
m.icon = "../../../res/music-sync-68.png"
m.focus_icon = "../../../res/music-sync-glow-68.png"
end
config.assemblyinfo do |a|
a.product_name = PRODUCT_LONG
a.version = VERSION
a.file_version = VERSION
a.copyright = COPYRIGHT
a.company_name = AUTHORS
a.trademark = TRADEMARKS
end
end
desc "Compile Wireless Music Sync"
msbuild :compile => :assemblyinfo do |msb|
msb.properties :configuration => CONFIGURATION, "OutputPath" => OUTPUT_DIR
msb.targets :Clean, :Build
msb.solution = "WifiMusicSync.sln"
# q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]
msb.verbosity = "detailed"
msb.log_level = :verbose
FileUtils.mkdir_p(BUILD_DIR)
# Disable console logging and send output to a file.
msb.parameters = "/noconsolelogger", "/fileLogger", "/fileloggerparameters:logfile=\"#{BUILD_DIR}/msbuild.log\""
end
desc "Organize Wireless Music Sync binaries"
task :build => [:compile, :build_bbapp] do
FileUtils.rm_rf BIN_DIR
FileUtils.mkdir_p("#{BIN_DIR}/#{PACKAGE}/app")
FileUtils.mkdir_p("#{BIN_DIR}/#{PACKAGE}/MusicSync.BlackBerryApp")
binaries = FileList["#{OUTPUT_DIR}/*.dll", "#{OUTPUT_DIR}/*.exe", "#{OUTPUT_DIR}/*.exe.config", "#{OUTPUT_DIR}/*.dll.config", "README.md", "COPYING.txt"]
.exclude(/Backup/)
.exclude(/Afterthought.Amender.exe/)
.exclude(/KayakExamples.exe/)
FileUtils.cp_r binaries, "#{BIN_DIR}/#{PACKAGE}/"
binaries = FileList["./BlackberryClient/WifiMusicSync/deliverables/Web/**"]
FileUtils.cp_r binaries, "#{BIN_DIR}/#{PACKAGE}/app"
binaries = FileList["./BlackberryClient/WifiMusicSync/deliverables/Standard/**"]
FileUtils.cp_r binaries, "#{BIN_DIR}/#{PACKAGE}/MusicSync.BlackBerryApp"
end
desc "Copy log config files to enable logging"
task :copylogconfig => :build do
files = FileList["#{OUTPUT_DIR}/*.log.config"]
FileUtils.cp_r files, "#{BIN_DIR}/#{PACKAGE}/"
end
desc "Package source code"
task :dist_src do |z|
gitModules = [
{"dir" => ".", "prefix" => "#{PACKAGE}" },
{"dir" => "lib/Afterthought", "prefix" => "#{PACKAGE}/lib/Afterthought"}
]
workingdir = Dir.pwd
FileUtils.rm_rf "#{BUILD_DIR}/src"
gitModules.each { |m|
prefix = m["prefix"]
filename = "#{BUILD_DIR}/src-temp.zip"
Dir.chdir(m["dir"])
sh "git archive HEAD --format=zip -9 --prefix=\"#{prefix}/\" > \"#{filename}\""
Dir.chdir(workingdir)
extract_zip(filename, "#{BUILD_DIR}/src")
FileUtils.rm_rf filename
}
FileUtils.rm_rf "#{BUILD_DIR}/#{SRC_PACKAGE}.zip"
zip_dir("#{BUILD_DIR}/src", "#{BUILD_DIR}/#{SRC_PACKAGE}.zip")
end
def zip_dir(dir, file)
path = File.expand_path(dir)
Zip::ZipFile.open(file, Zip::ZipFile::CREATE) do |zipfile|
Dir["#{path}/**/**"].each do |file|
zipfile.add(file.sub(path + '/',''),file)
end
end
end
def extract_zip(file, dest)
Zip::ZipFile.open(file) { |zip_file|
zip_file.each { |f|
f_path=File.join(dest, f.name)
FileUtils.mkdir_p(File.dirname(f_path))
zip_file.extract(f, f_path) unless File.exist?(f_path)
}
}
end
desc "Package binaries"
zip :dist_zip => [:build] do |z|
z.directories_to_zip BIN_DIR
z.output_file = "#{BIN_PACKAGE}.zip"
z.output_path = BUILD_DIR
end
desc "Update installer file list"
nsisfilelist :installerfiles => [:build] do |n|
n.dirs << File.expand_path("#{BIN_DIR}/#{PACKAGE}/")
n.add_files_list = File.expand_path("MusicSync.Installer/files_ADD.nsi")
n.remove_files_list = File.expand_path("MusicSync.Installer/files_REM.nsi")
end
desc "Build installer"
nsis :installer => [:installerfiles] do |n|
n.installer_file = File.expand_path("MusicSync.Installer/Installer.nsi")
n.verbosity = 4
n.log_file = File.expand_path("#{BUILD_DIR}/installer.log")
n.defines :PRODUCT_VERSION => VERSION, :OUT_FILE => "#{BUILD_DIR}/#{INS_PACKAGE}.exe"
end
desc "Run tests"
mstest :test => [:compile] do |test|
test.command = "C:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/mstest.exe"
test.assemblies "#{OUTPUT_DIR}/MusicSync.Tests.dll"
end
def ensure_submodules()
system("git submodule init")
system("git submodule update")
end
desc "Cleanup files"
task :clean do
FileUtils.rm_rf BUILD_DIR
end
task :build_bbapp => [:compile_bbapp, :sign_cod]
task :compile_bbapp => [:clean_bb, :build_bbapp5, :build_bbapp6]
sigtool :sign_cod => [:compile_bbapp] do |s|
s.codfiles = FileList[ "#{BB_BUILD_DIR}/**/*.cod" ]
end
task :clean_bb do
FileUtils.rm_rf BB_BUILD_DIR
end
rapc :build_bbapp5 => [:rapcmanifest5, :javaasminfo] do |r|
r.sdkversion = "5.0.0"
r.sources = FileList["BlackberryClient/WifiMusicSync/src/**/*.java", "BlackberryClient/WifiMusicSync/res/**/*"]
end
rapc :build_bbapp6 => [:rapcmanifest6, :javaasminfo] do |r|
r.sdkversion = "6.0.0"
r.sources = FileList["BlackberryClient/WifiMusicSync/src/**/*.java", "BlackberryClient/WifiMusicSync/res/**/*"].exclude(/json/)
end
desc "Create rapc manifest"
rapcmanifest :rapcmanifest5 do |m|
m.sdkversion = "5.0.0"
end
desc "Create rapc manifest"
rapcmanifest :rapcmanifest6 do |m|
m.sdkversion = "6.0.0"
end
desc "Create a java class with information about the app"
javaassemblyinfo :javaasminfo do |j|
j.title = PRODUCT_LONG
j.description = DESCRIPTION
j.version = VERSION
j.copyright = COPYRIGHT
j.class_name = "AssemblyInfo"
j.package_name = "com.nithinphilips"
j.output_dir = File.expand_path("BlackberryClient/WifiMusicSync/src/com/nithinphilips")
end
desc "Create assemblyinfo files"
task :assemblyinfo => [:libasminfo, :testsasminfo, :serverasminfo, :desktopasminfo, :configuratorasminfo]
assemblyinfo :libasminfo do |a|
a.title = "libMusicSync"
a.description = "A supporting library for wirelessly syncing music to BlackBerry phones"
a.output_file = "libMusicSync/Properties/AssemblyInfo.cs"
end
assemblyinfo :testsasminfo do |a|
a.title = "MusicSync.Tests"
a.description = "A set of tests for Wireless Music Sync features"
a.output_file = "MusicSync.Tests/Properties/AssemblyInfo.cs"
end
assemblyinfo :serverasminfo do |a|
a.title = "MusicSync.Server"
a.description = "A server for wirelessly syncing music to BlackBerry phones"
a.output_file = "MusicSync.Server/Properties/AssemblyInfo.cs"
end
assemblyinfo :desktopasminfo do |a|
a.title = "MusicSync.Desktop"
a.description = "A desktop client for syncing music to BlackBerry phones"
a.output_file = "MusicSync.Desktop/Properties/AssemblyInfo.cs"
end
assemblyinfo :configuratorasminfo do |a|
a.title = "MusicSync.Configurator"
a.description = "A tool to configure Wireless Music Sync"
a.output_file = "MusicSync.Configurator/Properties/AssemblyInfo.cs"
end
desc "Generate a graph of all the tasks and their relationship"
task :dep_graph do |task|
this_task = task.name
dep = RGL::ImplicitGraph.new { |g|
# vertices of the graph are all defined tasks without this task
g.vertex_iterator do |b|
Rake::Task.tasks.each do |t|
b.call(t) unless t.name == this_task
end
end
# neighbors of task t are its prerequisites
g.adjacent_iterator { |t, b| t.prerequisites.each(&b) }
g.directed = true
}
dep.write_to_graphic_file('png', this_task)
puts "Wrote dependency graph to #{this_task}.png."
end