SConscript (12315:97321085f650) | SConscript (12362:b485016c498f) |
---|---|
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 --- 88 unchanged lines hidden (view full) --- 97 cls.all = SourceList() 98 99class SourceFile(object): 100 '''Base object that encapsulates the notion of a source file. 101 This includes, the source node, target node, various manipulations 102 of those. A source file also specifies a set of tags which 103 describing arbitrary properties of the source file.''' 104 __metaclass__ = SourceMeta | 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 --- 88 unchanged lines hidden (view full) --- 97 cls.all = SourceList() 98 99class SourceFile(object): 100 '''Base object that encapsulates the notion of a source file. 101 This includes, the source node, target node, various manipulations 102 of those. A source file also specifies a set of tags which 103 describing arbitrary properties of the source file.''' 104 __metaclass__ = SourceMeta |
105 106 static_objs = {} 107 shared_objs = {} 108 |
|
105 def __init__(self, source, tags=None, add_tags=None): 106 if tags is None: 107 tags='gem5 lib' 108 if isinstance(tags, basestring): 109 tags = set([tags]) 110 if isinstance(add_tags, basestring): 111 add_tags = set([add_tags]) 112 if add_tags: --- 6 unchanged lines hidden (view full) --- 119 120 self.tnode = tnode 121 self.snode = tnode.srcnode() 122 123 for base in type(self).__mro__: 124 if issubclass(base, SourceFile): 125 base.all.append(self) 126 | 109 def __init__(self, source, tags=None, add_tags=None): 110 if tags is None: 111 tags='gem5 lib' 112 if isinstance(tags, basestring): 113 tags = set([tags]) 114 if isinstance(add_tags, basestring): 115 add_tags = set([add_tags]) 116 if add_tags: --- 6 unchanged lines hidden (view full) --- 123 124 self.tnode = tnode 125 self.snode = tnode.srcnode() 126 127 for base in type(self).__mro__: 128 if issubclass(base, SourceFile): 129 base.all.append(self) 130 |
131 def static(self, env): 132 key = (self.tnode, env['OBJSUFFIX']) 133 if not key in self.static_objs: 134 self.static_objs[key] = env.StaticObject(self.tnode) 135 return self.static_objs[key] 136 137 def shared(self, env): 138 key = (self.tnode, env['OBJSUFFIX']) 139 if not key in self.shared_objs: 140 self.shared_objs[key] = env.SharedObject(self.tnode) 141 return self.shared_objs[key] 142 |
|
127 @property 128 def filename(self): 129 return str(self.tnode) 130 131 @property 132 def dirname(self): 133 return dirname(self.filename) 134 --- 820 unchanged lines hidden (view full) --- 955 libname = 'gem5_' + label 956 exename = 'gem5.' + label 957 secondary_exename = 'm5.' + label 958 959 new_env = env.Clone(OBJSUFFIX=objsfx, SHOBJSUFFIX=objsfx + 's') 960 new_env.Label = label 961 new_env.Append(**kwargs) 962 | 143 @property 144 def filename(self): 145 return str(self.tnode) 146 147 @property 148 def dirname(self): 149 return dirname(self.filename) 150 --- 820 unchanged lines hidden (view full) --- 971 libname = 'gem5_' + label 972 exename = 'gem5.' + label 973 secondary_exename = 'm5.' + label 974 975 new_env = env.Clone(OBJSUFFIX=objsfx, SHOBJSUFFIX=objsfx + 's') 976 new_env.Label = label 977 new_env.Append(**kwargs) 978 |
963 make_static = lambda source: new_env.StaticObject(source.tnode) 964 make_shared = lambda source: new_env.SharedObject(source.tnode) 965 | |
966 lib_sources = Source.all.with_tag('gem5 lib') 967 968 # Without Python, leave out all Python content from the library 969 # builds. The option doesn't affect gem5 built as a program 970 if GetOption('without_python'): 971 lib_sources = lib_sources.without_tag('python') 972 973 static_objs = [] 974 shared_objs = [] 975 976 for s in lib_sources.with_tag(Source.ungrouped_tag): | 979 lib_sources = Source.all.with_tag('gem5 lib') 980 981 # Without Python, leave out all Python content from the library 982 # builds. The option doesn't affect gem5 built as a program 983 if GetOption('without_python'): 984 lib_sources = lib_sources.without_tag('python') 985 986 static_objs = [] 987 shared_objs = [] 988 989 for s in lib_sources.with_tag(Source.ungrouped_tag): |
977 static_objs.append(make_static(s)) 978 shared_objs.append(make_shared(s)) | 990 static_objs.append(s.static(new_env)) 991 shared_objs.append(s.shared(new_env)) |
979 980 for group in Source.source_groups: 981 srcs = lib_sources.with_tag(Source.link_group_tag(group)) 982 if not srcs: 983 continue 984 | 992 993 for group in Source.source_groups: 994 srcs = lib_sources.with_tag(Source.link_group_tag(group)) 995 if not srcs: 996 continue 997 |
985 group_static = [ make_static(s) for s in srcs ] 986 group_shared = [ make_shared(s) for s in srcs ] | 998 group_static = [ s.static(new_env) for s in srcs ] 999 group_shared = [ s.shared(new_env) for s in srcs ] |
987 988 # If partial linking is disabled, add these sources to the build 989 # directly, and short circuit this loop. 990 if disable_partial: 991 static_objs.extend(group_static) 992 shared_objs.extend(group_shared) 993 continue 994 --- 4 unchanged lines hidden (view full) --- 999 static_objs.extend(partial) 1000 1001 # Set up the shared partially linked objects. 1002 file_name = new_env.subst("${SHOBJPREFIX}lib${SHOBJSUFFIX}.partial") 1003 target = File(joinpath(group, file_name)) 1004 partial = env.PartialShared(target=target, source=group_shared) 1005 shared_objs.extend(partial) 1006 | 1000 1001 # If partial linking is disabled, add these sources to the build 1002 # directly, and short circuit this loop. 1003 if disable_partial: 1004 static_objs.extend(group_static) 1005 shared_objs.extend(group_shared) 1006 continue 1007 --- 4 unchanged lines hidden (view full) --- 1012 static_objs.extend(partial) 1013 1014 # Set up the shared partially linked objects. 1015 file_name = new_env.subst("${SHOBJPREFIX}lib${SHOBJSUFFIX}.partial") 1016 target = File(joinpath(group, file_name)) 1017 partial = env.PartialShared(target=target, source=group_shared) 1018 shared_objs.extend(partial) 1019 |
1007 static_date = make_static(date_source) | 1020 static_date = date_source.static(new_env) |
1008 new_env.Depends(static_date, static_objs) 1009 static_objs.extend(static_date) 1010 | 1021 new_env.Depends(static_date, static_objs) 1022 static_objs.extend(static_date) 1023 |
1011 shared_date = make_shared(date_source) | 1024 shared_date = date_source.shared(new_env) |
1012 new_env.Depends(shared_date, shared_objs) 1013 shared_objs.extend(shared_date) 1014 1015 # First make a library of everything but main() so other programs can 1016 # link against m5. 1017 static_lib = new_env.StaticLibrary(libname, static_objs) 1018 shared_lib = new_env.SharedLibrary(libname, shared_objs) 1019 1020 # Now link a stub with main() and the static library. | 1025 new_env.Depends(shared_date, shared_objs) 1026 shared_objs.extend(shared_date) 1027 1028 # First make a library of everything but main() so other programs can 1029 # link against m5. 1030 static_lib = new_env.StaticLibrary(libname, static_objs) 1031 shared_lib = new_env.SharedLibrary(libname, shared_objs) 1032 1033 # Now link a stub with main() and the static library. |
1021 main_objs = [ make_static(s) for s in Source.all.with_tag('main') ] | 1034 main_objs = [ s.static(new_env) for s in Source.all.with_tag('main') ] |
1022 1023 for test in UnitTest.all: 1024 test_sources = Source.all.with_tag(str(test.target)) | 1035 1036 for test in UnitTest.all: 1037 test_sources = Source.all.with_tag(str(test.target)) |
1025 test_objs = [ make_static(s) for s in test_sources ] | 1038 test_objs = [ s.static(new_env) for s in test_sources ] |
1026 if test.main: 1027 test_objs += main_objs 1028 path = 'unittest/%s.%s' % (test.target, label) 1029 new_env.Program(path, test_objs + static_objs) 1030 1031 gtest_env = new_env.Clone() 1032 gtest_env.Append(LIBS=gtest_env['GTEST_LIBS']) 1033 gtest_env.Append(CPPFLAGS=gtest_env['GTEST_CPPFLAGS']) 1034 for test in GTest.all: 1035 test_sources = Source.all.with_tag(str(test.target)) | 1039 if test.main: 1040 test_objs += main_objs 1041 path = 'unittest/%s.%s' % (test.target, label) 1042 new_env.Program(path, test_objs + static_objs) 1043 1044 gtest_env = new_env.Clone() 1045 gtest_env.Append(LIBS=gtest_env['GTEST_LIBS']) 1046 gtest_env.Append(CPPFLAGS=gtest_env['GTEST_CPPFLAGS']) 1047 for test in GTest.all: 1048 test_sources = Source.all.with_tag(str(test.target)) |
1036 test_objs = [ gtest_env.StaticObject(s.tnode) for s in test_sources ] | 1049 test_objs = [ s.static(gtest_env) for s in test_sources ] |
1037 gtest_env.Program(test.dir.File('%s.%s' % (test.target, label)), 1038 test_objs) 1039 1040 progname = exename 1041 if strip: 1042 progname += '.unstripped' 1043 1044 targets = new_env.Program(progname, main_objs + static_objs) --- 121 unchanged lines hidden --- | 1050 gtest_env.Program(test.dir.File('%s.%s' % (test.target, label)), 1051 test_objs) 1052 1053 progname = exename 1054 if strip: 1055 progname += '.unstripped' 1056 1057 targets = new_env.Program(progname, main_objs + static_objs) --- 121 unchanged lines hidden --- |