-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.pl
executable file
·332 lines (297 loc) · 10.9 KB
/
build.pl
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
#!/usr/bin/perl
use warnings;
use strict;
my $debug = 0;
my $errors = 0;
my $exec_ezsetup = "ezsetup.exe";
# ------------------------------------------------------------------------------
# Standard Variables
# ------------------------------------------------------------------------------
my $gcc = 0;
my $pf = $ENV{ProgramFiles};
if (!length($pf)) {
$gcc = 1;
} else {
if (! -s "$pf/Microsoft eMbedded C++ 4.0/Common/EVC/Bin/EVC.EXE") {
$pf = "D:/Program Files";
}
}
my $nobuild = 0;
my $noclean = 1;
my %execs = (
'EVC3' => {
'evc' => "$pf/Microsoft eMbedded C++ 3.0/Common/EVC/Bin/EVC.EXE",
'cabwiz' => "$pf/Windows CE Tools/wce300/Pocket PC 2002/support/ActiveSync/windows ce application installation/cabwiz/Cabwiz.exe",
},
'EVC4' => {
'evc' => "$pf/Microsoft eMbedded C++ 4.0/Common/EVC/Bin/EVC.EXE",
'cabwiz' => "$pf/Windows CE Tools/wce420/POCKET PC 2003/Tools/Cabwiz.exe",
},
);
if (!$gcc) {
foreach my $e (keys %execs) {
foreach my $p (qw/evc cabwiz/) {
error("Unable to locate $e $p\n\t" . $execs{$e}{$p} . "\n") unless (-e $execs{$e}{$p});
}
}
# TODO die "ERROR: Unable to locate EZSetup\n\t$exec_ezsetup\n" unless (-e $exec_ezsetup);
}
# List projects here... (note: we build all of these for each platform)
my @projects = qw/XCSoar XCSoarSimulator XCSoarLaunch XCSoarSetup/;
my %platforms = (
'PPC2003' => {
'exec' => "EVC4",
'proc' => [qw/ARMV4/],
'cab' => 1,
'sim' => 1
},
'PPC2003X' => {
'exec' => "EVC4",
'proc' => [qw/ARMV4/],
'cab' => 1,
'sim' => 1
},
'PNA' => {
'exec' => "EVC4",
'proc' => [qw/ARMV4/],
'cab' => 0,
'sim' => 0
},
'ALTAIRPORTRAIT' => {
'exec' => "EVC4",
'proc' => [qw/ARMV4/],
'cab' => 0,
'sim' => 0
},
'ALTAIR' => {
'exec' => "EVC4",
'proc' => [qw/ARMV4/],
'cab' => 0,
'sim' => 0
},
'PC' => {
'exec' => "EVC4",
'proc' => [qw/ARMV4/],
'cab' => 0,
'sim' => 1
},
'PPC2002' => {
'exec' => "EVC3",
'proc' => [qw/ARM/], # was and MIPS
'cab' => 1,
'sim' => 1
},
# XXX adding MIPS ARM for PPC but using PPC2002 project files !
# 'PPC' => { # Also known as PPC 2000
# 'exec' => "EVC3",
# 'proc' => [qw/MIPS ARM/],
# },
);
my @platforms_all = keys %platforms;
# XXX ALL currently not being supported
# push @platforms_all, "ALL";
# ------------------------------------------------------------------------------
# User Input (primative)
# ------------------------------------------------------------------------------
my $user = shift;
if ($user) {
if (exists($platforms{$user}) || $user eq "ALL") {
foreach my $key (keys %platforms) {
delete $platforms{$key} unless ($key eq $user);
}
@platforms_all = ($user);
} else {
if ($user eq "nobuild") {
$nobuild = 1;
} else {
die "ERROR: Invalid platform. Select from:\n\t" . join(",", keys %platforms) . "\n";
}
}
}
print STDERR "Building platforms: " . join(",", keys %platforms) . "\n";
# ------------------------------------------------------------------------------
# Process the VERSION
# ------------------------------------------------------------------------------
open (IN, "VERSION.txt") || die "ERROR: Unable to open version file: VERSION.txt - $!\n";
my $version_raw = <IN>;
close IN;
chomp($version_raw);
# __DATE__ = "mmm dd yyyy"
my $version = $version_raw;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year+=1900;
my $month = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/[$mon];
$version =~ s/__DATE__/$month $mday $year/g;
my $version_file = $version;
$version_file =~ s/ /_/g;
my $version_num = $version;
$version_num =~ s/(\d)\.(\d)\.(\d).*/$1$2$3/g;
print STDERR "Version = ",$version_file, " num $version_num\n";
# ------------------------------------------------------------------------------
# BUILD ALL via EVC3&4
# ------------------------------------------------------------------------------
if (!$gcc && !$nobuild) {
foreach my $platform (keys %platforms) {
foreach my $project (@projects) {
foreach my $proc (@{$platforms{$platform}{'proc'}}) {
my $cmd = q{"} . $execs{$platforms{$platform}{'exec'}}{evc} . q{" }
. qq{$platform/$project/$project.vcp /MAKE "$project - Win32 (WCE $proc) Release" /REBUILD};
print STDERR "Building $project for $platform/$proc\n";
print STDERR "\t$cmd\n" if ($debug);
system($cmd) and error("Executing Command - $?\n\t$cmd\n");
}
}
}
}
# ------------------------------------------------------------------------------
# CABs - via ???
# ------------------------------------------------------------------------------
if (!$gcc) {
foreach my $platform (keys %platforms) {
my $cmd = q{"} . $execs{$platforms{$platform}{'exec'}}{cabwiz} . q{" }
. qq{XCSoar$platform.inf /cpu } . join(" ", @{$platforms{$platform}{'proc'}});
print STDERR "CABing $platform\n";
print STDERR "\t$cmd\n" if ($debug);
system($cmd) and error("Executing Command - $?\n\t$cmd\n");
}
}
# ------------------------------------------------------------------------------
# EXEs - via EZSetup
# ------------------------------------------------------------------------------
foreach my $platform (@platforms_all) {
if (!$gcc) {
my $cmd = q{} . $exec_ezsetup . q{ -l english -i }
. qq{XCSoar$platform.ini -r installmsg.txt -e gpl.txt -o InstallXCSoar-$platform.exe};
print STDERR "EZSetup for $platform\n";
print STDERR "\t$cmd\n" if ($debug);
system($cmd) and error("Executing Command - $?\n\t$cmd\n");
} else {
if (!$nobuild) {
print "Making cab files with gcc\n";
system("make -j 2 TARGET=$platform clean");
if ($platforms{$platform}{cab}) {
system("make -j 2 TARGET=$platform cab");
} else {
system("make -j 2 TARGET=$platform all");
}
}
}
}
# ------------------------------------------------------------------------------
# RENAME for Distribution
# ------------------------------------------------------------------------------
# Rename CAB files
mkdir "dist";
foreach my $platform (keys %platforms) {
print "Cab files for $platform\n";
foreach my $proc (@{$platforms{$platform}{'proc'}}) {
if ($platforms{$platform}{cab}) {
print "XCSoar$platform.$proc.CAB\n";
rename "XCSoar$platform.$proc.CAB", "dist/XCSoar$platform.$proc.$version_file.cab"
or error("Unable to move CAB file $!\n\tXCSoar$platform.$proc.cab\n");
}
}
}
# Rename EXE files
foreach my $platform (@platforms_all) {
if ($platforms{$platform}{cab}) {
if (!$gcc) {
rename "InstallXCSoar-$platform.exe", "dist/InstallXCSoar-$platform.$version_file.exe"
or error("Unable to move EXE file $!\n\tInstallXCSoar-$platform.exe\n");
} else {
# rename "XCSoar-$platform.exe", "dist/XCSoar-$platform.$version_file.exe"
# or error("Unable to move EXE file $!\n\tXCSoar-$platform.exe\n");
# if ($platforms{$platform}{sim}) {
# rename "XCSoarSimulator-$platform.exe", "dist/XCSoarSimulator-$platform.$version_file.exe"
# or error("Unable to move EXE file $!\n\tXCSoarSimulator-$platform.exe\n");
# }
}
} else {
if ($platform eq "ALTAIR") {
rename "XCSoar-$platform.exe","XCSoarAltair-$version_num-CRC3E.exe";
system("/opt/upx-3.03-amd64_linux/upx XCSoarAltair-$version_num-CRC3E.exe");
system("cp PPC2003/GRecordDll.dll GRecordDLL.dat");
system("zip -r XCSoarAltair-$version_file.zip XCSoarAltair-$version_num-CRC3E.exe GRecordDLL.dat");
rename "XCSoarAltair-$version_file.zip","dist/XCSoarAltair-$version_file.zip";
} elsif ($platform eq "ALTAIRPORTRAIT") {
rename "XCSoar-$platform.exe","XCSoarAltair-$version_num-CRC3E.exe";
system("/opt/upx-3.03-amd64_linux/upx XCSoarAltair-$version_num-CRC3E.exe");
system("cp PPC2003/GRecordDll.dll GRecordDLL.dat");
system("zip -r XCSoarAltairPortrait-$version_file.zip XCSoarAltair-$version_num-CRC3E.exe GRecordDLL.dat");
rename "XCSoarAltairPortrait-$version_file.zip","dist/XCSoarAltairPortrait-$version_file.zip";
} else {
if ($platforms{$platform}{sim}) {
if ($platform eq "PC") {
system("/opt/upx-3.03-amd64_linux/upx XCSoarSimulator-PC.exe");
system("/opt/upx-3.03-amd64_linux/upx XCSoar-PC.exe");
system("zip -r XCSoar$platform-$version_file.zip XCSoar-PC.exe XCSoarSimulator-PC.exe");
rename "XCSoar$platform-$version_file.zip","dist/XCSoar$platform-$version_file.zip";
} else {
rename "XCSoarSimulator-$platform.exe", "XCSoarSimulator.exe"
or error("Unable to move EXE file $!\n\tXCSoarSimulator-$platform.exe\n");
rename "XCSoar-$platform.exe","XCSoar.exe"
or error("Unable to move EXE file $!\n\tXCSoar-$platform.exe\n");
system("zip -r XCSoar$platform-$version_file.zip XCSoar.exe XCSoarSimulator.exe");
rename "XCSoar$platform-$version_file.zip","dist/XCSoar$platform-$version_file.zip";
}
} else {
rename "XCSoar-$platform.exe","XCSoar.exe"
or error("Unable to move EXE file $!\n\tXCSoar-$platform.exe\n");
system("zip -r XCSoar$platform-$version_file.zip XCSoar.exe");
rename "XCSoar$platform-$version_file.zip","dist/XCSoar$platform-$version_file.zip";
}
}
}
}
# --------------
# Clean after build
if (!$gcc && !$noclean) {
foreach my $platform (keys %platforms) {
foreach my $project (@projects) {
foreach my $proc (@{$platforms{$platform}{'proc'}}) {
my $cmd = q{"} . $execs{$platforms{$platform}{'exec'}}{evc} . q{" }
. qq{$platform/$project/$project.vcp /MAKE "$project - Win32 (WCE $proc) Release" /CLEAN};
print STDERR "Clean $project for $platform/$proc\n";
print STDERR "\t$cmd\n" if ($debug);
system($cmd) and error("Executing Command - $?\n\t$cmd\n");
}
}
}
}
# ------------------------------------------------------------------------------
# Upload and Announce
# ------------------------------------------------------------------------------
# TODO - Upload to Sourceforge (optional)
# TODO - Announce to lists & Freshmeat etc
print STDERR "PROCESSING COMPLETE: $errors errors\n";
exit 0;
sub error {
my ($msg) = @_;
print STDERR "ERROR: $msg\n";
print STDERR "Continue (Y/N)? ";
my $A = <STDIN>;
unless (uc(substr($A, 0, 1)) eq "Y") {
print STDERR "PROCESSING INCOMPLETE!\n";
exit 1;
}
$errors++;
}
__END__
=====
NOTES
=====
EVC Help
Usage:
EVC [myprj.vcp|mywksp.vcw] - load project/workspace
[<filename>] - load source file
/? - display usage information
/EX <macroname> - execute a VBScript macro
/OUT <filename> - redirect command line output to a file
/USEENV - ignore tools.options.directories settings
/MAKE [<target>] [...] - build specified target(s)
[<project> - <platform> <configname>]
[[<project>|ALL] - [DEBUG|RELEASE|ALL]]
/CLEAN - delete intermediate files but don't build
/REBUILD - clean and build
/NORECURSE - don't build dependent projects
/CECONFIG [<configuration>] - use specified configuration