aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Dmitry Lomov <dslomov@google.com>2016-06-21 12:04:34 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-06-21 12:24:19 +0000
commita148b4c25a7e343eac6a9a972f482711f8bef944 (patch)
treeda63f4fb5871d974096a2f37d432af393c2a45ba /src/main/java/com
parent83131623f73bde31ba51f4ceda7fa601a5b122c3 (diff)
Disable runfiles on Windows.
This adds a new configuration option that allows disabling the creation of symlink forest for runfiles. On Windows, symlink forest is disabled by default; only the runfiles manifest is created. For shell tests, a function 'rlocation' is provided that converts from runfiles location to a real location. Work towards #1212. -- MOS_MIGRATED_REVID=125439553
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/RunfilesSupport.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/SymlinkTreeAction.java13
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/SymlinkTreeActionContext.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/config/BuildConfiguration.java19
-rw-r--r--src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeHelper.java24
-rw-r--r--src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeStrategy.java10
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/NativeLibs.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java13
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/test/TestRunnerAction.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/test/TestStrategy.java23
10 files changed, 92 insertions, 23 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RunfilesSupport.java b/src/main/java/com/google/devtools/build/lib/analysis/RunfilesSupport.java
index 98540d248a..61ac369f20 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/RunfilesSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/RunfilesSupport.java
@@ -312,7 +312,8 @@ public final class RunfilesSupport {
outputManifest,
/*filesetTree=*/ false,
config.getShExecutable(),
- config.getLocalShellEnvironment()));
+ config.getLocalShellEnvironment(),
+ config.runfilesEnabled()));
return outputManifest;
}
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/SymlinkTreeAction.java b/src/main/java/com/google/devtools/build/lib/analysis/SymlinkTreeAction.java
index 5ebe26f0eb..ef2fde933e 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/SymlinkTreeAction.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/SymlinkTreeAction.java
@@ -43,11 +43,11 @@ public final class SymlinkTreeAction extends AbstractAction {
private final boolean filesetTree;
private final PathFragment shExecutable;
private final ImmutableMap<String, String> shellEnviroment;
+ private final boolean enableRunfiles;
/**
* Creates SymlinkTreeAction instance.
- *
- * @param owner action owner
+ * @param owner action owner
* @param inputManifest the input runfiles manifest
* @param artifactMiddleman the middleman artifact representing all the files the symlinks
* point to (on Windows we need to know if the target of a "symlink" is
@@ -56,7 +56,7 @@ public final class SymlinkTreeAction extends AbstractAction {
* (must have "MANIFEST" base name). Symlink tree root
* will be set to the artifact's parent directory.
* @param filesetTree true if this is fileset symlink tree,
- * false if this is a runfiles symlink tree.
+ * @param enableRunfiles true is the actual symlink tree needs to be created.
*/
public SymlinkTreeAction(
ActionOwner owner,
@@ -65,7 +65,8 @@ public final class SymlinkTreeAction extends AbstractAction {
Artifact outputManifest,
boolean filesetTree,
PathFragment shExecutable,
- ImmutableMap<String, String> shellEnvironment) {
+ ImmutableMap<String, String> shellEnvironment,
+ boolean enableRunfiles) {
super(owner, computeInputs(inputManifest, artifactMiddleman), ImmutableList.of(outputManifest));
Preconditions.checkArgument(outputManifest.getPath().getBaseName().equals("MANIFEST"));
this.inputManifest = inputManifest;
@@ -73,6 +74,7 @@ public final class SymlinkTreeAction extends AbstractAction {
this.filesetTree = filesetTree;
this.shExecutable = shExecutable;
this.shellEnviroment = shellEnvironment;
+ this.enableRunfiles = enableRunfiles;
}
private static ImmutableList<Artifact> computeInputs(
@@ -129,6 +131,7 @@ public final class SymlinkTreeAction extends AbstractAction {
actionExecutionContext
.getExecutor()
.getContext(SymlinkTreeActionContext.class)
- .createSymlinks(this, actionExecutionContext, shExecutable, shellEnviroment);
+ .createSymlinks(
+ this, actionExecutionContext, shExecutable, shellEnviroment, enableRunfiles);
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/SymlinkTreeActionContext.java b/src/main/java/com/google/devtools/build/lib/analysis/SymlinkTreeActionContext.java
index fa9182abd2..11c141738b 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/SymlinkTreeActionContext.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/SymlinkTreeActionContext.java
@@ -31,6 +31,7 @@ public interface SymlinkTreeActionContext extends ActionContext {
SymlinkTreeAction action,
ActionExecutionContext actionExecutionContext,
PathFragment shExecutable,
- ImmutableMap<String, String> shellEnvironment)
+ ImmutableMap<String, String> shellEnvironment,
+ boolean enableRunfiles)
throws ActionExecutionException, InterruptedException;
}
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 c37bac45f5..0499743422 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
@@ -855,6 +855,14 @@ public final class BuildConfiguration {
+ "static globally defined ones")
public boolean useDynamicConfigurations;
+ @Option(
+ name = "experimental_enable_runfiles",
+ defaultValue = "auto",
+ category = "undocumented",
+ help = "Enable runfiles; off on Windows, on on other platforms"
+ )
+ public TriState enableRunfiles;
+
@Override
public FragmentOptions getHost(boolean fallback) {
Options host = (Options) getDefault();
@@ -2350,6 +2358,17 @@ public final class BuildConfiguration {
return options.cpu;
}
+ public boolean runfilesEnabled() {
+ switch (options.enableRunfiles) {
+ case YES:
+ return true;
+ case NO:
+ return false;
+ default:
+ return OS.getCurrent() != OS.WINDOWS;
+ }
+ }
+
/**
* Returns true if the configuration performs static linking.
*/
diff --git a/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeHelper.java b/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeHelper.java
index 0e47c2bd81..6a53d7daf0 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeHelper.java
@@ -89,7 +89,9 @@ public final class SymlinkTreeHelper {
*/
public void createSymlinksUsingCommand(Path execRoot,
BuildConfiguration config, BinTools binTools) throws CommandException {
- List<String> argv = getSpawnArgumentList(execRoot, binTools, config.getShExecutable());
+ List<String> argv =
+ getSpawnArgumentList(
+ execRoot, binTools, config.getShExecutable(), config.runfilesEnabled());
CommandBuilder builder = new CommandBuilder();
builder.addArgs(argv);
@@ -105,19 +107,25 @@ public final class SymlinkTreeHelper {
* block for undetermined period of time. If it is interrupted during
* that wait, ExecException will be thrown but interrupted bit will be
* preserved.
- * @param action action instance that requested symlink tree creation
+ * @param action action instance that requested symlink tree creation
* @param actionExecutionContext Services that are in the scope of the action.
* @param shExecutable
+ * @param enableRunfiles
*/
public void createSymlinks(
AbstractAction action,
ActionExecutionContext actionExecutionContext,
BinTools binTools,
PathFragment shExecutable,
- ImmutableMap<String, String> shellEnvironment)
+ ImmutableMap<String, String> shellEnvironment,
+ boolean enableRunfiles)
throws ExecException, InterruptedException {
- List<String> args = getSpawnArgumentList(
- actionExecutionContext.getExecutor().getExecRoot(), binTools, shExecutable);
+ List<String> args =
+ getSpawnArgumentList(
+ actionExecutionContext.getExecutor().getExecRoot(),
+ binTools,
+ shExecutable,
+ enableRunfiles);
try (ResourceHandle handle =
ResourceManager.instance().acquireResources(action, RESOURCE_SET)) {
actionExecutionContext.getExecutor().getSpawnActionContext(action.getMnemonic()).exec(
@@ -130,7 +138,7 @@ public final class SymlinkTreeHelper {
* Returns the complete argument list build-runfiles has to be called with.
*/
private List<String> getSpawnArgumentList(
- Path execRoot, BinTools binTools, PathFragment shExecutable) {
+ Path execRoot, BinTools binTools, PathFragment shExecutable, boolean enableRunfiles) {
PathFragment path = binTools.getExecPath(BUILD_RUNFILES);
Preconditions.checkNotNull(path, BUILD_RUNFILES + " not found in embedded tools");
@@ -156,6 +164,10 @@ public final class SymlinkTreeHelper {
args.add("--windows_compatible");
}
+ if (!enableRunfiles) {
+ args.add("--manifest_only");
+ }
+
args.add(inputManifest.getPathString());
args.add(symlinkTreeRoot.getPathString());
diff --git a/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeStrategy.java
index e34a6b4bef..dc54714cd1 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/SymlinkTreeStrategy.java
@@ -48,7 +48,8 @@ public final class SymlinkTreeStrategy implements SymlinkTreeActionContext {
SymlinkTreeAction action,
ActionExecutionContext actionExecutionContext,
PathFragment shExecutable,
- ImmutableMap<String, String> shellEnvironment)
+ ImmutableMap<String, String> shellEnvironment,
+ boolean enableRunfiles)
throws ActionExecutionException, InterruptedException {
Executor executor = actionExecutionContext.getExecutor();
try (AutoProfiler p =
@@ -64,7 +65,12 @@ public final class SymlinkTreeStrategy implements SymlinkTreeActionContext {
action.isFilesetTree(), helper.getSymlinkTreeRoot());
} else {
helper.createSymlinks(
- action, actionExecutionContext, binTools, shExecutable, shellEnvironment);
+ action,
+ actionExecutionContext,
+ binTools,
+ shExecutable,
+ shellEnvironment,
+ enableRunfiles);
}
} catch (ExecException e) {
throw e.toActionExecutionException(
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/NativeLibs.java b/src/main/java/com/google/devtools/build/lib/rules/android/NativeLibs.java
index 3790799542..fc736ae5e1 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/NativeLibs.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/NativeLibs.java
@@ -169,7 +169,8 @@ public final class NativeLibs {
outputManifest,
false,
ruleContext.getConfiguration().getShExecutable(),
- ruleContext.getConfiguration().getLocalShellEnvironment()));
+ ruleContext.getConfiguration().getLocalShellEnvironment(),
+ ruleContext.getConfiguration().runfilesEnabled()));
return outputManifest;
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java b/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java
index 72ff4e80d8..2dd01c3bcd 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java
@@ -71,8 +71,14 @@ public class StandaloneTestStrategy extends TestStrategy {
throws ExecException, InterruptedException {
Path runfilesDir = null;
try {
- runfilesDir = TestStrategy.getLocalRunfilesDirectory(action, actionExecutionContext, binTools,
- action.getShExecutable(), action.getLocalShellEnvironment());
+ runfilesDir =
+ TestStrategy.getLocalRunfilesDirectory(
+ action,
+ actionExecutionContext,
+ binTools,
+ action.getShExecutable(),
+ action.getLocalShellEnvironment(),
+ action.isEnableRunfiles());
} catch (ExecException e) {
throw new TestExecException(e.getMessage());
}
@@ -161,6 +167,9 @@ public class StandaloneTestStrategy extends TestStrategy {
vars.put("TEST_TMPDIR", tmpDir.getPathString());
vars.put("TEST_WORKSPACE", action.getRunfilesPrefix());
vars.put("XML_OUTPUT_FILE", resolvedPaths.getXmlOutputPath().getPathString());
+ if (!action.isEnableRunfiles()) {
+ vars.put("RUNFILES_MANIFEST_ONLY", "1");
+ }
return vars;
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/TestRunnerAction.java b/src/main/java/com/google/devtools/build/lib/rules/test/TestRunnerAction.java
index 687d6228a4..473ec92069 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/test/TestRunnerAction.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/test/TestRunnerAction.java
@@ -562,6 +562,10 @@ public class TestRunnerAction extends AbstractAction implements NotifyOnActionCa
return configuration.getLocalShellEnvironment();
}
+ public boolean isEnableRunfiles() {
+ return configuration.runfilesEnabled();
+ }
+
/**
* The same set of paths as the parent test action, resolved against a given exec root.
*/
diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/TestStrategy.java b/src/main/java/com/google/devtools/build/lib/rules/test/TestStrategy.java
index e1bd9dee9f..68cefe19ee 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/test/TestStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/test/TestStrategy.java
@@ -357,7 +357,8 @@ public abstract class TestStrategy implements TestActionContext {
ActionExecutionContext actionExecutionContext,
BinTools binTools,
PathFragment shExecutable,
- ImmutableMap<String, String> shellEnvironment)
+ ImmutableMap<String, String> shellEnvironment,
+ boolean enableRunfiles)
throws ExecException, InterruptedException {
TestTargetExecutionSettings execSettings = testAction.getExecutionSettings();
@@ -380,8 +381,14 @@ public abstract class TestStrategy implements TestActionContext {
long startTime = Profiler.nanoTimeMaybe();
synchronized (execSettings.getInputManifest()) {
Profiler.instance().logSimpleTask(startTime, ProfilerTask.WAIT, testAction);
- updateLocalRunfilesDirectory(testAction, runfilesDir, actionExecutionContext, binTools,
- shExecutable, shellEnvironment);
+ updateLocalRunfilesDirectory(
+ testAction,
+ runfilesDir,
+ actionExecutionContext,
+ binTools,
+ shExecutable,
+ shellEnvironment,
+ enableRunfiles);
}
return runfilesDir;
@@ -399,7 +406,8 @@ public abstract class TestStrategy implements TestActionContext {
ActionExecutionContext actionExecutionContext,
BinTools binTools,
PathFragment shExecutable,
- ImmutableMap<String, String> shellEnvironment)
+ ImmutableMap<String, String> shellEnvironment,
+ boolean enableRunfiles)
throws ExecException, InterruptedException {
Executor executor = actionExecutionContext.getExecutor();
@@ -423,7 +431,12 @@ public abstract class TestStrategy implements TestActionContext {
runfilesDir.relativeTo(executor.getExecRoot()), /* filesetTree= */
false)
.createSymlinks(
- testAction, actionExecutionContext, binTools, shExecutable, shellEnvironment);
+ testAction,
+ actionExecutionContext,
+ binTools,
+ shExecutable,
+ shellEnvironment,
+ enableRunfiles);
executor.getEventHandler().handle(Event.progress(testAction.getProgressMessage()));
}