From aa8bcd15ec1ba916f3e750f41697a65e06b3c2ac Mon Sep 17 00:00:00 2001 From: Jason Power Date: Wed, 12 Sep 2012 14:52:04 -0500 Subject: Ruby: Modify Scons so that we can put .sm files in extras Also allows for header files which are required in slicc generated code to be in a directory other than src/mem/ruby/slicc_interface. --- src/mem/protocol/SConscript | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src/mem/protocol/SConscript') diff --git a/src/mem/protocol/SConscript b/src/mem/protocol/SConscript index 9ef38d289..0eccdf3e5 100644 --- a/src/mem/protocol/SConscript +++ b/src/mem/protocol/SConscript @@ -41,7 +41,7 @@ Import('*') if env['PROTOCOL'] == 'None': Return() -protocol_dir = Dir('.') +output_dir = Dir('.') html_dir = Dir('html') slicc_dir = Dir('../slicc') @@ -57,7 +57,7 @@ for root,dirs,files in os.walk(slicc_dir.srcnode().abspath): # # Use SLICC # -env['SLICC_PATH'] = str(protocol_dir) +env["SLICC_PATH"] = protocol_dirs slicc_scanner = Classic("SliccScanner", ['.sm', '.slicc'], "SLICC_PATH", r'''include[ \t]["'](.*)["'];''') env.Append(SCANNERS=slicc_scanner) @@ -66,22 +66,22 @@ def slicc_emitter(target, source, env): assert len(source) == 1 filepath = source[0].srcnode().abspath - slicc = SLICC(filepath, verbose=False) + slicc = SLICC(filepath, protocol_base.abspath, verbose=False) slicc.process() - slicc.writeCodeFiles(protocol_dir.abspath) + slicc.writeCodeFiles(output_dir.abspath, slicc_includes) if env['SLICC_HTML']: slicc.writeHTMLFiles(html_dir.abspath) - target.extend([protocol_dir.File(f) for f in sorted(slicc.files())]) + target.extend([output_dir.File(f) for f in sorted(slicc.files())]) return target, source def slicc_action(target, source, env): assert len(source) == 1 filepath = source[0].srcnode().abspath - slicc = SLICC(filepath, verbose=True) + slicc = SLICC(filepath, protocol_base.abspath, verbose=True) slicc.process() - slicc.writeCodeFiles(protocol_dir.abspath) + slicc.writeCodeFiles(output_dir.abspath, slicc_includes) if env['SLICC_HTML']: slicc.writeHTMLFiles(html_dir.abspath) @@ -89,6 +89,15 @@ slicc_builder = Builder(action=MakeAction(slicc_action, Transform("SLICC")), emitter=slicc_emitter) protocol = env['PROTOCOL'] +protocol_dir = None +for path in protocol_dirs: + if os.path.exists(os.path.join(path, "%s.slicc" % protocol)): + protocol_dir = Dir(path) + break + +if not protocol_dir: + raise ValueError, "Could not find %s.slicc in protocol_dirs" % protocol + sources = [ protocol_dir.File("%s.slicc" % protocol) ] env.Append(BUILDERS={'SLICC' : slicc_builder}) -- cgit v1.2.3