Permalink
Browse files

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

  • Loading branch information...
1 parent 4348920 commit 943e0408907fa5ea61d81765a37b2bde38a0cb9e @fperrad fperrad committed Nov 22, 2009
Showing with 80 additions and 267 deletions.
  1. +0 −66 Configure.pl
  2. +3 −3 README
  3. +0 −164 config/makefiles/root.in
  4. +62 −0 setup.pir
  5. +0 −31 t/harness
  6. +5 −1 t/test_bf.t
  7. +5 −1 t/test_bfc.t
  8. +5 −1 t/test_bfco.t
View
@@ -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
@@ -2,16 +2,16 @@ DESCRIPTION
This is a Brainfuck interpreter for Parrot. Brainfuck is a full
computer programming language with only eight commands. For more
-information, see http://www.catseye.mb.ca/esoteric/bf/ or
+information, see http://www.catseye.mb.ca/esoteric/bf/ or
http://en.wikipedia.org/wiki/Brainfuck.
To compile the files:
- $ make
+ $ parrot setup.pir
To check that the compiler is working:
- $ make test
+ $ parrot setup.pir test
To run an example Brainfuck program:
@@ -1,164 +0,0 @@
-# Copyright (C) 2002-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@
-
-## Setup some commands
-PERL := @perl@
-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@
-
-DOCS := README
-
-BUILD_CLEANUPS := \
- "*.pbc" \
- "*.c" \
- "*$(O)" \
- bf@exe@ \
- bfc@exe@ \
- bfco@exe@ \
-#IF(win32): "parrot-*.exe" \
-#IF(win32): parrot-bf.iss \
-#IF(win32): "setup-parrot-*.exe" \
- installable_bf@exe@ \
- installable_bfc@exe@ \
- installable_bfco@exe@
-
-TEST_CLEANUPS :=
-
-# the default target
-build: bf.pbc bfc.pbc bfco.pbc
-
-all: build bf@exe@ bfc@exe@ bfco@exe@ installable
-
-bf.pbc: bf.pasm
- $(PARROT) -o bf.pbc bf.pasm
-
-bfc.pbc: bfc.pir
- $(PARROT) -o bfc.pbc bfc.pir
-
-bfco.pbc: bfco.pir
- $(PARROT) -o bfco.pbc bfco.pir
-
-bf@exe@: bf.pbc
- $(PBC_TO_EXE) bf.pbc
-
-bfc@exe@: bfc.pbc
- $(PBC_TO_EXE) bfc.pbc
-
-bfco@exe@: bfco.pbc
- $(PBC_TO_EXE) bfco.pbc
-
-installable: installable_bf@exe@ installable_bfc@exe@ installable_bfco@exe@
-
-installable_bf@exe@: bf.pbc
- $(PBC_TO_EXE) bf.pbc --install
-
-installable_bfc@exe@: bfc.pbc
- $(PBC_TO_EXE) bfc.pbc --install
-
-installable_bfco@exe@: bfco.pbc
- $(PBC_TO_EXE) bfco.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: bf.pbc"
- @echo " This is the default."
- @echo " all: bf.pbc bf@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 " 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
-
-install: installable
- $(CP) installable_bf@exe@ $(BIN_DIR)/parrot-bf@exe@
- $(CHMOD) 0755 $(BIN_DIR)/parrot-bf@exe@
- $(CP) installable_bfc@exe@ $(BIN_DIR)/parrot-bfc@exe@
- $(CHMOD) 0755 $(BIN_DIR)/parrot-bfc@exe@
- $(CP) installable_bfco@exe@ $(BIN_DIR)/parrot-bfco@exe@
- $(CHMOD) 0755 $(BIN_DIR)/parrot-bfco@exe@
- -$(MKPATH) $(LIB_DIR)/languages/bf
- $(CP) bf.pbc $(LIB_DIR)/languages/bf/bf.pbc
- $(CP) bfc.pbc $(LIB_DIR)/languages/bf/bfc.pbc
- $(CP) bfco.pbc $(LIB_DIR)/languages/bf/bfco.pbc
-# -$(MKPATH) $(MANDIR)/man1
-# $(POD2MAN) doc/running.pod > $(MANDIR)/man1/parrot-bf.1
- -$(MKPATH) $(DOC_DIR)/languages/bf
- $(CP) $(DOCS) $(DOC_DIR)/languages/bf
-
-uninstall:
- $(RM_F) $(BIN_DIR)/parrot-bf@exe@
- $(RM_F) $(BIN_DIR)/parrot-bfc@exe@
- $(RM_F) $(BIN_DIR)/parrot-bfco@exe@
- $(RM_RF) $(LIB_DIR)/languages/bf
-# $(RM_F) $(MANDIR)/man1/parrot-bf.1
- $(RM_RF) $(DOC_DIR)/languages/bf
-
-win32-inno-installer: installable
-# -$(MKPATH) man/man1
-# $(POD2MAN) doc/running.pod > man/man1/parrot-bf.1
-# -$(MKPATH) man/html
-# pod2html --infile doc/running.pod --outfile man/html/parrot-bf.html
- $(CP) installable_bf@exe@ parrot-bf.exe
- $(CP) installable_bfc@exe@ parrot-bfc.exe
- $(CP) installable_bfco@exe@ parrot-bfco.exe
- $(PERL) -I$(LIB_DIR)/tools/lib $(LIB_DIR)/tools/dev/mk_inno_language.pl bf
- iscc parrot-bf.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
@@ -0,0 +1,62 @@
+#! /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'] = 'bf'
+ $P0['abstract'] = 'Brainfuck'
+ $P0['description'] = 'This is a Brainfuck interpreter 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['generated_by'] = 'Francois Perrad <francois.perrad@gadz.org>'
+ $P0['checkout_uri'] = 'https://svn.parrot.org/languages/bf/trunk'
+ $P0['browser_uri'] = 'https://trac.parrot.org/languages/browser/bf'
+ $P0['project_uri'] = 'https://trac.parrot.org/parrot/wiki/Languages'
+
+ # build
+ $P1 = new 'Hash'
+ $P1['bf.pbc'] = 'bf.pasm'
+ $P1['bfc.pbc'] = 'bfc.pir'
+ $P1['bfco.pbc'] = 'bfco.pir'
+ $P0['pbc_pir'] = $P1
+
+ $P2 = new 'Hash'
+ $P2['parrot-bf'] = 'bf.pbc'
+ $P2['parrot-bfc'] = 'bfc.pbc'
+ $P2['parrot-bfco'] = 'bfco.pbc'
+ $P0['installable_pbc'] = $P2
+
+ # test
+ $S0 = get_parrot()
+ $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
@@ -1,31 +0,0 @@
-#! perl
-
-# $Id$
-
-=head1 NAME
-
-languages/bf/t/harness - A harness for bf
-
-=head1 SYNOPSIS
-
- cd languages && perl -I../lib bf/t/harness --files
-
- cd languages && perl -I../lib bf/t/harness
-
- cd languages && perl -I../lib bf/t/harness \
- bf/t/test_bf.t \
- bf/t/test_bfc.t
-
-=head1 DESCRIPTION
-
-If I'm called with a single
-argument of "--files", I just return a list of files to process.
-This list is one per line, and is relative to the languages dir.
-
-If I'm called with no args, I run the complete suite.
-
-Otherwise I run the tests that were passed on the command line.
-
-=cut
-
-use Parrot::Test::Harness language => 'bf';
View
@@ -3,4 +3,8 @@
# Test bf compiler
# Print TAP, Test Anything Protocol
-system( "../parrot -r bf/bf.pbc bf/test.bf" );
+.sub 'main' :main
+ $S0 = 'parrot -r bf.pbc test.bf'
+ $I0 = spawnw $S0
+.end
+
View
@@ -3,4 +3,8 @@
# Test bf interpreter
# Print TAP, Test Anything Protocol
-system( "../parrot -r bf/bfc.pbc bf/test.bf" );
+.sub 'main' :main
+ $S0 = 'parrot -r bfc.pbc test.bf'
+ $I0 = spawnw $S0
+.end
+
View
@@ -3,4 +3,8 @@
# Test bf interpreter
# Print TAP, Test Anything Protocol
-system( "../parrot -r bf/bfco.pbc bf/test.bf" );
+.sub 'main' :main
+ $S0 = 'parrot -r bfco.pbc test.bf'
+ $I0 = spawnw $S0
+.end
+

0 comments on commit 943e040

Please sign in to comment.