diff options
author | 2018-05-17 07:46:47 -0700 | |
---|---|---|
committer | 2018-05-17 07:48:10 -0700 | |
commit | d1ec570fb6ef8d142b0cf381df008c0f209b57aa (patch) | |
tree | ec84868f78a2080556f1e6b56149bff4d283b166 /src/main/java/com/google/devtools/build/lib/rules | |
parent | a61b53a8ef65881c6c4a69f16edc52ed7f1662a3 (diff) |
Rename CommandAction.getEnvironment, add AbstractAction.getEnvironment
This is a cleanup to clarify the code.
1. The getEnvironment method in the CommandAction interface does not have
access to the clientEnv, so it's return value is necessarily incomplete.
Rename to getIncompleteEnvironmentForTesting.
2. Add a final getEnvironment method to AbstractAction, which returns the
ActionEnvironment, which is intended to be a complete description of the
intended final environment of the action (technically, of any spawn running
within the action). This is not currently used, but is provided to prevent
action subclasses to add such a method (it may be used in the future).
PiperOrigin-RevId: 196991091
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java | 4 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkAction.java | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java index 3f8045a538..aa89b5ae4e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java @@ -746,7 +746,7 @@ public class CppCompileAction extends AbstractAction @Override @VisibleForTesting - public ImmutableMap<String, String> getEnvironment() { + public ImmutableMap<String, String> getIncompleteEnvironmentForTesting() { return getEnvironment(ImmutableMap.of()); } @@ -793,7 +793,7 @@ public class CppCompileAction extends AbstractAction Artifact.toExecPaths(ccCompilationContext.getDeclaredIncludeSrcs())); } // TODO(ulfjack): Extra actions currently ignore the client environment. - for (Map.Entry<String, String> envVariable : getEnvironment().entrySet()) { + for (Map.Entry<String, String> envVariable : getIncompleteEnvironmentForTesting().entrySet()) { info.addVariable( EnvironmentVariable.newBuilder() .setName(envVariable.getKey()) diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkAction.java index d18aca00e7..4547dbe35e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkAction.java @@ -210,7 +210,7 @@ public final class CppLinkAction extends AbstractAction @Override @VisibleForTesting - public ImmutableMap<String, String> getEnvironment() { + public ImmutableMap<String, String> getIncompleteEnvironmentForTesting() { return getEnvironment(ImmutableMap.of()); } |