Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bd7505b
[SNAP FORK] avoid processing resources if none are explicitly specified
Sep 19, 2022
ef0533e
[SNAP FORK] fix aar_import rule
Sep 19, 2022
b2057a4
[SNAP FORK] enable support multiplex workers in busybox actions
Sep 19, 2022
8068285
[SNAP FORK] remove missing dep
Sep 19, 2022
0e01923
[SNAP FORK] Always fix resources transitivity
Sep 19, 2022
6bbf6fb
[SNAP FORK] enable the resource processing pipeline for android_local…
Sep 19, 2022
fc4e2ae
Disable warnings for busybox actions
Oct 22, 2022
43a25b3
[SNAP FORK] disable min_sdk enforcement
Oct 25, 2022
c124539
Remove invalid attr
Nov 2, 2022
63c6d68
accept sources.jar as input for srcjars
mgalindo-sc Nov 16, 2022
a13352f
Implement namespaced R class
Nov 20, 2022
7391c2d
Do Not infer package from path
Nov 29, 2022
4997ae9
[Lyft] Hacks working around the custom JDK issues
Bencodes May 5, 2023
da046c0
Add flag for namespace resources
Bencodes May 25, 2023
9691362
Fix rules/android_local_test/resources.bzl to reference processed_man…
Bencodes Jun 12, 2023
60b23f4
Enable conditional merging of manifest permissions
Bencodes Jun 21, 2023
ca0b27c
support-additional_providers-in-make_rule
Bencodes Jun 21, 2023
6d54e56
Don't collect transitive AndroidLibraryResourceClassJarProvider
Bencodes Jul 6, 2023
11280e0
Expand support for kt_android_local_test
Bencodes Jul 12, 2023
918620e
Add support for --output_library_merged_assets
Bencodes Jul 12, 2023
46e87de
Support --merge_android_manifest_permissions
Bencodes Jul 12, 2023
3c74dc1
Disable g3itr
Bencodes Jul 12, 2023
18013f9
Disable aar validation for now
Bencodes Jul 14, 2023
7476590
Rename android_application_macro generated target names to work bette…
Bencodes Jul 14, 2023
41d890d
Make the custom toolchain setup a bit easier
Bencodes Aug 25, 2023
6dd3c78
Output proguard mappings from R8
Bencodes Sep 8, 2023
575b2f8
Increase ThreadStackSize
Bencodes Sep 13, 2023
275ab3a
Increase R8 ram to 10g
Bencodes Sep 20, 2023
cec1b12
Add config to possibly skip unecessary linking for android_library ta…
oliviernotteghem Oct 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rules/aar_import/attrs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ATTRS = _attrs.add(
"This needs to be the same value as the manifest's package.",
),
srcjar = attr.label(
allow_single_file = [".srcjar"],
allow_single_file = ["sources.jar", ".srcjar"],
doc = "A srcjar file that contains the source code for the JVM " +
"artifacts stored within the AAR.",
),
Expand Down
21 changes: 8 additions & 13 deletions rules/aar_import/impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ load(
_java = "java",
)
load("//rules:providers.bzl", "AndroidLintRulesInfo")
load("//rules/flags:flags.bzl", _flags = "flags")
load(
"//rules:resources.bzl",
_resources = "resources",
Expand Down Expand Up @@ -154,7 +155,10 @@ def _process_resources(
deps = ctx.attr.deps,
exports = ctx.attr.exports,
exports_manifest = getattr(ctx.attr, "exports_manifest", True),
propagate_resources = _acls.in_aar_propagate_resources(str(ctx.label)),
propagate_resources = True,
namespaced_r_class = False,
output_library_merged_assets = _flags.get(ctx).output_library_merged_assets,
merge_manifest_permissions = _flags.get(ctx).merge_manifest_permissions,

# Tool and Processing related inputs
aapt = _get_android_toolchain(ctx).aapt2.files_to_run,
Expand All @@ -165,6 +169,7 @@ def _process_resources(
host_javabase = _common.get_host_javabase(ctx),
instrument_xslt = _utils.only(_get_android_toolchain(ctx).add_g3itr_xslt.files.to_list()),
xsltproc = _get_android_toolchain(ctx).xsltproc_tool.files_to_run,
link_library_resources = True,
)

native_android_manifest = manifest
Expand All @@ -176,7 +181,6 @@ def _process_resources(
</manifest>
""" % package)


return struct(**resources_ctx)

def _extract_jars(
Expand Down Expand Up @@ -350,7 +354,7 @@ def _process_jars(
),
source_jar = source_jar,
neverlink = False,
deps = r_java_info + java_infos, # TODO(djwhang): Exports are not deps.
deps = java_infos, # TODO(djwhang): Exports are not deps.
exports =
(r_java_info if _acls.in_aar_import_exports_r_java(str(ctx.label)) else []) +
java_infos, # TODO(djwhang): Deps are not exports.
Expand Down Expand Up @@ -501,8 +505,7 @@ def impl(ctx):
r_java = resources_ctx.r_java,
exports = _utils.collect_providers(JavaInfo, ctx.attr.exports),
enable_desugar_java8 = ctx.fragments.android.desugar_java8,
enable_imports_deps_check =
_acls.in_aar_import_deps_checker(str(ctx.label)),
enable_imports_deps_check = False,
aar_embedded_jars_extractor_tool =
_get_android_toolchain(ctx).aar_embedded_jars_extractor.files_to_run,
bootclasspath =
Expand Down Expand Up @@ -559,14 +562,6 @@ def impl(ctx):
)
providers.extend(lint_providers)

validation_outputs.append(_validate_rule(
ctx,
aar = aar,
package = package,
manifest = manifest_ctx.processed_manifest,
checks = _get_android_toolchain(ctx).aar_import_checks.files_to_run,
))

providers.append(
intellij.make_android_ide_info(
ctx,
Expand Down
5 changes: 5 additions & 0 deletions rules/aar_import/rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

load(":attrs.bzl", _ATTRS = "ATTRS")
load(":impl.bzl", _impl = "impl")
load(
"//rules:providers.bzl",
"StarlarkAndroidResourcesInfo",
)

RULE_DOC = """
#### Examples
Expand Down Expand Up @@ -49,6 +53,7 @@ aar_import = rule(
AndroidLibraryResourceClassJarProvider,
AndroidNativeLibsInfo,
JavaInfo,
StarlarkAndroidResourcesInfo,
],
toolchains = [
"//toolchains/android:toolchain_type",
Expand Down
2 changes: 0 additions & 2 deletions rules/acls/min_sdk_floors.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ cover the entire depot.

MIN_SDK_FLOORS = {
19: [
"//:__subpackages__",
],
14: [
"//:__subpackages__",
],
}
8 changes: 3 additions & 5 deletions rules/android_application/android_application_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ def _create_feature_manifest(
args.add(java_package)
args.add(info.feature_name)
args.add(info.title_id)
args.add(info.fused)
args.add(aapt2.executable)

ctx.actions.run(
Expand Down Expand Up @@ -369,7 +368,6 @@ def android_application_macro(_android_binary, **attrs):

# Create an android_binary base split, plus an android_application to produce the aab
name = attrs.pop("name")
base_split_name = "%s_base" % name

# default to [] if feature_modules = None is passed
feature_modules = attrs.pop("feature_modules", []) or []
Expand All @@ -387,13 +385,13 @@ def android_application_macro(_android_binary, **attrs):
attrs["deps"].append(str(module_targets.title_lib))

_android_binary(
name = base_split_name,
name = name,
**attrs
)

android_application(
name = name,
base_module = ":%s" % base_split_name,
name = "%s_aab" % name,
base_module = ":%s" % name,
bundle_config_file = bundle_config_file,
app_integrity_config = app_integrity_config,
rotation_config = rotation_config,
Expand Down
5 changes: 0 additions & 5 deletions rules/android_application/android_feature_module_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def _impl(ctx):
title_id = ctx.attr.title_id,
title_lib = ctx.attr.title_lib,
feature_name = ctx.attr.feature_name,
fused = ctx.attr.fused,
manifest = ctx.file.manifest,
),
OutputGroupInfo(_validation = depset([validation])),
Expand Down Expand Up @@ -115,9 +114,6 @@ def android_feature_module_macro(_android_binary, _android_library, **attrs):
if not getattr(attrs, attr, None):
fail("%s missing required attr <%s>" % (fqn, attr))

if hasattr(attrs, "fused") and hasattr(attrs, "manifest"):
fail("%s cannot specify <fused> and <manifest>. Prefer <manifest>")

targets = get_feature_module_paths(fqn)

tags = getattr(attrs, "tags", [])
Expand Down Expand Up @@ -193,7 +189,6 @@ EOF
title_id = title_id,
title_lib = str(targets.title_lib),
feature_name = getattr(attrs, "feature_name", attrs.name),
fused = getattr(attrs, "fused", True),
manifest = getattr(attrs, "manifest", None),
tags = tags,
transitive_configs = transitive_configs,
Expand Down
2 changes: 1 addition & 1 deletion rules/android_application/attrs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ANDROID_APPLICATION_ATTRS = _attrs.add(
),
_bundle_keystore_properties = attr.label(
allow_single_file = True,
default = "//rules:bundle_keystore_properties.tmpl",
default = None,
),
_feature_manifest_script = attr.label(
allow_single_file = True,
Expand Down
2 changes: 0 additions & 2 deletions rules/android_application/gen_android_feature_manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ base_apk="${2}"
package="${3}"
split="${4}"
title_id="${5}"
fused="${6}"
aapt="${7}"

aapt_cmd="$aapt dump xmltree $base_apk --file AndroidManifest.xml"
Expand All @@ -41,7 +40,6 @@ cat >$out_manifest <<EOF
<dist:module
dist:instant="false"
dist:title="@string/$title_id"> <!-- title must be an ID! Needs to work with proguard/resource shrinking -->
<dist:fusing dist:include="$fused" />
<dist:delivery>
<dist:on-demand /></dist:delivery>
</dist:module>
Expand Down
2 changes: 1 addition & 1 deletion rules/android_binary_internal/impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -792,5 +792,5 @@ def impl(ctx):
Returns:
A list of providers.
"""
java_package = java.resolve_package_from_label(ctx.label, ctx.attr.custom_package)
java_package = ctx.attr.custom_package if ctx.attr.custom_package else None
return processing_pipeline.run(ctx, java_package, _PROCESSING_PIPELINE)
7 changes: 5 additions & 2 deletions rules/android_binary_internal/r8.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ def process_r8(ctx, jvm_ctx, packaged_resources_ctx, build_info_ctx, **_unused_c
android_jar = get_android_sdk(ctx).android_jar
proguard_specs = proguard.get_proguard_specs(ctx, packaged_resources_ctx.resource_proguard_config)
min_sdk_version = getattr(ctx.attr, "min_sdk_version", None)
proguard_mappings_file = ctx.actions.declare_file(ctx.label.name + "_proguard.map")

args = ctx.actions.args()
args.add("--release")
if min_sdk_version:
args.add("--min-api", min_sdk_version)
args.add("--pg-map-output", proguard_mappings_file)
args.add("--output", dexes_zip)
args.add_all(proguard_specs, before_each = "--pg-conf")
args.add("--lib", android_jar)
Expand All @@ -90,9 +92,9 @@ def process_r8(ctx, jvm_ctx, packaged_resources_ctx, build_info_ctx, **_unused_c
executable = get_android_toolchain(ctx).r8.files_to_run,
arguments = [args],
inputs = [android_jar, deploy_jar] + proguard_specs,
outputs = [dexes_zip],
outputs = [dexes_zip, proguard_mappings_file],
mnemonic = "AndroidR8",
jvm_flags = ["-Xmx8G"],
jvm_flags = ["-Xmx10G", "-XX:ThreadStackSize=2048"],
progress_message = "R8 Optimizing, Desugaring, and Dexing %{label}",
)

Expand All @@ -108,6 +110,7 @@ def process_r8(ctx, jvm_ctx, packaged_resources_ctx, build_info_ctx, **_unused_c
name = "r8_ctx",
value = struct(
final_classes_dex_zip = dexes_zip,
proguard_mappings_file = proguard_mappings_file,
providers = [android_dex_info],
),
)
Expand Down
6 changes: 4 additions & 2 deletions rules/android_binary_internal/rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,24 @@ def make_rule(
attrs = ATTRS,
implementation = impl,
provides = _DEFAULT_PROVIDES,
additional_toolchains = []):
additional_toolchains = [],
additional_providers = []):
"""Makes the rule.

Args:
attrs: A dict. The attributes for the rule.
implementation: A function. The rule's implementation method.
provides: A list. The providers that the rule must provide.
additional_toolchains: A list. Additional toolchains passed to pass to rule(toolchains).
additional_providers: A list. Additional providers passed to pass to rule(providers).

Returns:
A rule.
"""
return rule(
attrs = attrs,
implementation = implementation,
provides = provides,
provides = provides + additional_providers,
toolchains = [
"//toolchains/android:toolchain_type",
"//toolchains/android_sdk:toolchain_type",
Expand Down
8 changes: 6 additions & 2 deletions rules/android_library/impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,11 @@ def _process_resources(ctx, java_package, manifest_ctx, **unused_ctxs):
enable_res_v3 = _flags.get(ctx).android_enable_res_v3,
# TODO(b/144163743): remove fix_resource_transitivity, which was only added to emulate
# misbehavior on the Java side.
fix_resource_transitivity = bool(ctx.attr.srcs),
fix_resource_transitivity = True,
fix_export_exporting = acls.in_fix_export_exporting_rollout(str(ctx.label)),
namespaced_r_class = _flags.get(ctx).namespaced_r_class,
output_library_merged_assets = _flags.get(ctx).output_library_merged_assets,
merge_manifest_permissions = _flags.get(ctx).merge_manifest_permissions,

# Tool and Processing related inputs
aapt = get_android_toolchain(ctx).aapt2.files_to_run,
Expand All @@ -194,6 +197,7 @@ def _process_resources(ctx, java_package, manifest_ctx, **unused_ctxs):
),
xsltproc = get_android_toolchain(ctx).xsltproc_tool.files_to_run,
zip_tool = get_android_toolchain(ctx).zip_tool.files_to_run,
link_library_resources = _flags.get(ctx).link_library_resources,
)

# TODO(b/139305816): Remove the ability for android_library to be added in
Expand Down Expand Up @@ -584,5 +588,5 @@ def impl(ctx):
Returns:
A legacy struct provider.
"""
java_package = _java.resolve_package_from_label(ctx.label, ctx.attr.custom_package)
java_package = ctx.attr.custom_package if ctx.attr.custom_package else None
return processing_pipeline.run(ctx, java_package, _PROCESSING_PIPELINE)
7 changes: 4 additions & 3 deletions rules/android_library/rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def _outputs(name, _package_name, _defined_local_resources):
path_prefix = ""
outputs.update(
dict(
resources_src_jar = path_prefix + "%{name}.srcjar",
resources_txt = path_prefix + "%{name}_symbols/R.txt",
resources_jar = path_prefix + "%{name}_resources.jar",
),
Expand All @@ -140,14 +139,16 @@ def make_rule(
attrs = _ATTRS,
implementation = _impl,
outputs = _outputs,
additional_toolchains = []):
additional_toolchains = [],
additional_providers = []):
"""Makes the rule.

Args:
attrs: A dict. The attributes for the rule.
implementation: A function. The rule's implementation method.
outputs: A dict, function, or None. The rule's outputs.
additional_toolchains: A list. Additional toolchains passed to pass to rule(toolchains).
additional_providers: A list. Additional providers passed to pass to rule(providers).

Returns:
A rule.
Expand All @@ -167,7 +168,7 @@ def make_rule(
AndroidLibraryResourceClassJarProvider,
AndroidNativeLibsInfo,
JavaInfo,
],
] + additional_providers,
outputs = outputs,
toolchains = [
"//toolchains/android:toolchain_type",
Expand Down
Loading