diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
16 files changed, 231 insertions, 116 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java index b083cbf835..87b570318c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/SkylarkRuleClassFunctions.java @@ -35,6 +35,7 @@ import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.analysis.BaseRuleClasses; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.analysis.config.RunUnder; @@ -167,7 +168,7 @@ public class SkylarkRuleClassFunctions { .add(attr("args", STRING_LIST) .nonconfigurable("policy decision: should be consistent across configurations")) .add(attr("$test_runtime", LABEL_LIST).cfg(HOST).value(ImmutableList.of( - labelCache.getUnchecked("//tools/test:runtime")))) + labelCache.getUnchecked(Constants.TOOLS_REPOSITORY + "//tools/test:runtime")))) .add(attr(":run_under", LABEL).cfg(DATA).value(RUN_UNDER)) .build(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java index 7f63829480..79bf08a98e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java @@ -19,6 +19,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; +import com.google.devtools.build.lib.analysis.config.BuildConfiguration.DefaultLabelConverter; import com.google.devtools.build.lib.analysis.config.BuildConfiguration.Fragment; import com.google.devtools.build.lib.analysis.config.BuildConfiguration.LabelConverter; import com.google.devtools.build.lib.analysis.config.BuildConfiguration.StrictDepsConverter; @@ -40,6 +41,21 @@ import java.util.List; * Configuration fragment for Android rules. */ public class AndroidConfiguration extends BuildConfiguration.Fragment { + + /** Converter for --android_crosstool_top. */ + public static class AndroidCrosstoolTopConverter extends DefaultLabelConverter { + public AndroidCrosstoolTopConverter() { + super(Constants.ANDROID_DEFAULT_CROSSTOOL); + } + } + + /** Converter for --android_sdk. */ + public static class AndroidSdkConverter extends DefaultLabelConverter { + public AndroidSdkConverter() { + super(Constants.ANDROID_DEFAULT_SDK); + } + } + /** * Value used to avoid multiple configurations from conflicting. * @@ -92,9 +108,9 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { public boolean incrementalNativeLibs; @Option(name = "android_crosstool_top", - defaultValue = "null", + defaultValue = "", category = "semantics", - converter = LabelConverter.class, + converter = AndroidCrosstoolTopConverter.class, help = "The location of the C++ compiler used for Android builds.") public Label androidCrosstoolTop; @@ -116,9 +132,9 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { // Label of filegroup combining all Android tools used as implicit dependencies of // android_* rules @Option(name = "android_sdk", - defaultValue = "null", + defaultValue = "", category = "version", - converter = LabelConverter.class, + converter = AndroidSdkConverter.class, help = "Specifies Android SDK/platform that is used to build Android applications.") public Label sdk; @@ -177,37 +193,16 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { labelMap.put("android_proguard", proguard); } - if (realAndroidCrosstoolTop() != null) { - labelMap.put("android_crosstool_top", realAndroidCrosstoolTop()); - } - - labelMap.put("android_sdk", realSdk()); - } - - // This method is here because Constants.ANDROID_DEFAULT_SDK cannot be a constant, because we - // replace the class file in the .jar after compilation. However, that means that we cannot use - // it as an attribute value in an annotation. - private Label realSdk() { - return sdk == null - ? Label.parseAbsoluteUnchecked(Constants.ANDROID_DEFAULT_SDK) - : sdk; - } - - // This method is here because Constants.ANDROID_DEFAULT_CROSSTOOL cannot be a constant, because - // we replace the class file in the .jar after compilation. However, that means that we cannot - // use it as an attribute value in an annotation. - public Label realAndroidCrosstoolTop() { if (androidCrosstoolTop != null) { - return androidCrosstoolTop; - } - - if (Constants.ANDROID_DEFAULT_CROSSTOOL.equals("null")) { - return null; + labelMap.put("android_crosstool_top", androidCrosstoolTop); } - return Label.parseAbsoluteUnchecked(Constants.ANDROID_DEFAULT_CROSSTOOL); + labelMap.put("android_sdk", sdk); } + // This method is here because Constants.ANDROID_DEFAULT_FAT_APK_CPUS cannot be a constant + // because we replace the class file in the .jar after compilation. However, that means that we + // cannot use it as an attribute value in an annotation. public List<String> realFatApkCpus() { if (fatApkCpus.isEmpty()) { return Constants.ANDROID_DEFAULT_FAT_APK_CPUS; @@ -260,7 +255,7 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { private final boolean jackSanityChecks; AndroidConfiguration(Options options) { - this.sdk = options.realSdk(); + this.sdk = options.sdk; this.incrementalNativeLibs = options.incrementalNativeLibs; this.strictDeps = options.strictDeps; this.legacyNativeSupport = options.legacyNativeSupport; diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidRuleClasses.java index c1e14989a3..3a1a376f02 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidRuleClasses.java @@ -180,12 +180,12 @@ public final class AndroidRuleClasses { output.get(AndroidConfiguration.Options.class); CppOptions cppOptions = output.get(CppOptions.class); - if (inputAndroidOptions.realAndroidCrosstoolTop() != null - && !cppOptions.crosstoolTop.equals(inputAndroidOptions.realAndroidCrosstoolTop())) { + if (inputAndroidOptions.androidCrosstoolTop != null + && !cppOptions.crosstoolTop().equals(inputAndroidOptions.androidCrosstoolTop)) { if (cppOptions.hostCrosstoolTop == null) { cppOptions.hostCrosstoolTop = cppOptions.crosstoolTop; } - cppOptions.crosstoolTop = inputAndroidOptions.realAndroidCrosstoolTop(); + cppOptions.crosstoolTop = inputAndroidOptions.androidCrosstoolTop; } outputAndroidOptions.configurationDistinguisher = ConfigurationDistinguisher.ANDROID; @@ -196,9 +196,10 @@ public final class AndroidRuleClasses { AndroidConfiguration.Options androidOptions = buildOptions.get(AndroidConfiguration.Options.class); CppOptions cppOptions = buildOptions.get(CppOptions.class); - Label androidCrosstoolTop = androidOptions.realAndroidCrosstoolTop(); + Label androidCrosstoolTop = androidOptions.androidCrosstoolTop; if (androidOptions.realFatApkCpus().isEmpty() - && (androidCrosstoolTop == null || androidCrosstoolTop.equals(cppOptions.crosstoolTop))) { + && (androidCrosstoolTop == null + || androidCrosstoolTop.equals(cppOptions.crosstoolTop()))) { return ImmutableList.of(); } @@ -330,7 +331,8 @@ public final class AndroidRuleClasses { .allowedFileTypes(ANY_FILE) // TODO(bazel-team): Remove defaults and make mandatory when android_sdk targets // have been updated to include manually specified Jack attributes. - .value(environment.getLabel("//tools/android/jack:android_jack"))) + .value(environment.getLabel( + Constants.TOOLS_REPOSITORY + "//tools/android/jack:android_jack"))) .add(attr("annotations_jar", LABEL).mandatory().cfg(HOST).allowedFileTypes(ANY_FILE)) .add(attr("main_dex_classes", LABEL).mandatory().cfg(HOST).allowedFileTypes(ANY_FILE)) .add(attr("apkbuilder", LABEL).mandatory().cfg(HOST).allowedFileTypes(ANY_FILE).exec()) @@ -340,19 +342,22 @@ public final class AndroidRuleClasses { .cfg(HOST) .allowedFileTypes(ANY_FILE) .exec() - .value(environment.getLabel("//tools/android/jack:jack"))) + .value(environment.getLabel( + Constants.TOOLS_REPOSITORY + "//tools/android/jack:jack"))) .add( attr("jill", LABEL) .cfg(HOST) .allowedFileTypes(ANY_FILE) .exec() - .value(environment.getLabel("//tools/android/jack:jill"))) + .value(environment.getLabel( + Constants.TOOLS_REPOSITORY + "//tools/android/jack:jill"))) .add( attr("resource_extractor", LABEL) .cfg(HOST) .allowedFileTypes(ANY_FILE) .exec() - .value(environment.getLabel("//tools/android/jack:resource_extractor"))) + .value(environment.getLabel( + Constants.TOOLS_REPOSITORY + "//tools/android/jack:resource_extractor"))) .build(); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java index a68b800bd4..3604f58115 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfigurationLoader.java @@ -119,7 +119,7 @@ public class CppConfigurationLoader implements ConfigurationFragmentFactory { return null; } Label crosstoolTopLabel = RedirectChaser.followRedirects(env, - options.get(CppOptions.class).crosstoolTop, "crosstool_top"); + options.get(CppOptions.class).crosstoolTop(), "crosstool_top"); if (crosstoolTopLabel == null) { return null; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java index 6c550d0f9c..e76fb265bb 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java @@ -19,6 +19,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; +import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.analysis.config.BuildConfiguration.LabelConverter; import com.google.devtools.build.lib.analysis.config.CompilationMode; @@ -170,7 +171,7 @@ public class CppOptions extends FragmentOptions { public boolean lipoCollector; @Option(name = "crosstool_top", - defaultValue = CppOptions.DEFAULT_CROSSTOOL_TARGET, + defaultValue = "null", category = "version", converter = LabelConverter.class, help = "The label of the crosstool package to be used for compiling C++ code.") @@ -502,6 +503,12 @@ public class CppOptions extends FragmentOptions { + "will be shared among different targets") public boolean shareNativeDeps; + public Label crosstoolTop() { + return crosstoolTop == null + ? Label.parseAbsoluteUnchecked(Constants.TOOLS_REPOSITORY + DEFAULT_CROSSTOOL_TARGET) + : crosstoolTop; + } + @Override public FragmentOptions getHost(boolean fallback) { CppOptions host = (CppOptions) getDefault(); @@ -544,7 +551,7 @@ public class CppOptions extends FragmentOptions { @Override public void addAllLabels(Multimap<String, Label> labelMap) { - labelMap.put("crosstool", crosstoolTop); + labelMap.put("crosstool", crosstoolTop()); if (hostCrosstoolTop != null) { labelMap.put("crosstool", hostCrosstoolTop); } @@ -573,7 +580,7 @@ public class CppOptions extends FragmentOptions { @Override public Map<String, Set<Label>> getDefaultsLabels(BuildConfiguration.Options commonOptions) { Set<Label> crosstoolLabels = new LinkedHashSet<>(); - crosstoolLabels.add(crosstoolTop); + crosstoolLabels.add(crosstoolTop()); if (hostCrosstoolTop != null) { crosstoolLabels.add(hostCrosstoolTop); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java index 361e95f505..633439d4d5 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaOptions.java @@ -16,7 +16,9 @@ package com.google.devtools.build.lib.rules.java; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; +import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; +import com.google.devtools.build.lib.analysis.config.BuildConfiguration.DefaultLabelConverter; import com.google.devtools.build.lib.analysis.config.BuildConfiguration.LabelConverter; import com.google.devtools.build.lib.analysis.config.BuildConfiguration.StrictDepsConverter; import com.google.devtools.build.lib.analysis.config.BuildConfiguration.StrictDepsMode; @@ -25,9 +27,11 @@ import com.google.devtools.build.lib.analysis.config.FragmentOptions; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelSyntaxException; import com.google.devtools.build.lib.rules.java.JavaConfiguration.JavaClasspathMode; +import com.google.devtools.common.options.Converter; import com.google.devtools.common.options.Converters.StringSetConverter; import com.google.devtools.common.options.EnumConverter; import com.google.devtools.common.options.Option; +import com.google.devtools.common.options.OptionsParsingException; import com.google.devtools.common.options.TriState; import java.util.HashMap; @@ -40,16 +44,77 @@ import java.util.Set; * Command-line options for building Java targets */ public class JavaOptions extends FragmentOptions { - // Defaults value for options public static final String DEFAULT_LANGTOOLS = "//tools/jdk:langtools"; - static final String DEFAULT_LANGTOOLS_BOOTCLASSPATH = "//tools/jdk:bootclasspath"; - static final String DEFAULT_LANGTOOLS_EXTDIR = "//tools/jdk:extdir"; - static final String DEFAULT_JAVABUILDER = "//tools/jdk:JavaBuilder_deploy.jar"; - static final String DEFAULT_SINGLEJAR = "//tools/jdk:SingleJar_deploy.jar"; - static final String DEFAULT_GENCLASS = "//tools/jdk:GenClass_deploy.jar"; - static final String DEFAULT_JAVABASE = "//tools/jdk:jdk"; - static final String DEFAULT_IJAR = "//tools/jdk:ijar"; - static final String DEFAULT_TOOLCHAIN = "//tools/jdk:toolchain"; + + /** Converter for --javabase and --host_javabase. */ + public static class JavabaseConverter implements Converter<String> { + @Override + public String convert(String input) throws OptionsParsingException { + return input.isEmpty() ? Constants.TOOLS_REPOSITORY + "//tools/jdk:jdk" : input; + } + + @Override + public String getTypeDescription() { + return "a string"; + } + } + + /** Converter for --java_langtools. */ + public static class LangtoolsConverter extends DefaultLabelConverter { + public LangtoolsConverter() { + super(Constants.TOOLS_REPOSITORY + DEFAULT_LANGTOOLS); + } + } + + /** Converter for --javac_bootclasspath. */ + public static class BootclasspathConverter extends DefaultLabelConverter { + public BootclasspathConverter() { + super(Constants.TOOLS_REPOSITORY + "//tools/jdk:bootclasspath"); + } + } + + /** Converter for --javac_extdir. */ + public static class ExtdirConverter extends DefaultLabelConverter { + public ExtdirConverter() { + super(Constants.TOOLS_REPOSITORY + "//tools/jdk:extdir"); + } + } + + /** Converter for --javabuilder_top. */ + public static class JavaBuilderConverter extends DefaultLabelConverter { + public JavaBuilderConverter() { + super(Constants.TOOLS_REPOSITORY + "//tools/jdk:JavaBuilder_deploy.jar"); + } + } + + + /** Converter for --singlejar_top. */ + public static class SingleJarConverter extends DefaultLabelConverter { + public SingleJarConverter() { + super(Constants.TOOLS_REPOSITORY + "//tools/jdk:SingleJar_deploy.jar"); + } + } + + /** Converter for --genclass_top. */ + public static class GenClassConverter extends DefaultLabelConverter { + public GenClassConverter() { + super(Constants.TOOLS_REPOSITORY + "//tools/jdk:GenClass_deploy.jar"); + } + } + + /** Converter for --ijar_top. */ + public static class IjarConverter extends DefaultLabelConverter { + public IjarConverter() { + super(Constants.TOOLS_REPOSITORY + "//tools/jdk:ijar"); + } + } + + /** Converter for --java_toolchain. */ + public static class JavaToolchainConverter extends DefaultLabelConverter { + public JavaToolchainConverter() { + super(Constants.TOOLS_REPOSITORY + "//tools/jdk:toolchain"); + } + } /** * Converter for the --javawarn option. @@ -98,7 +163,8 @@ public class JavaOptions extends FragmentOptions { } @Option(name = "javabase", - defaultValue = DEFAULT_JAVABASE, + defaultValue = "", + converter = JavabaseConverter.class, category = "version", help = "JAVABASE used for the JDK invoked by Blaze. This is the " + "JAVABASE which will be used to execute external Java " @@ -106,17 +172,18 @@ public class JavaOptions extends FragmentOptions { public String javaBase; @Option(name = "java_toolchain", - defaultValue = DEFAULT_TOOLCHAIN, + defaultValue = "", category = "version", - converter = LabelConverter.class, - help = "The name of the toolchain rule for Java. Default is " + DEFAULT_TOOLCHAIN) + converter = JavaToolchainConverter.class, + help = "The name of the toolchain rule for Java.") public Label javaToolchain; @Option(name = "host_javabase", - defaultValue = DEFAULT_JAVABASE, - category = "version", - help = "JAVABASE used for the host JDK. This is the JAVABASE which is used to execute " - + " tools during a build.") + defaultValue = "", + converter = JavabaseConverter.class, + category = "version", + help = "JAVABASE used for the host JDK. This is the JAVABASE which is used to execute " + + " tools during a build.") public String hostJavaBase; @Option(name = "javacopt", @@ -206,9 +273,9 @@ public class JavaOptions extends FragmentOptions { public StrictDepsMode strictJavaDeps; @Option(name = "javabuilder_top", - defaultValue = DEFAULT_JAVABUILDER, + defaultValue = "", category = "version", - converter = LabelConverter.class, + converter = JavaBuilderConverter.class, help = "Label of the filegroup that contains the JavaBuilder jar.") public Label javaBuilderTop; @@ -220,44 +287,44 @@ public class JavaOptions extends FragmentOptions { public List<String> javaBuilderJvmOpts; @Option(name = "singlejar_top", - defaultValue = DEFAULT_SINGLEJAR, + defaultValue = "", category = "version", - converter = LabelConverter.class, + converter = SingleJarConverter.class, help = "Label of the filegroup that contains the SingleJar jar.") public Label singleJarTop; @Option(name = "genclass_top", - defaultValue = DEFAULT_GENCLASS, + defaultValue = "", category = "version", - converter = LabelConverter.class, + converter = GenClassConverter.class, help = "Label of the filegroup that contains the GenClass jar.") public Label genClassTop; @Option(name = "ijar_top", - defaultValue = DEFAULT_IJAR, + defaultValue = "", category = "version", - converter = LabelConverter.class, + converter = IjarConverter.class, help = "Label of the filegroup that contains the ijar binary.") public Label iJarTop; @Option(name = "java_langtools", - defaultValue = DEFAULT_LANGTOOLS, + defaultValue = "", category = "version", - converter = LabelConverter.class, + converter = LangtoolsConverter.class, help = "Label of the rule that produces the Java langtools jar.") public Label javaLangtoolsJar; @Option(name = "javac_bootclasspath", - defaultValue = DEFAULT_LANGTOOLS_BOOTCLASSPATH, + defaultValue = "", category = "version", - converter = LabelConverter.class, + converter = BootclasspathConverter.class, help = "Label of the rule that produces the bootclasspath jars for javac to use.") public Label javacBootclasspath; @Option(name = "javac_extdir", - defaultValue = DEFAULT_LANGTOOLS_EXTDIR, + defaultValue = "", category = "version", - converter = LabelConverter.class, + converter = ExtdirConverter.class, help = "Label of the rule that produces the extdir for javac to use.") public Label javacExtdir; diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java index d616d2af66..a75b414ef1 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaSemantics.java @@ -18,6 +18,7 @@ import static com.google.devtools.build.lib.packages.ImplicitOutputsFunction.fro import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.LanguageDependentFragment.LibraryLanguage; import com.google.devtools.build.lib.analysis.OutputGroupProvider; @@ -79,7 +80,8 @@ public interface JavaSemantics { /** * Label to the Java Toolchain rule. It is resolved from a label given in the java options. */ - static final String JAVA_TOOLCHAIN_LABEL = "//tools/defaults:java_toolchain"; + static final String JAVA_TOOLCHAIN_LABEL = + Constants.TOOLS_REPOSITORY + "//tools/defaults:java_toolchain"; public static final LateBoundLabel<BuildConfiguration> JAVA_TOOLCHAIN = new LateBoundLabel<BuildConfiguration>(JAVA_TOOLCHAIN_LABEL, JavaConfiguration.class) { @@ -106,33 +108,39 @@ public interface JavaSemantics { * Label of a pseudo-filegroup that contains all jdk files for all * configurations, as specified on the command-line. */ - public static final String JDK_LABEL = "//tools/defaults:jdk"; + public static final String JDK_LABEL = + Constants.TOOLS_REPOSITORY + "//tools/defaults:jdk"; /** * Label of a pseudo-filegroup that contains the boot-classpath entries. */ - public static final String JAVAC_BOOTCLASSPATH_LABEL = "//tools/defaults:javac_bootclasspath"; + public static final String JAVAC_BOOTCLASSPATH_LABEL = + Constants.TOOLS_REPOSITORY + "//tools/defaults:javac_bootclasspath"; /** * Label of the javac extdir used for compiling Java source code. */ - public static final String JAVAC_EXTDIR_LABEL = "//tools/defaults:javac_extdir"; + public static final String JAVAC_EXTDIR_LABEL = + Constants.TOOLS_REPOSITORY + "//tools/defaults:javac_extdir"; /** * Label of the JavaBuilder JAR used for compiling Java source code. */ - public static final String JAVABUILDER_LABEL = "//tools/defaults:javabuilder"; + public static final String JAVABUILDER_LABEL = + Constants.TOOLS_REPOSITORY + "//tools/defaults:javabuilder"; /** * Label of the SingleJar JAR used for creating deploy jars. */ - public static final String SINGLEJAR_LABEL = "//tools/defaults:singlejar"; + public static final String SINGLEJAR_LABEL = + Constants.TOOLS_REPOSITORY + "//tools/defaults:singlejar"; /** * Label of the GenClass JAR used for creating the jar for classes from sources generated from * annotation processors. */ - public static final String GENCLASS_LABEL = "//tools/defaults:genclass"; + public static final String GENCLASS_LABEL = + Constants.TOOLS_REPOSITORY + "//tools/defaults:genclass"; /** * Label of pseudo-cc_binary that tells Blaze a java target's JAVABIN is never to be replaced by @@ -188,7 +196,7 @@ public interface JavaSemantics { } }; - public static final String IJAR_LABEL = "//tools/defaults:ijar"; + public static final String IJAR_LABEL = Constants.TOOLS_REPOSITORY + "//tools/defaults:ijar"; /** * Verifies if the rule contains and errors. diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcProtoAspect.java b/src/main/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcProtoAspect.java index 8d692e562c..2da029c7ad 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcProtoAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcProtoAspect.java @@ -19,6 +19,7 @@ import static com.google.devtools.build.lib.packages.Attribute.attr; import static com.google.devtools.build.lib.packages.BuildType.LABEL; import com.google.common.collect.ImmutableMap; +import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode; @@ -42,11 +43,11 @@ public class BazelJ2ObjcProtoAspect extends AbstractJ2ObjcProtoAspect { .add(attr("$protoc_darwin", LABEL) .cfg(HOST) .exec() - .value(parseLabel("//tools/objc:compile_protos"))) + .value(parseLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:compile_protos"))) .add(attr("$protoc_support_darwin", LABEL) .cfg(HOST) .exec() - .value(parseLabel("//tools/objc:proto_support"))) + .value(parseLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:proto_support"))) .add(attr("$j2objc_plugin", LABEL) .cfg(HOST) .exec() diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ExperimentalIosTestRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ExperimentalIosTestRule.java index a7b81dcc07..1769a9c05b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ExperimentalIosTestRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ExperimentalIosTestRule.java @@ -21,6 +21,7 @@ import static com.google.devtools.build.lib.packages.BuildType.LABEL_LIST; import static com.google.devtools.build.lib.syntax.Type.STRING_LIST; import com.google.common.collect.ImmutableList; +import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.analysis.BaseRuleClasses; import com.google.devtools.build.lib.analysis.RuleDefinition; import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment; @@ -62,7 +63,8 @@ public final class ExperimentalIosTestRule implements RuleDefinition { attr(IosTest.TARGET_DEVICE, LABEL) .allowedFileTypes() .allowedRuleClasses("ios_device") - .value(env.getLabel("//tools/objc/sim_devices:default"))) + .value(env.getLabel( + Constants.TOOLS_REPOSITORY + "//tools/objc/sim_devices:default"))) /* <!-- #BLAZE_RULE(experimental_ios_test).ATTRIBUTE(ios_test_target_device) --> The device against how to run the test. If this attribute is defined, the test will run on the lab device. Otherwise, the test will run on simulator. @@ -85,8 +87,10 @@ public final class ExperimentalIosTestRule implements RuleDefinition { <!-- #END_BLAZE_RULE.ATTRIBUTE -->*/ .add(attr("plugins", LABEL_LIST).allowedFileTypes(FileType.of("_deploy.jar"))) .add(attr("$test_template", LABEL) - .value(env.getLabel("//tools/objc:ios_test.sh.bazel_template"))) - .add(attr("$test_runner", LABEL).value(env.getLabel("//tools/objc:testrunner"))) + .value(env.getLabel( + Constants.TOOLS_REPOSITORY + "//tools/objc:ios_test.sh.bazel_template"))) + .add(attr("$test_runner", LABEL).value(env.getLabel( + Constants.TOOLS_REPOSITORY + "//tools/objc:testrunner"))) .override(attr(":gcov", LABEL_LIST).cfg(HOST) .value(new LateBoundLabelList<BuildConfiguration>() { @Override diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplicationRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplicationRule.java index 363219f0f8..f25d457176 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplicationRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/IosApplicationRule.java @@ -20,6 +20,7 @@ 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.syntax.Type.BOOLEAN; +import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.analysis.BaseRuleClasses; import com.google.devtools.build.lib.analysis.RuleDefinition; import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment; @@ -65,7 +66,8 @@ public class IosApplicationRule implements RuleDefinition { .allowedFileTypes() .direct_compile_time_input()) .add(attr("$runner_script_template", LABEL).cfg(HOST) - .value(env.getLabel("//tools/objc:ios_runner.sh.mac_template"))) + .value(env.getLabel( + Constants.TOOLS_REPOSITORY + "//tools/objc:ios_runner.sh.mac_template"))) .add(attr("$is_executable", BOOLEAN).value(true) .nonconfigurable("Called from RunCommand.isExecutable, which takes a Target")) .build(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java index 4a6a7f182f..f6a527bde6 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcAspect.java @@ -21,6 +21,7 @@ import static java.nio.charset.StandardCharsets.ISO_8859_1; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.ParameterFile; import com.google.devtools.build.lib.analysis.Aspect; @@ -70,13 +71,13 @@ public class J2ObjcAspect implements ConfiguredAspectFactory { .requireProvider(JavaSourceInfoProvider.class) .requireProvider(JavaCompilationArgsProvider.class) .add(attr("$j2objc", LABEL).cfg(HOST).exec() - .value(parseLabel("//tools/j2objc:j2objc_deploy.jar"))) + .value(parseLabel(Constants.TOOLS_REPOSITORY + "//tools/j2objc:j2objc_deploy.jar"))) .add(attr("$j2objc_wrapper", LABEL) .allowedFileTypes(FileType.of(".py")) .cfg(HOST) .exec() .singleArtifact() - .value(parseLabel("//tools/j2objc:j2objc_wrapper"))) + .value(parseLabel(Constants.TOOLS_REPOSITORY + "//tools/j2objc:j2objc_wrapper"))) .build(); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBinaryRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBinaryRule.java index bb34419929..deeb5aca5f 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBinaryRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcBinaryRule.java @@ -19,6 +19,7 @@ import static com.google.devtools.build.lib.packages.Attribute.attr; import static com.google.devtools.build.lib.packages.BuildType.LABEL; import static com.google.devtools.build.lib.syntax.Type.BOOLEAN; +import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.analysis.BaseRuleClasses; import com.google.devtools.build.lib.analysis.RuleDefinition; import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment; @@ -49,7 +50,8 @@ public class ObjcBinaryRule implements RuleDefinition { ImplicitOutputsFunction.fromFunctions(ReleaseBundlingSupport.IPA, XcodeSupport.PBXPROJ)) // TODO(bazel-team): Remove these when this rule no longer produces a bundle. .add(attr("$runner_script_template", LABEL).cfg(HOST) - .value(env.getLabel("//tools/objc:ios_runner.sh.mac_template"))) + .value(env.getLabel( + Constants.TOOLS_REPOSITORY + "//tools/objc:ios_runner.sh.mac_template"))) .add(attr("$is_executable", BOOLEAN).value(true) .nonconfigurable("Called from RunCommand.isExecutable, which takes a Target")) .build(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java index f88ce4fbdb..d30cc92cdb 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcCommandLineOptions.java @@ -17,7 +17,8 @@ package com.google.devtools.build.lib.rules.objc; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import com.google.common.collect.Multimap; -import com.google.devtools.build.lib.analysis.config.BuildConfiguration.LabelConverter; +import com.google.devtools.build.lib.Constants; +import com.google.devtools.build.lib.analysis.config.BuildConfiguration.DefaultLabelConverter; import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.config.FragmentOptions; import com.google.devtools.build.lib.cmdline.Label; @@ -33,6 +34,20 @@ import java.util.List; * Command-line options for building Objective-C targets. */ public class ObjcCommandLineOptions extends FragmentOptions { + /** Converter for --objc_dump_syms_binary. */ + public static class DumpSymsConverter extends DefaultLabelConverter { + public DumpSymsConverter() { + super(Constants.TOOLS_REPOSITORY + "//tools/objc:dump_syms"); + } + } + + /** Converter for --default_ios_provisioning_profile. */ + public static class DefaultProvisioningProfileConverter extends DefaultLabelConverter { + public DefaultProvisioningProfileConverter() { + super(Constants.TOOLS_REPOSITORY + "//tools/objc:default_provisioning_profile"); + } + } + // TODO(cparsons): Validate version flag value. @Option(name = "xcode_version", defaultValue = "", @@ -114,15 +129,15 @@ public class ObjcCommandLineOptions extends FragmentOptions { public String iosSplitCpu; @Option(name = "objc_dump_syms_binary", - defaultValue = "//tools/objc:dump_syms", + defaultValue = "", category = "undocumented", - converter = LabelConverter.class) + converter = DumpSymsConverter.class) public Label dumpSyms; @Option(name = "default_ios_provisiong_profile", - defaultValue = "//tools/objc:default_provisioning_profile", + defaultValue = "", category = "undocumented", - converter = LabelConverter.class) + converter = DefaultProvisioningProfileConverter.class) public Label defaultProvisioningProfile; @Option(name = "objc_per_proto_includes", @@ -206,6 +221,7 @@ public class ObjcCommandLineOptions extends FragmentOptions { IosApplication.SPLIT_ARCH_TRANSITION, IosExtension.MINIMUM_OS_AND_SPLIT_ARCH_TRANSITION); } + /** Converter for the iOS configuration distinguisher. */ public static final class ConfigurationDistinguisherConverter extends EnumConverter<ConfigurationDistinguisher> { public ConfigurationDistinguisherConverter() { diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibraryRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibraryRule.java index 1374c35d79..03ea73d953 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibraryRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibraryRule.java @@ -21,6 +21,7 @@ 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.syntax.Type.BOOLEAN; +import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.analysis.BaseRuleClasses; import com.google.devtools.build.lib.analysis.RuleDefinition; import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment; @@ -81,11 +82,11 @@ public class ObjcProtoLibraryRule implements RuleDefinition { .allowedFileTypes(FileType.of(".py")) .cfg(HOST) .singleArtifact() - .value(env.getLabel("//tools/objc:compile_protos"))) + .value(env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:compile_protos"))) .add(attr(PROTO_SUPPORT_ATTR, LABEL) .legacyAllowAnyFileType() .cfg(HOST) - .value(env.getLabel("//tools/objc:proto_support"))) + .value(env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:proto_support"))) .add(attr(USE_OBJC_HEADER_NAMES_ATTR, BOOLEAN).value(false)) .add(attr(LIBPROTOBUF_ATTR, LABEL).allowedRuleClasses("objc_library") .value(new ComputedDefault(OUTPUT_CPP_ATTR) { @@ -97,7 +98,7 @@ public class ObjcProtoLibraryRule implements RuleDefinition { } })) .add(attr("$xcodegen", LABEL).cfg(HOST).exec() - .value(env.getLabel("//tools/objc:xcodegen"))) + .value(env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:xcodegen"))) .build(); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java index e21a9755d5..082603d5a9 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcRuleClasses.java @@ -26,6 +26,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.devtools.build.lib.Constants; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.BaseRuleClasses; import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode; @@ -497,15 +498,15 @@ public class ObjcRuleClasses { public RuleClass build(Builder builder, RuleDefinitionEnvironment env) { return builder .add(attr("$plmerge", LABEL).cfg(HOST).exec() - .value(env.getLabel("//tools/objc:plmerge"))) + .value(env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:plmerge"))) .add(attr("$actoolwrapper", LABEL).cfg(HOST).exec() - .value(env.getLabel("//tools/objc:actoolwrapper"))) + .value(env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:actoolwrapper"))) .add(attr("$ibtoolwrapper", LABEL).cfg(HOST).exec() - .value(env.getLabel("//tools/objc:ibtoolwrapper"))) + .value(env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:ibtoolwrapper"))) // TODO(dmaclach): Adding realpath here should not be required once // https://github.com/bazelbuild/bazel/issues/285 is fixed. .add(attr("$realpath", LABEL).cfg(HOST).exec() - .value(env.getLabel("//tools/objc:realpath"))) + .value(env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:realpath"))) .build(); } @Override @@ -525,9 +526,9 @@ public class ObjcRuleClasses { public RuleClass build(Builder builder, RuleDefinitionEnvironment env) { return builder .add(attr("$xcodegen", LABEL).cfg(HOST).exec() - .value(env.getLabel("//tools/objc:xcodegen"))) + .value(env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:xcodegen"))) .add(attr("$dummy_source", LABEL) - .value(env.getLabel("//tools/objc:dummy.c"))) + .value(env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:dummy.c"))) .build(); } @Override @@ -771,7 +772,8 @@ public class ObjcRuleClasses { .cfg(HOST) .exec() .singleArtifact() - .value(env.getLabel("//tools/objc:j2objc_dead_code_pruner"))) + .value(env.getLabel( + Constants.TOOLS_REPOSITORY + "//tools/objc:j2objc_dead_code_pruner"))) .build(); } @Override @@ -818,7 +820,7 @@ public class ObjcRuleClasses { @Override public Object getDefault(AttributeMap rule) { return rule.get(IosTest.IS_XCTEST, Type.BOOLEAN) - ? env.getLabel("//tools/objc:xctest_app") + ? env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:xctest_app") : null; } }) @@ -832,7 +834,8 @@ public class ObjcRuleClasses { @Override public Object getDefault(AttributeMap rule) { return rule.get(IosTest.IS_XCTEST, Type.BOOLEAN) - ? env.getLabel("//tools/objc:xctest_infoplist") + ? env.getLabel( + Constants.TOOLS_REPOSITORY + "//tools/objc:xctest_infoplist") : null; } }) @@ -890,9 +893,10 @@ public class ObjcRuleClasses { .add(attr("families", STRING_LIST) .value(ImmutableList.of(TargetDeviceFamily.IPHONE.getNameInRule()))) .add(attr("$momcwrapper", LABEL).cfg(HOST).exec() - .value(env.getLabel("//tools/objc:momcwrapper"))) + .value(env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:momcwrapper"))) .add(attr("$swiftstdlibtoolwrapper", LABEL).cfg(HOST).exec() - .value(env.getLabel("//tools/objc:swiftstdlibtoolwrapper"))) + .value(env.getLabel( + Constants.TOOLS_REPOSITORY + "//tools/objc:swiftstdlibtoolwrapper"))) .build(); } @Override @@ -997,9 +1001,10 @@ public class ObjcRuleClasses { } })) .add(attr("$bundlemerge", LABEL).cfg(HOST).exec() - .value(env.getLabel("//tools/objc:bundlemerge"))) + .value(env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:bundlemerge"))) .add(attr("$environment_plist_sh", LABEL).cfg(HOST) - .value(env.getLabel("//tools/objc:environment_plist.sh"))) + .value(env.getLabel( + Constants.TOOLS_REPOSITORY + "//tools/objc:environment_plist.sh"))) .build(); } @Override @@ -1023,7 +1028,7 @@ public class ObjcRuleClasses { .add(attr("$iossim", LABEL).cfg(HOST).exec() .value(env.getLabel("//third_party/iossim:iossim"))) .add(attr("$std_redirect_dylib", LABEL).cfg(HOST).exec() - .value(env.getLabel("//tools/objc:StdRedirect.dylib"))) + .value(env.getLabel(Constants.TOOLS_REPOSITORY + "//tools/objc:StdRedirect.dylib"))) .build(); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfigurationLoader.java b/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfigurationLoader.java index 2599cb139d..917576d879 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfigurationLoader.java +++ b/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfigurationLoader.java @@ -67,7 +67,7 @@ public class PythonConfigurationLoader implements ConfigurationFragmentFactory { } CrosstoolConfig.CToolchain toolchain = getToolchain( - env, buildOptions, buildOptions.get(CppOptions.class).crosstoolTop); + env, buildOptions, buildOptions.get(CppOptions.class).crosstoolTop()); if (toolchain == null) { return null; } |