// 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.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.rules.android.AndroidConfiguration.AndroidManifestMerger;
import com.google.devtools.build.lib.rules.android.AndroidRuleClasses.MultidexMode;
/**
* 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.native
: Split code into multiple dex files when the dex 64K index limit
is exceeded. Assumes native platform support for loading multidex classes at runtime.
This works with only Android L and newer.legacy
: Split code into multiple dex files when the dex 64K index limit
is exceeded. Assumes multidex classes are loaded through application code (i.e. no
native platform support).manual_main_dex
: Split code into multiple dex files when the dex 64K
index limit is exceeded. The content of the main dex file needs to be specified by
providing a list of classes in a text file using the
main_dex_list attribute.off
: Compile all code to a single dex file, even if it exceeds the index
limit.