[svn:parrot] r38147 - in trunk: . tools/dev
pmichaud at svn.parrot.org
pmichaud at svn.parrot.org
Thu Apr 16 05:21:26 UTC 2009
Author: pmichaud
Date: Thu Apr 16 05:21:25 2009
New Revision: 38147
URL: https://trac.parrot.org/parrot/changeset/38147
Log:
Add tools/dev/create_language.pl, a substantially modified version of tools/dev/mk_language_shell.pl .
Significant differences:
* Languages now go to any path, not just languages/foo/
* No longer relies on Parrot's configuration tools
* Uses an independent t/harness (no longer requires Parrot::Test::Harness)
* Supports the --gen-parrot and build/PARROT_REVISION options (from Rakudo)
* Switches src/parser/* to be src/pct/*
* Converts actions.pm to use $<match>.ast instead of deprecated $($<match>)
There are still updates needed to make this work well with
installed parrot and provide a 'make install' target -- these
will be added shortly.
Added:
trunk/tools/dev/create_language.pl
- copied, changed from r38144, trunk/tools/dev/mk_language_shell.pl
Modified:
trunk/MANIFEST
Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST Thu Apr 16 03:36:40 2009 (r38146)
+++ trunk/MANIFEST Thu Apr 16 05:21:25 2009 (r38147)
@@ -1,7 +1,7 @@
# ex: set ro:
# $Id$
#
-# generated by tools/dev/mk_manifest_and_skip.pl Wed Apr 15 17:57:34 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Thu Apr 16 05:13:39 2009 UT
#
# See tools/dev/install_files.pl for documentation on the
# format of this file.
@@ -2060,6 +2060,7 @@
tools/dev/as2c.pl []
tools/dev/bench_op.pir []
tools/dev/cc_flags.pl []
+tools/dev/create_language.pl []
tools/dev/debian_docs.sh []
tools/dev/fetch_languages.pl []
tools/dev/gen_charset_tables.pl []
Copied and modified: trunk/tools/dev/create_language.pl (from r38144, trunk/tools/dev/mk_language_shell.pl)
==============================================================================
--- trunk/tools/dev/mk_language_shell.pl Thu Apr 16 02:25:38 2009 (r38144, copy source)
+++ trunk/tools/dev/create_language.pl Thu Apr 16 05:21:25 2009 (r38147)
@@ -1,63 +1,42 @@
#! perl
-# Copyright (C) 2007-2008, Parrot Foundation.
+# Copyright (C) 2007-2009, Parrot Foundation.
# $Id$
=head1 NAME
-tools/dev/mk_language_shell.pl -- create initial files for a new language
+create_language.pl -- create initial files for a new language
=head1 SYNOPSIS
- % perl tools/dev/mk_language_shell.pl [options] Xyz [path]
-
-option:
-
- --with-doc
- --with-ops
- --with-pmc
+% perl tools/dev/create_language.pl Xyz [path]
=head1 DESCRIPTION
This script populates a directory with files for building a
new language translator in Parrot. The first argument is the
name of the language to be built. The C<path> argument
-says where to populate the directory, if no C<path> is specified
-then it is taken to be a subdirectory in F<languages/> (with the
-name of the directory converted to lowercase).
+says where to populate the directory, if not given then the
+lowercase version of the language name is used.
For a language 'Xyz', this script will create the following
-files and directories (relative to C<path>, which defaults
-to F<languages/xyz> if an explicit C<path> isn't given):
+files and directories in C<path>:
README
Configure.pl
xyz.pir
- build/PARROT_REVISION
build/Makefile.in
- build/src/ops/Makefile.in
- build/src/pmc/Makefile.in
+ build/gen_builtins_pir.pl
build/gen_parrot.pl
- doc/running.pod
- doc/Xyz.pod
- dynext/.ignore
- library/.ignore
+ src/pct/grammar.pg
+ src/pct/grammar-oper.pg
+ src/pct/actions.pm
src/builtins/say.pir
- src/parser/grammar.pg
- src/parser/grammar-oper.pg
- src/parser/actions.pm
- src/pmc/xyz.pmc
- src/ops/xyz.ops
t/harness
t/00-sanity.t
Any files that already exist are skipped, so this script can
be used to repopulate a language directory with omitted files.
-After populating the language directory, the script attempts to
-run Configure.pl to automatically generate the Makefile
-from build/Makefile.in . This step is only executed if the
-optional C<path> argument is not specified.
-
If all goes well, after creating the language shell one can simply
change to the language directory and type
@@ -72,15 +51,6 @@
use lib 'lib';
use File::Path;
use File::Spec;
-use Getopt::Long;
-use Parrot::Config qw/ %PConfig /;
-
-my ($with_doc, $with_ops, $with_pmc);
-GetOptions(
- 'with-doc' => \$with_doc,
- 'with-ops' => \$with_ops,
- 'with-pmc' => \$with_pmc,
-);
unless (@ARGV) {
die "usage: $0 language [path]\n";
@@ -94,16 +64,11 @@
## the name and revision of the script, for use in the generated README
my $script = $0;
my $rev = '$Revision$';
-$rev =~ s/^\D*(\d+)\D*$/$1/;
-
-my $no_doc = $with_doc ? '' : '#';
-my $no_ops = $with_ops ? '' : '#';
-my $no_pmc = $with_pmc ? '' : '#';
+$rev =~ s/^\D*(\d+)\D*$/r$1/;
## get the path from the command line, or if not supplied then
## use languages/$lclang.
-my $path = $ARGV[1] ||
- "$PConfig{build_dir}$PConfig{slash}languages$PConfig{slash}$lclang";
+my $path = $ARGV[1] || $lclang;
## now loop through the file information (see below), substituting
## any instances of @lang@, @lclang@, @UCLANG@, and @Id@ with
@@ -118,21 +83,23 @@
s{\@Id\@} {\$Id\$}ig;
s{\@script\@} {$script}ig;
s{\@rev\@} {$rev}ig;
- s{\@no_doc\@} {$no_doc}ig;
- s{\@no_ops\@} {$no_ops}ig;
- s{\@no_pmc\@} {$no_pmc}ig;
- s{\@rev\@} {$rev}ig;
- if (/^__(.*)__$/) { start_new_file("$path$PConfig{slash}$1"); }
+ if (/^__(.*)__$/) { start_new_file("$path/$1"); }
elsif ($fh) { print $fh $_; }
}
## close the last file
close($fh) if $fh;
-## build the initial makefile if no path was specified on command line
-unless ($ARGV[1]) {
- my $reconfigure = "$PConfig{perl} Configure.pl";
- system("cd languages && cd $lclang && $reconfigure");
-}
+print <<"END";
+
+Your new language has been created in the $path directory.
+To do an initial build and test of the language:
+
+ cd $path
+ perl Configure.pl
+ make
+ make test
+
+END
## we're done
1;
@@ -143,30 +110,8 @@
## create any needed parent subdirectories.
sub start_new_file {
my ($filepath) = @_;
- if ($fh) {
- close $fh;
- undef $fh;
- }
- if (-e $filepath) {
- print "skipping $filepath\n";
- return;
- }
- if (!$with_doc and $filepath =~ /doc/) {
- print "no doc: skipping $filepath\n";
- return;
- }
- if (!$with_ops and $filepath =~ /ops/) {
- print "no ops: skipping $filepath\n";
- return;
- }
- if (!$with_pmc and $filepath =~ /pmc/) {
- print "no pmc: skipping $filepath\n";
- return;
- }
- if (!$with_ops and!$with_pmc and $filepath =~ /dynext/) {
- print "no dynext: skipping $filepath\n";
- return;
- }
+ if ($fh) { close $fh; undef $fh; }
+ if (-e $filepath) { print "skipping $filepath\n"; return; }
my ($volume, $dir, $base) = File::Spec->splitpath($filepath);
my $filedir = File::Spec->catpath($volume, $dir);
unless (-d $filedir) {
@@ -187,61 +132,73 @@
__DATA__
__README__
-Language '@lang@' was created with @script@, r at rev@.
-
-See doc/@lang at .pod for the documentation, and
-doc/running.pod for the command-line options.
+Language '@lang@' was created with @script@, @rev at .
__Configure.pl__
-# @Id@
-
-=head1 NAME
-
-Configure.pl - a configure script for a high level language running on Parrot
-
-=head1 SYNOPSIS
-
- perl Configure.pl --help
+#! perl
+use 5.008;
+use strict;
+use warnings;
+use Getopt::Long;
- perl Configure.pl
+MAIN: {
+ my %options;
+ GetOptions(\%options, 'help!', 'parrot-config=s',
+ 'gen-parrot!', 'gen-parrot-option=s@');
+
+ # Print help if it's requested
+ if ($options{'help'}) {
+ print_help();
+ exit(0);
+ }
+
+ # Update/generate parrot build if needed
+ if ($options{'gen-parrot'}) {
+ my @opts = @{ $options{'gen-parrot-option'} || [] };
+ my @command = ($^X, "build/gen_parrot.pl", @opts);
+
+ print "Generating Parrot ...\n";
+ print "@command\n\n";
+ system @command;
+ }
+
+ # Get a list of parrot-configs to invoke.
+ my @parrot_config_exe = qw(
+ parrot/parrot_config
+ ../../parrot_config
+ parrot_config
+ );
- perl Configure.pl --parrot_config=<path_to_parrot>
+ if ($options{'parrot-config'} && $options{'parrot-config'} ne '1') {
+ @parrot_config_exe = ($options{'parrot-config'});
+ }
- perl Configure.pl --gen-parrot [ -- --options-for-configure-parrot ]
+ # Get configuration information from parrot_config
+ my %config = read_parrot_config(@parrot_config_exe);
+ unless (%config) {
+ die <<'END';
+Unable to locate parrot_config.
+To automatically checkout (svn) and build a copy of parrot,
+try re-running Configure.pl with the '--gen-parrot' option.
+Or, use the '--parrot-config' option to explicitly specify
+the location of parrot_config.
+END
+ }
-=cut
+# Create the Makefile using the information we just got
+ create_makefile(%config);
-use strict;
-use warnings;
-use 5.008;
+ my $make = $config{'make'};
+ print <<"END";
-use Getopt::Long qw(:config auto_help);
+You can now use '$make' to build @lang at .
+After that, you can use '$make test' to run some local tests.
-our ( $opt_parrot_config, $opt_gen_parrot);
-GetOptions( 'parrot_config=s', 'gen-parrot' );
+END
+ exit 0;
-# Update/generate parrot build if needed
-if ($opt_gen_parrot) {
- system($^X, 'build/gen_parrot.pl', @ARGV);
-}
-
-# Get a list of parrot-configs to invoke.
-my @parrot_config_exe = $opt_parrot_config
- ? ( $opt_parrot_config )
- : (
- 'parrot/parrot_config',
- '../../parrot_config',
- 'parrot_config',
- );
-
-# Get configuration information from parrot_config
-my %config = read_parrot_config(@parrot_config_exe);
-unless (%config) {
- die "Unable to locate parrot_config.";
}
-# Create the Makefile using the information we just got
-create_makefiles(%config);
sub read_parrot_config {
my @parrot_config_exe = @_;
@@ -249,443 +206,283 @@
for my $exe (@parrot_config_exe) {
no warnings;
if (open my $PARROT_CONFIG, '-|', "$exe --dump") {
- print "Reading configuration information from $exe\n";
+ print "\nReading configuration information from $exe ...\n";
while (<$PARROT_CONFIG>) {
- $config{$1} = $2 if (/(\w+) => '(.*)'/);
+ if (/(\w+) => '(.*)'/) { $config{$1} = $2 }
}
- close $PARROT_CONFIG;
+ close $PARROT_CONFIG or die $!;
last if %config;
}
}
- %config;
+ return %config;
}
-# Generate Makefiles from a configuration
-sub create_makefiles {
+# Generate a Makefile from a configuration
+sub create_makefile {
my %config = @_;
- my %makefiles = (
- 'build/Makefile.in' => 'Makefile',
- at no_pmc@ 'build/src/pmc/Makefile.in' => 'src/pmc/Makefile',
- at no_ops@ 'build/src/ops/Makefile.in' => 'src/ops/Makefile',
- );
- my $build_tool = $config{libdir} . $config{versiondir}
- . '/tools/dev/gen_makefile.pl';
-
- foreach my $template (keys %makefiles) {
- my $makefile = $makefiles{$template};
- print "Creating $makefile\n";
- system($config{perl}, $build_tool, $template, $makefile);
- }
-}
-
-# Local Variables:
-# mode: cperl
-# cperl-indent-level: 4
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
-
-__build/PARROT_REVISION__
- at rev@
-__build/src/ops/Makefile.in__
-## @Id@
-
-# values from parrot_config
-VERSION_DIR := @versiondir@
-INCLUDE_DIR := @includedir@$(VERSION_DIR)
-LIB_DIR := @libdir@$(VERSION_DIR)
-#STAGING_DIR := ../../dynext
-STAGING_DIR := @build_dir@/runtime/parrot/dynext
-#INSTALL_DIR := $(LIB_DIR)/languages/@lclang@/dynext
-INSTALL_DIR := $(LIB_DIR)/dynext
-
-# Set up extensions
-LOAD_EXT := @load_ext@
-O := @o@
-
-# Setup some commands
-PERL := @perl@
-RM_F := @rm_f@
-CHMOD := @chmod@
-CP := @cp@
-CC := @cc@ -c
-LD := @ld@
-LDFLAGS := @ldflags@ @ld_debug@ @rpath_blib@ @linkflags@
-LD_LOAD_FLAGS := @ld_load_flags@
-CFLAGS := @ccflags@ @cc_shared@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@
-CC_OUT := @cc_o_out@
-LD_OUT := @ld_out@
-#IF(parrot_is_shared):LIBPARROT := @libparrot_ldflags@
-#ELSE:LIBPARROT :=
-
-OPS2C := $(PERL) $(LIB_DIR)/tools/build/ops2c.pl
-
-INCLUDES := -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/pmc
-LINKARGS := $(LDFLAGS) $(LD_LOAD_FLAGS) $(LIBPARROT)
-
-OPS_FILE := @lclang at .ops
-
-CLEANUPS := \
- "*$(LOAD_EXT)" \
- "*$(O)" \
- "*.c" \
- "*.h" \
- "$(STAGING_DIR)/@lclang at _ops*$(LOAD_EXT)"
-
-
-all: staging
-
-generate: $(OPS_FILE)
- $(OPS2C) C --dynamic $(OPS_FILE)
- $(OPS2C) CSwitch --dynamic $(OPS_FILE)
-#IF(cg_flag): $(OPS2C) CGoto --dynamic $(OPS_FILE)
-#IF(cg_flag): $(OPS2C) CGP --dynamic $(OPS_FILE)
-
-compile: generate
- $(CC) $(CC_OUT)@lclang at _ops$(O) $(INCLUDES) $(CFLAGS) @lclang at _ops.c
- $(CC) $(CC_OUT)@lclang at _ops_switch$(O) $(INCLUDES) $(CFLAGS) @lclang at _ops_switch.c
-#IF(cg_flag): $(CC) $(CC_OUT)@lclang at _ops_cg$(O) $(INCLUDES) $(CFLAGS) @lclang at _ops_cg.c
-#IF(cg_flag): $(CC) $(CC_OUT)@lclang at _ops_cgp$(O) $(INCLUDES) $(CFLAGS) @lclang at _ops_cgp.c
-
-linklibs: compile
- $(LD) $(LD_OUT)@lclang at _ops$(LOAD_EXT) @lclang at _ops$(O) $(LINKARGS)
- $(LD) $(LD_OUT)@lclang at _ops_switch$(LOAD_EXT) @lclang at _ops_switch$(O) $(LINKARGS)
-#IF(cg_flag): $(LD) $(LD_OUT)@lclang at _ops_cg$(LOAD_EXT) @lclang at _ops_cg$(O) $(LINKARGS)
-#IF(cg_flag): $(LD) $(LD_OUT)@lclang at _ops_cgp$(LOAD_EXT) @lclang at _ops_cgp$(O) $(LINKARGS)
-
-staging: linklibs
-#IF(cygwin or hpux): CHMOD 0775 "*$(LOAD_EXT)"
- $(CP) "*$(LOAD_EXT)" $(STAGING_DIR)
-
-install:
-#IF(cygwin or hpux): CHMOD 0775 "*$(LOAD_EXT)"
- $(CP) "*$(LOAD_EXT)" $(INSTALL_DIR)
-
-uninstall:
- $(RM_F) "$(INSTALL_DIR)/@lclang at _ops*$(LOAD_EXT)"
-Makefile: ../../build/src/ops/Makefile.in
- cd ../.. && $(PERL) Configure.pl
+ my $maketext = slurp( 'build/Makefile.in' );
-clean:
- $(RM_F) $(CLEANUPS)
+ $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{http:\S+}{ do {my $t = $&; $t =~ s'\\'/'g; $t} }eg;
+ }
-realclean:
- $(RM_F) $(CLEANUPS) 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 $!;
-# Local variables:
-# mode: makefile
-# End:
-# vim: ft=make:
+ return;
+}
-__build/src/pmc/Makefile.in__
-## @Id@
+sub slurp {
+ my $filename = shift;
-# values from parrot_config
-VERSION_DIR := @versiondir@
-INCLUDE_DIR := @includedir@$(VERSION_DIR)
-LIB_DIR := @libdir@$(VERSION_DIR)
-SRC_DIR := @srcdir@$(VERSION_DIR)
-TOOLS_DIR := @libdir@$(VERSION_DIR)/tools/lib
-#STAGING_DIR := ../../dynext
-STAGING_DIR := @build_dir@/runtime/parrot/dynext
-#INSTALL_DIR := $(LIB_DIR)/languages/@lclang@/dynext
-INSTALL_DIR := $(LIB_DIR)/dynext
-
-# Set up extensions
-LOAD_EXT := @load_ext@
-O := @o@
+ open my $fh, '<', $filename or die "Unable to read $filename\n";
+ local $/ = undef;
+ my $maketext = <$fh>;
+ close $fh or die $!;
-# Setup some commands
-PERL := @perl@
-RM_F := @rm_f@
-CHMOD := @chmod@
-CP := @cp@
-CC := @cc@ -c
-LD := @ld@
-LDFLAGS := @ldflags@ @ld_debug@
-LD_LOAD_FLAGS := @ld_load_flags@
-CFLAGS := @ccflags@ @cc_shared@ @cc_debug@ @ccwarn@ @cc_hasjit@ @cg_flag@ @gc_flag@
-CC_OUT := @cc_o_out@
-LD_OUT := @ld_out@
-#IF(parrot_is_shared):LIBPARROT := @libparrot_ldflags@
-#ELSE:LIBPARROT :=
-
-PMC2C_INCLUDES := --include $(SRC_DIR) --include $(SRC_DIR)/pmc
-PMC2C := $(PERL) $(LIB_DIR)/tools/build/pmc2c.pl
-PMC2CD := $(PMC2C) --dump $(PMC2C_INCLUDES)
-PMC2CC := $(PMC2C) --c $(PMC2C_INCLUDES)
-
-INCLUDES := -I$(INCLUDE_DIR) -I$(INCLUDE_DIR)/pmc
-LINKARGS := $(LDFLAGS) $(LD_LOAD_FLAGS) $(LIBPARROT)
-
- at uclang@_GROUP := @lclang at _group
-
-PMC_SOURCES := \
- @lclang at .pmc
-
-OBJS := \
- lib-$(@uclang at _GROUP)$(O) \
- @lclang@$(O)
-
-CLEANUPS := \
- "*$(LOAD_EXT)" \
- "*$(O)" \
- "*.c" \
- "*.h" \
- "*.dump" \
-#IF(win32): "*.exp" \
-#IF(win32): "*.ilk" \
-#IF(win32): "*.manifext" \
-#IF(win32): "*.pdb" \
-#IF(win32): "*.lib" \
- $(STAGING_DIR)/$(@uclang at _GROUP)$(LOAD_EXT)
-
-
-all: staging
-
-generate: $(PMC_SOURCES)
- $(PMC2CD) @lclang at .pmc
- $(PMC2CC) @lclang at .pmc
- $(PMC2C) --library $(@uclang at _GROUP) --c $(PMC_SOURCES)
-
-compile: generate
- $(CC) $(CC_OUT)@lclang@$(O) $(INCLUDES) $(CFLAGS) @lclang at .c
- $(CC) $(CC_OUT)lib-$(@uclang at _GROUP)$(O) $(INCLUDES) $(CFLAGS) $(@uclang at _GROUP).c
-
-linklibs: compile
- $(LD) $(LD_OUT)$(@uclang at _GROUP)$(LOAD_EXT) $(OBJS) $(LINKARGS)
-
-staging: linklibs
-#IF(cygwin or hpux): CHMOD 0775 "*$(LOAD_EXT)"
- $(CP) "*$(LOAD_EXT)" $(STAGING_DIR)
-
-install:
-#IF(cygwin or hpux): CHMOD 0775 "*$(LOAD_EXT)"
- $(CP) "*$(LOAD_EXT)" $(INSTALL_DIR)
+ return $maketext;
+}
-uninstall:
- $(RM_F) $(INSTALL_DIR)/$(@uclang at _GROUP)$(LOAD_EXT)
-Makefile: ../../build/src/pmc/Makefile.in
- cd ../.. && $(PERL) Configure.pl
+# Print some help text.
+sub print_help {
+ print <<'END';
+Configure.pl - @lang@ Configure
-clean:
- $(RM_F) $(CLEANUPS)
+General Options:
+ --help Show this text
+ --parrot-config=(config)
+ Use configuration information from config
+ --gen-parrot Download and build a copy of Parrot to use
+ --gen-parrot-option='--option=value'
+ Set parrot config option when using --gen-parrot
+END
-realclean:
- $(RM_F) $(CLEANUPS) Makefile
+ return;
+}
-# Local variables:
-# mode: makefile
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
# End:
-# vim: ft=make:
+# vim: expandtab shiftwidth=4:
+__build/PARROT_REVISION__
+ at rev@
__build/Makefile.in__
-## @Id@
+# $Id$
-## arguments we want to run parrot with
-PARROT_ARGS :=
+# arguments we want to run parrot with
+PARROT_ARGS =
-## configuration settings
-VERSION := @versiondir@
-BIN_DIR := @bindir@
-LIB_DIR := @libdir@$(VERSION)
-DOC_DIR := @doc_dir@$(VERSION)
-MANDIR := @mandir@$(VERSION)
-
-# Set up extensions
-LOAD_EXT := @load_ext@
-O := @o@
+# values from parrot_config
+BUILD_DIR = @build_dir@
+LOAD_EXT = @load_ext@
+O = @o@
+EXE = @exe@
+MAKE = @make_c@
+PERL = @perl@
+RM_F = @rm_f@
+HAS_ICU = @has_icu@
# Various paths
-PERL6GRAMMAR := $(LIB_DIR)/library/PGE/Perl6Grammar.pbc
-NQP := $(LIB_DIR)/languages/nqp/nqp.pbc
-PCT := $(LIB_DIR)/library/PCT.pbc
-PMC_DIR := src/pmc
-OPS_DIR := src/ops
-
-## Setup some commands
-MAKE := @make_c@
-PERL := @perl@
-CAT := @cat@
-CHMOD := @chmod@
-CP := @cp@
-MKPATH := @mkpath@
-RM_F := @rm_f@
-RM_RF := @rm_rf@
-POD2MAN := pod2man
-#IF(parrot_is_shared and not(cygwin or win32)):export LD_RUN_PATH := @blib_dir@:$(LD_RUN_PATH)
-PARROT := $(BIN_DIR)/parrot at exe@
-PBC_TO_EXE := $(BIN_DIR)/pbc_to_exe at exe@
-#IF(darwin):
-#IF(darwin):# MACOSX_DEPLOYMENT_TARGET must be defined for OS X compilation/linking
-#IF(darwin):export MACOSX_DEPLOYMENT_TARGET := @osx_version@
+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
+PMC_DIR = src/pmc
+OPSDIR = src/ops
+OPSLIB = @lclang@
+OPS_FILE = src/ops/@lclang at .ops
- at UCLANG@_GROUP := $(PMC_DIR)/@lclang at _group$(LOAD_EXT)
- at UCLANG@_OPS := $(OPS_DIR)/@lclang at _ops$(LOAD_EXT)
-
- at no_pmc@PMC_DEPS := build/src/pmc/Makefile.in $(PMC_DIR)/@lclang at .pmc
- at no_ops@OPS_DEPS := build/src/ops/Makefile.in $(OPS_DIR)/@lclang at .ops
+# Setup some commands
+PARROT = $(BUILD_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
+PBC_TO_EXE = $(BUILD_DIR)/pbc_to_exe$(EXE)
-SOURCES := \
+SOURCES = @lclang at .pir \
src/gen_grammar.pir \
src/gen_actions.pir \
src/gen_builtins.pir \
- @lclang at .pir
+ $(@uclang at _GROUP)
-BUILTINS_PIR := \
- src/builtins/say.pir
+BUILTINS_PIR = \
+ src/builtins/say.pir \
-DOCS := README
+# PMCS = @lclang@
+# PMC_SOURCES = $(PMC_DIR)/@lclang at .pmc
+# @uclang at _GROUP = $(PMC_DIR)/@lclang at _group$(LOAD_EXT)
-BUILD_CLEANUPS := \
+CLEANUPS = \
@lclang at .pbc \
- "src/gen_*.pir" \
- "*.c" \
- "*$(O)" \
- @lclang@@exe@ \
-#IF(win32): parrot- at lclang@.exe \
-#IF(win32): parrot- at lclang@.iss \
-#IF(win32): "setup-parrot-*.exe" \
- installable_ at lclang@@exe@
+ @lclang at .c \
+ *.manifest \
+ *.pdb \
+ @lclang@$(O) \
+ @lclang@$(EXE) \
+ src/gen_*.pir \
+ src/gen_*.pm \
+ $(PMC_DIR)/*.h \
+ $(PMC_DIR)/*.c \
+ $(PMC_DIR)/*.dump \
+ $(PMC_DIR)/*$(O) \
+ $(PMC_DIR)/*$(LOAD_EXT) \
+ $(PMC_DIR)/*.exp \
+ $(PMC_DIR)/*.ilk \
+ $(PMC_DIR)/*.manifest \
+ $(PMC_DIR)/*.pdb \
+ $(PMC_DIR)/*.lib \
+ $(PMC_DIR)/objectref.pmc \
+ $(OPSDIR)/*.h \
+ $(OPSDIR)/*.c \
+ $(OPSDIR)/*$(O) \
+ $(OPSDIR)/*$(LOAD_EXT) \
-TEST_CLEANUPS :=
+HARNESS = $(PERL) t/harness --keep-exit-code --icu=$(HAS_ICU)
+HARNESS_JOBS = $(HARNESS) --jobs
# the default target
-build: \
- $(@UCLANG at _OPS) \
- $(@UCLANG at _GROUP) \
- @lclang at .pbc
+all: @lclang@$(EXE)
-all: build @lclang@@exe@ installable
+## targets for building a standalone executable
+ at lclang@$(EXE): @lclang at .pbc
+ $(PBC_TO_EXE) @lclang at .pbc
+ @win32_libparrot_copy@
- at lclang@.pbc: $(SOURCES)
+# the compiler .pbc
+ at lclang@.pbc: Makefile $(PARROT) $(SOURCES) $(BUILTINS_PIR)
+ $(PERL) -e "" > src/gen_setting.pir
$(PARROT) $(PARROT_ARGS) -o @lclang at .pbc @lclang at .pir
- at lclang@@exe@: @lclang at .pbc
- $(PBC_TO_EXE) @lclang at .pbc
-
-src/gen_grammar.pir: $(PERL6GRAMMAR) src/parser/grammar.pg src/parser/grammar-oper.pg
+src/gen_grammar.pir: $(PARROT) $(PERL6GRAMMAR) src/pct/grammar.pg src/pct/grammar-oper.pg
$(PARROT) $(PARROT_ARGS) $(PERL6GRAMMAR) \
--output=src/gen_grammar.pir \
- src/parser/grammar.pg \
- src/parser/grammar-oper.pg
+ src/pct/grammar.pg src/pct/grammar-oper.pg
-src/gen_actions.pir: $(NQP) src/parser/actions.pm
+src/gen_actions.pir: $(PARROT) $(NQP) $(PCT) src/pct/actions.pm
$(PARROT) $(PARROT_ARGS) $(NQP) --output=src/gen_actions.pir \
- --target=pir src/parser/actions.pm
+ --encoding=fixed_8 --target=pir src/pct/actions.pm
+
+src/gen_builtins.pir: Makefile build/gen_builtins_pir.pl
+ $(PERL) build/gen_builtins_pir.pl $(BUILTINS_PIR) > src/gen_builtins.pir
-src/gen_builtins.pir: $(BUILTINS_PIR)
- $(CAT) $(BUILTINS_PIR) > src/gen_builtins.pir
+$(@uclang at _GROUP): Makefile $(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)
+
+src/ops/@lclang at _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)
+
+## local copy of Parrot
+parrot: parrot/parrot_config build/PARROT_REVISION
+ $(PERL) build/gen_parrot.pl
+
+parrot/parrot_config:
+ @echo "Don't see parrot/parrot_config."
+
+test: @lclang@$(EXE)
+ $(PERL) t/harness t/
+
+# Run a single test
+t/*.t t/*/*.t t/*/*/*.t: all Test.pir
+ @$(HARNESS_WITH_FUDGE) --verbosity=1 $@
-$(@UCLANG at _GROUP): $(PMC_DEPS)
- at no_pmc@ $(MAKE) $(PMC_DIR)
+## cleaning
+clean:
+ $(RM_F) $(CLEANUPS)
-$(@UCLANG at _OPS): $(OPS_DEPS)
- at no_ops@ $(MAKE) $(OPS_DIR)
+distclean: realclean
-installable: installable_ at lclang@@exe@
+realclean: clean
+ $(RM_F) src/utils/Makefile Makefile
-installable_ at lclang@@exe@: @lclang at .pbc
- $(PBC_TO_EXE) @lclang at .pbc --install
+testclean:
-Makefile: build/Makefile.in
- $(PERL) Configure.pl
-# This is a listing of all targets, that are meant to be called by users
+## miscellaneous targets
+# a listing of all targets meant to be called by users
help:
@echo ""
@echo "Following targets are available for the user:"
@echo ""
- @echo " build: @lclang at .pbc"
+ @echo " all: @lclang at .exe"
@echo " This is the default."
- @echo " @lclang@@exe@ Self-hosting binary not to be installed."
- @echo " all: @lclang at .pbc @lclang@@exe@ installable"
- @echo " installable: Create libs and self-hosting binaries to be installed."
- @echo " install: Install the installable targets and docs."
@echo ""
@echo "Testing:"
- @echo " test: Run the test suite."
- @echo " test-installable: Test self-hosting targets."
- @echo " testclean: Clean up test results."
+ @echo " test: Run Rakudo's sanity tests."
@echo ""
@echo "Cleaning:"
@echo " clean: Basic cleaning up."
- @echo " realclean: Removes also files generated by 'Configure.pl'"
- @echo " distclean: Removes also anything built, in theory"
+ @echo " distclean: Removes also anything built, in theory."
+ @echo " realclean: Removes also files generated by 'Configure.pl'."
+ @echo " testclean: Clean up test results."
@echo ""
@echo "Misc:"
@echo " help: Print this help message."
@echo ""
-test: build
- $(PERL) -I$(LIB_DIR)/tools/lib t/harness --bindir=$(BIN_DIR)
+Makefile: build/Makefile.in
+ @echo ""
+ @echo "warning: Makefile is out of date... re-run Configure.pl"
+ @echo ""
+
+manifest:
+ echo MANIFEST >MANIFEST
+ git ls-files | $(PERL) -ne '/^\./ || print' >>MANIFEST
+
+release: manifest
+ [ -n "$(VERSION)" ] || ( echo "\nTry 'make release VERSION=yyyymm'\n\n"; exit 1 )
+ [ -d @lclang at -$(VERSION) ] || ln -s . @lclang at -$(VERSION)
+ $(PERL) -ne 'print "@lclang at -$(VERSION)/$$_"' MANIFEST | \
+ tar -zcv -T - -f @lclang at -$(VERSION).tar.gz
+ rm @lclang at -$(VERSION)
-# basic run for missing libs
-test-installable: installable
- echo "1" | ./installable_ at lclang@@exe@
-
-install: installable
- at no_ops@ $(MAKE) $(OPS_DIR) install
- at no_pmc@ $(MAKE) $(PMC_DIR) install
- $(CP) installable_ at lclang@@exe@ $(BIN_DIR)/parrot- at lclang@@exe@
- $(CHMOD) 0755 $(BIN_DIR)/parrot- at lclang@@exe@
- -$(MKPATH) $(LIB_DIR)/languages/@lclang@
- $(CP) @lclang at .pbc $(LIB_DIR)/languages/@lclang@/@lclang at .pbc
- at no_doc@ -$(MKPATH) $(MANDIR)/man1
- at no_doc@ $(POD2MAN) doc/running.pod > $(MANDIR)/man1/parrot- at lclang@.1
- at no_doc@ -$(MKPATH) $(DOC_DIR)/languages/@lclang@
- at no_doc@ $(CP) $(DOCS) $(DOC_DIR)/languages/@lclang@
-
-uninstall:
- at no_ops@ $(MAKE) $(OPS_DIR) uninstall
- at no_pmc@ $(MAKE) $(PMC_DIR) uninstall
- $(RM_F) $(BIN_DIR)/parrot- at lclang@@exe@
- $(RM_RF) $(LIB_DIR)/languages/@lclang@
- at no_doc@ $(RM_F) $(MANDIR)/man1/parrot- at lclang@.1
- at no_doc@ $(RM_RF) $(DOC_DIR)/languages/@lclang@
-
-win32-inno-installer: installable
- at no_doc@ -$(MKPATH) man/man1
- at no_doc@ $(POD2MAN) doc/running.pod > man/man1/parrot- at lclang@.1
- at no_doc@ -$(MKPATH) man/html
- at no_doc@ pod2html --infile doc/running.pod --outfile man/html/parrot- at lclang@.html
- $(CP) installable_ at lclang@@exe@ parrot- at lclang@.exe
- $(PERL) -I$(LIB_DIR)/tools/lib $(LIB_DIR)/tools/dev/mk_inno_language.pl @lclang@
- iscc parrot- at lclang@.iss
+__build/gen_builtins_pir.pl__
+#!/usr/bin/perl
+# $Id$
-testclean:
- $(RM_F) $(TEST_CLEANUPS)
+use strict;
+use warnings;
-clean:
- at no_ops@ $(MAKE) $(OPS_DIR) clean
- at no_pmc@ $(MAKE) $(PMC_DIR) clean
- $(RM_F) $(TEST_CLEANUPS) $(BUILD_CLEANUPS)
-
-realclean:
- at no_ops@ $(MAKE) $(OPS_DIR) realclean
- at no_pmc@ $(MAKE) $(PMC_DIR) realclean
- $(RM_F) $(TEST_CLEANUPS) $(BUILD_CLEANUPS) Makefile
+my @files = @ARGV;
-distclean: realclean
+print <<"END_PRELUDE";
+# This file automatically generated by $0.
+
+END_PRELUDE
+
+foreach my $file (@files) {
+ print ".include '$file'\n";
+}
-# Local variables:
-# mode: makefile
-# End:
-# vim: ft=make:
__build/gen_parrot.pl__
#! perl
=head1 TITLE
-gen_parrot.pl - script to obtain and build Parrot for @lang@
+gen_parrot.pl - script to obtain and build Parrot
=head2 SYNOPSIS
- perl gen_parrot.pl [--option-for-Configure-pl]
+ perl gen_parrot.pl [--parrot --configure=options]
=head2 DESCRIPTION
@@ -699,16 +496,18 @@
use warnings;
use 5.008;
+# Work out slash character to use.
+my $slash = $^O eq 'MSWin32' ? '\\' : '/';
+
## determine what revision of Parrot we require
-open my $REQ, 'build/PARROT_REVISION'
- or die "cannot open build/PARROT_REVISION ($!)\n";
-my $required = <$REQ>;
-chomp $required;
+open my $REQ, "build/PARROT_REVISION"
+ || die "cannot open build/PARROT_REVISION\n";
+my $required = <$REQ>; chomp $required;
close $REQ;
{
no warnings;
- if (open my $REV, '-|', 'parrot/parrot_config revision') {
+ if (open my $REV, '-|', "parrot${slash}parrot_config revision") {
my $revision = <$REV>;
close $REV;
chomp $revision;
@@ -720,7 +519,7 @@
}
print "Checking out Parrot r$required via svn...\n";
-system("svn checkout -r $required https://svn.parrot.org/parrot/trunk parrot");
+system(qw(svn checkout -r), $required , qw(https://svn.parrot.org/parrot/trunk parrot));
chdir('parrot');
@@ -730,81 +529,32 @@
my %config = read_parrot_config();
my $make = $config{'make'};
if ($make) {
- print "Performing '$make realclean'\n";
- system($make, 'realclean');
+ print "\nPerforming '$make realclean' ...\n";
+ system($make, "realclean");
}
}
-## Configure Parrot
-system($^X, 'Configure.pl', @ARGV);
+print "\nConfiguring Parrot ...\n";
+my @config_command = ($^X, 'Configure.pl', @ARGV);
+print "@config_command\n";
+system @config_command;
+print "\nBuilding Parrot ...\n";
my %config = read_parrot_config();
-my $make = $config{'make'};
-system( $make );
-system( $make, 'install-dev' );
+my $make = $config{'make'} or exit(1);
+system($make);
sub read_parrot_config {
my %config = ();
- if (open my $CFG, 'config_lib.pasm') {
+ if (open my $CFG, "config_lib.pasm") {
while (<$CFG>) {
- $config{$1} = $2 if (/P0\["(.*?)"], "(.*?)"/);
+ if (/P0\["(.*?)"], "(.*?)"/) { $config{$1} = $2 }
}
close $CFG;
}
%config;
}
-
-# Local Variables:
-# mode: cperl
-# cperl-indent-level: 4
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
-
-__doc/@lang at .pod__
-# @Id@
-
-=head1 @lang@
-
-=head1 Design
-
-=head1 SEE ALSO
-
-=cut
-
-# Local Variables:
-# fill-column:78
-# End:
-# vim: expandtab shiftwidth=4:
-__doc/running.pod__
-# @Id@
-
-=head1 Running
-
-This document describes how to use the command line @lclang@ program, which
-...
-
-=head2 Usage
-
- parrot @lclang at .pbc [OPTIONS] <input>
-
-or
-
- parrot- at lclang@@exe [OPTIONS] <input>
-
-A number of additional options are available:
-
- -q Quiet mode; suppress output of summary at the end.
-
-=cut
-
-# Local Variables:
-# fill-column:78
-# End:
-# vim: expandtab shiftwidth=4:
-
-__dynext/.ignore__
-
+
__ at lclang@.pir__
=head1 TITLE
@@ -829,18 +579,32 @@
=cut
-.namespace [ '@lang@::Compiler' ]
+.HLL '@lclang@'
- at no_pmc@.loadlib '@lclang at _group'
+.namespace [ '@lang@';'Compiler' ]
-.sub 'onload' :anon :load :init
+.loadlib '@lclang at _group'
+
+.sub '' :anon :load :init
load_bytecode 'PCT.pbc'
+ .local pmc parrotns, hllns, exports
+ parrotns = get_root_namespace ['parrot']
+ hllns = get_hll_namespace
+ exports = split ' ', 'PAST PCT PGE'
+ parrotns.'export_to'(hllns, exports)
+.end
+.include 'src/gen_grammar.pir'
+.include 'src/gen_actions.pir'
+
+.sub 'onload' :anon :load :init
$P0 = get_hll_global ['PCT'], 'HLLCompiler'
$P1 = $P0.'new'()
- $P1.'language'('@lang@')
- $P1.'parsegrammar'('@lang@::Grammar')
- $P1.'parseactions'('@lang@::Grammar::Actions')
+ $P1.'language'('@lclang@')
+ $P0 = get_hll_namespace ['@lang@';'Grammar']
+ $P1.'parsegrammar'($P0)
+ $P0 = get_hll_namespace ['@lang@';'Grammar';'Actions']
+ $P1.'parseactions'($P0)
.end
=item main(args :slurpy) :main
@@ -853,13 +617,11 @@
.sub 'main' :main
.param pmc args
- $P0 = compreg '@lang@'
+ $P0 = compreg '@lclang@'
$P1 = $P0.'command_line'(args)
.end
.include 'src/gen_builtins.pir'
-.include 'src/gen_grammar.pir'
-.include 'src/gen_actions.pir'
=back
@@ -871,7 +633,7 @@
# End:
# vim: expandtab shiftwidth=4 ft=pir:
-__src/parser/grammar.pg__
+__src/pct/grammar.pg__
# @Id@
=begin overview
@@ -919,7 +681,7 @@
rule expression is optable { ... }
-__src/parser/grammar-oper.pg__
+__src/pct/grammar-oper.pg__
# @Id@
## expressions and operators
@@ -933,7 +695,7 @@
proto infix:<+> is looser(infix:<*>) is pirop('add') { ... }
proto infix:<-> is equiv(infix:<+>) is pirop('sub') { ... }
-__src/parser/actions.pm__
+__src/pct/actions.pm__
# @Id@
=begin comments
@@ -953,9 +715,9 @@
class @lang@::Grammar::Actions;
method TOP($/) {
- my $past := PAST::Block.new( :blocktype('declaration'), :node( $/ ) );
+ my $past := PAST::Block.new( :blocktype('declaration'), :node( $/ ), :hll('@lang@') );
for $<statement> {
- $past.push( $( $_ ) );
+ $past.push( $_.ast );
}
make $past;
}
@@ -964,7 +726,7 @@
method statement($/) {
my $past := PAST::Op.new( :name('say'), :pasttype('call'), :node( $/ ) );
for $<expression> {
- $past.push( $( $_ ) );
+ $past.push( $_.ast );
}
make $past;
}
@@ -981,7 +743,7 @@
## is invoked with the expression in $<expr> and a $key of 'end'.
method expression($/, $key) {
if ($key eq 'end') {
- make $($<expr>);
+ make $<expr>.ast;
}
else {
my $past := PAST::Op.new( :name($<type>),
@@ -991,7 +753,7 @@
:node($/)
);
for @($/) {
- $past.push( $($_) );
+ $past.push( $_.ast );
}
make $past;
}
@@ -1002,12 +764,12 @@
## Like 'statement' above, the $key has been set to let us know
## which term subrule was matched.
method term($/, $key) {
- make $( $/{$key} );
+ make $/{$key}.ast;
}
method value($/, $key) {
- make $( $/{$key} );
+ make $/{$key}.ast;
}
@@ -1017,7 +779,7 @@
method quote($/) {
- make PAST::Val.new( :value( $($<string_literal>) ), :node($/) );
+ make PAST::Val.new( :value( $<string_literal>.ast ), :node($/) );
}
@@ -1028,221 +790,6 @@
# End:
# vim: expandtab shiftwidth=4:
-__src/pmc/@lclang at .pmc__
-/*
-Copyright (C) 20xx, Parrot Foundation.
- at Id@
-
-=head1 NAME
-
-src/pmc/@lang at .pmc - @lang@
-
-=head1 DESCRIPTION
-
-These are the vtable functions for the @lang@ class.
-
-=cut
-
-=head2 Helper functions
-
-=over 4
-
-=item INTVAL size(INTERP, PMC, PMC)
-
-*/
-
-#include "parrot/parrot.h"
-
-static INTVAL
-size(Interp *interp, PMC* self, PMC* obj)
-{
- INTVAL retval;
- INTVAL dimension;
- INTVAL length;
- INTVAL pos;
-
- if (!obj || PMC_IS_NULL(obj)) {
- /* not set, so a simple 1D */
- return VTABLE_get_integer(interp, self);
- }
-
- retval = 1;
- dimension = VTABLE_get_integer(interp, obj);
- for (pos = 0; pos < dimension; pos++)
- {
- length = VTABLE_get_integer_keyed_int(interp, obj, pos);
- retval *= length;
- }
- return retval;
-}
-
-/*
-
-=back
-
-=head2 Methods
-
-=over 4
-
-=cut
-
-*/
-
-pmclass @lang@
- extends ResizablePMCArray
- provides array
- group @lclang at _group
-
- need_ext
- dynpmc
- {
-/*
-
-=item C<void class_init()>
-
-initialize the pmc class. Store some constants, etc.
-
-=cut
-
-*/
-
- /* RT#48194: move any constant string declarations here so we just do them once. */
- void class_init() {
- }
-
-
-/*
-
-=item C<PMC* init()>
-
-initialize the instance.
-
-=cut
-
-*/
-
-void init() {
- SUPER();
-};
-
-=item C<PMC* get()>
-
-Returns a vector-like PMC.
-
-=cut
-
-*/
-
- METHOD PMC* get() {
- PMC* property;
- INTVAL array_t;
- STRING* property_name;
-
- property_name = string_from_literal(INTERP, "property");
- shape = VTABLE_getprop(INTERP, SELF, property_name);
- if (PMC_IS_NULL(property)) {
- /*
- * No property has been set yet. This means that we are
- * a simple vector
- *
- * we use our own type here. Perhaps a better way to
- * specify it?
- */
- /*
- array_t = pmc_type(INTERP,
- string_from_literal(INTERP, "@lang@"));
- */
- property = pmc_new(INTERP, VTABLE_type(INTERP, SELF));
-
- VTABLE_set_integer_native(INTERP, property, 1);
- VTABLE_set_integer_keyed_int(INTERP, property, 0,
- VTABLE_get_integer(INTERP, SELF));
- VTABLE_setprop(INTERP, SELF, property_name, property);
- }
- RETURN(PMC* property);
- }
-
-/*
-
-=item C<PMC* set()>
-
-Change the existing @lang@ by passing in an existing vector.
-
-If the new property is larger than our old property, pad the end of the vector
-with elements from the beginning.
-
-If the new property is shorter than our old property, truncate elements from
-the end of the vector.
-
-=cut
-
-*/
-
- METHOD set(PMC *new_property) {
- STRING* property_name;
- PMC* old_property;
- INTVAL old_size, new_size, pos;
-
- /* save the old property momentarily, set the new property */
- property_name = string_from_literal(INTERP, "property");
- old_property = VTABLE_getprop(INTERP, SELF, property_name);
- VTABLE_setprop(INTERP, SELF, property_name, new_property);
-
- /* how big are these property? */
- old_size = size(INTERP, SELF, old_property);
- new_size = size(INTERP, SELF, new_property);
-
- if (old_size > new_size) {
- for (; new_size != old_size; new_size++) {
- VTABLE_pop_pmc(INTERP, SELF);
- }
- } else if (new_size > old_size) {
- pos = 0;
- for (; new_size != old_size; old_size++, pos++) {
- /* RT#48196 clone this? */
- VTABLE_push_pmc(INTERP, SELF,
- VTABLE_get_pmc_keyed_int(INTERP, SELF, pos));
- }
- }
- }
-
-/*
-
-=back
-
-=cut
-
-*/
-
-}
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
-__src/ops/@lclang at .ops__
-/*
- * @id@
- * Copyright (C) 20xx, Parrot Foundation.
- */
-
-#include "parrot/dynext.h"
-VERSION = PARROT_VERSION;
-
-/* Op to get the address of a PMC. */
-inline op @lclang at _pmc_addr(out INT, invar PMC) :base_core {
- $1 = (int) $2;
- goto NEXT();
-}
-
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */
__src/builtins/say.pir__
# @Id@
@@ -1278,35 +825,95 @@
__t/harness__
#! perl
-# @Id@
+# $Id$
-# pragmata
use strict;
use warnings;
-use Getopt::Long;
-use 5.008;
-our %harness_args = (
- language => '@lang@',
- verbosity => 0,
-);
+use FindBin;
+use File::Spec;
+use Getopt::Long qw(:config pass_through);
+
+$ENV{'HARNESS_PERL'} = './@lclang@';
+use Test::Harness;
+$Test::Harness::switches = '';
GetOptions(
- 'verbosity=i' => \$harness_args{verbosity},
- 'bindir=s' => \my $bindir,
- # A sensible default is num_cores + 1.
- # Many people have two cores these days.
- 'jobs:3' => \$harness_args{jobs},
+ 'tests-from-file=s' => \my $list_file,
+ 'verbosity=i' => \$Test::Harness::verbose,
+ 'jobs:3' => \my $jobs,
+ 'icu:1' => \my $do_icu,
);
-if ($bindir) {
- $harness_args{exec} = [$bindir.'/parrot', '@lclang at .pbc'];
+my @pass_through_options = grep m/^--?[^-]/, @ARGV;
+my @files = grep m/^[^-]/, @ARGV;
+
+my $slash = $^O eq 'MSWin32' ? '\\' : '/';
+
+if ($list_file) {
+ open(my $f, '<', $list_file)
+ or die "Can't open file '$list_file' for reading: $!";
+ while (<$f>) {
+ next if m/^\s*#/;
+ next unless m/\S/;
+ chomp;
+ my ($fn, $flags) = split /\s+#\s*/;
+ next if ($flags && ($flags =~ m/icu/) && !$do_icu);
+ $fn = "t/spec/$fn" unless $fn =~ m/^t\Q$slash\Espec\Q$slash\E/;
+ $fn =~ s{/}{$slash}g;
+ if ( -r $fn ) {
+ push @files, $fn;
+ } else {
+ warn "Missing test file: $fn\n";
+ }
+ }
+ close $f or die $!;
+}
+
+my @tfiles = map { all_in($_) } sort @files;
+
+if (eval { require TAP::Harness; 1 }) {
+ my %harness_options = (
+ exec => ['./perl6'],
+ verbosity => 0+$Test::Harness::verbose,
+ jobs => $jobs || 1,
+ );
+ TAP::Harness->new( \%harness_options )->runtests(@tfiles);
}
else {
- $harness_args{compiler} = '@lclang at .pbc';
+ runtests(@tfiles);
}
-eval 'use Parrot::Test::Harness %harness_args';
+# adapted to return only files ending in '.t'
+sub all_in {
+ my $start = shift;
+
+ return $start unless -d $start;
+
+ my @skip = ( File::Spec->updir, File::Spec->curdir, qw( .svn CVS .git ) );
+ my %skip = map {($_,1)} @skip;
+
+ my @hits = ();
+
+ if ( opendir( my $dh, $start ) ) {
+ my @files = sort readdir $dh;
+ closedir $dh or die $!;
+ for my $file ( @files ) {
+ next if $skip{$file};
+
+ my $currfile = File::Spec->catfile( $start, $file );
+ if ( -d $currfile ) {
+ push( @hits, all_in( $currfile ) );
+ } else {
+ push( @hits, $currfile ) if $currfile =~ /\.t$/;
+ }
+ }
+ } else {
+ warn "$start: $!\n";
+ }
+
+ return @hits;
+}
__t/00-sanity.t__
# This just checks that the basic parsing and call to builtin say() works.
@@ -1315,6 +922,7 @@
say 'ok ', 2;
say 'ok ', 2 + 1;
say 'ok', ' ', 4;
+
__DATA__
More information about the parrot-commits
mailing list