diff options
Diffstat (limited to 'src/main/java/com')
3 files changed, 45 insertions, 0 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 07a1213bca..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 @@ -164,6 +164,7 @@ public abstract class PyBinary implements RuleConfiguredTargetFactory { CcLinkParams.Builder builder, boolean linkingStatically, boolean linkShared) { builder.addTransitiveTargets( ruleContext.getPrerequisites("deps", Mode.TARGET), + PyCcLinkParamsProvider.TO_LINK_PARAMS, CcLinkParamsStore.TO_LINK_PARAMS); } }; diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PyCcLinkParamsProvider.java b/src/main/java/com/google/devtools/build/lib/rules/python/PyCcLinkParamsProvider.java new file mode 100644 index 0000000000..8a270ac306 --- /dev/null +++ b/src/main/java/com/google/devtools/build/lib/rules/python/PyCcLinkParamsProvider.java @@ -0,0 +1,43 @@ +// Copyright 2014 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package com.google.devtools.build.lib.rules.python; + +import com.google.common.base.Function; +import com.google.devtools.build.lib.analysis.TransitiveInfoCollection; +import com.google.devtools.build.lib.analysis.TransitiveInfoProvider; +import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; +import com.google.devtools.build.lib.rules.cpp.AbstractCcLinkParamsStore; +import com.google.devtools.build.lib.rules.cpp.CcLinkParamsStore; +import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; + +/** A target that provides C++ libraries to be linked into Python targets. */ +@Immutable +@AutoCodec +public final class PyCcLinkParamsProvider implements TransitiveInfoProvider { + private final CcLinkParamsStore store; + + public PyCcLinkParamsProvider(CcLinkParamsStore store) { + this.store = store; + } + + public AbstractCcLinkParamsStore getLinkParams() { + return store; + } + + public static final Function<TransitiveInfoCollection, AbstractCcLinkParamsStore> TO_LINK_PARAMS = + input -> { + PyCcLinkParamsProvider provider = input.getProvider(PyCcLinkParamsProvider.class); + return provider == null ? null : provider.getLinkParams(); + }; +} diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PyLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/python/PyLibrary.java index 97060f345c..e40a1ab978 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/python/PyLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/python/PyLibrary.java @@ -71,6 +71,7 @@ public abstract class PyLibrary implements RuleConfiguredTargetFactory { CcLinkParams.Builder builder, boolean linkingStatically, boolean linkShared) { builder.addTransitiveTargets( ruleContext.getPrerequisites("deps", Mode.TARGET), + PyCcLinkParamsProvider.TO_LINK_PARAMS, CcLinkParamsStore.TO_LINK_PARAMS); } }; |