scons: Create a Gem5 subclass of the Executable class.
The Executable class was used both for the generic gem5 target, and as a base for the GTest binaries, the systemc test binaries, etc. Unfortunately, the gem5 binary needs to include src/base/date.cc, and to ensure that that file is up to date, it needs to depend on all the other object files. No other binary should have that, but it was included by inheritance. Also, depending on the object file works well when those object files and the date.cc object file are all part of the same binary and not mixed and matched. That is not true for the GTest binaries for instance, and so building a unit test would also build all the other unit test object files because they are dependencies for date.to, date.tdo, etc. If they already exist, then they would satisfy the dependency and not be rebuilt. Change-Id: Ia9cdddc5b2593678e714c08655eb440d7f5b5d1f Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51088 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
This commit is contained in:
@@ -307,10 +307,7 @@ class Executable(TopLevelBase):
|
||||
env['BIN_RPATH_PREFIX'] = os.path.relpath(
|
||||
env['BUILDDIR'], self.path(env).dir.abspath)
|
||||
|
||||
date_obj = env.StaticObject(date_source)
|
||||
env.Depends(date_obj, objs)
|
||||
|
||||
executable = env.Program(self.path(env).abspath, [date_obj, objs])[0]
|
||||
executable = env.Program(self.path(env).abspath, objs)[0]
|
||||
|
||||
if sys.platform == 'sunos5':
|
||||
cmd = 'cp $SOURCE $TARGET; strip $TARGET'
|
||||
@@ -321,6 +318,19 @@ class Executable(TopLevelBase):
|
||||
|
||||
return [executable, stripped]
|
||||
|
||||
class Gem5(Executable):
|
||||
'''Base class for the main gem5 executable.'''
|
||||
|
||||
def declare(self, env):
|
||||
objs = self.srcs_to_objs(env, self.sources(env))
|
||||
|
||||
date_obj = env.StaticObject(date_source)
|
||||
env.Depends(date_obj, objs)
|
||||
objs.append(date_obj)
|
||||
|
||||
return super(Gem5, self).declare(env, objs)
|
||||
|
||||
|
||||
class GTest(Executable):
|
||||
'''Create a unit test based on the google test framework.'''
|
||||
all = []
|
||||
@@ -990,7 +1000,7 @@ if GetOption('without_python'):
|
||||
StaticLib(lib_name, lib_filter)
|
||||
SharedLib(lib_name, lib_filter)
|
||||
|
||||
Executable('gem5', with_any_tags('gem5 lib', 'main'))
|
||||
Gem5('gem5', with_any_tags('gem5 lib', 'main'))
|
||||
|
||||
|
||||
# Function to create a new build environment as clone of current
|
||||
|
||||
Reference in New Issue
Block a user