-
Notifications
You must be signed in to change notification settings - Fork 0
/
korvo_build.pl
875 lines (810 loc) · 28.7 KB
/
korvo_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
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
#!perl
#
#
# This script builds and optionally tests GTKorvo projects. What is built and how it is build is controlled by
# the build_config file. This file is either supplied on the command line
# with a -c argument, or searched for in '.', or '$HOME'. If the korvo_arch script is found, or if a -a
# argument is specified, then the file 'build_config.$KORVO_ARCH' is
# prefered. Alternatively, 'build_config.$HOSTNAME' (where $HOSTNAME is
# the output of the hostname command) is prefered over simple
# 'build_config'. By default the script produces a moderate amount of
# output, which can be suppressed with '-q' or enhanced with '-v'.
#
# Further documentation can be found in the supplied sample build_config file.
#
use strict;
use warnings;
use Cwd;
use File::Basename;
use File::Spec;
use 5.010;
my $script_pwd = getcwd;
my $enable_testing = 1;
my $verbose = 0;
my $quiet = 0;
my $BUILD_CONFIG = "";
my $enable_debug_build = 0;
my $ARCH = "";
my $build_config_open = 0;
our %korvo_tag;
my ($RESULTS_FILES_DIR, $BUILD_AREA, $EVPATH_TEST_INSTALL_DIR, $VERSION_TAG, $INSTALL_DIRECTORY, @projects);
my (%spec, %tool, %cmake_args, %config_args, $OVERRIDE_VERSION, $OVERRIDE_DISABLE_TESTING, $stop_on_failure);
$OVERRIDE_DISABLE_TESTING = 0;
until ( ! @ARGV ) {
$_ = $ARGV[0];
last if /^--$/;
if(/^-v/) { $verbose++ }
elsif(/^-q/) { $quiet++;}
elsif(/^--stop_on_failure/) {$stop_on_failure=1;}
elsif(/^-a/) { $ARCH=$ARGV[1]; shift; }
elsif(/^-V/) { $OVERRIDE_VERSION=$ARGV[1]; shift; }
elsif(/^-D/) { $OVERRIDE_DISABLE_TESTING++; }
elsif(/^--debug/) { $enable_debug_build++; }
elsif(/^-c/) { $BUILD_CONFIG=$ARGV[1]; shift; }
else {
print "Unknown argument \"$_\"\n";
print "Arguments:\n";
print "\t -v \t verbose\n";
print "\t -q \t quiet\n";
print "\t -a <arch> \t what sets the \$ARCH value\n";
print "\t --debug \t build with debug (override build_config)\n";
print "\t -c <config_file> \t file to use as build_config\n";
print "\t -V <version> \t override version spec in build_config\n";
print "\t -D \t disable testing (despite spec in build_config)\n";
print "\n";
exit;
}
shift;
}
check_needed_commands();
my $HOME = $ENV{'HOME'};
my $USER = $ENV{'USER'};
my $hostname = `hostname`; chop($hostname);
my $korvo_arch_cmd = `which korvo_arch 2>/dev/null`;
if ("$ARCH" eq "") {
if ($korvo_arch_cmd) {
$ARCH=`korvo_arch`;
} else {
my $dir = dirname $0;
if (-e "$dir/korvo_arch") {
if (! -x "$dir/korvo_arch") {
if (!($quiet != 0)) {
print("Doing chmod of korvo_arch\n");
}
system("chmod ugo+x $dir/korvo_arch");
}
$ARCH=`$dir/korvo_arch`;
}
}
chop($ARCH);
}
$ARCH =~ s/^\s*//g;
$ARCH =~ s/\s*$//g;
my $DOT_ARCH = "";
if ($ARCH ne "" ) {
$DOT_ARCH=".$ARCH";
}
my $UNDER_ARCH = `echo $ARCH | tr '.\\055' '__'`;
chop($UNDER_ARCH);
$UNDER_ARCH =~ s/^\s*//g;
$UNDER_ARCH =~ s/\s*$//g;
my @config_path = ('$HOME', '$script_pwd');
my @config_files = ('korvo_build_config.$ARCH', 'korvo_build_config', 'build_config.$ARCH', 'build_config.$USER', 'build_config');
my @config_search;
if (("$BUILD_CONFIG" ne "") && (!-f "$BUILD_CONFIG")) {
die ("Build Configuration not found at $BUILD_CONFIG");
}
foreach (@config_files) {
my $file = $_;
foreach (@config_path) {
my $path = $_;
if ((/ARCH/) && ("$ARCH" eq "")) { next; }
my $eval_file = eval('"'.$path.'/'.$file.'"'); warn $@ if $@;
push(@config_search, $eval_file);
}
}
foreach (@config_search) {
my $eval_file = eval('"'.$_.'"'); warn $@ if $@;
if (($BUILD_CONFIG eq "") && (-f "$eval_file")) {
$BUILD_CONFIG=$eval_file;
last;
}
}
if ($BUILD_CONFIG eq "") {
die ("Build configuration not found!\n\tSearch path: @config_search\n");
}
open(CONFIG, "$BUILD_CONFIG") && $build_config_open++;
if ($build_config_open) {
$BUILD_CONFIG = File::Spec->rel2abs($BUILD_CONFIG);
parse_config();
}
if (defined $OVERRIDE_VERSION) {
print "Overriding build_config version with $OVERRIDE_VERSION\n";
$VERSION_TAG = $OVERRIDE_VERSION;
$BUILD_AREA = "/tmp/$VERSION_TAG";
$INSTALL_DIRECTORY = $BUILD_AREA;
}
if ($OVERRIDE_DISABLE_TESTING) {
$enable_testing = 0;
}
if (not defined $stop_on_failure) {
$stop_on_failure = !$quiet;
}
my @transport_projects = ('nnti', 'enet');
my $TAG_DB = "";
our %korvo_projects_override;
my %repositories;
my %config_env_string;
foreach (@config_path) {
my $eval_file = eval('"'.$_.'/korvo_tag_db'.'"'); warn $@ if $@;
if (($TAG_DB eq "") && (-f "$eval_file")) {
$TAG_DB=$eval_file;
last;
}
}
if ($TAG_DB ne "") {
if (-w "$TAG_DB") {
update_file($TAG_DB);
}
if (!$quiet) {
print "Loading version tag database : " . $TAG_DB . "\n";
}
my $return;
unless ($return = do $TAG_DB) {
warn "couldn't parse $TAG_DB: $@" if $@;
warn "couldn't do $TAG_DB: $!" unless defined $return;
warn "couldn't run $TAG_DB" unless $return;
}
} else {
print "No tag database found - all packages build from HEAD\n";
}
do "$TAG_DB";
unless (defined $korvo_tag{"$VERSION_TAG"}) { die "Couldn't find version \"$VERSION_TAG\" in korvo_tag_db\n";}
my $SUMMARY = ">$RESULTS_FILES_DIR/build_results$DOT_ARCH";
open SUMMARY, $SUMMARY;
select(SUMMARY);
$| = 1;
select(STDOUT);
if (!$quiet) {
dump_config();
}
my $host = `hostname`;
chop ($host);
$host =~ s/^\s*//g;
$host =~ s/\s*$//g;
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isds)
= localtime(time);
$year += 1900;
my $now_string = "$mon/$mday/$year $hour:$min:$sec";
verbose_output ("building on host ", $host, " at ", $now_string,
"\n\n");
my $CC = $ENV{'CC'};
if (! $CC) { $CC = "cc"; }
my $ccv = `$CC -v 2>&1`;
if (defined $korvo_projects_override{"$VERSION_TAG"}) {
@projects = split(/\s+/, $korvo_projects_override{"$VERSION_TAG"});
}
if ( ! -d "$BUILD_AREA" ) {
verbose_output(" Making directory \"$BUILD_AREA\"\n");
mkdir ("$BUILD_AREA", 0755);
}
my $failed_projects = "";
while(my $project = shift(@projects)) {
my $repository = $repositories{$project};
my $result;
verbose_output(" cd'ing to directory \"$BUILD_AREA\"\n");
chdir "$BUILD_AREA" || die ("Couldn't chdir to $BUILD_AREA");
my $PWD="$BUILD_AREA";
if ( ! -d $project ) {
verbose_output(" Making directory \"$project\"\n");
mkdir ($project, 0755);
}
verbose_output(" cd'ing to directory \"$project\"\n");
chdir $project;
$PWD="$PWD/$project";
my $src_dir = "$PWD/source";
my $build_dir;
if ( $ARCH ne "" ) {
$build_dir = "$PWD/$ARCH";
} else {
$build_dir = "$PWD/build";
}
if (! defined($spec{$repository})) {
print STDERR "Unknown repository specification \"$repository\" for project $project.\n";
next;
}
my $build = 1;
normal_output("Building project $project\n\twith srcdir=$src_dir and builddir=$build_dir\n");
sleep 3;
mkdir $build_dir;
verbose_output("Removing $build_dir/*\n");
system("rm -fr $build_dir/*");
my $repo_spec = '"'.$spec{$repository}.'"';
my $eval_repo_spec = eval($repo_spec); warn $@ if $@;
my $rev_arg = "";
if ("$tool{$repository}" eq "svn") {
if ("$eval_repo_spec" =~ /^http:\/\/svn.research.cc.gatech.edu/) {
$rev_arg = "--non-interactive --no-auth-cache --username anon --password anon $rev_arg";
}
if ($korvo_tag{"$VERSION_TAG"} =~ /$project:(\w*)/) {
$rev_arg = "-r $1 $rev_arg";
}
my $command = "svn co -q $rev_arg $eval_repo_spec $src_dir";
normal_output(" ==> $command \n");
system($command);
system("cd $src_dir; svn update $rev_arg 1> /dev/null 2>&1");
} elsif ("$tool{$repository}" eq "git") {
if ($korvo_tag{"$VERSION_TAG"} =~ /$project:(\w*)/) {
$rev_arg = "$1";
if (lc $rev_arg eq "head") { $rev_arg = "master"; }
} else {
$rev_arg = "master";
}
if (-d "$src_dir/.git") {
my $command = "cd $src_dir ; git pull 1> /dev/null 2>&1";
normal_output(" ==> $command \n");
system($command);
if (${?} != 0) {
normal_output(" PULL FAILED! ${?}\n");
system("rm -fr $src_dir");
my $command = "git clone $eval_repo_spec $src_dir";
normal_output(" ==> $command \n");
system($command);
$command = "cd $src_dir ; git pull 1> /dev/null 2>&1";
normal_output(" ==> $command \n");
system($command);
}
} else {
my $command = "git clone $eval_repo_spec $src_dir";
normal_output(" ==> $command \n");
system($command);
$command = "cd $src_dir ; git pull 1> /dev/null 2>&1";
normal_output(" ==> $command \n");
system($command);
}
my $command = "cd $src_dir ; git checkout $rev_arg 1> /dev/null 2>&1";
normal_output(" ==> $command \n");
system($command);
} else {
printf("Unknown tool in build \"$tool{$repository}\"\n");
exit;
}
chdir $build_dir;
unlink ('config.cache');
unlink ('config.h');
unlink ('CMakeCache.txt');
my $results = "$RESULTS_FILES_DIR/$project/current_install$DOT_ARCH";
if (! -d "$RESULTS_FILES_DIR/$project") {
verbose_output("doing mkdir on ".$RESULTS_FILES_DIR . "/".$project."\n");
mkdir("$RESULTS_FILES_DIR/$project",0777);
}
open(RESULTS, ">$results") || die "failed to open $results\n";
print RESULTS "\nBuilding project $project on $hostname, arch = $ARCH\n\n";
close(RESULTS);
my %STORE_ENV = %ENV; # save environment
if (defined($config_env_string{$repository})) {
foreach my $var (split("&", $config_env_string{$repository})) {
my ($name,$value) = split("=",$var);
$ENV{$name} = $value;
}
}
my $tmp = eval('"'.$INSTALL_DIRECTORY.'"');
my $THIS_INSTALL_DIRECTORY = $tmp;
if ( ! -d "$THIS_INSTALL_DIRECTORY" ) {
verbose_output(" Making directory \"$THIS_INSTALL_DIRECTORY\"\n");
mkdir ("$THIS_INSTALL_DIRECTORY", 0755);
}
chomp($tmp=`cd "$THIS_INSTALL_DIRECTORY"; pwd`);
$THIS_INSTALL_DIRECTORY=$tmp;
my $config_command;
if ( -r "$src_dir/CMakeLists.txt" ) {
my $args = '"';
if (defined($cmake_args{$repository})) {
$args.= "$cmake_args{$repository}";
}
if ($enable_testing && ("$ARCH" ne "")) {
$args.=" -DBUILDNAME=$project-$ARCH";
}
if ($enable_testing == 0) {
$args.=" -DENABLE_TESTING=0"
}
if ($enable_debug_build > 0) {
$args.=" -DCMAKE_BUILD_TYPE=Debug"
}
if ($THIS_INSTALL_DIRECTORY) {
$args.=" -DCMAKE_INSTALL_PREFIX=$THIS_INSTALL_DIRECTORY";
}
if ($EVPATH_TEST_INSTALL_DIR && ($project eq "evpath")) {
$args.=" -DTEST_INSTALL_DIRECTORY=$EVPATH_TEST_INSTALL_DIR";
}
$args.='"';
my $eval_args = eval($args); warn $@ if $@;
normal_output(" ==> cmake $eval_args $src_dir\n");
$config_command = "cmake $eval_args $src_dir 1>>$results 2>&1";
} else {
my $args = '"';
printf("Doing configure build fore repository $repository, args is $config_args{$repository}\n");
if (defined($config_args{$repository})) {
$args.= "$config_args{$repository}";
}
if ($enable_debug_build > 0) {
$args.= " CFLAGS='-g -O0' CPPFLAGS='-g -O0' "
}
my $dir;
if ($THIS_INSTALL_DIRECTORY) {
$args.= "--prefix=$THIS_INSTALL_DIRECTORY";
}
$args.='"';
my $eval_args = eval($args); warn $@ if $@;
if (($dir) = ($eval_args =~ /.*-bindir=(\S+)\b.*/)) {
if (! -d $dir) {
verbose_output("doing bin mkdir on $dir\n");
verbose_output("in was $eval_args\n");
mkdir($dir,0777);
}
}
if (($dir) = ($eval_args =~ /.*-libdir=(\S+)\b.*/)) {
if (! -d $dir) {
verbose_output("doing lib mkdir on $dir\n");
verbose_output("in was $eval_args\n");
mkdir($dir,0777);
}
}
if (($dir) = ($eval_args =~ /.*-includedir=(\S+)\b.*/)) {
if (! -d $dir) {
verbose_output("doing include mkdir on $dir\n");
verbose_output("in was $eval_args\n");
mkdir($dir,0777);
}
}
normal_output(" ==> $src_dir/configure $eval_args\n");
$config_command = "$src_dir/configure $eval_args 1>>$results 2>&1";
}
verbose_output("Doing $config_command\n");
system($config_command);
system("make clean 1> /dev/null 2>&1");
if ( -r "$src_dir/CMakeLists.txt") {
open CMFILE, "$src_dir/CMakeLists.txt" or die $!;
my @cmfile = <CMFILE>;
if ( grep( /^ENABLE_TESTING()/,@cmfile ) && $enable_testing ) {
# do a make test
system("make clean 1>>/dev/null 2>&1");
normal_output(" ==> make\n");
system("make 1>>$results 2>&1");
$result = 0;
normal_output(" ==> make test\n");
$result = system("make test 2>&1 | sed 's/[0-9.]* sec//g' 1>>$results");
if (($result/256) == 0) {
normal_output(" ==> make install\n");
$result = system("make install 1>>$results 2>&1");
} else {
system("echo \"TESTING FAILED, NO INSTALL, result from make test ${?}\" 1>>$results");
}
} else {
verbose_output("ENABLE_TESTING NOT FOUND or testing disabled\n");
normal_output(" ==> make all install\n");
$result = system("make all install 1>>$results 2>&1");
}
close CMFILE;
} elsif ( -r "Makefile.am") {
# do a make check
system("make depend 1> /dev/null 2>&1 ");
if ($enable_testing) {
normal_output(" ==> make check install\n");
$result = system("make check install 1>>$results 2>&1");
} else {
normal_output(" ==> make install\n");
$result = system("make install 1>>$results 2>&1");
}
} else {
normal_output(" ==> make install\n");
$result = system("make install 1>>$results 2>&1");
}
if (($result / 256) != 0) {
if ($stop_on_failure) {
}
possible_exit_on_failure ($project);
$failed_projects .= " $project";
}
if ( ! -r ".no_clean") {
system("make clean 1> /dev/null 2>&1");
}
%ENV = %STORE_ENV; # restore environment
}
$_ = $HOME;
my $evpath_rel_rev = `grep "EVPath Version" ${BUILD_AREA}/evpath/source/version.c | sed 's/.* Version //;s/ .*//'`;
chomp($evpath_rel_rev);
&_generate_build_xml($VERSION_TAG, $evpath_rel_rev, $failed_projects, $ARCH, $BUILD_CONFIG);
if ($failed_projects ne "") {
normal_output("\n\nThese projects failed to install : $failed_projects\n");
normal_output(" * More detailed build output is available in $RESULTS_FILES_DIR/<project> \n\n");
normal_output("These failures may or may not be important depending upon what packages you need.\n");
normal_output("If \"evpath\" is not listed as one of the projects that failed to install, then \n");
normal_output("the evpath library has been installed and is available in the specified install directory\n\n");
if (index($failed_projects, "nnti") != -1) {
normal_output("- nnti failure possible cause: NNTI supports EVPath RDMA transport and will not \n");
normal_output(" build unless it finds an RDMA interface, but is not needed unless you're doing RDMA work.\n");
}
if (index($failed_projects, "soapstone") != -1) {
normal_output("- soapstone failure possible cause: Soapstone requires gsoap2 and will fail if it is not found\n");
normal_output(" This is a supplementary project and not necessary to use EVPath\n");
}
if (index($failed_projects, "pds") != -1) {
normal_output("- pds failure possible cause: The PDS package requires libxml2 and will fail if it is not found\n");
normal_output(" This is a supplementary project and not necessary to use EVPath\n");
}
if (index($failed_projects, "comm_group") != -1) {
normal_output("- comm_group : This is a supplementary project and not necessary to use EVPath\n");
}
if (index($failed_projects, "cmrpc") != -1) {
normal_output("- cmrpc : This is a supplementary project and not necessary to use EVPath\n");
}
if (index($failed_projects, "gs") != -1) {
normal_output("- gs : This is a supplementary project and not necessary to use EVPath\n");
}
if (index($failed_projects, "lgs") != -1) {
normal_output("- lgs : This is a supplementary project and not necessary to use EVPath\n");
}
}
sub _generate_build_xml {
my ($release_name, $release_rev, $fail_list, $platform, $build_config_file) = @_;
if ("$platform" eq "") { return; }
open BUILD_RESULTS_FILE, ">/tmp/build_results_$$.xml" or die "failed to open build_results XML output";
print BUILD_RESULTS_FILE "<?xml version='1.0'?>\n<build_result>\n";
print BUILD_RESULTS_FILE "<releasename>$release_name</releasename>\n";
print BUILD_RESULTS_FILE "<releasetag>$release_rev</releasetag>\n";
print BUILD_RESULTS_FILE "<platform>$platform</platform>\n";
print BUILD_RESULTS_FILE "<hostname>$hostname</hostname>\n";
print BUILD_RESULTS_FILE "<user>$USER</user>\n";
my $uname = `uname -a`;
print BUILD_RESULTS_FILE "<uname>$uname</uname>\n";
my $CC = $ENV{'CC'};
if (! $CC) { $CC = "cc"; }
my $ccv = `$CC -v 2>&1`;
$ccv =~ s/&/&/sg;
$ccv =~ s/</</sg;
$ccv =~ s/>/>/sg;
$ccv =~ s/"/"/sg;
print BUILD_RESULTS_FILE "<ccv>$ccv</ccv>\n";
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
$year += 1900;
$mon += 1;
print BUILD_RESULTS_FILE "<date>$mon/$mday/$year</date>\n";
if (index($failed_projects, 'evpath') == -1) {
print BUILD_RESULTS_FILE "<buildstatus>1</buildstatus>\n";
} else {
print BUILD_RESULTS_FILE "<buildstatus>0</buildstatus>\n";
}
print BUILD_RESULTS_FILE "<build_config>\n";
my $conf;
my $include_build_config = 0;
foreach $conf (keys %cmake_args) {
if (defined $cmake_args{$conf} && ($cmake_args{$conf} !~ /^\s*$/)) {
$include_build_config = 1;
}
}
foreach $conf (keys %config_args) {
if (defined $config_args{$conf} && ($config_args{$conf} !~ /^\s*$/)) {
$include_build_config = 1;
}
}
if ($include_build_config) {
open my $fh, "<$BUILD_CONFIG" or die;
$/ = undef;
my $build_config = <$fh>;
close $fh;
$build_config =~ s/&/&/sg;
$build_config =~ s/</</sg;
$build_config =~ s/>/>/sg;
$build_config =~ s/"/"/sg;
print BUILD_RESULTS_FILE "$build_config";
}
print BUILD_RESULTS_FILE "</build_config>\n";
print BUILD_RESULTS_FILE "<module_list>\n";
my $fh;
if (&Which("module")) {
open $fh, "module list 2>&1 |" or die;
} elsif (&Which("modulecmd")) {
open $fh, "modulecmd tcsh list 2>&1 |" or die;
}
if ($fh) {
$/ = undef;
my $module_list = <$fh>;
close $fh;
$module_list =~ s/&/&/sg;
$module_list =~ s/</</sg;
$module_list =~ s/>/>/sg;
$module_list =~ s/"/"/sg;
print BUILD_RESULTS_FILE $module_list;
}
print BUILD_RESULTS_FILE "</module_list>\n";
print BUILD_RESULTS_FILE "</build_result>\n";
close BUILD_RESULTS_FILE;
system("wget -q --post-file=/tmp/build_results_$$.xml -O - http://evpath.net/submit.php");
unlink("/tmp/build_results_$$.xml");
if (defined $OVERRIDE_VERSION) {
system("rm -fr /tmp/$VERSION_TAG");
}
}
sub parse_config {
my $parsing;
@projects = ();
$RESULTS_FILES_DIR="/tmp/build_results_$USER";
$BUILD_AREA="$HOME/korvo_build_area";
$VERSION_TAG="stable";
while(<CONFIG>) {
if (/^%BUILDLIST/) { $parsing = "list"; next; }
elsif (/^%REPOSITORIES/) { $parsing = "repos"; next; }
elsif (/^%CONFIGURE/) { $parsing = "args"; next; }
elsif (/^[ \t]*%/) { next;}
elsif (/DISABLE_TESTING/) { $enable_testing = 0; next; }
elsif (/ENABLE_DEBUG_BUILD/) { $enable_debug_build++; next; }
elsif (/RESULTS_FILES_DIR/) {
$_ =~ m{.*=\s*(\S+)};
$RESULTS_FILES_DIR = $1;
}
elsif (/INSTALL_DIRECTORY/) {
$_ =~ m{.*=\s*(\S+)};
$INSTALL_DIRECTORY = $1;
}
elsif (/BUILD_AREA/) {
$_ =~ m{.*=\s*(\S+)};
$BUILD_AREA = $1;
}
elsif (/EVPATH_TEST_INSTALL_DIR/) {
$_ =~ m{.*=\s*(\S+)};
$EVPATH_TEST_INSTALL_DIR = $1;
}
elsif (/VERSION_TAG/) {
$_ =~ m{.*=\s*(\S+)};
$VERSION_TAG = $1;
}
elsif (/^%/) {next;}
elsif (/^#/) {next;}
elsif (/^[ ]*$/) {next;}
else {
if ($parsing eq "list") {
my ($project,$repository,$notify_users) = split(/[ \t\n]+/,$_,3);
push(@projects, $project);
$repositories{$project} = $repository;
} elsif ($parsing eq "repos") {
$_ =~ m/\s*(\S+)\s+(\S+)\s+(\S+)/;
my ($repo, $tool, $spec);
$repo = $1; $tool = $2; $spec = $3;
# ($repo,$tool,$spec) = split(/[ \t]+/,$_,3);
$tool{$repo} = $tool;
$spec{$repo} = $spec;
} elsif ($parsing eq "args") {
chomp();
my ($repo,$conf, $args) = split(/[ \t]+/,$_,3);
if (defined($conf)) {
if ($conf eq "cmake") {
$cmake_args{$repo} = $args;
} elsif ($conf eq "configure") {
$config_args{$repo} = $args;
} else {
printf("Unknown configure type \"$conf\" in build_config.");
}
}
}
}
}
my $eval_build_area = eval('"'.$BUILD_AREA.'"'); warn $@ if $@;
$BUILD_AREA=$eval_build_area;
if ( ! -d "$BUILD_AREA" ) {
print(" Making directory \"$BUILD_AREA\"\n");
mkdir ("$BUILD_AREA", 0755);
}
my $tmp;
chomp($tmp=`cd "$BUILD_AREA"; pwd`);
$BUILD_AREA=$tmp;
if ( ! -d "$RESULTS_FILES_DIR" ) {
print(" Making directory \"$RESULTS_FILES_DIR\"\n");
mkdir ("$RESULTS_FILES_DIR", 0755);
}
chomp($tmp=`cd "$RESULTS_FILES_DIR"; pwd`);
$RESULTS_FILES_DIR=$tmp;
}
sub dump_config {
if ("$ARCH" ne "") {
print("Build configured by $BUILD_CONFIG for architecture $ARCH on host $hostname\n\t\tInstalling to $INSTALL_DIRECTORY\n");
} else {
print("Build configured by $BUILD_CONFIG on host $hostname\n\t\tInstalling to $INSTALL_DIRECTORY\n");
}
print("Building version tagged with $VERSION_TAG\n");
print("Builds are to be performed under directory : $BUILD_AREA\n");
print("Result files are to be placed in directory : $RESULTS_FILES_DIR\n");
if ($enable_testing) {
print(" Package tests will be run prior to installation.\n");
} else {
print(" Package tests will *NOT* be run prior to installation.\n");
}
print("\n\n");
}
sub normal_output {
if (!($quiet != 0)) {
foreach my $foo (@_) {
print $foo;
}
}
foreach my $foo (@_) {
print SUMMARY $foo;
}
}
sub verbose_output {
if ($verbose != 0) {
foreach my $foo (@_) {
print $foo;
}
}
foreach my $foo (@_) {
print SUMMARY $foo;
}
}
sub check_needed_commands {
my $make_found = `which make`;
my $cmake_found = `which cmake`;
my $svn_found = `which svn`;
my $git_found = `which git`;
my $exit = 0;
if ("$make_found" eq "") {
printf("Didn't find 'make', required for build\n"); $exit++;
}
if ("$cmake_found" eq "") {
printf("Didn't find 'cmake', required for build\n"); $exit++;
} else {
my ($substr) = `cmake --version` =~ /(?<=cmake version )([^.]+)/g;
if ("$substr" < 3) {
printf("EVPath build requires CMake 3.0 or higher\n"); $exit++;
}
}
if ("$git_found" eq "") {
printf("Didn't find 'git', required for build\n"); $exit++;
}
($exit == 0) || die("Some required components missing, korvo_build aborted");
open(HOUT, ">/tmp/". $$ . "CrayPEWarn.cmake") || die "Can't cmake";
print HOUT<<EOF;
if(CMAKE_SYSTEM_NAME STREQUAL "CrayLinuxEnvironment" OR
DEFINED ENV{CRAYOS_VERSION} OR
DEFINED ENV{XTOS_VERSION} OR
EXISTS /etc/opt/cray/release/cle-release OR
EXISTS /etc/opt/cray/release/clerelease)
if(NOT (CMAKE_VERSION VERSION_GREATER 3.5))
message(STATUS "WARNING")
message(STATUS "WARNING It looks like you're building on a Cray but using")
message(STATUS "WARNING a version of CMake prior to proper integration")
message(STATUS "WARNING with the CrayPE compiler wrappers. If targeting")
message(STATUS "WARNING compute nodes with the CrayPE compiler wrappers,")
message(STATUS "WARNING please re-run the build script from a clean")
message(STATUS "WARNING build directory using CMake >= 3.5.")
message(STATUS "WARNING")
message(STATUS "WARNING If not targeting compute nodes or explicitly")
message(STATUS "WARNING managing the low level compiler settings yourself")
message(STATUS "WARNING then this warning can be safely ignored.")
message(STATUS "WARNING")
elseif(NOT (CMAKE_C_COMPILER_WRAPPER STREQUAL "CrayPrgEnv"))
message(STATUS "WARNING")
message(STATUS "WARNING It looks like you're building on a Cray but not")
message(STATUS "WARNING using the CrayPE compiler wrappers. While this")
message(STATUS "WARNING is an entirely valid configuration, it's usually")
message(STATUS "WARNING not the intended behavior if targeting the")
message(STATUS "WARNING compute nodes. Please explicitly set the CC=cc")
message(STATUS "WARNING CXX=CC FC=ftn environment variables and re-run the")
message(STATUS "WARNING build script from a clean build directory to use")
message(STATUS "WARNING the CrayPE compiler wrappers and ensure proper")
message(STATUS "WARNING interaction with the module environment for")
message(STATUS "WARNING compute nodes if that's the intended behavior")
message(STATUS "WARNING")
message(STATUS "WARNING If not targeting compute nodes or explicitly")
message(STATUS "WARNING managing the low level compiler settings yourself")
message(STATUS "WARNING then this warning can be safely ignored.")
message(STATUS "WARNING")
endif()
endif()
EOF
system("cmake -P /tmp/" . $$ . "CrayPEWarn.cmake");
unlink ("/tmp/". $$ . "CrayPEWarn.cmake");
}
sub update_file {
my ($filename) = @_;
my $base = basename $filename;
my $dir = dirname $filename;
my ($ua, $response);
state $has_lwp = -1;
if (-d $dir . "/.svn") {
# if under svn, do an svn update
system('cd "$dir" ; svn -q update');
return;
}
if ($has_lwp == -1) {
$has_lwp = eval
{
require LWP::UserAgent;
require LWP::Protocol::https;
LWP::UserAgent->new();
1;
};
}
$has_lwp = 0 unless defined($has_lwp);
if($has_lwp) {
# LWP::UserAgent loaded and imported successfully
my $ua = LWP::UserAgent->new();
$ua->env_proxy();
$response = $ua->get("https://GTkorvo.github.io/$base");
if ($response->is_success) {
open(FILE, ">/tmp/$base");
print FILE $response->decoded_content;
close FILE;
} else {
print "Error updating $base: " . $response->status_line . "\n";
return;
}
} else {
my $ret = system("cd /tmp ; rm -f $base ; wget -q https://GTkorvo.github.io/$base");
my $exit_value = $ret >> 8;
if ($exit_value != 0) {
die("This script requires either the perl module LWP::UserAgent, or the command 'wget' to be installed\n\tThe former was not found and the latter failed.");
}
}
if (system("cmp -s $filename /tmp/$base") != 0) {
system("mv /tmp/$base $filename");
print "Installed fresh $filename\n";
} else {
unlink("/tmp/$base");
print "No need to update $filename\n";
}
}
sub possible_exit_on_failure {
my $failed_project = shift;
my $count=map {m/^$failed_project$/i} @transport_projects;
if ($count) {
print "\n BUILD FAILURE of OPTIONAL PROJECT \n";
if ("$failed_project" eq "nnti") {
print "\tProject nnti has failed to configure/build/install. \n";
print "\tnnti is an RDMA wrapper library used to provide a high performance network \n";
print "\ttransport in EVPATH on machines where RDMA is available. If you are\n";
print "\tbuilding on a machine without an RDMA interface, this is an expected failure. \n";
print "\tEVPath can still be built, but will operate without RDMA capabilities. \n";
print "\tTherefore this build script will continue to execute.\n";
print "\tHowever, if you think you *should* be building for RDMA, you can examine the file:\n";
print "\t$RESULTS_FILES_DIR/$failed_project/current_install$DOT_ARCH for clues as to what went wrong.\n\n";
} else {
print "\tProject $failed_project has failed to configure/build/install. However, \n";
print "\t$failed_project is not a critical project for EVPath, so this build script\n";
print "\twill continue to execute.\n";
print "\tIf you are curious about the failure, you can examine the file:\n";
print "\t$RESULTS_FILES_DIR/$failed_project/current_install$DOT_ARCH\n";
print "\tfor clues as to what went wrong.\n\n";
}
} else {
print "\t BUILD FAILURE of CRITICAL PROJECT \n";
print "\tProject $failed_project has failed to configure/build/install. \n";
print "\tThis project is necessary for EVPath, so the build is exiting now\n";
print "\tOutput from the failed build has been left in the file:\n";
print "\t$RESULTS_FILES_DIR/$failed_project/current_install$DOT_ARCH\n";
print "\tPlease examine that file for clues.\n";
die ("Critical project build failure");
}
}
sub Which {
# Get the passed value
my $program = shift;
# Return if nothing is provided
return if (not defined($program));
# Load the path
my $path = $ENV{'PATH'};
# Let's replace all \ by /
$path =~ s/\\/\//g;
# Substitute all /; by ; as there could be some trailing / in the path
$path =~ s/\/;/;/g;
# Now make an array
my @path = split(/:/,$path);
# Loop and find if the file is in one of the paths
foreach (@path) {
# Concatenate the file
my $file = $_ . '/' . $program;
# Return the path if it was found
return $file if ((-e $file) && (-f $file));
}
}