// Copyright 2015 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.devtools.build.lib.rules.android;
import static com.google.devtools.build.lib.packages.Attribute.ConfigurationTransition.HOST;
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.packages.BuildType.TRISTATE;
import static com.google.devtools.build.lib.syntax.Type.BOOLEAN;
import static com.google.devtools.build.lib.syntax.Type.STRING;
import static com.google.devtools.build.lib.syntax.Type.STRING_DICT;
import static com.google.devtools.build.lib.syntax.Type.STRING_LIST;
import com.google.devtools.build.lib.analysis.RuleDefinition;
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
import com.google.devtools.build.lib.packages.Attribute.AllowedValueSet;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
import com.google.devtools.build.lib.packages.TriState;
import com.google.devtools.build.lib.rules.android.AndroidConfiguration.AndroidManifestMerger;
/**
* Attributes for {@code android_binary} that are not present on {@code android_test}.
*/
public final class AndroidBinaryOnlyRule implements RuleDefinition {
@Override
public RuleClass build(RuleClass.Builder builder, final RuleDefinitionEnvironment env) {
return builder
/*
Select the manifest merger to use for this rule.
Possible values:
manifest_merger = "legacy"
: Use the legacy manifest merger. Does not
allow features of the android merger like placeholder substitution and tools
attributes for defining merge behavior. Removes all
<uses-permission>
and <uses-permission-sdk-23>
tags. Performs a tag-level merge.manifest_merger = "android"
: Use the android manifest merger. Allows
features like placeholder substitution and tools attributes for defining merge
behavior. Follows the semantics from
the documentation except it has been modified to also remove all
<uses-permission>
and <uses-permission-sdk-23>
tags. Performs an attribute-level merge.manifest_merger = "auto"
: Merger is controlled by the
--android_manifest_merger flag.manifest
and resource_files
attributes) and requires ProGuard. It
operates in mostly the same manner as the Gradle resource shrinker
(https://developer.android.com/studio/build/shrink-code.html#shrink-resources).
Notable differences:
strict mode
by defaultname_files/resource_shrinker.log
will also be generated, detailing the analysis and deletions performed.
Possible values:
shrink_resources = 1
: Turns on Android resource shrinkingshrink_resources = 0
: Turns off Android resource shrinkingshrink_resources = -1
: Shrinking is controlled by the
--android_resource_shrinking flag.