-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
3e87c62
commit 1d62c67
Showing
15 changed files
with
372 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/google/devtools/build/lib/exec/apple/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package( | ||
default_visibility = ["//src:__subpackages__"], | ||
) | ||
|
||
java_library( | ||
name = "apple", | ||
srcs = glob(["*.java"]), | ||
deps = [ | ||
"//src/main/java/com/google/devtools/build/lib:build-base", | ||
"//src/main/java/com/google/devtools/build/lib:packages-internal", | ||
"//src/main/java/com/google/devtools/build/lib:shell", | ||
"//src/main/java/com/google/devtools/build/lib:util", | ||
"//src/main/java/com/google/devtools/build/lib:vfs", | ||
"//src/main/java/com/google/devtools/build/lib/exec/local", | ||
"//src/main/java/com/google/devtools/build/lib/rules/apple", | ||
"//third_party:guava", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "srcs", | ||
testonly = 0, # All srcs should be not test only, overwrite package default. | ||
srcs = glob(["**"]), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/com/google/devtools/build/lib/exec/local/LocalEnvProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.