aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java
diff options
context:
space:
mode:
authorGravatar cpeyser <cpeyser@google.com>2018-06-08 13:23:22 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-08 13:24:50 -0700
commit6d0de4337482b65509374f672c06fd9af81eea18 (patch)
treea2bbdf42e99a33fdf6fe89fa87c3feb0e6eb7e6c /src/main/java/com/google/devtools/build/lib/rules/python/PyBinary.java
parentc34d6ee17570afc6e8b3942ab170d70758251bfd (diff)
Automated rollback of commit 6c87715b8ac6b32e636ba307440e2b7362b10a48.
RELNOTES:none PiperOrigin-RevId: 199840978
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.java40
1 files changed, 27 insertions, 13 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 b8c449529f..41e19c497c 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
@@ -24,7 +24,10 @@ import com.google.devtools.build.lib.analysis.RunfilesProvider;
import com.google.devtools.build.lib.analysis.RunfilesSupport;
import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
+import com.google.devtools.build.lib.rules.cpp.AbstractCcLinkParamsStore;
import com.google.devtools.build.lib.rules.cpp.CcCommon.CcFlagsSupplier;
+import com.google.devtools.build.lib.rules.cpp.CcLinkParams;
+import com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore;
import com.google.devtools.build.lib.rules.cpp.CcLinkingInfo;
import com.google.devtools.build.lib.syntax.Type;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -57,6 +60,7 @@ public abstract class PyBinary implements RuleConfiguredTargetFactory {
static RuleConfiguredTargetBuilder init(RuleContext ruleContext, PythonSemantics semantics,
PyCommon common) throws InterruptedException {
ruleContext.initConfigurationMakeVariableContext(new CcFlagsSupplier(ruleContext));
+ AbstractCcLinkParamsStore ccLinkParamsStore = initializeCcLinkParamStore(ruleContext);
List<Artifact> srcs = common.validateSrcs();
List<Artifact> allOutputs =
@@ -76,10 +80,9 @@ public abstract class PyBinary implements RuleConfiguredTargetFactory {
return null;
}
- CcLinkingInfo ccLinkingInfo =
- semantics.buildCcLinkingInfoProvider(ruleContext.getPrerequisites("deps", Mode.TARGET));
-
- Runfiles commonRunfiles = collectCommonRunfiles(ruleContext, common, semantics, ccLinkingInfo);
+ Artifact realExecutable =
+ semantics.createExecutable(ruleContext, common, ccLinkParamsStore, imports);
+ Runfiles commonRunfiles = collectCommonRunfiles(ruleContext, common, semantics);
Runfiles.Builder defaultRunfilesBuilder = new Runfiles.Builder(
ruleContext.getWorkspaceName(), ruleContext.getConfiguration().legacyExternalRunfiles())
@@ -121,22 +124,19 @@ public abstract class PyBinary implements RuleConfiguredTargetFactory {
semantics.postInitBinary(ruleContext, runfilesSupport, common);
- Artifact realExecutable =
- semantics.createExecutable(ruleContext, common, ccLinkingInfo, imports);
+ CcLinkingInfo.Builder ccLinkingInfoBuilder = CcLinkingInfo.Builder.create();
+ ccLinkingInfoBuilder.setCcLinkParamsStore(new CcLinkParamsStore(ccLinkParamsStore));
return builder
.setFilesToBuild(common.getFilesToBuild())
.add(RunfilesProvider.class, runfilesProvider)
.setRunfilesSupport(runfilesSupport, realExecutable)
+ .addNativeDeclaredProvider(ccLinkingInfoBuilder.build())
.add(PythonImportsProvider.class, new PythonImportsProvider(imports));
}
- private static Runfiles collectCommonRunfiles(
- RuleContext ruleContext,
- PyCommon common,
- PythonSemantics semantics,
- CcLinkingInfo ccLinkingInfo)
- throws InterruptedException {
+ private static Runfiles collectCommonRunfiles(RuleContext ruleContext, PyCommon common,
+ PythonSemantics semantics) {
Runfiles.Builder builder = new Runfiles.Builder(
ruleContext.getWorkspaceName(), ruleContext.getConfiguration().legacyExternalRunfiles());
builder.addArtifact(common.getExecutable());
@@ -152,7 +152,21 @@ public abstract class PyBinary implements RuleConfiguredTargetFactory {
|| ruleContext.attributes().get("legacy_create_init", Type.BOOLEAN)) {
builder.setEmptyFilesSupplier(PythonUtils.GET_INIT_PY_FILES);
}
- semantics.collectRunfilesForBinary(ruleContext, builder, common, ccLinkingInfo);
+ semantics.collectRunfilesForBinary(ruleContext, builder, common);
return builder.build();
}
+
+ private static AbstractCcLinkParamsStore initializeCcLinkParamStore(
+ final RuleContext ruleContext) {
+ return new AbstractCcLinkParamsStore() {
+ @Override
+ protected void collect(
+ CcLinkParams.Builder builder, boolean linkingStatically, boolean linkShared) {
+ builder.addTransitiveTargets(
+ ruleContext.getPrerequisites("deps", Mode.TARGET),
+ PyCcLinkParamsProvider.TO_LINK_PARAMS,
+ CcLinkParamsStore.TO_LINK_PARAMS);
+ }
+ };
+ }
}