diff options
author | Gabe Black <gabeblack@google.com> | 2020-01-29 23:44:54 -0800 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2020-02-01 09:25:07 +0000 |
commit | 017ffc268ae050e387cb71d7a4ee6eff85cca102 (patch) | |
tree | 9787d5fc0d7fa6de300abb491a1e674c138fb2f2 /src/SConscript | |
parent | 82f6d6e90f36e400db1f38eef5fe17430313458e (diff) | |
download | gem5-017ffc268ae050e387cb71d7a4ee6eff85cca102.tar.xz |
scons: Add a mechanism to append flags when building particular files.
This could be used to tweak settings for a particular file if it needed
special treatment. I plan to use this for protobuf files which generate
code that produce a warning in gcc 9 which turns into an error.
Change-Id: I53e2dac48cd68f0cc8ad9031d8484c5036d6e4a6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24923
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src/SConscript')
-rw-r--r-- | src/SConscript | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/SConscript b/src/SConscript index 76bbb9e65..d1b2cfcbb 100644 --- a/src/SConscript +++ b/src/SConscript @@ -154,7 +154,7 @@ class SourceFile(object): static_objs = {} shared_objs = {} - def __init__(self, source, tags=None, add_tags=None): + def __init__(self, source, tags=None, add_tags=None, append=None): if tags is None: tags='gem5 lib' if isinstance(tags, basestring): @@ -170,6 +170,8 @@ class SourceFile(object): add_tags = set(add_tags) self.tags |= add_tags + self.append = append + tnode = source if not isinstance(source, SCons.Node.FS.File): tnode = File(source) @@ -183,12 +185,18 @@ class SourceFile(object): def static(self, env): key = (self.tnode, env['OBJSUFFIX']) + if self.append: + env = env.Clone() + env.Append(**self.append) if not key in self.static_objs: self.static_objs[key] = env.StaticObject(self.tnode) return self.static_objs[key] def shared(self, env): key = (self.tnode, env['OBJSUFFIX']) + if self.append: + env = env.Clone() + env.Append(**self.append) if not key in self.shared_objs: self.shared_objs[key] = env.SharedObject(self.tnode) return self.shared_objs[key] @@ -315,9 +323,9 @@ class Source(SourceFile): self.tags.add(Source._current_group_tag) '''Add a c/c++ source file to the build''' - def __init__(self, source, tags=None, add_tags=None): + def __init__(self, source, tags=None, add_tags=None, append=None): '''specify the source file, and any tags''' - super(Source, self).__init__(source, tags, add_tags) + super(Source, self).__init__(source, tags, add_tags, append) self._add_link_group_tag() class PySource(SourceFile): |