Commits

blairuk  committed 1c04ec7

Remove dependency on Perl (except for parrot of course!)
Replace Makefile.in with platform independent setup.py (use args help/build/test).
Update subunit to allow optional command for testing - allows use in Win32 as well as Linux.
Updated runtests.py to use new subunit option to allow tests to also run on Windows.

  • Participants
  • Parent commits 6e16bd0

Comments (0)

Files changed (7)

File Configure.pl

-#! perl
-
-use strict;
-use warnings;
-
-my $perlbin = `parrot_config perl`;
-my $libdir = `parrot_config libdir`;
-my $versiondir = `parrot_config versiondir`;
-my $slash = `parrot_config slash`;
-my $make = `parrot_config make`;
-
-chomp($perlbin);
-chomp($libdir);
-chomp($versiondir);
-chomp($slash);
-chomp($make);
-
-my $build_tool = $perlbin . " "
-               . $libdir
-               . $versiondir
-               . $slash
-               . "tools"
-               . $slash
-               . "dev"
-               . $slash
-               . "gen_makefile.pl";
-
-my %makefiles = (
-    "Makefile.in" => "Makefile",
-);
-
-foreach my $template (keys %makefiles) {
-    my $makefile = $makefiles{$template};
-    print "Creating $makefile\n";
-    system("$build_tool $template $makefile");
-}
-
-print <<"END";
-
-You can now use '$make' to build Pynie, and '$make-test' to test it.
-END
-
-exit;

File Makefile.in

