blob: 4e54f5ae82ed65d6501dc2eb67f2260e987fd3dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
// 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.bazel.rules.android;
import com.google.devtools.build.lib.analysis.RuleDefinition;
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
import com.google.devtools.build.lib.bazel.rules.cpp.BazelCppRuleClasses;
import com.google.devtools.build.lib.bazel.rules.java.BazelJavaRuleClasses;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder;
import com.google.devtools.build.lib.rules.android.AndroidFeatureFlagSetProvider;
import com.google.devtools.build.lib.rules.android.AndroidRuleClasses;
import com.google.devtools.build.lib.rules.config.ConfigFeatureFlagTransitionFactory;
/**
* Rule class definition for {@code android_binary}.
*/
public class BazelAndroidBinaryRule implements RuleDefinition {
@Override
public RuleClass build(Builder builder, RuleDefinitionEnvironment environment) {
return builder
/* <!-- #BLAZE_RULE(android_binary).IMPLICIT_OUTPUTS -->
<ul>
<li><code><var>name</var>.apk</code>: An Android application
package file signed with debug keys and
<a href="http://developer.android.com/guide/developing/tools/zipalign.html">
zipaligned</a>, it could be used to develop and debug your application.
You cannot release your application when signed with the debug keys.</li>
<li><code><var>name</var>_unsigned.apk</code>: An unsigned version of the
above file that could be signed with the release keys before release to
the public.
</li>
<li><code><var>name</var>_deploy.jar</code>: A Java archive containing the
transitive closure of this target.
<p>The deploy jar contains all the classes that would be found by a
classloader that searched the runtime classpath of this target
from beginning to end.</p>
</li>
<li><code><var>name</var>_proguard.jar</code>: A Java archive containing
the result of running ProGuard on the
<code><var>name</var>_deploy.jar</code>.
This output is only produced if
<a href="${link android_binary.proguard_specs}">proguard_specs</a> attribute is
specified.
</li>
<li><code><var>name</var>_proguard.map</code>: A mapping file result of
running ProGuard on the <code><var>name</var>_deploy.jar</code>.
This output is only produced if
<a href="${link android_binary.proguard_specs}">proguard_specs</a> attribute is
specified and
<a href="${link android_binary.proguard_generate_mapping}">proguard_generate_mapping</a>
or <a href="${link android_binary.shrink_resources}">shrink_resources</a> is set.
</li>
</ul>
<!-- #END_BLAZE_RULE.IMPLICIT_OUTPUTS --> */
.setImplicitOutputsFunction(AndroidRuleClasses.ANDROID_BINARY_IMPLICIT_OUTPUTS)
.cfg(
new ConfigFeatureFlagTransitionFactory(AndroidFeatureFlagSetProvider.FEATURE_FLAG_ATTR))
.build();
}
@Override
public Metadata getMetadata() {
return RuleDefinition.Metadata.builder()
.name("android_binary")
.ancestors(
AndroidRuleClasses.AndroidBinaryBaseRule.class,
BazelJavaRuleClasses.JavaBaseRule.class,
BazelCppRuleClasses.CcLinkingRule.class)
.factoryClass(BazelAndroidBinary.class)
.build();
}
}
/*<!-- #BLAZE_RULE (NAME = android_binary, TYPE = BINARY, FAMILY = Android) -->
<p>
Produces Android application package files (.apk).
</p>
${IMPLICIT_OUTPUTS}
<h4 id="android_binary_examples">Examples</h4>
<p>Examples of Android rules can be found in the <code>examples/android</code> directory of the
Bazel source tree.
<!-- #END_BLAZE_RULE -->*/
|