self.installed = set()
def find_module(self, fullname, path):
- if fullname == '__scons':
+ if fullname == 'defines':
return self
if fullname == 'm5.objects':
mod.__path__ = fullname.split('.')
return mod
- if fullname == '__scons':
- mod.__dict__['m5_build_env'] = build_env
+ if fullname == 'defines':
+ mod.__dict__['buildEnv'] = build_env
return mod
srcfile = self.modules[fullname]
# Commands for the basic automatically generated python files
#
+scons_dir = str(SCons.Node.FS.default_fs.SConstruct_dir)
+
+hg_info = ("Unknown", "Unknown", "Unknown")
+hg_demandimport = False
+try:
+ if not exists(scons_dir) or not isdir(scons_dir) or \
+ not exists(joinpath(scons_dir, ".hg")):
+ raise ValueError(".hg directory not found")
+
+ import mercurial.demandimport, mercurial.hg, mercurial.ui
+ import mercurial.util, mercurial.node
+ hg_demandimport = True
+
+ repo = mercurial.hg.repository(mercurial.ui.ui(), scons_dir)
+ rev = mercurial.node.nullrev + repo.changelog.count()
+ changenode = repo.changelog.node(rev)
+ changes = repo.changelog.read(changenode)
+ id = mercurial.node.hex(changenode)
+ date = mercurial.util.datestr(changes[2])
+
+ hg_info = (rev, id, date)
+except ImportError, e:
+ print "Mercurial not found"
+except ValueError, e:
+ print e
+except Exception, e:
+ print "Other mercurial exception: %s" % e
+
+if hg_demandimport:
+ mercurial.demandimport.disable()
+
# Generate Python file containing a dict specifying the current
# build_env flags.
def makeDefinesPyFile(target, source, env):
f = file(str(target[0]), 'w')
- print >>f, "m5_build_env = ", source[0]
+ build_env, hg_info = [ x.get_contents() for x in source ]
+ print >>f, "buildEnv = %s" % build_env
+ print >>f, "hgRev, hgId, hgDate = %s" % hg_info
f.close()
+defines_info = [ Value(build_env), Value(hg_info) ]
+# Generate a file with all of the compile options in it
+env.Command('python/m5/defines.py', defines_info, makeDefinesPyFile)
+PySource('m5', 'python/m5/defines.py')
+
# Generate python file containing info about the M5 source code
def makeInfoPyFile(target, source, env):
f = file(str(target[0]), 'w')
print >>f, "%s = %s" % (src, repr(data))
f.close()
+# Generate a file that wraps the basic top level files
+env.Command('python/m5/info.py',
+ [ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ],
+ makeInfoPyFile)
+PySource('m5', 'python/m5/info.py')
+
# Generate the __init__.py file for m5.objects
def makeObjectsInitFile(target, source, env):
f = file(str(target[0]), 'w')
print >>f, 'from %s import *' % module.get_contents()
f.close()
-# Generate a file with all of the compile options in it
-env.Command('python/m5/defines.py', Value(build_env), makeDefinesPyFile)
-PySource('m5', 'python/m5/defines.py')
-
-# Generate a file that wraps the basic top level files
-env.Command('python/m5/info.py',
- [ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ],
- makeInfoPyFile)
-PySource('m5', 'python/m5/info.py')
-
# Generate an __init__.py file for the objects package
env.Command('python/m5/objects/__init__.py',
[ Value(o) for o in sort_list(sim_object_modfiles) ],
env.Command('base/traceflags.cc', flags, traceFlagsCC)
Source('base/traceflags.cc')
-# Generate program_info.cc
-def programInfo(target, source, env):
- def gen_file(target, rev, node, date):
- pi_stats = file(target, 'w')
- print >>pi_stats, 'const char *hgRev = "%s:%s";' % (rev, node)
- print >>pi_stats, 'const char *hgDate = "%s";' % date
- pi_stats.close()
-
- target = str(target[0])
- scons_dir = str(source[0].get_contents())
- try:
- import mercurial.demandimport, mercurial.hg, mercurial.ui
- import mercurial.util, mercurial.node
- if not exists(scons_dir) or not isdir(scons_dir) or \
- not exists(joinpath(scons_dir, ".hg")):
- raise ValueError
- repo = mercurial.hg.repository(mercurial.ui.ui(), scons_dir)
- rev = mercurial.node.nullrev + repo.changelog.count()
- changenode = repo.changelog.node(rev)
- changes = repo.changelog.read(changenode)
- date = mercurial.util.datestr(changes[2])
-
- gen_file(target, rev, mercurial.node.hex(changenode), date)
-
- mercurial.demandimport.disable()
- except ImportError:
- gen_file(target, "Unknown", "Unknown", "Unknown")
-
- except:
- print "in except"
- gen_file(target, "Unknown", "Unknown", "Unknown")
- mercurial.demandimport.disable()
-
-env.Command('base/program_info.cc',
- Value(str(SCons.Node.FS.default_fs.SConstruct_dir)),
- programInfo)
-
# embed python files. All .py files that have been indicated by a
# PySource() call in a SConscript need to be embedded into the M5
# library. To do that, we compile the file to byte code, marshal the
# recompiled whenever anything else does
date_obj = XObject('base/date.cc')
- # Make the generation of program_info.cc dependend on all
- # the other cc files and the compiling of program_info.cc
- # dependent on all the objects but program_info.o
- pinfo_obj = XObject('base/program_info.cc')
- env.Depends('base/program_info.cc', sources)
env.Depends(date_obj, objs)
- env.Depends(pinfo_obj, objs)
- objs.extend([date_obj, pinfo_obj])
+ objs.append(date_obj)
return objs
# Function to create a new build environment as clone of current
+++ /dev/null
-/*
- * Copyright (c) 2008 The Hewlett-Packard Development Company
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met: redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer;
- * redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution;
- * neither the name of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Nathan Binkert
- * Steve Reinhardt
- */
-
-#include <string>
-#include <vector>
-
-std::vector<std::string>
-compileFlags()
-{
- static const char *flags[] = {
-#ifdef DEBUG
- "DEBUG",
-#endif
-#ifdef NDEBUG
- "NDEBUG",
-#endif
-#if TRACING_ON
- "TRACING_ON",
-#endif
- };
-
- std::vector<std::string> result;
- for (int i = 0; i < sizeof(flags) / sizeof(flags[0]); ++i)
- result.push_back(flags[i]);
-
- return result;
-}
-