Skip to content

Commit

Permalink
chore: vendir sync
Browse files Browse the repository at this point in the history
  • Loading branch information
dolcalmi committed Oct 19, 2024
1 parent f0c5ab2 commit e34795e
Show file tree
Hide file tree
Showing 580 changed files with 27,672 additions and 9,936 deletions.
11 changes: 0 additions & 11 deletions prelude/.buckconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@ prelude = .
# but our custom config format (yuk) doesn't accept inline comments.
# Therefore, we hide the name of the group when not open source.

[not_repositories] # @oss-enable
fbcode = ../..
fbsource = ../../..
ovr_config = ../../../arvr/tools/build_defs/config
bazel_skylib = ../../../third-party/bazel-skylib
fbcode_macros = ../../../tools/build_defs/fbcode_macros
fbobjc_dylibs = ../../../tools/build_defs/fbobjc_dylibs
buck = ../../../xplat/build_infra/buck_client
buck_bazel_skylib = ../../../xplat/build_infra/buck_client/third-party/skylark/bazel-skylib
toolchains = ../toolchains

[repository_aliases]
[not_repository_aliases] # @oss-enable
config = ovr_config
Expand Down
15 changes: 14 additions & 1 deletion prelude/BUCK
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
load("@prelude//utils:source_listing.bzl", "source_listing")
load(":native.bzl", prelude = "native")

oncall("build_infra")

source_listing(exclude = [
# Exclude PACKAGE file using modifiers since those are not enabled everywhere yet.
"PACKAGE",
])

# Done to avoid triggering a lint rule that replaces glob with an fbcode macro
globby = glob

srcs = globby(
["**"],
# Context: https://fb.workplace.com/groups/buck2users/posts/3121903854732641/
exclude = ["**/.pyre_configuration.local"],
exclude = [
"**/.pyre_configuration.local",
# Unfortunately, using modifiers require loading bzl files in outside of prelude,
# and that currently breaks isolated tests that attempt to grab a best-effort prelude
# from the filegroup below.
# TODO: Switch these tests to use the bundled prelude instead.
"PACKAGE",
],
)

# Re-export filegroups that are behind package boundary violations for
Expand Down
6 changes: 6 additions & 0 deletions prelude/abi/BUCK.v2
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
load("@prelude//utils:source_listing.bzl", "source_listing")

oncall("build_infra")

source_listing()

