SConscript (7811:a8fc35183c10) SConscript (7816:b5003ac75977)
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

--- 276 unchanged lines hidden (view full) ---

285#define THE_ISA ${{define(target_isa)}}
286#define TheISA ${{namespace(target_isa)}}
287
288#endif // __CONFIG_THE_ISA_HH__''')
289
290 code.write(str(target[0]))
291
292env.Command('config/the_isa.hh', map(Value, all_isa_list),
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

--- 276 unchanged lines hidden (view full) ---

285#define THE_ISA ${{define(target_isa)}}
286#define TheISA ${{namespace(target_isa)}}
287
288#endif // __CONFIG_THE_ISA_HH__''')
289
290 code.write(str(target[0]))
291
292env.Command('config/the_isa.hh', map(Value, all_isa_list),
293 MakeAction(makeTheISA, " [ CFG ISA] $STRIP_TARGET"))
293 MakeAction(makeTheISA, Transform("CFG ISA", 0)))
294
295########################################################################
296#
297# Prevent any SimObjects from being added after this point, they
298# should all have been added in the SConscripts above
299#
300SimObject.fixed = True
301

--- 126 unchanged lines hidden (view full) ---

428 _globals[flag] = val
429del _globals
430""")
431 code.write(target[0].abspath)
432
433defines_info = [ Value(build_env), Value(env['HG_INFO']) ]
434# Generate a file with all of the compile options in it
435env.Command('python/m5/defines.py', defines_info,
294
295########################################################################
296#
297# Prevent any SimObjects from being added after this point, they
298# should all have been added in the SConscripts above
299#
300SimObject.fixed = True
301

--- 126 unchanged lines hidden (view full) ---

428 _globals[flag] = val
429del _globals
430""")
431 code.write(target[0].abspath)
432
433defines_info = [ Value(build_env), Value(env['HG_INFO']) ]
434# Generate a file with all of the compile options in it
435env.Command('python/m5/defines.py', defines_info,
436 MakeAction(makeDefinesPyFile, " [ DEFINES] $STRIP_TARGET"))
436 MakeAction(makeDefinesPyFile, Transform("DEFINES", 0)))
437PySource('m5', 'python/m5/defines.py')
438
439# Generate python file containing info about the M5 source code
440def makeInfoPyFile(target, source, env):
441 code = code_formatter()
442 for src in source:
443 data = ''.join(file(src.srcnode().abspath, 'r').xreadlines())
444 code('$src = ${{repr(data)}}')
445 code.write(str(target[0]))
446
447# Generate a file that wraps the basic top level files
448env.Command('python/m5/info.py',
449 [ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ],
437PySource('m5', 'python/m5/defines.py')
438
439# Generate python file containing info about the M5 source code
440def makeInfoPyFile(target, source, env):
441 code = code_formatter()
442 for src in source:
443 data = ''.join(file(src.srcnode().abspath, 'r').xreadlines())
444 code('$src = ${{repr(data)}}')
445 code.write(str(target[0]))
446
447# Generate a file that wraps the basic top level files
448env.Command('python/m5/info.py',
449 [ '#/AUTHORS', '#/LICENSE', '#/README', '#/RELEASE_NOTES' ],
450 MakeAction(makeInfoPyFile, " [ INFO] $STRIP_TARGET"))
450 MakeAction(makeInfoPyFile, Transform("INFO")))
451PySource('m5', 'python/m5/info.py')
452
453########################################################################
454#
455# Create all of the SimObject param headers and enum headers
456#
457
458def createSimObjectParam(target, source, env):

--- 59 unchanged lines hidden (view full) ---

