Permalink
Browse files

Convert over to PIR-based Configure and build system

Parrot's script for generating a language shell was used and tweaked.
This configuration does not yet compile on the NQP that Parrot
has in trunk right now:

(kadath)(~/git/nqptap master )$ parrot-nqp Configure.pir
Confused at line 4, near ".include '"
current instr.: 'parrot;HLL;Grammar;panic' pc 519 (src/stage0/HLL-s0.pir:336)
called from Sub 'parrot;NQP;Grammar;comp_unit' pc 4922 (src/stage0/NQP-s0.pir:138)
called from Sub 'parrot;NQP;Grammar;TOP' pc 965 (src/stage0/NQP-s0.pir:368)
called from Sub 'parrot;Regex;Cursor;parse' pc 282 (src/stage0/Regex-s0.pir:181)
called from Sub 'parrot;HLL;Compiler;parse' pc 24 (src/stage0/HLL-s0.pir:32)
called from Sub 'parrot;PCT;HLLCompiler;compile' pc 388 (src/PCT/HLLCompiler.pir:287)
called from Sub 'parrot;PCT;HLLCompiler;eval' pc 937 (src/PCT/HLLCompiler.pir:532)
called from Sub 'parrot;PCT;HLLCompiler;evalfiles' pc 1224 (src/PCT/HLLCompiler.pir:676)
called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1410 (src/PCT/HLLCompiler.pir:763)
called from Sub 'parrot;NQP;Compiler;main' pc -1 ((unknown file):-1)

As far as I know, NQP does not yet have a version numbering scheme and
this makes the situation icky. pmichaud++ has described a good one, it
just has not been implemented yet.
  • Loading branch information...
1 parent c0579bc commit fbb061dcceb8a3b9717be873bc9756245173b563 @leto committed Nov 27, 2009
Showing with 618 additions and 51 deletions.
  1. +0 −51 Configure.nqp
  2. +58 −0 Configure.pir
  3. +188 −0 Makefile.in
  4. +1 −0 PARROT_REVISION
  5. +40 −0 nqptap.pir
  6. +83 −0 setup.pir
  7. +10 −0 src/builtins.pir
  8. +31 −0 src/builtins/say.pir
  9. +53 −0 src/nqptap.pir
  10. +94 −0 src/parser/actions.pm
  11. +13 −0 src/parser/grammar-oper.pg
  12. +47 −0 src/parser/grammar.pg
