-
Notifications
You must be signed in to change notification settings - Fork 84
/
buildit
executable file
·1270 lines (1126 loc) · 36.3 KB
/
buildit
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/perl
#
# This file is part of the Jikes RVM project (http://jikesrvm.org).
#
# This file is licensed to You under the Eclipse Public License (EPL);
# You may not use this file except in compliance with the License. You
# may obtain a copy of the License at
#
# http://www.opensource.org/licenses/eclipse-1.0.php
#
# See the COPYRIGHT.txt file distributed with this work for information
# regarding copyright ownership.
#
# This is not the standard supported way of building. This is a helper
# script to faciliate testing and building of many builds across
# multiple machines.
#
# This script can be dangerous. Be CAREFUL.
#
# Comments and suggestions on how to improve this script are most welcome.
#
use strict;
use warnings;
my $shortusage =
"Usage: buildit [-dhgqpz] [-r root] [-s suffix] [-j java-home]
[--test-run xxx] build-host [-c target-host] [ Configs... ]
";
my $usage = $shortusage."Building:
buildit <Option(s)> build-host [-c target-host] <Config(s)>
Eclipse Project:
buildit --eclipse build-host
MMTk Harness Eclipse Project:
buildit --mmtk-eclipse build-host
Testing:
buildit <Option(s)> -t test build-host [-c target-host] [<Config(s)>]
for example:
buildit -t dacapo host production
buildit <Option(s)> --test-run test-run build-host
for example:
buildit --test-run pre-commit host
Configuration is specified as either:
- a specific configuration, such as
buildit <Option(s)> build-host -c target-host development
- a single compiler and N gcs, such as
buildit <Option(s)> build-host -c target-host BaseBase MarkSweep SemiSpace
Tests can be run as either:
- build and run a complete test run as specified in the test file
buildit <Option(s)> --test-run xxx build-host target-host
- build and run the test run from the test file on a different Configuration
buildit <Option(s)> --test-run xxx build-host -c target-host <Config(s)>
- build and run the test(s) specified on the command line
buildit <Option(s)> -t test build-host -c target-host <Config(s)>
buildit <Option(s)> -t test1 -t test2 ...
Options:
--nuke Nuke the build and target host roots (rm -rf *)
--clear-cache Clear configuration cache
-d, --dry-run Dry run, just print commands
--build-user Specify a username for the build host
--target-user Specify a username for the target host
-u, --user Specify a username for both hosts
-h, --help Show this usage message
--ulimit Specify resource usage limits for the build (arg passed verbatim to 'ulimit')
Building Options:
--x87 Use x87 Compatibility mode.
--m32, --m64 Force use of 32- or 64-bit addressing in the build
-c, --cross-to Crossbuild to target host (or copy post build).
--with-perfevent Build with perf event support
-a, --with-acheck Build with align checks, implies --x87 --processors 1
-g, --gdb-symbols Build with gdb symbols
-q, --quick Quick build (not 100% safe - doesn't regenerate source)
--classpath-git Build from classpath git HEAD
-r, --root Specify rvm root on the commandline, chosen by:
-r root option if specified, otherwise;
\$RVM_ROOT environment variable if set, otherwise;
current directory, equivalent to -r .
-s, --suffix Append a suffix to the build name
-m, --mmtk-config MMTk properties (included in suffix)
-j, --java-home Specify a JAVA_HOME directory to use
--eclipse Build an eclipse project (and bring it back to this machine)
--mmtk-eclipse Build an eclipse project using the MMTk Harness (and bring it back to this machine)
--build-arg Specify an additional argument for the ant build
--bc-arg Specify arguments for the bootimage compiler
--checkstyle Perform source code style checks.
--test-image Run unit tests on the built RVM image and fail the build if the tests fail
-p, --profile Perform a profiled build (including creation of a profile)
--comp-cache-dir Specify a cache location for component downloads
--clear-cc Clear out the component caches
--harmony Build with harmony (instead of classpath)
--openjdk Build with OpenJDK libraries (instead of classpath)
--answer-yes Answer yes for all messages from the script that require confirmation. This option may be useful for headless builds.
--timestamp-file Print contents of the timestamp file at the beginning and end of the build
Note: Cross-building (i.e. different host and target is not supported by this option)
--host-name Use the argument for host.name instead of reading it from the config file
Use in conjunction with --target-name.
--target-name Use the argument for target.name instead of reading it from the config file
Use in conjunction with --host-name.
Testing Options:
-t, --test Specify a test to run (overriden by --test-run)
-n, --name Give the results run a name, link in results/buildit
--test-run The test run to use for each configuration on the target
--test-arg Specify additional arguments(s) for the test
--run-arg Specify an additional argument for the test execution
--email-report Send a result summary email when done
--ext-lib-dir Specify the benchmarks directory for testing.
--processors Specify the number of processors to use.
-z, --skip-build Run tests without building
--save-space Keep only archived results on the local machine and throw away the rest
";
#
# Load configuration and cache
#
my $baseConfigFile = $0.".base_config";
my $configFile = home_dir()."/.buildit_config";
my $cacheFile = home_dir()."/.buildit_cache";
my %config;
my $config;
load_config($baseConfigFile);
load_config($configFile);
# Benchmarks directory
my $extlibdir=$config{"global.ext.lib.dir"};
# Components download cache
my $compcachedir=$config{"global.components.cache.dir"};
# Upload Information
my $upload_base=$config{"global.upload.base"};
my $upload_host=$config{"global.upload.host"};
my $web_base=$config{"global.upload.url"};
# Email Server
my $mailserver=$config{"global.mail.server"};
# Execution environment
my $xvfb_run=$config{"global.display-wrapper.exe"};
my $shell=$config{"global.shell"};
use Cwd 'abs_path';
use Getopt::Long qw(:config no_auto_abbrev bundling);
# Define all options
my $suffix;
my $mmtk_config;
my $custom_host_name;
my $custom_target_name;
my $nuke;
my $answeryes;
my $target;
my $checkstyle;
my $test_image;
my $profile;
my $cmd_user;
my $cmd_hostUser;
my $cmd_ulimit;
my $eclipse;
my $mmtk_eclipse;
my $cmd_targetUser;
my $git_head;
my $gdb_symbols;
my @test_arg_array;
my $test_set;
my @test_array;
my @build_array;
my $results_name;
my @run_array;
my @bcarg_array;
my $dry_run;
my $clear_cache;
my $root;
my $quick;
my $procs;
my $with_perfevent;
my $with_acheck;
my $skip_build;
my $save_space;
my $help;
my $x87;
my $m32;
my $m64;
my $harmony;
my $openjdk;
my $javaHomeCmd;
my $clearcc;
my $timestampfile;
my $email_report;
GetOptions(
"s|suffix=s" => \$suffix,
"m|mmtk-config=s" => \$mmtk_config,
"host-name=s" => \$custom_host_name,
"target-name=s" => \$custom_target_name,
"nuke" => \$nuke,
"answer-yes" => \$answeryes,
"c|cross-to=s" => \$target,
"checkstyle" => \$checkstyle,
"test-image" => \$test_image,
"p|profile" => \$profile,
"u|user=s" => \$cmd_user,
"build-user=s" => \$cmd_hostUser,
"ulimit=s" => \$cmd_ulimit,
"eclipse" => \$eclipse,
"mmtk-eclipse" => \$mmtk_eclipse,
"target-user=s" => \$cmd_targetUser,
"classpath-git" => \$git_head,
"g|gdb-symbols" => \$gdb_symbols,
"test-arg=s" => \@test_arg_array,
"test-run=s" => \$test_set,
"t|test=s" => \@test_array,
"build-arg=s" => \@build_array,
"n|name=s" => \$results_name,
"run-arg=s" => \@run_array,
"bc-arg=s" => \@bcarg_array,
"d|dry-run" => \$dry_run,
"clear-cache" => \$clear_cache,
"r|root=s" => \$root,
"q|quick" => \$quick,
"processors=s" => \$procs,
"with-perfevent" => \$with_perfevent,
"a|with-acheck" => \$with_acheck,
"z|skip-build" => \$skip_build,
"save-space" => \$save_space,
"h|help" => \$help,
"x87" => \$x87,
"m32" => \$m32,
"m64" => \$m64,
"harmony" => \$harmony,
"openjdk" => \$openjdk,
"j|java-home=s" => \$javaHomeCmd,
"ext-lib-dir=s" => \$extlibdir,
"comp-cache-dir=s" => \$compcachedir,
"clear-cc" => \$clearcc,
"timestamp-file=s" => \$timestampfile,
"e|email-report" => \$email_report) or bad_usage();
if ($with_acheck) {
$x87 = $with_acheck;
$procs = "1";
}
if ($clear_cache) {
unlink($cacheFile);
}
load_config($cacheFile);
my $test_list = join(" ", @test_array);
my $build_args = join(" ", @build_array);
my $run_args = join(" ", @run_array);
my $test_args = join(" ", @test_arg_array);
my $bc_args = join(" ", @bcarg_array);
my $start = `date`;
chomp($start);
my $host = shift(@ARGV);
my $compiler = shift(@ARGV);
my @gcs = @ARGV;
if (!defined $target) {
$target = $host;
}
if (!defined $results_name) {
$results_name = "latest";
}
if (!defined $shell) {
$shell = "/bin/bash --login -c ";
}
sub getid();
my $testsid = getid();
# The -h option
if ($help) {
print($usage);
exit();
}
if (!defined $root) {
if (defined $ENV{RVM_ROOT}) {
$root = $ENV{RVM_ROOT};
} else {
$root = abs_path(".");
}
}
if ($host eq "") {
bad_usage("build-host not specified");
}
if ($target eq "") {
bad_usage("target-host not specified");
}
if ($root eq "") {
bad_usage("rvm root is not specified");
}
if (defined $m64 && defined $m32) {
bad_usage("Only one of --m64 and --m32 can be specified");
}
my $local = `hostname`;
chomp($local);
if ($host eq "localhost") {
$host = $local;
}
if ($target eq "localhost") {
$target = $local;
}
my $hostUser = undef;
my $targetUser = undef;
if (defined $cmd_hostUser) {
$hostUser = $cmd_hostUser;
} elsif (defined $cmd_user) {
$hostUser = $cmd_user;
} elsif (defined $config{"$host.user"}) {
$hostUser = $config{"$host.user"};
}
if (defined $cmd_targetUser) {
$targetUser = $cmd_targetUser;
} elsif (defined $cmd_user) {
$targetUser = $cmd_user;
} elsif (defined $config{"$target.user"}) {
$targetUser = $config{"$target.user"};
}
my $sshHost = defined($hostUser) ? $hostUser."@".$host : $host;
my $sshHostCmd = "ssh $sshHost";
my $sshHostCmdT = "ssh $sshHost -t";
my $sshTarget = defined($targetUser) ? $targetUser."@".$target : $target;
my $sshTargetCmd = "ssh $sshTarget";
my $sshTargetCmdT = "ssh $sshTarget -t";
if ($host eq $local) {
$sshHostCmd = $shell;
$sshHostCmdT = $shell;
}
if ($target eq $local) {
$sshTargetCmd = $shell;
$sshTargetCmdT = $shell;
}
my $localHome;
if (defined $config{"$local.home"}) {
$localHome = $config{"$local.home"};
} else {
$localHome = abs_path(home_dir());
}
my $hostHome;
if (defined $config{"$host.home"}) {
$hostHome = $config{"$host.home"};
} else {
if ($host eq $local) {
$hostHome = $localHome;
} else {
$hostHome = `ssh $sshHost pwd`;
chomp($hostHome);
}
}
my $targetHome;
if (defined $config{"$target.home"}) {
$targetHome = $config{"$target.home"};
} else {
if ($target eq $local) {
$targetHome = $localHome;
} else {
$targetHome = `ssh $sshTarget pwd`;
chomp($targetHome);
}
}
my $localCompCache;
my $hostCompCache;
my $targetCompCache;
if ($compcachedir ne "") {
if (defined $config{"$local.components.cache"}) {
$localCompCache = $config{"$local.components.cache"};
} else {
$localCompCache = $localHome."/".$compcachedir;
}
if (defined $config{"$host.components.cache"}) {
$hostCompCache = $config{"$host.components.cache"};
} else {
$hostCompCache = $hostHome."/".$compcachedir;
}
if (defined $config{"$target.components.cache"}) {
$targetCompCache = $config{"$target.components.cache"};
} else {
$targetCompCache = $targetHome."/".$compcachedir;
}
}
my $localRoot = abs_path($root);
$localRoot =~ s/^$localHome/~/;
my $hostRoot = $localRoot;
my $targetRoot = $localRoot;
$localRoot =~ s/^~/$localHome/;
$hostRoot =~ s/^~/$hostHome/;
$targetRoot =~ s/^~/$targetHome/;
if (! -e $localRoot . "/rvm") {
bad_usage("rvm root does not point to a valid source tree");
}
my $hostConfig;
my @host_info;
if (defined $custom_host_name) {
$hostConfig = $custom_host_name;
} else {
if (defined $config{"$host.host-type"}) {
$hostConfig = $config{"$host.host-type"};
} else {
my $unameOutput = `$sshHostCmd 'uname -ms'`;
@host_info = split(/ /, $unameOutput);
chomp(@host_info);
$hostConfig = $config{"global.arch.".$host_info[1]}."-".$config{"global.os.".$host_info[0]};
}
my ($arch, $os) = split(/-/,$hostConfig);
$hostConfig = get_word_variant($arch)."-$os";
}
my $targetConfig;
if (defined $custom_target_name) {
$targetConfig = $custom_target_name;
} elsif (defined $config{"$target.host-type"}) {
$targetConfig = $config{"$target.host-type"};
my ($arch, $os) = split(/-/,$targetConfig);
$targetConfig = get_word_variant($arch)."-$os";
} else {
my @target_info = split(/ /, `$sshTargetCmd 'uname -ms'`);
chomp(@target_info);
my $arch = get_word_variant($config{"global.arch.".$target_info[1]});
$targetConfig = $arch."-".$config{"global.os.".$target_info[0]};
}
if (!defined $config{"$local.home"}) {
confirm("Is $localHome the right home directory for $local?");
cache_data("$local.home", $localHome);
}
if (!defined $config{"$host.home"}) {
confirm("Is $hostHome the right home directory for $host?");
cache_data("$host.home", $hostHome);
}
if ($config{"$target.home"} eq "" && $host ne $target) {
confirm("Is $targetHome the right home directory for $target?");
cache_data("$target.home", $targetHome);
}
if (!defined $config{"$host.host-type"}) {
confirm("Is $hostConfig the right type for $host?");
cache_data("$host.host-type", $hostConfig);
}
if (!defined $config{"$target.host-type"} && $host ne $target) {
confirm("Is $targetConfig the right type for $target?");
cache_data("$target.host-type", $targetConfig);
}
if (!defined $config{"$local.$localRoot"}) {
confirm("Is $localRoot the correct root directory here?");
cache_data("$local.$localRoot", "OK");
}
if (!defined $config{"$host.$hostRoot"}) {
confirm("Is $hostRoot the correct root directory on $host?\nBe CAREFUL as we are going to rsync --delete to there!");
cache_data("$host.$hostRoot", "OK");
}
if (!defined $config{"$target.$targetRoot"} && $host ne $target) {
confirm("Is $targetRoot the correct root directory on $target?\nBe CAREFUL as we are going to rsync --delete to there!");
cache_data("$target.$targetRoot", "OK");
}
my %javaHome;
if (! defined $javaHomeCmd) {
$javaHome{$host} = $config{"global.javahome.".$hostConfig};
$javaHome{$target} = $config{"global.javahome.".$targetConfig};
} else {
$javaHome{$host} = $javaHomeCmd;
$javaHome{$target} = $javaHomeCmd;
}
if ($extlibdir eq "") {
bad_usage("ext.lib.dir not specified");
}
if ($javaHome{$host} eq "") {
bad_usage("Host java home not specified. Use -j JAVAHOME or set global.javahome.$hostConfig in ~/.buildit_config");
}
if ($javaHome{$target} eq "") {
bad_usage("Target java home not specified");
}
if (! -e $localRoot."/build/hosts/".$hostConfig.".properties") {
bad_usage("Couldn't find build-host config for $host '@host_info'");
}
if (! -e $localRoot."/build/targets/".$targetConfig.".properties") {
bad_usage("Couldn't find target-host config for $target '$targetConfig'");
}
if (defined $test_set) {
if (! -e $localRoot."/build/test-runs/".$test_set.".properties") {
bad_usage("Couldn't find test-set '$test_set'");
}
}
if ($test_list ne "") {
my @tests = split(" ", $test_list);
my $test;
foreach $test (@tests) {
if (! -d $localRoot."/testing/tests/$test") {
bad_usage("Couldn't find test '$test'");
}
}
}
#
# Configuration
#
# Read out test-run properties that affect the build config (e.g. for checkstyle and
# unit tests on the images) and add them to the build arguments.
#
# Those properties would be ignored otherwise because buildit always skips builds in test-runs.
if ($test_set && !$checkstyle) {
$checkstyle = `grep ^require.checkstyle=true\$ $localRoot/build/test-runs/$test_set.properties`;
chomp($checkstyle);
if ($checkstyle ne "") {
$checkstyle = 1;
}
}
if ($test_set && !$test_image) {
$test_image = `grep ^require.rvm-unit-tests=true\$ $localRoot/build/test-runs/$test_set.properties`;
chomp($test_image);
if ($test_image ne "") {
$test_image = 1;
}
}
my $implicitconfigs = ($#gcs == -1 && !defined $compiler);
if ($#gcs == -1 && $test_set && !defined $compiler) {
my $rawconfigs = `grep \"^test.configs=.*$\" $localRoot/build/test-runs/$test_set.properties`;
chomp($rawconfigs);
$rawconfigs =~ s/^test.configs=//;
$compiler="";
my $baseconfigs = " ";
foreach $config (split(" ", $rawconfigs)) {
my $search = "test.config.$config.configuration=";
my $baseconfig = `grep \"^$search.*$\" $localRoot/build/test-runs/$test_set.properties`;
chomp($baseconfig);
if ($baseconfig eq "") {
$baseconfig = $config;
} else {
$baseconfig =~ s/^$search//;
}
if($baseconfigs !~ / $baseconfig /) {
$baseconfigs = $baseconfigs.$baseconfig." ";
}
}
$baseconfigs =~ s/^ //;
@gcs = split(" ", $baseconfigs);
}
if ($#gcs == -1) {
if ($eclipse && !defined $compiler) {
$compiler = "production";
}
if ($mmtk_eclipse && !defined $compiler) {
$compiler = "prototype-opt";
}
if ($compiler ne "") {
@gcs = ( $compiler );
$compiler = "";
} else {
bad_usage("Need at least one configuration");
}
}
foreach my $g (@gcs) {
$config = $compiler.$g;
if (! -e $localRoot."/build/configs/".$config.".properties") {
bad_usage("Could not find configuration '$config'");
}
}
# The -m option
if (defined $mmtk_config) {
if (! -e $localRoot."/build/mmtk/".$mmtk_config.".properties") {
bad_usage("Could not find MMTk properties '$mmtk_config'");
}
$suffix .= $mmtk_config;
}
my $report_email="";
if ($email_report) {
if ($config{"global.report-email"} ne "") {
$report_email = $config{"global.report-email"};
} else {
print "Please enter the email address for reporting...\nreport_email : ";
$report_email = <STDIN>;
chomp($report_email);
confirm("Is $report_email correct?");
$report_email =~ s/\@/\\\@/;
cache_data("global.report-email", $report_email);
}
}
my $bindir = "bin";
my $configdir = "config";
my $sourcedirs = "";
#
# The files that need to be transferred to a host in order to do a build
#
my @dirs = ("rvm", "MMTk", "bin", "build", "testing", "tools", "tools-external",
"common", "build.xml", "libraryInterface", "external", "test.xml");
#
# The files needed to be transferred to a host in order to complete a
# cross-compiled build
#
# Plus the particular 'target' subdirectory.
#
my @ccdirs = ("build.xml", "build");
my $dir;
foreach $dir (@dirs) {
if (-e $localRoot."/".$dir) {
$sourcedirs .= " $localRoot/$dir";
}
}
#
# Test connectivity
#
if (! defined $config{"$host.tested"} && $host ne $local) {
print "Testing build-host connectivity... ";
if (!system("$sshHostCmd echo OK")) {
cache_data("$host.tested", "OK");
}
}
if (! defined $config{"$target.tested"} && $target ne $local) {
print "Testing target-host connectivity... ";
if (!system("$sshTargetCmd echo OK")) {
cache_data("$target.tested", "OK");
}
}
if ($host ne $target && $config{"$host-$target.tested"} eq "") {
print "Testing build-host -> target-host connectivity... ";
if (!system("$sshHostCmdT 'ssh $sshTarget echo OK'")) {
cache_data("$host-$target.tested", "OK");
}
}
if (defined $upload_host && $config{"$target-$upload_host.tested"} eq "") {
print "Testing target-host -> upload-host connectivity... ";
if (!system("$sshTargetCmdT 'ssh $upload_host -t echo OK'")) {
cache_data("$target-$upload_host.tested", "OK");
}
}
#
# Timestamp (pre-build)
#
if (defined $timestampfile) {
my $timestampCmd = "$sshHostCmd 'echo -n \"Contents of timestamp file (pre build): \"; cat $timestampfile ; echo \n'";
print "$timestampCmd\n";
if (! $dry_run) {
system ($timestampCmd);
}
}
#
# Clean up first ?
#
if ($nuke && $target ne $local) {
my $nukecmd = "$sshHostCmdT rm -rf $hostRoot;\n";
if ($host ne $target) {
$nukecmd = "$sshTargetCmdT rm -rf $targetRoot;\n";
}
print "$nukecmd\n\n";
if (! $dry_run) {
system ($nukecmd);
}
}
#
# Now do it!
#
my $mkccRet = 0;
if ($compcachedir) {
my $mkcc;
if (! -d $localCompCache) {
$mkcc = "mkdir -p $localCompCache";
} elsif (defined $clearcc) {
$mkcc = "rm -rf $localCompCache/*";
}
if (defined $mkcc) {
print "$mkcc\n\n";
if (! $dry_run) {
$mkccRet = system ($mkcc);
}
}
}
my $ok = ($mkccRet == 0);
my $rsyncRet = 0;
my $rsync;
if ($ok) {
if ($host ne $local) {
$rsync .= "ssh $sshHost -t mkdir -p $hostRoot;\n";
if ($compcachedir ne "") {
$rsync .= "ssh $sshHost -t mkdir -p $hostCompCache;\n";
$rsync .= "rsync -azvLe ssh --delete $localCompCache/ $sshHost:$hostCompCache/;\n";
}
$rsync .= "rsync -azvLe ssh --delete --exclude=\*.class ".$sourcedirs." $sshHost:$hostRoot";
if ($host ne $target) {
$rsync .= ";\nssh $sshTarget -t mkdir -p $targetRoot/dist";
if ($hostConfig ne $targetConfig) {
$rsync .= ";\nrsync -azvLe ssh --delete --exclude=\*.class ".$sourcedirs." $sshTarget:$targetRoot";
if ($compcachedir ne "") {
$rsync .= ";\nssh $sshTarget -t mkdir -p $targetCompCache;\n";
$rsync .= "rsync -azvLe ssh --delete $localCompCache/ $sshTarget:$targetCompCache;\n";
}
}
}
print "$rsync\n\n";
if (! $dry_run) {
$rsyncRet = system ($rsync);
}
}
}
$ok = $ok && ($rsyncRet == 0);
#
# Additional ant flags for building classpath
#
my $cp_flags = "";
if ($git_head) {
$cp_flags .= "-Dclasspath.from-git=true ";
}
my $rvm_revision=`git rev-parse HEAD`;
chomp($rvm_revision);
my $build;
my %retval;
my %date;
if ($ok) {
foreach my $g (@gcs) {
$_ = $g;
$config = "$compiler$g";
# Principal "-D" defines for ant
my $defs = "-Dtarget.name=$targetConfig ".
"-Dconfig.name=$config ".
"-Dgit.revision=$rvm_revision ";
my $targetDir;
if (defined $suffix) {
$defs .= "-Dconfig.variant=$suffix ";
$targetDir = $config."_".$suffix."_".$targetConfig;
} else {
$targetDir = $config."_".$targetConfig;
}
if (defined $checkstyle) {
$defs .= "-Drequire.checkstyle=true ";
}
if (defined $test_image && $test_image ne "") {
$defs .= "-Drequire.rvm-unit-tests=true ";
}
if (defined $x87) {
$defs .= "-Dtarget.arch.sse2=none ";
}
if (defined $harmony) {
$defs .= "-Dclasslib.provider=Harmony ";
}
if (defined $openjdk) {
$defs .= "-Dclasslib.provider=OpenJDK ";
}
if (defined $with_perfevent) {
$defs .= "-Dconfig.include.perfevent=true ";
}
if (defined $with_acheck) {
$defs .= "-Dconfig.alignment-checking=true ";
}
if (defined $mmtk_config && $mmtk_config ne "") {
$defs .= "-Dconfig.mmtk=$mmtk_config ";
}
if (defined $gdb_symbols) {
$defs .= "-Drvm.debug-symbols=true ";
}
if (defined $build_args && $build_args ne "") {
$defs = $defs." ".$build_args." ";
}
if (defined $profile) {
$defs = $defs." profiled-image ";
}
if (defined $bc_args && $bc_args ne "") {
$defs = $defs."-Dconfig.bootimage.compiler.args=\\\"$bc_args\\\" ";
}
my $hostdefs = $defs."-Dhost.name=$hostConfig ";
my $targetdefs = $defs."-Dhost.name=$targetConfig ";
if (defined $compcachedir) {
$hostdefs .= "-Dcomponents.cache.dir=$hostCompCache ";
$targetdefs .= "-Dcomponents.cache.dir=$targetCompCache ";
}
#
# Build classpath on host
#
$build = "";
my $ulimit = "";
if (defined $cmd_ulimit && $cmd_ulimit ne "") {
$ulimit = "ulimit $cmd_ulimit; "
}
if ($skip_build) {
$build .= "echo Skipping build ";
} else {
$build .= "$sshHostCmdT '$shell \"$ulimit ".
" cd $hostRoot &&".
" export JAVA_HOME=$javaHome{$host} && ";
if (! $quick) {
$build .= " ant very-clean -Dhost.name=$hostConfig &&";
}
$build .= " ant check-components-properties ".
"-Dhost.name=$hostConfig ".
"-Dtarget.name=$hostConfig ";
if ($compcachedir ne "") {
$build .= "-Dcomponents.cache.dir=$hostCompCache ";
}
$build .= $cp_flags." && ";
#
# Initial build
#
if ($eclipse) {
$build .= " ant eclipse-project $hostdefs";
} elsif ($mmtk_eclipse) {
$build .= " ant mmtk-harness-eclipse-project $hostdefs";
} elsif ($hostConfig eq $targetConfig) {
$build .= " ant $hostdefs";
} else {
$build .= " ant cross-compile-host $hostdefs";
}
$build .= "\"' ";
if ($compcachedir ne "" && $host ne $local) {
$build .= "&& rsync -azvLe ssh --delete $sshHost:$hostCompCache/ $localCompCache/ ";
}
}
#
# Cross-builds
#
if ($eclipse || $mmtk_eclipse) {
if ($host ne $local) {
$build .= "&& rsync -azvLe ssh --delete $sshHost:$hostRoot/eclipse $localRoot/ ";
$build .= "&& rsync -azvLe ssh --delete $sshHost:$hostRoot/.project $localRoot/ ";
$build .= "&& rsync -azvLe ssh --delete $sshHost:$hostRoot/.classpath $localRoot/ ";
if ($mmtk_eclipse) {
$build .= "&& rsync -azvLe ssh --delete $sshHost:$hostRoot/generated $localRoot/ --include=mmtk-harness-parser ";
}
}
} elsif ($host ne $target) {
if ($compcachedir ne "" && $target ne $local) {
$build .= "&& rsync -azvLe ssh --delete $localCompCache/ $sshTarget:$targetCompCache/ ";
}
$build .= "&& ".
"$sshTargetCmdT 'mkdir -p $targetRoot/dist && ".
"mkdir -p $targetRoot/target' &&";
if ($hostConfig eq $targetConfig) {
#
# Same architecture: just copy the dist directory
#
$build .= "$sshHostCmdT 'rsync -avze ssh --delete $hostRoot/dist/$targetDir/ ";
$build .= " $sshTarget:$targetRoot/dist/$targetDir/ ' ";
} else {
# Copy the compiled classes and boot image
$build .= "$sshHostCmdT '".
" rsync -avze ssh --delete $hostRoot/target/$targetDir/ ".
" $sshTarget:$targetRoot/target/$targetDir/ &&".
" rsync -avze ssh --delete $hostRoot/dist/$targetDir/ ".
" $sshTarget:$targetRoot/dist/$targetDir/ &&";
my $copydirs = "";
foreach my $d (@ccdirs) {
$copydirs .= " $hostRoot/$d";
}
$build .= " rsync -avze ssh --delete $copydirs $sshTarget:$targetRoot/' &&";
#
# post-processing for cross-compile
#
# For the classpath build, the host is now the target ;)
$build .= "$sshTargetCmdT '$shell \"".
" cd $targetRoot && ".
" export JAVA_HOME=$javaHome{$target} && ";
$build .= " ant check-components-properties ".
"-Dhost.name=$targetConfig ".
"-Dtarget.name=$targetConfig ";
if ($compcachedir ne "") {
$build .= "-Dcomponents.cache.dir=$targetCompCache ";
}
$build .= $cp_flags." && ";
$build .= " ant cross-compile-target $targetdefs \"'";
}
if ($compcachedir ne "" && $target ne $local) {
$build .= " && rsync -azvLe ssh --delete $sshTarget:$targetCompCache/ $localCompCache/ ";
}
}
print "---> Config: $compiler$g\n";
print "$build\n";
if (! $dry_run) {
$retval{$g} = system($build);
$ok = $ok && ($retval{$g} == 0);
}
$date{$g} = `date`;
chomp($date{$g});
print $date{$g}."\n";
}
}
my $resultdir = "results/buildit/".$testsid;
my $uploaddir;
if (defined $upload_base) {
$uploaddir = $upload_base.$resultdir;
}
my $webdir;
if (defined $web_base) {
$web_base = $web_base.$resultdir;
}
if ($ok && (defined $test_set || defined $test_list)) {
my $configs="";
foreach my $g (@gcs) {
$configs = $configs." ".$compiler.$g;
}
$configs =~ s/^ //;
my $test = "$sshTargetCmdT \"$shell \\\" ".
" cd $targetRoot && ".
" mkdir -p $resultdir && ".
" rm -rf results/buildit/latest && ".
" ln -s $testsid results/buildit/latest && ".
" export JAVA_HOME=$javaHome{$target} && ".
" ant -f test.xml ".
"-Dhost.name=$targetConfig ".
"-Dgit.revision=$rvm_revision ".
"-Dskip.build=true ".
"-Dexternal.lib.dir=$extlibdir ".
"-Dresults.dir=$targetRoot/$resultdir ";
if ($compcachedir ne "") {
$test .= "-Dcomponents.cache.dir=$targetCompCache ";
}
if (defined $suffix && $suffix ne "") {
$test .= "-Dconfig.variant=$suffix ";
}
if ($xvfb_run ne "") {
$test .="-Ddisplay-wrapper.exe=$xvfb_run ";
}
if($report_email ne "") {
$test .= "-Dmail.from=$report_email ".
"-Dmail.to=$report_email ".
"-Dmail.host=$mailserver ".
"-Dsend.reports=true ".
"-Dweb.directory=$webdir ".
"-Dreporting.host.name=$target ";