Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 mobile_install/apks.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def make_split_apks(
to_pack = dexes + [r_dex]
if native_zips:
to_pack.extend(native_zips)
for i, artifact in enumerate(to_pack):
for artifact in to_pack:
# the split attr in the manifest will be used to name the file on the device like
# split_${SPLIT_ID}.apk. We need to follow the same pattern so that we can compare
# files during sync time and only do the incremental install.
Expand Down
10 changes: 1 addition & 9 deletions rules/aar_import/impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ RULE_PREFIX = "_aar"
ANDROID_MANIFEST = "AndroidManifest.xml"
LINT_JAR = "lint.jar"

# Resources context dict fields.
_PROVIDERS = "providers"
_VALIDATION_RESULTS = "validation_results"

def _create_aar_tree_artifact(ctx, name):
return ctx.actions.declare_directory("%s/unzipped/%s/%s" % (RULE_PREFIX, name, ctx.label.name))

Expand Down Expand Up @@ -138,9 +134,7 @@ def _process_resources(
aar,
package,
manifest,
deps,
aar_resources_extractor_tool,
unzip_tool):
aar_resources_extractor_tool):
# Extract resources and assets, if they exist.
resources = _create_aar_tree_artifact(ctx, "resources")
assets = _create_aar_tree_artifact(ctx, "assets")
Expand Down Expand Up @@ -492,10 +486,8 @@ def impl(ctx):
aar = aar,
package = package,
manifest = manifest_ctx.processed_manifest,
deps = ctx.attr.deps,
aar_resources_extractor_tool =
_get_android_toolchain(ctx).aar_resources_extractor.files_to_run,
unzip_tool = unzip_tool,
)
providers.extend(resources_ctx.providers)

Expand Down
6 changes: 1 addition & 5 deletions rules/android_application/android_application_rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ def _process_feature_module(
get_android_sdk(ctx).aapt2,
ctx.executable._feature_manifest_script,
ctx.executable._priority_feature_manifest_script,
get_android_toolchain(ctx).android_resources_busybox,
_common.get_host_javabase(ctx),
)

# Remove all dexes from the feature module apk. jvm / resources are not
Expand Down Expand Up @@ -186,9 +184,7 @@ def _create_feature_manifest(
feature_target,
aapt2,
feature_manifest_script,
priority_feature_manifest_script,
android_resources_busybox,
host_javabase):
priority_feature_manifest_script):
info = feature_target[AndroidFeatureModuleInfo]
manifest = ctx.actions.declare_file(ctx.label.name + "/" + feature_target.label.name + "/AndroidManifest.xml")

Expand Down
15 changes: 2 additions & 13 deletions rules/android_binary/impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def _process_build_info(_unused_ctx, **unused_ctxs):
),
)

def _process_dex(ctx, validation_ctx, packaged_resources_ctx, manifest_ctx, deploy_ctx, bp_ctx, optimize_ctx, **_unused_ctxs):
def _process_dex(ctx, validation_ctx, packaged_resources_ctx, manifest_ctx, deploy_ctx, optimize_ctx, **_unused_ctxs):
if validation_ctx.use_r8:
return ProviderInfo(
name = "dex_ctx",
Expand Down Expand Up @@ -421,7 +421,7 @@ def _process_dex(ctx, validation_ctx, packaged_resources_ctx, manifest_ctx, depl
),
)

