From cf05fa476df711f64d0481117cf075ce68676d57 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Fri, 11 Mar 2005 18:28:38 -0500 Subject: [PATCH] stick all python stuff into a top level python directory. create an m5 package in python/m5 move the objects package into the m5 package move the m5config into the m5 package as config leave both importers outside of the package. SConscript: sim/main.cc: move sim/pyconfig/* -> python python/SConscript: m5config.py -> m5/config.py (now automatically embedded) objects -> python/m5/objects embed all python files in python/m5 python/m5/config.py: importer renamed mpy_importer move code to m5/__init__.py test/genini.py: deal with new python organization keep track of paths we want to add and add them after parameters are parsed. --HG-- rename : sim/pyconfig/SConscript => python/SConscript rename : sim/pyconfig/m5config.py => python/m5/config.py rename : objects/AlphaConsole.mpy => python/m5/objects/AlphaConsole.mpy rename : objects/AlphaTLB.mpy => python/m5/objects/AlphaTLB.mpy rename : objects/BadDevice.mpy => python/m5/objects/BadDevice.mpy rename : objects/BaseCPU.mpy => python/m5/objects/BaseCPU.mpy rename : objects/BaseCache.mpy => python/m5/objects/BaseCache.mpy rename : objects/BaseSystem.mpy => python/m5/objects/BaseSystem.mpy rename : objects/Bus.mpy => python/m5/objects/Bus.mpy rename : objects/CoherenceProtocol.mpy => python/m5/objects/CoherenceProtocol.mpy rename : objects/Device.mpy => python/m5/objects/Device.mpy rename : objects/DiskImage.mpy => python/m5/objects/DiskImage.mpy rename : objects/Ethernet.mpy => python/m5/objects/Ethernet.mpy rename : objects/Ide.mpy => python/m5/objects/Ide.mpy rename : objects/IntrControl.mpy => python/m5/objects/IntrControl.mpy rename : objects/MemTest.mpy => python/m5/objects/MemTest.mpy rename : objects/Pci.mpy => python/m5/objects/Pci.mpy rename : objects/PhysicalMemory.mpy => python/m5/objects/PhysicalMemory.mpy rename : objects/Platform.mpy => python/m5/objects/Platform.mpy rename : objects/Process.mpy => python/m5/objects/Process.mpy rename : objects/Repl.mpy => python/m5/objects/Repl.mpy rename : objects/Root.mpy => python/m5/objects/Root.mpy rename : objects/SimConsole.mpy => python/m5/objects/SimConsole.mpy rename : objects/SimpleDisk.mpy => python/m5/objects/SimpleDisk.mpy rename : objects/Tsunami.mpy => python/m5/objects/Tsunami.mpy rename : objects/Uart.mpy => python/m5/objects/Uart.mpy extra : convert_revision : aebf6ccda33028b1125974ca8b6aeab6f7570f30 --- SConscript | 7 ++++--- {sim/pyconfig => python}/SConscript | 4 ++-- python/m5/__init__.py | 7 +++++++ sim/pyconfig/m5config.py => python/m5/config.py | 5 +---- {objects => python/m5/objects}/AlphaConsole.mpy | 0 {objects => python/m5/objects}/AlphaTLB.mpy | 0 {objects => python/m5/objects}/BadDevice.mpy | 0 {objects => python/m5/objects}/BaseCPU.mpy | 0 {objects => python/m5/objects}/BaseCache.mpy | 0 {objects => python/m5/objects}/BaseSystem.mpy | 0 {objects => python/m5/objects}/Bus.mpy | 0 .../m5/objects}/CoherenceProtocol.mpy | 0 {objects => python/m5/objects}/Device.mpy | 0 {objects => python/m5/objects}/DiskImage.mpy | 0 {objects => python/m5/objects}/Ethernet.mpy | 0 {objects => python/m5/objects}/Ide.mpy | 0 {objects => python/m5/objects}/IntrControl.mpy | 0 {objects => python/m5/objects}/MemTest.mpy | 0 {objects => python/m5/objects}/Pci.mpy | 0 {objects => python/m5/objects}/PhysicalMemory.mpy | 0 {objects => python/m5/objects}/Platform.mpy | 0 {objects => python/m5/objects}/Process.mpy | 0 {objects => python/m5/objects}/Repl.mpy | 0 {objects => python/m5/objects}/Root.mpy | 0 {objects => python/m5/objects}/SimConsole.mpy | 0 {objects => python/m5/objects}/SimpleDisk.mpy | 0 {objects => python/m5/objects}/Tsunami.mpy | 0 {objects => python/m5/objects}/Uart.mpy | 0 sim/main.cc | 2 +- test/genini.py | 13 +++++++------ 30 files changed, 22 insertions(+), 16 deletions(-) rename {sim/pyconfig => python}/SConscript (98%) create mode 100644 python/m5/__init__.py rename sim/pyconfig/m5config.py => python/m5/config.py (99%) rename {objects => python/m5/objects}/AlphaConsole.mpy (100%) rename {objects => python/m5/objects}/AlphaTLB.mpy (100%) rename {objects => python/m5/objects}/BadDevice.mpy (100%) rename {objects => python/m5/objects}/BaseCPU.mpy (100%) rename {objects => python/m5/objects}/BaseCache.mpy (100%) rename {objects => python/m5/objects}/BaseSystem.mpy (100%) rename {objects => python/m5/objects}/Bus.mpy (100%) rename {objects => python/m5/objects}/CoherenceProtocol.mpy (100%) rename {objects => python/m5/objects}/Device.mpy (100%) rename {objects => python/m5/objects}/DiskImage.mpy (100%) rename {objects => python/m5/objects}/Ethernet.mpy (100%) rename {objects => python/m5/objects}/Ide.mpy (100%) rename {objects => python/m5/objects}/IntrControl.mpy (100%) rename {objects => python/m5/objects}/MemTest.mpy (100%) rename {objects => python/m5/objects}/Pci.mpy (100%) rename {objects => python/m5/objects}/PhysicalMemory.mpy (100%) rename {objects => python/m5/objects}/Platform.mpy (100%) rename {objects => python/m5/objects}/Process.mpy (100%) rename {objects => python/m5/objects}/Repl.mpy (100%) rename {objects => python/m5/objects}/Root.mpy (100%) rename {objects => python/m5/objects}/SimConsole.mpy (100%) rename {objects => python/m5/objects}/SimpleDisk.mpy (100%) rename {objects => python/m5/objects}/Tsunami.mpy (100%) rename {objects => python/m5/objects}/Uart.mpy (100%) diff --git a/SConscript b/SConscript index 19f84f913..cff240a69 100644 --- a/SConscript +++ b/SConscript @@ -183,6 +183,9 @@ base_sources = Split(''' mem/trace/mem_trace_writer.cc mem/trace/m5_writer.cc + python/pyconfig.cc + python/embedded_py.cc + sim/builder.cc sim/configfile.cc sim/debug.cc @@ -199,8 +202,6 @@ base_sources = Split(''' sim/stat_control.cc sim/trace_context.cc sim/universe.cc - sim/pyconfig/pyconfig.cc - sim/pyconfig/embedded_py.cc ''') # MySql sources @@ -376,7 +377,7 @@ env.Command(Split('''arch/alpha/decoder.cc # SConscript-local is the per-config build, which just copies some # header files into a place where they can be found. SConscript('libelf/SConscript-local', exports = 'env', duplicate=0) -SConscript('sim/pyconfig/SConscript', exports = ['env'], duplicate=0) +SConscript('python/SConscript', exports = ['env'], duplicate=0) # This function adds the specified sources to the given build diff --git a/sim/pyconfig/SConscript b/python/SConscript similarity index 98% rename from sim/pyconfig/SConscript rename to python/SConscript index 2799ef64f..81bc52286 100644 --- a/sim/pyconfig/SConscript +++ b/python/SConscript @@ -193,8 +193,8 @@ EmbedMap %(name)s("%(fname)s", /* namespace */ } ''' -embedded_py_files = ['m5config.py', 'importer.py', '../../util/pbs/jobfile.py'] -objpath = os.path.join(env['SRCDIR'], 'objects') +embedded_py_files = [ 'mpy_importer.py', '../util/pbs/jobfile.py' ] +objpath = os.path.join(env['SRCDIR'], 'python/m5') for root, dirs, files in os.walk(objpath, topdown=True): for i,dir in enumerate(dirs): if dir == 'SCCS': diff --git a/python/m5/__init__.py b/python/m5/__init__.py new file mode 100644 index 000000000..7cb3a32c6 --- /dev/null +++ b/python/m5/__init__.py @@ -0,0 +1,7 @@ +from mpy_importer import * +from config import * +from objects import * + +cpp_classes = MetaSimObject.cpp_classes +cpp_classes.sort() + diff --git a/sim/pyconfig/m5config.py b/python/m5/config.py similarity index 99% rename from sim/pyconfig/m5config.py rename to python/m5/config.py index e6201b3ad..b39a8b9a6 100644 --- a/sim/pyconfig/m5config.py +++ b/python/m5/config.py @@ -27,7 +27,7 @@ from __future__ import generators import os, re, sys, types, inspect -from importer import AddToPath, LoadMpyFile +from mpy_importer import AddToPath, LoadMpyFile noDot = False try: @@ -1298,6 +1298,3 @@ class SimObject(ConfigNode): type = 'SimObject' from objects import * - -cpp_classes = MetaSimObject.cpp_classes -cpp_classes.sort() diff --git a/objects/AlphaConsole.mpy b/python/m5/objects/AlphaConsole.mpy similarity index 100% rename from objects/AlphaConsole.mpy rename to python/m5/objects/AlphaConsole.mpy diff --git a/objects/AlphaTLB.mpy b/python/m5/objects/AlphaTLB.mpy similarity index 100% rename from objects/AlphaTLB.mpy rename to python/m5/objects/AlphaTLB.mpy diff --git a/objects/BadDevice.mpy b/python/m5/objects/BadDevice.mpy similarity index 100% rename from objects/BadDevice.mpy rename to python/m5/objects/BadDevice.mpy diff --git a/objects/BaseCPU.mpy b/python/m5/objects/BaseCPU.mpy similarity index 100% rename from objects/BaseCPU.mpy rename to python/m5/objects/BaseCPU.mpy diff --git a/objects/BaseCache.mpy b/python/m5/objects/BaseCache.mpy similarity index 100% rename from objects/BaseCache.mpy rename to python/m5/objects/BaseCache.mpy diff --git a/objects/BaseSystem.mpy b/python/m5/objects/BaseSystem.mpy similarity index 100% rename from objects/BaseSystem.mpy rename to python/m5/objects/BaseSystem.mpy diff --git a/objects/Bus.mpy b/python/m5/objects/Bus.mpy similarity index 100% rename from objects/Bus.mpy rename to python/m5/objects/Bus.mpy diff --git a/objects/CoherenceProtocol.mpy b/python/m5/objects/CoherenceProtocol.mpy similarity index 100% rename from objects/CoherenceProtocol.mpy rename to python/m5/objects/CoherenceProtocol.mpy diff --git a/objects/Device.mpy b/python/m5/objects/Device.mpy similarity index 100% rename from objects/Device.mpy rename to python/m5/objects/Device.mpy diff --git a/objects/DiskImage.mpy b/python/m5/objects/DiskImage.mpy similarity index 100% rename from objects/DiskImage.mpy rename to python/m5/objects/DiskImage.mpy diff --git a/objects/Ethernet.mpy b/python/m5/objects/Ethernet.mpy similarity index 100% rename from objects/Ethernet.mpy rename to python/m5/objects/Ethernet.mpy diff --git a/objects/Ide.mpy b/python/m5/objects/Ide.mpy similarity index 100% rename from objects/Ide.mpy rename to python/m5/objects/Ide.mpy diff --git a/objects/IntrControl.mpy b/python/m5/objects/IntrControl.mpy similarity index 100% rename from objects/IntrControl.mpy rename to python/m5/objects/IntrControl.mpy diff --git a/objects/MemTest.mpy b/python/m5/objects/MemTest.mpy similarity index 100% rename from objects/MemTest.mpy rename to python/m5/objects/MemTest.mpy diff --git a/objects/Pci.mpy b/python/m5/objects/Pci.mpy similarity index 100% rename from objects/Pci.mpy rename to python/m5/objects/Pci.mpy diff --git a/objects/PhysicalMemory.mpy b/python/m5/objects/PhysicalMemory.mpy similarity index 100% rename from objects/PhysicalMemory.mpy rename to python/m5/objects/PhysicalMemory.mpy diff --git a/objects/Platform.mpy b/python/m5/objects/Platform.mpy similarity index 100% rename from objects/Platform.mpy rename to python/m5/objects/Platform.mpy diff --git a/objects/Process.mpy b/python/m5/objects/Process.mpy similarity index 100% rename from objects/Process.mpy rename to python/m5/objects/Process.mpy diff --git a/objects/Repl.mpy b/python/m5/objects/Repl.mpy similarity index 100% rename from objects/Repl.mpy rename to python/m5/objects/Repl.mpy diff --git a/objects/Root.mpy b/python/m5/objects/Root.mpy similarity index 100% rename from objects/Root.mpy rename to python/m5/objects/Root.mpy diff --git a/objects/SimConsole.mpy b/python/m5/objects/SimConsole.mpy similarity index 100% rename from objects/SimConsole.mpy rename to python/m5/objects/SimConsole.mpy diff --git a/objects/SimpleDisk.mpy b/python/m5/objects/SimpleDisk.mpy similarity index 100% rename from objects/SimpleDisk.mpy rename to python/m5/objects/SimpleDisk.mpy diff --git a/objects/Tsunami.mpy b/python/m5/objects/Tsunami.mpy similarity index 100% rename from objects/Tsunami.mpy rename to python/m5/objects/Tsunami.mpy diff --git a/objects/Uart.mpy b/python/m5/objects/Uart.mpy similarity index 100% rename from objects/Uart.mpy rename to python/m5/objects/Uart.mpy diff --git a/sim/main.cc b/sim/main.cc index c15d24453..ee59cb83b 100644 --- a/sim/main.cc +++ b/sim/main.cc @@ -51,6 +51,7 @@ #include "base/time.hh" #include "cpu/base_cpu.hh" #include "cpu/full_cpu/smt.hh" +#include "python/pyconfig.hh" #include "sim/async.hh" #include "sim/builder.hh" #include "sim/configfile.hh" @@ -61,7 +62,6 @@ #include "sim/stat_control.hh" #include "sim/stats.hh" #include "sim/universe.hh" -#include "sim/pyconfig/pyconfig.hh" using namespace std; diff --git a/test/genini.py b/test/genini.py index f4d1575db..025ba998a 100755 --- a/test/genini.py +++ b/test/genini.py @@ -30,12 +30,10 @@ from os.path import join as joinpath, realpath mypath = sys.path[0] sys.path.append(joinpath(mypath, '..')) +sys.path.append(joinpath(mypath, '../python')) sys.path.append(joinpath(mypath, '../util/pbs')) -sys.path.append(joinpath(mypath, '../sim/pyconfig')) -from importer import AddToPath, LoadMpyFile - -AddToPath('.') +pathlist = [ '.' ] try: opts, args = getopt.getopt(sys.argv[1:], '-E:I:') @@ -50,11 +48,14 @@ try: value = arg[offset+1:] os.environ[name] = value if opt == '-I': - AddToPath(arg) + pathlist.append(arg) except getopt.GetoptError: sys.exit('Improper Usage') -from m5config import * +from m5 import * + +for path in pathlist: + AddToPath(path) for arg in args: LoadMpyFile(arg)