-# Copyright (C) 2006-2009, The Perl Foundation.
-# $Id$
-
-# arguments we want to run parrot with
-PARROT_ARGS =
-
-# values from parrot_config
-LOAD_EXT      = @load_ext@
-O             = @o@
-EXE           = @exe@
-MAKE          = @make_c@
-RM_F          = @rm_f@
-PERL          = @perl@
-
-VERSION_DIR   = @versiondir@
-INCLUDE_DIR   = @includedir@$(VERSION_DIR)
-LIB_DIR       = @libdir@$(VERSION_DIR)
-BIN_DIR       = @bindir@
-TOOLS_DIR     = @libdir@$(VERSION_DIR)@slash@tools
-CUR_DIR       = .
-
-
-# Various paths
-PARROT_DYNEXT = $(LIB_DIR)/dynext
-GRAMMAR_GEN   = $(LIB_DIR)/library/PGE/Perl6Grammar.pbc
-NQP           = $(LIB_DIR)/languages/nqp/nqp.pbc
-PCT           = $(LIB_DIR)/library/PCT.pbc
-
-# Setup some commands
-PARROT        = $(BIN_DIR)/parrot$(EXE)
-CAT           = $(PERL) -MExtUtils::Command -e cat
-MKDIR         = $(PERL) -MExtUtils::Command -e mkpath
-PBC_TO_EXE    = $(BIN_DIR)/pbc_to_exe$(EXE)
-
-SOURCES = pynie.pir \
-  include/gen_grammar.pir \
-  include/gen_actions.pir \
-  include/gen_builtins.pir \
-  src/parser/indent.pir \
-
-
-BUILTINS_PIR = \
-  src/builtins/funcs.pir \
-  src/builtins/io.pir \
-  src/builtins/lists.pir \
-  src/builtins/oper.pir
-
-
-CLEANUPS = \
-  pynie.pbc \
-  pynie$(EXE) \
-  *.c \
-  *$(O) \
-  include/gen_*.pir \
-  installable_pynie$(EXE)
-
-
-# the default target
-build: pynie.pbc
-
-all: build installable
-
-##  targets for building a standalone pynie.
-pynie$(EXE): pynie.pbc
-	$(PBC_TO_EXE) pynie.pbc
-
-# the Pynie compiler
-pynie.pbc: $(SOURCES) $(BUILTINS_PIR)
-	$(PARROT) $(PARROT_ARGS) -o pynie.pbc pynie.pir
-
-include:
-	if [ ! -d include ] ; then \
-	    $(MKDIR) include; \
-	fi
-
-include/gen_grammar.pir: include Grammar/Grammar.pg
-	$(PARROT) $(PARROT_ARGS) $(GRAMMAR_GEN) \
-	    --output=include/gen_grammar.pir Grammar/Grammar.pg
-
-include/gen_actions.pir: include Grammar/Actions.nqp
-	$(PARROT) $(PARROT_ARGS) $(NQP) --output=include/gen_actions.pir \
-	    --encoding=fixed_8 --target=pir Grammar/Actions.nqp
-
-include/gen_builtins.pir: include $(BUILTINS_PIR)
-	$(CAT) $(BUILTINS_PIR) > include/gen_builtins.pir
-
-installable: installable_pynie$(EXE)
- 
-installable_pynie$(EXE): pynie.pbc
-	$(PBC_TO_EXE) pynie.pbc --install
-
-##  testing targets
-test    : build
-	python runtests.py
-
-# basic run for missing libs
-test-installable: installable
-	echo "1" | ./installable_pynie$(EXE)
-
-install: installable
-	$(CP) installable_pynie$(EXE) $(BIN_DIR)/pynie$(EXE)
-	$(CHMOD) 0755 $(BIN_DIR)/pynie$(EXE)
-	-$(MKPATH) $(LIB_DIR)/languages/pynie
-	$(CP) pynie.pbc $(LIB_DIR)/languages/pynie/pynie.pbc
-#	-$(MKPATH) $(MANDIR)/man1
-#	$(POD2MAN) doc/running.pod > $(MANDIR)/man1/parrot-pynie.1
-	-$(MKPATH) $(DOC_DIR)/pynie
-	$(CP) $(DOCS) $(DOC_DIR)/pynie
-
-##  cleaning
-clean:
-	$(RM_F) $(CLEANUPS)
-
-distclean: realclean
-
-realclean: clean testclean
-	$(RM_F) Makefile
-
-testclean:
-#	$(RM_F) $(TEST_CLEANUPS)
-
-
-release : MANIFEST
-	[ -d pynie-$(VERSION) ] || ln -s $(CUR_DIR) pynie-$(VERSION)
-	$(PERL) -lane 'print"pynie-$(VERSION)/$$F[0]"unless!length||/#/' MANIFEST | \
-              tar -zcv -T - -f pynie-$(VERSION).tar.gz
-	rm pynie-$(VERSION)
-
-
-
-# a listing of all targets meant to be called by users
-help:
-	@echo ""
-	@echo "Following targets are available for the user:"
-	@echo ""
-	@echo "  build:             pynie.pbc and pynie$(EXE) executable"
-	@echo "                     This is the default."
-	@echo "  all:               pynie executable and 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 ""
-	@echo "Cleaning:"
-	@echo "  clean:             Basic cleaning up."
-	@echo "  distclean:         Removes also anything built, in theory."
-	@echo "  realclean:         Removes also files generated by configuration."
-	@echo "  testclean:         Clean up test results."
-	@echo ""
-	@echo "Misc:"
-	@echo "  help:              Print this help message."
-	@echo ""
 Once you have checked out a copy of pynie, build it as follows:
 
   $ cd pynie
-  $ .configure
-  $ make
-  
+  $ setup.py build
 
-This will create a "pynie" or "pynie.exe" executable in the
-current directory.   Pynie doesn't currently have a "make install"
+This will create a "pynie.pbc" parrot bytecode executable in the
+current directory.   Pynie doesn't currently have a "install"
 target.
 
 To invoke pynie on a Python program from a shell prompt, use:
 
 To run pynie's test suite:
 
-  $ make test
+  $ setup.py test
 
 To display the parse tree, add the "--target=parse" option:
 
 
 The other files needed for the compiler are in the F<src/> subdirectory.
 
-The F<src/parser/grammar.pg> file defines the tokens, rules,
+The F<Grammar/Grammar.pg> file defines the tokens, rules,
 and protos for Python.  Much of this has been taken from
 the "Python Language Reference Manual (release 2.3)" by
 Guido van Rossum (Fred L. Drake, Jr., editor).  PGE's "Perl6Grammar.pbc"
 compiler is then used to compile the two grammar files into
-F<src/parser/gen_grammar.pir>, which is included by F<pynie.pir>.
+F<include/gen_grammar.pir>, which is included by F<pynie.pir>.
 (See Synopsis 5 for more details on Perl 6 rules syntax,
 and F<compilers/pge/> for more details about PGE.)
 
 rules needed to support parsing that are better written
 directly in PIR instead of using the rules or token syntax.
 
