bazel_0_4: add optional Nix-specific hacks
* Skip verifying checksums for already fetched packages. Needed for two-staged building in Nix: 1. Build a fixed derivation with `bazel fetch` (filtered out of non-reproducable bits). 2. Build an actual derivation which uses fetched dependencies (skipping checksums needed here because they depend on the build directory). * Don't clean environment variables for children processes. Needed for Nix compiler wrappers.
This commit is contained in:
parent
15bfc8c12a
commit
ba9cde1dd5
|
@ -1,4 +1,8 @@
|
|||
{ stdenv, fetchurl, jdk, zip, unzip, bash, makeWrapper, which }:
|
||||
{ stdenv, lib, fetchurl, jdk, zip, unzip, bash, makeWrapper, which
|
||||
# Always assume all markers valid (don't redownload dependencies).
|
||||
# Also, don't clean up environment variables.
|
||||
, enableNixHacks ? false
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
|
||||
|
@ -21,6 +25,8 @@ stdenv.mkDerivation rec {
|
|||
|
||||
sourceRoot = ".";
|
||||
|
||||
patches = lib.optional enableNixHacks ./nix-hacks.patch;
|
||||
|
||||
postPatch = ''
|
||||
for f in $(grep -l -r '#!/bin/bash'); do
|
||||
substituteInPlace "$f" --replace '#!/bin/bash' '#!${bash}/bin/bash'
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
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 eafa09fb5..d2d5e40e8 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
|
||||
@@ -287,21 +287,8 @@ public final class RepositoryDelegatorFunction implements SkyFunction {
|
||||
markerData.put(key, value);
|
||||
}
|
||||
}
|
||||
- boolean result = false;
|
||||
- if (markerRuleKey.equals(ruleKey)) {
|
||||
- result = handler.verifyMarkerData(rule, markerData, env);
|
||||
- if (env.valuesMissing()) {
|
||||
- return null;
|
||||
- }
|
||||
- }
|
||||
|
||||
- if (result) {
|
||||
- return new Fingerprint().addString(content).digestAndReset();
|
||||
- } else {
|
||||
- // So that we are in a consistent state if something happens while fetching the repository
|
||||
- markerPath.delete();
|
||||
- return null;
|
||||
- }
|
||||
+ return new Fingerprint().addString(content).digestAndReset();
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RepositoryFunctionException(e, Transience.TRANSIENT);
|
||||
diff --git a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
|
||||
index a7ebc8f7a..40f2049fa 100644
|
||||
--- a/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
|
||||
+++ b/src/main/java/com/google/devtools/build/lib/shell/JavaSubprocessFactory.java
|
||||
@@ -129,7 +129,6 @@ public class JavaSubprocessFactory implements SubprocessFactory {
|
||||
ProcessBuilder builder = new ProcessBuilder();
|
||||
builder.command(params.getArgv());
|
||||
if (params.getEnv() != null) {
|
||||
- builder.environment().clear();
|
||||
builder.environment().putAll(params.getEnv());
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/com/google/devtools/build/lib/worker/Worker.java b/src/main/java/com/google/devtools/build/lib/worker/Worker.java
|
||||
index 0268d1b2b..637364657 100644
|
||||
--- a/src/main/java/com/google/devtools/build/lib/worker/Worker.java
|
||||
+++ b/src/main/java/com/google/devtools/build/lib/worker/Worker.java
|
||||
@@ -77,7 +77,6 @@ class Worker {
|
||||
new ProcessBuilder(command)
|
||||
.directory(workDir.getPathFile())
|
||||
.redirectError(Redirect.appendTo(logFile.getPathFile()));
|
||||
- processBuilder.environment().clear();
|
||||
processBuilder.environment().putAll(workerKey.getEnv());
|
||||
|
||||
this.process = processBuilder.start();
|
Loading…
Reference in New Issue