Browse files

update infrastructure with setup.pir (distutils)

  • Loading branch information...
1 parent 62ad078 commit 10dca746dccb5b0d6c17d1fe68cfc0c53afdf16f @fperrad fperrad committed Dec 8, 2009
Showing with 229 additions and 369 deletions.
  1. +6 −2 .gitignore
  2. +0 −159 Configure.pl
  3. +0 −181 build/Makefile.in
  4. +223 −0 setup.pir
  5. +0 −27 t/harness
View
8 .gitignore
@@ -1,4 +1,4 @@
-Makefile
+MANIFEST
*.pbc
*.c
@@ -11,6 +11,10 @@ Makefile
cardinal
installable_cardinal
+*.tar.gz
+*.zip
+*.patch
+
Test.pir
-gen_*.pir
+src/gen_*.pir
build.yaml
View
159 Configure.pl
@@ -1,159 +0,0 @@
-#! perl
-# Copyright (C) 2009 The Perl Foundation
-
-use strict;
-use warnings;
-use 5.008;
-
-MAIN: {
- my %valid_options = (
- 'help' => 'Display configuration help',
- 'parrot-config' => 'Use configuration given by parrot_config binary',
- 'gen-parrot' => 'Automatically retrieve and build Parrot',
- );
-
- # Get any options from the command line
- my %options = get_command_options( \%valid_options );
-
- # Print help if it's requested
- if ($options{'help'}) {
- print_help();
- exit(0);
- }
-
- # Update/generate parrot build if needed
- if ($options{'gen-parrot'}) {
- system("$^X build/gen_parrot.pl");
- }
-
- # Get a list of parrot-configs to invoke.
- my @parrot_config_exe = qw(
- parrot/parrot_config
- ../../parrot_config
- parrot_config
- );
-
- if ($options{'parrot-config'} && $options{'parrot-config'} ne '1') {
- @parrot_config_exe = ($options{'parrot-config'});
- }
-
- # 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
- }
-
-# Create the Makefile using the information we just got
- create_makefile(%config);
-
- my $make = $config{'make'};
- print <<"END";
-
-You can now use '$make' to build Cardinal Ruby.
-After that, you can use '$make test' to run some local tests.
-
-END
- exit 0;
-
-}
-
-
-# Process command line arguments into a hash.
-sub get_command_options {
- my $valid_options = shift;
-
- my %options = ();
- for my $arg (@ARGV) {
- if ($arg =~ /^--(\w[-\w]*)(?:=(.*))?/ && $valid_options->{$1}) {
- my ($key, $value) = ($1, $2);
- $value = 1 unless defined $value;
- $options{$key} = $value;
- next;
- }
- die qq/Invalid option "$arg". See "perl Configure.pl --help" for valid options.\n/;
- }
- return %options;
-}
-
-
-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>) {
- if (/(\w+) => '(.*)'/) { $config{$1} = $2 }
- }
- close $PARROT_CONFIG;
- last if %config;
- }
- }
- return %config;
-}
-
-
-# Generate a Makefile from a configuration
-sub create_makefile {
- my %config = @_;
-
- my $maketext = slurp( 'build/Makefile.in' );
-
- $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;
- }
-
- my $outfile = 'Makefile';
- print "Creating $outfile\n";
- open(my $MAKEOUT, '>', $outfile) ||
- die "Unable to write $outfile\n";
- print {$MAKEOUT} $maketext;
- close $MAKEOUT or die $!;
-
- return;
-}
-
-sub slurp {
- my $filename = shift;
-
- open my $fh, '<', $filename or die "Unable to read $filename\n";
- local $/ = undef;
- my $maketext = <$fh>;
- close $fh or die $!;
-
- return $maketext;
-}
-
-
-# Print some help text.
-sub print_help {
- print <<'END';
-Configure.pl - Cardinal Configure
-
-General Options:
- --help Show this text
- --gen-parrot Download and build a copy of Parrot to use
- --parrot-config=(config)
- Use configuration information from config
-
-END
-
- return;
-}
-
-# Local Variables:
-# mode: cperl
-# cperl-indent-level: 4
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
View
181 build/Makefile.in
@@ -1,181 +0,0 @@
-# Copyright (C) 2008-2009, Parrot Foundation.
-## $Id$
-
-## arguments we want to run parrot with
-PARROT_ARGS =
-
-## configuration settings
-BUILD_DIR = @build_dir@
-LOAD_EXT = @load_ext@
-O = @o@
-EXE = @exe@
-
-## Setup some commands
-LN_S = @lns@
-PERL = @perl@
-RM_RF = @rm_rf@
-CP = @cp@
-CAT = @cat@
-BUILD_DYNPMC = $(PERL) $(BUILD_DIR)/tools/build/dynpmc.pl
-RECONFIGURE = $(PERL) $(BUILD_DIR)/tools/dev/reconfigure.pl
-PARROT = $(BUILD_DIR)/parrot$(EXE)
-PBC_TO_EXE = $(BUILD_DIR)/pbc_to_exe$(EXE)
-
-## places to look for things
-PARROT_DYNEXT = $(BUILD_DIR)/runtime/parrot/dynext
-PGE_LIBRARY = $(BUILD_DIR)/runtime/parrot/library/PGE
-PERL6GRAMMAR = $(PGE_LIBRARY)/Perl6Grammar.pbc
-NQP = $(BUILD_DIR)/compilers/nqp/nqp.pbc
-PCT = $(BUILD_DIR)/runtime/parrot/library/PCT.pbc
-
-PMC_DIR = src/pmc
-
-all: cardinal.pbc Test.pir cardinal$(EXE)
-
-CARDINAL_GROUP = $(PMC_DIR)/cardinal_group$(LOAD_EXT)
-
-SOURCES = cardinal.pir \
- src/parser/quote_expression.pir \
- src/gen_grammar.pir \
- src/gen_actions.pir \
- src/gen_builtins.pir \
-# $(CARDINAL_GROUP)
-
-BUILTINS_PIR = \
- src/builtins/guts.pir \
- src/builtins/control.pir \
- src/builtins/say.pir \
- src/builtins/cmp.pir \
- src/builtins/op.pir \
- src/classes/Object.pir \
- src/classes/Exception.pir \
- src/classes/NilClass.pir \
- src/classes/String.pir \
- src/classes/Integer.pir \
- src/classes/Array.pir \
- src/classes/Hash.pir \
- src/classes/Range.pir \
- src/classes/TrueClass.pir \
- src/classes/FalseClass.pir \
- src/classes/Kernel.pir \
- src/classes/Time.pir \
- src/classes/Math.pir \
- src/classes/GC.pir \
- src/classes/IO.pir \
- src/classes/Proc.pir \
- src/classes/File.pir \
- src/classes/FileStat.pir \
- src/classes/Dir.pir \
- src/builtins/globals.pir \
- src/builtins/eval.pir \
- src/classes/Continuation.pir \
-
-# PMCS = cardinal
-# PMC_SOURCES = $(PMC_DIR)/cardinal.pmc
-
-# targets for building a standalone cardinal.
-# (We're not quite ready to make this a default target.)
-cardinal$(EXE): cardinal.pbc
- $(PBC_TO_EXE) cardinal.pbc
-
-installable: installable_cardinal$(EXE)
-
-installable_cardinal$(EXE): cardinal.pbc
- $(PBC_TO_EXE) cardinal.pbc --install
-
-# the default target
-cardinal.pbc: $(PARROT) $(SOURCES)
- $(PARROT) $(PARROT_ARGS) -o cardinal.pbc cardinal.pir
-
-Test.pir: $(PARROT) Test.rb cardinal.pbc
- $(PARROT) $(PARROT_ARGS) cardinal.pbc --target=pir --output=Test.pir Test.rb
-
-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) $(PCT) 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
-
-$(CARDINAL_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)
-
-# regenerate the Makefile
-Makefile: build/Makefile.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 " all: cardinal.pbc"
- @echo " This is the default."
- @echo "Testing:"
- @echo " test: Run the test suite."
- @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: all
- rake test:all
-
-arraytest: all
- rake test:array:all
-
-hashtest: all
- rake test:hash:all
-
-# this target has nothing to do
-testclean:
-
-CLEANUPS = \
- cardinal.pbc \
- cardinal.c \
- *.manifest \
- *.pdb \
- cardinal$(O) \
- cardinal$(EXE) \
- installable_cardinal$(EXE) \
- src/gen_grammar.pir \
- src/gen_actions.pir \
- src/gen_builtins.pir \
- $(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 \
-
-
-clean:
- $(RM_RF) $(CLEANUPS)
-
-realclean: clean
- $(RM_RF) Makefile
-
-distclean: realclean
-
-# Local variables:
-# mode: makefile
-# End:
-# vim: ft=make:
View
223 setup.pir
@@ -0,0 +1,223 @@
+#!/usr/bin/env parrot
+# Copyright (C) 2009, Parrot Foundation.
+
+=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'
+ .local pmc config
+ config = get_config()
+
+ .const 'Sub' prebuild = 'prebuild'
+ register_step_before('build', prebuild)
+
+ .const 'Sub' postbuild = 'postbuild'
+ register_step_after('build', postbuild)
+
+ .const 'Sub' clean = 'clean'
+ register_step_before('clean', clean)
+
+ .const 'Sub' arraytest = 'arraytest'
+ register_step('arraytest', arraytest)
+
+ .const 'Sub' hashtest = 'hashtest'
+ register_step('hashtest', hashtest)
+
+ $P0 = new 'Hash'
+ $P0['name'] = 'Cardinal'
+ $P0['abstract'] = 'Cardinal - Ruby compiler for Parrot'
+ $P0['authority'] = 'http://github.com/cardinal'
+ $P0['description'] = 'Cardinal is a Ruby compiler for Parrot.'
+ $P1 = split ',', 'ruby'
+ $P0['keywords'] = $P1
+ $P0['license_type'] = 'Artistic License 2.0'
+ $P0['license_uri'] = 'http://www.perlfoundation.org/artistic_license_2_0'
+ $P0['copyright_holder'] = 'Parrot Foundation'
+ $P0['checkout_uri'] = 'git://github.com/cardinal/cardinal.git'
+ $P0['browser_uri'] = 'http://github.com/cardinal/cardinal'
+ $P0['project_uri'] = 'http://github.com/cardinal/cardinal'
+
+ # build
+ $P2 = new 'Hash'
+ $P2['src/gen_grammar.pir'] = 'src/parser/grammar.pg'
+ $P0['pir_pge'] = $P2
+
+ $P3 = new 'Hash'
+ $P3['src/gen_actions.pir'] = 'src/parser/actions.pm'
+ $P0['pir_nqp'] = $P3
+
+ $P4 = new 'Hash'
+ $P5 = split "\n", <<'SOURCES'
+cardinal.pir
+src/parser/quote_expression.pir
+src/gen_grammar.pir
+src/gen_actions.pir
+src/gen_builtins.pir
+SOURCES
+ $S0 = pop $P5
+ $P4['cardinal.pbc'] = $P5
+ $P0['pbc_pir'] = $P4
+
+ $P6 = new 'Hash'
+ $P6['parrot-cardinal'] = 'cardinal.pbc'
+ $P0['exe_pbc'] = $P6
+ $P0['installable_pbc'] = $P6
+
+ # test
+ $S0 = get_parrot()
+ $S0 .= ' cardinal.pbc'
+ $P0['prove_exec'] = $S0
+ $P0['prove_files'] = 't/*.t t/*/*.t'
+
+ # smoke
+ $P7 = new 'Hash'
+ $S0 = config['archname']
+ $P7['Architecture'] = $S0
+ $S0 = config['osname']
+ $P7['Platform'] = $S0
+ $S0 = config['revision']
+ $P7['Parrot Revision'] = $S0
+ $S0 = get_submitter()
+ $P7['Submitter'] = $S0
+ $P0['smolder_extra_properties'] = $P7
+ $S0 = get_tags()
+ $P0['smolder_tags'] = $S0
+ $P0['prove_archive'] = 'report.tar.gz'
+ $P0['smolder_url'] = 'http://smolder.plusthree.com/app/public_projects/process_add_report/16'
+
+ # dist
+ $P8 = glob('src/builtins/*.pir src/classes/*.pir Test.rb')
+ $P0['manifest_includes'] = $P8
+ $P0['manifest_excludes'] = 'src/gen_builtins.pir'
+
+ .tailcall setup(args :flat, $P0 :flat :named)
+.end
+
+.sub 'prebuild' :anon
+ .param pmc kv :slurpy :named
+ $P1 = split "\n", <<'BUILTINS_PIR'
+src/builtins/guts.pir
+src/builtins/control.pir
+src/builtins/say.pir
+src/builtins/cmp.pir
+src/builtins/op.pir
+src/classes/Object.pir
+src/classes/Exception.pir
+src/classes/NilClass.pir
+src/classes/String.pir
+src/classes/Integer.pir
+src/classes/Array.pir
+src/classes/Hash.pir
+src/classes/Range.pir
+src/classes/TrueClass.pir
+src/classes/FalseClass.pir
+src/classes/Kernel.pir
+src/classes/Time.pir
+src/classes/Math.pir
+src/classes/GC.pir
+src/classes/IO.pir
+src/classes/Proc.pir
+src/classes/File.pir
+src/classes/FileStat.pir
+src/classes/Dir.pir
+src/builtins/globals.pir
+src/builtins/eval.pir
+src/classes/Continuation.pir
+BUILTINS_PIR
+ $S0 = pop $P1
+ $I0 = newer('src/gen_builtins.pir', $P1)
+ if $I0 goto L1
+ $S0 = "# generated by setup.pir\n\n.include '"
+ $S1 = join "'\n.include '", $P1
+ $S0 .= $S1
+ $S0 .= "'\n\n"
+ spew('src/gen_builtins.pir', $S0)
+ say "creating src/gen_builtins.pir"
+ L1:
+.end
+
+.sub 'postbuild' :anon
+ .param pmc kv :slurpy :named
+ $P1 = split ' ', 'Test.rb cardinal.pbc'
+ $I0 = newer('Test.pir', $P1)
+ if $I0 goto L1
+ .local string cmd
+ cmd = get_parrot()
+ cmd .= ' cardinal.pbc --target=pir --output=Test.pir Test.rb'
+ system(cmd, 1 :named('verbose'))
+ L1:
+.end
+
+.sub 'clean' :anon
+ .param pmc kv :slurpy :named
+ unlink('src/gen_builtins.pir', 1 :named('verbose'))
+ unlink('Test.pir', 1 :named('verbose'))
+.end
+
+.sub 'arraytest' :anon
+ .param pmc kv :slurpy :named
+ run_step('build', kv :flat :named)
+
+ .local string cmd
+ cmd = "prove --exec=\""
+ $S0 = get_parrot()
+ cmd .= $S0
+ cmd .= " cardinal.pbc\" t/array/*.t"
+ system(cmd, 1 :named('verbose'))
+.end
+
+.sub 'hashtest' :anon
+ .param pmc kv :slurpy :named
+ run_step('build', kv :flat :named)
+
+ .local string cmd
+ cmd = "prove --exec=\""
+ $S0 = get_parrot()
+ cmd .= $S0
+ cmd .= " cardinal.pbc\" t/hash/*.t"
+ system(cmd, 1 :named('verbose'))
+.end
+
+.sub 'get_tags' :anon
+ .local string tags
+ .local pmc config
+ config = get_config()
+ tags = config['osname']
+ tags .= ", "
+ $S0 = config['archname']
+ tags .= $S0
+ .return (tags)
+.end
+
+.sub 'get_submitter' :anon
+ $P0 = new 'Env'
+ $I0 = exists $P0['SMOLDER_SUBMITTER']
+ unless $I0 goto L1
+ $S0 = $P0['SMOLDER_SUBMITTER']
+ .return ($S0)
+ L1:
+ .return ('')
+.end
+
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
View
27 t/harness
@@ -1,27 +0,0 @@
-#! perl
-
-# $Id$
-
-use FindBin;
-use lib qw( . lib ../lib ../../lib );
-use File::Spec;
-use Getopt::Long qw(:config pass_through);
-use Data::Dumper;
-
-my %harness_args = (
- language => 'cardinal',
- compiler => 'cardinal.pbc',
-);
-
-GetOptions(
- 'tests-from-dir=s' => \my $test_dir,
- );
-if ($test_dir) {
-my @files = grep m/^[^-]/, @ARGV;
-push @files, "t/$test_dir/*.t";
-
-$harness_args{files} = \@files;
-}
-
-eval 'use Parrot::Test::Harness %harness_args';
-

0 comments on commit 10dca74

Please sign in to comment.