Skip to content

Commit 9a2b686

Browse files
committed
Rename the bool flag
1 parent d6d2a1e commit 9a2b686

File tree

7 files changed

+31
-31
lines changed

7 files changed

+31
-31
lines changed

examples/bundle/features/assets/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ android_feature_module(
1616
title = "asset_feature",
1717
library = ":lib",
1818
feature_name = "asset_feature",
19-
has_dex = True,
19+
has_code = True,
2020
visibility = ["//visibility:public"],
2121
)

providers/providers.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ AndroidFeatureModuleInfo = provider(
105105
binary = "String, target of the underlying split android_binary target",
106106
feature_name = "String, the name of the feature module. If unspecified, the target name will be used.",
107107
fused = "Boolean, whether the split is \"fused\" for the system image and for pre-L devices.",
108-
has_dex = "Boolean, whether the split android_library contains dex code",
108+
has_code = "Boolean, whether the feature module contains code",
109109
library = "String, target of the underlying split android_library target",
110110
manifest = "Optional AndroidManifest.xml file to use for this feature.",
111111
pre_dexed_jar = "File, contains pre-dexed jar file",

rules/android_application/android_application_rule.bzl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ def _process_feature_module(
100100
_common.get_host_javabase(ctx),
101101
)
102102

103-
has_dex = bool(feature_target[AndroidFeatureModuleInfo].has_dex)
104-
if has_dex:
103+
has_code = bool(feature_target[AndroidFeatureModuleInfo].has_code)
104+
if has_code:
105105
binary = feature_target[AndroidFeatureModuleInfo].binary[ApkInfo].unsigned_apk
106106
else:
107107
# Remove the dex files.
@@ -118,7 +118,7 @@ def _process_feature_module(
118118

119119
# Create res .proto-apk_, output depending on whether further manipulations
120120
# are required after busybox. This prevents action conflicts.
121-
if has_native_libs or is_asset_pack or has_dex:
121+
if has_native_libs or is_asset_pack or has_code:
122122
res_apk = ctx.actions.declare_file(ctx.label.name + "/" + feature_target.label.name + "/res.proto-ap_")
123123
else:
124124
res_apk = out
@@ -158,7 +158,7 @@ def _process_feature_module(
158158
application_id = application_id,
159159
)
160160

161-
if not is_asset_pack and not has_native_libs and not has_dex:
161+
if not is_asset_pack and not has_native_libs and not has_code:
162162
return
163163

164164
if is_asset_pack:
@@ -177,8 +177,8 @@ def _process_feature_module(
177177
_common.filter_zip_include(ctx, binary, native_libs, ["lib/*"])
178178
inputs_to_merge.append(native_libs)
179179

180-
# Add dex files if has_dex is enabled
181-
if has_dex:
180+
# Add dex files if has_code is enabled
181+
if has_code:
182182
if feature_dex:
183183
# Use R8 feature splits dex output
184184
inputs_to_merge.append(feature_dex)
@@ -220,7 +220,7 @@ def _create_feature_manifest(
220220
args.add(info.title_id)
221221
args.add(info.fused)
222222
args.add(aapt2.executable)
223-
args.add(info.has_dex)
223+
args.add(info.has_code)
224224

225225
ctx.actions.run(
226226
executable = feature_manifest_script,
@@ -239,7 +239,7 @@ def _create_feature_manifest(
239239
# Rule has a manifest (already validated by android_feature_module).
240240
# Generate a priority manifest and then merge the user supplied manifest.
241241
is_asset_pack = feature_target[AndroidFeatureModuleInfo].is_asset_pack
242-
has_dex = feature_target[AndroidFeatureModuleInfo].has_dex
242+
has_code = feature_target[AndroidFeatureModuleInfo].has_code
243243
priority_manifest = ctx.actions.declare_file(
244244
ctx.label.name + "/" + feature_target.label.name + "/Priority_AndroidManifest.xml",
245245
)
@@ -251,7 +251,7 @@ def _create_feature_manifest(
251251
args.add(aapt2.executable)
252252
args.add(info.manifest)
253253
args.add(is_asset_pack)
254-
args.add(has_dex)
254+
args.add(has_code)
255255

256256
ctx.actions.run(
257257
executable = priority_feature_manifest_script,
@@ -331,7 +331,7 @@ def _impl(ctx):
331331
all_proguard_specs = list(ctx.files.proguard_specs)
332332
for feature in ctx.attr.feature_modules:
333333
info = feature[AndroidFeatureModuleInfo]
334-
if info.has_dex:
334+
if info.has_code:
335335
feature_deploy_jars[info.feature_name] = info.pre_dexed_jar
336336
if info.proguards_specs:
337337
all_proguard_specs.extend(info.proguards_specs)

rules/android_application/android_feature_module_rule.bzl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ load("@rules_java//java/common:proguard_spec_info.bzl", "ProguardSpecInfo")
3535
visibility(PROJECT_VISIBILITY)
3636

3737
def _impl(ctx):
38-
# Get the binary from the appropriate attribute based on has_dex
39-
binary = ctx.attr.binary_with_dex if ctx.attr.has_dex else ctx.attr.binary
38+
# Get the binary from the appropriate attribute based on has_code
39+
binary = ctx.attr.binary_with_code if ctx.attr.has_code else ctx.attr.binary
4040
pre_dexed_jar = binary[AndroidPreDexJarInfo].pre_dex_jar
4141

4242
# Collect proguard_specs from library dependencies of the feature module
@@ -80,7 +80,7 @@ def _impl(ctx):
8080
return [
8181
AndroidFeatureModuleInfo(
8282
binary = binary,
83-
has_dex = ctx.attr.has_dex,
83+
has_code = ctx.attr.has_code,
8484
library = utils.dedupe_split_attr(ctx.split_attr.library),
8585
title_id = ctx.attr.title_id,
8686
title_lib = ctx.attr.title_lib,
@@ -211,18 +211,18 @@ EOF
211211
}
212212
_android_binary(**binary_attrs)
213213

214-
has_dex = getattr(attrs, "has_dex", False)
214+
has_code = getattr(attrs, "has_code", False)
215215
android_feature_module(
216216
name = attrs.name,
217217
library = attrs.library,
218-
# Use binary_with_dex when has_dex=True to skip validation aspect
219-
binary = None if has_dex else str(targets.binary),
220-
binary_with_dex = str(targets.binary) if has_dex else None,
218+
# Use binary_with_code when has_code=True to skip validation aspect
219+
binary = None if has_code else str(targets.binary),
220+
binary_with_code = str(targets.binary) if has_code else None,
221221
title_id = title_id,
222222
title_lib = str(targets.title_lib),
223223
feature_name = getattr(attrs, "feature_name", attrs.name),
224224
fused = getattr(attrs, "fused", True),
225-
has_dex = has_dex,
225+
has_code = has_code,
226226
manifest = getattr(attrs, "manifest", None),
227227
tags = tags,
228228
transitive_configs = transitive_configs,

rules/android_application/attrs.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,18 @@ ANDROID_APPLICATION_ATTRS = _attrs.add(
108108
)
109109

110110
ANDROID_FEATURE_MODULE_ATTRS = dict(
111-
# binary is used when has_dex=False (with validation aspect)
111+
# binary is used when has_code=False (with validation aspect)
112112
binary = attr.label(aspects = [android_feature_module_validation_aspect]),
113-
# binary_with_dex is used when has_dex=True (without validation aspect)
114-
binary_with_dex = attr.label(),
113+
# binary_with_code is used when has_code=True (without validation aspect)
114+
binary_with_code = attr.label(),
115115
feature_name = attr.string(),
116116
fused = attr.bool(
117117
default = True,
118118
doc = "Whether the split is fused for the system image and for pre-L devices.",
119119
),
120-
has_dex = attr.bool(
120+
has_code = attr.bool(
121121
default = False,
122-
doc = "Allows the library dependency to contain dex files (Kotlin/Java code).",
122+
doc = "Whether the feature module contains code (Kotlin/Java). Maps to android:hasCode in manifest.",
123123
),
124124
library = attr.label(
125125
allow_rules = ["android_library"],

rules/android_application/gen_android_feature_manifest.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ split="${4}"
2020
title_id="${5}"
2121
fused="${6}"
2222
aapt="${7}"
23-
has_dex="${8}"
23+
has_code="${8}"
2424

2525
aapt_cmd="$aapt dump xmltree $base_apk --file AndroidManifest.xml"
2626
version_code=$(${aapt_cmd} | grep "http://schemas.android.com/apk/res/android:versionCode" | cut -d "=" -f2 | head -n 1 )
@@ -30,8 +30,8 @@ then
3030
exit 1
3131
fi
3232

33-
# Determine hasCode value based on has_dex parameter
34-
if [[ "$has_dex" == "true" ]]; then
33+
# Determine hasCode value based on has_code parameter
34+
if [[ "$has_code" == "true" ]]; then
3535
has_code_value="true"
3636
else
3737
has_code_value="false"

rules/android_application/gen_priority_android_feature_manifest.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ split="${4}"
2020
aapt="${5}"
2121
in_manifest="${6}" # Developer-provided manifest for the feature module
2222
is_asset_pack="${7}"
23-
has_dex="${8}"
23+
has_code="${8}"
2424

2525
aapt_cmd="$aapt dump xmltree $base_apk --file AndroidManifest.xml"
2626
version_code=$(${aapt_cmd} | grep "http://schemas.android.com/apk/res/android:versionCode" | cut -d "=" -f2 | head -n 1)
@@ -37,8 +37,8 @@ then
3737
exit 1
3838
fi
3939

40-
# Determine hasCode value based on has_dex parameter
41-
if [[ "$has_dex" == "true" ]]; then
40+
# Determine hasCode value based on has_code parameter
41+
if [[ "$has_code" == "true" ]]; then
4242
has_code_value="true"
4343
else
4444
has_code_value="false"

0 commit comments

Comments
 (0)