Deleted Added
sdiff udiff text old ( 11985:03e3d059c4b9 ) new ( 11988:665cd5f8b52b )
full compact
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

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

171
172 @classmethod
173 def set_group(cls, group):
174 if not group in Source.source_groups:
175 Source.source_groups[group] = []
176 Source.current_group = group
177
178 '''Add a c/c++ source file to the build'''
179 def __init__(self, source, Werror=True, **guards):
180 '''specify the source file, and any guards'''
181 super(Source, self).__init__(source, **guards)
182
183 self.Werror = Werror
184
185 Source.source_groups[Source.current_group].append(self)
186
187class PySource(SourceFile):
188 '''Add a python source file to the named package'''
189 invalid_sym_char = re.compile('[^A-z0-9_]')
190 modules = {}
191 tnodes = {}

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

237 '''Specify the source file and any guards (automatically in
238 the m5.objects package)'''
239 super(SimObject, self).__init__('m5.objects', source, **guards)
240 if self.fixed:
241 raise AttributeError, "Too late to call SimObject now."
242
243 bisect.insort_right(SimObject.modnames, self.modname)
244
245class ProtoBuf(SourceFile):
246 '''Add a Protocol Buffer to build'''
247
248 def __init__(self, source, **guards):
249 '''Specify the source file, and any guards'''
250 super(ProtoBuf, self).__init__(source, **guards)
251
252 # Get the file name and the extension

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

279 self.target = target
280 self.main = kwargs.get('main', False)
281 UnitTest.all.append(self)
282
283# Children should have access
284Export('Source')
285Export('PySource')
286Export('SimObject')
287Export('ProtoBuf')
288Export('UnitTest')
289
290########################################################################
291#
292# Debug Flags
293#
294debug_flags = {}

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

534# we need to unload all of the currently imported modules so that they
535# will be re-imported the next time the sconscript is run
536importer.unload()
537sys.meta_path.remove(importer)
538
539sim_objects = m5.SimObject.allClasses
540all_enums = m5.params.allEnums
541
542for name,obj in sorted(sim_objects.iteritems()):
543 for param in obj._params.local.values():
544 # load the ptype attribute now because it depends on the
545 # current version of SimObject.allClasses, but when scons
546 # actually uses the value, all versions of
547 # SimObject.allClasses will have been loaded
548 param.ptype
549
550########################################################################
551#
552# calculate extra dependencies
553#
554module_depends = ["m5", "m5.SimObject", "m5.params"]
555depends = [ PySource.modules[dep].snode for dep in module_depends ]
556depends.sort(key = lambda x: x.name)
557

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

624 name = str(source[0].get_contents())
625 obj = sim_objects[name]
626
627 code = code_formatter()
628 obj.cxx_config_param_file(code, is_header)
629 code.write(target[0].abspath)
630 return body
631
632def createEnumStrings(target, source, env):
633 assert len(target) == 1 and len(source) == 1
634
635 name = str(source[0].get_contents())
636 obj = all_enums[name]
637
638 code = code_formatter()
639 obj.cxx_def(code)
640 if env['USE_PYTHON']:
641 obj.pybind_def(code)
642 code.write(target[0].abspath)
643
644def createEnumDecls(target, source, env):
645 assert len(target) == 1 and len(source) == 1
646
647 name = str(source[0].get_contents())
648 obj = all_enums[name]
649
650 code = code_formatter()
651 obj.cxx_decl(code)
652 code.write(target[0].abspath)
653
654def createSimObjectPyBindWrapper(target, source, env):
655 name = source[0].get_contents()
656 obj = sim_objects[name]
657
658 code = code_formatter()
659 obj.pybind_decl(code)
660 code.write(target[0].abspath)
661
662# Generate all of the SimObject param C++ struct header files
663params_hh_files = []
664for name,simobj in sorted(sim_objects.iteritems()):
665 py_source = PySource.modules[simobj.__module__]
666 extra_deps = [ py_source.tnode ]
667
668 hh_file = File('params/%s.hh' % name)
669 params_hh_files.append(hh_file)
670 env.Command(hh_file, Value(name),
671 MakeAction(createSimObjectParamStruct, Transform("SO PARAM")))
672 env.Depends(hh_file, depends + extra_deps)
673
674# C++ parameter description files
675if GetOption('with_cxx_config'):
676 for name,simobj in sorted(sim_objects.iteritems()):
677 py_source = PySource.modules[simobj.__module__]
678 extra_deps = [ py_source.tnode ]
679
680 cxx_config_hh_file = File('cxx_config/%s.hh' % name)

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

