Skip to content

Commit

Permalink
builder: add capability to work with staging directories
Browse files Browse the repository at this point in the history
To allow building for a staging root which might differ from host and tools to be used,
be more careful about the PATH's to be used. This will allow cross-compiling rakudo
using two builds of nqp: a native one in SDKROOT and a cross-compiled one in SYSROOT.
Using host one remains untouched when run without --sysroot or --sdkroot, respectively.

Signed-off-by: Jens Rehsack <sno@netbsd.org>
  • Loading branch information
rehsack committed Nov 10, 2015
1 parent bb49e08 commit 253e633
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
1 change: 1 addition & 0 deletions Configure.pl
Expand Up @@ -224,6 +224,7 @@

$config{'nqp_prefix'} = $nqp_config{'jvm::prefix'};
$config{'nqp_jars'} = $nqp_config{'jvm::runtime.jars'};
$config{'bld_nqp_jars'} = join( $config{'cpsep'}, map { $config{'sysroot'} . $_ } split( $config{'cpsep'}, $nqp_config{'jvm::runtime.jars'} ) );
$config{'nqp_classpath'} = $nqp_config{'jvm::runtime.classpath'};
$config{'j_runner'} = $win ? 'perl6-j.bat' : 'perl6-j';

Expand Down
14 changes: 9 additions & 5 deletions tools/build/Makefile-JVM.in
Expand Up @@ -11,8 +11,10 @@ J_BUILD_DIR = gen/jvm
PERL6_LANG_DIR = $(PREFIX)/share/perl6

NQP_JARS = @nqp_jars@
BLD_NQP_JARS = @bld_nqp_jars@

J_RUN_PERL6 = $(JAVA) -Xss1m -Xms500m -Xmx2000m -Xbootclasspath/a:.@cpsep@$(NQP_JARS)@cpsep@rakudo-runtime.jar@cpsep@perl6.jar -cp @nqp_classpath@ perl6
J_RUN_NQP_RR = $(JAVA) -Xss1m -Xms500m -Xmx2000m -Xbootclasspath/a:.@cpsep@$(BLD_NQP_JARS)@cpsep@rakudo-runtime.jar -cp $(SYSROOT)@nqp_classpath@ nqp
J_RUN_PERL6 = $(JAVA) -Xss1m -Xms500m -Xmx2000m -Xbootclasspath/a:.@cpsep@$(BLD_NQP_JARS)@cpsep@rakudo-runtime.jar@cpsep@perl6.jar -cp $(SYSROOT)@nqp_classpath@ perl6

