SConscript (5584:e08e65fd0f76) | SConscript (5601:1acb7016d0e4) |
---|---|
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 --- 920 unchanged lines hidden (view full) --- 929# List of constructed environments to pass back to SConstruct 930envList = [] 931 932# This function adds the specified sources to the given build 933# environment, and returns a list of all the corresponding SCons 934# Object nodes (including an extra one for date.cc). We explicitly 935# add the Object nodes so we can set up special dependencies for 936# date.cc. | 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 --- 920 unchanged lines hidden (view full) --- 929# List of constructed environments to pass back to SConstruct 930envList = [] 931 932# This function adds the specified sources to the given build 933# environment, and returns a list of all the corresponding SCons 934# Object nodes (including an extra one for date.cc). We explicitly 935# add the Object nodes so we can set up special dependencies for 936# date.cc. |
937def make_objs(sources, env): 938 objs = [env.Object(s) for s in sources] | 937def make_objs(sources, env, static): 938 if static: 939 XObject = env.StaticObject 940 else: 941 XObject = env.SharedObject 942 943 objs = [ XObject(s) for s in sources ] |
939 940 # make date.cc depend on all other objects so it always gets 941 # recompiled whenever anything else does | 944 945 # make date.cc depend on all other objects so it always gets 946 # recompiled whenever anything else does |
942 date_obj = env.Object('base/date.cc') | 947 date_obj = XObject('base/date.cc') |
943 944 # Make the generation of program_info.cc dependend on all 945 # the other cc files and the compiling of program_info.cc 946 # dependent on all the objects but program_info.o | 948 949 # Make the generation of program_info.cc dependend on all 950 # the other cc files and the compiling of program_info.cc 951 # dependent on all the objects but program_info.o |
947 pinfo_obj = env.Object('base/program_info.cc') | 952 pinfo_obj = XObject('base/program_info.cc') |
948 env.Depends('base/program_info.cc', sources) 949 env.Depends(date_obj, objs) 950 env.Depends(pinfo_obj, objs) | 953 env.Depends('base/program_info.cc', sources) 954 env.Depends(date_obj, objs) 955 env.Depends(pinfo_obj, objs) |
951 objs.extend([date_obj,pinfo_obj]) | 956 objs.extend([date_obj, pinfo_obj]) |
952 return objs 953 954# Function to create a new build environment as clone of current 955# environment 'env' with modified object suffix and optional stripped 956# binary. Additional keyword arguments are appended to corresponding 957# build environment vars. 958def makeEnv(label, objsfx, strip = False, **kwargs): | 957 return objs 958 959# Function to create a new build environment as clone of current 960# environment 'env' with modified object suffix and optional stripped 961# binary. Additional keyword arguments are appended to corresponding 962# build environment vars. 963def makeEnv(label, objsfx, strip = False, **kwargs): |
959 newEnv = env.Copy(OBJSUFFIX=objsfx) 960 newEnv.Label = label 961 newEnv.Append(**kwargs) | 964 # SCons doesn't know to append a library suffix when there is a '.' in the 965 # name. Use '_' instead. 966 libname = 'm5_' + label 967 exename = 'm5.' + label |
962 | 968 |
963 swig_env = newEnv.Copy() | 969 new_env = env.Copy(OBJSUFFIX=objsfx, SHOBJSUFFIX=objsfx + 's') 970 new_env.Label = label 971 new_env.Append(**kwargs) 972 973 swig_env = new_env.Copy() |
964 if env['GCC']: 965 swig_env.Append(CCFLAGS='-Wno-uninitialized') 966 swig_env.Append(CCFLAGS='-Wno-sign-compare') 967 swig_env.Append(CCFLAGS='-Wno-parentheses') | 974 if env['GCC']: 975 swig_env.Append(CCFLAGS='-Wno-uninitialized') 976 swig_env.Append(CCFLAGS='-Wno-sign-compare') 977 swig_env.Append(CCFLAGS='-Wno-parentheses') |
968 swig_objs = [ swig_env.Object(s) for s in cc_swig_sources ] | |
969 | 978 |
979 static_objs = make_objs(cc_lib_sources, new_env, static=True) 980 shared_objs = make_objs(cc_lib_sources, new_env, static=False) 981 static_objs += [ swig_env.StaticObject(s) for s in cc_swig_sources ] 982 shared_objs += [ swig_env.SharedObject(s) for s in cc_swig_sources ] 983 |
|
970 # First make a library of everything but main() so other programs can 971 # link against m5. | 984 # First make a library of everything but main() so other programs can 985 # link against m5. |
972 # 973 # SCons doesn't know to append a library suffix when there is a '.' in the 974 # name. Use '_' instead. | 986 static_lib = new_env.StaticLibrary(libname, static_objs + static_objs) 987 shared_lib = new_env.SharedLibrary(libname, shared_objs + shared_objs) |
975 | 988 |
976 m5lib = newEnv.Library('m5_' + label, 977 make_objs(cc_lib_sources, newEnv) + swig_objs) 978 | |
979 for target, sources in unit_tests: | 989 for target, sources in unit_tests: |
980 objs = [ newEnv.StaticObject(s) for s in sources ] 981 newEnv.Program("unittest/%s.%s" % (target, label), objs + m5lib) | 990 objs = [ new_env.StaticObject(s) for s in sources ] 991 new_env.Program("unittest/%s.%s" % (target, label), objs + static_lib) |
982 | 992 |
983 # Now link a stub with main() and the library. 984 exe = 'm5.' + label # final executable 985 objects = [newEnv.Object(s) for s in cc_bin_sources] + m5lib | 993 # Now link a stub with main() and the static library. 994 objects = [new_env.Object(s) for s in cc_bin_sources] + static_lib |
986 if strip: | 995 if strip: |
987 unstripped_exe = exe + '.unstripped' 988 newEnv.Program(unstripped_exe, objects) | 996 unstripped_exe = exename + '.unstripped' 997 new_env.Program(unstripped_exe, objects) |
989 if sys.platform == 'sunos5': 990 cmd = 'cp $SOURCE $TARGET; strip $TARGET' 991 else: 992 cmd = 'strip $SOURCE -o $TARGET' | 998 if sys.platform == 'sunos5': 999 cmd = 'cp $SOURCE $TARGET; strip $TARGET' 1000 else: 1001 cmd = 'strip $SOURCE -o $TARGET' |
993 targets = newEnv.Command(exe, unstripped_exe, cmd) | 1002 targets = new_env.Command(exename, unstripped_exe, cmd) |
994 else: | 1003 else: |
995 targets = newEnv.Program(exe, objects) | 1004 targets = new_env.Program(exename, objects) |
996 | 1005 |
997 newEnv.M5Binary = targets[0] 998 envList.append(newEnv) | 1006 new_env.M5Binary = targets[0] 1007 envList.append(new_env) |
999 1000# Debug binary 1001ccflags = {} 1002if env['GCC']: 1003 if sys.platform == 'sunos5': 1004 ccflags['debug'] = '-gstabs+' 1005 else: 1006 ccflags['debug'] = '-ggdb3' --- 38 unchanged lines hidden --- | 1008 1009# Debug binary 1010ccflags = {} 1011if env['GCC']: 1012 if sys.platform == 'sunos5': 1013 ccflags['debug'] = '-gstabs+' 1014 else: 1015 ccflags['debug'] = '-ggdb3' --- 38 unchanged lines hidden --- |