# New Ticket Created by  Matt Fowles 
# Please include the string:  [perl #31285]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=31285 >


All~

This patch is an early step in getting a scons based build system for
parrot.  Currently, it leaves the make system in place, the goal being
to add a SCons system alongside the make system until the scons one is
entirely ready.

This patch allows scons to build foo.c and foo.dump files from
foo.pmc.  It will automatically detect dependencies between various
PMC's and rebuild them as appropriate.

Obviously this requires SCons to be installed on the system (and SCons
requires Python).  But since parrot can be built without it, I figured
that this was a non-issue.

If any one has a burning itch to implement other parts of this system,
feel free to email me so we can collaborate.

Have fun,
Matt
-- 
"Computer Science is merely the post-Turing Decline of Formal Systems Theory."
-???
--- /dev/null	2004-08-11 14:33:25.000000000 -0400
+++ SConstruct	2004-08-22 19:30:44.000000000 -0400
@@ -0,0 +1,2 @@
+SConscript([	'build_tools/scons_tools/pmcEnv.py',
+		'classes/SConscript'])
--- /dev/null	2004-08-11 14:33:25.000000000 -0400
+++ classes/SConscript	2004-08-22 19:29:51.000000000 -0400
@@ -0,0 +1,24 @@
+import re
+
+Import('pmcEnv')
+
+env = pmcEnv.Copy()
+
+pmc_re = re.compile(r'\.pmc$')
+
+local = Dir('.')
+pmcs = filter( lambda(x): pmc_re.search(x), map(str, local.all_children()))
+
+for p in pmcs:
+    dump = env.Dump(p)
+    c = env.PMC(p)
+    env.Depends(dump, p)
+    env.Depends(c, dump)
+    env.Depends(c, p)
+
+
+# Tell Emacs that this is python 
+# Local Variables:
+# mode:python
+# End:
+
Index: MANIFEST
RCS file: /cvs/public/parrot/MANIFEST,v
retrieving revision 1.722
diff -u -r1.722 MANIFEST
--- MANIFEST	20 Aug 2004 17:09:50 -0000	1.722
+++ MANIFEST	22 Aug 2004 23:52:04 -0000
@@ -18,6 +18,7 @@
 README.win32                                      [main]doc
 RELEASE_INSTRUCTIONS                              []
 RESPONSIBLE_PARTIES                               [main]doc
+SConstruct                                        []
 TODO                                              [main]doc
 TODO.win32                                        [main]doc
 VERSION                                           [main]doc
@@ -38,7 +39,9 @@
 build_tools/ops2c.pl                              [devel]
 build_tools/ops2pm.pl                             [devel]
 build_tools/pbc2c.pl                              [devel]
+build_tools/scons_tools/pmcEnv.py                 []
 build_tools/vtable_h.pl                           []
+classes/SConscript                                []
 classes/array.pmc                                 []
 classes/bigint.pmc                                []
 classes/boolean.pmc                               []
--- /dev/null	2004-08-11 14:33:25.000000000 -0400
+++ build_tools/scons_tools/pmcEnv.py	2004-08-22 20:13:23.000000000 -0400
@@ -0,0 +1,33 @@
+import re
+import string
+
+pmcEnv = Environment()
+
+bldDump = Builder(  action = 'perl classes/pmc2c2.pl --dump $SOURCE',
+		    suffix = '.dump',
+		    src_suffix = '.pmc')
+
+bldC = Builder(   action = 'perl classes/pmc2c2.pl --c --no-lines $SOURCE',
+		  suffix = '.c',
+		  src_suffix = '.pmc')
+
+pmc_re = re.compile(r'\.pmc$')
+extends_re = re.compile(r'pmclass.*extends\s+(\w+)')
+    
+
+def PMC_scan(node, env, path):
+    contents = node.get_contents()
+    deps = map(lambda(x): string.lower(x)+".pmc", extends_re.findall(contents))
+    if(deps == [] and str(node) != "classes/default.pmc"):
+	deps = ["default.pmc"] + deps
+    deps += map(lambda(x): pmc_re.sub(".dump",x), deps)
+    #print str(node), " - ", deps
+    return deps
+
+pmcScanner = Scanner(function = PMC_scan, skeys = ['.pmc'])
+
+pmcEnv.Append(SCANNERS = pmcScanner)
+pmcEnv.Append( BUILDERS = {'Dump' : bldDump } )
+pmcEnv.Append( BUILDERS = {'PMC' : bldC } )
+
+Export('pmcEnv')

Reply via email to