RUNTIME_JAVAS = src/vm/jvm/runtime/org/perl6/rakudo/*.java

Expand Down Expand Up @@ -248,7 +250,7 @@ j-all: $(PERL6_JAR) $(SETTING_JAR) $(J_RUNNER) lib/Test.pm.jar lib/lib.pm6.jar l

$(RUNTIME_JAR): $(RUNTIME_JAVAS)
$(PERL) -MExtUtils::Command -e mkpath bin
$(JAVAC) -source 1.7 -cp $(NQP_JARS) -g -d bin -encoding UTF8 $(RUNTIME_JAVAS)
$(JAVAC) -source 1.7 -cp $(BLD_NQP_JARS) -g -d bin -encoding UTF8 $(RUNTIME_JAVAS)
$(JAR) cf0 rakudo-runtime.jar -C bin/ .

$(PERL6_ML_JAR): src/Perl6/ModuleLoader.nqp src/vm/jvm/ModuleLoaderVMConfig.nqp src/vm/jvm/Perl6/JavaModuleLoader.nqp
Expand Down Expand Up @@ -299,8 +301,7 @@ $(PERL6_M_JAR): $(J_METAMODEL_SOURCES) $(PERL6_OPS_JAR)

$(PERL6_B_JAR): $(BOOTSTRAP_SOURCES) $(PERL6_M_JAR)
$(J_NQP) $(J_GEN_CAT) $(BOOTSTRAP_SOURCES) > $(J_BUILD_DIR)/BOOTSTRAP.nqp
$(PERL) tools/build/nqp-jvm-rr.pl $(J_NQP) --target=jar \
--output=$(PERL6_B_JAR) --encoding=utf8 $(J_BUILD_DIR)/BOOTSTRAP.nqp
$(J_RUN_NQP_RR) --target=jar --output=$(PERL6_B_JAR) --encoding=utf8 $(J_BUILD_DIR)/BOOTSTRAP.nqp

$(SETTING_JAR): $(PERL6_JAR) $(PERL6_B_JAR) $(J_CORE_SOURCES)
$(J_NQP) $(J_GEN_CAT) $(J_CORE_SOURCES) > $(J_BUILD_DIR)/CORE.setting
Expand Down Expand Up @@ -347,12 +348,15 @@ lib/Pod/To/Text.pm.jar: lib/Pod/To/Text.pm $(PERL6_JAR) $(SETTING_JAR) $(J_RUNNE
lib/newline.pm6.jar: lib/newline.pm6 $(PERL6_JAR) $(SETTING_JAR) $(J_RUNNER)
.@slash@$(J_RUNNER) --target=jar --output=lib/newline.pm6.jar lib/newline.pm6

eval-client.pl:
$(CP) $(SDKROOT)$(NQP_PREFIX)/bin/eval-client.pl .

## testing targets
j-test : j-coretest

j-fulltest: j-coretest j-stresstest

j-coretest: j-all
j-coretest: j-all eval-client.pl
$(J_HARNESS) t/01-sanity t/03-jvm t/04-nativecall

# Run the spectests that we know work.
Expand Down
1 change: 1 addition & 0 deletions tools/build/Makefile-common.in
Expand Up @@ -9,6 +9,7 @@ RM_F = $(PERL) -MExtUtils::Command -e rm_f
RM_RF = $(PERL) -MExtUtils::Command -e rm_rf

SYSROOT= @sysroot@
SDKROOT= @sdkroot@
PREFIX = @prefix@
PERL6_LANG_DIR = $(PREFIX)/share/perl6

Expand Down
34 changes: 19 additions & 15 deletions tools/build/create-jvm-runner.pl
Expand Up @@ -23,15 +23,26 @@
my $cpsep = $^O eq 'MSWin32' ? ';' : ':';
my $bat = $^O eq 'MSWin32' ? '.bat' : '';

my $preamble = $^O eq 'MSWin32' ? '@' : '#!/bin/sh
exec ';
my $postamble = $^O eq 'MSWin32' ? ' %*' : ' "$@"';

my $nqpdir = File::Spec->catfile($nqpprefix, 'share', 'nqp');
my $nqplibdir = $^O eq 'MSWin32' ? File::Spec->catfile($nqpdir, 'lib') : File::Spec->catfile('${NQP_DIR}', 'lib');
my $nqpjars = $^O eq 'MSWin32' ? $thirdpartyjars : join( $cpsep, map { $_ =~ s,$nqpdir,\${NQP_DIR},g; $_ } split($cpsep, $thirdpartyjars) );
my $bindir = $type eq 'install' ? File::Spec->catfile($prefix, 'bin') : $prefix;
my $jardir = $type eq 'install' ? File::Spec->catfile($prefix, 'share', 'perl6', 'runtime') : $prefix;
my $libdir = $type eq 'install' ? File::Spec->catfile($prefix, 'share', 'perl6', 'lib') : 'blib';
my $nqplibdir = File::Spec->catfile($nqpprefix, 'share', 'nqp', 'lib');
my $perl6dir = $type eq 'install' ? File::Spec->catfile($prefix, 'share', 'perl6') : $prefix;
my $jardir = $type eq 'install' ? File::Spec->catfile($^O eq 'MSWin32' ? $perl6dir : '${PERL6_DIR}', 'runtime') : $prefix;
my $libdir = $type eq 'install' ? File::Spec->catfile($^O eq 'MSWin32' ? $perl6dir : '${PERL6_DIR}', 'lib') : 'blib';
my $sharedir = File::Spec->catfile($prefix, 'share', 'perl6', 'site', 'lib');
my $perl6jars = join( $cpsep,
$^O eq 'MSWin32' ? $nqpjars : '${NQP_JARS}',
File::Spec->catfile($jardir, 'rakudo-runtime.jar'),
File::Spec->catfile($jardir, $debugger ? 'perl6-debug.jar' : 'perl6.jar'));

my $preamble = $^O eq 'MSWin32' ? '@' : "#!/bin/sh
: \${NQP_DIR:=\"$nqpdir\"}
: \${NQP_JARS:=\"$nqpjars\"}
: \${PERL6_DIR:=\"$perl6dir\"}
: \${PERL6_JARS:=\"$perl6jars\"}
exec ";
my $postamble = $^O eq 'MSWin32' ? ' %*' : ' "$@"';

sub install {
my ($name, $command) = @_;
Expand All @@ -48,13 +59,8 @@ sub install {
chmod 0755, $install_to if $^O ne 'MSWin32';
}

my $bootclasspath = join($cpsep,
($thirdpartyjars,
File::Spec->catfile($jardir, 'rakudo-runtime.jar'),
File::Spec->catfile($jardir, $debugger ? 'perl6-debug.jar' : 'perl6.jar')));

my $classpath = join($cpsep, ($jardir, $libdir, $nqplibdir));
my $jopts = '-noverify -Xms100m -Xbootclasspath/a:' . $bootclasspath
my $jopts = '-noverify -Xms100m -Xbootclasspath/a:' . $perl6jars
. ' -cp ' . ($^O eq 'MSWin32' ? '"%CLASSPATH%";' : '$CLASSPATH:') . $classpath
. ' -Dperl6.prefix=' . $prefix
. ' -Djna.library.path=' . $sharedir
Expand All @@ -67,6 +73,4 @@ sub install {
install "perl6-j", "java $jopts perl6";
install "perl6-jdb-server", "java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y $jopts perl6";
install "perl6-eval-server", "java -Xmx3000m -XX:MaxPermSize=200m $jopts org.perl6.nqp.tools.EvalServer";
cp(File::Spec->catfile($nqpprefix,'bin','eval-client.pl'), '.')
or die "Couldn't copy 'eval-client.pl' from $nqpprefix: $!";
}

0 comments on commit 253e633

Please sign in to comment.