-The file F<src/parser/actions.pm> defines the actions that are
+The file F<Grammar/Actions.nqp> defines the actions that are
 invoked during the parse. These actions construct the Parrot AST
 (PAST) nodes. At the end of the parse, the whole PAST is constructed
 and handed off to the next compilation phases (PAST->POST->PIR)
 
 =head1 Submitting Bugs/Patches
 
-Patches/bugs/suggestions can be sent to <http://launchpad.net/pynie>.
+Patches/bugs/suggestions can be sent to <http://code.google.com/p/pynie/issues/list>.
 
 =head1 AUTHOR
 

File configure

-#!/bin/sh
-
-PERL=`parrot_config perl`
-LIB_DIR=`parrot_config libdir`
-VERSION_DIR=`parrot_config versiondir`
-MAKE=`parrot_config make`
-
-MAKEFILE_BUILDER="$PERL ${LIB_DIR}$VERSION_DIR/tools/dev/gen_makefile.pl"
-
-echo "Creating Makefile"
-
-`$MAKEFILE_BUILDER Makefile.in Makefile`
-
-echo "You can now use '$MAKE' to build Pynie, and '$MAKE test' to test it."
 import subunit
 import unittest
 
+from subprocess import Popen,PIPE
+
+bin_dir = Popen("parrot_config bin_dir", shell=True, stdout=PIPE).stdout.readline().rstrip()
+parrot = '%s/parrot' % (bin_dir)
+parrot.replace(r'\\', '/')
+
 class PynieParrotTests(subunit.ExecTestCase):
 
