SConscript (5797:0767f2b9524b) | SConscript (5798:edbf23127462) |
---|---|
1# -*- mode:python -*- 2 3# Copyright (c) 2004-2005 The Regents of The University of Michigan 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright --- 258 unchanged lines hidden (view full) --- 267 268 def unload(self): 269 import sys 270 for module in self.installed: 271 del sys.modules[module] 272 self.installed = set() 273 274 def find_module(self, fullname, path): | 1# -*- mode:python -*- 2 3# Copyright (c) 2004-2005 The Regents of The University of Michigan 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright --- 258 unchanged lines hidden (view full) --- 267 268 def unload(self): 269 import sys 270 for module in self.installed: 271 del sys.modules[module] 272 self.installed = set() 273 274 def find_module(self, fullname, path): |
275 if fullname == '__scons': | 275 if fullname == 'defines': |
276 return self 277 278 if fullname == 'm5.objects': 279 return self 280 281 if fullname.startswith('m5.internal'): 282 return None 283 --- 7 unchanged lines hidden (view full) --- 291 sys.modules[fullname] = mod 292 self.installed.add(fullname) 293 294 mod.__loader__ = self 295 if fullname == 'm5.objects': 296 mod.__path__ = fullname.split('.') 297 return mod 298 | 276 return self 277 278 if fullname == 'm5.objects': 279 return self 280 281 if fullname.startswith('m5.internal'): 282 return None 283 --- 7 unchanged lines hidden (view full) --- 291 sys.modules[fullname] = mod 292 self.installed.add(fullname) 293 294 mod.__loader__ = self 295 if fullname == 'm5.objects': 296 mod.__path__ = fullname.split('.') 297 return mod 298 |
299 if fullname == '__scons': 300 mod.__dict__['m5_build_env'] = build_env | 299 if fullname == 'defines': 300 mod.__dict__['buildEnv'] = build_env |
301 return mod 302 303 srcfile = self.modules[fullname] 304 if basename(srcfile) == '__init__.py': 305 mod.__path__ = fullname.split('.') 306 mod.__file__ = srcfile 307 308 exec file(srcfile, 'r') in mod.__dict__ --- 44 unchanged lines hidden (view full) --- 353module_depends = ["m5", "m5.SimObject", "m5.params"] 354depends = [ File(py_modules[dep]) for dep in module_depends ] 355 356######################################################################## 357# 358# Commands for the basic automatically generated python files 359# 360 | 301 return mod 302 303 srcfile = self.modules[fullname] 304 if basename(srcfile) == '__init__.py': 305 mod.__path__ = fullname.split('.') 306 mod.__file__ = srcfile 307 308 exec file(srcfile, 'r') in mod.__dict__ --- 44 unchanged lines hidden (view full) --- 353module_depends = ["m5", "m5.SimObject", "m5.params"] 354depends = [ File(py_modules[dep]) for dep in module_depends ] 355 356######################################################################## 357# 358# Commands for the basic automatically generated python files 359# 360 |
361scons_dir = str(SCons.Node.FS.default_fs.SConstruct_dir) 362 363hg_info = ("Unknown", "Unknown", "Unknown") 364hg_demandimport = False 365try: 366 if not exists(scons_dir) or not isdir(scons_dir) or \ 367 not exists(joinpath(scons_dir, ".hg")): 368 raise ValueError(".hg directory not found") 369 370 import mercurial.demandimport, mercurial.hg, mercurial.ui 371 import mercurial.util, mercurial.node 372 hg_demandimport = True 373 374 repo = mercurial.hg.repository(mercurial.ui.ui(), scons_dir) 375 rev = mercurial.node.nullrev + repo.changelog.count() 376 changenode = repo.changelog.node(rev) 377 changes = repo.changelog.read(changenode) 378 id = mercurial.node.hex(changenode) 379 date = mercurial.util.datestr(changes[2]) 380 381 hg_info = (rev, id, date) 382except ImportError, e: 383 print "Mercurial not found" 384except ValueError, e: 385 print e 386except Exception, e: 387 print "Other mercurial exception: %s" % e 388 389if hg_demandimport: 390 mercurial.demandimport.disable() 391 |
|
361# Generate Python file containing a dict specifying the current 362# build_env flags. 363def makeDefinesPyFile(target, source, env): 364 f = file(str(target[0]), 'w') | 392# Generate Python file containing a dict specifying the current 393# build_env flags. 394def makeDefinesPyFile(target, source, env): 395 f = file(str(target[0]), 'w') |
365 print >>f, "m5_build_env = ", source[0] | 396 build_env, hg_info = [ x.get_contents() for x in source ] 397 print >>f, "buildEnv = %s" % build_env 398 print >>f, "hgRev, hgId, hgDate = %s" % hg_info |
366 f.close() 367 | 399 f.close() 400 |
401defines_info = [ Value(build_env), Value(hg_info) ] 402# Generate a file with all of the compile options in it 403env.Command('python/m5/defines.py', defines_info, makeDefinesPyFile) 404PySource('m5', 'python/m5/defines.py') 405 |
|
368# Generate python file containing info about the M5 source code 369def makeInfoPyFile(target, source, env): 370 f = file(str(target[0]), 'w') 371 for src in source: 372 data = ''.join(file(src.srcnode().abspath, 'r').xreadlines()) 373 print >>f, "%s = %s" % (src, repr(data)) 374 f.close() 375 | 406# Generate python file containing info about the M5 source code 407def makeInfoPyFile(target, source, env): 408 f = file(str(target[0]), 'w') 409 for src in source: 410 data = ''.join(file(src.srcnode().abspath, 'r').xreadlines()) 411 print >>f, "%s = %s" % (src, repr(data)) 412 f.close() 413 |
414# Generate a file that wraps the basic top level files 415env.Command('python/m5/info.py', 416 [ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ], 417 makeInfoPyFile) 418PySource('m5', 'python/m5/info.py') 419 |
|
376# Generate the __init__.py file for m5.objects 377def makeObjectsInitFile(target, source, env): 378 f = file(str(target[0]), 'w') 379 print >>f, 'from params import *' 380 print >>f, 'from m5.SimObject import *' 381 for module in source: 382 print >>f, 'from %s import *' % module.get_contents() 383 f.close() 384 | 420# Generate the __init__.py file for m5.objects 421def makeObjectsInitFile(target, source, env): 422 f = file(str(target[0]), 'w') 423 print >>f, 'from params import *' 424 print >>f, 'from m5.SimObject import *' 425 for module in source: 426 print >>f, 'from %s import *' % module.get_contents() 427 f.close() 428 |
385# Generate a file with all of the compile options in it 386env.Command('python/m5/defines.py', Value(build_env), makeDefinesPyFile) 387PySource('m5', 'python/m5/defines.py') 388 389# Generate a file that wraps the basic top level files 390env.Command('python/m5/info.py', 391 [ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ], 392 makeInfoPyFile) 393PySource('m5', 'python/m5/info.py') 394 | |
395# Generate an __init__.py file for the objects package 396env.Command('python/m5/objects/__init__.py', 397 [ Value(o) for o in sort_list(sim_object_modfiles) ], 398 makeObjectsInitFile) 399PySource('m5.objects', 'python/m5/objects/__init__.py') 400 401######################################################################## 402# --- 413 unchanged lines hidden (view full) --- 816flags = [ Value(f) for f in trace_flags ] 817env.Command('base/traceflags.py', flags, traceFlagsPy) 818PySource('m5', 'base/traceflags.py') 819 820env.Command('base/traceflags.hh', flags, traceFlagsHH) 821env.Command('base/traceflags.cc', flags, traceFlagsCC) 822Source('base/traceflags.cc') 823 | 429# Generate an __init__.py file for the objects package 430env.Command('python/m5/objects/__init__.py', 431 [ Value(o) for o in sort_list(sim_object_modfiles) ], 432 makeObjectsInitFile) 433PySource('m5.objects', 'python/m5/objects/__init__.py') 434 435######################################################################## 436# --- 413 unchanged lines hidden (view full) --- 850flags = [ Value(f) for f in trace_flags ] 851env.Command('base/traceflags.py', flags, traceFlagsPy) 852PySource('m5', 'base/traceflags.py') 853 854env.Command('base/traceflags.hh', flags, traceFlagsHH) 855env.Command('base/traceflags.cc', flags, traceFlagsCC) 856Source('base/traceflags.cc') 857 |
824# Generate program_info.cc 825def programInfo(target, source, env): 826 def gen_file(target, rev, node, date): 827 pi_stats = file(target, 'w') 828 print >>pi_stats, 'const char *hgRev = "%s:%s";' % (rev, node) 829 print >>pi_stats, 'const char *hgDate = "%s";' % date 830 pi_stats.close() 831 832 target = str(target[0]) 833 scons_dir = str(source[0].get_contents()) 834 try: 835 import mercurial.demandimport, mercurial.hg, mercurial.ui 836 import mercurial.util, mercurial.node 837 if not exists(scons_dir) or not isdir(scons_dir) or \ 838 not exists(joinpath(scons_dir, ".hg")): 839 raise ValueError 840 repo = mercurial.hg.repository(mercurial.ui.ui(), scons_dir) 841 rev = mercurial.node.nullrev + repo.changelog.count() 842 changenode = repo.changelog.node(rev) 843 changes = repo.changelog.read(changenode) 844 date = mercurial.util.datestr(changes[2]) 845 846 gen_file(target, rev, mercurial.node.hex(changenode), date) 847 848 mercurial.demandimport.disable() 849 except ImportError: 850 gen_file(target, "Unknown", "Unknown", "Unknown") 851 852 except: 853 print "in except" 854 gen_file(target, "Unknown", "Unknown", "Unknown") 855 mercurial.demandimport.disable() 856 857env.Command('base/program_info.cc', 858 Value(str(SCons.Node.FS.default_fs.SConstruct_dir)), 859 programInfo) 860 | |
861# embed python files. All .py files that have been indicated by a 862# PySource() call in a SConscript need to be embedded into the M5 863# library. To do that, we compile the file to byte code, marshal the 864# byte code, compress it, and then generate an assembly file that 865# inserts the result into the data section with symbols indicating the 866# beginning, and end (and with the size at the end) 867py_sources_tnodes = {} 868for pysource in py_sources: --- 100 unchanged lines hidden (view full) --- 969 XObject = env.SharedObject 970 971 objs = [ XObject(s) for s in sources ] 972 973 # make date.cc depend on all other objects so it always gets 974 # recompiled whenever anything else does 975 date_obj = XObject('base/date.cc') 976 | 858# embed python files. All .py files that have been indicated by a 859# PySource() call in a SConscript need to be embedded into the M5 860# library. To do that, we compile the file to byte code, marshal the 861# byte code, compress it, and then generate an assembly file that 862# inserts the result into the data section with symbols indicating the 863# beginning, and end (and with the size at the end) 864py_sources_tnodes = {} 865for pysource in py_sources: --- 100 unchanged lines hidden (view full) --- 966 XObject = env.SharedObject 967 968 objs = [ XObject(s) for s in sources ] 969 970 # make date.cc depend on all other objects so it always gets 971 # recompiled whenever anything else does 972 date_obj = XObject('base/date.cc') 973 |
977 # Make the generation of program_info.cc dependend on all 978 # the other cc files and the compiling of program_info.cc 979 # dependent on all the objects but program_info.o 980 pinfo_obj = XObject('base/program_info.cc') 981 env.Depends('base/program_info.cc', sources) | |
982 env.Depends(date_obj, objs) | 974 env.Depends(date_obj, objs) |
983 env.Depends(pinfo_obj, objs) 984 objs.extend([date_obj, pinfo_obj]) | 975 objs.append(date_obj) |
985 return objs 986 987# Function to create a new build environment as clone of current 988# environment 'env' with modified object suffix and optional stripped 989# binary. Additional keyword arguments are appended to corresponding 990# build environment vars. 991def makeEnv(label, objsfx, strip = False, **kwargs): 992 # SCons doesn't know to append a library suffix when there is a '.' in the --- 89 unchanged lines hidden --- | 976 return objs 977 978# Function to create a new build environment as clone of current 979# environment 'env' with modified object suffix and optional stripped 980# binary. Additional keyword arguments are appended to corresponding 981# build environment vars. 982def makeEnv(label, objsfx, strip = False, **kwargs): 983 # SCons doesn't know to append a library suffix when there is a '.' in the --- 89 unchanged lines hidden --- |