Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/49396 )
Change subject: python,util,scons: Move grammar.py and code_formatter.py
into util.
......................................................................
python,util,scons: Move grammar.py and code_formatter.py into util.
These are only used in a build, and so don't need to be built into gem5.
grammar.py is used by slicc and the fast model project file parser, and
code_formatter.py is only used by SConscripts.
Change-Id: Id43e62459d69f07fdb2ed125548a83e38bbb7590
---
M SConstruct
M site_scons/gem5_scons/builders/blob.py
M src/SConscript
M src/arch/arm/fastmodel/SConscript
M src/arch/isa_parser/isa_parser.py
M src/python/SConscript
M src/python/m5/util/__init__.py
R util/bld/code_formatter.py
R util/bld/grammar.py
M util/slicc
M util/slicclib/slicc/generate/dot.py
M util/slicclib/slicc/generate/html.py
M util/slicclib/slicc/generate/tex.py
M util/slicclib/slicc/parser.py
14 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/SConstruct b/SConstruct
index 79c8708..7e06e68 100755
--- a/SConstruct
+++ b/SConstruct
@@ -124,6 +124,9 @@
AddOption('--with-systemc-tests', action='store_true',
help='Build systemc tests')
+# Inject the util/bld directory into the python path.
+sys.path[1:1] = [ Dir('#util').Dir('bld').abspath ]
+
# Imports of gem5_scons happen here since it depends on some options which
are
# declared above.
from gem5_scons import error, warning, summarize_warnings, parse_build_path
diff --git a/site_scons/gem5_scons/builders/blob.py
b/site_scons/gem5_scons/builders/blob.py
index b36c683..fe74fcd 100644
--- a/site_scons/gem5_scons/builders/blob.py
+++ b/site_scons/gem5_scons/builders/blob.py
@@ -42,7 +42,7 @@
from gem5_scons import Transform, MakeAction
from gem5_scons.util import bytesToCppArray
-from m5.util import code_formatter
+from code_formatter import code_formatter
import SCons.Node.Python
diff --git a/src/SConscript b/src/SConscript
index b2b19ce..1ef6c47 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -67,7 +67,7 @@
build_env = [(opt, env[opt]) for opt in export_vars]
-from m5.util import code_formatter
+from code_formatter import code_formatter
def GdbXml(xml_id, symbol):
cc, hh = env.Blob(symbol, xml_id)
diff --git a/src/arch/arm/fastmodel/SConscript
b/src/arch/arm/fastmodel/SConscript
index 257c001..c3c121e 100644
--- a/src/arch/arm/fastmodel/SConscript
+++ b/src/arch/arm/fastmodel/SConscript
@@ -40,7 +40,7 @@
Import('*')
-from m5.util.grammar import Grammar
+from grammar import Grammar
from gem5_scons import Transform, warning, error
diff --git a/src/arch/isa_parser/isa_parser.py
b/src/arch/isa_parser/isa_parser.py
index 02102bd..a66059c 100755
--- a/src/arch/isa_parser/isa_parser.py
+++ b/src/arch/isa_parser/isa_parser.py
@@ -44,7 +44,7 @@
# get type names
from types import *
-from m5.util.grammar import Grammar
+from grammar import Grammar
from .operand_list import *
from .operand_types import *
from .util import *
diff --git a/src/python/SConscript b/src/python/SConscript
index ddca79a..8aefbb8 100644
--- a/src/python/SConscript
+++ b/src/python/SConscript
@@ -46,12 +46,10 @@
PySource('m5.stats', 'm5/stats/__init__.py')
PySource('m5.util', 'm5/util/__init__.py')
PySource('m5.util', 'm5/util/attrdict.py')
-PySource('m5.util', 'm5/util/code_formatter.py')
PySource('m5.util', 'm5/util/convert.py')
PySource('m5.util', 'm5/util/dot_writer.py')
PySource('m5.util', 'm5/util/dot_writer_ruby.py')
PySource('m5.util', 'm5/util/fdthelper.py')
-PySource('m5.util', 'm5/util/grammar.py')
PySource('m5.util', 'm5/util/multidict.py')
PySource('m5.util', 'm5/util/pybind.py')
PySource('m5.util', 'm5/util/terminal.py')
diff --git a/src/python/m5/util/__init__.py b/src/python/m5/util/__init__.py
index 833800d..a99012e 100644
--- a/src/python/m5/util/__init__.py
+++ b/src/python/m5/util/__init__.py
@@ -44,7 +44,6 @@
from . import convert
from .attrdict import attrdict, multiattrdict, optiondict
-from .code_formatter import code_formatter
from .multidict import multidict
# panic() should be called when something happens that should never
diff --git a/src/python/m5/util/code_formatter.py
b/util/bld/code_formatter.py
similarity index 100%
rename from src/python/m5/util/code_formatter.py
rename to util/bld/code_formatter.py
diff --git a/src/python/m5/util/grammar.py b/util/bld/grammar.py
similarity index 100%
rename from src/python/m5/util/grammar.py
rename to util/bld/grammar.py
diff --git a/util/slicc b/util/slicc
index c25e55e..ceab0f3 100755
--- a/util/slicc
+++ b/util/slicc
@@ -33,6 +33,7 @@
sys.path.insert(1, join(base, "../src/mem"))
sys.path.insert(1, join(base, "../src/python"))
sys.path.insert(1, join(base, "slicclib"))
+ sys.path.insert(1, join(base, "bld"))
sys.path.insert(1, join(base, "../ext/ply"))
import slicc.main
diff --git a/util/slicclib/slicc/generate/dot.py
b/util/slicclib/slicc/generate/dot.py
index 7626589..294075c 100644
--- a/util/slicclib/slicc/generate/dot.py
+++ b/util/slicclib/slicc/generate/dot.py
@@ -25,8 +25,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-from m5.util.code_formatter import code_formatter
-
def printDotty(sm, code):
code('digraph ${{sm.getIdent()}} {')
code.indent()
diff --git a/util/slicclib/slicc/generate/html.py
b/util/slicclib/slicc/generate/html.py
index c0ed368..b0bc3e9 100644
--- a/util/slicclib/slicc/generate/html.py
+++ b/util/slicclib/slicc/generate/html.py
@@ -25,7 +25,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-from m5.util.code_formatter import code_formatter
+from code_formatter import code_formatter
def createSymbol(symbol, title):
code = code_formatter()
diff --git a/util/slicclib/slicc/generate/tex.py
b/util/slicclib/slicc/generate/tex.py
index 97c63eb..176227f 100644
--- a/util/slicclib/slicc/generate/tex.py
+++ b/util/slicclib/slicc/generate/tex.py
@@ -25,7 +25,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-from m5.util.code_formatter import code_formatter
+from code_formatter import code_formatter
class tex_formatter(code_formatter):
braced = "<>"
diff --git a/util/slicclib/slicc/parser.py b/util/slicclib/slicc/parser.py
index 73ca835..cc45f95 100644
--- a/util/slicclib/slicc/parser.py
+++ b/util/slicclib/slicc/parser.py
@@ -41,8 +41,8 @@
import re
import sys
-from m5.util import code_formatter
-from m5.util.grammar import Grammar, ParseError
+from code_formatter import code_formatter
+from grammar import Grammar, ParseError
import slicc.ast as ast
import slicc.util as util
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49396
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Id43e62459d69f07fdb2ed125548a83e38bbb7590
Gerrit-Change-Number: 49396
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s