From 49ea6928f0d562a21ff98cfef18528c5dcff4689 Mon Sep 17 00:00:00 2001 From: Luca Di Grazia Date: Sun, 4 Sep 2022 20:48:21 +0200 Subject: [PATCH] Add cc_common.action_is_enabled This will help users who want to use CROSSTOOL with other than C++ rules, plus it will enable users to make rules forward compatible for incompatible CROSSTOOL changes. Progress towards https://github.com/bazelbuild/bazel/issues/5883 RELNOTES: None. PiperOrigin-RevId: 228216650 --- .../build/lib/rules/cpp/CcModule.java | 12 +++--------- .../lib/skylarkbuildapi/cpp/CcModuleApi.java | 9 +++------ .../skydoc/fakebuildapi/cpp/FakeCcModule.java | 8 ++------ .../lib/rules/cpp/SkylarkCcCommonTest.java | 19 ++----------------- 4 files changed, 10 insertions(+), 38 deletions(-) diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java index 14a6345163e..2d0e4cf5852 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcModule.java @@ -82,13 +82,7 @@ /** A module that contains Skylark utilities for C++ support. */ public class CcModule - implements CcModuleApi< - CcToolchainProvider, - FeatureConfiguration, - CcCompilationContext, - CcLinkingContext, - LibraryToLinkWrapper, - CcToolchainVariables> { + implements CcModuleApi { private enum RegisterActions { ALWAYS, @@ -332,7 +326,7 @@ protected Iterable userFlagsToIterable(CppConfiguration cppConfiguration * @throws InterruptedException */ @Override - public LibraryToLinkWrapper createLibraryLinkerInput( + public Object createLibraryLinkerInput( Object actionsObject, Object featureConfigurationObject, Object ccToolchainProviderObject, @@ -478,7 +472,7 @@ private static SkylarkNestedSet toNestedSetOfStrings(Object obj, String fieldNam } @Override - public CcLinkingContext createCcLinkingInfo( + public Object createCcLinkingInfo( Object librariesToLinkObject, Object userLinkFlagsObject, Location location, diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcModuleApi.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcModuleApi.java index be5f4c40a09..a2b0030991d 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcModuleApi.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcModuleApi.java @@ -36,9 +36,6 @@ public interface CcModuleApi< CcToolchainProviderT extends CcToolchainProviderApi, FeatureConfigurationT extends FeatureConfigurationApi, - CompilationContextT extends CcCompilationContextApi, - LinkingContextT extends CcLinkingContextApi, - LibraryToLinkWrapperT extends LibraryToLinkWrapperApi, CcToolchainVariablesT extends CcToolchainVariablesApi> { @SkylarkCallable( @@ -546,7 +543,7 @@ CcToolchainVariablesT getLinkBuildVariables( named = true, defaultValue = "False"), }) - LibraryToLinkWrapperT createLibraryLinkerInput( + Object createLibraryLinkerInput( Object actions, Object featureConfiguration, Object ccToolchainProvider, @@ -582,7 +579,7 @@ LibraryToLinkWrapperT createLibraryLinkerInput( defaultValue = "None", type = SkylarkList.class) }) - LinkingContextT createCcLinkingInfo( + Object createCcLinkingInfo( Object librariesToLinkObject, Object userLinkFlagsObject, Location location, @@ -651,7 +648,7 @@ LinkingContextT createCcLinkingInfo( defaultValue = "unbound", type = Object.class) }) - CompilationContextT createCcCompilationContext( + CcCompilationContextApi createCcCompilationContext( Object headers, Object systemIncludes, Object includes, Object quoteIncludes, Object defines) throws EvalException; diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/skydoc/fakebuildapi/cpp/FakeCcModule.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/skydoc/fakebuildapi/cpp/FakeCcModule.java index 3da4970af48..5397655456c 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/skydoc/fakebuildapi/cpp/FakeCcModule.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/skydoc/fakebuildapi/cpp/FakeCcModule.java @@ -22,14 +22,12 @@ import com.google.devtools.build.lib.skylarkbuildapi.cpp.CcCompilationContextApi; import com.google.devtools.build.lib.skylarkbuildapi.cpp.CcCompilationOutputsApi; import com.google.devtools.build.lib.skylarkbuildapi.cpp.CcInfoApi; -import com.google.devtools.build.lib.skylarkbuildapi.cpp.CcLinkingContextApi; import com.google.devtools.build.lib.skylarkbuildapi.cpp.CcLinkingInfoApi; import com.google.devtools.build.lib.skylarkbuildapi.cpp.CcModuleApi; import com.google.devtools.build.lib.skylarkbuildapi.cpp.CcToolchainProviderApi; import com.google.devtools.build.lib.skylarkbuildapi.cpp.CcToolchainVariablesApi; import com.google.devtools.build.lib.skylarkbuildapi.cpp.CompilationInfoApi; import com.google.devtools.build.lib.skylarkbuildapi.cpp.FeatureConfigurationApi; -import com.google.devtools.build.lib.skylarkbuildapi.cpp.LibraryToLinkWrapperApi; import com.google.devtools.build.lib.skylarkbuildapi.cpp.LinkingInfoApi; import com.google.devtools.build.lib.syntax.Environment; import com.google.devtools.build.lib.syntax.EvalException; @@ -47,8 +45,6 @@ public class FakeCcModule CcCompilationOutputsApi, LinkingInfoApi, CcLinkingInfoApi, - CcLinkingContextApi, - LibraryToLinkWrapperApi, CcToolchainVariablesApi> { @Override @@ -116,7 +112,7 @@ public CcToolchainVariablesApi getVariables() { } @Override - public LibraryToLinkWrapperApi createLibraryLinkerInput( + public Object createLibraryLinkerInput( Object actions, Object featureConfiguration, Object ccToolchainProvider, @@ -131,7 +127,7 @@ public LibraryToLinkWrapperApi createLibraryLinkerInput( } @Override - public CcLinkingContextApi createCcLinkingInfo( + public Object createCcLinkingInfo( Object librariesToLinkObject, Object userLinkFlagsObject, Location location, diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java index 5dfd092f857..10e43e3cbaf 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcCommonTest.java @@ -4379,9 +4379,7 @@ public void testCcToolchainInfoToProto() throws Exception { " not_features=['b', 'c']),", " with_feature_set(features=['b'])],", " execution_requirements = ['a', 'b', 'c'])],", - " implies = ['compiler_input_flags', 'compiler_output_flags'],", - " flag_sets = [flag_set(flag_groups = [flag_group(flags = ['a'])]", - " )])],", + " implies = ['compiler_input_flags', 'compiler_output_flags'])],", " artifact_name_patterns = [artifact_name_pattern(", " category_name = 'static_library',", " prefix = 'prefix',", @@ -4493,20 +4491,7 @@ public void testCcToolchainInfoToProto() throws Exception { assertThat(tool.getExecutionRequirementList()).containsExactly("a", "b", "c"); assertThat(tool.getWithFeature(0).getFeatureList()).containsExactly("a"); assertThat(tool.getWithFeature(0).getNotFeatureList()).containsExactly("b", "c"); - // When we create an ActionConfig from a proto we put the action name as the only element of its - // FlagSet.action lists. So when we convert back to proto, we need to remove it. - assertThat( - ccToolchainConfigInfo.getActionConfigs().stream() - .filter(config -> config.getName().equals("action_two")) - .findFirst() - .get() - .getFlagSets() - .get(0) - .getActions()) - .containsExactly("action_two"); - CToolchain.FlagSet actionConfigFlagSet = - Iterables.getOnlyElement(actionConfig.getFlagSetList()); - assertThat(actionConfigFlagSet.getActionCount()).isEqualTo(0); + assertThat(Iterables.getOnlyElement(toolchain.getArtifactNamePatternList())) .isEqualTo( CToolchain.ArtifactNamePattern.newBuilder()