Skip to content

Commit

Permalink
Merge pull request #5216 from systeminit/sf/updates-2025-W02
Browse files Browse the repository at this point in the history
build: update Nix & Buck2 software (2025-W02)
  • Loading branch information
zacharyhamm authored Jan 10, 2025
2 parents 4b807b6 + 462b035 commit 8ff5530
Showing 328 changed files with 8,930 additions and 3,492 deletions.
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions prelude/BUCK
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@prelude//:none.bzl", "none_rule")
load("@prelude//utils:source_listing.bzl", "source_listing")
load(":native.bzl", prelude = "native")

@@ -48,3 +49,8 @@ prelude.filegroup(
},
visibility = ["PUBLIC"],
)

none_rule(
name = "none",
visibility = ["PUBLIC"],
)
7 changes: 3 additions & 4 deletions prelude/android/aapt2_link.bzl
Original file line number Diff line number Diff line change
@@ -99,10 +99,9 @@ def get_aapt2_link(
aapt2_command.add(["--debug-mode"])

if filter_locales and len(locales) > 0:
aapt2_command.add("-c")

# "NONE" means "en", update the list of locales
aapt2_command.add(cmd_args([locale if locale != "NONE" else "en" for locale in locales], delimiter = ","))
for locale in locales:
# "NONE" means "en", update the list of locales
aapt2_command.add(["-c", locale if locale != "NONE" else "en"])

for compiled_resource_apk in compiled_resource_apks:
aapt2_command.add(["-I", compiled_resource_apk])
24 changes: 9 additions & 15 deletions prelude/android/android.bzl
Original file line number Diff line number Diff line change
@@ -5,17 +5,18 @@
# License, Version 2.0 found in the LICENSE-APACHE file in the root directory
# of this source tree.

load("@prelude//:genrule.bzl", "genrule_attributes")
load(
"@prelude//:validation_deps.bzl",
"VALIDATION_DEPS_ATTR_NAME",
)
load("@prelude//android:cpu_filters.bzl", "ALL_CPU_FILTERS")
load("@prelude//decls:android_rules.bzl", "DuplicateResourceBehaviour")
load("@prelude//decls:common.bzl", "buck")
load("@prelude//decls:core_rules.bzl", "TargetCpuType")
load("@prelude//decls:toolchains_common.bzl", "toolchains_common")
load("@prelude//java:java.bzl", "AbiGenerationMode", "dex_min_sdk_version")
load("@prelude//decls/android_rules.bzl", "AaptMode", "DuplicateResourceBehaviour")
load("@prelude//decls/common.bzl", "buck")
load("@prelude//decls/core_rules.bzl", "TargetCpuType")
load("@prelude//decls/toolchains_common.bzl", "toolchains_common")
load("@prelude//genrule.bzl", "genrule_attributes")
load("@prelude//transitions:constraint_overrides.bzl", "constraint_overrides")
load(":android_aar.bzl", "android_aar_impl")
load(":android_apk.bzl", "android_apk_impl")
load(":android_build_config.bzl", "android_build_config_impl")
@@ -103,13 +104,10 @@ extra_attributes = {
"_build_only_native_code": attrs.default_only(attrs.bool(default = is_build_only_native_code())),
},
"android_binary": {
"aapt_mode": attrs.enum(AaptMode, default = "aapt1"), # Match default in V1
"application_module_blacklist": attrs.option(attrs.list(attrs.transition_dep(cfg = cpu_transition)), default = None),
"application_module_blocklist": attrs.option(attrs.list(attrs.transition_dep(cfg = cpu_transition)), default = None),
"application_module_configs": attrs.dict(key = attrs.string(), value = attrs.list(attrs.transition_dep(cfg = cpu_transition)), sorted = False, default = {}),
"build_config_values_file": attrs.option(attrs.one_of(attrs.transition_dep(cfg = cpu_transition), attrs.source()), default = None),
"constraint_overrides": attrs.list(attrs.string(), default = []),
"deps": attrs.list(attrs.split_transition_dep(cfg = cpu_split_transition), default = []),
"dex_tool": attrs.string(default = "d8"), # Match default in V1
"duplicate_resource_behavior": attrs.enum(DuplicateResourceBehaviour, default = "allow_by_default"), # Match default in V1
"manifest": attrs.option(attrs.one_of(attrs.transition_dep(cfg = cpu_transition), attrs.source()), default = None),
"manifest_skeleton": attrs.option(attrs.one_of(attrs.transition_dep(cfg = cpu_transition), attrs.source()), default = None),
@@ -129,20 +127,18 @@ extra_attributes = {
"_is_force_single_default_cpu": attrs.default_only(attrs.bool(default = FORCE_SINGLE_DEFAULT_CPU)),
"_java_toolchain": toolchains_common.java_for_android(),
VALIDATION_DEPS_ATTR_NAME: attrs.set(attrs.transition_dep(cfg = cpu_transition), sorted = True, default = []),
},
} | constraint_overrides.attributes,
"android_build_config": {
"_android_toolchain": toolchains_common.android(),
"_build_only_native_code": attrs.default_only(attrs.bool(default = is_build_only_native_code())),
"_is_building_android_binary": is_building_android_binary_attr(),
"_java_toolchain": toolchains_common.java_for_android(),
},
"android_bundle": {
"aapt_mode": attrs.enum(AaptMode, default = "aapt1"), # Match default in V1
"application_module_blacklist": attrs.option(attrs.list(attrs.transition_dep(cfg = cpu_transition)), default = None),
"application_module_blocklist": attrs.option(attrs.list(attrs.transition_dep(cfg = cpu_transition)), default = None),
"application_module_configs": attrs.dict(key = attrs.string(), value = attrs.list(attrs.transition_dep(cfg = cpu_transition)), sorted = False, default = {}),
"build_config_values_file": attrs.option(attrs.one_of(attrs.transition_dep(cfg = cpu_transition), attrs.source()), default = None),
"deps": attrs.list(attrs.split_transition_dep(cfg = cpu_split_transition), default = []),
"dex_tool": attrs.string(default = "d8"), # Match default in V1
"duplicate_resource_behavior": attrs.enum(DuplicateResourceBehaviour, default = "allow_by_default"), # Match default in V1
"manifest": attrs.option(attrs.one_of(attrs.transition_dep(cfg = cpu_transition), attrs.source()), default = None),
"manifest_skeleton": attrs.option(attrs.one_of(attrs.transition_dep(cfg = cpu_transition), attrs.source()), default = None),
@@ -164,11 +160,9 @@ extra_attributes = {
VALIDATION_DEPS_ATTR_NAME: attrs.set(attrs.transition_dep(cfg = cpu_transition), sorted = True, default = []),
},
"android_instrumentation_apk": {
"aapt_mode": attrs.enum(AaptMode, default = "aapt1"), # Match default in V1
"apk": attrs.dep(),
"cpu_filters": attrs.list(attrs.enum(TargetCpuType), default = []),
"deps": attrs.list(attrs.split_transition_dep(cfg = cpu_split_transition), default = []),
"dex_tool": attrs.string(default = "d8"), # Match default in V1
"is_self_instrumenting": attrs.bool(default = False),
"manifest": attrs.option(attrs.one_of(attrs.transition_dep(cfg = cpu_transition), attrs.source()), default = None),
"manifest_skeleton": attrs.option(attrs.one_of(attrs.transition_dep(cfg = cpu_transition), attrs.source()), default = None),
2 changes: 1 addition & 1 deletion prelude/android/android_aar.bzl
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ def android_aar_impl(ctx: AnalysisContext) -> list[Provider]:
java_packaging_deps = [packaging_dep for packaging_dep in get_all_java_packaging_deps(ctx, deps) if not excluded_java_packaging_deps_targets.contains(packaging_dep.label.raw_target())]
android_packageable_info = merge_android_packageable_info(ctx.label, ctx.actions, deps)

android_manifest = get_manifest(ctx, android_packageable_info, manifest_entries = {}, should_replace_application_id_placeholders = False)
android_manifest = get_manifest(ctx, android_packageable_info, ctx.attrs.manifest_entries, should_replace_application_id_placeholders = False)

if ctx.attrs.include_build_config_class:
build_config_infos = list(android_packageable_info.build_config_infos.traverse()) if android_packageable_info.build_config_infos else []
2 changes: 1 addition & 1 deletion prelude/android/android_apk.bzl
Original file line number Diff line number Diff line change
@@ -139,6 +139,7 @@ def build_apk(
asset_directories = (
native_library_info.root_module_native_lib_assets +
native_library_info.non_root_module_native_lib_assets +
dex_files_info.root_module_bootstrap_dex_dirs +
dex_files_info.root_module_secondary_dex_dirs +
dex_files_info.non_root_module_secondary_dex_dirs +
resources_info.module_manifests
@@ -229,7 +230,6 @@ def get_install_config(apex_mode: bool) -> dict[str, typing.Any]:
install_config = {
"adb_restart_on_failure": read_root_config("adb", "adb_restart_on_failure", "true"),
"agent_port_base": read_root_config("adb", "agent_port_base", "2828"),
"always_use_java_agent": read_root_config("adb", "always_use_java_agent", "false"),
"apex_mode": apex_mode,
"is_zstd_compression_enabled": read_root_config("adb", "is_zstd_compression_enabled", "false"),
"max_retries": read_root_config("adb", "retries", "5"),
8 changes: 2 additions & 6 deletions prelude/android/android_binary.bzl
Original file line number Diff line number Diff line change
@@ -51,8 +51,6 @@ def get_binary_info(ctx: AnalysisContext, use_proto_format: bool) -> AndroidBina
sub_targets = {}
materialized_artifacts = []

_verify_params(ctx)

deps_by_platform = get_deps_by_platform(ctx)
primary_platform = CPU_FILTER_FOR_PRIMARY_PLATFORM if CPU_FILTER_FOR_PRIMARY_PLATFORM in deps_by_platform else CPU_FILTER_FOR_DEFAULT_PLATFORM
deps = deps_by_platform[primary_platform]
@@ -130,6 +128,7 @@ def get_binary_info(ctx: AnalysisContext, use_proto_format: bool) -> AndroidBina
pre_dexed_libs,
get_split_dex_merge_config(ctx, android_toolchain),
target_to_module_mapping_file,
enable_bootstrap_dexes = ctx.attrs.enable_bootstrap_dexes,
)
else:
dex_files_info = merge_to_single_dex(ctx, android_toolchain, pre_dexed_libs)
@@ -173,6 +172,7 @@ def get_binary_info(ctx: AnalysisContext, use_proto_format: bool) -> AndroidBina
proguard_output.proguard_mapping_output_file if proguard_output else None,
is_optimized = has_proguard_config,
apk_module_graph_file = target_to_module_mapping_file,
enable_bootstrap_dexes = ctx.attrs.enable_bootstrap_dexes,
)
else:
dex_files_info = get_single_primary_dex(
@@ -245,7 +245,3 @@ def get_build_config_java_libraries(
)[1])

return java_libraries

def _verify_params(ctx: AnalysisContext):
expect(ctx.attrs.aapt_mode == "aapt2", "aapt1 is deprecated!")
expect(ctx.attrs.dex_tool == "d8", "dx is deprecated!")
60 changes: 18 additions & 42 deletions prelude/android/android_binary_native_library_rules.bzl
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ load("@prelude//linking:strip.bzl", "strip_object")
load("@prelude//linking:types.bzl", "Linkage")
load("@prelude//utils:argfile.bzl", "argfile")
load("@prelude//utils:expect.bzl", "expect")
load("@prelude//utils:graph_utils.bzl", "GraphTraversal", "depth_first_traversal_by", "post_order_traversal", "pre_order_traversal")
load("@prelude//utils:graph_utils.bzl", "post_order_traversal", "pre_order_traversal", "rust_matching_topological_traversal")
load("@prelude//utils:set.bzl", "set", "set_type") # @unused Used as a type
load("@prelude//utils:utils.bzl", "dedupe_by_value")

@@ -183,6 +183,7 @@ def get_android_binary_native_library_info(
linkable_nodes_by_platform = {}
native_library_merge_sequence = getattr(ctx.attrs, "native_library_merge_sequence", None)
native_library_merge_map = getattr(ctx.attrs, "native_library_merge_map", None)
native_library_merge_non_asset_libs = getattr(ctx.attrs, "native_library_merge_non_asset_libs", False)
has_native_merging = native_library_merge_sequence or native_library_merge_map
enable_relinker = getattr(ctx.attrs, "enable_relinker", False)

@@ -211,6 +212,8 @@ def get_android_binary_native_library_info(
mergemap_cmd.add(cmd_args(native_library_merge_input_file, format = "--mergemap-input={}"))
if apk_module_graph_file:
mergemap_cmd.add(cmd_args(apk_module_graph_file, format = "--apk-module-graph={}"))
if native_library_merge_non_asset_libs:
mergemap_cmd.add(cmd_args("--merge-non-asset-libs"))
native_library_merge_dir = ctx.actions.declare_output("merge_sequence_output")
native_library_merge_map = native_library_merge_dir.project("merge.map")
split_groups_map = native_library_merge_dir.project("split_groups.map")
@@ -1154,8 +1157,9 @@ def _get_merged_linkables_for_platform(
group_deps = link_groups_graph_builder.setdefault(target_group, {})
for dep in linkable_nodes_graph[target]:
dep_group = target_to_link_group[dep]
if target_group != dep_group:
group_deps[dep_group] = True
if target_group != dep_group and dep_group not in group_deps:
# Store one example of why target_group depends on dep_group
group_deps[dep_group] = (target, dep)
link_groups_graph = {k: list(v.keys()) for k, v in link_groups_graph_builder.items()}

archive_output_style = LibOutputStyle("pic_archive")
@@ -1165,9 +1169,17 @@ def _get_merged_linkables_for_platform(
group_shared_libs = {}
included_default_solibs = {}

def edge_explainer(src_group, dest_group):
"""Explains in an error why src_group has a dependency on dest_group"""
if src_group not in link_groups_graph_builder or dest_group not in link_groups_graph_builder[src_group]:
return ["Unknown"]

src_target, dest_target = link_groups_graph_builder[src_group][dest_group]
return [" " + str(src_target), "-> " + str(dest_target)]

# Now we will traverse from the leaves up the graph (the link groups graph). As we traverse, we will produce
# a link group linkablenode for each group.
for group in post_order_traversal(link_groups_graph):
for group in post_order_traversal(link_groups_graph, edge_explainer = edge_explainer):
group_data = link_groups[group]
is_actually_merged = len(group_data.constituents) > 1

@@ -1446,42 +1458,6 @@ def _create_relinkable_links(

return {lib.soname.ensure_str(): lib for lib in shared_libs.values()}, debug_link_deps

# To support migration from a tset-based link strategy, we are trying to match buck's internal tset
# traversal logic here. Look for implementation of TopologicalTransitiveSetIteratorGen
def _rust_matching_topological_traversal(
roots: list[typing.Any],
get_nodes_to_traverse_func: typing.Callable) -> list[typing.Any]:
counts = {}

for label in depth_first_traversal_by(None, roots, get_nodes_to_traverse_func, GraphTraversal("preorder-right-to-left")):
for dep in get_nodes_to_traverse_func(label):
if dep in counts:
counts[dep] += 1
else:
counts[dep] = 1

# some of the targets in roots might be transitive deps of others, we only put those that are true roots
# in the stack at this point
stack = [root_target for root_target in roots if not root_target in counts]
true_roots = len(stack)

result = []
for _ in range(2000000000):
if not stack:
break
next = stack.pop()
result.append(next)
deps = get_nodes_to_traverse_func(next)
for child in deps[::-1]: # reverse order ensures we put things on the stack in the same order as rust's tset traversal
counts[child] -= 1
if counts[child] == 0:
stack.append(child)

if len(result) != true_roots + len(counts):
fail() # fail_cycle

return result

def _create_link_args(
*,
cxx_toolchain: CxxToolchainInfo,
@@ -1519,7 +1495,7 @@ def _create_link_args(

links = []
shlib_deps = []
for target in _rust_matching_topological_traversal([root_target], link_traversal):
for target in rust_matching_topological_traversal(None, [root_target], link_traversal):
is_root = target == root_target
node = graph[target]
preferred_linkable_type = get_lib_output_style(link_strategy, node.preferred_linkage, PicBehavior("supported"))
@@ -1577,7 +1553,7 @@ def _create_merged_link_args(

links = []
shlib_deps = []
for label in _rust_matching_topological_traversal([root_target.label], link_traversal):
for label in rust_matching_topological_traversal(None, [root_target.label], link_traversal):
if label == root_target.label:
links.extend(root_target.constituent_link_infos)
else:
6 changes: 3 additions & 3 deletions prelude/android/android_binary_resources_rules.bzl
Original file line number Diff line number Diff line change
@@ -13,14 +13,14 @@ load("@prelude//android:android_resource.bzl", "aapt2_compile")
load("@prelude//android:android_toolchain.bzl", "AndroidToolchainInfo")
load("@prelude//android:r_dot_java.bzl", "generate_r_dot_javas")
load("@prelude//android:voltron.bzl", "ROOT_MODULE", "get_apk_module_graph_info", "is_root_module")
load("@prelude//decls:android_rules.bzl", "RType")
load(
"@prelude//java:java_providers.bzl",
"JavaPackagingDep", # @unused Used as type
)
load("@prelude//utils:expect.bzl", "expect")
load("@prelude//utils:set.bzl", "set_type") # @unused Used as a type
load("@prelude//utils:utils.bzl", "flatten")
load("@prelude//decls/android_rules.bzl", "RType")

_FilteredResourcesOutput = record(
resource_infos = list[AndroidResourceInfo],
@@ -443,7 +443,7 @@ def get_manifest(

android_toolchain = ctx.attrs._android_toolchain[AndroidToolchainInfo]
if ctx.attrs.manifest:
expect(ctx.attrs.manifest_skeleton == None, "Only one of manifest and manifest_skeleton should be declared")
expect(getattr(ctx.attrs, "manifest_skeleton", None) == None, "Only one of manifest and manifest_skeleton should be declared")
if isinstance(ctx.attrs.manifest, Dependency):
android_manifest = ctx.attrs.manifest[DefaultInfo].default_outputs[0]
else:
@@ -465,7 +465,7 @@ def get_manifest(
)

if android_toolchain.set_application_id_to_specified_package and should_replace_application_id_placeholders:
android_manifest_with_replaced_application_id = ctx.actions.declare_output("android_manifest_with_replaced_application_id/AndroidManifest.xml")
android_manifest_with_replaced_application_id = ctx.actions.declare_output("replaced/AndroidManifest.xml")
replace_application_id_placeholders_cmd = cmd_args([
ctx.attrs._android_toolchain[AndroidToolchainInfo].replace_application_id_placeholders[RunInfo],
"--manifest",
2 changes: 1 addition & 1 deletion prelude/android/android_bundle.bzl
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ def build_bundle(
if android_toolchain.package_meta_inf_version_files:
bundle_builder_args.add("--package-meta-inf-version-files")

root_module_asset_directories = native_library_info.root_module_native_lib_assets + dex_files_info.root_module_secondary_dex_dirs
root_module_asset_directories = native_library_info.root_module_native_lib_assets + dex_files_info.root_module_bootstrap_dex_dirs + dex_files_info.root_module_secondary_dex_dirs
root_module_asset_directories_file = argfile(actions = actions, name = "root_module_asset_directories.txt", args = root_module_asset_directories)

non_root_module_asset_directories = resources_info.module_manifests + dex_files_info.non_root_module_secondary_dex_dirs
Loading

0 comments on commit 8ff5530

Please sign in to comment.