721 MakeAction(createCxxConfigInitCC, Transform("CXXCINIT")))
722 cxx_param_hh_files = ["cxx_config/%s.hh" % simobj
723 for name,simobj in sorted(sim_objects.iteritems())
724 if not hasattr(simobj, 'abstract') or not simobj.abstract]
725 Depends(cxx_config_init_cc_file, cxx_param_hh_files +
726 [File('sim/cxx_config.hh')])
727 Source(cxx_config_init_cc_file)
728
729# Generate all enum header files
730for name,enum in sorted(all_enums.iteritems()):
731 py_source = PySource.modules[enum.__module__]
732 extra_deps = [ py_source.tnode ]
733
734 cc_file = File('enums/%s.cc' % name)
735 env.Command(cc_file, Value(name),
736 MakeAction(createEnumStrings, Transform("ENUM STR")))
737 env.Depends(cc_file, depends + extra_deps)
738 Source(cc_file)
739
740 hh_file = File('enums/%s.hh' % name)
741 env.Command(hh_file, Value(name),
742 MakeAction(createEnumDecls, Transform("ENUMDECL")))
743 env.Depends(hh_file, depends + extra_deps)
744
745# Generate SimObject Python bindings wrapper files
746if env['USE_PYTHON']:
747 for name,simobj in sorted(sim_objects.iteritems()):
748 py_source = PySource.modules[simobj.__module__]
749 extra_deps = [ py_source.tnode ]
750 cc_file = File('python/_m5/param_%s.cc' % name)
751 env.Command(cc_file, Value(name),
752 MakeAction(createSimObjectPyBindWrapper,
753 Transform("SO PyBind")))
754 env.Depends(cc_file, depends + extra_deps)
755 Source(cc_file)
756
757# Build all protocol buffers if we have got protoc and protobuf available
758if env['HAVE_PROTOBUF']:
759 for proto in ProtoBuf.all:
760 # Use both the source and header as the target, and the .proto
761 # file as the source. When executing the protoc compiler, also
762 # specify the proto_path to avoid having the generated files
763 # include the path.
764 env.Command([proto.cc_file, proto.hh_file], proto.tnode,
765 MakeAction('$PROTOC --cpp_out ${TARGET.dir} '
766 '--proto_path ${SOURCE.dir} $SOURCE',
767 Transform("PROTOC")))
768
769 # Add the C++ source file
770 Source(proto.cc_file, **proto.guards)
771elif ProtoBuf.all:
772 print 'Got protobuf to build, but lacks support!'
773 Exit(1)
774
775#
776# Handle debug flags

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

860
861for name,flag in sorted(debug_flags.iteritems()):
862 n, compound, desc = flag
863 assert n == name
864
865 hh_file = 'debug/%s.hh' % name
866 env.Command(hh_file, Value(flag),
867 MakeAction(makeDebugFlagHH, Transform("TRACING", 0)))
868
869env.Command('debug/flags.cc', Value(debug_flags),
870 MakeAction(makeDebugFlagCC, Transform("TRACING", 0)))
871Source('debug/flags.cc')
872
873# version tags
874tags = \
875env.Command('sim/tags.cc', None,
876 MakeAction('util/cpt_upgrader.py --get-cc-file > $TARGET',
877 Transform("VER TAGS")))
878env.AlwaysBuild(tags)

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

928
929} // anonymous namespace
930''')
931 code.write(str(target[0]))
932
933for source in PySource.all:
934 env.Command(source.cpp, source.tnode,
935 MakeAction(embedPyFile, Transform("EMBED PY")))
936 Source(source.cpp, skip_no_python=True)
937
938########################################################################
939#
940# Define binaries. Each different build type (debug, opt, etc.) gets
941# a slightly different build environment.
942#
943

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

962 libname = variant('gem5_' + label)
963 exename = variant('gem5.' + label)
964 secondary_exename = variant('m5.' + label)
965
966 new_env = env.Clone(OBJSUFFIX=objsfx, SHOBJSUFFIX=objsfx + 's')
967 new_env.Label = label
968 new_env.Append(**kwargs)
969
970 if env['GCC']:
971 # The address sanitizer is available for gcc >= 4.8
972 if GetOption('with_asan'):
973 if GetOption('with_ubsan') and \
974 compareVersions(env['GCC_VERSION'], '4.9') >= 0:
975 new_env.Append(CCFLAGS=['-fsanitize=address,undefined',
976 '-fno-omit-frame-pointer'])
977 new_env.Append(LINKFLAGS='-fsanitize=address,undefined')
978 else:

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

984 # linker flags.
985 elif GetOption('with_ubsan') and \
986 compareVersions(env['GCC_VERSION'], '4.9') >= 0:
987 new_env.Append(CCFLAGS='-fsanitize=undefined')
988 new_env.Append(LINKFLAGS='-fsanitize=undefined')
989
990
991 if env['CLANG']:
992 # We require clang >= 3.1, so there is no need to check any
993 # versions here.
994 if GetOption('with_ubsan'):
995 if GetOption('with_asan'):
996 new_env.Append(CCFLAGS=['-fsanitize=address,undefined',
997 '-fno-omit-frame-pointer'])
998 new_env.Append(LINKFLAGS='-fsanitize=address,undefined')
999 else:

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

1013 '-Wno-error=deprecated',
1014 ])
1015
1016 def make_obj(source, static, extra_deps = None):
1017 '''This function adds the specified source to the correct
1018 build environment, and returns the corresponding SCons Object
1019 nodes'''
1020
1021 if source.Werror:
1022 env = werror_env
1023 else:
1024 env = new_env
1025
1026 if static:
1027 obj = env.StaticObject(source.tnode)
1028 else:
1029 obj = env.SharedObject(source.tnode)
1030
1031 if extra_deps:
1032 env.Depends(obj, extra_deps)
1033
1034 return obj
1035
1036 lib_guards = {'main': False, 'skip_lib': False}
1037
1038 # Without Python, leave out all Python content from the library
1039 # builds. The option doesn't affect gem5 built as a program
1040 if GetOption('without_python'):
1041 lib_guards['skip_no_python'] = False
1042
1043 static_objs = []
1044 shared_objs = []
1045 for s in guarded_source_iterator(Source.source_groups[None], **lib_guards):
1046 static_objs.append(make_obj(s, True))
1047 shared_objs.append(make_obj(s, False))

--- 207 unchanged lines hidden ---