summaryrefslogtreecommitdiffstats
path: root/atoms_cc
diff options
context:
space:
mode:
authorSimon Lipp <simon.lipp@scilab.org>2008-07-02 08:23:33 +0000
committerSimon Lipp <simon.lipp@scilab.org>2008-07-02 08:23:33 +0000
commit80af0eaa1fe5787c0c83de39d8b6d2c2999ceb85 (patch)
tree91614975812daef0aea26dbe0dd2551dddabfa00 /atoms_cc
parent381078a96189657d04cb4022e1343a26e8ea9b33 (diff)
downloadscilab-80af0eaa1fe5787c0c83de39d8b6d2c2999ceb85.zip
scilab-80af0eaa1fe5787c0c83de39d8b6d2c2999ceb85.tar.gz
atoms_cc/buildtoolbox.pl:
* check_tree now based on contrib/toolbox_skeleton.sce and not wiki page, which is outdated * check_tree: better check of help/ subtree * implement build stage * open logfile earlier, to allow usage of common_die before any stage
Diffstat (limited to 'atoms_cc')
-rwxr-xr-xatoms_cc/buildtoolbox.pl100
1 files changed, 82 insertions, 18 deletions
diff --git a/atoms_cc/buildtoolbox.pl b/atoms_cc/buildtoolbox.pl
index d12dcc4..33a93e0 100755
--- a/atoms_cc/buildtoolbox.pl
+++ b/atoms_cc/buildtoolbox.pl
@@ -278,9 +278,9 @@ sub check_tree {
278 278
279 # Check that basic files are here 279 # Check that basic files are here
280 my @required = qw(DESCRIPTION DESCRIPTION-FUNCTIONS readme.txt license.txt 280 my @required = qw(DESCRIPTION DESCRIPTION-FUNCTIONS readme.txt license.txt
281 builder.sce loader.sce); 281 changelog.txt builder.sce);
282 push(@required, "etc/$TOOLBOXNAME.start"); 282 push(@required, "etc/$TOOLBOXNAME.start");
283 push(@required, "etc/$TOOLBOXNAME.end"); 283 push(@required, "etc/$TOOLBOXNAME.quit");
284 284
285 foreach (@required) { 285 foreach (@required) {
286 if(!defined($tree{$_})) { 286 if(!defined($tree{$_})) {
@@ -314,8 +314,11 @@ sub check_tree {
314 314
315 # Constraints: if $key exists, $constraints{$key} must exist 315 # Constraints: if $key exists, $constraints{$key} must exist
316 my %constraints = ( 316 my %constraints = (
317 qr#help/.+\.xml$# => "help/buildhelp.sce", 317 qr#^help/([a-z][a-z]_[A-Z][A-Z])/[^/]+\.xml$# => sub{ "help/$1/build_help.sce" },
318 qr#macros/.+\.sc[ie]$# => "macros/buildmacros.sce"); 318 qr#^help/([a-z][a-z]_[A-Z][A-Z])/build_help.sce$# => sub{ "help/$1/addchapter.sce" },
319 qr#^help/([a-z][a-z]_[A-Z][A-Z])/addchapter.sce$# => sub{ "help/builder_help.sce" },
320 qr#^sci_gateway/builder_gateway.sce$# => sub{ "sci_gateway/loader_gateway.sce" },
321 qr#^macros/.+\.sc[ie]$# => sub{ "macros/buildmacros.sce" });
319 322
320 # Build constraints for allowed languages 323 # Build constraints for allowed languages
321 my %languages = ( 324 my %languages = (
@@ -323,26 +326,28 @@ sub check_tree {
323 "fortran" => qr/f/); 326 "fortran" => qr/f/);
324 327
325 foreach (keys %languages) { 328 foreach (keys %languages) {
326 # if src/(lang) has source files, src/(lang)/buildsrc_(lang).sce must exist 329 # if src/(lang) has source files, src/(lang)/builder_(lang).sce must exist
327 $constraints{qr#^src/$_/.+\.$languages{$_}$#} = "src/$_/buildsrc_$_.sce"; 330 $constraints{qr#^src/($_)/.+\.$languages{$_}$#} = sub{ "src/$1/builder_$1.sce" };
328 331
329 # if sci_gateway/(lang) has C sources, sci_gateway/(lang)/buildgateway_(lang).sce 332 # if sci_gateway/(lang) has C sources, sci_gateway/(lang)/builder_gateway_(lang).sce
330 # must exist 333 # must exist
331 $constraints{qr#^sci_gateway/$_/.+[ch]$#} = "sci_gateway/$_/buildgateway_$_.sce"; 334 $constraints{qr#^sci_gateway/($_)/.+[ch]$#} = sub{ "sci_gateway/$1/builder_gateway_$1.sce" };
332 335
333 # if src/(lang)/buildsrc_(lang).sce exist, src/buildsrc.sce must exist 336 # if src/(lang)/builder_(lang).sce exist, src/builder_src.sce must exist
334 $constraints{qr#^src/$_/buildsrc_$_.sce$#} = "src/buildsrc.sce"; 337 $constraints{qr#^src/$_/builder_$_.sce$#} = sub{ "src/builder_src.sce" };
335 338
336 # if sci_gateway/(lang)/buildgateway_(lang).sce exist, sci_gateway/buildgateway.sce must exist 339 # if sci_gateway/(lang)/builder_gateway_(lang).sce exist, sci_gateway/builder_gateway.sce must exist
337 $constraints{qr#^sci_gateway/$_/buildgateway_$_.sce$#} = "sci_gateway/buildgateway.sce"; 340 $constraints{qr#^sci_gateway/$_/builder_gateway_$_.sce$#} = sub{ "sci_gateway/builder_gateway.sce" };
338 } 341 }
339 342
340 # Check constraints 343 # Check constraints
341 foreach my $constraint (keys %constraints) { 344 foreach my $constraint (keys %constraints) {
342 my $required = $constraints{$constraint}; 345 foreach my $file (keys %tree) {
343 my @found = grep { $_ =~ $constraint } keys %tree; 346 if($file =~ $constraint) {
344 if(@found && !defined($tree{$required})) { 347 my $required = $constraints{$constraint}();
345 common_die "Invalid archive: \"$found[0]\" needs \"$required\", which isn't in the archive"; 348 common_die "Invalid archive: \"$&\" needs \"$required\", which isn't in the archive"
349 unless(defined($tree{$required}));
350 }
346 } 351 }
347 } 352 }
348} 353}
@@ -518,7 +523,50 @@ sub stage_tbdeps {
518 common_leave_stage("tbdeps"); 523 common_leave_stage("tbdeps");
519} 524}
520 525
526# stage_sysdeps:
527# Install system dependencies
528sub stage_sysdeps {
529 common_enter_stage("sysdeps");
530 # TODO
531 common_leave_stage("sysdeps");
532}
533
534# stage_build
535# Run the build script
536sub stage_build {
537 common_enter_stage("build");
538
539 # Generate ccbuilder.sce (see __DATA__ section)
540 open CCBUILDER, ">ccbuilder.sce";
541 print CCBUILDER while(<DATA>);
542 close CCBUILDER;
543
544 # For logging purposes only
545 common_exec("cat ccbuilder.sce");
546
547 my $fd = common_exec("cd $TOOLBOXNAME; scilab -nb -nwni -e 'exec(\"../ccbuilder.sce\");'");
548
549 # Check result
550 my $done = 0;
551
552 while(<$fd>) {
553 $done = 1 if(/^atoms_cc_builder:done$/);
554 if(/^atoms_cc_ilib_compile:\s*(.+?)\s*$/) {
555 common_die("Generated library \"$1\" is invalid") unless($1 && -x $1 && ! -d $1);
556 }
557 }
558
559 # fixme: need to check if everything was OK in macros/help generation
560
561 common_die("builder.sce script didn't terminate normally") unless($done);
562 common_leave_stage("build");
563}
564
521# Init global vars, check arguments 565# Init global vars, check arguments
566open LOGFILE, ">build.log";
567
568$STAGE = "";
569
522$TOOLBOXFILE = shift; 570$TOOLBOXFILE = shift;
523if(!defined($TOOLBOXFILE)) { 571if(!defined($TOOLBOXFILE)) {
524 common_die "Toolbox source file required"; 572 common_die "Toolbox source file required";
@@ -530,8 +578,6 @@ if(! -r $TOOLBOXFILE) {
530 578
531$TOOLBOXNAME = $1 if ($TOOLBOXFILE =~ /^([^.]+)/); 579$TOOLBOXNAME = $1 if ($TOOLBOXFILE =~ /^([^.]+)/);
532 580
533open LOGFILE, ">build.log";
534
535common_log "Toolbox: $TOOLBOXNAME"; 581common_log "Toolbox: $TOOLBOXNAME";
536common_log "Source file: $TOOLBOXFILE"; 582common_log "Source file: $TOOLBOXFILE";
537 583
@@ -539,5 +585,23 @@ stage_check;
539stage_unpack; 585stage_unpack;
540stage_makeenv; 586stage_makeenv;
541stage_tbdeps; 587stage_tbdeps;
588stage_sysdeps;
589stage_build;
542 590
543close LOGFILE; 591close LOGFILE;
592
593# Overwrite some scilab functions to get its return value and extra infos
594__DATA__
595predef(0);
596funcprot(0);
597
598old_ilib_compile = ilib_compile;
599function libn = ilib_compile(lib_name,makename,files,ldflags,cflags,fflags)
600 libn = old_ilib_compile(lib_name,makename,files,ldflags,cflags,fflags);
601 mprintf("\natoms_cc_ilib_compile:%s/%s\n", pwd(), libn);
602endfunction
603
604exec("builder.sce");
605mprintf("\natoms_cc_builder:done\n");
606quit;
607