aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java
diff options
context:
space:
mode:
authorGravatar Benjamin Peterson <bp@benjamin.pe>2017-09-26 08:15:27 -0400
committerGravatar John Cater <jcater@google.com>2017-09-26 09:30:25 -0400
commit3b0bcd9f550cdcd37c668651e552a4dff70033d7 (patch)
tree0d2093bdd10cd57adc1ca01671f3c0ec04b71d3b /src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java
parente69bcce4f81b0a2380fcc30ae355a1eb02f6cea1 (diff)
Add an option to control building of transitive py_binary runfiles trees. ,
) Currently, "bazel build :script" constructs the bazel-bin/python-prog.runfiles tree. We'd like to do anyway with this behavior but doing so is a backwards-incompatible change. To facilitate a transition, this CL adds an option --experimental_build_transitive_python_runfiles to control the behavior. In the example above, "bazel build --noexperimental_build_transitive_python_runfiles :script" won't construct bazel-bin/python-prog.runfiles. Change-Id: If4d5a84c956a0bbac9067dcf38a00e5732c450f2 PiperOrigin-RevId: 170038245
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java b/src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java
index 95bcd8c31e..b0dd535c95 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java
@@ -98,14 +98,21 @@ public abstract class PyBinary implements RuleConfiguredTargetFactory {
return null;
}
- // Only include common runfiles and middleman. Default runfiles added by semantics are
- // excluded. The middleman is necessary to ensure the runfiles trees are generated for all
- // dependency binaries.
- Runfiles dataRunfiles = new Runfiles.Builder(
- ruleContext.getWorkspaceName(), ruleContext.getConfiguration().legacyExternalRunfiles())
- .merge(commonRunfiles)
- .addArtifact(runfilesSupport.getRunfilesMiddleman())
- .build();
+ Runfiles dataRunfiles;
+ if (ruleContext.getFragment(PythonConfiguration.class).buildTransitiveRunfilesTrees()) {
+ // Only include common runfiles and middleman. Default runfiles added by semantics are
+ // excluded. The middleman is necessary to ensure the runfiles trees are generated for all
+ // dependency binaries.
+ dataRunfiles =
+ new Runfiles.Builder(
+ ruleContext.getWorkspaceName(),
+ ruleContext.getConfiguration().legacyExternalRunfiles())
+ .merge(commonRunfiles)
+ .addArtifact(runfilesSupport.getRunfilesMiddleman())
+ .build();
+ } else {
+ dataRunfiles = commonRunfiles;
+ }
RunfilesProvider runfilesProvider = RunfilesProvider.withData(defaultRunfiles, dataRunfiles);