Deleted Added
sdiff udiff text old ( 9982:b2bfc23f932c ) new ( 10196:be0e1724eb39 )
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

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

144
145 def __lt__(self, other): return self.filename < other.filename
146 def __le__(self, other): return self.filename <= other.filename
147 def __gt__(self, other): return self.filename > other.filename
148 def __ge__(self, other): return self.filename >= other.filename
149 def __eq__(self, other): return self.filename == other.filename
150 def __ne__(self, other): return self.filename != other.filename
151
152class Source(SourceFile):
153 '''Add a c/c++ source file to the build'''
154 def __init__(self, source, Werror=True, swig=False, **guards):
155 '''specify the source file, and any guards'''
156 super(Source, self).__init__(source, **guards)
157
158 self.Werror = Werror
159 self.swig = swig

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

872
873########################################################################
874#
875# Define binaries. Each different build type (debug, opt, etc.) gets
876# a slightly different build environment.
877#
878
879# List of constructed environments to pass back to SConstruct
880envList = []
881
882date_source = Source('base/date.cc', skip_lib=True)
883
884# Function to create a new build environment as clone of current
885# environment 'env' with modified object suffix and optional stripped
886# binary. Additional keyword arguments are appended to corresponding
887# build environment vars.
888def makeEnv(label, objsfx, strip = False, **kwargs):
889 # SCons doesn't know to append a library suffix when there is a '.' in the
890 # name. Use '_' instead.
891 libname = 'gem5_' + label
892 exename = 'gem5.' + label
893 secondary_exename = 'm5.' + label
894
895 new_env = env.Clone(OBJSUFFIX=objsfx, SHOBJSUFFIX=objsfx + 's')
896 new_env.Label = label
897 new_env.Append(**kwargs)
898
899 swig_env = new_env.Clone()
900
901 # Both gcc and clang have issues with unused labels and values in

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

973 main_objs = [ make_obj(s, True) for s in Source.get(main=True) ]
974
975 for test in UnitTest.all:
976 flags = { test.target : True }
977 test_sources = Source.get(**flags)
978 test_objs = [ make_obj(s, static=True) for s in test_sources ]
979 if test.main:
980 test_objs += main_objs
981 testname = "unittest/%s.%s" % (test.target, label)
982 new_env.Program(testname, test_objs + static_objs)
983
984 progname = exename
985 if strip:
986 progname += '.unstripped'
987
988 targets = new_env.Program(progname, main_objs + static_objs)
989
990 if strip:
991 if sys.platform == 'sunos5':
992 cmd = 'cp $SOURCE $TARGET; strip $TARGET'
993 else:
994 cmd = 'strip $SOURCE -o $TARGET'
995 targets = new_env.Command(exename, progname,
996 MakeAction(cmd, Transform("STRIP")))
997
998 new_env.Command(secondary_exename, exename,
999 MakeAction('ln $SOURCE $TARGET', Transform("HARDLINK")))
1000
1001 new_env.M5Binary = targets[0]
1002 envList.append(new_env)
1003
1004# Start out with the compiler flags common to all compilers,
1005# i.e. they all use -g for opt and -g -pg for prof
1006ccflags = {'debug' : [], 'opt' : ['-g'], 'fast' : [], 'prof' : ['-g', '-pg'],
1007 'perf' : ['-g']}
1008
1009# Start out with the linker flags common to all linkers, i.e. -pg for
1010# prof, and -lprofiler for perf. The -lprofile flag is surrounded by

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

1060 if match and match.group(1) in target_types:
1061 return match.group(1)
1062 return 'all'
1063
1064needed_envs = [identifyTarget(target) for target in BUILD_TARGETS]
1065if 'all' in needed_envs:
1066 needed_envs += target_types
1067
1068# Debug binary
1069if 'debug' in needed_envs:
1070 makeEnv('debug', '.do',
1071 CCFLAGS = Split(ccflags['debug']),
1072 CPPDEFINES = ['DEBUG', 'TRACING_ON=1'],
1073 LINKFLAGS = Split(ldflags['debug']))
1074
1075# Optimized binary
1076if 'opt' in needed_envs:
1077 makeEnv('opt', '.o',
1078 CCFLAGS = Split(ccflags['opt']),
1079 CPPDEFINES = ['TRACING_ON=1'],
1080 LINKFLAGS = Split(ldflags['opt']))
1081
1082# "Fast" binary
1083if 'fast' in needed_envs:
1084 makeEnv('fast', '.fo', strip = True,
1085 CCFLAGS = Split(ccflags['fast']),
1086 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'],
1087 LINKFLAGS = Split(ldflags['fast']))
1088
1089# Profiled binary using gprof
1090if 'prof' in needed_envs:
1091 makeEnv('prof', '.po',
1092 CCFLAGS = Split(ccflags['prof']),
1093 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'],
1094 LINKFLAGS = Split(ldflags['prof']))
1095
1096# Profiled binary using google-pprof
1097if 'perf' in needed_envs:
1098 makeEnv('perf', '.gpo',
1099 CCFLAGS = Split(ccflags['perf']),
1100 CPPDEFINES = ['NDEBUG', 'TRACING_ON=0'],
1101 LINKFLAGS = Split(ldflags['perf']))
1102
1103Return('envList')