diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
2 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java index 6e39a17a73..d6f143f873 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java @@ -36,6 +36,7 @@ import com.google.devtools.build.skyframe.SkyValue; import java.io.IOException; import java.util.Arrays; +import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.Nullable; @@ -61,6 +62,8 @@ public final class RepositoryDelegatorFunction implements SkyFunction { // command is a fetch. Remote repository lookups are only allowed during fetches. private final AtomicBoolean isFetch; + private Map<String, String> clientEnvironment; + public RepositoryDelegatorFunction( ImmutableMap<String, RepositoryFunction> handlers, @Nullable RepositoryFunction skylarkHandler, @@ -70,6 +73,10 @@ public final class RepositoryDelegatorFunction implements SkyFunction { this.isFetch = isFetch; } + public void setClientEnvironment(Map<String, String> clientEnvironment) { + this.clientEnvironment = clientEnvironment; + } + private void setupRepositoryRoot(Path repoRoot) throws RepositoryFunctionException { try { FileSystemUtils.deleteTree(repoRoot); @@ -107,6 +114,7 @@ public final class RepositoryDelegatorFunction implements SkyFunction { Path repoRoot = RepositoryFunction.getExternalRepositoryDirectory(directories).getRelative(rule.getName()); + handler.setClientEnvironment(clientEnvironment); if (handler.isLocal(rule)) { // Local repositories are always fetched because the operation is generally fast and they do // not depend on non-local data, so it does not make much sense to try to catch from across diff --git a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java index d3f5982fb1..043bd0f0df 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryFunction.java @@ -50,6 +50,7 @@ import com.google.devtools.build.skyframe.SkyValue; import java.io.IOException; import java.nio.charset.Charset; +import java.util.Map; import javax.annotation.Nullable; @@ -83,6 +84,8 @@ import javax.annotation.Nullable; */ public abstract class RepositoryFunction { + protected Map<String, String> clientEnvironment; + /** * Exception thrown when something goes wrong accessing a remote repository. * @@ -107,6 +110,7 @@ public abstract class RepositoryFunction { public RepositoryFunctionException(EvalException cause, Transience transience) { super(cause, transience); } + } /** @@ -417,6 +421,13 @@ public abstract class RepositoryFunction { } /** + * Sets up a mapping of environment variables to use. + */ + public void setClientEnvironment(Map<String, String> clientEnvironment) { + this.clientEnvironment = clientEnvironment; + } + + /** * Returns the RuleDefinition class for this type of repository. */ public abstract Class<? extends RuleDefinition> getRuleDefinition(); |