diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java index 2ebcd2c8a04..c55d1a8c745 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcBinary.java @@ -345,6 +345,7 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont .addCcCompilationContexts(CppHelper.getCompilationContextsFromDeps(deps)) .addCcCompilationContexts( ImmutableList.of(CcCompilationHelper.getStlCcCompilationContext(ruleContext))) + .addQuoteIncludeDirs(semantics.getQuoteIncludes(ruleContext)) .setHeadersCheckingMode(semantics.determineHeadersCheckingMode(ruleContext)) .setCodeCoverageEnabled(CcCompilationHelper.isCodeCoverageEnabled(ruleContext)) .setFake(fake); diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java index 712b5e8cc4a..92479b58f81 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLibrary.java @@ -168,6 +168,7 @@ public static void init( .collect(ImmutableList.toImmutableList())) .addCcCompilationContexts( ImmutableList.of(CcCompilationHelper.getStlCcCompilationContext(ruleContext))) + .addQuoteIncludeDirs(semantics.getQuoteIncludes(ruleContext)) .setHeadersCheckingMode(semantics.determineHeadersCheckingMode(ruleContext)); CcLinkingHelper linkingHelper = diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java index 58aa9589f89..501a66795af 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcLinkingHelper.java @@ -454,18 +454,6 @@ private CcLinkingOutputs createCcLinkActions(CcCompilationOutputs ccOutputs) ccLinkingOutputsBuilder, libraryToLinkBuilder, usePic, libraryIdentifier, ccOutputs); } - if (shouldCreateStaticLibraries - && featureConfiguration.isEnabled(CppRuleClasses.DISABLE_WHOLE_ARCHIVE_FOR_STATIC_LIB) - && (staticLinkType == LinkTargetType.ALWAYS_LINK_STATIC_LIBRARY)) { - ruleErrorConsumer.throwWithAttributeError( - "alwayslink", - "alwayslink should not be True for a target with the" - + " disable_whole_archive_for_static_lib feature enabled."); - } - - libraryToLinkBuilder.setDisableWholeArchive( - featureConfiguration.isEnabled(CppRuleClasses.DISABLE_WHOLE_ARCHIVE_FOR_STATIC_LIB)); - if (hasBuiltDynamicLibrary || shouldCreateStaticLibraries) { ccLinkingOutputsBuilder.setLibraryToLink(libraryToLinkBuilder.build()); } @@ -622,11 +610,12 @@ private CppLinkAction registerActionForStaticLibrary( throws RuleErrorException, InterruptedException { Artifact linkedArtifact = getLinkedArtifact(linkTargetTypeUsedForNaming); CppLinkAction action = - newLinkActionBuilder(linkedArtifact, linkTargetTypeUsedForNaming) + newLinkActionBuilder(linkedArtifact) .addObjectFiles(ccOutputs.getObjectFiles(usePic)) .addNonCodeInputs(nonCodeLinkerInputs) .addLtoCompilationContext(ccOutputs.getLtoCompilationContext()) .setUsePicForLtoBackendActions(usePic) + .setLinkType(linkTargetTypeUsedForNaming) .setLinkingMode(LinkingMode.STATIC) .addActionInputs(linkActionInputs) .setLibraryIdentifier(libraryIdentifier) @@ -678,13 +667,14 @@ private boolean createDynamicLinkAction( } CppLinkActionBuilder dynamicLinkActionBuilder = - newLinkActionBuilder(linkerOutput, dynamicLinkType) + newLinkActionBuilder(linkerOutput) .setWholeArchive(wholeArchive) .setNativeDeps(nativeDeps) .setAdditionalLinkstampDefines(additionalLinkstampDefines.build()) .setInterfaceOutput(soInterface) .addNonCodeInputs(ccOutputs.getHeaderTokenFiles()) .addLtoCompilationContext(ccOutputs.getLtoCompilationContext()) + .setLinkType(dynamicLinkType) .setLinkingMode(linkingMode) .setFake(fake) .addActionInputs(linkActionInputs) @@ -821,8 +811,7 @@ private boolean createDynamicLinkAction( return hasBuiltDynamicLibrary; } - private CppLinkActionBuilder newLinkActionBuilder( - Artifact outputArtifact, LinkTargetType linkType) { + private CppLinkActionBuilder newLinkActionBuilder(Artifact outputArtifact) { return new CppLinkActionBuilder( ruleErrorConsumer, actionConstructionContext, @@ -836,12 +825,7 @@ private CppLinkActionBuilder newLinkActionBuilder( .setGrepIncludes(grepIncludes) .setIsStampingEnabled(isStampingEnabled) .setTestOrTestOnlyTarget(isTestOrTestOnlyTarget) - .setLinkType(linkType) - .setLinkerFiles( - (cppConfiguration.useSpecificToolFiles() - && linkType.linkerOrArchiver() == LinkerOrArchiver.ARCHIVER) - ? ccToolchain.getArFiles() - : ccToolchain.getLinkerFiles()) + .setLinkerFiles(ccToolchain.getLinkerFiles()) .setLinkArtifactFactory(linkArtifactFactory) .setUseTestOnlyFlags(useTestOnlyFlags); } diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java index e1492f9d174..e20b3823763 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainProvider.java @@ -86,8 +86,7 @@ public final class CcToolchainProvider extends ToolchainInfo /* targetSysroot= */ null, /* fdoContext= */ null, /* isHostConfiguration= */ false, - /* licensesProvider= */ null, - /* toolPaths= */ ImmutableMap.of()); + /* licensesProvider= */ null); @Nullable private final CppConfiguration cppConfiguration; private final CppToolchainInfo toolchainInfo; @@ -123,7 +122,6 @@ public final class CcToolchainProvider extends ToolchainInfo @Nullable private final PathFragment sysroot; private final PathFragment targetSysroot; private final boolean isHostConfiguration; - private final ImmutableMap toolPaths; /** * WARNING: We don't like {@link FdoContext}. Its {@link FdoContext#fdoProfilePath} is pure path * and that is horrible as it breaks many Bazel assumptions! Don't do bad stuff with it, don't @@ -170,8 +168,7 @@ public CcToolchainProvider( @Nullable PathFragment targetSysroot, FdoContext fdoContext, boolean isHostConfiguration, - LicensesProvider licensesProvider, - ImmutableMap toolPaths) { + LicensesProvider licensesProvider) { super(values, Location.BUILTIN); this.cppConfiguration = cppConfiguration; this.toolchainInfo = toolchainInfo; @@ -213,7 +210,6 @@ public CcToolchainProvider( this.fdoContext = fdoContext == null ? FdoContext.getDisabledContext() : fdoContext; this.isHostConfiguration = isHostConfiguration; this.licensesProvider = licensesProvider; - this.toolPaths = toolPaths; } /** @@ -349,16 +345,11 @@ public String getToolPathStringOrNull(Tool tool) { return toolPathFragment == null ? null : toolPathFragment.getPathString(); } - /** - * Returns the path fragment that is either absolute or relative to the execution root that can be - * used to execute the given tool. - */ @Nullable public PathFragment getToolPathFragmentOrNull(CppConfiguration.Tool tool) { - return CcToolchainProviderHelper.getToolPathFragment(toolPaths, tool); + return toolchainInfo.getToolPathFragment(tool); } - @Override public ImmutableList getBuiltInIncludeDirectoriesAsStrings() { return builtInIncludeDirectories @@ -891,6 +882,11 @@ public boolean requireCtxInConfigureFeatures() { .requireCtxInConfigureFeatures(); } + public boolean disableGenruleCcToolchainDependency() { + return getCppConfigurationEvenThoughItCanBeDifferentThatWhatTargetHas() + .disableGenruleCcToolchainDependency(); + } + @VisibleForTesting NestedSet getStaticRuntimeLibForTesting() { return staticRuntimeLinkInputs; diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java index 4b8e27d417a..d0c381d04e8 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java @@ -15,14 +15,12 @@ package com.google.devtools.build.lib.rules.cpp; import static com.google.devtools.build.lib.packages.BuildType.LABEL; -import static com.google.devtools.build.lib.packages.BuildType.LABEL_LIST; import static com.google.devtools.build.lib.packages.BuildType.NODEP_LABEL; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; @@ -34,10 +32,8 @@ import com.google.devtools.build.lib.actions.MiddlemanFactory; import com.google.devtools.build.lib.actions.ParamFileInfo; import com.google.devtools.build.lib.actions.ParameterFile; -import com.google.devtools.build.lib.analysis.AliasProvider; import com.google.devtools.build.lib.analysis.AnalysisUtils; import com.google.devtools.build.lib.analysis.Expander; -import com.google.devtools.build.lib.analysis.FileProvider; import com.google.devtools.build.lib.analysis.PlatformConfiguration; import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder; import com.google.devtools.build.lib.analysis.RuleContext; @@ -169,18 +165,7 @@ static ImmutableList getPackageCopts(RuleContext ruleContext) { public static List expandLinkopts( RuleContext ruleContext, String attrName, Iterable values) { List result = new ArrayList<>(); - ImmutableMap.Builder> builder = ImmutableMap.builder(); - - if (ruleContext.attributes().has("additional_linker_inputs", LABEL_LIST)) { - for (TransitiveInfoCollection current : - ruleContext.getPrerequisites("additional_linker_inputs", Mode.TARGET)) { - builder.put( - AliasProvider.getDependencyLabel(current), - ImmutableList.copyOf(current.getProvider(FileProvider.class).getFilesToBuild())); - } - } - - Expander expander = ruleContext.getExpander(builder.build()).withDataExecLocations(); + Expander expander = ruleContext.getExpander().withDataExecLocations(); for (String value : values) { expander.tokenizeAndExpandMakeVars(result, attrName, value); } diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcToolchainProviderApi.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcToolchainProviderApi.java index 0dc6513c324..4be923f9898 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcToolchainProviderApi.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/skylarkbuildapi/cpp/CcToolchainProviderApi.java @@ -19,16 +19,12 @@ import com.google.devtools.build.lib.skylarkinterface.Param; import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; -import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; import com.google.devtools.build.lib.syntax.EvalException; import com.google.devtools.build.lib.syntax.SkylarkNestedSet; import javax.annotation.Nullable; /** Information about the C++ toolchain. */ -@SkylarkModule( - name = "CcToolchainInfo", - category = SkylarkModuleCategory.PROVIDER, - doc = "Information about the C++ compiler being used.") +@SkylarkModule(name = "CcToolchainInfo", doc = "Information about the C++ compiler being used.") public interface CcToolchainProviderApi extends ToolchainInfoApi { 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 b74b044d2f6..d40e576221f 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 @@ -19,7 +19,6 @@ import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.actions.Artifact; @@ -29,12 +28,12 @@ import com.google.devtools.build.lib.analysis.util.AnalysisMock; import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; import com.google.devtools.build.lib.cmdline.Label; -import com.google.devtools.build.lib.packages.Provider; import com.google.devtools.build.lib.packages.SkylarkInfo; import com.google.devtools.build.lib.packages.SkylarkProvider; import com.google.devtools.build.lib.packages.StructImpl; import com.google.devtools.build.lib.packages.util.Crosstool.CcToolchainConfig; import com.google.devtools.build.lib.packages.util.ResourceLoader; +import com.google.devtools.build.lib.rules.cpp.CcInfo.Provider; import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.ActionConfig; import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.ArtifactNamePattern; import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.EnvEntry; @@ -74,17 +73,6 @@ public class SkylarkCcCommonTest extends BuildViewTestCase { public void setSkylarkSemanticsOptions() throws Exception { setSkylarkSemanticsOptions(SkylarkCcCommonTestHelper.CC_SKYLARK_WHITELIST_FLAG); invalidatePackages(); - - scratch.file("myinfo/myinfo.bzl", "MyInfo = provider()"); - - scratch.file("myinfo/BUILD"); - } - - private StructImpl getMyInfoFromTarget(ConfiguredTarget configuredTarget) throws Exception { - Provider.Key key = - new SkylarkProvider.SkylarkKey( - Label.parseAbsolute("//myinfo:myinfo.bzl", ImmutableMap.of()), "MyInfo"); - return (StructImpl) configuredTarget.get(key); } @Test @@ -97,10 +85,9 @@ public void testAllFiles() throws Exception { scratch.file( "a/rule.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", " toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]", - " return [MyInfo(all_files = toolchain.all_files)]", + " return struct(all_files = toolchain.all_files)", "crule = rule(", " _impl,", " attrs = { ", @@ -110,7 +97,7 @@ public void testAllFiles() throws Exception { ConfiguredTarget r = getConfiguredTarget("//a:r"); @SuppressWarnings("unchecked") - SkylarkNestedSet allFiles = (SkylarkNestedSet) getMyInfoFromTarget(r).getValue("all_files"); + SkylarkNestedSet allFiles = (SkylarkNestedSet) r.get("all_files"); RuleContext ruleContext = getRuleContext(r); CcToolchainProvider toolchain = CppHelper.getToolchain( @@ -193,14 +180,13 @@ public void testGetToolForAction() throws Exception { scratch.file( "a/rule.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", " toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]", " feature_configuration = cc_common.configure_features(cc_toolchain = toolchain)", - " return [MyInfo(", + " return struct(", " action_tool_path = cc_common.get_tool_for_action(", " feature_configuration = feature_configuration,", - " action_name = 'c++-compile'))]", + " action_name = 'c++-compile'))", "crule = rule(", " _impl,", " attrs = { ", @@ -211,7 +197,7 @@ public void testGetToolForAction() throws Exception { ConfiguredTarget r = getConfiguredTarget("//a:r"); @SuppressWarnings("unchecked") - String actionToolPath = (String) getMyInfoFromTarget(r).getValue("action_tool_path"); + String actionToolPath = (String) r.get("action_tool_path"); RuleContext ruleContext = getRuleContext(r); CcToolchainProvider toolchain = CppHelper.getToolchain( @@ -241,16 +227,15 @@ public void testFeatureConfigurationWithAdditionalEnabledFeature() throws Except scratch.file( "a/rule.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", " toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]", " feature_configuration = cc_common.configure_features(", " cc_toolchain = toolchain,", " requested_features = ['foo_feature'])", - " return [MyInfo(", + " return struct(", " foo_feature_enabled = cc_common.is_enabled(", " feature_configuration = feature_configuration,", - " feature_name = 'foo_feature'))]", + " feature_name = 'foo_feature'))", "crule = rule(", " _impl,", " attrs = { ", @@ -261,7 +246,7 @@ public void testFeatureConfigurationWithAdditionalEnabledFeature() throws Except ConfiguredTarget r = getConfiguredTarget("//a:r"); @SuppressWarnings("unchecked") - boolean fooFeatureEnabled = (boolean) getMyInfoFromTarget(r).getValue("foo_feature_enabled"); + boolean fooFeatureEnabled = (boolean) r.get("foo_feature_enabled"); assertThat(fooFeatureEnabled).isTrue(); } @@ -280,16 +265,15 @@ public void testFeatureConfigurationWithAdditionalUnsupportedFeature() throws Ex scratch.file( "a/rule.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", " toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]", " feature_configuration = cc_common.configure_features(", " cc_toolchain = toolchain,", " unsupported_features = ['foo_feature'])", - " return [MyInfo(", + " return struct(", " foo_feature_enabled = cc_common.is_enabled(", " feature_configuration = feature_configuration,", - " feature_name = 'foo_feature'))]", + " feature_name = 'foo_feature'))", "crule = rule(", " _impl,", " attrs = { ", @@ -300,7 +284,7 @@ public void testFeatureConfigurationWithAdditionalUnsupportedFeature() throws Ex ConfiguredTarget r = getConfiguredTarget("//a:r"); @SuppressWarnings("unchecked") - boolean fooFeatureEnabled = (boolean) getMyInfoFromTarget(r).getValue("foo_feature_enabled"); + boolean fooFeatureEnabled = (boolean) r.get("foo_feature_enabled"); assertThat(fooFeatureEnabled).isFalse(); } @@ -314,15 +298,14 @@ public void testGetCommandLine() throws Exception { scratch.file( "a/rule.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", " toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]", " feature_configuration = cc_common.configure_features(cc_toolchain = toolchain)", - " return [MyInfo(", + " return struct(", " command_line = cc_common.get_memory_inefficient_command_line(", " feature_configuration = feature_configuration,", " action_name = 'c++-link-executable',", - " variables = cc_common.empty_variables()))]", + " variables = cc_common.empty_variables()))", "crule = rule(", " _impl,", " attrs = { ", @@ -333,8 +316,7 @@ public void testGetCommandLine() throws Exception { ConfiguredTarget r = getConfiguredTarget("//a:r"); @SuppressWarnings("unchecked") - SkylarkList commandLine = - (SkylarkList) getMyInfoFromTarget(r).getValue("command_line"); + SkylarkList commandLine = (SkylarkList) r.get("command_line"); RuleContext ruleContext = getRuleContext(r); CcToolchainProvider toolchain = CppHelper.getToolchain( @@ -360,15 +342,14 @@ public void testGetEnvironment() throws Exception { scratch.file( "a/rule.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", " toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]", " feature_configuration = cc_common.configure_features(cc_toolchain = toolchain)", - " return [MyInfo(", + " return struct(", " environment_variables = cc_common.get_environment_variables(", " feature_configuration = feature_configuration,", " action_name = 'c++-compile',", - " variables = cc_common.empty_variables()))]", + " variables = cc_common.empty_variables()))", "crule = rule(", " _impl,", " attrs = { ", @@ -380,7 +361,7 @@ public void testGetEnvironment() throws Exception { ConfiguredTarget r = getConfiguredTarget("//a:r"); @SuppressWarnings("unchecked") SkylarkDict environmentVariables = - (SkylarkDict) getMyInfoFromTarget(r).getValue("environment_variables"); + (SkylarkDict) r.get("environment_variables"); RuleContext ruleContext = getRuleContext(r); CcToolchainProvider toolchain = CppHelper.getToolchain( @@ -407,17 +388,16 @@ public void testActionIsEnabled() throws Exception { scratch.file( "a/rule.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", " toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]", " feature_configuration = cc_common.configure_features(cc_toolchain = toolchain)", - " return [MyInfo(", + " return struct(", " enabled_action = cc_common.action_is_enabled(", " feature_configuration = feature_configuration,", " action_name = 'c-compile'),", " disabled_action = cc_common.action_is_enabled(", " feature_configuration = feature_configuration,", - " action_name = 'wololoo'))]", + " action_name = 'wololoo'))", "crule = rule(", " _impl,", " attrs = { ", @@ -426,11 +406,11 @@ public void testActionIsEnabled() throws Exception { " fragments = ['cpp'],", ");"); - StructImpl myInfo = getMyInfoFromTarget(getConfiguredTarget("//a:r")); + ConfiguredTarget r = getConfiguredTarget("//a:r"); @SuppressWarnings("unchecked") - boolean enabledActionIsEnabled = (boolean) myInfo.getValue("enabled_action"); + boolean enabledActionIsEnabled = (boolean) r.get("enabled_action"); @SuppressWarnings("unchecked") - boolean disabledActionIsDisabled = (boolean) myInfo.getValue("disabled_action"); + boolean disabledActionIsDisabled = (boolean) r.get("disabled_action"); assertThat(enabledActionIsEnabled).isTrue(); assertThat(disabledActionIsDisabled).isFalse(); } @@ -445,17 +425,16 @@ public void testIsEnabled() throws Exception { scratch.file( "a/rule.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", " toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]", " feature_configuration = cc_common.configure_features(cc_toolchain = toolchain)", - " return [MyInfo(", + " return struct(", " enabled_feature = cc_common.is_enabled(", " feature_configuration = feature_configuration,", " feature_name = 'libraries_to_link'),", " disabled_feature = cc_common.is_enabled(", " feature_configuration = feature_configuration,", - " feature_name = 'wololoo'))]", + " feature_name = 'wololoo'))", "crule = rule(", " _impl,", " attrs = { ", @@ -464,12 +443,11 @@ public void testIsEnabled() throws Exception { " fragments = ['cpp'],", ");"); - StructImpl myInfo = getMyInfoFromTarget(getConfiguredTarget("//a:r")); - + ConfiguredTarget r = getConfiguredTarget("//a:r"); @SuppressWarnings("unchecked") - boolean enabledFeatureIsEnabled = (boolean) myInfo.getValue("enabled_feature"); + boolean enabledFeatureIsEnabled = (boolean) r.get("enabled_feature"); @SuppressWarnings("unchecked") - boolean disabledFeatureIsDisabled = (boolean) myInfo.getValue("disabled_feature"); + boolean disabledFeatureIsDisabled = (boolean) r.get("disabled_feature"); assertThat(enabledFeatureIsEnabled).isTrue(); assertThat(disabledFeatureIsDisabled).isFalse(); } @@ -487,6 +465,7 @@ public void testFeatureConfigurationRequiresCtx() throws Exception { "def _impl(ctx):", " toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]", " feature_configuration = cc_common.configure_features(cc_toolchain = toolchain)", + " return struct()", "crule = rule(", " _impl,", " attrs = { ", @@ -516,7 +495,6 @@ public void testActionNames() throws Exception { scratch.file( "a/rule.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "load('//tools/build_defs/cc:action_names.bzl',", " 'C_COMPILE_ACTION_NAME',", " 'CPP_COMPILE_ACTION_NAME',", @@ -537,7 +515,7 @@ public void testActionNames() throws Exception { "def _impl(ctx):", " toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]", " feature_configuration = cc_common.configure_features(cc_toolchain = toolchain)", - " return [MyInfo(", + " return struct(", " c_compile_action_name=C_COMPILE_ACTION_NAME,", " cpp_compile_action_name=CPP_COMPILE_ACTION_NAME,", " linkstamp_compile_action_name=LINKSTAMP_COMPILE_ACTION_NAME,", @@ -554,7 +532,7 @@ public void testActionNames() throws Exception { " " + " cpp_link_nodeps_dynamic_library_action_name=CPP_LINK_NODEPS_DYNAMIC_LIBRARY_ACTION_NAME,", " cpp_link_static_library_action_name=CPP_LINK_STATIC_LIBRARY_ACTION_NAME,", - " strip_action_name=STRIP_ACTION_NAME)]", + " strip_action_name=STRIP_ACTION_NAME)", "crule = rule(", " _impl,", " attrs = { ", @@ -564,35 +542,32 @@ public void testActionNames() throws Exception { ")"); assertThat(getTarget("//a:r")).isNotNull(); - - StructImpl myInfo = getMyInfoFromTarget(getConfiguredTarget("//a:r")); - - assertThat(myInfo.getValue("c_compile_action_name")).isEqualTo(CppActionNames.C_COMPILE); - assertThat(myInfo.getValue("cpp_compile_action_name")).isEqualTo(CppActionNames.CPP_COMPILE); - assertThat(myInfo.getValue("linkstamp_compile_action_name")) - .isEqualTo(CppActionNames.LINKSTAMP_COMPILE); - assertThat(myInfo.getValue("cc_flags_make_variable_action_name_action_name")) + ConfiguredTarget r = getConfiguredTarget("//a:r"); + assertThat(r.get("c_compile_action_name")).isEqualTo(CppActionNames.C_COMPILE); + assertThat(r.get("cpp_compile_action_name")).isEqualTo(CppActionNames.CPP_COMPILE); + assertThat(r.get("linkstamp_compile_action_name")).isEqualTo(CppActionNames.LINKSTAMP_COMPILE); + assertThat(r.get("cc_flags_make_variable_action_name_action_name")) .isEqualTo(CppActionNames.CC_FLAGS_MAKE_VARIABLE); - assertThat(myInfo.getValue("cpp_module_codegen_action_name")) + assertThat(r.get("cpp_module_codegen_action_name")) .isEqualTo(CppActionNames.CPP_MODULE_CODEGEN); - assertThat(myInfo.getValue("cpp_header_parsing_action_name")) + assertThat(r.get("cpp_header_parsing_action_name")) .isEqualTo(CppActionNames.CPP_HEADER_PARSING); - assertThat(myInfo.getValue("cpp_module_compile_action_name")) + assertThat(r.get("cpp_module_compile_action_name")) .isEqualTo(CppActionNames.CPP_MODULE_COMPILE); - assertThat(myInfo.getValue("assemble_action_name")).isEqualTo(CppActionNames.ASSEMBLE); - assertThat(myInfo.getValue("preprocess_assemble_action_name")) + assertThat(r.get("assemble_action_name")).isEqualTo(CppActionNames.ASSEMBLE); + assertThat(r.get("preprocess_assemble_action_name")) .isEqualTo(CppActionNames.PREPROCESS_ASSEMBLE); - assertThat(myInfo.getValue("lto_indexing_action_name")).isEqualTo(CppActionNames.LTO_INDEXING); - assertThat(myInfo.getValue("lto_backend_action_name")).isEqualTo(CppActionNames.LTO_BACKEND); - assertThat(myInfo.getValue("cpp_link_executable_action_name")) + assertThat(r.get("lto_indexing_action_name")).isEqualTo(CppActionNames.LTO_INDEXING); + assertThat(r.get("lto_backend_action_name")).isEqualTo(CppActionNames.LTO_BACKEND); + assertThat(r.get("cpp_link_executable_action_name")) .isEqualTo(CppActionNames.CPP_LINK_EXECUTABLE); - assertThat(myInfo.getValue("cpp_link_dynamic_library_action_name")) + assertThat(r.get("cpp_link_dynamic_library_action_name")) .isEqualTo(CppActionNames.CPP_LINK_DYNAMIC_LIBRARY); - assertThat(myInfo.getValue("cpp_link_nodeps_dynamic_library_action_name")) + assertThat(r.get("cpp_link_nodeps_dynamic_library_action_name")) .isEqualTo(CppActionNames.CPP_LINK_NODEPS_DYNAMIC_LIBRARY); - assertThat(myInfo.getValue("cpp_link_static_library_action_name")) + assertThat(r.get("cpp_link_static_library_action_name")) .isEqualTo(CppActionNames.CPP_LINK_STATIC_LIBRARY); - assertThat(myInfo.getValue("strip_action_name")).isEqualTo(CppActionNames.STRIP); + assertThat(r.get("strip_action_name")).isEqualTo(CppActionNames.STRIP); } @Test @@ -931,16 +906,15 @@ private SkylarkList commandLineForVariables( scratch.file( "a" + pkgSuffix + "/rule.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", " toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]", " feature_configuration = cc_common.configure_features(cc_toolchain = toolchain)", " variables = " + Joiner.on("\n").join(variables), - " return [MyInfo(", + " return struct(", " command_line = cc_common.get_memory_inefficient_command_line(", " feature_configuration = feature_configuration,", " action_name = '" + actionName + "',", - " variables = variables))]", + " variables = variables))", "crule = rule(", " _impl,", " attrs = { ", @@ -956,8 +930,7 @@ private SkylarkList commandLineForVariables( return null; } @SuppressWarnings("unchecked") - SkylarkList result = - (SkylarkList) getMyInfoFromTarget(r).getValue("command_line"); + SkylarkList result = (SkylarkList) r.get("command_line"); return result; } @@ -993,7 +966,6 @@ public void testCcCompilationProvider() throws Exception { scratch.overwriteFile("tools/build_defs/cc/BUILD", ""); scratch.file( "tools/build_defs/cc/rule.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", " compilation_context = cc_common.create_compilation_context(", " headers=depset([ctx.file._header]),", @@ -1005,15 +977,14 @@ public void testCcCompilationProvider() throws Exception { " for dep in ctx.attr._deps:", " cc_infos.append(dep[CcInfo])", " merged_cc_info=cc_common.merge_cc_infos(cc_infos=cc_infos)", - " return [", - " merged_cc_info,", - " MyInfo(", - " merged_headers=merged_cc_info.compilation_context.headers,", - " merged_system_includes=merged_cc_info.compilation_context.system_includes,", - " merged_includes=merged_cc_info.compilation_context.includes,", - " merged_quote_includes=merged_cc_info.compilation_context.quote_includes,", - " merged_defines=merged_cc_info.compilation_context.defines", - " )]", + " return struct(", + " providers=[merged_cc_info],", + " merged_headers=merged_cc_info.compilation_context.headers,", + " merged_system_includes=merged_cc_info.compilation_context.system_includes,", + " merged_includes=merged_cc_info.compilation_context.includes,", + " merged_quote_includes=merged_cc_info.compilation_context.quote_includes,", + " merged_defines=merged_cc_info.compilation_context.defines", + " )", "crule = rule(", " _impl,", " attrs = { ", @@ -1037,10 +1008,10 @@ public void testCcCompilationProvider() throws Exception { .collect(ImmutableList.toImmutableList())) .containsExactly("lib.h", "header.h", "dep1.h", "dep2.h"); - StructImpl myInfo = getMyInfoFromTarget(getConfiguredTarget("//a:r")); + ConfiguredTarget r = getConfiguredTarget("//a:r"); List mergedHeaders = - ((SkylarkNestedSet) myInfo.getValue("merged_headers")).getSet(Artifact.class).toList(); + ((SkylarkNestedSet) r.get("merged_headers")).getSet(Artifact.class).toList(); assertThat( mergedHeaders.stream() .map(Artifact::getFilename) @@ -1048,21 +1019,19 @@ public void testCcCompilationProvider() throws Exception { .containsAllOf("header.h", "dep1.h", "dep2.h"); List mergedDefines = - ((SkylarkNestedSet) myInfo.getValue("merged_defines")).getSet(String.class).toList(); + ((SkylarkNestedSet) r.get("merged_defines")).getSet(String.class).toList(); assertThat(mergedDefines).containsAllOf("MYDEFINE", "DEP1", "DEP2"); List mergedSystemIncludes = - ((SkylarkNestedSet) myInfo.getValue("merged_system_includes")) - .getSet(String.class) - .toList(); + ((SkylarkNestedSet) r.get("merged_system_includes")).getSet(String.class).toList(); assertThat(mergedSystemIncludes).containsAllOf("foo/bar", "a/dep1/baz", "a/dep2/qux"); List mergedIncludes = - ((SkylarkNestedSet) myInfo.getValue("merged_includes")).getSet(String.class).toList(); + ((SkylarkNestedSet) r.get("merged_includes")).getSet(String.class).toList(); assertThat(mergedIncludes).contains("baz/qux"); List mergedQuoteIncludes = - ((SkylarkNestedSet) myInfo.getValue("merged_quote_includes")).getSet(String.class).toList(); + ((SkylarkNestedSet) r.get("merged_quote_includes")).getSet(String.class).toList(); assertThat(mergedQuoteIncludes).contains("quux/abc"); } @@ -1078,6 +1047,7 @@ public void testCcCompilationProviderDefaultValues() throws Exception { "tools/build_defs/cc/rule.bzl", "def _impl(ctx):", " compilation_context = cc_common.create_compilation_context()", + " return struct()", "crule = rule(", " _impl,", " fragments = ['cpp'],", @@ -1099,6 +1069,7 @@ public void testCcCompilationProviderInvalidValues() throws Exception { "tools/build_defs/cc/rule.bzl", "def _impl(ctx):", " compilation_context = cc_common.create_compilation_context(headers=[])", + " return struct()", "crule = rule(", " _impl,", " fragments = ['cpp'],", @@ -1151,7 +1122,7 @@ private void doTestCcLinkingContext( setUpCcLinkingContextTest(); ConfiguredTarget a = getConfiguredTarget("//a:a"); - StructImpl info = ((StructImpl) getMyInfoFromTarget(a).getValue("info")); + StructImpl info = ((StructImpl) a.get("info")); @SuppressWarnings("unchecked") SkylarkList userLinkFlags = (SkylarkList) info.getValue("user_link_flags", SkylarkList.class); @@ -1263,7 +1234,6 @@ private void setUpCcLinkingContextTest() throws Exception { scratch.overwriteFile("tools/build_defs/cc/BUILD", ""); scratch.file( "tools/build_defs/cc/rule.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "top_linking_context_smoke = cc_common.create_linking_context(libraries_to_link=[],", " user_link_flags=['-first_flag', '-second_flag'])", "def _create(ctx, feature_configuration, static_library, pic_static_library,", @@ -1288,20 +1258,19 @@ private void setUpCcLinkingContextTest() throws Exception { " for dep in ctx.attr.deps:", " cc_infos.append(dep[CcInfo])", " merged_cc_info = cc_common.merge_cc_infos(cc_infos=cc_infos)", - " return [", - " MyInfo(", - " info = struct(", - " cc_info = merged_cc_info,", - " user_link_flags = merged_cc_info.linking_context.user_link_flags,", - " additional_inputs = merged_cc_info.linking_context.additional_inputs,", - " libraries_to_link = merged_cc_info.linking_context.libraries_to_link,", - " static_library = library_to_link.static_library,", - " pic_static_library = library_to_link.pic_static_library,", - " dynamic_library = library_to_link.dynamic_library,", - " interface_library = library_to_link.interface_library,", - " alwayslink = library_to_link.alwayslink),", - " ),", - " merged_cc_info]", + " return struct(", + " info = struct(", + " cc_info = merged_cc_info,", + " user_link_flags = merged_cc_info.linking_context.user_link_flags,", + " additional_inputs = merged_cc_info.linking_context.additional_inputs,", + " libraries_to_link = merged_cc_info.linking_context.libraries_to_link,", + " static_library = library_to_link.static_library,", + " pic_static_library = library_to_link.pic_static_library,", + " dynamic_library = library_to_link.dynamic_library,", + " interface_library = library_to_link.interface_library,", + " alwayslink = library_to_link.alwayslink),", + " providers = [merged_cc_info]", + " )", "crule = rule(", " _impl,", " attrs = { ", @@ -1361,7 +1330,7 @@ public void testVariableWithValue() throws Exception { createVariableWithValueRule("five", /* name= */ "'abc'", /* value= */ "'def'"); ConfiguredTarget t = getConfiguredTarget("//five:a"); - SkylarkInfo variable = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + SkylarkInfo variable = (SkylarkInfo) t.get("variable"); assertThat(variable).isNotNull(); VariableWithValue v = CcModule.variableWithValueFromSkylark(variable); assertThat(v).isNotNull(); @@ -1370,7 +1339,7 @@ public void testVariableWithValue() throws Exception { createEnvEntryRule("six", /* key= */ "'abc'", /* value= */ "'def'"); t = getConfiguredTarget("//six:a"); - SkylarkInfo envEntry = (SkylarkInfo) getMyInfoFromTarget(t).getValue("entry"); + SkylarkInfo envEntry = (SkylarkInfo) t.get("entry"); try { CcModule.variableWithValueFromSkylark(envEntry); fail("Should have failed because of wrong object type."); @@ -1386,11 +1355,10 @@ private void createVariableWithValueRule(String pkg, String name, String value) scratch.file( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl', 'variable_with_value')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(variable = variable_with_value(", + " return struct(variable = variable_with_value(", " name = " + name + ",", - " value = " + value + "))]", + " value = " + value + "))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -1400,7 +1368,7 @@ public void testCustomVariableWithValue() throws Exception { loadCcToolchainConfigLib(); createCustomVariableWithValueRule("one", /* name= */ "None", /* value= */ "None"); ConfiguredTarget t = getConfiguredTarget("//one:a"); - SkylarkInfo variable = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + SkylarkInfo variable = (SkylarkInfo) t.get("variable"); try { CcModule.variableWithValueFromSkylark(variable); fail("Should have failed because of empty string."); @@ -1413,7 +1381,7 @@ public void testCustomVariableWithValue() throws Exception { createCustomVariableWithValueRule("two", /* name= */ "'abc'", /* value= */ "None"); t = getConfiguredTarget("//two:a"); - variable = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + variable = (SkylarkInfo) t.get("variable"); try { CcModule.variableWithValueFromSkylark(variable); fail("Should have failed because of empty string."); @@ -1426,7 +1394,7 @@ public void testCustomVariableWithValue() throws Exception { createCustomVariableWithValueRule("three", /* name= */ "'abc'", /* value= */ "struct()"); t = getConfiguredTarget("//three:a"); - variable = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + variable = (SkylarkInfo) t.get("variable"); try { CcModule.variableWithValueFromSkylark(variable); fail("Should have failed because of wrong object type."); @@ -1437,7 +1405,7 @@ public void testCustomVariableWithValue() throws Exception { createCustomVariableWithValueRule("four", /* name= */ "True", /* value= */ "'abc'"); t = getConfiguredTarget("//four:a"); - variable = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + variable = (SkylarkInfo) t.get("variable"); try { CcModule.variableWithValueFromSkylark(variable); fail("Should have failed because of wrong object type."); @@ -1450,12 +1418,11 @@ private void createCustomVariableWithValueRule(String pkg, String name, String v throws IOException { scratch.file( pkg + "/foo.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(variable = struct(", + " return struct(variable = struct(", " name = " + name + ",", " value = " + value + ",", - " type_name = 'variable_with_value'))]", + " type_name = 'variable_with_value'))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -1492,7 +1459,7 @@ public void testEnvEntry() throws Exception { createEnvEntryRule("five", "'abc'", /* value= */ "'def'"); ConfiguredTarget t = getConfiguredTarget("//five:a"); - SkylarkInfo entryProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("entry"); + SkylarkInfo entryProvider = (SkylarkInfo) t.get("entry"); assertThat(entryProvider).isNotNull(); EnvEntry entry = CcModule.envEntryFromSkylark(entryProvider); assertThat(entry).isNotNull(); @@ -1501,7 +1468,7 @@ public void testEnvEntry() throws Exception { createVariableWithValueRule("six", /* name= */ "'abc'", /* value= */ "'def'"); t = getConfiguredTarget("//six:a"); - SkylarkInfo variable = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + SkylarkInfo variable = (SkylarkInfo) t.get("variable"); try { CcModule.envEntryFromSkylark(variable); fail("Should have failed because of wrong object type."); @@ -1516,11 +1483,10 @@ private void createEnvEntryRule(String pkg, String key, String value) throws Exc scratch.file( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl', 'env_entry')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(entry = env_entry(", + " return struct(entry = env_entry(", " key = " + key + ",", - " value = " + value + "))]", + " value = " + value + "))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -1532,7 +1498,7 @@ public void testCustomEnvEntry() throws Exception { createCustomEnvEntryRule("one", /* key= */ "None", /* value= */ "None"); ConfiguredTarget t = getConfiguredTarget("//one:a"); - SkylarkInfo entry = (SkylarkInfo) getMyInfoFromTarget(t).getValue("entry"); + SkylarkInfo entry = (SkylarkInfo) t.get("entry"); try { CcModule.envEntryFromSkylark(entry); fail("Should have failed because of empty string."); @@ -1545,7 +1511,7 @@ public void testCustomEnvEntry() throws Exception { createCustomEnvEntryRule("two", /* key= */ "'abc'", /* value= */ "None"); t = getConfiguredTarget("//two:a"); - entry = (SkylarkInfo) getMyInfoFromTarget(t).getValue("entry"); + entry = (SkylarkInfo) t.get("entry"); try { CcModule.envEntryFromSkylark(entry); fail("Should have failed because of empty string."); @@ -1559,7 +1525,7 @@ public void testCustomEnvEntry() throws Exception { createCustomEnvEntryRule("three", /* key= */ "'abc'", /* value= */ "struct()"); t = getConfiguredTarget("//three:a"); - entry = (SkylarkInfo) getMyInfoFromTarget(t).getValue("entry"); + entry = (SkylarkInfo) t.get("entry"); try { CcModule.envEntryFromSkylark(entry); fail("Should have failed because of wrong object type."); @@ -1570,7 +1536,7 @@ public void testCustomEnvEntry() throws Exception { createCustomEnvEntryRule("four", /* key= */ "True", /* value= */ "'abc'"); t = getConfiguredTarget("//four:a"); - entry = (SkylarkInfo) getMyInfoFromTarget(t).getValue("entry"); + entry = (SkylarkInfo) t.get("entry"); try { CcModule.envEntryFromSkylark(entry); fail("Should have failed because of wrong object type."); @@ -1582,12 +1548,11 @@ public void testCustomEnvEntry() throws Exception { private void createCustomEnvEntryRule(String pkg, String key, String value) throws Exception { scratch.file( pkg + "/foo.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(entry = struct(", + " return struct(entry = struct(", " key = " + key + ",", " value = " + value + ",", - " type_name = 'env_entry'))]", + " type_name = 'env_entry'))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -1626,7 +1591,7 @@ public void testToolPath() throws Exception { createToolPathRule("five", /* name= */ "'abc'", "'/d/e/f'"); ConfiguredTarget t = getConfiguredTarget("//five:a"); - SkylarkInfo toolPathProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("toolpath"); + SkylarkInfo toolPathProvider = (SkylarkInfo) t.get("toolpath"); assertThat(toolPathProvider).isNotNull(); Pair toolPath = CcModule.toolPathFromSkylark(toolPathProvider); assertThat(toolPath).isNotNull(); @@ -1635,7 +1600,7 @@ public void testToolPath() throws Exception { createVariableWithValueRule("six", /* name= */ "'abc'", /* value= */ "'def'"); t = getConfiguredTarget("//six:a"); - SkylarkInfo variable = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + SkylarkInfo variable = (SkylarkInfo) t.get("variable"); try { CcModule.toolPathFromSkylark(variable); fail("Should have failed because of wrong object type."); @@ -1650,11 +1615,10 @@ private void createToolPathRule(String pkg, String name, String path) throws IOE scratch.file( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl', 'tool_path')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(toolpath = tool_path(", + " return struct(toolpath = tool_path(", " name = " + name + ",", - " path = " + path + "))]", + " path = " + path + "))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -1666,7 +1630,7 @@ public void testCustomToolPath() throws Exception { createCustomToolPathRule("one", /* name= */ "None", /* path= */ "None"); ConfiguredTarget t = getConfiguredTarget("//one:a"); - SkylarkInfo toolPath = (SkylarkInfo) getMyInfoFromTarget(t).getValue("toolpath"); + SkylarkInfo toolPath = (SkylarkInfo) t.get("toolpath"); try { CcModule.toolPathFromSkylark(toolPath); fail("Should have failed because of empty string."); @@ -1679,7 +1643,7 @@ public void testCustomToolPath() throws Exception { createCustomToolPathRule("two", /* name= */ "'abc'", /* path= */ "None"); t = getConfiguredTarget("//two:a"); - toolPath = (SkylarkInfo) getMyInfoFromTarget(t).getValue("toolpath"); + toolPath = (SkylarkInfo) t.get("toolpath"); try { CcModule.toolPathFromSkylark(toolPath); fail("Should have failed because of empty string."); @@ -1692,7 +1656,7 @@ public void testCustomToolPath() throws Exception { createCustomToolPathRule("three", /* name= */ "'abc'", /* path= */ "struct()"); t = getConfiguredTarget("//three:a"); - toolPath = (SkylarkInfo) getMyInfoFromTarget(t).getValue("toolpath"); + toolPath = (SkylarkInfo) t.get("toolpath"); try { CcModule.toolPathFromSkylark(toolPath); fail("Should have failed because of wrong object type."); @@ -1703,7 +1667,7 @@ public void testCustomToolPath() throws Exception { createCustomToolPathRule("four", /* name= */ "True", /* path= */ "'abc'"); t = getConfiguredTarget("//four:a"); - toolPath = (SkylarkInfo) getMyInfoFromTarget(t).getValue("toolpath"); + toolPath = (SkylarkInfo) t.get("toolpath"); try { CcModule.toolPathFromSkylark(toolPath); fail("Should have failed because of wrong object type."); @@ -1716,12 +1680,11 @@ private void createCustomToolPathRule(String pkg, String name, String path) thro scratch.file( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl', 'tool_path')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(toolpath = struct(", + " return struct(toolpath = struct(", " name = " + name + ",", " path = " + path + ",", - " type_name = 'tool_path'))]", + " type_name = 'tool_path'))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -1760,7 +1723,7 @@ public void testMakeVariable() throws Exception { createMakeVariablerule("five", /* name= */ "'abc'", /* value= */ "'val'"); ConfiguredTarget t = getConfiguredTarget("//five:a"); - SkylarkInfo makeVariableProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + SkylarkInfo makeVariableProvider = (SkylarkInfo) t.get("variable"); assertThat(makeVariableProvider).isNotNull(); Pair makeVariable = CcModule.makeVariableFromSkylark(makeVariableProvider); assertThat(makeVariable).isNotNull(); @@ -1769,7 +1732,7 @@ public void testMakeVariable() throws Exception { createVariableWithValueRule("six", /* name= */ "'abc'", /* value= */ "'def'"); t = getConfiguredTarget("//six:a"); - SkylarkInfo variable = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + SkylarkInfo variable = (SkylarkInfo) t.get("variable"); try { CcModule.makeVariableFromSkylark(variable); fail("Should have failed because of wrong object type."); @@ -1784,11 +1747,10 @@ private void createMakeVariablerule(String pkg, String name, String value) throw scratch.file( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl', 'make_variable')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(variable = make_variable(", + " return struct(variable = make_variable(", " name = " + name + ",", - " value = " + value + "))]", + " value = " + value + "))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -1799,7 +1761,7 @@ public void testCustomMakeVariable() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//one:a"); - SkylarkInfo makeVariableProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + SkylarkInfo makeVariableProvider = (SkylarkInfo) t.get("variable"); CcModule.makeVariableFromSkylark(makeVariableProvider); fail("Should have failed because of empty string."); } catch (EvalException e) { @@ -1812,7 +1774,7 @@ public void testCustomMakeVariable() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//two:a"); - SkylarkInfo makeVariableProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + SkylarkInfo makeVariableProvider = (SkylarkInfo) t.get("variable"); CcModule.makeVariableFromSkylark(makeVariableProvider); fail("Should have failed because of empty string."); } catch (EvalException e) { @@ -1825,7 +1787,7 @@ public void testCustomMakeVariable() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//three:a"); - SkylarkInfo makeVariableProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + SkylarkInfo makeVariableProvider = (SkylarkInfo) t.get("variable"); CcModule.makeVariableFromSkylark(makeVariableProvider); fail("Should have failed because of empty string."); } catch (EvalException e) { @@ -1836,7 +1798,7 @@ public void testCustomMakeVariable() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//four:a"); - SkylarkInfo makeVariableProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + SkylarkInfo makeVariableProvider = (SkylarkInfo) t.get("variable"); CcModule.makeVariableFromSkylark(makeVariableProvider); fail("Should have failed because of empty string."); } catch (EvalException e) { @@ -1848,12 +1810,11 @@ private void createCustomMakeVariablerule(String pkg, String name, String value) throws Exception { scratch.file( pkg + "/foo.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(variable = struct(", + " return struct(variable = struct(", " name = " + name + ",", " value = " + value + ",", - " type_name = 'make_variable'))]", + " type_name = 'make_variable'))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -1893,7 +1854,7 @@ public void testWithFeatureSet() throws Exception { "five", /* features= */ "['f1', 'f2']", /* notFeatures= */ "['nf1', 'nf2']"); ConfiguredTarget t = getConfiguredTarget("//five:a"); - SkylarkInfo withFeatureSetProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("wfs"); + SkylarkInfo withFeatureSetProvider = (SkylarkInfo) t.get("wfs"); assertThat(withFeatureSetProvider).isNotNull(); WithFeatureSet withFeatureSet = CcModule.withFeatureSetFromSkylark(withFeatureSetProvider); assertThat(withFeatureSet).isNotNull(); @@ -1902,7 +1863,7 @@ public void testWithFeatureSet() throws Exception { createVariableWithValueRule("six", /* name= */ "'abc'", /* value= */ "'def'"); t = getConfiguredTarget("//six:a"); - SkylarkInfo variable = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + SkylarkInfo variable = (SkylarkInfo) t.get("variable"); try { CcModule.withFeatureSetFromSkylark(variable); fail("Should have failed because of wrong object type."); @@ -1918,11 +1879,10 @@ private void createWithFeatureSetRule(String pkg, String features, String notFea scratch.file( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl', 'with_feature_set')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(wfs = with_feature_set(", + " return struct(wfs = with_feature_set(", " features = " + features + ",", - " not_features = " + notFeatures + "))]", + " not_features = " + notFeatures + "))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -1933,7 +1893,7 @@ public void testCustomWithFeatureSet() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//one:a"); - SkylarkInfo withFeatureSetProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("wfs"); + SkylarkInfo withFeatureSetProvider = (SkylarkInfo) t.get("wfs"); assertThat(withFeatureSetProvider).isNotNull(); CcModule.withFeatureSetFromSkylark(withFeatureSetProvider); fail("Should have failed because of wrong object type."); @@ -1947,7 +1907,7 @@ public void testCustomWithFeatureSet() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//two:a"); - SkylarkInfo withFeatureSetProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("wfs"); + SkylarkInfo withFeatureSetProvider = (SkylarkInfo) t.get("wfs"); assertThat(withFeatureSetProvider).isNotNull(); CcModule.withFeatureSetFromSkylark(withFeatureSetProvider); fail("Should have failed because of wrong object type."); @@ -1961,7 +1921,7 @@ public void testCustomWithFeatureSet() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//three:a"); - SkylarkInfo withFeatureSetProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("wfs"); + SkylarkInfo withFeatureSetProvider = (SkylarkInfo) t.get("wfs"); assertThat(withFeatureSetProvider).isNotNull(); CcModule.withFeatureSetFromSkylark(withFeatureSetProvider); fail("Should have failed because of wrong object type."); @@ -1975,7 +1935,7 @@ public void testCustomWithFeatureSet() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//four:a"); - SkylarkInfo withFeatureSetProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("wfs"); + SkylarkInfo withFeatureSetProvider = (SkylarkInfo) t.get("wfs"); assertThat(withFeatureSetProvider).isNotNull(); CcModule.withFeatureSetFromSkylark(withFeatureSetProvider); fail("Should have failed because of wrong object type."); @@ -1991,12 +1951,11 @@ private void createCustomWithFeatureSetRule(String pkg, String features, String throws Exception { scratch.file( pkg + "/foo.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(wfs = struct(", + " return struct(wfs = struct(", " features = " + features + ",", " not_features = " + notFeatures + ",", - " type_name = 'with_feature_set'))]", + " type_name = 'with_feature_set'))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -2044,7 +2003,7 @@ public void testEnvSet() throws Exception { /* withFeatures= */ "[]"); ConfiguredTarget t = getConfiguredTarget("//five:a"); - SkylarkInfo envSetProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("envset"); + SkylarkInfo envSetProvider = (SkylarkInfo) t.get("envset"); assertThat(envSetProvider).isNotNull(); try { CcModule.envSetFromSkylark(envSetProvider); @@ -2067,14 +2026,14 @@ public void testEnvSet() throws Exception { /* withFeatures= */ "[with_feature_set(features = ['a'])]"); t = getConfiguredTarget("//seven:a"); - envSetProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("envset"); + envSetProvider = (SkylarkInfo) t.get("envset"); assertThat(envSetProvider).isNotNull(); EnvSet envSet = CcModule.envSetFromSkylark(envSetProvider); assertThat(envSet).isNotNull(); createVariableWithValueRule("eight", /* name= */ "'abc'", /* value= */ "'def'"); t = getConfiguredTarget("//eight:a"); - SkylarkInfo variable = (SkylarkInfo) getMyInfoFromTarget(t).getValue("variable"); + SkylarkInfo variable = (SkylarkInfo) t.get("variable"); try { CcModule.envSetFromSkylark(variable); fail("Should have failed because of wrong object type."); @@ -2091,12 +2050,11 @@ private void createEnvSetRule(String pkg, String actions, String envEntries, Str pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl',", " 'env_set', 'env_entry', 'with_feature_set', 'variable_with_value')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(envset = env_set(", + " return struct(envset = env_set(", " actions = " + actions + ",", " env_entries = " + envEntries + ",", - " with_features = " + withFeatures + "))]", + " with_features = " + withFeatures + "))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -2107,7 +2065,7 @@ public void testCustomEnvSet() throws Exception { createCustomEnvSetRule( "one", /* actions= */ "[]", /* envEntries= */ "None", /* withFeatures= */ "None"); ConfiguredTarget t = getConfiguredTarget("//one:a"); - SkylarkInfo envSetProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("envset"); + SkylarkInfo envSetProvider = (SkylarkInfo) t.get("envset"); assertThat(envSetProvider).isNotNull(); try { CcModule.envSetFromSkylark(envSetProvider); @@ -2121,7 +2079,7 @@ public void testCustomEnvSet() throws Exception { createCustomEnvSetRule( "two", /* actions= */ "['a1']", /* envEntries= */ "struct()", /* withFeatures= */ "None"); t = getConfiguredTarget("//two:a"); - envSetProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("envset"); + envSetProvider = (SkylarkInfo) t.get("envset"); assertThat(envSetProvider).isNotNull(); try { CcModule.envSetFromSkylark(envSetProvider); @@ -2138,7 +2096,7 @@ public void testCustomEnvSet() throws Exception { /* envEntries= */ "[struct()]", /* withFeatures= */ "None"); t = getConfiguredTarget("//three:a"); - envSetProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("envset"); + envSetProvider = (SkylarkInfo) t.get("envset"); assertThat(envSetProvider).isNotNull(); try { CcModule.envSetFromSkylark(envSetProvider); @@ -2155,7 +2113,7 @@ public void testCustomEnvSet() throws Exception { /* envEntries= */ "[env_entry(key = 'a', value = 'b')]", /* withFeatures= */ "'a'"); t = getConfiguredTarget("//four:a"); - envSetProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("envset"); + envSetProvider = (SkylarkInfo) t.get("envset"); assertThat(envSetProvider).isNotNull(); try { CcModule.envSetFromSkylark(envSetProvider); @@ -2172,7 +2130,7 @@ public void testCustomEnvSet() throws Exception { /* envEntries= */ "[env_entry(key = 'a', value = 'b')]", /* withFeatures= */ "[env_entry(key = 'a', value = 'b')]"); t = getConfiguredTarget("//five:a"); - envSetProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("envset"); + envSetProvider = (SkylarkInfo) t.get("envset"); assertThat(envSetProvider).isNotNull(); try { CcModule.envSetFromSkylark(envSetProvider); @@ -2190,13 +2148,12 @@ private void createCustomEnvSetRule( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl',", " 'env_entry', 'with_feature_set', 'variable_with_value')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(envset = struct(", + " return struct(envset = struct(", " actions = " + actions + ",", " env_entries = " + envEntries + ",", " with_features = " + withFeatures + ",", - " type_name = 'env_set'))]", + " type_name = 'env_set'))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -2329,7 +2286,7 @@ public void testFlagGroup() throws Exception { /* expandIfEqual= */ "'a'"); ConfiguredTarget t = getConfiguredTarget("//eight:a"); - SkylarkInfo flagGroupProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flaggroup"); + SkylarkInfo flagGroupProvider = (SkylarkInfo) t.get("flaggroup"); assertThat(flagGroupProvider).isNotNull(); try { CcModule.flagGroupFromSkylark(flagGroupProvider); @@ -2354,7 +2311,7 @@ public void testFlagGroup() throws Exception { /* expandIfEqual= */ "variable_with_value(name = 'a', value = 'b')"); t = getConfiguredTarget("//nine:a"); - flagGroupProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flaggroup"); + flagGroupProvider = (SkylarkInfo) t.get("flaggroup"); assertThat(flagGroupProvider).isNotNull(); FlagGroup f = CcModule.flagGroupFromSkylark(flagGroupProvider); assertThat(f).isNotNull(); @@ -2371,7 +2328,7 @@ public void testFlagGroup() throws Exception { /* expandIfEqual= */ "variable_with_value(name = 'a', value = 'b')"); t = getConfiguredTarget("//ten:a"); - flagGroupProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flaggroup"); + flagGroupProvider = (SkylarkInfo) t.get("flaggroup"); assertThat(flagGroupProvider).isNotNull(); try { CcModule.flagGroupFromSkylark(flagGroupProvider); @@ -2398,9 +2355,8 @@ private void createFlagGroupRule( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl',", " 'env_set', 'env_entry', 'with_feature_set', 'variable_with_value', 'flag_group')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(flaggroup = flag_group(", + " return struct(flaggroup = flag_group(", " flags = " + flags + ",", " flag_groups = " + flagGroups + ",", " expand_if_true = " + expandIfTrue + ",", @@ -2408,7 +2364,7 @@ private void createFlagGroupRule( " expand_if_available = " + expandIfAvailable + ",", " expand_if_not_available = " + expandIfNotAvailable + ",", " expand_if_equal = " + expandIfEqual + ",", - " iterate_over = " + iterateOver + "))]", + " iterate_over = " + iterateOver + "))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -2429,7 +2385,7 @@ public void testSingleChunkFlagIsUsed() throws Exception { /* expandIfEqual= */ "None"); ConfiguredTarget t = getConfiguredTarget("//single_chunk_flag:a"); - SkylarkInfo flagGroupProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flaggroup"); + SkylarkInfo flagGroupProvider = (SkylarkInfo) t.get("flaggroup"); assertThat(flagGroupProvider).isNotNull(); FlagGroup flagGroup = CcModule.flagGroupFromSkylark(flagGroupProvider); assertThat(flagGroup.getExpandables()).isNotEmpty(); @@ -2452,7 +2408,7 @@ public void testCustomFlagGroup() throws Exception { /* expandIfEqual= */ "None"); ConfiguredTarget t = getConfiguredTarget("//one:a"); - SkylarkInfo flagGroupProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flaggroup"); + SkylarkInfo flagGroupProvider = (SkylarkInfo) t.get("flaggroup"); assertThat(flagGroupProvider).isNotNull(); try { CcModule.flagGroupFromSkylark(flagGroupProvider); @@ -2475,7 +2431,7 @@ public void testCustomFlagGroup() throws Exception { /* expandIfEqual= */ "variable_with_value(name = 'a', value = 'b')"); t = getConfiguredTarget("//two:a"); - flagGroupProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flaggroup"); + flagGroupProvider = (SkylarkInfo) t.get("flaggroup"); assertThat(flagGroupProvider).isNotNull(); try { CcModule.flagGroupFromSkylark(flagGroupProvider); @@ -2498,7 +2454,7 @@ public void testCustomFlagGroup() throws Exception { /* expandIfEqual= */ "variable_with_value(name = 'a', value = 'b')"); t = getConfiguredTarget("//three:a"); - flagGroupProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flaggroup"); + flagGroupProvider = (SkylarkInfo) t.get("flaggroup"); assertThat(flagGroupProvider).isNotNull(); try { CcModule.flagGroupFromSkylark(flagGroupProvider); @@ -2521,7 +2477,7 @@ public void testCustomFlagGroup() throws Exception { /* expandIfEqual= */ "variable_with_value(name = 'a', value = 'b')"); t = getConfiguredTarget("//four:a"); - flagGroupProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flaggroup"); + flagGroupProvider = (SkylarkInfo) t.get("flaggroup"); assertThat(flagGroupProvider).isNotNull(); try { CcModule.flagGroupFromSkylark(flagGroupProvider); @@ -2544,7 +2500,7 @@ public void testCustomFlagGroup() throws Exception { /* expandIfEqual= */ "variable_with_value(name = 'a', value = 'b')"); t = getConfiguredTarget("//five:a"); - flagGroupProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flaggroup"); + flagGroupProvider = (SkylarkInfo) t.get("flaggroup"); assertThat(flagGroupProvider).isNotNull(); try { CcModule.flagGroupFromSkylark(flagGroupProvider); @@ -2567,7 +2523,7 @@ public void testCustomFlagGroup() throws Exception { /* expandIfEqual= */ "struct(name = 'a', value = 'b')"); t = getConfiguredTarget("//six:a"); - flagGroupProvider = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flaggroup"); + flagGroupProvider = (SkylarkInfo) t.get("flaggroup"); assertThat(flagGroupProvider).isNotNull(); try { CcModule.flagGroupFromSkylark(flagGroupProvider); @@ -2594,9 +2550,8 @@ private void createCustomFlagGroupRule( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl',", " 'env_set', 'env_entry', 'with_feature_set', 'variable_with_value', 'flag_group')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(flaggroup = struct(", + " return struct(flaggroup = struct(", " flags = " + flags + ",", " flag_groups = " + flagGroups + ",", " expand_if_true = " + expandIfTrue + ",", @@ -2605,7 +2560,7 @@ private void createCustomFlagGroupRule( " expand_if_not_available = " + expandIfNotAvailable + ",", " expand_if_equal = " + expandIfEqual + ",", " iterate_over = " + iterateOver + ",", - " type_name = 'flag_group'))]", + " type_name = 'flag_group'))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -2641,7 +2596,7 @@ public void testTool() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//four:a"); - SkylarkInfo toolStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("tool"); + SkylarkInfo toolStruct = (SkylarkInfo) t.getValue("tool"); assertThat(toolStruct).isNotNull(); CcModule.toolFromSkylark(toolStruct); fail("Should have failed because of wrong object type."); @@ -2659,7 +2614,7 @@ public void testTool() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//five:a"); - SkylarkInfo toolStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("tool"); + SkylarkInfo toolStruct = (SkylarkInfo) t.getValue("tool"); assertThat(toolStruct).isNotNull(); CcModule.toolFromSkylark(toolStruct); fail("Should have failed because of wrong object type."); @@ -2678,7 +2633,7 @@ public void testTool() throws Exception { /* requirements= */ "['a', 'b']"); ConfiguredTarget t = getConfiguredTarget("//six:a"); - SkylarkInfo toolStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("tool"); + SkylarkInfo toolStruct = (SkylarkInfo) t.getValue("tool"); assertThat(toolStruct).isNotNull(); Tool tool = CcModule.toolFromSkylark(toolStruct); assertThat(tool.getExecutionRequirements()).containsExactly("a", "b"); @@ -2692,12 +2647,11 @@ private void createToolRule(String pkg, String path, String withFeatures, String scratch.file( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl', 'with_feature_set', 'tool')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(tool = tool(", + " return struct(tool = tool(", " path = " + path + ",", " with_features = " + withFeatures + ",", - " execution_requirements = " + requirements + "))]", + " execution_requirements = " + requirements + "))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -2710,7 +2664,7 @@ public void testCustomTool() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//one:a"); - SkylarkInfo toolStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("tool"); + SkylarkInfo toolStruct = (SkylarkInfo) t.getValue("tool"); assertThat(toolStruct).isNotNull(); CcModule.toolFromSkylark(toolStruct); fail("Should have failed because of wrong object type."); @@ -2725,7 +2679,7 @@ public void testCustomTool() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//two:a"); - SkylarkInfo toolStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("tool"); + SkylarkInfo toolStruct = (SkylarkInfo) t.getValue("tool"); assertThat(toolStruct).isNotNull(); CcModule.toolFromSkylark(toolStruct); fail("Should have failed because of wrong object type."); @@ -2738,7 +2692,7 @@ public void testCustomTool() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//three:a"); - SkylarkInfo toolStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("tool"); + SkylarkInfo toolStruct = (SkylarkInfo) t.getValue("tool"); assertThat(toolStruct).isNotNull(); CcModule.toolFromSkylark(toolStruct); fail("Should have failed because of wrong object type."); @@ -2756,7 +2710,7 @@ public void testCustomTool() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//four:a"); - SkylarkInfo toolStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("tool"); + SkylarkInfo toolStruct = (SkylarkInfo) t.getValue("tool"); assertThat(toolStruct).isNotNull(); CcModule.toolFromSkylark(toolStruct); fail("Should have failed because of wrong object type."); @@ -2771,7 +2725,7 @@ public void testCustomTool() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//five:a"); - SkylarkInfo toolStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("tool"); + SkylarkInfo toolStruct = (SkylarkInfo) t.getValue("tool"); assertThat(toolStruct).isNotNull(); CcModule.toolFromSkylark(toolStruct); fail("Should have failed because of wrong object type."); @@ -2787,7 +2741,7 @@ public void testCustomTool() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//six:a"); - SkylarkInfo toolStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("tool"); + SkylarkInfo toolStruct = (SkylarkInfo) t.getValue("tool"); assertThat(toolStruct).isNotNull(); CcModule.toolFromSkylark(toolStruct); fail("Should have failed because of wrong object type."); @@ -2805,13 +2759,12 @@ private void createCustomToolRule( scratch.file( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl', 'with_feature_set')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(tool = struct(", + " return struct(tool = struct(", " path = " + path + ",", " with_features = " + withFeatures + ",", " execution_requirements = " + requirements + ",", - " type_name = 'tool'))]", + " type_name = 'tool'))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -2844,7 +2797,7 @@ public void testFlagSet() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//four:a"); - SkylarkInfo flagSetStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flagset"); + SkylarkInfo flagSetStruct = (SkylarkInfo) t.getValue("flagset"); assertThat(flagSetStruct).isNotNull(); CcModule.flagSetFromSkylark(flagSetStruct, /* actionName= */ null); fail("Should have failed because of wrong object type."); @@ -2862,7 +2815,7 @@ public void testFlagSet() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//five:a"); - SkylarkInfo flagSetStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flagset"); + SkylarkInfo flagSetStruct = (SkylarkInfo) t.getValue("flagset"); assertThat(flagSetStruct).isNotNull(); CcModule.flagSetFromSkylark(flagSetStruct, /* actionName= */ null); fail("Should have failed because of wrong object type."); @@ -2880,7 +2833,7 @@ public void testFlagSet() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//six:a"); - SkylarkInfo flagSetStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flagset"); + SkylarkInfo flagSetStruct = (SkylarkInfo) t.getValue("flagset"); assertThat(flagSetStruct).isNotNull(); CcModule.flagSetFromSkylark(flagSetStruct, /* actionName= */ null); fail("Should have failed because of wrong object type."); @@ -2896,7 +2849,7 @@ public void testFlagSet() throws Exception { /* flagGroups= */ "[flag_group(flags = ['a'])]", /* withFeatures= */ "[with_feature_set(features = ['a'])]"); ConfiguredTarget t = getConfiguredTarget("//seven:a"); - SkylarkInfo flagSetStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flagset"); + SkylarkInfo flagSetStruct = (SkylarkInfo) t.getValue("flagset"); assertThat(flagSetStruct).isNotNull(); FlagSet f = CcModule.flagSetFromSkylark(flagSetStruct, /* actionName= */ null); assertThat(f).isNotNull(); @@ -2909,7 +2862,7 @@ public void testFlagSet() throws Exception { try { t = getConfiguredTarget("//eight:a"); - flagSetStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flagset"); + flagSetStruct = (SkylarkInfo) t.getValue("flagset"); assertThat(flagSetStruct).isNotNull(); CcModule.flagSetFromSkylark(flagSetStruct, /* actionName= */ "action"); fail("Should have failed because of nonempty actions field when created from action_config."); @@ -2925,7 +2878,7 @@ public void testFlagSet() throws Exception { /* flagGroups= */ "[flag_group(flags = ['a'])]", /* withFeatures= */ "[with_feature_set(features = ['a'])]"); t = getConfiguredTarget("//nine:a"); - flagSetStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flagset"); + flagSetStruct = (SkylarkInfo) t.getValue("flagset"); assertThat(flagSetStruct).isNotNull(); f = CcModule.flagSetFromSkylark(flagSetStruct, /* actionName= */ "action"); assertThat(f).isNotNull(); @@ -2939,12 +2892,11 @@ private void createFlagSetRule(String pkg, String actions, String flagGroups, St "load('//tools/cpp:cc_toolchain_config_lib.bzl',", " 'env_set', 'env_entry', 'with_feature_set', 'variable_with_value', 'flag_group',", " 'flag_set')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(flagset = flag_set(", + " return struct(flagset = flag_set(", " flag_groups = " + flagGroups + ",", " actions = " + actions + ",", - " with_features = " + withFeatures + "))]", + " with_features = " + withFeatures + "))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -2956,7 +2908,7 @@ public void testCustomFlagSet() throws Exception { "one", /* actions= */ "[]", /* flagGroups= */ "[]", /* withFeatures= */ "[]"); ConfiguredTarget target = getConfiguredTarget("//one:a"); - SkylarkInfo flagSet = (SkylarkInfo) getMyInfoFromTarget(target).getValue("flagset"); + SkylarkInfo flagSet = (SkylarkInfo) target.getValue("flagset"); assertThat(flagSet).isNotNull(); FlagSet flagSetObject = CcModule.flagSetFromSkylark(flagSet, /* actionName */ null); assertThat(flagSetObject).isNotNull(); @@ -2966,7 +2918,7 @@ public void testCustomFlagSet() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//two:a"); - SkylarkInfo flagSetStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flagset"); + SkylarkInfo flagSetStruct = (SkylarkInfo) t.getValue("flagset"); assertThat(flagSetStruct).isNotNull(); CcModule.flagSetFromSkylark(flagSetStruct, /* actionName */ null); fail("Should have failed because of wrong object type."); @@ -2981,7 +2933,7 @@ public void testCustomFlagSet() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//three:a"); - SkylarkInfo flagSetStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flagset"); + SkylarkInfo flagSetStruct = (SkylarkInfo) t.getValue("flagset"); assertThat(flagSetStruct).isNotNull(); CcModule.flagSetFromSkylark(flagSetStruct, /* actionName */ null); fail("Should have failed because of wrong object type."); @@ -2996,7 +2948,7 @@ public void testCustomFlagSet() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//four:a"); - SkylarkInfo flagSetStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("flagset"); + SkylarkInfo flagSetStruct = (SkylarkInfo) t.getValue("flagset"); assertThat(flagSetStruct).isNotNull(); CcModule.flagSetFromSkylark(flagSetStruct, /* actionName */ null); fail("Should have failed because of wrong object type."); @@ -3014,13 +2966,12 @@ private void createCustomFlagSetRule( "load('//tools/cpp:cc_toolchain_config_lib.bzl',", " 'env_set', 'env_entry', 'with_feature_set', 'variable_with_value', 'flag_group',", " 'flag_set')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(flagset = struct(", + " return struct(flagset = struct(", " flag_groups = " + flagGroups + ",", " actions = " + actions + ",", " with_features = " + withFeatures + ",", - " type_name = 'flag_set'))]", + " type_name = 'flag_set'))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -3063,7 +3014,7 @@ public void testActionConfig() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//three:a"); - SkylarkInfo actionConfigStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("config"); + SkylarkInfo actionConfigStruct = (SkylarkInfo) t.getValue("config"); assertThat(actionConfigStruct).isNotNull(); CcModule.actionConfigFromSkylark(actionConfigStruct); fail("Should have failed because of wrong object type."); @@ -3083,7 +3034,7 @@ public void testActionConfig() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//four:a"); - SkylarkInfo actionConfigStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("config"); + SkylarkInfo actionConfigStruct = (SkylarkInfo) t.getValue("config"); assertThat(actionConfigStruct).isNotNull(); CcModule.actionConfigFromSkylark(actionConfigStruct); fail("Should have failed because of wrong object type."); @@ -3116,7 +3067,7 @@ public void testActionConfig() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//six:a"); - SkylarkInfo actionConfigStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("config"); + SkylarkInfo actionConfigStruct = (SkylarkInfo) t.getValue("config"); assertThat(actionConfigStruct).isNotNull(); CcModule.actionConfigFromSkylark(actionConfigStruct); fail("Should have failed because of wrong object type."); @@ -3136,7 +3087,7 @@ public void testActionConfig() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//seven:a"); - SkylarkInfo actionConfigStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("config"); + SkylarkInfo actionConfigStruct = (SkylarkInfo) t.getValue("config"); assertThat(actionConfigStruct).isNotNull(); CcModule.actionConfigFromSkylark(actionConfigStruct); fail("Should have failed because of wrong object type."); @@ -3155,7 +3106,7 @@ public void testActionConfig() throws Exception { /* implies= */ "['a', 'b']"); ConfiguredTarget t = getConfiguredTarget("//eight:a"); - SkylarkInfo actionConfigStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("config"); + SkylarkInfo actionConfigStruct = (SkylarkInfo) t.getValue("config"); assertThat(actionConfigStruct).isNotNull(); ActionConfig a = CcModule.actionConfigFromSkylark(actionConfigStruct); assertThat(a).isNotNull(); @@ -3174,7 +3125,7 @@ public void testActionConfig() throws Exception { try { t = getConfiguredTarget("//nine:a"); - actionConfigStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("config"); + actionConfigStruct = (SkylarkInfo) t.getValue("config"); assertThat(actionConfigStruct).isNotNull(); CcModule.actionConfigFromSkylark(actionConfigStruct); fail("Should have failed because of wrong object type."); @@ -3196,7 +3147,7 @@ public void testActionConfig() throws Exception { try { t = getConfiguredTarget("//ten:a"); - actionConfigStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("config"); + actionConfigStruct = (SkylarkInfo) t.getValue("config"); assertThat(actionConfigStruct).isNotNull(); CcModule.actionConfigFromSkylark(actionConfigStruct); fail("Should have failed because of wrong object type."); @@ -3217,14 +3168,13 @@ private void createActionConfigRule( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl', 'with_feature_set',", " 'tool', 'flag_set', 'action_config', 'flag_group')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(config = action_config(", + " return struct(config = action_config(", " action_name = " + actionName + ",", " enabled = " + enabled + ",", " tools = " + tools + ",", " flag_sets = " + flagSets + ",", - " implies = " + implies + "))]", + " implies = " + implies + "))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -3242,7 +3192,7 @@ public void testCustomActionConfig() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//one:a"); - SkylarkInfo actionConfigStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("config"); + SkylarkInfo actionConfigStruct = (SkylarkInfo) t.getValue("config"); assertThat(actionConfigStruct).isNotNull(); CcModule.actionConfigFromSkylark(actionConfigStruct); fail("Should have failed because of wrong object type."); @@ -3261,7 +3211,7 @@ public void testCustomActionConfig() throws Exception { /* implies= */ "[]"); try { ConfiguredTarget t = getConfiguredTarget("//two:a"); - SkylarkInfo actionConfigStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("config"); + SkylarkInfo actionConfigStruct = (SkylarkInfo) t.getValue("config"); assertThat(actionConfigStruct).isNotNull(); CcModule.actionConfigFromSkylark(actionConfigStruct); fail("Should have failed because of wrong object type."); @@ -3281,7 +3231,7 @@ public void testCustomActionConfig() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//three:a"); - SkylarkInfo actionConfigStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("config"); + SkylarkInfo actionConfigStruct = (SkylarkInfo) t.getValue("config"); assertThat(actionConfigStruct).isNotNull(); CcModule.actionConfigFromSkylark(actionConfigStruct); fail("Should have failed because of wrong object type."); @@ -3301,7 +3251,7 @@ public void testCustomActionConfig() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//four:a"); - SkylarkInfo actionConfigStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("config"); + SkylarkInfo actionConfigStruct = (SkylarkInfo) t.getValue("config"); assertThat(actionConfigStruct).isNotNull(); CcModule.actionConfigFromSkylark(actionConfigStruct); fail("Should have failed because of wrong object type."); @@ -3321,7 +3271,7 @@ public void testCustomActionConfig() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//five:a"); - SkylarkInfo actionConfigStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("config"); + SkylarkInfo actionConfigStruct = (SkylarkInfo) t.getValue("config"); assertThat(actionConfigStruct).isNotNull(); CcModule.actionConfigFromSkylark(actionConfigStruct); fail("Should have failed because of wrong object type."); @@ -3339,15 +3289,14 @@ private void createCustomActionConfigRule( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl', 'with_feature_set',", " 'tool', 'flag_set', 'action_config', )", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(config = struct(", + " return struct(config = struct(", " action_name = " + actionName + ",", " enabled = " + enabled + ",", " tools = " + tools + ",", " flag_sets = " + flagSets + ",", " implies = " + implies + ",", - " type_name = 'action_config'))]", + " type_name = 'action_config'))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -3367,7 +3316,7 @@ public void testFeature() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//one:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3403,7 +3352,7 @@ public void testFeature() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//three:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3425,7 +3374,7 @@ public void testFeature() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//four:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3448,7 +3397,7 @@ public void testFeature() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//five:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3469,7 +3418,7 @@ public void testFeature() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//six:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3492,7 +3441,7 @@ public void testFeature() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//seven:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3514,7 +3463,7 @@ public void testFeature() throws Exception { /* provides= */ "['a', 'b', 'c']"); ConfiguredTarget t = getConfiguredTarget("//eight:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); Feature a = CcModule.featureFromSkylark(featureStruct); assertThat(a).isNotNull(); @@ -3531,7 +3480,7 @@ public void testFeature() throws Exception { try { t = getConfiguredTarget("//nine:a"); - featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3555,7 +3504,7 @@ public void testFeature() throws Exception { try { t = getConfiguredTarget("//ten:a"); - featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3582,16 +3531,15 @@ private void createFeatureRule( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl', 'with_feature_set', 'feature_set',", " 'flag_set', 'flag_group', 'tool', 'env_set', 'env_entry', 'feature')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(f = feature(", + " return struct(f = feature(", " name = " + name + ",", " enabled = " + enabled + ",", " flag_sets = " + flagSets + ",", " env_sets = " + envSets + ",", " requires = " + requires + ",", " implies = " + implies + ",", - " provides = " + provides + "))]", + " provides = " + provides + "))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -3611,7 +3559,7 @@ public void testCustomFeature() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//one:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3630,7 +3578,7 @@ public void testCustomFeature() throws Exception { /* provides= */ "[]"); try { ConfiguredTarget t = getConfiguredTarget("//two:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3652,7 +3600,7 @@ public void testCustomFeature() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//three:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3674,7 +3622,7 @@ public void testCustomFeature() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//four:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3696,7 +3644,7 @@ public void testCustomFeature() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//five:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3718,7 +3666,7 @@ public void testCustomFeature() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//six:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3740,7 +3688,7 @@ public void testCustomFeature() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//seven:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of wrong object type."); @@ -3762,7 +3710,7 @@ public void testCustomFeature() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//eight:a"); - SkylarkInfo featureStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("f"); + SkylarkInfo featureStruct = (SkylarkInfo) t.getValue("f"); assertThat(featureStruct).isNotNull(); CcModule.featureFromSkylark(featureStruct); fail("Should have failed because of empty 'actions' parameter in flag_set."); @@ -3787,9 +3735,8 @@ private void createCustomFeatureRule( pkg + "/foo.bzl", "load('//tools/cpp:cc_toolchain_config_lib.bzl', 'with_feature_set', 'feature_set',", " 'flag_set', 'flag_group', 'tool', 'env_set', 'env_entry', 'feature')", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(f = struct(", + " return struct(f = struct(", " name = " + name + ",", " enabled = " + enabled + ",", " flag_sets = " + flagSets + ",", @@ -3797,7 +3744,7 @@ private void createCustomFeatureRule( " requires = " + requires + ",", " implies = " + implies + ",", " provides = " + provides + ",", - " type_name = 'feature'))]", + " type_name = 'feature'))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -3810,8 +3757,7 @@ public void testCustomArtifactNamePattern() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//one:a"); - SkylarkInfo artifactNamePatternStruct = - (SkylarkInfo) getMyInfoFromTarget(t).getValue("namepattern"); + SkylarkInfo artifactNamePatternStruct = (SkylarkInfo) t.getValue("namepattern"); assertThat(artifactNamePatternStruct).isNotNull(); CcModule.artifactNamePatternFromSkylark(artifactNamePatternStruct); fail("Should have failed because of wrong object type."); @@ -3829,8 +3775,7 @@ public void testCustomArtifactNamePattern() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//two:a"); - SkylarkInfo artifactNamePatternStruct = - (SkylarkInfo) getMyInfoFromTarget(t).getValue("namepattern"); + SkylarkInfo artifactNamePatternStruct = (SkylarkInfo) t.getValue("namepattern"); assertThat(artifactNamePatternStruct).isNotNull(); CcModule.artifactNamePatternFromSkylark(artifactNamePatternStruct); fail("Should have failed because of wrong object type."); @@ -3848,8 +3793,7 @@ public void testCustomArtifactNamePattern() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//three:a"); - SkylarkInfo artifactNamePatternStruct = - (SkylarkInfo) getMyInfoFromTarget(t).getValue("namepattern"); + SkylarkInfo artifactNamePatternStruct = (SkylarkInfo) t.getValue("namepattern"); assertThat(artifactNamePatternStruct).isNotNull(); CcModule.artifactNamePatternFromSkylark(artifactNamePatternStruct); fail("Should have failed because of wrong object type."); @@ -3862,8 +3806,7 @@ public void testCustomArtifactNamePattern() throws Exception { try { ConfiguredTarget t = getConfiguredTarget("//four:a"); - SkylarkInfo artifactNamePatternStruct = - (SkylarkInfo) getMyInfoFromTarget(t).getValue("namepattern"); + SkylarkInfo artifactNamePatternStruct = (SkylarkInfo) t.getValue("namepattern"); assertThat(artifactNamePatternStruct).isNotNull(); CcModule.artifactNamePatternFromSkylark(artifactNamePatternStruct); fail("Should have failed because of empty string."); @@ -3878,8 +3821,7 @@ public void testCustomArtifactNamePattern() throws Exception { "five", /* categoryName= */ "'executable'", /* extension= */ "''", /* prefix= */ "''"); ConfiguredTarget t = getConfiguredTarget("//five:a"); - SkylarkInfo artifactNamePatternStruct = - (SkylarkInfo) getMyInfoFromTarget(t).getValue("namepattern"); + SkylarkInfo artifactNamePatternStruct = (SkylarkInfo) t.getValue("namepattern"); assertThat(artifactNamePatternStruct).isNotNull(); ArtifactNamePattern artifactNamePattern = CcModule.artifactNamePatternFromSkylark(artifactNamePatternStruct); @@ -3889,7 +3831,7 @@ public void testCustomArtifactNamePattern() throws Exception { "six", /* categoryName= */ "'executable'", /* extension= */ "None", /* prefix= */ "None"); t = getConfiguredTarget("//six:a"); - artifactNamePatternStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("namepattern"); + artifactNamePatternStruct = (SkylarkInfo) t.getValue("namepattern"); assertThat(artifactNamePatternStruct).isNotNull(); artifactNamePattern = CcModule.artifactNamePatternFromSkylark(artifactNamePatternStruct); assertThat(artifactNamePattern).isNotNull(); @@ -3899,7 +3841,7 @@ public void testCustomArtifactNamePattern() throws Exception { try { t = getConfiguredTarget("//seven:a"); - artifactNamePatternStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("namepattern"); + artifactNamePatternStruct = (SkylarkInfo) t.getValue("namepattern"); assertThat(artifactNamePatternStruct).isNotNull(); CcModule.artifactNamePatternFromSkylark(artifactNamePatternStruct); fail("Should have failed because of unrecognized category."); @@ -3915,7 +3857,7 @@ public void testCustomArtifactNamePattern() throws Exception { try { t = getConfiguredTarget("//eight:a"); - artifactNamePatternStruct = (SkylarkInfo) getMyInfoFromTarget(t).getValue("namepattern"); + artifactNamePatternStruct = (SkylarkInfo) t.getValue("namepattern"); assertThat(artifactNamePatternStruct).isNotNull(); CcModule.artifactNamePatternFromSkylark(artifactNamePatternStruct); fail("Should have failed because of unrecognized extension."); @@ -3928,13 +3870,12 @@ private void createCustomArtifactNamePatternRule( String pkg, String categoryName, String extension, String prefix) throws Exception { scratch.file( pkg + "/foo.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", - " return [MyInfo(namepattern = struct(", + " return struct(namepattern = struct(", " category_name = " + categoryName + ",", " extension = " + extension + ",", " prefix = " + prefix + ",", - " type_name = 'artifact_name_pattern'))]", + " type_name = 'artifact_name_pattern'))", "crule = rule(implementation = _impl)"); scratch.file(pkg + "/BUILD", "load(':foo.bzl', 'crule')", "crule(name = 'a')"); } @@ -4504,13 +4445,12 @@ public void testGetLegacyCcFlagsMakeVariable() throws Exception { loadCcToolchainConfigLib(); scratch.file( "a/rule.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", " toolchain = ctx.attr._cc_toolchain[cc_common.CcToolchainInfo]", " cc_flags = cc_common.legacy_cc_flags_make_variable_do_not_use(", " cc_toolchain = toolchain)", - " return [MyInfo(", - " cc_flags = cc_flags)]", + " return struct(", + " cc_flags = cc_flags)", "cc_flags = rule(", " _impl,", " attrs = { ", @@ -4525,9 +4465,9 @@ public void testGetLegacyCcFlagsMakeVariable() throws Exception { "cc_toolchain_alias(name='alias')", "cc_flags(name='r')"); + ConfiguredTarget r = getConfiguredTarget("//a:r"); @SuppressWarnings("unchecked") - String ccFlags = - (String) getMyInfoFromTarget(getConfiguredTarget("//a:r")).getValue("cc_flags"); + String ccFlags = (String) r.get("cc_flags"); assertThat(ccFlags).isEqualTo("-test-cflag1 -testcflag2"); } @@ -4535,12 +4475,11 @@ public void testGetLegacyCcFlagsMakeVariable() throws Exception { private boolean toolchainResolutionEnabled() throws Exception { scratch.file( "a/rule.bzl", - "load('//myinfo:myinfo.bzl', 'MyInfo')", "def _impl(ctx):", " toolchain_resolution_enabled = cc_common.is_cc_toolchain_resolution_enabled_do_not_use(", " ctx = ctx)", - " return [MyInfo(", - " toolchain_resolution_enabled = toolchain_resolution_enabled)]", + " return struct(", + " toolchain_resolution_enabled = toolchain_resolution_enabled)", "toolchain_resolution_enabled = rule(", " _impl,", ");"); @@ -4552,8 +4491,7 @@ private boolean toolchainResolutionEnabled() throws Exception { ConfiguredTarget r = getConfiguredTarget("//a:r"); @SuppressWarnings("unchecked") // Use an extra variable in order to suppress the warning. - boolean toolchainResolutionEnabled = - (boolean) getMyInfoFromTarget(r).getValue("toolchain_resolution_enabled"); + boolean toolchainResolutionEnabled = (boolean) r.get("toolchain_resolution_enabled"); return toolchainResolutionEnabled; }