Skip to content

Commit

Permalink
Update all attributes which use the host transition to use the host t…
Browse files Browse the repository at this point in the history
…ransition

factory.

This will help ensure that calls to TransitionFactory.isHost will always be
correct.

Part of #7814.

PiperOrigin-RevId: 240977747
  • Loading branch information
katre authored and copybara-github committed Mar 29, 2019
1 parent d52ec85 commit ffb65c8
Show file tree
Hide file tree
Showing 46 changed files with 276 additions and 242 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,31 +167,31 @@ public Object getDefault(AttributeMap rule) {
// Input files for every test action
.add(
attr("$test_wrapper", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.singleArtifact()
.value(env.getToolsLabel("//tools/test:test_wrapper")))
.add(
attr("$xml_writer", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.singleArtifact()
.value(env.getToolsLabel("//tools/test:xml_writer")))
.add(
attr("$test_runtime", LABEL_LIST)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.value(ImmutableList.of(env.getToolsLabel("//tools/test:runtime"))))
.add(
attr("$test_setup_script", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.singleArtifact()
.value(env.getToolsLabel("//tools/test:test_setup")))
.add(
attr("$xml_generator_script", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.singleArtifact()
.value(env.getToolsLabel("//tools/test:test_xml_generator")))
.add(
attr("$collect_coverage_script", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.singleArtifact()
.value(env.getToolsLabel("//tools/test:collect_coverage")))
// Input files for test actions collecting code coverage
Expand All @@ -202,7 +202,7 @@ public Object getDefault(AttributeMap rule) {
// Used in the one-per-build coverage report generation action.
.add(
attr(":coverage_report_generator", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.value(
coverageReportGeneratorAttribute(
env.getToolsLabel(DEFAULT_COVERAGE_REPORT_GENERATOR_VALUE))))
Expand Down Expand Up @@ -240,7 +240,7 @@ public static RuleClass.Builder commonCoreAndSkylarkAttributes(RuleClass.Builder
.add(
attr("visibility", NODEP_LABEL_LIST)
.orderIndependent()
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.nonconfigurable(
"special attribute integrated more deeply into Bazel's core logic"))
.add(
Expand Down Expand Up @@ -275,20 +275,20 @@ public static RuleClass.Builder commonCoreAndSkylarkAttributes(RuleClass.Builder
.add(attr("features", STRING_LIST).orderIndependent())
.add(
attr(":action_listener", LABEL_LIST)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.value(ACTION_LISTENER))
.add(
attr(RuleClass.COMPATIBLE_ENVIRONMENT_ATTR, LABEL_LIST)
.allowedRuleClasses(EnvironmentRule.RULE_NAME)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.allowedFileTypes(FileTypeSet.NO_FILE)
.dontCheckConstraints()
.nonconfigurable(
"special logic for constraints and select: see ConstraintSemantics"))
.add(
attr(RuleClass.RESTRICTED_ENVIRONMENT_ATTR, LABEL_LIST)
.allowedRuleClasses(EnvironmentRule.RULE_NAME)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.allowedFileTypes(FileTypeSet.NO_FILE)
.dontCheckConstraints()
.nonconfigurable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private Whitelist() {}
public static Attribute.Builder<Label> getAttributeFromWhitelistName(String whitelistName) {
String attributeName = getAttributeNameFromWhitelistName(whitelistName);
return attr(attributeName, LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.mandatoryNativeProviders(ImmutableList.of(PackageSpecificationProvider.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ && containsNonNoneKey(arguments, ALLOW_SINGLE_FILE_ARG)) {
"late-bound attributes must not have a split configuration transition");
}
if (trans.equals("host")) {
builder.cfg(HostTransition.INSTANCE);
builder.cfg(HostTransition.createFactory());
} else if (trans instanceof SplitTransition) {
builder.cfg((SplitTransition) trans);
} else if (trans instanceof TransitionFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,48 +172,48 @@ public static final RuleClass getTestBaseRule(String toolsRepository) {
// Input files for every test action
.add(
attr("$test_wrapper", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.singleArtifact()
.value(labelCache.getUnchecked(toolsRepository + "//tools/test:test_wrapper")))
.add(
attr("$xml_writer", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.singleArtifact()
.value(labelCache.getUnchecked(toolsRepository + "//tools/test:xml_writer")))
.add(
attr("$test_runtime", LABEL_LIST)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.value(
ImmutableList.of(
labelCache.getUnchecked(toolsRepository + "//tools/test:runtime"))))
.add(
attr("$test_setup_script", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.singleArtifact()
.value(labelCache.getUnchecked(toolsRepository + "//tools/test:test_setup")))
.add(
attr("$xml_generator_script", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.singleArtifact()
.value(
labelCache.getUnchecked(toolsRepository + "//tools/test:test_xml_generator")))
.add(
attr("$collect_coverage_script", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.singleArtifact()
.value(labelCache.getUnchecked(toolsRepository + "//tools/test:collect_coverage")))
// Input files for test actions collecting code coverage
.add(
attr(":coverage_support", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.value(
BaseRuleClasses.coverageSupportAttribute(
labelCache.getUnchecked(
toolsRepository + BaseRuleClasses.DEFAULT_COVERAGE_SUPPORT_VALUE))))
// Used in the one-per-build coverage report generation action.
.add(
attr(":coverage_report_generator", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.value(
BaseRuleClasses.coverageReportGeneratorAttribute(
labelCache.getUnchecked(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
"@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main")))
.add(
attr("$collect_cc_coverage", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.singleArtifact()
.value(env.getToolsLabel("//tools/test:collect_cc_coverage")))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ <li> DYNAMIC, in which all libraries are linked dynamically (if a dynamic versio
.add(attr("linkstatic", BOOLEAN).value(true))
.add(
attr("$def_parser", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.singleArtifact()
.value(
new Attribute.ComputedDefault() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
.setOutputToGenfiles()
.add(
attr("$genrule_setup", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.value(env.getToolsLabel(GENRULE_SETUP_LABEL)))

// TODO(bazel-team): stamping doesn't seem to work. Fix it or remove attribute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ differs only in places that the JLS forbids compilers to inline (and that must h
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.add(
attr("exported_plugins", LABEL_LIST)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.allowedRuleClasses("java_plugin")
.allowedFileTypes())
.advertiseSkylarkProvider(SkylarkProviderIdentifier.forKey(JavaInfo.PROVIDER.getKey()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,12 @@ class on the runtime classpath or you specify the <code>runtime_deps</code> argu
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.add(
attr("plugins", LABEL_LIST)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.allowedRuleClasses("java_plugin")
.legacyAllowAnyFileType())
.add(
attr(":java_plugins", LABEL_LIST)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.allowedRuleClasses("java_plugin")
.silentRuleClassFilter()
.value(JavaSemantics.JAVA_PLUGINS))
Expand Down Expand Up @@ -443,7 +443,7 @@ <li>If you are using any other launcher, native (C++) dependencies are staticall
env.getToolsLabel("//tools/jdk:no_launcher"))))
.add(
attr("$launcher", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.value(env.getToolsLabel("//tools/launcher:launcher")))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
// Primarily this is intended to help test changes to Proguard.
.add(
attr(":proguard", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.value(JavaSemantics.PROGUARD)
.exec())
.add(attr(":extra_proguard_specs", LABEL_LIST).value(JavaSemantics.EXTRA_PROGUARD_SPECS))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
.cfg(PyRuleClasses.VERSION_TRANSITION)
.add(
attr("$zipper", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.exec()
.value(env.getToolsLabel("//tools/zip:zipper")))
.addRequiredToolchains(CppRuleClasses.ccToolchainTypeAttribute(env))
.add(
attr("$launcher", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.value(env.getToolsLabel("//tools/launcher:launcher")))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ executable Python rule (<code>py_binary</code> or <code>py_test</code>).
// 2to3 is itself written in Python and depends on many libraries.
.add(
attr("$python2to3", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.exec()
.value(env.getToolsLabel("//tools/python:2to3")))
.setPreferredDependencyPredicate(PyRuleClasses.PYTHON_SOURCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
.cfg(PyRuleClasses.VERSION_TRANSITION)
.add(
attr("$zipper", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.exec()
.value(env.getToolsLabel("//tools/zip:zipper")))
.override(
Expand All @@ -57,7 +57,7 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
.addRequiredToolchains(CppRuleClasses.ccToolchainTypeAttribute(env))
.add(
attr("$launcher", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.value(env.getToolsLabel("//tools/launcher:launcher")))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment envi
return builder
.add(
attr("$launcher", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.value(environment.getToolsLabel("//tools/launcher:launcher")))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment envi
"@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main")))
.add(
attr("$launcher", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.value(environment.getToolsLabel("//tools/launcher:launcher")))
// Add the script as an attribute in order for sh_test to output code coverage results for
// code covered by CC binaries invocations.
.add(
attr("$collect_cc_coverage", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.singleArtifact()
.value(environment.getToolsLabel("//tools/test:collect_cc_coverage")));
return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,27 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
.validityPredicate(ANY_EDGE))
.add(
attr(AAR_EMBEDDED_JARS_EXTACTOR, LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.exec()
.value(env.getToolsLabel("//tools/android:aar_embedded_jars_extractor")))
.add(
attr(AAR_NATIVE_LIBS_ZIP_CREATOR, LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.exec()
.value(env.getToolsLabel("//tools/android:aar_native_libs_zip_creator")))
.add(
attr(AAR_RESOURCES_EXTRACTOR, LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.exec()
.value(env.getToolsLabel("//tools/android:aar_resources_extractor")))
.add(
attr("$import_deps_checker", LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.exec()
.value(env.getToolsLabel("//tools/android:aar_import_deps_checker")))
.add(
attr(ZIPPER, LABEL)
.cfg(HostTransition.INSTANCE)
.cfg(HostTransition.createFactory())
.exec()
.value(env.getToolsLabel("//tools/zip:zipper")))
.advertiseSkylarkProvider(SkylarkProviderIdentifier.forKey(JavaInfo.PROVIDER.getKey()))
Expand Down
Loading

0 comments on commit ffb65c8

Please sign in to comment.