config_setting(
name = "gnu",
constraint_values = [
Expand Down
6 changes: 6 additions & 0 deletions prelude/abi/constraints/BUCK.v2
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
load("@prelude//utils:source_listing.bzl", "source_listing")

oncall("build_infra")

source_listing()

# Used by open source projects to support `prelude//`

constraint_setting(
Expand Down
9 changes: 6 additions & 3 deletions prelude/android/aapt2_link.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_aapt2_link(
no_resource_removal: bool,
should_keep_raw_values: bool,
package_id_offset: int,
resource_stable_ids: [Artifact, None],
resource_stable_ids: Artifact | None,
preferred_density: [str, None],
filter_locales: bool,
locales: list[str],
Expand Down Expand Up @@ -117,8 +117,11 @@ def get_aapt2_link(

aapt2_compile_rules_args_file = ctx.actions.write("{}/aapt2_compile_rules_args_file".format(identifier), cmd_args(aapt2_compile_rules, delimiter = " "))
aapt2_command.add("-R")
aapt2_command.add(cmd_args(aapt2_compile_rules_args_file, format = "@{}"))
aapt2_command.hidden(aapt2_compile_rules)
aapt2_command.add(cmd_args(
aapt2_compile_rules_args_file,
format = "@{}",
hidden = aapt2_compile_rules,
))

aapt2_command.add(additional_aapt2_params)

Expand Down
53 changes: 48 additions & 5 deletions prelude/android/android.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,38 @@ FORCE_SINGLE_CPU = read_root_config("buck2", "android_force_single_cpu") in ("Tr
FORCE_SINGLE_DEFAULT_CPU = read_root_config("buck2", "android_force_single_default_cpu") in ("True", "true")
DISABLE_STRIPPING = read_root_config("android", "disable_stripping") in ("True", "true")

# Format is {"ovveride_name": {"re_cap_key": "re_cap_value"}}; for example:
# {
# "dynamic-listing": {
# "platform": "riot",
# "pool": "EUREKA_POOL",
# },
# "test-execution": {
# "platform": "riot",
# "pool": "EUREKA_POOL",
# },
# }
_RE_CAPS = attrs.option(attrs.dict(key = attrs.string(), value = attrs.dict(key = attrs.string(), value = attrs.string())), default = None)

# Format is {"ovveride_name": "re_use_case"}; for example:
# {
# "dynamic-listing": "riot",
# "test-execution": "riot",
# }
_RE_USE_CASE = attrs.option(attrs.dict(key = attrs.string(), value = attrs.string()), default = None)

extra_attributes = {
"android_aar": {
"abi_generation_mode": attrs.option(attrs.enum(AbiGenerationMode), default = None),
"compress_asset_libraries": attrs.default_only(attrs.bool(default = False)),
"cpu_filters": attrs.list(attrs.enum(TargetCpuType), default = ALL_CPU_FILTERS),
"deps": attrs.list(attrs.split_transition_dep(cfg = cpu_split_transition), default = []),
"javac": attrs.option(attrs.one_of(attrs.exec_dep(), attrs.source()), default = None),
"min_sdk_version": attrs.option(attrs.int(), default = None),
"native_library_merge_glue": attrs.option(attrs.split_transition_dep(cfg = cpu_split_transition), default = None),
"native_library_merge_linker_args": attrs.option(attrs.dict(key = attrs.string(), value = attrs.list(attrs.arg())), default = None),
"package_asset_libraries": attrs.default_only(attrs.bool(default = True)),
"package_asset_libraries": attrs.bool(default = True),
"package_resources": attrs.bool(default = True),
"relinker_extra_deps": attrs.list(attrs.split_transition_dep(cfg = cpu_split_transition), default = []),
"resources_root": attrs.option(attrs.string(), default = None),
"strip_libraries": attrs.default_only(attrs.bool(default = not DISABLE_STRIPPING)),
"_android_toolchain": toolchains_common.android(),
Expand All @@ -83,6 +104,7 @@ extra_attributes = {
},
"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_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 = []),
Expand All @@ -96,6 +118,7 @@ extra_attributes = {
"native_library_merge_code_generator": attrs.option(attrs.exec_dep(), default = None),
"native_library_merge_glue": attrs.option(attrs.split_transition_dep(cfg = cpu_split_transition), default = None),
"native_library_merge_linker_args": attrs.option(attrs.dict(key = attrs.string(), value = attrs.list(attrs.arg())), default = None),
"relinker_extra_deps": attrs.list(attrs.split_transition_dep(cfg = cpu_split_transition), default = []),
"strip_libraries": attrs.bool(default = not DISABLE_STRIPPING),
"_android_toolchain": toolchains_common.android(),
"_cxx_toolchain": attrs.split_transition_dep(cfg = cpu_split_transition, default = "toolchains//:android-hack"),
Expand All @@ -115,6 +138,7 @@ extra_attributes = {
},
"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_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 = []),
Expand All @@ -127,6 +151,8 @@ extra_attributes = {
"native_library_merge_code_generator": attrs.option(attrs.exec_dep(), default = None),
"native_library_merge_glue": attrs.option(attrs.split_transition_dep(cfg = cpu_split_transition), default = None),
"native_library_merge_linker_args": attrs.option(attrs.dict(key = attrs.string(), value = attrs.list(attrs.arg())), default = None),
"relinker_extra_deps": attrs.list(attrs.split_transition_dep(cfg = cpu_split_transition), default = []),
"use_derived_apk": attrs.bool(default = False),
"_android_toolchain": toolchains_common.android(),
"_cxx_toolchain": attrs.split_transition_dep(cfg = cpu_split_transition, default = "toolchains//:android-hack"),
"_dex_toolchain": toolchains_common.dex(),
Expand All @@ -151,24 +177,35 @@ extra_attributes = {
"native_library_merge_sequence": attrs.option(attrs.list(attrs.any()), default = None),
"_android_toolchain": toolchains_common.android(),
"_dex_toolchain": toolchains_common.dex(),
"_exec_os_type": buck.exec_os_type_arg(),
"_is_building_android_binary": attrs.default_only(attrs.bool(default = True)),
"_is_force_single_cpu": attrs.default_only(attrs.bool(default = FORCE_SINGLE_CPU)),
"_is_force_single_default_cpu": attrs.default_only(attrs.bool(default = FORCE_SINGLE_DEFAULT_CPU)),
"_java_toolchain": toolchains_common.java_for_android(),
},
"android_instrumentation_test": {
"instrumentation_test_listener": attrs.option(attrs.source(), default = None),
"extra_instrumentation_args": attrs.option(attrs.dict(key = attrs.string(), value = attrs.arg()), default = None),
"instrumentation_test_listener": attrs.option(attrs.exec_dep(), default = None),
"instrumentation_test_listener_class": attrs.option(attrs.string(), default = None),
"is_self_instrumenting": attrs.bool(default = False),
"re_caps": _RE_CAPS,
"re_use_case": _RE_USE_CASE,
"_android_toolchain": toolchains_common.android(),
"_exec_os_type": buck.exec_os_type_arg(),
"_java_test_toolchain": toolchains_common.java_for_host_test(),
"_java_toolchain": toolchains_common.java_for_android(),
},
"android_library": {
"abi_generation_mode": attrs.option(attrs.enum(AbiGenerationMode), default = None),
"javac": attrs.option(attrs.one_of(attrs.exec_dep(), attrs.source()), default = None),
"android_optional_jars": attrs.option(attrs.list(attrs.source()), default = None),
"resources_root": attrs.option(attrs.string(), default = None),
VALIDATION_DEPS_ATTR_NAME: attrs.set(attrs.dep(), sorted = True, default = []),
"_android_toolchain": toolchains_common.android(),
"_build_only_native_code": attrs.default_only(attrs.bool(default = is_build_only_native_code())),
"_compose_stability_config": attrs.option(attrs.source(), default = select({
"DEFAULT": None,
"fbsource//tools/build_defs/android/compose:enable-compose-stability-config": "fbsource//tools/build_defs/android/compose:stability_config",
})),
"_dex_min_sdk_version": attrs.default_only(attrs.option(attrs.int(), default = dex_min_sdk_version())),
"_dex_toolchain": toolchains_common.dex(),
"_exec_os_type": buck.exec_os_type_arg(),
Expand Down Expand Up @@ -198,11 +235,16 @@ extra_attributes = {
"res": attrs.option(attrs.one_of(attrs.source(allow_directory = True), attrs.dict(key = attrs.string(), value = attrs.source(), sorted = True)), default = None),
"_android_toolchain": toolchains_common.android(),
"_build_only_native_code": attrs.default_only(attrs.bool(default = is_build_only_native_code())),
"_java_toolchain": toolchains_common.java_for_android(),
},
"apk_genrule": genrule_attributes() | {
"default_outs": attrs.option(attrs.set(attrs.string(), sorted = False), default = None),
"outs": attrs.option(attrs.dict(key = attrs.string(), value = attrs.set(attrs.string(), sorted = False), sorted = False), default = None),
"type": attrs.string(default = "apk"),
"use_derived_apk": attrs.bool(default = False),
"_android_toolchain": toolchains_common.android(),
"_exec_os_type": buck.exec_os_type_arg(),
"_java_toolchain": toolchains_common.java_for_android(),
},
"gen_aidl": {
"import_paths": attrs.list(attrs.arg(), default = []),
Expand All @@ -215,7 +257,8 @@ extra_attributes = {
},
"robolectric_test": {
"abi_generation_mode": attrs.option(attrs.enum(AbiGenerationMode), default = None),
"javac": attrs.option(attrs.one_of(attrs.exec_dep(), attrs.source()), default = None),
"android_optional_jars": attrs.option(attrs.list(attrs.source()), default = None),
"java_agents": attrs.list(attrs.source(), default = []),
"resources_root": attrs.option(attrs.string(), default = None),
"robolectric_runtime_dependencies": attrs.list(attrs.source(), default = []),
"test_class_names_file": attrs.option(attrs.source(), default = None),
Expand Down
84 changes: 60 additions & 24 deletions prelude/android/android_aar.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ load("@prelude//android:android_toolchain.bzl", "AndroidToolchainInfo")
load("@prelude//android:configuration.bzl", "get_deps_by_platform")
load("@prelude//android:cpu_filters.bzl", "CPU_FILTER_FOR_DEFAULT_PLATFORM", "CPU_FILTER_FOR_PRIMARY_PLATFORM")
load("@prelude//android:util.bzl", "create_enhancement_context")
load("@prelude//java:java_providers.bzl", "get_all_java_packaging_deps", "get_all_java_packaging_deps_from_packaging_infos")
load("@prelude//java:java_providers.bzl", "create_java_packaging_dep", "get_all_java_packaging_deps", "get_all_java_packaging_deps_from_packaging_infos")
load("@prelude//java:java_toolchain.bzl", "JavaToolchainInfo")
load("@prelude//utils:argfile.bzl", "argfile")
load("@prelude//utils:set.bzl", "set")

def android_aar_impl(ctx: AnalysisContext) -> list[Provider]:
Expand All @@ -37,16 +38,23 @@ def android_aar_impl(ctx: AnalysisContext) -> list[Provider]:
get_build_config_java_libraries(ctx, build_config_infos, package_type = "release", exopackage_modes = []),
))

enhancement_ctx = create_enhancement_context(ctx)
android_binary_native_library_info = get_android_binary_native_library_info(enhancement_ctx, android_packageable_info, deps_by_platform)
java_packaging_deps.extend([create_java_packaging_dep(
ctx,
lib.library_output.full_library,
) for lib in android_binary_native_library_info.generated_java_code])

jars = [dep.jar for dep in java_packaging_deps if dep.jar]
classes_jar = ctx.actions.declare_output("classes.jar")
java_toolchain = ctx.attrs._java_toolchain[JavaToolchainInfo]
classes_jar_cmd = cmd_args([
java_toolchain.jar_builder,
"--entries-to-jar",
ctx.actions.write("classes_jar_entries.txt", jars),
argfile(actions = ctx.actions, name = "classes_jar_entries.txt", args = jars),
"--output",
classes_jar.as_output(),
]).hidden(jars)
])

if ctx.attrs.remove_classes:
remove_classes_file = ctx.actions.write("remove_classes.txt", ctx.attrs.remove_classes)
Expand All @@ -59,22 +67,47 @@ def android_aar_impl(ctx: AnalysisContext) -> list[Provider]:

ctx.actions.run(classes_jar_cmd, category = "create_classes_jar")

sub_targets = {}
dependency_sources_jars = [dep.sources_jar for dep in java_packaging_deps if dep.sources_jar]
if dependency_sources_jars:
combined_sources_jar = ctx.actions.declare_output("sources.jar")
java_toolchain = ctx.attrs._java_toolchain[JavaToolchainInfo]
combined_sources_jar_cmd = cmd_args([
java_toolchain.jar_builder,
"--entries-to-jar",
argfile(actions = ctx.actions, name = "combined_sources_jar_entries.txt", args = dependency_sources_jars),
"--output",
combined_sources_jar.as_output(),
])

if ctx.attrs.remove_classes:
remove_classes_file = ctx.actions.write("sources_remove_classes.txt", ctx.attrs.remove_classes)
combined_sources_jar_cmd.add([
"--blocklist-patterns",
remove_classes_file,
"--blocklist-patterns-matcher",
"remove_classes_patterns_matcher",
])

ctx.actions.run(combined_sources_jar_cmd, category = "create_sources_jar")
sub_targets["sources.jar"] = [DefaultInfo(default_output = combined_sources_jar)]

entries = [android_manifest, classes_jar]

resource_infos = list(android_packageable_info.resource_infos.traverse()) if android_packageable_info.resource_infos else []

android_toolchain = ctx.attrs._android_toolchain[AndroidToolchainInfo]
if resource_infos:
res_dirs = [resource_info.res for resource_info in resource_infos if resource_info.res]
if res_dirs:
if ctx.attrs.package_resources and res_dirs:
merged_resource_sources_dir = ctx.actions.declare_output("merged_resource_sources_dir/res", dir = True)
merge_resource_sources_cmd = cmd_args([
android_toolchain.merge_android_resource_sources[RunInfo],
"--resource-paths",
ctx.actions.write("resource_paths.txt", res_dirs),
argfile(actions = ctx.actions, name = "resource_paths.txt", args = res_dirs),
"--output",
merged_resource_sources_dir.as_output(),
]).hidden(res_dirs)
])

ctx.actions.run(merge_resource_sources_cmd, category = "merge_android_resource_sources")

Expand All @@ -88,28 +121,31 @@ def android_aar_impl(ctx: AnalysisContext) -> list[Provider]:
if cxx_resources:
entries.append(cxx_resources)

enhancement_ctx = create_enhancement_context(ctx)
android_binary_native_library_info = get_android_binary_native_library_info(enhancement_ctx, android_packageable_info, deps_by_platform)
native_libs_file = ctx.actions.write("native_libs_entries.txt", android_binary_native_library_info.native_libs_for_primary_apk)
native_libs_assets_file = ctx.actions.write("native_libs_assets_entries.txt", android_binary_native_library_info.root_module_native_lib_assets)
native_libs_file = argfile(actions = ctx.actions, name = "native_libs_entries.txt", args = android_binary_native_library_info.native_libs_for_primary_apk)
native_libs_assets_file = argfile(actions = ctx.actions, name = "native_libs_assets_entries.txt", args = android_binary_native_library_info.root_module_native_lib_assets)

entries_file = ctx.actions.write("entries.txt", entries)

aar = ctx.actions.declare_output("{}.aar".format(ctx.label.name))
create_aar_cmd = cmd_args([
android_toolchain.aar_builder,
"--output_path",
aar.as_output(),
"--entries_file",
entries_file,
"--on_duplicate_entry",
"fail",
"--native_libs_file",
native_libs_file,
"--native_libs_assets_file",
native_libs_assets_file,
]).hidden(entries, android_binary_native_library_info.native_libs_for_primary_apk, android_binary_native_library_info.root_module_native_lib_assets)
create_aar_cmd = cmd_args(
[
android_toolchain.aar_builder,
"--output_path",
aar.as_output(),
"--entries_file",
entries_file,
"--on_duplicate_entry",
"fail",
"--native_libs_file",
native_libs_file,
"--native_libs_assets_file",
native_libs_assets_file,
],
hidden = [
entries,
],
)

ctx.actions.run(create_aar_cmd, category = "create_aar")

return [DefaultInfo(default_outputs = [aar], sub_targets = enhancement_ctx.get_sub_targets())]
return [DefaultInfo(default_outputs = [aar], sub_targets = enhancement_ctx.get_sub_targets() | sub_targets)]
Loading

0 comments on commit e34795e

Please sign in to comment.