518params_hh_files = []
519for name,simobj in sorted(sim_objects.iteritems()):
520 py_source = PySource.modules[simobj.__module__]
521 extra_deps = [ py_source.tnode ]
522
523 hh_file = File('params/%s.hh' % name)
524 params_hh_files.append(hh_file)
525 env.Command(hh_file, Value(name),
451PySource('m5', 'python/m5/info.py')
452
453########################################################################
454#
455# Create all of the SimObject param headers and enum headers
456#
457
458def createSimObjectParam(target, source, env):

--- 59 unchanged lines hidden (view full) ---

518params_hh_files = []
519for name,simobj in sorted(sim_objects.iteritems()):
520 py_source = PySource.modules[simobj.__module__]
521 extra_deps = [ py_source.tnode ]
522
523 hh_file = File('params/%s.hh' % name)
524 params_hh_files.append(hh_file)
525 env.Command(hh_file, Value(name),
526 MakeAction(createSimObjectParam, " [SO PARAM] $STRIP_TARGET"))
526 MakeAction(createSimObjectParam, Transform("SO PARAM")))
527 env.Depends(hh_file, depends + extra_deps)
528
529# Generate any parameter header files needed
530params_i_files = []
531for name,param in all_params.iteritems():
532 i_file = File('python/m5/internal/%s_%s.i' % (param.file_ext, name))
533 params_i_files.append(i_file)
534 env.Command(i_file, Value(name),
527 env.Depends(hh_file, depends + extra_deps)
528
529# Generate any parameter header files needed
530params_i_files = []
531for name,param in all_params.iteritems():
532 i_file = File('python/m5/internal/%s_%s.i' % (param.file_ext, name))
533 params_i_files.append(i_file)
534 env.Command(i_file, Value(name),
535 MakeAction(createSwigParam, " [SW PARAM] $STRIP_TARGET"))
535 MakeAction(createSwigParam, Transform("SW PARAM")))
536 env.Depends(i_file, depends)
537 SwigSource('m5.internal', i_file)
538
539# Generate all enum header files
540for name,enum in sorted(all_enums.iteritems()):
541 py_source = PySource.modules[enum.__module__]
542 extra_deps = [ py_source.tnode ]
543
544 cc_file = File('enums/%s.cc' % name)
545 env.Command(cc_file, Value(name),
536 env.Depends(i_file, depends)
537 SwigSource('m5.internal', i_file)
538
539# Generate all enum header files
540for name,enum in sorted(all_enums.iteritems()):
541 py_source = PySource.modules[enum.__module__]
542 extra_deps = [ py_source.tnode ]
543
544 cc_file = File('enums/%s.cc' % name)
545 env.Command(cc_file, Value(name),
546 MakeAction(createEnumStrings, " [ENUM STR] $STRIP_TARGET"))
546 MakeAction(createEnumStrings, Transform("ENUM STR")))
547 env.Depends(cc_file, depends + extra_deps)
548 Source(cc_file)
549
550 hh_file = File('enums/%s.hh' % name)
551 env.Command(hh_file, Value(name),
547 env.Depends(cc_file, depends + extra_deps)
548 Source(cc_file)
549
550 hh_file = File('enums/%s.hh' % name)
551 env.Command(hh_file, Value(name),
552 MakeAction(createEnumParam, " [EN PARAM] $STRIP_TARGET"))
552 MakeAction(createEnumParam, Transform("EN PARAM")))
553 env.Depends(hh_file, depends + extra_deps)
554
555 i_file = File('python/m5/internal/enum_%s.i' % name)
556 env.Command(i_file, Value(name),
553 env.Depends(hh_file, depends + extra_deps)
554
555 i_file = File('python/m5/internal/enum_%s.i' % name)
556 env.Command(i_file, Value(name),
557 MakeAction(createEnumSwig, " [ENUMSWIG] $STRIP_TARGET"))
557 MakeAction(createEnumSwig, Transform("ENUMSWIG")))
558 env.Depends(i_file, depends + extra_deps)
559 SwigSource('m5.internal', i_file)
560
561def buildParam(target, source, env):
562 name = source[0].get_contents()
563 obj = sim_objects[name]
564 class_path = obj.cxx_class.split('::')
565 classname = class_path[-1]

