Skip to content

Commit

Permalink
python: port PyWrapCcInfo to Starlark and enable it
Browse files Browse the repository at this point in the history
Because providers are based on identity, and there are Java tests that need
to reference the provider, it's hard to split up the changes, so it's all
in a single change.

The Java class is kept to make usage by the Java tests easier; it isn't
actually used outside of tests.

Work towards #15897

PiperOrigin-RevId: 523748496
Change-Id: I1f5e9316bb3c4aed6c36fbd317914e4deea26f61
  • Loading branch information
rickeylev authored and copybara-github committed Apr 12, 2023
1 parent 6dbac49 commit 01e8da5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,7 @@ public void init(ConfiguredRuleClassProvider.Builder builder) {
new PyBootstrap(
PyInfo.PROVIDER,
PyStarlarkTransitions.INSTANCE,
new GoogleLegacyStubs.PyWrapCcHelper(),
new GoogleLegacyStubs.PyWrapCcInfoProvider()));
new GoogleLegacyStubs.PyWrapCcHelper()));

builder.addSymlinkDefinition(PySymlink.PY2);
builder.addSymlinkDefinition(PySymlink.PY3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.devtools.build.lib.starlarkbuildapi.core.Bootstrap;
import com.google.devtools.build.lib.starlarkbuildapi.core.ContextAndFlagGuardedValue;
import com.google.devtools.build.lib.starlarkbuildapi.cpp.PyWrapCcHelperApi;
import com.google.devtools.build.lib.starlarkbuildapi.cpp.PyWrapCcInfoApi;
import com.google.devtools.build.lib.starlarkbuildapi.python.PyInfoApi.PyInfoProviderApi;
import com.google.devtools.build.lib.starlarkbuildapi.stubs.ProviderStub;
import net.starlark.java.eval.FlagGuardedValue;
Expand All @@ -38,17 +37,14 @@ public class PyBootstrap implements Bootstrap {
private final PyInfoProviderApi pyInfoProviderApi;
private final PyStarlarkTransitionsApi pyStarlarkTransitionsApi;
private final PyWrapCcHelperApi<?, ?, ?, ?, ?, ?, ?, ?, ?> pyWrapCcHelper;
private final PyWrapCcInfoApi.Provider pyWrapCcInfoProvider;

public PyBootstrap(
PyInfoProviderApi pyInfoProviderApi,
PyStarlarkTransitionsApi pyStarlarkTransitionsApi,
PyWrapCcHelperApi<?, ?, ?, ?, ?, ?, ?, ?, ?> pyWrapCcHelper,
PyWrapCcInfoApi.Provider pyWrapCcInfoProvider) {
PyWrapCcHelperApi<?, ?, ?, ?, ?, ?, ?, ?, ?> pyWrapCcHelper) {
this.pyInfoProviderApi = pyInfoProviderApi;
this.pyStarlarkTransitionsApi = pyStarlarkTransitionsApi;
this.pyWrapCcHelper = pyWrapCcHelper;
this.pyWrapCcInfoProvider = pyWrapCcInfoProvider;
}

@Override
Expand Down Expand Up @@ -79,7 +75,8 @@ public void addBindingsToBuilder(ImmutableMap.Builder<String, Object> builder) {
"PyWrapCcInfo",
ContextAndFlagGuardedValue.onlyInAllowedReposOrWhenIncompatibleFlagIsFalse(
BuildLanguageOptions.INCOMPATIBLE_STOP_EXPORTING_LANGUAGE_MODULES,
pyWrapCcInfoProvider,
// Workaround for https://github.com/bazelbuild/bazel/issues/17713
new ProviderStub(),
allowedRepositories));
builder.put(
"PyCcLinkParamsProvider",
Expand Down

0 comments on commit 01e8da5

Please sign in to comment.