# New Ticket Created by Tim Nelson # Please include the string: [perl #66056] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=66056 >
The attached patch depends on Parrot ticket 712. Some of the code comes from stuff that Allison sent me, and the rest is of my own devising. https://trac.parrot.org/parrot/ticket/712 Hope this helps, --------------------------------------------------------------------- | Name: Tim Nelson | Because the Creator is, | | E-mail: wayl...@wayland.id.au | I am | --------------------------------------------------------------------- ----BEGIN GEEK CODE BLOCK---- Version 3.12 GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y- -----END GEEK CODE BLOCK-----
diff --git a/Configure.pl b/Configure.pl index 07bbf0d..94c2a95 100644 --- a/Configure.pl +++ b/Configure.pl @@ -5,10 +5,14 @@ use 5.008; use strict; use warnings; use Getopt::Long; +use Cwd qw(abs_path); MAIN: { - my %options; - GetOptions(\%options, 'help!', 'parrot-config=s', + my %options = ( + 'build-root' => '/', + 'rakudo-version' => 'build17', + ); + GetOptions(\%options, 'help!', 'parrot-config=s', 'build-root=s', 'rakudo-version=s', 'gen-parrot!', 'gen-parrot-option=s@'); # Print help if it's requested @@ -52,7 +56,14 @@ MAIN: { $parrot_errors .= "Unable to locate parrot_config\n"; } elsif ($required > $config{'revision'}) { - $parrot_errors .= "Parrot revision r$required required (currently r$config{'revision'})\n"; + # If Parrot was built from a tarball or package, the revision number + # is 0, so we'd need to use the Parrot version instead. But even + # that is unreliable, as someone may have built their own package + # from SVN. So just let them do their thing, and worry about it + # some other time. + if($config{'revision'} != 0) { + $parrot_errors .= "Parrot revision r$required required (currently r$config{'revision'})\n"; + } } if ($parrot_errors) { @@ -65,8 +76,19 @@ the location of parrot_config to be used to build Rakudo Perl. END } + $options{'build-root'} =~ s#/#$config{slash}#g; + + my($short); + my(%rakudo_config) = (); + foreach(qw(build-root rakudo-version)) { + $short = $_; + $short =~ s/-//g; + $rakudo_config{$short} = $options{$_}; + } + $rakudo_config{buildroot} = abs_path($rakudo_config{buildroot}); + # Create the Makefile using the information we just got - create_makefile(%config); + create_makefiles(\%config, \%rakudo_config); my $make = $config{'make'}; { @@ -110,26 +132,44 @@ sub read_parrot_config { # Generate a Makefile from a configuration -sub create_makefile { - my %config = @_; - - my $maketext = slurp( 'build/Makefile.in' ); +sub create_makefiles { + my($config, $rakudo_config) = @_; + my %makefiles = ( + "build/Makefile.in" => "Makefile", + "build/pmc_makefile.in" => "src/pmc/Makefile", + "build/ops_makefile.in" => "src/ops/Makefile", + ); + my $build_tool = $config->{perl} . " " + . $config->{libdir} + . $config->{versiondir} + . $config->{slash} + . "tools" + . $config->{slash} + . "dev" + . $config->{slash} + . "gen_makefile.pl"; + + my($text); + foreach my $template (keys %makefiles) { + my $makefile = $makefiles{$template}; + print "Creating $makefile\n"; + $text = slurp($template); + $config->{'win32_libparrot_copy'} = $^O eq 'MSWin32' ? 'copy $(BUILD_DIR)\libparrot.dll .' : ''; + $text =~ s{\@(\w+)\...@}{ + defined($rakudo_config->{$1}) ? $rakudo_config->{$1} : $& + }eg; + if ($^O eq 'MSWin32') { + $text =~ s{/}{\\}g; + $text =~ s{\\\*}{\\\\*}g; + $text =~ s{http:\S+}{ do {my $t = $&; $t =~ s'\\'/'g; $t} }eg; + } - $config{'win32_libparrot_copy'} = $^O eq 'MSWin32' ? 'copy $(BUILD_DIR)\libparrot.dll .' : ''; - $maketext =~ s/@(\w+)@/$config{$1}/g; - if ($^O eq 'MSWin32') { - $maketext =~ s{/}{\\}g; - $maketext =~ s{\\\*}{\\\\*}g; - $maketext =~ s{http:\S+}{ do {my $t = $&; $t =~ s'\\'/'g; $t} }eg; + open(FILE, ">$template.tmp") or die "Error opening file '$template.tmp' for writing: $!"; + print FILE $text; + close(FILE); + system("$build_tool $template.tmp $makefile"); } - my $outfile = 'Makefile'; - print "\nCreating $outfile ...\n"; - open(my $MAKEOUT, '>', $outfile) || - die "Unable to write $outfile\n"; - print {$MAKEOUT} $maketext; - close $MAKEOUT or die $!; - return; } @@ -157,6 +197,10 @@ General Options: Set parrot config option when using --gen-parrot --parrot-config=(config) Use configuration information from config + --build-root=(directory) + Root of directory to build Rakudo in + --rakudo-version=(version) + Version of Rakudo to call this build END return; diff --git a/build/Makefile.in b/build/Makefile.in index 954e204..da025ce 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -1,11 +1,11 @@ # Copyright (C) 2006-2009, The Perl Foundation. # $Id$ -# arguments we want to run parrot with -PARROT_ARGS = - # values from parrot_config -BUILD_DIR = @build_dir@ +VERSION_DIR = @versiondir@ +LIB_DIR = @lib...@$(VERSION_DIR) +BIN_DIR = @bindir@ +TOOLS_DIR = @lib...@$(VERSION_DIR)@sl...@tools@sl...@lib LOAD_EXT = @load_ext@ O = @o@ EXE = @exe@ @@ -14,22 +14,23 @@ RM_F = @rm_f@ HAS_ICU = @has_icu@ # Various paths -PARROT_DYNEXT = $(BUILD_DIR)/runtime/parrot/dynext -PERL6GRAMMAR = $(BUILD_DIR)/runtime/parrot/library/PGE/Perl6Grammar.pbc -NQP = $(BUILD_DIR)/compilers/nqp/nqp.pbc -PCT = $(BUILD_DIR)/runtime/parrot/library/PCT.pbc +PARROT_DYNEXT = $(LIB_DIR)/dynext +RAKUDO_DYNEXT = @buildroot@@sl...@usr@sl...@lib@sl...@rakudo@slash@@rakudoversion@@sl...@dynext +PERL6GRAMMAR = $(LIB_DIR)/library/PGE/Perl6Grammar.pbc +NQP = $(LIB_DIR)/languages/nqp/nqp.pbc +PCT = $(LIB_DIR)/library/PCT.pbc PMC_DIR = src/pmc -OPSDIR = src/ops +OPS_DIR = src/ops OPSLIB = perl6 -OPS_FILE = src/ops/perl6.ops +OPS_FILE = $(OPS_DIR)/perl6.ops + +# arguments we want to run parrot with +PARROT_ARGS = -X$(RAKUDO_DYNEXT) # Setup some commands -PARROT = $(BUILD_DIR)/parrot$(EXE) +PARROT = $(BIN_DIR)/parrot$(EXE) CAT = $(PERL) -MExtUtils::Command -e cat -BUILD_DYNPMC = $(PERL) $(BUILD_DIR)/tools/build/dynpmc.pl -BUILD_DYNOPS = $(PERL) $(BUILD_DIR)/tools/build/dynoplibs.pl -RECONFIGURE = $(PERL) $(BUILD_DIR)/tools/dev/reconfigure.pl -PBC_TO_EXE = $(BUILD_DIR)/pbc_to_exe$(EXE) +PBC_TO_EXE = $(BIN_DIR)/pbc_to_exe$(EXE) SOURCES = perl6.pir \ src/gen_grammar.pir \ @@ -48,7 +49,7 @@ SOURCES = perl6.pir \ src/parrot/state.pir \ src/gen_uprop.pir \ $(PERL6_GROUP) \ - src/ops/perl6_ops$(LOAD_EXT) + $(OPS_DIR)/perl6_ops$(LOAD_EXT) BUILTINS_PIR = \ src/classes/Object.pir \ @@ -124,8 +125,6 @@ SETTING = \ src/setting/Range.pm \ src/setting/Whatever.pm \ -PMCS = perl6str objectref perl6scalar mutablevar perl6multisub p6invocation - PMC_SOURCES = $(PMC_DIR)/perl6str.pmc $(PMC_DIR)/objectref.pmc $(PMC_DIR)/perl6scalar.pmc \ $(PMC_DIR)/mutablevar.pmc $(PMC_DIR)/perl6multisub.pmc $(PMC_DIR)/p6invocation.pmc @@ -153,14 +152,14 @@ CLEANUPS = \ $(PMC_DIR)/*.pdb \ $(PMC_DIR)/*.lib \ $(PMC_DIR)/objectref.pmc \ - $(OPSDIR)/*.h \ - $(OPSDIR)/*.c \ - $(OPSDIR)/*$(O) \ - $(OPSDIR)/*$(LOAD_EXT) \ + $(OPS_DIR)/*.h \ + $(OPS_DIR)/*.c \ + $(OPS_DIR)/*$(O) \ + $(OPS_DIR)/*$(LOAD_EXT) \ # NOTE: eventually, we should remove --keep-exit-code and --fudge # as the goal is that all tests must pass without fudge -HARNESS_WITH_FUDGE = $(PERL) t/harness --fudge --keep-exit-code --icu=$(HAS_ICU) +HARNESS_WITH_FUDGE = $(PERL) -I$(TOOLS_DIR) t/harness --bindir=$(BIN_DIR) --fudge --keep-exit-code --icu=$(HAS_ICU) HARNESS_WITH_FUDGE_JOBS = $(HARNESS_WITH_FUDGE) --jobs @@ -172,7 +171,7 @@ xmas: perl6$(EXE) ## targets for building a standalone perl6. perl6$(EXE): perl6.pbc $(PBC_TO_EXE) perl6.pbc - @win32_libparrot_copy@ +#IF(win32): copy $(LIB_DIR)\libparrot.dll . # the Perl 6 compiler perl6.pbc: perl6_s1.pbc src/gen_setting.pm @@ -211,20 +210,15 @@ src/gen_uprop.pir: build/gen_uprop_pir.pl src/gen_setting.pm: build/gen_setting_pm.pl $(SETTING) $(PERL) build/gen_setting_pm.pl $(SETTING) > src/gen_setting.pm -$(PERL6_GROUP): $(PARROT) $(PMC_SOURCES) - cd $(PMC_DIR) && $(BUILD_DYNPMC) generate $(PMCS) - cd $(PMC_DIR) && $(BUILD_DYNPMC) compile $(PMCS) - cd $(PMC_DIR) && $(BUILD_DYNPMC) linklibs $(PMCS) - cd $(PMC_DIR) && $(BUILD_DYNPMC) copy --destination=$(PARROT_DYNEXT) $(PMCS) +$(PERL6_GROUP): $(PARROT) $(PMC_SOURCES) $(PMC_DIR)/Makefile + $(MAKE) -C $(PMC_DIR) + +$(OPS_DIR)/perl6_ops$(LOAD_EXT) : $(OPS_FILE) $(OPS_DIR)/Makefile + $(MAKE) -C $(OPS_DIR) -src/ops/perl6_ops$(LOAD_EXT) : $(PARROT) $(OPS_FILE) - @cd $(OPSDIR) && $(BUILD_DYNOPS) generate $(OPSLIB) - @cd $(OPSDIR) && $(BUILD_DYNOPS) compile $(OPSLIB) - @cd $(OPSDIR) && $(BUILD_DYNOPS) linklibs $(OPSLIB) - @cd $(OPSDIR) && $(BUILD_DYNOPS) copy "--destination=$(PARROT_DYNEXT)" $(OPSLIB) $(PMC_DIR)/objectref.pmc : $(PMC_DIR)/objectref_pmc.template build/gen_objectref_pmc.pl - $(PERL) -I$(BUILD_DIR)/lib build/gen_objectref_pmc.pl $(PMC_DIR)/objectref_pmc.template \ + $(PERL) -I$(TOOLS_DIR) build/gen_objectref_pmc.pl $(PMC_DIR)/objectref_pmc.template \ $(PMC_DIR)/objectref.pmc @@ -237,7 +231,7 @@ test : coretest fulltest: coretest spectest coretest: perl6$(EXE) - $(PERL) t/harness t/00-parrot t/01-sanity + $(PERL) -I$(TOOLS_DIR) t/harness --bindir=$(BIN_DIR) t/00-parrot t/01-sanity # Run the spectests that we know work. spectest_regression: spectest @@ -338,7 +332,8 @@ parrot: build/PARROT_REVISION build/gen_parrot.pl $(PARROT): -CRITIC_FILES=Configure.pl t/harness build/ tools/ +# Next line must not end with a slash; I added a space +CRITIC_FILES=Configure.pl t/harness build/ tools/ perlcritic: perlcritic -1 --profile tools/util/perlcritic.conf $(CRITIC_FILES) @@ -357,3 +352,21 @@ release: manifest $(PERL) -ne 'print "rakudo-$(VERSION)/$$_"' MANIFEST | \ tar -zcv -T - -f rakudo-$(VERSION).tar.gz rm rakudo-$(VERSION) + +install: + $(PERL) -I/usr/lib/parrot/1.2.0-devel/tools/lib/ tools/build/install_files.pl \ + --buildprefix=$(BUILDPREFIX) \ + --prefix=$(PREFIX) \ + --exec-prefix=$(EXEC_PREFIX) \ + --bindir=$(BIN_DIR) \ + --libdir=$(LIB_DIR) \ + --includedir=$(INCLUDE_DIR) \ + --destdir=$(DESTDIR) \ + --docdir=$(DOC_DIR) \ + --datadir=$(DATA_DIR) \ + --srcd...@srcdir@ \ + --versiondir=$(VERSION_DIR) \ + MANIFEST + + +# diff --git a/t/harness b/t/harness index b67d164..71bf09b 100644 --- a/t/harness +++ b/t/harness @@ -21,10 +21,20 @@ GetOptions( 'tests-from-file=s' => \my $list_file, 'fudge' => \my $do_fudge, 'verbosity=i' => \$Test::Harness::verbose, + 'bindir=s' => \$harness_args{bindir}, 'jobs:3' => \my $jobs, 'icu:1' => \my $do_icu, ); +if ($harness_args{bindir}) { + $harness_args{exec} = [$harness_args{bindir}.'/parrot', 'perl6.pbc']; +} elsif (-d 'parrot') { + $harness_args{exec} = ['parrot/parrot', 'perl6.pbc']; +} else { + $harness_args{compiler} = 'perl6.pbc'; +} + + my @pass_through_options = grep m/^--?[^-]/, @ARGV; my @files = grep m/^[^-]/, @ARGV; @@ -56,7 +66,8 @@ if ($do_fudge) { if (eval { require TAP::Harness; 1 }) { my %harness_options = ( - exec => ['./perl6'], + %harness_args, +# exec => ['./perl6'], verbosity => 0+$Test::Harness::verbose, jobs => $jobs || 1, );