From: Gabe Black Date: Thu, 30 Jan 2020 07:44:54 +0000 (-0800) Subject: scons: Add a mechanism to append flags when building particular files. X-Git-Tag: v19.0.0.0~57 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=017ffc268ae050e387cb71d7a4ee6eff85cca102;p=gem5.git 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 Maintainer: Gabe Black Tested-by: kokoro --- 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):