--- 23 unchanged lines hidden (view full) ---

589
590 code('%include "params/$obj.hh"')
591
592 code.write(target[0].abspath)
593
594for name in sim_objects.iterkeys():
595 params_file = File('python/m5/internal/param_%s.i' % name)
596 env.Command(params_file, Value(name),
558 env.Depends(i_file, depends + extra_deps)
559 SwigSource('m5.internal', i_file)
560
561def buildParam(target, source, env):
562 name = source[0].get_contents()
563 obj = sim_objects[name]
564 class_path = obj.cxx_class.split('::')
565 classname = class_path[-1]

--- 23 unchanged lines hidden (view full) ---

589
590 code('%include "params/$obj.hh"')
591
592 code.write(target[0].abspath)
593
594for name in sim_objects.iterkeys():
595 params_file = File('python/m5/internal/param_%s.i' % name)
596 env.Command(params_file, Value(name),
597 MakeAction(buildParam, " [BLDPARAM] $STRIP_TARGET"))
597 MakeAction(buildParam, Transform("BLDPARAM")))
598 env.Depends(params_file, depends)
599 SwigSource('m5.internal', params_file)
600
601# Generate the main swig init file
602def makeEmbeddedSwigInit(target, source, env):
603 code = code_formatter()
604 module = source[0].get_contents()
605 code('''\

--- 6 unchanged lines hidden (view full) ---

612EmbeddedSwig embed_swig_${module}(init_${module});
613''')
614 code.write(str(target[0]))
615
616# Build all swig modules
617for swig in SwigSource.all:
618 env.Command([swig.cc_source.tnode, swig.py_source.tnode], swig.tnode,
619 MakeAction('$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} '
598 env.Depends(params_file, depends)
599 SwigSource('m5.internal', params_file)
600
601# Generate the main swig init file
602def makeEmbeddedSwigInit(target, source, env):
603 code = code_formatter()
604 module = source[0].get_contents()
605 code('''\

--- 6 unchanged lines hidden (view full) ---

612EmbeddedSwig embed_swig_${module}(init_${module});
613''')
614 code.write(str(target[0]))
615
616# Build all swig modules
617for swig in SwigSource.all:
618 env.Command([swig.cc_source.tnode, swig.py_source.tnode], swig.tnode,
619 MakeAction('$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} '
620 '-o ${TARGETS[0]} $SOURCES', " [ SWIG] $STRIP_TARGET"))
620 '-o ${TARGETS[0]} $SOURCES', Transform("SWIG")))
621 init_file = 'python/swig/init_%s.cc' % swig.module
622 env.Command(init_file, Value(swig.module),
621 init_file = 'python/swig/init_%s.cc' % swig.module
622 env.Command(init_file, Value(swig.module),
623 MakeAction(makeEmbeddedSwigInit, " [EMBED SW] $STRIP_TARGET"))
623 MakeAction(makeEmbeddedSwigInit, Transform("EMBED SW")))
624 Source(init_file)
625
626def getFlags(source_flags):
627 flagsMap = {}
628 flagsList = []
629 for s in source_flags:
630 val = eval(s.get_contents())
631 name, compound, desc = val

--- 207 unchanged lines hidden (view full) ---

