From cc5c2b11fc2d90b56a46d336fcfb57b23faef396 Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Thu, 7 Nov 2013 04:20:16 +0100 Subject: start to adapt build to multiple backends --- Configure.pl | 199 +++++++++++++++++++++++++++---------------- modules/DBIish | 2 +- modules/Perl6-MIME-Base64 | 2 +- modules/json | 2 +- modules/panda | 2 +- modules/perl6-Term-ANSIColor | 2 +- modules/rakudo-debugger | 2 +- modules/shell-command | 2 +- modules/zavolaj | 2 +- tools/build/Makefile.in | 2 +- tools/lib/NQP/Configure.pm | 4 + 11 files changed, 138 insertions(+), 83 deletions(-) diff --git a/Configure.pl b/Configure.pl index 92298d6..e0c682c 100644 --- a/Configure.pl +++ b/Configure.pl @@ -6,8 +6,9 @@ use strict; use warnings; use Text::ParseWords; use Getopt::Long; +use File::Spec; use Cwd; -use lib "tools/lib"; +use lib 'tools/lib'; use NQP::Configure qw(sorry slurp cmp_rev gen_nqp read_config fill_template_text fill_template_file system_or_die verify_install); @@ -15,25 +16,32 @@ use NQP::Configure qw(sorry slurp cmp_rev gen_nqp read_config my $lang = 'Rakudo'; my $lclang = lc $lang; my $uclang = uc $lang; +my $slash = $^O eq 'MSWin32' ? '\\' : '/'; + MAIN: { - if (-r "config.default") { + if (-r 'config.default') { unshift @ARGV, shellwords(slurp('config.default')); } - my %config; + my %config = (perl => $^X); my $config_status = "${lclang}_config_status"; - $config{$config_status} = join(' ', map { "\"$_\""} @ARGV); + $config{$config_status} = join ' ', map { qq("$_") } @ARGV; my $exe = $NQP::Configure::exe; my %options; GetOptions(\%options, 'help!', 'prefix=s', - 'with-nqp=s', 'gen-nqp:s', - 'with-parrot=s', 'gen-parrot:s', 'parrot-option=s@', + 'backends=s', 'no-clean!', + 'gen-nqp:s', + 'gen-parrot:s', 'parrot-option=s@', + 'parrot-make-option=s@', 'make-install!', 'makefile-timing!', - 'force!' - ); + 'force!', + ) or do { + print_help(); + exit(1); + }; # Print help if it's requested if ($options{'help'}) { @@ -46,16 +54,52 @@ MAIN: { "I see a .git directory here -- you appear to be trying", "to run Configure.pl from a clone of the Rakudo Star git", "repository.", - $options{'force'} + $options{'force'} ? '--force specified, continuing' : download_text() ); } - my $prefix = $options{'prefix'} || cwd().'/install'; - my $with_parrot = $options{'with-parrot'}; - $options{'gen-parrot'} ||= "parrot" if defined $options{'gen-parrot'}; - my $gen_parrot = $options{'gen-parrot'}; + + $options{prefix} ||= 'install'; + $options{prefix} = File::Spec->rel2abs($options{prefix}); + my $prefix = $options{'prefix'}; + my %known_backends = (parrot => 1, jvm => 1); + my %letter_to_backend; + my $default_backend; + for (keys %known_backends) { + $letter_to_backend{ substr($_, 0, 1) } = $_; + } + my %backends; + if (defined $options{backends}) { + for my $b (split /,\s*/, $options{backends}) { + $b = lc $b; + unless ($known_backends{$b}) { + die "Unknown backend '$b'; Supported backends are: " . + join(", ", sort keys %known_backends) . + "\n"; + } + $backends{$b} = 1; + $default_backend ||= $b; + } + unless (%backends) { + die "--prefix given, but no valid backend?!\n"; + } + } + else { + for my $l (sort keys %letter_to_backend) { + # TODO: needs .exe/.bat magic on windows? + if (-x "$prefix/bin/nqp-$l") { + my $b = $letter_to_backend{$l}; + print "Found $prefix/bin/nqp-$l (backend $b)\n"; + $backends{$b} = 1; + $default_backend ||= $b; + } + } + unless (%backends) { + $backends{parrot} = 1; + } + } # Save options in config.status unlink('config.status'); @@ -65,77 +109,84 @@ MAIN: { close($CONFIG_STATUS); } - # --with-parrot and --gen-parrot imply --gen-nqp - if (defined $with_parrot || defined $gen_parrot) { - $options{'gen-nqp'} ||= ''; - } + $config{prefix} = $prefix; + $config{slash} = $slash; + $config{'makefile-timing'} = $options{'makefile-timing'}; + $config{'stagestats'} = '--stagestats' if $options{'makefile-timing'}; + $config{'cpsep'} = $^O eq 'MSWin32' ? ';' : ':'; + $config{'shell'} = $^O eq 'MSWin32' ? 'cmd' : 'sh'; + my $make = $config{'make'} = $^O eq 'MSWin32' ? 'nmake' : 'make'; - $options{'gen-nqp'} ||= "nqp" if defined $options{'gen-nqp'}; - my $with_nqp = $options{'with-nqp'}; - my $gen_nqp = $options{'gen-nqp'}; + my @prefixes = sort map substr($_, 0, 1), keys %backends; # determine the version of NQP we want - my ($nqp_want) = split(' ', slurp("rakudo/tools/build/NQP_REVISION")); + my ($nqp_want) = split(' ', slurp('rakudo/tools/build/NQP_REVISION')); - if (defined $gen_nqp) { - $with_nqp = gen_nqp($nqp_want, %options); - } + my %binaries; + my %impls = gen_nqp($nqp_want, prefix => $prefix, backends => join(',', sort keys %backends), %options); my @errors; + if ($backends{parrot}) { + my %nqp_config; + if ($impls{parrot}{config}) { + %nqp_config = %{ $impls{parrot}{config} }; + } + else { + push @errors, "Cannot obtain configuration from NQP on parrot"; + } - my %nqp_config; - if ($with_nqp) { - %nqp_config = read_config($with_nqp) - or push @errors, "Unable to read configuration from $with_nqp."; - } - else { - %nqp_config = read_config("$prefix/bin/nqp$exe", "nqp$exe") - or push @errors, "Unable to find an NQP executable."; - $with_nqp = fill_template_text('@bindir@/nqp@exe@', %nqp_config) - } + my $nqp_have = $nqp_config{'nqp::version'} || ''; + if ($nqp_have && cmp_rev($nqp_have, $nqp_want) < 0) { + push @errors, "NQP revision $nqp_want required (currently $nqp_have)."; + } - %config = (%config, %nqp_config); - my $nqp_have = $config{'nqp::version'} || ''; - if ($nqp_have && cmp_rev($nqp_have, $nqp_want) < 0) { - push @errors, "NQP revision $nqp_want required (currently $nqp_have)."; - } + if (!@errors) { + push @errors, verify_install([ @NQP::Configure::required_parrot_files, + @NQP::Configure::required_nqp_files ], + %config, %nqp_config); + push @errors, + "(Perhaps you need to 'make install', 'make install-dev',", + "or install the 'devel' package for NQP or Parrot?)" + if @errors; + } - if (!@errors) { - push @errors, verify_install([ @NQP::Configure::required_parrot_files, - @NQP::Configure::required_nqp_files ], - %config); - push @errors, - "(Perhaps you need to 'make install', 'make install-dev',", - "or install the 'devel' package for NQP or Parrot?)" - if @errors; - } + if (@errors && !defined $options{'gen-nqp'}) { + push @errors, + "\nTo automatically clone (git) and build a copy of NQP $nqp_want,", + "try re-running Configure.pl with the '--gen-nqp' or '--gen-parrot'", + "options. Or, use '--prefix=' to explicitly", + "specify the path where the NQP and Parrot executable can be found that are use to build $lang."; + } + + sorry(@errors) if @errors; - if (@errors && !defined $gen_nqp) { - push @errors, - "\nTo automatically clone (git) and build a copy of NQP $nqp_want,", - "try re-running Configure.pl with the '--gen-nqp' or '--gen-parrot'", - "options. Or, use '--with-nqp=' or '--with-parrot=' to explicitly", - "specify the NQP or Parrot executable to use to build $lang."; + print "Using $impls{parrot}{bin} (version $nqp_config{'nqp::version'}).\n"; } + if ($backends{jvm}) { + $config{j_nqp} = $impls{jvm}{bin}; + $config{j_nqp} =~ s{/}{\\}g if $^O eq 'MSWin32'; + my %nqp_config; + if ( $impls{jvm}{config} ) { + %nqp_config = %{ $impls{jvm}{config} }; + } + else { + push @errors, "Unable to read configuration from NQP on the JVM"; + } + my $bin = $impls{jvm}{bin}; - sorry(@errors) if @errors; + if (!@errors && !defined $nqp_config{'jvm::runtime.jars'}) { + push @errors, "jvm::runtime.jars value not available from $bin --show-config."; + } - print "Using $with_nqp (version $config{'nqp::version'}).\n"; + sorry(@errors) if @errors; + + print "Using $bin.\n"; - $config{'makefile-timing'} = $options{'makefile-timing'}; - $config{'stagestats'} = '--stagestats' if $options{'makefile-timing'}; - $config{'shell'} = $^O eq 'MSWin32' ? 'cmd' : 'sh'; - if ($^O eq 'MSWin32' or $^O eq 'cygwin') { - $config{'dll'} = '$(PARROT_BIN_DIR)/$(PARROT_LIB_SHARED)'; - $config{'dllcopy'} = '$(PARROT_LIB_SHARED)'; - $config{'make_dllcopy'} = - '$(PARROT_DLL_COPY): $(PARROT_DLL)'."\n\t".'$(CP) $(PARROT_DLL) .'; } - my $make = fill_template_text('@make@', %config); fill_template_file('tools/build/Makefile.in', 'Makefile', %config); - { + unless ($options{'no-clean'}) { no warnings; print "Cleaning up ...\n"; if (open my $CLEAN, '-|', "$make configclean") { @@ -151,8 +202,8 @@ MAIN: { } else { print "\nYou can now use '$make' to build $lang.\n"; - print "After that, '$make test' provides information on running tests\n"; - print "and '$make install' will install $lang.\n"; + print "After that, '$make test' will run some tests and\n"; + print "'$make install' will install $lang.\n"; } exit 0; @@ -166,17 +217,17 @@ Configure.pl - $lang Configure General Options: --help Show this text - --prefix=dir Install files in dir - --with-nqp=path/to/bin/nqp - NQP executable to use to build $lang + --prefix=dir Install files in dir; also look for executables there + --backends=parrot,jvm Which backend(s) to use --gen-nqp[=branch] Download and build a copy of NQP - --with-parrot=path/to/bin/parrot - Parrot executable to use to build NQP --gen-parrot[=branch] Download and build a copy of Parrot --parrot-option='--option' Options to pass to Parrot's Configure.pl + --parrot-make-option='--option' + Options to pass to Parrot's make, for example: + --parrot-make-option='--jobs=4' --makefile-timing Enable timing of individual makefile commands Configure.pl also reads options from 'config.default' in the current directory. @@ -185,7 +236,6 @@ END return; } - sub download_text { ("The git repository contains the tools needed to build a Rakudo Star", "release, but does not contain a complete Rakudo Star release.", @@ -199,6 +249,7 @@ sub worry { print join "\n", @text, ''; } + # Local Variables: # mode: cperl # cperl-indent-level: 4 diff --git a/modules/DBIish b/modules/DBIish index b0c5d75..51cfd5a 160000 --- a/modules/DBIish +++ b/modules/DBIish @@ -1 +1 @@ -Subproject commit b0c5d75f7fd8d00d44748169f53c4e515e7b1055 +Subproject commit 51cfd5a96214899da7eb97ea2b1adea85e1d5cc6 diff --git a/modules/Perl6-MIME-Base64 b/modules/Perl6-MIME-Base64 index 8302767..42bb156 160000 --- a/modules/Perl6-MIME-Base64 +++ b/modules/Perl6-MIME-Base64 @@ -1 +1 @@ -Subproject commit 8302767094ffcae6987cc52a2c99bd8185cea868 +Subproject commit 42bb15693c8549fc411c4b5e578642fab28fa155 diff --git a/modules/json b/modules/json index 79a707f..2fe251e 160000 --- a/modules/json +++ b/modules/json @@ -1 +1 @@ -Subproject commit 79a707fa6161a3bcd348e850c55e749153132af8 +Subproject commit 2fe251e12bdc213783e5bdce6ac02178f3449d8c diff --git a/modules/panda b/modules/panda index 08e09b0..da441fd 160000 --- a/modules/panda +++ b/modules/panda @@ -1 +1 @@ -Subproject commit 08e09b0f529b640816c222ac63c826584c81c528 +Subproject commit da441fddcc80701f978c51b82525ea5194c28a35 diff --git a/modules/perl6-Term-ANSIColor b/modules/perl6-Term-ANSIColor index d0af2ab..8068020 160000 --- a/modules/perl6-Term-ANSIColor +++ b/modules/perl6-Term-ANSIColor @@ -1 +1 @@ -Subproject commit d0af2ab20fc0b2f4152798f3c2c21574b3088711 +Subproject commit 8068020c6f29442d99617bc491a30d6d066a4a02 diff --git a/modules/rakudo-debugger b/modules/rakudo-debugger index 33b17a7..af2f675 160000 --- a/modules/rakudo-debugger +++ b/modules/rakudo-debugger @@ -1 +1 @@ -Subproject commit 33b17a7e0a8972f12f9017dae37ed5af8d5b071a +Subproject commit af2f6756f0fe85502a94ad063027ba9dc61fa6c5 diff --git a/modules/shell-command b/modules/shell-command index 1b89c9e..2bff90e 160000 --- a/modules/shell-command +++ b/modules/shell-command @@ -1 +1 @@ -Subproject commit 1b89c9e18682897eb120b15885dbb3a502ecded0 +Subproject commit 2bff90ec2b12560d1072cfca3a1657dab0a0088c diff --git a/modules/zavolaj b/modules/zavolaj index 50bcadd..6f912ac 160000 --- a/modules/zavolaj +++ b/modules/zavolaj @@ -1 +1 @@ -Subproject commit 50bcadd31cf270a6dad26c1a3e2f3933ac160a01 +Subproject commit 6f912aca5f8865e1e3fc7936f9e6d47da17acb27 diff --git a/tools/build/Makefile.in b/tools/build/Makefile.in index 42aa229..c27cf49 100644 --- a/tools/build/Makefile.in +++ b/tools/build/Makefile.in @@ -64,7 +64,7 @@ all: rakudo rakudo: $(RAKUDO_DIR)/$(PERL6_EXE) $(RAKUDO_DIR)/$(PERL6_EXE): @echo "== Configuring and building Rakudo" - cd $(RAKUDO_DIR) && $(PERL) Configure.pl --with-nqp=$(NQP_EXE) && $(MAKE) + cd $(RAKUDO_DIR) && $(PERL) Configure.pl --prefix=$(PREFIX_DIR) && $(MAKE) rakudo-test: rakudo cd $(RAKUDO_DIR) && $(MAKE) test rakudo-spectest: rakudo diff --git a/tools/lib/NQP/Configure.pm b/tools/lib/NQP/Configure.pm index f12e3b3..641d2c6 100644 --- a/tools/lib/NQP/Configure.pm +++ b/tools/lib/NQP/Configure.pm @@ -228,6 +228,10 @@ sub git_checkout { } else { chdir($dir); + unless (-e '.git') { + chdir $pwd; + return; + } system_or_die('git', 'fetch'); } -- cgit v1.1