summaryrefslogtreecommitdiff
path: root/src/mem/protocol/SConscript
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem/protocol/SConscript')
-rw-r--r--src/mem/protocol/SConscript78
1 files changed, 49 insertions, 29 deletions
diff --git a/src/mem/protocol/SConscript b/src/mem/protocol/SConscript
index 293346f13..cd9920d22 100644
--- a/src/mem/protocol/SConscript
+++ b/src/mem/protocol/SConscript
@@ -29,30 +29,51 @@
# Authors: Nathan Binkert
import os
-import re
-import string
import sys
-from os.path import basename, dirname, exists, expanduser, isdir, isfile
-from os.path import join as joinpath
-
-import SCons
+from os.path import isdir, isfile, join as joinpath
Import('*')
if not env['RUBY']:
Return()
-slicc_dir = Dir('../slicc')
protocol_dir = Dir('.')
html_dir = Dir('html')
+slicc_dir = Dir('../slicc')
+
+sys.path[1:1] = [ Dir('..').srcnode().abspath ]
+from slicc.parser import SLICC
+
+slicc_depends = []
+for root,dirs,files in os.walk(slicc_dir.srcnode().abspath):
+ for f in files:
+ if f.endswith('.py'):
+ slicc_depends.append(File(joinpath(root, f)))
#
# Use SLICC
#
-def slicc_generator(target, source, env, for_signature):
- slicc_bin = str(source[0])
- protocol = source[1].get_contents()
+
+def slicc_scanner(node, env, path):
+ contents = node.get_contents()
+ files = [ line.strip() for line in contents.splitlines() ]
+ return files
+
+env.Append(SCANNERS=Scanner(function=slicc_scanner,skeys=['.slicc']))
+
+def slicc_emitter(target, source, env):
+ files = [s.srcnode().abspath for s in source[1:]]
+ slicc = SLICC(debug=True)
+ print "SLICC parsing..."
+ for name in slicc.load(files, verbose=True):
+ print " %s" % name
+
+ target.extend(sorted(slicc.files()))
+ return target, source
+
+def slicc_action(target, source, env):
+ protocol = source[0].get_contents()
pdir = str(protocol_dir)
hdir = str(html_dir)
@@ -61,32 +82,31 @@ def slicc_generator(target, source, env, for_signature):
if not isdir(hdir):
os.mkdir(hdir)
- do_html = "html"
- cmdline = [ slicc_bin, pdir, hdir, protocol, do_html ]
- cmdline += [ str(s) for s in source[2:] ]
- cmdline = ' '.join(cmdline)
- return cmdline
+ slicc = SLICC(debug=True)
+ files = [str(s) for s in source[1:]]
+ slicc.load(files, verbose=False)
-slicc_builder = Builder(generator=slicc_generator)
+ print "SLICC Generator pass 1..."
+ slicc.findMachines()
-protocol = env['PROTOCOL']
-sources = [ protocol_dir.File("RubySlicc_interfaces.slicc"),
- protocol_dir.File("%s.slicc" % protocol) ]
+ print "SLICC Generator pass 2..."
+ slicc.generate()
-sys.path[0:0] = [env['ENV']['M5_PLY']]
-execfile(slicc_dir.File('parser/parser.py').srcnode().abspath)
+ print "SLICC writing C++ files..."
+ slicc.writeCodeFiles(pdir)
-sm_files = read_slicc([s.srcnode().abspath for s in sources])
-sm_files = [ protocol_dir.File(f) for f in sm_files ]
+ print "SLICC writing HTML files..."
+ slicc.writeHTMLFiles(hdir)
-hh, cc = scan([s.srcnode().abspath for s in sm_files])
-hh = [ protocol_dir.File(f) for f in hh ]
-cc = [ protocol_dir.File(f) for f in cc ]
+slicc_builder = Builder(action=slicc_action, emitter=slicc_emitter)
-slicc_bin = slicc_dir.File("slicc")
+protocol = env['PROTOCOL']
+sources = [ protocol_dir.File("RubySlicc_interfaces.slicc"),
+ protocol_dir.File("%s.slicc" % protocol) ]
env.Append(BUILDERS={'SLICC' : slicc_builder})
-env.SLICC(hh + cc, [ slicc_bin, Value(protocol) ] + sm_files)
+nodes = env.SLICC([], [ Value(protocol) ] + sources)
+env.Depends(nodes, slicc_depends)
-for f in cc:
+for f in sorted(s for s in nodes if str(s).endswith('.cc')):
Source(f)