From d5c4641fc2089d340c5165c64cc82d3ef2477f6d Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Sat, 28 Nov 2009 22:25:05 +0100 Subject: [PATCH] update infrastructure with setup.pir (distutils) --- Configure.pl | 65 --------------- README | 6 +- config/makefiles/root.in | 170 --------------------------------------- gil.pir | 2 +- setup.pir | 75 +++++++++++++++++ src/builtins.pir | 9 +++ t/harness | 8 -- 7 files changed, 87 insertions(+), 248 deletions(-) delete mode 100644 Configure.pl delete mode 100644 config/makefiles/root.in create mode 100644 setup.pir create mode 100644 src/builtins.pir delete mode 100644 t/harness diff --git a/Configure.pl b/Configure.pl deleted file mode 100644 index d5d026d..0000000 --- a/Configure.pl +++ /dev/null @@ -1,65 +0,0 @@ -# $Id$ -# Copyright (C) 2009, The Perl Foundation. - -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: diff --git a/README b/README index 73b116a..675c724 100644 --- a/README +++ b/README @@ -1,7 +1,5 @@ Run: - $ cd languages - $ cd gil - $ perl Configure.pl - $ make + $ parrot setup.pir + $ parrot setup.pir test diff --git a/config/makefiles/root.in b/config/makefiles/root.in deleted file mode 100644 index 9a07550..0000000 --- a/config/makefiles/root.in +++ /dev/null @@ -1,170 +0,0 @@ -## $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 -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@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 \ - gil.pir - -BUILTINS_PIR := \ - src/builtins/say.pir \ - src/builtins/math.pir - -DOCS := README - -BUILD_CLEANUPS := \ - gil.pbc \ - "src/gen_*.pir" \ - "*.c" \ - "*$(O)" \ - gil@exe@ \ -#IF(win32): parrot-gil.exe \ -#IF(win32): parrot-gil.iss \ -#IF(win32): "setup-parrot-*.exe" \ - installable_gil@exe@ - -TEST_CLEANUPS := - -# the default target -build: gil.pbc - -all: build gil@exe@ installable - -gil.pbc: $(SOURCES) - $(PARROT) $(PARROT_ARGS) -o gil.pbc gil.pir - -gil@exe@: gil.pbc - $(PBC_TO_EXE) gil.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_gil@exe@ - -installable_gil@exe@: gil.pbc - $(PBC_TO_EXE) gil.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: gil.pbc" - @echo " This is the default." - @echo " gil@exe@ Self-hosting binary not to be installed." - @echo " all: gil.pbc gil@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 - -# basic run for missing libs -test-installable: installable - echo "1" | ./installable_gil@exe@ - -install: installable - $(CP) installable_gil@exe@ $(BIN_DIR)/parrot-gil@exe@ - $(CHMOD) 0755 $(BIN_DIR)/parrot-gil@exe@ - -$(MKPATH) $(LIB_DIR)/languages/gil - $(CP) gil.pbc $(LIB_DIR)/languages/gil/gil.pbc -# -$(MKPATH) $(MANDIR)/man1 -# $(POD2MAN) doc/running.pod > $(MANDIR)/man1/parrot-gil.1 -# -$(MKPATH) $(DOC_DIR)/languages/gil -# $(CP) $(DOCS) $(DOC_DIR)/languages/gil - -uninstall: - $(RM_F) $(BIN_DIR)/parrot-gil@exe@ - $(RM_RF) $(LIB_DIR)/languages/gil -# $(RM_F) $(MANDIR)/man1/parrot-gil.1 -# $(RM_RF) $(DOC_DIR)/languages/gil - -win32-inno-installer: installable -# -$(MKPATH) man/man1 -# $(POD2MAN) doc/running.pod > man/man1/parrot-gil.1 -# -$(MKPATH) man/html -# pod2html --infile doc/running.pod --outfile man/html/parrot-gil.html - $(CP) installable_gil@exe@ parrot-gil.exe - $(PERL) -I$(LIB_DIR)/tools/lib $(LIB_DIR)/tools/dev/mk_inno_language.pl gil - iscc parrot-gil.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: - diff --git a/gil.pir b/gil.pir index 3d23866..cbe4ffd 100644 --- a/gil.pir +++ b/gil.pir @@ -50,7 +50,7 @@ to the gil compiler. .end -.include 'src/gen_builtins.pir' +.include 'src/builtins.pir' .include 'src/gen_grammar.pir' .include 'src/gen_actions.pir' diff --git a/setup.pir b/setup.pir new file mode 100644 index 0000000..37a073e --- /dev/null +++ b/setup.pir @@ -0,0 +1,75 @@ +#! /usr/local/bin/parrot + +=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'] = 'gil' + $P0['abstract'] = 'Generic Imperative Language' + $P0['authority'] = 'http://github.com/tene' + $P0['description'] = 'Generic Imperative Language - demo language for parrot' + $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/tene/gil.git' + $P0['browser_uri'] = 'http://github.com/tene/gil' + $P0['project_uri'] = 'http://github.com/tene/gil' + + # 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' +gil.pir +src/gen_grammar.pir +src/gen_actions.pir +src/builtins.pir +src/builtins/math.pir +src/builtins/say.pir +SOURCES + $S0 = pop $P4 + $P3['gil.pbc'] = $P4 + $P0['pbc_pir'] = $P3 + + $P5 = new 'Hash' + $P5['parrot-gil'] = 'gil.pbc' + $P0['installable_pbc'] = $P5 + + # test + $S0 = get_parrot() + $S0 .= ' gil.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: diff --git a/src/builtins.pir b/src/builtins.pir new file mode 100644 index 0000000..321d2d5 --- /dev/null +++ b/src/builtins.pir @@ -0,0 +1,9 @@ + +.include 'src/builtins/math.pir' +.include 'src/builtins/say.pir' + +# Local Variables: +# mode: pir +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4 ft=pir: diff --git a/t/harness b/t/harness deleted file mode 100644 index 612b7d3..0000000 --- a/t/harness +++ /dev/null @@ -1,8 +0,0 @@ -#! perl - -# $Id$ - -use FindBin; -use lib qw( . lib ../lib ../../lib ); -use Parrot::Test::Harness language => 'gil', compiler => 'gil.pbc'; -