Browse files

[lolcode] modernize infrastructure with setup.pir (distutils)

  • Loading branch information...
1 parent 65d922d commit 6870c5ef43beaef87c2664ad2cfa2d4e9160c7c6 @fperrad fperrad committed Nov 22, 2009
Showing with 98 additions and 335 deletions.
  1. +0 −66 Configure.pl
  2. +0 −171 config/makefiles/root.in
  3. +1 −3 lolcode.pir
  4. +78 −0 setup.pir
  5. +13 −0 src/builtins.pir
  6. +3 −0 src/builtins/cmp.pir
  7. +3 −0 src/builtins/math.pir
  8. +0 −95 t/harness
View
66 Configure.pl
@@ -1,66 +0,0 @@
-# Copyright (C) 2009, Parrot Foundation.
-# $Id$
-
-use strict;
-use warnings;
-use 5.008;
-
-# Get a list of parrot-configs to invoke.
-my @parrot_config_exe = (
- '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 = @_;
- my %config = ();
- for my $exe (@parrot_config_exe) {
- no warnings;
- if (open my $PARROT_CONFIG, '-|', "$exe --dump") {
- print "Reading configuration information from $exe\n";
- while (<$PARROT_CONFIG>) {
- $config{$1} = $2 if (/(\w+) => '(.*)'/);
- }
- close $PARROT_CONFIG;
- last if %config;
- }
- }
- %config;
-}
-
-
-# Generate Makefiles from a configuration
-sub create_makefiles {
- my %config = @_;
- my %makefiles = (
- 'config/makefiles/root.in' => 'Makefile',
-# 'config/makefiles/pmc.in' => 'src/pmc/Makefile',
-# 'config/makefiles/ops.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:
-
View
171 config/makefiles/root.in
@@ -1,171 +0,0 @@
-# Copyright (C) 2008-2009, Parrot Foundation.
-## $Id$
-
-## arguments we want to run parrot with
-PARROT_ARGS :=
-
-## configuration settings
-VERSION := @versiondir@
-BIN_DIR := @bindir@
-LIB_DIR := @libdir@$(VERSION)
-DOC_DIR := @docdir@$(VERSION)
-MANDIR := @mandir@$(VERSION)
-
-# Set up extensions
-LOAD_EXT := @load_ext@
-O := @o@
-
-# Various paths
-PERL6GRAMMAR := $(LIB_DIR)/library/PGE/Perl6Grammar.pbc
-NQP := $(LIB_DIR)/languages/nqp/nqp.pbc
-PCT := $(LIB_DIR)/library/PCT.pbc
-
-## 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
-PARROT := $(BIN_DIR)/parrot@exe@
-PBC_TO_EXE := $(BIN_DIR)/pbc_to_exe@exe@
-#IF(darwin):
-#IF(darwin):# MACOSX_DEPLOYMENT_TARGET must be defined for OS X compilation/linking
-#IF(darwin):export MACOSX_DEPLOYMENT_TARGET := @osx_version@
-
-SOURCES := \
- src/gen_grammar.pir \
- src/gen_actions.pir \
- src/gen_builtins.pir \
- src/parser/yarn_literal.pir \
- lolcode.pir
-
-BUILTINS_PIR := \
- src/builtins/say.pir \
- src/builtins/expr_parse.pir \
- src/builtins/math.pir \
- src/builtins/cmp.pir
-
-DOCS := README
-
-BUILD_CLEANUPS := \
- lolcode.pbc \
- "src/gen_*.pir" \
- "*.c" \
- "*$(O)" \
- lolcode@exe@ \
-#IF(win32): parrot-lolcode.exe \
-#IF(win32): parrot-lolcode.iss \
-#IF(win32): "setup-parrot-*.exe" \
- installable_lolcode@exe@
-
-TEST_CLEANUPS :=
-
-# the default target
-all: build lolcode@exe@ installable
-
-build: lolcode.pbc
-
-lolcode.pbc: $(SOURCES)
- $(PARROT) $(PARROT_ARGS) -o lolcode.pbc lolcode.pir
-
-lolcode@exe@: lolcode.pbc
- $(PBC_TO_EXE) lolcode.pbc
-
-src/gen_grammar.pir: $(PERL6GRAMMAR) src/parser/grammar.pg
- $(PARROT) $(PARROT_ARGS) $(PERL6GRAMMAR) \
- --output=src/gen_grammar.pir \
- src/parser/grammar.pg
-
-src/gen_actions.pir: $(NQP) src/parser/actions.pm
- $(PARROT) $(PARROT_ARGS) $(NQP) --output=src/gen_actions.pir \
- --target=pir src/parser/actions.pm
-
-src/gen_builtins.pir: $(BUILTINS_PIR)
- $(CAT) $(BUILTINS_PIR) > src/gen_builtins.pir
-
-installable: installable_lolcode@exe@
-
-installable_lolcode@exe@: lolcode.pbc
- $(PBC_TO_EXE) lolcode.pbc --install
-
-Makefile: config/makefiles/root.in
- $(PERL) Configure.pl
-
-# This is a listing of all targets, that are meant to be called by users
-help:
- @echo ""
- @echo "Following targets are available for the user:"
- @echo ""
- @echo " build: lolcode.pbc"
- @echo " This is the default."
- @echo " lolcode@exe@ Self-hosting binary not to be installed."
- @echo " all: lolcode.pbc lolcode@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 ""
- @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 ""
- @echo "Misc:"
- @echo " help: Print this help message."
- @echo ""
-
-test: build
- $(PERL) -I$(LIB_DIR)/tools/lib t/harness t
-
-# basic run for missing libs
-test-installable: installable
- echo "1" | ./installable_lolcode@exe@
-
-install: installable
- $(CP) installable_lolcode@exe@ $(BIN_DIR)/parrot-lolcode@exe@
- $(CHMOD) 0755 $(BIN_DIR)/parrot-lolcode@exe@
- -$(MKPATH) $(LIB_DIR)/languages/lolcode
- $(CP) lolcode.pbc $(LIB_DIR)/languages/lolcode/lolcode.pbc
-# -$(MKPATH) $(MANDIR)/man1
-# $(POD2MAN) doc/running.pod > $(MANDIR)/man1/parrot-lolcode.1
-# -$(MKPATH) $(DOC_DIR)/languages/lolcode
-# $(CP) $(DOCS) $(DOC_DIR)/languages/lolcode
-
-uninstall:
- $(RM_F) $(BIN_DIR)/parrot-lolcode@exe@
- $(RM_RF) $(LIB_DIR)/languages/lolcode
-# $(RM_F) $(MANDIR)/man1/parrot-lolcode.1
-# $(RM_RF) $(DOC_DIR)/languages/lolcode
-
-win32-inno-installer: installable
-# -$(MKPATH) man/man1
-# $(POD2MAN) doc/running.pod > man/man1/parrot-lolcode.1
-# -$(MKPATH) man/html
-# pod2html --infile doc/running.pod --outfile man/html/parrot-lolcode.html
- $(CP) installable_lolcode@exe@ parrot-lolcode.exe
- $(PERL) $(LIB_DIR)/tools/dev/mk_inno_language.pl lolcode
- iscc parrot-lolcode.iss
-
-testclean:
- $(RM_F) $(TEST_CLEANUPS)
-
-clean:
- $(RM_F) $(TEST_CLEANUPS) $(BUILD_CLEANUPS)
-
-realclean:
- $(RM_F) $(TEST_CLEANUPS) $(BUILD_CLEANUPS) Makefile
-
-distclean: realclean
-
-# Local variables:
-# mode: makefile
-# End:
-# vim: ft=make:
-
View
4 lolcode.pir
@@ -25,8 +25,6 @@ object.
.namespace [ 'lolcode';'Compiler' ]
-.loadlib 'lolcode_group'
-
.sub '' :anon :load :init
load_bytecode 'PCT.pbc'
.local pmc parrotns, lolns, exports
@@ -36,7 +34,7 @@ object.
parrotns.'export_to'(lolns, exports)
.end
-.include 'src/gen_builtins.pir'
+.include 'src/builtins.pir'
.include 'src/gen_grammar.pir'
.include 'src/parser/yarn_literal.pir'
.include 'src/gen_actions.pir'
View
78 setup.pir
@@ -0,0 +1,78 @@
+#! /usr/local/bin/parrot
+# Copyright (C) 2009, Parrot Foundation.
+# $Id$
+
+=head1 NAME
+
+setup.pir - Python distutils style
+
+=head1 DESCRIPTION
+
+No Configure step, no Makefile generated.
+
+=head1 USAGE
+
+ $ parrot setup.pir build
+ $ parrot setup.pir test
+ $ sudo parrot setup.pir install
+
+=cut
+
+.sub 'main' :main
+ .param pmc args
+ $S0 = shift args
+ load_bytecode 'distutils.pbc'
+
+ $P0 = new 'Hash'
+ $P0['name'] = 'Lolcode'
+ $P0['abstract'] = 'Lolcode'
+ $P0['description'] = 'Lolcode'
+ $P0['license_type'] = 'Artistic License 2.0'
+ $P0['license_uri'] = 'http://www.perlfoundation.org/artistic_license_2_0'
+ $P0['copyright_holder'] = 'Parrot Foundation'
+ $P0['generated_by'] = 'Francois Perrad <francois.perrad@gadz.org>'
+ $P0['checkout_uri'] = 'https://svn.parrot.org/languages/lolcode/trunk'
+ $P0['browser_uri'] = 'https://trac.parrot.org/languages/browser/lolcode'
+ $P0['project_uri'] = 'https://trac.parrot.org/parrot/wiki/Languages'
+
+ # build
+ $P1 = new 'Hash'
+ $P1['src/gen_grammar.pir'] = 'src/parser/grammar.pg'
+ $P0['pir_pge'] = $P1
+
+ $P2 = new 'Hash'
+ $P2['src/gen_actions.pir'] = 'src/parser/actions.pm'
+ $P0['pir_nqp'] = $P2
+
+ $P3 = new 'Hash'
+ $P4 = split "\n", <<'SOURCES'
+lolcode.pir
+src/gen_grammar.pir
+src/parser/yarn_literal.pir
+src/gen_actions.pir
+src/builtins.pir
+src/builtins/cmp.pir
+src/builtins/expr_parse.pir
+src/builtins/math.pir
+src/builtins/say.pir
+SOURCES
+ $P3['lolcode.pbc'] = $P4
+ $P0['pbc_pir'] = $P3
+
+ $P5 = new 'Hash'
+ $P5['parrot-lolcode'] = 'lolcode.pbc'
+ $P0['installable_pbc'] = $P5
+
+ # test
+ $S0 = get_parrot()
+ $S0 .= ' lolcode.pbc'
+ $P0['prove_exec'] = $S0
+
+ .tailcall setup(args :flat, $P0 :flat :named)
+.end
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
View
13 src/builtins.pir
@@ -0,0 +1,13 @@
+# $Id$
+
+.include 'src/builtins/cmp.pir'
+.include 'src/builtins/expr_parse.pir'
+.include 'src/builtins/math.pir'
+.include 'src/builtins/say.pir'
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+
View
3 src/builtins/cmp.pir
@@ -1,3 +1,6 @@
+
+.namespace []
+
.sub 'BOTH SAEM'
.param pmc x
.param pmc y
View
3 src/builtins/math.pir
@@ -1,3 +1,6 @@
+
+.namespace []
+
.sub 'SUM OF'
.param pmc x
.param pmc y
View
95 t/harness
@@ -1,95 +0,0 @@
-#! perl
-
-# $Id$
-
-use strict;
-use warnings;
-
-use FindBin;
-use File::Spec;
-use Getopt::Long qw(:config pass_through);
-
-$ENV{'HARNESS_PERL'} = './lolcode';
-use Test::Harness;
-$Test::Harness::switches = '';
-
-GetOptions(
- 'tests-from-file=s' => \my $list_file,
- 'verbosity=i' => \$Test::Harness::verbose,
- 'jobs:3' => \my $jobs,
- 'icu:1' => \my $do_icu,
-);
-
-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 => ['./lolcode'],
- verbosity => 0+$Test::Harness::verbose,
- jobs => $jobs || 1,
- );
- TAP::Harness->new( \%harness_options )->runtests(@tfiles);
-}
-else {
- runtests(@tfiles);
-}
-
-# 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;
-}
-

0 comments on commit 6870c5e

Please sign in to comment.