View
@@ -1,51 +0,0 @@
-# Purpose: Use Parrot's config info to configure our Makefile.
-#
-# Usage:
-# nqp Configure.nqp [input_makefile [output_makefile]]
-#
-# input_makefile defaults to 'src/Makefile.in';
-# output_makefile defaults to 'Makefile'.
-
-our @ARGS;
-our %VM;
-our $OS;
-
-MAIN();
-
-sub MAIN () {
- # Wave to the friendly users
- say("Hello, I'm Configure. My job is to poke and prod\nyour system to figure out how to build nqpTAP.\n");
-
- # Load Parrot config and glue functions
- pir::load_bytecode('PGE.pbc');
- pir::load_bytecode('src/lib/Glue.pir');
-
- # Slurp in the unconfigured Makefile text
- my $unconfigured := slurp(@ARGS[0] || 'src/Makefile.in');
-
- # Replace all of the @foo@ markers
- my $replaced := subst($unconfigured, rx('\@<ident>\@'), replacement);
-
- # Fix paths on Windows
- if ($OS eq 'MSWin32') {
- $replaced := subst($replaced, rx('\/'), '\\' );
- $replaced := subst($replaced, rx('\\\\\*'), '\\\\*');
- }
-
- # Spew out the final makefile
- spew(@ARGS[1] || 'Makefile', $replaced);
-
- # Give the user a hint of next action
- my $make := %VM<config><make>;
- say("Configure completed for platform '$OS'.");
- say("You can now type '$make' to build nqpTAP.\n");
- say("You may also type '$make test' to run the nqpTAP test suite.\n");
- say("Happy Hacking,\n\tThe nqpTAP Team");
-}
-
-sub replacement ($match) {
- my $key := $match<ident>;
- my $config := %VM<config>{$key} || '';
-
- return $config;
-}
View
@@ -0,0 +1,58 @@
+#! /usr/local/bin/parrot
+# $Id$
+
+.include 'sysinfo.pasm'
+.include 'iglobals.pasm'
+
+.sub 'main' :main
+ load_bytecode 'Configure.pbc'
+
+ # Wave to the friendly users
+ print "Hello! I'm Configure. My job is to poke and prod\n"
+ print "your system to figure out how to build nqpTAP.\n"
+
+ .local pmc config
+ $P0 = getinterp
+ config = $P0[.IGLOBALS_CONFIG_HASH]
+ .local string OS
+ OS = sysinfo .SYSINFO_PARROT_OS
+
+ # Here, do the job
+ push_eh _handler
+ genfile('Makefile.in', 'Makefile', config)
+# genfile('src/ops/Makefile.in', 'src/ops/Makefile', config)
+# genfile('src/pmc/Makefile.in', 'src/pmc/Makefile', config)
+ pop_eh
+
+ # Give the user a hint of next action
+ .local string make
+ make = config['make']
+ print "Configure completed for platform '"
+ print OS
+ print "'.\n"
+ print "You can now type '"
+ print make
+ print "' to build nqptap.\n"
+ print "You may also type '"
+ print make
+ print " test' to run the nqptap test suite.\n"
+ print "\nHappy Hacking,\n\tThe nqpTAP Team.\n"
+ end
+
+ _handler:
+ .local pmc e
+ .local string msg
+ .get_results (e)
+ printerr "\n"
+ msg = e
+ printerr msg
+ printerr "\n"
+ end
+.end
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+
View
@@ -0,0 +1,188 @@
+## $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
+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@
+
+NQPTAP_GROUP := $(PMC_DIR)/nqptap_group$(LOAD_EXT)
+NQPTAP_OPS := $(OPS_DIR)/nqptap_ops$(LOAD_EXT)
+
+#PMC_DEPS := src/pmc/Makefile.in $(PMC_DIR)/nqptap.pmc
+#OPS_DEPS := src/ops/Makefile.in $(OPS_DIR)/nqptap.ops
+
+SOURCES := \
+ src/nqptap.pir \
+ src/gen_grammar.pir \
+ src/gen_actions.pir \
+ src/builtins.pir \
+ src/builtins/say.pir
+
+DOCS := README
+
+BUILD_CLEANUPS := \
+ nqptap.pbc \
+ nqptap/nqptap.pbc \
+ "src/gen_*.pir" \
+ "*.c" \
+ "*$(O)" \
+#IF(win32): parrot-nqptap.exe \
+#IF(win32): parrot-nqptap.iss \
+#IF(win32): "setup-parrot-*.exe" \
+ installable_nqptap@exe@
+
+TEST_CLEANUPS :=
+
+# the default target
+build: \
+ $(NQPTAP_OPS) \
+ $(NQPTAP_GROUP) \
+ nqptap/nqptap.pbc \
+ nqptap.pbc
+
+all: build installable
+
+nqptap.pbc: nqptap.pir
+ $(PARROT) $(PARROT_ARGS) -o nqptap.pbc nqptap.pir
+
+nqptap/nqptap.pbc: $(SOURCES)
+ $(PARROT) $(PARROT_ARGS) -o nqptap/nqptap.pbc src/nqptap.pir
+
+src/gen_grammar.pir: $(PERL6GRAMMAR) src/parser/grammar.pg src/parser/grammar-oper.pg
+ $(PARROT) $(PARROT_ARGS) $(PERL6GRAMMAR) \
+ --output=src/gen_grammar.pir \
+ src/parser/grammar.pg \
+ src/parser/grammar-oper.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
+
+$(NQPTAP_GROUP): $(PMC_DEPS)
+# $(MAKE) $(PMC_DIR)
+
+$(NQPTAP_OPS): $(OPS_DEPS)
+# $(MAKE) $(OPS_DIR)
+
+installable: installable_nqptap@exe@
+
+installable_nqptap@exe@: nqptap.pbc
+ $(PBC_TO_EXE) nqptap.pbc --install
+
+Makefile: Makefile.in
+ $(PARROT) Configure.pir
+
+# 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: nqptap.pbc"
+ @echo " This is the default."
+ @echo " nqptap@exe@ Self-hosting binary not to be installed."
+ @echo " all: nqptap.pbc nqptap@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
+ prove --exec="$(PARROT) nqptap.pbc" t/*.t
+
+# basic run for missing libs
+test-installable: installable
+ echo "1" | ./installable_nqptap@exe@
+
+install: installable
+# $(MAKE) $(OPS_DIR) install
+# $(MAKE) $(PMC_DIR) install
+ $(CP) installable_nqptap@exe@ $(BIN_DIR)/parrot-nqptap@exe@
+ $(CHMOD) 0755 $(BIN_DIR)/parrot-nqptap@exe@
+ -$(MKPATH) $(LIB_DIR)/languages/nqptap
+ $(CP) nqptap/nqptap.pbc $(LIB_DIR)/languages/nqptap/nqptap.pbc
+# -$(MKPATH) $(MANDIR)/man1
+# $(POD2MAN) doc/running.pod > $(MANDIR)/man1/parrot-nqptap.1
+# -$(MKPATH) $(DOC_DIR)/languages/nqptap
+# $(CP) $(DOCS) $(DOC_DIR)/languages/nqptap
+
+uninstall:
+# $(MAKE) $(OPS_DIR) uninstall
+# $(MAKE) $(PMC_DIR) uninstall
+ $(RM_F) $(BIN_DIR)/parrot-nqptap@exe@
+ $(RM_RF) $(LIB_DIR)/languages/nqptap
+# $(RM_F) $(MANDIR)/man1/parrot-nqptap.1
+# $(RM_RF) $(DOC_DIR)/languages/nqptap
+
+win32-inno-installer: installable
+# -$(MKPATH) man/man1
+# $(POD2MAN) doc/running.pod > man/man1/parrot-nqptap.1
+# -$(MKPATH) man/html
+# pod2html --infile doc/running.pod --outfile man/html/parrot-nqptap.html
+ $(CP) installable_nqptap@exe@ parrot-nqptap.exe
+ $(PERL) -I$(LIB_DIR)/tools/lib $(LIB_DIR)/tools/dev/mk_inno_language.pl nqptap
+ iscc parrot-nqptap.iss
+
+testclean:
+ $(RM_F) $(TEST_CLEANUPS)
+
+clean:
+# $(MAKE) $(OPS_DIR) clean
+# $(MAKE) $(PMC_DIR) clean
+ $(RM_F) $(TEST_CLEANUPS) $(BUILD_CLEANUPS)
+
+realclean:
+# $(MAKE) $(OPS_DIR) realclean
+# $(MAKE) $(PMC_DIR) realclean
+ $(RM_F) $(TEST_CLEANUPS) $(BUILD_CLEANUPS) Makefile
+
+distclean: realclean
+
+# Local variables:
+# mode: makefile
+# End:
+# vim: ft=make:
+
View
@@ -0,0 +1 @@
+42797
View
@@ -0,0 +1,40 @@
+# $Id$
+
+=head1 TITLE
+
+nqptap.pir - A nqptap compiler.
+
+=head2 Description
+
+This is the entry point for the nqptap compiler.
+
+=head2 Functions
+
+=over 4
+
+=item main(args :slurpy) :main
+
+Start compilation by passing any command line C<args>
+to the nqptap compiler.
+
+=cut
+
+.sub 'main' :main
+ .param pmc args
+
+ load_language 'nqptap'
+
+ $P0 = compreg 'nqptap'
+ $P1 = $P0.'command_line'(args)
+.end
+
+=back
+
+=cut
+
+# Local Variables:
+# mode: pir
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4 ft=pir:
+
Oops, something went wrong.

0 comments on commit fbb061d

Please sign in to comment.