From 01e8da5f0b9b247a00941e9ade1b0dfc9df050b6 Mon Sep 17 00:00:00 2001 From: Richard Levasseur Date: Wed, 12 Apr 2023 11:00:24 -0700 Subject: [PATCH] python: port PyWrapCcInfo to Starlark and enable it 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 --- .../build/lib/bazel/rules/BazelRuleClassProvider.java | 3 +-- .../build/lib/starlarkbuildapi/python/PyBootstrap.java | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java index a0060156292012..6150bbe11f91aa 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java @@ -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); diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyBootstrap.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyBootstrap.java index b3252d781ed504..fdc1e6bc0f537b 100644 --- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyBootstrap.java +++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/python/PyBootstrap.java @@ -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; @@ -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 @@ -79,7 +75,8 @@ public void addBindingsToBuilder(ImmutableMap.Builder 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",