+    def __init__(self, methodName='runTest'):
+        self.command = parrot
+        subunit.ExecTestCase.__init__(self, methodName)
+
     def test_01_simplest(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/simplest.py"""
-
+        """pynie.pbc Lib/test/parrot/simplest.py"""
+        
     def test_02_literals(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/literals.py"""
+        """pynie.pbc Lib/test/parrot/literals.py"""
 
     def test_03_math_ops(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/op-math.py"""
+        """pynie.pbc Lib/test/parrot/op-math.py"""
 
     def test_04_bitwise_ops(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/op-bitwise.py"""
+        """pynie.pbc Lib/test/parrot/op-bitwise.py"""
 
     def test_05_variables(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/variables.py"""
+        """pynie.pbc Lib/test/parrot/variables.py"""
 
     def test_06_statements(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/control-flow.py"""
+        """pynie.pbc Lib/test/parrot/control-flow.py"""
 
     def test_07_compare_ops(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/op-cmp.py"""
+        """pynie.pbc Lib/test/parrot/op-cmp.py"""
 
     def test_08_lists(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/lists.py"""
+        """pynie.pbc Lib/test/parrot/lists.py"""
 
     def test_09_assign_ops(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/op-assign.py"""
+        """pynie.pbc Lib/test/parrot/op-assign.py"""
 
     def test_10_logic_ops(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/op-boolean.py"""
+        """pynie.pbc Lib/test/parrot/op-boolean.py"""
 
     def test_11_functions(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/functions.py"""
+        """pynie.pbc Lib/test/parrot/functions.py"""
 
     def test_12_builtins(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/builtins.py"""
+        """pynie.pbc Lib/test/parrot/builtins.py"""
 
     def test_13_exceptions(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/exceptions.py"""
+        """pynie.pbc Lib/test/parrot/exceptions.py"""
 
     def test_math_ops_compare(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/op-math-compare.py"""
+        """pynie.pbc Lib/test/parrot/op-math-compare.py"""
 
     def test_logic_ops_compare(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/op-logic-compare.py"""
+        """pynie.pbc Lib/test/parrot/op-logic-compare.py"""
 
     def test_grammar(self):
-        """/usr/bin/parrot pynie.pbc Lib/test/parrot/grammar.py"""
+        """pynie.pbc Lib/test/parrot/grammar.py"""
 
 
 if __name__ == '__main__':
+#!/usr/bin/env python
+
+from distutils.core import setup
+from distutils.command.build import build
+from distutils.dep_util import newer_group, newer
+from distutils.spawn import spawn
+from subprocess import Popen,PIPE
+from re import compile
+from fileinput import input
+from os import mkdir, remove
+from os.path import exists
+from sys import executable
+
+pc_raw = Popen("parrot_config --dump", shell=True, stdout=PIPE).stdout.readlines()
+if not pc_raw:
+    print "\nplease check parrot_config is in your PATH!"
+    exit(1)
+    
+pc = {}
+rx = compile("(.*) => '(.*)'")
+
+for l in pc_raw:
+    m = rx.match(l)
+    if m:
+        pc[m.group(1)] = m.group(2)
+        
+
+PARROT        = "%s/parrot%s" % (pc['bin_dir'], pc['exe'])
+GRAMMAR_GEN   = "%s/parrot/library/PGE/Perl6Grammar.pbc" % pc['lib_dir']
+NQP           = "%s/parrot/languages/nqp/nqp.pbc" % pc['lib_dir']
+PCT           = "%s/library/PCT.pbc" % pc['lib_dir']
+
+GEN_SOURCES = [
+  'include/gen_grammar.pir',
+  'include/gen_actions.pir',
+  'include/gen_builtins.pir',
+]
+
+SOURCES = GEN_SOURCES + [ 'pynie.pir',
+  'src/parser/indent.pir' ]
+
+BUILTINS_PIR = [
+  'src/builtins/funcs.pir', 
+  'src/builtins/io.pir', 
+  'src/builtins/lists.pir', 
+  'src/builtins/oper.pir' ]
+
+CLEANUPS = GEN_SOURCES + [
+  'pynie.pbc',
+  'pynie%s' % pc['exe'],
+  'installable_pynie%s' % pc['exe'] ]
+  
+def real_build():
+    if not exists('include'):
+        mkdir('include')
+        
+    if newer_group(BUILTINS_PIR, 'include/gen_builtins.pir'):
+        f = open('include/gen_builtins.pir', 'w')
+        for l in input(BUILTINS_PIR): f.write(l)
+        f.close()
+
+    if newer('Grammar/Grammar.pg', 'include/gen_grammar.pir'):
+        spawn([PARROT, GRAMMAR_GEN, '--output=include/gen_grammar.pir', 'Grammar/Grammar.pg'])
+
+    if newer('Grammar/Actions.nqp','include/gen_actions.pir'):
+        spawn([PARROT, NQP, '--output=include/gen_actions.pir', '--encoding=fixed_8', '--target=pir', 'Grammar/Actions.nqp'])
+    
+    if newer_group(SOURCES + BUILTINS_PIR, 'pynie.pbc'):
+        spawn([PARROT, '-o', 'pynie.pbc', 'pynie.pir'])    
+  
+class build_pynie(build):
+    def run(self):
+        real_build()
+        build.run(self)
+
+class test_pynie(build):
+    def run(self):
+        real_build()
+        spawn([executable, 'runtests.py'])
+        build.run(self)
+        
+class clean_pynie(build):
+    def run(self):
+        [remove(f) for f in CLEANUPS if exists(f)]
+        build.run(self)
+        
+
+class help_pynie(build):
+    def run(self):
+        print """
+            Following targets are available for the user:
+
+              build:             pynie.pbc and pynie$(EXE) executable
+                                 This is the default.
+
+              test:              Run the test suite.
+
+              clean:             Basic cleaning up.
+
+              help:              Print this help message.        
+        """
+
+setup(name='Pynie',
+      version='0.1',
+      description='Pynie - Python on Parrot',
+      url='http://code.google.com/p/pynie/',
+      cmdclass = {
+            'build': build_pynie,
+            'clean': clean_pynie,
+            'test':  test_pynie,
+            'help':  help_pynie,
+      }
+)
+
+    

File subunit/__init__.py

         """
         unittest.TestCase.__init__(self, methodName)
         testMethod = getattr(self, methodName)
-        self.script = join_dir(sys.modules[self.__class__.__module__].__file__,
+        if self.command:
+            self.script = "%s %s" % (self.command, testMethod.__doc__)
+        elif hasattr(sys.modules[self.__class__.__module__], "__file__"):
+            self.script = join_dir(sys.modules[self.__class__.__module__].__file__,
                                testMethod.__doc__)
+        else:
+            self.script = testMethod.__doc__
+        #print "using script %s" % self.script
 
     def countTestCases(self):
         return 1