diff options
author | lberki <lberki@google.com> | 2018-04-11 00:33:42 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-04-11 00:35:23 -0700 |
commit | 8626623106fc0f9f83781990f7c235074926d196 (patch) | |
tree | 4aedd6318337c111b264c5e05249f0d138454df3 /src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java | |
parent | a65b419c25ae15fb51206f57ca47f9e7cfea0c83 (diff) |
Remove BuildConfiguration.Fragment#setupActionEnvironment().
This is accomplished by moving it to ConfiguredRuleClassProvider. This also suggests a neat way to get rid of logic in ShellConfiguration.Loader() by moving the determination of the shell executable, there, too, but not in this change.
RELNOTES: None.
PiperOrigin-RevId: 192411609
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java index b2b77314b3..2a0faf087b 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java @@ -123,6 +123,11 @@ public class BuildConfiguration { private static final Interner<ImmutableSortedMap<Class<? extends Fragment>, Fragment>> fragmentsInterner = BlazeInterners.newWeakInterner(); + /** Compute the default shell environment for actions from the command line options. */ + public interface ActionEnvironmentProvider { + ActionEnvironment getActionEnvironment(BuildOptions options); + } + /** * An interface for language-specific configurations. * @@ -157,14 +162,6 @@ public class BuildConfiguration { } /** - * Add items to the action environment. - * - * @param builder the map to add environment variables to - */ - public void setupActionEnvironment(Map<String, String> builder) { - } - - /** * Returns { 'option name': 'alternative default' } entries for options where the * "real default" should be something besides the default specified in the {@link Option} * declaration. @@ -1219,27 +1216,6 @@ public class BuildConfiguration { } /** - * Compute the shell environment, which, at configuration level, is a pair consisting of the - * statically set environment variables with their values and the set of environment variables to - * be inherited from the client environment. - */ - private ActionEnvironment setupActionEnvironment() { - // We make a copy first to remove duplicate entries; last one wins. - Map<String, String> actionEnv = new HashMap<>(); - // TODO(ulfjack): Remove all env variables from configuration fragments. - for (Fragment fragment : fragments.values()) { - fragment.setupActionEnvironment(actionEnv); - } - // Shell environment variables specified via options take precedence over the - // ones inherited from the fragments. In the long run, these fragments will - // be replaced by appropriate default rc files anyway. - for (Map.Entry<String, String> entry : options.actionEnvironment) { - actionEnv.put(entry.getKey(), entry.getValue()); - } - return ActionEnvironment.split(actionEnv); - } - - /** * Compute the test environment, which, at configuration level, is a pair consisting of the * statically set environment variables with their values and the set of environment variables to * be inherited from the client environment. @@ -1265,6 +1241,7 @@ public class BuildConfiguration { BuildOptions buildOptions, BuildOptions.OptionsDiffForReconstruction buildOptionsDiff, ImmutableSet<String> reservedActionMnemonics, + ActionEnvironment actionEnvironment, String repositoryName) { this.directories = directories; this.fragments = makeFragmentsMap(fragmentsMap); @@ -1314,7 +1291,7 @@ public class BuildConfiguration { OutputDirectory.MIDDLEMAN.getRoot( RepositoryName.MAIN, outputDirName, directories, mainRepositoryName); - this.actionEnv = setupActionEnvironment(); + this.actionEnv = actionEnvironment; this.testEnv = setupTestEnvironment(); @@ -1367,6 +1344,7 @@ public class BuildConfiguration { options, BuildOptions.diffForReconstruction(defaultBuildOptions, options), reservedActionMnemonics, + actionEnv, mainRepositoryName.strippedName()); return newConfig; } |