scons: Work around a SCons bug in Glob.
The recent change to add an "exclude" pattern to Glob in SCons also seems to have triggered a bug where SCons has decided directories that don't exist are files, and then gets upset later when we try to treat them as directories. To avoid that bug, and to also make recursive searching for isa parser .py files work, we can replace the call to Glob with a loop based on os.walk. Also, tell the microcode assembler not to generate the parsetab.py file in the first place. This comes with a minor performance overhead, but shouldn't matter for us since there are *much* bigger overheads when processing ISA descriptions. Change-Id: Ia84e97dab72723ad3f4350798ad70178e231144c Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/56749 Maintainer: Bobby Bruce <bbruce@ucdavis.edu> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Gabe Black <gabe.black@gmail.com>
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
|
||||
from gem5_scons import Transform
|
||||
@@ -103,9 +104,12 @@ SCons.Tool.SourceFileScanner.add_scanner('.cc.inc', SCons.Tool.CScanner)
|
||||
# Now create a Builder object that uses isa_parser.py to generate C++
|
||||
# output from the ISA description (*.isa) files.
|
||||
#
|
||||
|
||||
# parsetab.py is a file generated by PLY which we don't want to add as a dep.
|
||||
parser_files = Glob('isa_parser/*.py', exclude=['*/parsetab.py'])
|
||||
parser_files = []
|
||||
for root, dirnames, filenames in os.walk(Dir("isa_parser").srcnode().abspath):
|
||||
for name in filenames:
|
||||
_, ext = os.path.splitext(name)
|
||||
if ext == '.py':
|
||||
parser_files.append(os.path.join(root, name))
|
||||
micro_asm_py = File('micro_asm.py')
|
||||
|
||||
# import ply here because SCons screws with sys.path when performing actions.
|
||||
@@ -115,7 +119,7 @@ arch_dir = Dir('.')
|
||||
|
||||
def run_parser(target, source, env):
|
||||
# Add the current directory to the system path so we can import files.
|
||||
sys.path[0:0] = [ arch_dir.abspath ]
|
||||
sys.path[0:0] = [ arch_dir.srcnode().abspath ]
|
||||
import isa_parser
|
||||
|
||||
parser = isa_parser.ISAParser(target[0].dir.abspath)
|
||||
|
||||
@@ -486,7 +486,7 @@ class MicroAssembler(object):
|
||||
def __init__(self, macro_type, microops,
|
||||
rom = None, rom_macroop_type = None):
|
||||
self.lexer = lex.lex()
|
||||
self.parser = yacc.yacc()
|
||||
self.parser = yacc.yacc(write_tables=False)
|
||||
self.parser.macro_type = macro_type
|
||||
self.parser.macroops = {}
|
||||
self.parser.microops = microops
|
||||
|
||||
Reference in New Issue
Block a user