def _process_deploy_jar(ctx, validation_ctx, stamp_ctx, manifest_ctx, packaged_resources_ctx, jvm_ctx, build_info_ctx, proto_ctx, **_unused_ctxs):
def _process_deploy_jar(ctx, validation_ctx, stamp_ctx, manifest_ctx, jvm_ctx, build_info_ctx, **_unused_ctxs):
if validation_ctx.use_r8:
return ProviderInfo(
name = "deploy_ctx",
Expand Down Expand Up @@ -608,17 +608,6 @@ def _get_library_r_jars(deps):
transitive_resource_jars += dep.jars.to_list()
return transitive_resource_jars

def _is_test_binary(ctx):
"""Whether this android_binary target is a test binary.

Args:
ctx: The context.

Returns:
Boolean indicating whether the target is a test target.
"""
return ctx.attr.testonly or is_instrumentation(ctx) or str(ctx.label).find("/javatests/") >= 0

def is_instrumentation(ctx):
"""Whether this android_binary target is an instrumentation binary.

Expand Down
3 changes: 0 additions & 3 deletions rules/android_binary/rule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ load(":impl.bzl", "impl")

visibility(PROJECT_VISIBILITY)

_DEFAULT_ALLOWED_ATTRS = ["name", "visibility", "tags", "testonly", "transitive_configs", "$enable_manifest_merging", "features", "exec_properties"]

_DEFAULT_PROVIDES = [ApkInfo, JavaInfo]

def _outputs(name, proguard_generate_mapping, _package_name, _generate_proguard_outputs, _generate_art_profile_outputs):
Expand Down Expand Up @@ -126,7 +124,6 @@ def android_binary_macro(**attrs):

# Required for ACLs check in _outputs(), since the callback can't access the native module.
attrs["$package_name"] = native.package_name()
target_fqn = "//%s:%s" % (native.package_name(), attrs["name"])

if type(attrs.get("proguard_specs", None)) == "select" or attrs.get("proguard_specs", None):
attrs["$generate_proguard_outputs"] = True
Expand Down
3 changes: 1 addition & 2 deletions rules/android_library/impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def _process_lint_rules(ctx, **unused_sub_ctxs):
),
)

def _process_aar(ctx, java_package, resources_ctx, proguard_ctx, **unused_ctx):
def _process_aar(ctx, resources_ctx, proguard_ctx, **unused_ctx):
aar_ctx = {
_PROVIDERS: [],
_VALIDATION_OUTPUTS: [],
Expand Down Expand Up @@ -460,7 +460,6 @@ PROCESSORS = dict(
def finalize(
ctx,
resources_ctx,
intellij_ctx,
jvm_ctx,
proguard_ctx,
providers,
Expand Down
2 changes: 0 additions & 2 deletions rules/data_binding.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ def _setup_dependent_lib_artifacts(ctx, output_dir, deps):
return dep_lib_artifacts

def _get_javac_opts(
ctx,
java_package,
artifact_type,
dependency_artifacts_dir,
Expand Down Expand Up @@ -284,7 +283,6 @@ def _process(
)

db_info[_JAVAC_OPTS] = _get_javac_opts(
ctx,
java_package,
artifact_type,
(
Expand Down
4 changes: 2 additions & 2 deletions rules/dex_desugar_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _aspect_impl(target, ctx):

if runtime_jars:
basename_clash = _check_basename_clash(runtime_jars)
aspect_dexopts = _get_aspect_dexopts(ctx)
aspect_dexopts = _get_aspect_dexopts()
for jar in runtime_jars:
if ctx.fragments.android.desugar_java8:
jar_to_desugar = jar
Expand Down Expand Up @@ -214,7 +214,7 @@ def _get_platform_based_toolchain_jars(ctx):
return ctx.rule.attr._aidl_lib[JavaInfo].runtime_output_jars
return []

def _get_aspect_dexopts(ctx):
def _get_aspect_dexopts():
return _power_set(_dex.normalize_dexopts(_dex.DEXOPTS_SUPPORTED_IN_INCREMENTAL_DEXING))

def _get_boot_classpath(target, ctx):
Expand Down
8 changes: 4 additions & 4 deletions rules/min_sdk_version.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ it holds utilities for handling minSdkVersion propagation.

"""

load("//rules:visibility.bzl", "PROJECT_VISIBILITY")
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("//rules:visibility.bzl", "PROJECT_VISIBILITY")

visibility(PROJECT_VISIBILITY)

_SETTING = "//rules/flags:min_sdk_version"
_DEPOT_FLOOR = 23
_DEX_DESUGAR = 23 # Kept at 23 due to b/331852939. See some related discussion at b/319114605
_MIN_SDK_LEVELS = sorted([_DEPOT_FLOOR, 24])
# _MIN_SDK_LEVELS = sorted([_DEPOT_FLOOR, 24])

_ATTRS = dict(
_min_sdk_version = attr.label(
Expand All @@ -35,7 +35,7 @@ _ATTRS = dict(
),
)

def _clamp(min_sdk_version):
def _clamp(min_sdk_version): # @unused
# TODO(asinclair): Uncomment this once android_binary is Starlarkified and the order of the
# Android Platforms Transition and Feature Flags transition is swapped.
# clamped = _MIN_SDK_LEVELS[0]
Expand All @@ -46,7 +46,7 @@ def _clamp(min_sdk_version):
# return clamped
return 0

def _get(ctx):
def _get(ctx): # @unused
# This is the case when an android_binary target does not set a value explicitly.
# The configuration value defaults to 0
# So in this case we use the depot floor.
Expand Down
1 change: 0 additions & 1 deletion rules/native_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ SplitConfigInfo = provider(
)

def _split_config_aspect_impl(__, ctx):
android_cfg = ctx.fragments.android
return SplitConfigInfo(
build_config = ctx.configuration,
target_platform = ctx.fragments.platform.platform,
Expand Down
50 changes: 0 additions & 50 deletions rules/resources.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ _MANIFEST_MISSING_ERROR = (
"assets, or exports_manifest are specified."
)

_ASSET_DEFINITION_ERROR = (
"In target %s, the assets and assets_dir attributes should be either " +
"both empty or non-empty."
)

_INCORRECT_RESOURCE_LAYOUT_ERROR = (
"'%s' is not in the expected resource directory structure of " +
"<resource directory>/{%s}/<file>" % (",").join(_RESOURCE_FOLDER_TYPES)
Expand Down Expand Up @@ -886,43 +881,6 @@ def _liteparse(ctx, out_r_pb, resource_files, android_kit):
toolchain = None,
)

def _fastr(ctx, r_pbs, package, manifest, android_kit):
"""Create R.srcjar from the given R.pb files in the transitive closure.

Args:
ctx: The context.
r_pbs: Transitive set of resource pbs.
package: The package name of the compile-time R.java.
manifest: File. The AndroidManifest.xml file.
android_kit: FilesToRunProvider. The Android Kit executable or
FilesToRunProvider.

Returns:
The output R source jar artifact.
"""
inputs = r_pbs
r_srcjar = ctx.actions.declare_file(ctx.label.name + "/resources/R-fastr.srcjar")
args = ctx.actions.args()
args.use_param_file(param_file_arg = "--flagfile=%s", use_always = True)
args.set_param_file_format("multiline")
args.add("-rJavaOutput", r_srcjar)
if package:
args.add("-packageForR", package)
else:
args.add("-manifest", manifest)
inputs = depset([manifest], transitive = [inputs])
args.add_joined("-resourcePbs", r_pbs, join_with = ",")

ctx.actions.run(
executable = android_kit,
arguments = ["rstub", args],
inputs = inputs,
outputs = [r_srcjar],
mnemonic = "CompileTimeR",
progress_message = "Generating compile-time R %s" % r_srcjar.short_path,
)
return r_srcjar

def _compile(
ctx,
out_compiled_resources = None,
Expand Down Expand Up @@ -1007,14 +965,6 @@ def _make_aar(
)
return aar

def _validate(ctx, manifest, defined_assets, defined_assets_dir):
if ((defined_assets and not defined_assets_dir) or
(not defined_assets and defined_assets_dir)):
_log.error(_ASSET_DEFINITION_ERROR % ctx.label)

if not manifest:
_log.error(_MANIFEST_MISSING_ERROR % ctx.label)

def _validate_resources(resource_files = None):
for resource_file in resource_files:
path_segments = resource_file.path.split("/")
Expand Down
1 change: 0 additions & 1 deletion test/rules/resources/test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,6 @@ resources_package_test = rule(

def _package_resources_final_id_test(ctx):
env = analysistest.begin(ctx)
target_under_test = analysistest.target_under_test(env)
actions = analysistest.target_actions(env)
found_final_r = False
found_nonfinal_r = False
Expand Down
12 changes: 0 additions & 12 deletions test/utils/asserts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,6 @@ def ExpectedStarlarkAndroidResourcesInfo(
)
return name

def _build_expected_resources_node_info(string):
parts = string.split(":")
if len(parts) != 5:
fail("Error: malformed resources_node_info string: %s" % string)
return dict(
label = parts[0],
assets = parts[1].split(",") if parts[1] else [],
assets_dir = parts[2],
assets_symbols = parts[3],
compiled_resources = parts[4],
)

def _expected_android_binary_native_libs_info_impl(ctx):
return _ExpectedAndroidBinaryNativeInfo(
transitive_native_libs_by_cpu_architecture = ctx.attr.transitive_native_libs_by_cpu_architecture,
Expand Down