839
840#endif // __BASE_TRACE_FLAGS_HH__
841''')
842
843 code.write(str(target[0]))
844
845flags = map(Value, trace_flags.values())
846env.Command('base/traceflags.py', flags,
624 Source(init_file)
625
626def getFlags(source_flags):
627 flagsMap = {}
628 flagsList = []
629 for s in source_flags:
630 val = eval(s.get_contents())
631 name, compound, desc = val

--- 207 unchanged lines hidden (view full) ---

839
840#endif // __BASE_TRACE_FLAGS_HH__
841''')
842
843 code.write(str(target[0]))
844
845flags = map(Value, trace_flags.values())
846env.Command('base/traceflags.py', flags,
847 MakeAction(traceFlagsPy, " [ TRACING] $STRIP_TARGET"))
847 MakeAction(traceFlagsPy, Transform("TRACING", 0)))
848PySource('m5', 'base/traceflags.py')
849
850env.Command('base/traceflags.hh', flags,
848PySource('m5', 'base/traceflags.py')
849
850env.Command('base/traceflags.hh', flags,
851 MakeAction(traceFlagsHH, " [ TRACING] $STRIP_TARGET"))
851 MakeAction(traceFlagsHH, Transform("TRACING", 0)))
852env.Command('base/traceflags.cc', flags,
852env.Command('base/traceflags.cc', flags,
853 MakeAction(traceFlagsCC, " [ TRACING] $STRIP_TARGET"))
853 MakeAction(traceFlagsCC, Transform("TRACING", 0)))
854Source('base/traceflags.cc')
855
856# Embed python files. All .py files that have been indicated by a
857# PySource() call in a SConscript need to be embedded into the M5
858# library. To do that, we compile the file to byte code, marshal the
859# byte code, compress it, and then generate a c++ file that
860# inserts the result into an array.
861def embedPyFile(target, source, env):

--- 41 unchanged lines hidden (view full) ---

903 ${{len(marshalled)}});
904
905} // anonymous namespace
906''')
907 code.write(str(target[0]))
908
909for source in PySource.all:
910 env.Command(source.cpp, source.tnode,
854Source('base/traceflags.cc')
855
856# Embed python files. All .py files that have been indicated by a
857# PySource() call in a SConscript need to be embedded into the M5
858# library. To do that, we compile the file to byte code, marshal the
859# byte code, compress it, and then generate a c++ file that
860# inserts the result into an array.
861def embedPyFile(target, source, env):

--- 41 unchanged lines hidden (view full) ---

903 ${{len(marshalled)}});
904
905} // anonymous namespace
906''')
907 code.write(str(target[0]))
908
909for source in PySource.all:
910 env.Command(source.cpp, source.tnode,
911 MakeAction(embedPyFile, " [EMBED PY] $STRIP_TARGET"))
911 MakeAction(embedPyFile, Transform("EMBED PY")))
912 Source(source.cpp)
913
914########################################################################
915#
916# Define binaries. Each different build type (debug, opt, etc.) gets
917# a slightly different build environment.
918#
919

--- 75 unchanged lines hidden (view full) ---

995 targets = new_env.Program(progname, bin_objs + static_objs)
996
997 if strip:
998 if sys.platform == 'sunos5':
999 cmd = 'cp $SOURCE $TARGET; strip $TARGET'
1000 else:
1001 cmd = 'strip $SOURCE -o $TARGET'
1002 targets = new_env.Command(exename, progname,
912 Source(source.cpp)
913
914########################################################################
915#
916# Define binaries. Each different build type (debug, opt, etc.) gets
917# a slightly different build environment.
918#
919

--- 75 unchanged lines hidden (view full) ---

995 targets = new_env.Program(progname, bin_objs + static_objs)
996
997 if strip:
998 if sys.platform == 'sunos5':
999 cmd = 'cp $SOURCE $TARGET; strip $TARGET'
1000 else:
1001 cmd = 'strip $SOURCE -o $TARGET'
1002 targets = new_env.Command(exename, progname,
1003 MakeAction(cmd, " [ STRIP] $STRIP_TARGET"))
1003 MakeAction(cmd, Transform("STRIP")))
1004
1005 new_env.M5Binary = targets[0]
1006 envList.append(new_env)
1007
1008# Debug binary
1009ccflags = {}
1010if env['GCC']:
1011 if sys.platform == 'sunos5':

--- 41 unchanged lines hidden ---
1004
1005 new_env.M5Binary = targets[0]
1006 envList.append(new_env)
1007
1008# Debug binary
1009ccflags = {}
1010if env['GCC']:
1011 if sys.platform == 'sunos5':

--- 41 unchanged lines hidden ---