diff options
Diffstat (limited to 'src/main/java/com/google')
5 files changed, 36 insertions, 4 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java index 6c89ea7e4c..bdfb683517 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java @@ -752,7 +752,11 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory { // TODO(kmb): In modes other than LEGACY verify that proguard specs don't include -dont... flags // since those flags would override the desired optMode (b/25621573) ImmutableSortedSet.Builder<Artifact> builder = - ImmutableSortedSet.<Artifact>orderedBy(Artifact.EXEC_PATH_COMPARATOR).addAll(proguardSpecs); + ImmutableSortedSet.orderedBy(Artifact.EXEC_PATH_COMPARATOR) + .addAll(proguardSpecs) + .addAll(ruleContext + .getPrerequisiteArtifacts(":extra_proguard_specs", Mode.TARGET) + .list()); for (ProguardSpecProvider dep : ruleContext.getPrerequisites("deps", Mode.TARGET, ProguardSpecProvider.class)) { builder.addAll(dep.getTransitiveProguardSpecs()); 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 a220b76ae5..5fec1ebaf5 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 @@ -712,6 +712,7 @@ com/google/common/base/Objects.class </ul> <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ .add(attr("legacy_native_support", TRISTATE).value(TriState.AUTO)) + .add(attr(":extra_proguard_specs", LABEL_LIST).value(JavaSemantics.EXTRA_PROGUARD_SPECS)) .advertiseProvider(JavaCompilationArgsProvider.class) .build(); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaConfiguration.java index 4da2550541..83ebef3c68 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaConfiguration.java @@ -137,6 +137,7 @@ public final class JavaConfiguration extends Fragment { private final Label javacBootclasspath; private final Label javacExtdir; private final ImmutableList<String> javacOpts; + private final ImmutableList<Label> extraProguardSpecs; private final TriState bundleTranslations; private final ImmutableList<Label> translationTargets; private final String javaCpu; @@ -164,6 +165,7 @@ public final class JavaConfiguration extends Fragment { this.javacBootclasspath = javaOptions.javacBootclasspath; this.javacExtdir = javaOptions.javacExtdir; this.javacOpts = ImmutableList.copyOf(javaOptions.javacOpts); + this.extraProguardSpecs = ImmutableList.copyOf(javaOptions.extraProguardSpecs); this.bundleTranslations = javaOptions.bundleTranslations; this.javaCpu = javaCpu; this.javaToolchain = javaToolchain; @@ -294,6 +296,13 @@ public final class JavaConfiguration extends Fragment { } /** + * Returns all labels provided with --extra_proguard_specs. + */ + public List<Label> getExtraProguardSpecs() { + return extraProguardSpecs; + } + + /** * Returns the raw translation targets. */ public List<Label> getTranslationTargets() { 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 324ae14c74..f7da293136 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 @@ -346,6 +346,15 @@ public class JavaOptions extends FragmentOptions { + "The \"launcher\" attribute overrides this flag. ") public Label javaLauncher; + @Option(name = "extra_proguard_specs", + allowMultiple = true, + defaultValue = "", // Ignored + converter = LabelConverter.class, + category = "undocumented", + help = "Additional Proguard specs that will be used for all Proguard invocations. Note that " + + "using this option only has an effect when Proguard is used anyway.") + public List<Label> extraProguardSpecs; + @Option(name = "translations", defaultValue = "auto", category = "semantics", 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 065e378d29..4f7d8cdb6d 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 @@ -99,7 +99,7 @@ public interface JavaSemantics { * Name of the output group used for gen jars (the jars containing the class files for sources * generated from annotation processors). */ - public static final String GENERATED_JARS_OUTPUT_GROUP = + public static final String GENERATED_JARS_OUTPUT_GROUP = OutputGroupProvider.HIDDEN_OUTPUT_GROUP_PREFIX + "gen_jars"; /** @@ -182,6 +182,15 @@ public interface JavaSemantics { } }; + public static final LateBoundLabelList<BuildConfiguration> EXTRA_PROGUARD_SPECS = + new LateBoundLabelList<BuildConfiguration>() { + @Override + public List<Label> getDefault(Rule rule, BuildConfiguration configuration) { + return ImmutableList.copyOf( + configuration.getFragment(JavaConfiguration.class).getExtraProguardSpecs()); + } + }; + public static final String IJAR_LABEL = "//tools/defaults:ijar"; /** @@ -278,7 +287,7 @@ public interface JavaSemantics { /** * Adds extra providers to a Java target. - * @throws InterruptedException + * @throws InterruptedException */ void addProviders(RuleContext ruleContext, JavaCommon javaCommon, @@ -309,7 +318,7 @@ public interface JavaSemantics { * @param attributesBuilder the builder to construct the list of attributes of this target * (mutable). * @return the launcher as an artifact - * @throws InterruptedException + * @throws InterruptedException */ Artifact getLauncher(final RuleContext ruleContext, final JavaCommon common, DeployArchiveBuilder deployArchiveBuilder, Runfiles.Builder runfilesBuilder, |