diff options
author | ulfjack <ulfjack@google.com> | 2017-06-13 12:56:07 +0200 |
---|---|---|
committer | Yun Peng <pcloudy@google.com> | 2017-06-13 17:13:17 +0200 |
commit | 1d62c67a2d6d6eccf415ad5647d860d08f4c5966 (patch) | |
tree | 23eeec1aa45038fc5693b09c8d2556df5f92aa59 /src/main/java/com/google/devtools/build/lib/exec/local/LocalEnvProvider.java | |
parent | 3e87c626ed76536420aa06e4c258209b32bb76e0 (diff) |
Extract the MacOS/XCode env rewrite logic into lib.exec.apple
Also add an interface to allow injecting that logic into LocalSpawnRunner; this
is in preparation for rewriting StandaloneSpawnStrategy to use
LocalSpawnRunner.
At the same time, this reduces the dependencies from exec / standalone to
rules.apple, which is a prerequisite for micro-Bazel.
There's a small semantic change hidden here - we now only set the new
XCodeLocalEnvProvider if we're actually running on Darwin, so we no longer
fail execution on non-Darwin platforms if XCODE_VERSION_OVERRIDE or
APPLE_SDK_VERSION_OVERRIDE is set. As a result, I moved the corresponding test
from StandaloneSpawnStrategyTest to the new XCodeLocalEnvProviderTest.
While I'm at it, also open source DottedVersionTest and CacheManagerTest.
PiperOrigin-RevId: 158829077
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/exec/local/LocalEnvProvider.java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/exec/local/LocalEnvProvider.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/exec/local/LocalEnvProvider.java b/src/main/java/com/google/devtools/build/lib/exec/local/LocalEnvProvider.java new file mode 100644 index 0000000000..52610761c5 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/exec/local/LocalEnvProvider.java @@ -0,0 +1,36 @@ +// Copyright 2017 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.lib.exec.local; + +import com.google.devtools.build.lib.vfs.Path; +import java.io.IOException; +import java.util.Map; + +/** + * Allows just-in-time rewriting of the environment used for local actions. Do not use! This class + * probably should not exist, but is currently necessary for our local MacOS support. + */ +public interface LocalEnvProvider { + public static final LocalEnvProvider UNMODIFIED = new LocalEnvProvider() { + @Override + public Map<String, String> rewriteLocalEnv( + Map<String, String> env, Path execRoot, String productName) throws IOException { + return env; + } + }; + + /** Rewrites the environment if necessary. */ + Map<String, String> rewriteLocalEnv(Map<String, String> env, Path execRoot, String productName) + throws IOException; +} |