SConscript (7722:c10bc8ad3f97) SConscript (7756:846fb3ffe0dc)
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

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

284
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
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

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

284
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), makeTheISA)
292env.Command('config/the_isa.hh', map(Value, all_isa_list),
293 MakeAction(makeTheISA, " [ CFG ISA] $STRIP_TARGET"))
293
294########################################################################
295#
296# Prevent any SimObjects from being added after this point, they
297# should all have been added in the SConscripts above
298#
299SimObject.fixed = True
300

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

426 flag = key[5:]
427 _globals[flag] = val
428del _globals
429""")
430 code.write(target[0].abspath)
431
432defines_info = [ Value(build_env), Value(env['HG_INFO']) ]
433# Generate a file with all of the compile options in it
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

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

427 flag = key[5:]
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
434env.Command('python/m5/defines.py', defines_info, makeDefinesPyFile)
435env.Command('python/m5/defines.py', defines_info,
436 MakeAction(makeDefinesPyFile, " [ DEFINES] $STRIP_TARGET"))
435PySource('m5', 'python/m5/defines.py')
436
437# Generate python file containing info about the M5 source code
438def makeInfoPyFile(target, source, env):
439 code = code_formatter()
440 for src in source:
441 data = ''.join(file(src.srcnode().abspath, 'r').xreadlines())
442 code('$src = ${{repr(data)}}')
443 code.write(str(target[0]))
444
445# Generate a file that wraps the basic top level files
446env.Command('python/m5/info.py',
447 [ '#/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' ],
448 makeInfoPyFile)
450 MakeAction(makeInfoPyFile, " [ INFO] $STRIP_TARGET"))
449PySource('m5', 'python/m5/info.py')
450
451########################################################################
452#
453# Create all of the SimObject param headers and enum headers
454#
455
456def createSimObjectParam(target, source, env):

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

515# Generate all of the SimObject param struct header files
516params_hh_files = []
517for name,simobj in sorted(sim_objects.iteritems()):
518 py_source = PySource.modules[simobj.__module__]
519 extra_deps = [ py_source.tnode ]
520
521 hh_file = File('params/%s.hh' % name)
522 params_hh_files.append(hh_file)
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):

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

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

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

581 code()
582
583 code('%include "params/$obj.hh"')
584
585 code.write(target[0].abspath)
586
587for name in sim_objects.iterkeys():
588 params_file = File('python/m5/internal/param_%s.i' % 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]

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

588 code()
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)
589 env.Command(params_file, Value(name), buildParam)
596 env.Command(params_file, Value(name),
597 MakeAction(buildParam, " [BLDPARAM] $STRIP_TARGET"))
590 env.Depends(params_file, depends)
591 SwigSource('m5.internal', params_file)
592
593# Generate the main swig init file
594def makeEmbeddedSwigInit(target, source, env):
595 code = code_formatter()
596 module = source[0].get_contents()
597 code('''\

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

603
604EmbeddedSwig embed_swig_${module}(init_${module});
605''')
606 code.write(str(target[0]))
607
608# Build all swig modules
609for swig in SwigSource.all:
610 env.Command([swig.cc_source.tnode, swig.py_source.tnode], swig.tnode,
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('''\

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

611
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,
611 '$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} '
612 '-o ${TARGETS[0]} $SOURCES')
619 MakeAction('$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} '
620 '-o ${TARGETS[0]} $SOURCES', " [ SWIG] $STRIP_TARGET"))
613 init_file = 'python/swig/init_%s.cc' % swig.module
621 init_file = 'python/swig/init_%s.cc' % swig.module
614 env.Command(init_file, Value(swig.module), makeEmbeddedSwigInit)
622 env.Command(init_file, Value(swig.module),
623 MakeAction(makeEmbeddedSwigInit, " [EMBED SW] $STRIP_TARGET"))
615 Source(init_file)
616 env.Depends(swig.py_source.tnode, swig.tnode)
617 env.Depends(swig.cc_source.tnode, swig.tnode)
618
619def getFlags(source_flags):
620 flagsMap = {}
621 flagsList = []
622 for s in source_flags:

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

831/* namespace Trace */ }
832
833#endif // __BASE_TRACE_FLAGS_HH__
834''')
835
836 code.write(str(target[0]))
837
838flags = map(Value, trace_flags.values())
624 Source(init_file)
625 env.Depends(swig.py_source.tnode, swig.tnode)
626 env.Depends(swig.cc_source.tnode, swig.tnode)
627
628def getFlags(source_flags):
629 flagsMap = {}
630 flagsList = []
631 for s in source_flags:

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

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

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

892 ${{len(data)}},
893 ${{len(marshalled)}});
894
895/* namespace */ }
896''')
897 code.write(str(target[0]))
898
899for source in PySource.all:
856Source('base/traceflags.cc')
857
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 a c++ file that
862# inserts the result into an array.
863def embedPyFile(target, source, env):

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

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

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

983
984 targets = new_env.Program(progname, bin_objs + static_objs)
985
986 if strip:
987 if sys.platform == 'sunos5':
988 cmd = 'cp $SOURCE $TARGET; strip $TARGET'
989 else:
990 cmd = 'strip $SOURCE -o $TARGET'
914 Source(source.cpp)
915
916########################################################################
917#
918# Define binaries. Each different build type (debug, opt, etc.) gets
919# a slightly different build environment.
920#
921

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

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

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

--- 41 unchanged lines hidden ---