summaryrefslogtreecommitdiffstats
path: root/atoms_cc
diff options
context:
space:
mode:
authorSimon Lipp <simon.lipp@scilab.org>2008-07-02 14:22:49 +0000
committerSimon Lipp <simon.lipp@scilab.org>2008-07-02 14:22:49 +0000
commit6fabeaf8788dc10c6ccf1b761636047ac54cbebc (patch)
tree851363719ce151f4a5eb9607800b0b34083d6113 /atoms_cc
parentd8d32047a638fe474767a17c47e0bd9753b62cee (diff)
downloadscilab-6fabeaf8788dc10c6ccf1b761636047ac54cbebc.zip
scilab-6fabeaf8788dc10c6ccf1b761636047ac54cbebc.tar.gz
atoms_cc/buildtoolbox.pl:
* typos, cosmetics * describe number of arguments for each functions in comments * common_exec: consider a non-empty stderr as an error * common_leave_stage doesn't take an argument * stage_tbdeps: fix incompatibility introduced in r25602 * stage_build: more logs * first implementation of stage_pack This is the first version of the script producing an archive. Hallelujah !
Diffstat (limited to 'atoms_cc')
-rwxr-xr-xatoms_cc/buildtoolbox.pl83
1 files changed, 59 insertions, 24 deletions
diff --git a/atoms_cc/buildtoolbox.pl b/atoms_cc/buildtoolbox.pl
index 33a93e0..0923845 100755
--- a/atoms_cc/buildtoolbox.pl
+++ b/atoms_cc/buildtoolbox.pl
@@ -10,8 +10,8 @@ my ($TOOLBOXFILE, # Toolbox archive to compile
10 $TOOLBOXNAME, # Name of the toolbox 10 $TOOLBOXNAME, # Name of the toolbox
11 $STAGE); # Current stage 11 $STAGE); # Current stage
12 12
13# common_log: 13# common_log(message, type):
14# Print a log message. Seconf argument is the type of the 14# Print a log message. Second argument is the type of the
15# message: 15# message:
16# " " for a normal message 16# " " for a normal message
17# "!" for an error 17# "!" for an error
@@ -32,7 +32,7 @@ sub common_log {
32 print "[$type] $message \n"; 32 print "[$type] $message \n";
33} 33}
34 34
35# common_enter_stage: 35# common_enter_stage(stage):
36# Common stuff while starting a new stage 36# Common stuff while starting a new stage
37sub common_enter_stage { 37sub common_enter_stage {
38 $STAGE = shift; 38 $STAGE = shift;
@@ -45,7 +45,7 @@ sub common_leave_stage {
45 common_log($STAGE, "<"); 45 common_log($STAGE, "<");
46} 46}
47 47
48# common_die: 48# common_die(message):
49# Called when a problem happens 49# Called when a problem happens
50sub common_die { 50sub common_die {
51 my $message = shift; 51 my $message = shift;
@@ -57,7 +57,7 @@ sub common_die {
57 exit(1); 57 exit(1);
58} 58}
59 59
60# common_exec: 60# common_exec(command):
61# Execute given command, places its outputs to log files. 61# Execute given command, places its outputs to log files.
62# Returns a file handle on STDOUT 62# Returns a file handle on STDOUT
63# Die if return code is non-zero 63# Die if return code is non-zero
@@ -85,9 +85,8 @@ sub common_exec {
85 else { 85 else {
86 waitpid($pid, 0); 86 waitpid($pid, 0);
87 common_log("$?", "?"); 87 common_log("$?", "?");
88 if($? != 0) { 88 common_die("\"$cmd\" failed (non-zero exit code)") if($? != 0);
89 common_die("\"$cmd\" failed"); 89 common_die("\"$cmd\" failed (non-empty error output)") if(-s $stderr);
90 }
91 } 90 }
92 91
93 open my ($fd), $stdout; 92 open my ($fd), $stdout;
@@ -150,21 +149,21 @@ sub get_tree {
150 } 149 }
151} 150}
152 151
153# read_file_from_tgz: 152# read_file_from_tgz(filename):
154# Extract given file from the .zip archive 153# Extract given file from the .zip archive
155sub read_file_from_tgz { 154sub read_file_from_tgz {
156 my $filename = shift; 155 my $filename = shift;
157 return common_exec("zcat ${TOOLBOXFILE} | tar -xO ${TOOLBOXNAME}/$filename"); 156 return common_exec("zcat ${TOOLBOXFILE} | tar -xO ${TOOLBOXNAME}/$filename");
158} 157}
159 158
160# read_file_from_tgz: 159# read_file_from_tgz(filename):
161# Extract given file from the .tar.gz archive 160# Extract given file from the .tar.gz archive
162sub read_file_from_zip { 161sub read_file_from_zip {
163 my $filename = shift; 162 my $filename = shift;
164 return common_exec("unzip -p ${TOOLBOXFILE} ${TOOLBOXNAME}/$filename"); 163 return common_exec("unzip -p ${TOOLBOXFILE} ${TOOLBOXNAME}/$filename");
165} 164}
166 165
167# read_file_from_archive: 166# read_file_from_archive(filename):
168# Extract given file from the archive 167# Extract given file from the archive
169sub read_file_from_archive { 168sub read_file_from_archive {
170 if(is_zip()) { 169 if(is_zip()) {
@@ -175,7 +174,7 @@ sub read_file_from_archive {
175 } 174 }
176} 175}
177 176
178# read_description: 177# read_description(*description):
179# Check if DESCRIPTION file is correct, and parse it (return a hash 178# Check if DESCRIPTION file is correct, and parse it (return a hash
180# field => value). 179# field => value).
181# First argument is a file descriptor for the DESCRIPTION file (see 180# First argument is a file descriptor for the DESCRIPTION file (see
@@ -230,7 +229,7 @@ sub read_description {
230 return %infos; 229 return %infos;
231} 230}
232 231
233# read_description_functions: 232# read_description_functions(*description_functions):
234# Parse DESCRIPTION-FUNCTIONS file (and check it, too). Like DESCRIPTION, 233# Parse DESCRIPTION-FUNCTIONS file (and check it, too). Like DESCRIPTION,
235# first argument is a file descriptor. Returns a hash function name => 234# first argument is a file descriptor. Returns a hash function name =>
236# function description 235# function description
@@ -257,7 +256,7 @@ sub read_description_functions {
257 return %funcs; 256 return %funcs;
258} 257}
259 258
260# check_tree: 259# check_tree(%tree):
261# Given a source tree of a toolbox (see get_tree), check if it is correct 260# Given a source tree of a toolbox (see get_tree), check if it is correct
262# (required files are present, files are at their right place, and so on...) 261# (required files are present, files are at their right place, and so on...)
263sub check_tree { 262sub check_tree {
@@ -401,7 +400,7 @@ sub stage_check {
401 common_log("Computed DESCRIPTION-FUNCTIONS:\n" . 400 common_log("Computed DESCRIPTION-FUNCTIONS:\n" .
402 join("\n", map { "$_: $funcs{$_}" } sort keys %funcs)); 401 join("\n", map { "$_: $funcs{$_}" } sort keys %funcs));
403 402
404 common_leave_stage("check"); 403 common_leave_stage();
405} 404}
406 405
407# stage_unpack: 406# stage_unpack:
@@ -416,7 +415,7 @@ sub stage_unpack {
416 common_exec("zcat ${TOOLBOXFILE} | tar -vx"); 415 common_exec("zcat ${TOOLBOXFILE} | tar -vx");
417 } 416 }
418 417
419 common_leave_stage("unpack"); 418 common_leave_stage();
420} 419}
421 420
422# stage_makeenv: 421# stage_makeenv:
@@ -424,7 +423,7 @@ sub stage_unpack {
424sub stage_makeenv { 423sub stage_makeenv {
425 common_enter_stage("makeenv"); 424 common_enter_stage("makeenv");
426 # TODO 425 # TODO
427 common_leave_stage("makeenv"); 426 common_leave_stage();
428} 427}
429 428
430# compare_versions: 429# compare_versions:
@@ -484,7 +483,7 @@ sub stage_tbdeps {
484 foreach(keys %deps); 483 foreach(keys %deps);
485 484
486 # Find toolboxes directory 485 # Find toolboxes directory
487 $fd = common_exec("$SCILABX 'printf(\"path: %s\\n\", cd(toolboxDirectory())); quit;'"); 486 $fd = common_exec("$SCILABX 'printf(\"path: %s\\n\", cd(atomsToolboxDirectory())); quit;'");
488 487
489 my $tbpath; 488 my $tbpath;
490 while(<$fd>) { 489 while(<$fd>) {
@@ -520,7 +519,7 @@ sub stage_tbdeps {
520 } 519 }
521 } 520 }
522 521
523 common_leave_stage("tbdeps"); 522 common_leave_stage();
524} 523}
525 524
526# stage_sysdeps: 525# stage_sysdeps:
@@ -528,25 +527,28 @@ sub stage_tbdeps {
528sub stage_sysdeps { 527sub stage_sysdeps {
529 common_enter_stage("sysdeps"); 528 common_enter_stage("sysdeps");
530 # TODO 529 # TODO
531 common_leave_stage("sysdeps"); 530 common_leave_stage();
532} 531}
533 532
534# stage_build 533# stage_build:
535# Run the build script 534# Run the build script
536sub stage_build { 535sub stage_build {
537 common_enter_stage("build"); 536 common_enter_stage("build");
538 537
539 # Generate ccbuilder.sce (see __DATA__ section) 538 # Generate ccbuilder.sce (see __DATA__ section)
539 common_log("Generating ccbuilder.sce");
540 open CCBUILDER, ">ccbuilder.sce"; 540 open CCBUILDER, ">ccbuilder.sce";
541 print CCBUILDER while(<DATA>); 541 print CCBUILDER while(<DATA>);
542 close CCBUILDER; 542 close CCBUILDER;
543 543
544 # For logging purposes only 544 common_exec("cat ccbuilder.sce"); # For logging purposes only
545 common_exec("cat ccbuilder.sce");
546 545
546 # Run build script
547 common_log("Running ccbuilder.sce");
547 my $fd = common_exec("cd $TOOLBOXNAME; scilab -nb -nwni -e 'exec(\"../ccbuilder.sce\");'"); 548 my $fd = common_exec("cd $TOOLBOXNAME; scilab -nb -nwni -e 'exec(\"../ccbuilder.sce\");'");
548 549
549 # Check result 550 # Check result
551 common_log("Checking build result");
550 my $done = 0; 552 my $done = 0;
551 553
552 while(<$fd>) { 554 while(<$fd>) {
@@ -559,7 +561,38 @@ sub stage_build {
559 # fixme: need to check if everything was OK in macros/help generation 561 # fixme: need to check if everything was OK in macros/help generation
560 562
561 common_die("builder.sce script didn't terminate normally") unless($done); 563 common_die("builder.sce script didn't terminate normally") unless($done);
562 common_leave_stage("build"); 564 common_leave_stage();
565}
566
567# stage_pack:
568# Make the archive
569sub stage_pack {
570 common_enter_stage("pack");
571
572 my @files = qw(readme.txt license.txt changelog.txt DESCRIPTION-FUNCTIONS
573 DESCRIPTION macros src help sci_gateway demos tests locales includes);
574 push(@files, "etc/$TOOLBOXNAME.start");
575 push(@files, "etc/$TOOLBOXNAME.quit");
576 my $files_str = join(" ", map { "$TOOLBOXNAME/$_" } @files);
577
578 my $output = $TOOLBOXFILE;
579 $output =~ s/(\.zip|\.tar.gz)$//;
580 $output .= "-bin";
581
582 common_log("Making binary .tar.gz archive ($output.tar.gz)");
583 common_exec("tar -czvf $output.tar.gz $files_str");
584 common_log("Making binary .zip archive ($output.zip)");
585 common_exec("zip -r $output.zip $files_str");
586
587 common_leave_stage();
588}
589
590# stage_cleanenv:
591# Clean up the environment
592sub stage_cleanenv {
593 common_enter_stage("cleanenv");
594 # TODO
595 common_leave_stage();
563} 596}
564 597
565# Init global vars, check arguments 598# Init global vars, check arguments
@@ -587,6 +620,8 @@ stage_makeenv;
587stage_tbdeps; 620stage_tbdeps;
588stage_sysdeps; 621stage_sysdeps;
589stage_build; 622stage_build;
623stage_pack;
624stage_cleanenv;
590 625
591close LOGFILE; 626close LOGFILE;
592 627