summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Gross <grossag@vmware.com>2020-01-10 17:32:15 (GMT)
committerAdam Gross <grossag@vmware.com>2020-01-10 17:32:15 (GMT)
commit07590772d7a87fbfa29d77f64d23fd599b719485 (patch)
tree4361c843060413ded4415e13c73b66054890eadf
parent5df60c3f82a68acbc7f51769822a715259a9210d (diff)
downloadSCons-07590772d7a87fbfa29d77f64d23fd599b719485.zip
SCons-07590772d7a87fbfa29d77f64d23fd599b719485.tar.gz
SCons-07590772d7a87fbfa29d77f64d23fd599b719485.tar.bz2
Update scanning code to get it closer to desired state
Changes: 1. Remove repository code. 2. Only use env.WhereIs() if it's the first entry in a group. 3. Avoid duplicate sources if they are in another variable (e.g. LIBS).
-rw-r--r--src/engine/SCons/Action.py41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py
index ef99a4d..6edaa05 100644
--- a/src/engine/SCons/Action.py
+++ b/src/engine/SCons/Action.py
@@ -1013,11 +1013,12 @@ class CommandAction(_ActionAction):
# target, or executor to subst_list. This causes references to
# $SOURCES, $TARGETS, and all related variables to disappear.
from SCons.Subst import SUBST_SIG
- cmd_list = env.subst_list(self.cmd_list, SUBST_SIG)
+ cmd_list = env.subst_list(self.cmd_list, SUBST_SIG, conv=lambda x: x)
res = []
for cmd_line in cmd_list:
if cmd_line:
+ is_first_entry = True
for entry in cmd_line:
d = str(entry)
if not d.startswith(('&', '-', '/') if os.name == 'nt'
@@ -1026,25 +1027,27 @@ class CommandAction(_ActionAction):
if m:
d = m.group(1)
- # For now, only match files, not directories.
- p = os.path.abspath(d) if os.path.isfile(d) else \
- env.WhereIs(d)
- if p:
- res.append(env.fs.File(p))
- else:
- # Try to find the dependency in any source
- # repositories.
- #
- # TODO: I want to enumerate get_all_rdirs() and am
- # not sure whether I want to enumerate
- # srcdir_list(). srcdir_find_file() does both. Is
- # that bad? Should we instead change env.WhereIs()
- # to search in repositories too?
- n, _ = env.fs.Top.srcdir_find_file(d)
- if n and n not in target and n not in source:
- res.append(n)
+ if d:
+ # Resolve the first entry in the command string using
+ # PATH, which env.WhereIs() looks in.
+ # For now, only match files, not directories.
+ p = os.path.abspath(d) if os.path.isfile(d) else None
+ if not p and is_first_entry:
+ p = env.WhereIs(d)
- return res
+ if p:
+ res.append(env.fs.File(p))
+
+ is_first_entry = False
+ else:
+ is_first_entry = d == '&&'
+
+ # Despite not providing source and target to env.subst() above, we
+ # can still end up with sources in this list. For example, files in
+ # LIBS will still resolve in env.subst(). This won't result in
+ # circular dependencies, but it causes problems with cache signatures
+ # changing between full and incremental builds.
+ return [r for r in res if r not in target and r not in source]
class CommandGeneratorAction(ActionBase):