├── cxx ├── dist_lto │ ├── tools │ │ ├── __init__.py │ │ ├── dist_lto_copy.py │ │ └── BUCK.v2 │ └── tools.bzl ├── gcno.bzl ├── tools │ ├── defs.bzl │ └── BUCK.v2 ├── platform.bzl ├── debug.bzl ├── cxx_toolchain_macro_layer.bzl ├── cxx_utility.bzl └── target_sdk_version.bzl ├── erlang ├── toolchain │ ├── erlang_ls.config │ ├── erlc_trampoline.sh │ ├── escript_trampoline.sh │ ├── BUCK.v2 │ └── include_erts.escript ├── common_test │ ├── .elp.toml │ ├── common │ │ ├── include │ │ │ ├── artifact_annotations.hrl │ │ │ └── tpx_records.hrl │ │ ├── BUCK.v2 │ │ └── src │ │ │ ├── buck_ct_parser.erl │ │ │ └── bounded_buffer.erl │ ├── test_exec │ │ ├── src │ │ │ ├── test_exec.app.src │ │ │ └── test_exec.erl │ │ ├── BUCK.v2 │ │ └── test │ │ │ └── ct_executor_SUITE.erl │ ├── test_cli_lib │ │ ├── test │ │ │ ├── test_cli_e2e_SUITE_data │ │ │ │ └── test_list_SUITE.erl │ │ │ └── test_cli_e2e_SUITE.erl │ │ └── BUCK.v2 │ ├── cth_hooks │ │ ├── BUCK.v2 │ │ └── src │ │ │ └── method_ids.hrl │ └── test_binary │ │ └── BUCK.v2 ├── applications │ └── BUCK.v2 ├── shell │ ├── BUCK.v2 │ └── shell.bxl └── erlang_ls.config ├── CHANGELOG.md ├── apple ├── tools │ ├── bundling │ │ ├── test_resources │ │ │ ├── the.broken_json │ │ │ ├── newer_version_action_metadata.json │ │ │ ├── newer_version_incremental_state.json │ │ │ ├── valid_action_metadata.json │ │ │ └── valid_incremental_state.json │ │ └── BUCK.v2 │ ├── selective_debugging │ │ ├── test_resources │ │ │ ├── focused_targets_empty.json │ │ │ ├── focused_targets.json │ │ │ ├── HelloWorld │ │ │ └── focused_spec.json │ │ ├── utils.py │ │ └── BUCK.v2 │ ├── re_compatibility_utils │ │ ├── BUCK │ │ └── writable.py │ ├── code_signing │ │ ├── dummy_binary_for_signing.c │ │ ├── test_resources │ │ │ └── Entitlements.plist │ │ ├── info_plist_metadata.py │ │ ├── read_provisioning_profile_command_factory.py │ │ ├── identity.py │ │ └── BUCK.v2 │ ├── resource_broker │ │ ├── timeouts.py │ │ ├── idb_companion.py │ │ ├── BUCK.v2 │ │ ├── idb_target.py │ │ └── macos.py │ ├── info_plist_processor │ │ └── BUCK.v2 │ ├── defs.bzl │ └── plistlib_utils.py ├── apple_platforms.bzl ├── scene_kit_assets_types.bzl ├── apple_core_data_types.bzl ├── swift │ ├── swift_types.bzl │ ├── swift_module_map.bzl │ ├── swift_toolchain_macro_layer.bzl │ └── swift_pcm_compilation_types.bzl ├── user │ └── apple_selected_debug_path_file.bzl ├── apple_swift_stdlib.bzl ├── apple_bundle_attrs.bzl ├── apple_dsym_config.bzl ├── apple_package_config.bzl ├── apple_sdk.bzl ├── apple_stripping.bzl ├── apple_modular_utility.bzl ├── apple_resource_utility.bzl ├── apple_code_signing_types.bzl ├── versions.bzl ├── apple_resource_dedupe_alias.bzl ├── apple_asset_catalog_compilation_options.bzl ├── apple_asset_catalog_types.bzl ├── mockingbird │ └── mockingbird_types.bzl └── apple_resource_types.bzl ├── .gitignore ├── haskell ├── ide │ ├── hie.yaml │ └── README.md ├── tools │ └── BUCK.v2 ├── haskell_ide.bzl └── link_info.bzl ├── toolchains ├── apple │ └── xcode_version_checker │ │ ├── .gitignore │ │ ├── xcode_version_checker │ │ ├── BUCK.v2 │ │ ├── README │ │ ├── test │ │ └── Xcode_14.2.0_14C18_fb_version.plist │ │ ├── src │ │ ├── xcode_exec_tester.m │ │ └── xcode_version_checks.h │ │ └── Makefile ├── cxx │ └── clang │ │ ├── BUCK │ │ └── tools.bzl ├── execution_host.bzl ├── msvc │ ├── BUCK.v2 │ └── run_msvc_tool.py ├── genrule.bzl ├── haskell.bzl ├── remote_test_execution.bzl └── conan │ └── BUCK ├── third-party ├── hmaptool │ ├── METADATA.bzl │ ├── BUCK.v2 │ └── README.md └── tools │ ├── BUCK.v2 │ └── create_build.py ├── zip_file ├── tools │ └── BUCK.v2 └── zip_file_toolchain.bzl ├── python ├── runtime │ └── BUCK.v2 ├── tools │ ├── sourcedb_merger │ │ ├── tests │ │ │ └── main.sh │ │ ├── BUCK.v2 │ │ ├── legacy_merge.py │ │ └── merge.py │ ├── fail_with_message.py │ ├── make_par │ │ └── BUCK │ └── make_source_db_no_deps.py ├── typecheck │ ├── batch_files.bxl │ └── batch.bxl └── sourcedb │ └── merge.bxl ├── runtime └── BUCK.v2 ├── git └── tools │ └── BUCK.v2 ├── julia ├── tools │ └── BUCK.v2 ├── julia_toolchain.bzl └── julia_test.bzl ├── test └── tools │ ├── BUCK.v2 │ └── inject_test_env.py ├── is_buck2_internal.bzl ├── python_bootstrap └── tools │ ├── BUCK.v2 │ └── win_python_wrapper.bat ├── pull_request_template.md ├── attributes.bzl ├── matlab ├── matlab_info.bzl ├── matlab_toolchain.bzl ├── matlab.bzl └── matlab_program.bzl ├── .buckconfig ├── csharp └── toolchain.bzl ├── lua ├── lua_binary.bzl ├── lua_library.bzl └── cxx_lua_extension.bzl ├── windows └── tools │ ├── BUCK.v2 │ └── msvc_hermetic_exec.bat ├── is_buck2.bzl ├── is_full_meta_repo.bzl ├── platforms ├── apple │ ├── arch.bzl │ ├── sdk.bzl │ └── platforms_map.bzl └── BUCK ├── http_archive ├── tools │ ├── BUCK.v2 │ └── create_exclusion_list.py └── exec_deps.bzl ├── playground └── test.bxl ├── cache_mode.bzl ├── android ├── tools │ └── com │ │ └── facebook │ │ └── buck_generated │ │ └── AppWithoutResourcesStub.java ├── build_only_native_code.bzl ├── min_sdk_version.bzl ├── cpu_filters.bzl ├── exopackage.bzl ├── constraints │ └── BUCK.v2 ├── util.bzl ├── bundletool_util.bzl └── prebuilt_native_library.bzl ├── docs └── rules.bzl ├── genrule_toolchain.bzl ├── os_lookup ├── targets │ └── BUCK.v2 └── defs.bzl ├── prelude.bzl ├── kotlin ├── tools │ ├── compile_kotlin │ │ └── BUCK.v2 │ └── kapt_base64_encoder │ │ └── BUCK.v2 ├── kotlin_utils.bzl └── kotlin_test.bzl ├── utils ├── source_listing.bzl ├── strings.bzl ├── arglike.bzl ├── host.bzl ├── platform_flavors_util.bzl ├── pick.bzl ├── dicts.bzl └── selects.bzl ├── rust ├── with_workspace.bzl ├── rust_common.bzl ├── resources.bzl ├── tools │ ├── attrs.bzl │ ├── BUCK.v2 │ └── tool_rules.bzl ├── rust-analyzer │ └── check.bxl ├── targets.bzl └── named_deps.bzl ├── abi ├── BUCK.v2 └── constraints │ └── BUCK.v2 ├── linking └── types.bzl ├── tests └── remote_test_execution_toolchain.bzl ├── java ├── dex_toolchain.bzl ├── utils │ └── java_more_utils.bzl ├── keystore.bzl └── jar_genrule.bzl ├── user └── rule_spec.bzl ├── tools └── audit_providers_universe.bxl ├── README.md ├── debugging ├── ensure_dwp.bzl ├── common.bzl ├── inspect_default.bzl └── inspect_java.bzl ├── validation_deps.bzl ├── go ├── transitions │ └── tags_helper.bzl ├── constraints │ └── defs.bzl └── tools │ ├── BUCK.v2 │ ├── concat_files.py │ ├── gen_stdlib_importcfg.py │ └── cgo_wrapper.py ├── export_file.bzl ├── cpu ├── BUCK.v2 └── constraints │ └── BUCK.v2 ├── BUCK ├── buck2_compatibility.bzl ├── test_suite.bzl ├── LICENSE-MIT ├── configurations └── util.bzl ├── alias.bzl ├── decls ├── lua_common.bzl ├── d_common.bzl └── git_rules.bzl └── ide_integrations └── xcode.bzl /cxx/dist_lto/tools/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /erlang/toolchain/erlang_ls.config: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Buck2 Prelude 2 | 3 | - Initial version. 4 | -------------------------------------------------------------------------------- /apple/tools/bundling/test_resources/the.broken_json: -------------------------------------------------------------------------------- 1 | { 2 | "version": -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Top-level files and directories used by buck. 2 | /buck-out 3 | /.lsp-buck-out 4 | -------------------------------------------------------------------------------- /apple/tools/selective_debugging/test_resources/focused_targets_empty.json: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | ] 4 | } -------------------------------------------------------------------------------- /erlang/common_test/.elp.toml: -------------------------------------------------------------------------------- 1 | [buck] 2 | build_deps = false 3 | enabled = true 4 | included_targets = ["//erlang/common_test/..."] 5 | -------------------------------------------------------------------------------- /apple/tools/bundling/test_resources/newer_version_action_metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "data": { 4 | "something": [] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /apple/tools/bundling/test_resources/newer_version_incremental_state.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 7, 3 | "data": { 4 | "something": [] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /haskell/ide/hie.yaml: -------------------------------------------------------------------------------- 1 | cradle: 2 | bios: 3 | shell: buck2 bxl prelude//haskell/ide/ide.bxl --bios true --file $HIE_BIOS_ARG > $HIE_BIOS_OUTPUT 4 | -------------------------------------------------------------------------------- /toolchains/apple/xcode_version_checker/.gitignore: -------------------------------------------------------------------------------- 1 | xcode_version_checker.arm64 2 | xcode_version_checker.x86_64 3 | xcode_version_tester 4 | xcode_exec_tester 5 | -------------------------------------------------------------------------------- /apple/tools/selective_debugging/test_resources/focused_targets.json: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | "//fbobjc/buck2/samples/focused_debugging:Foo" 4 | ] 5 | } -------------------------------------------------------------------------------- /apple/tools/selective_debugging/test_resources/HelloWorld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/buck2-prelude/main/apple/tools/selective_debugging/test_resources/HelloWorld -------------------------------------------------------------------------------- /toolchains/apple/xcode_version_checker/xcode_version_checker: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elastic/buck2-prelude/main/toolchains/apple/xcode_version_checker/xcode_version_checker -------------------------------------------------------------------------------- /third-party/hmaptool/METADATA.bzl: -------------------------------------------------------------------------------- 1 | METADATA = { 2 | "maintainers": [ 3 | "build_infra", 4 | ], 5 | "name": "hmaptool", 6 | "owner": "build_infra", 7 | } 8 | -------------------------------------------------------------------------------- /erlang/applications/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//erlang:erlang_otp_application.bzl", "gen_otp_applications") 2 | load("@prelude//utils:source_listing.bzl", "source_listing") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | gen_otp_applications() 9 | -------------------------------------------------------------------------------- /zip_file/tools/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | python_bootstrap_binary( 8 | name = "unzip", 9 | main = "unzip.py", 10 | visibility = ["PUBLIC"], 11 | ) 12 | -------------------------------------------------------------------------------- /python/runtime/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | filegroup( 8 | name = "bootstrap_files", 9 | srcs = glob(["__par__/**/*.py"]), 10 | visibility = ["PUBLIC"], 11 | ) 12 | -------------------------------------------------------------------------------- /runtime/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | # Used by open source projects to support `prelude//` 8 | 9 | config_setting( 10 | name = "fbcode", 11 | visibility = ["PUBLIC"], 12 | ) 13 | -------------------------------------------------------------------------------- /third-party/tools/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | source_listing() 4 | 5 | prelude = native 6 | 7 | prelude.python_bootstrap_binary( 8 | name = "create_build", 9 | main = "create_build.py", 10 | visibility = ["PUBLIC"], 11 | ) 12 | -------------------------------------------------------------------------------- /toolchains/cxx/clang/BUCK: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | load(":tools.bzl", "path_clang_tools") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | path_clang_tools( 9 | name = "path_clang_tools", 10 | visibility = ["PUBLIC"], 11 | ) 12 | -------------------------------------------------------------------------------- /apple/tools/bundling/test_resources/valid_action_metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "digests": [ 4 | { 5 | "path": "repo/foo.txt", 6 | "digest": "foo_digest" 7 | }, 8 | { 9 | "path": "buck-out/bar.txt", 10 | "digest": "bar_digest" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /apple/tools/selective_debugging/test_resources/focused_spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "include_build_target_patterns": [ 3 | "//fbobjc/buck2/samples/focused_debugging:Foo" 4 | ], 5 | "include_regular_expressions": [], 6 | "exclude_build_target_patterns": [], 7 | "exclude_regular_expressions": [] 8 | } 9 | -------------------------------------------------------------------------------- /git/tools/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | prelude = native 8 | 9 | prelude.python_bootstrap_binary( 10 | name = "git_fetch", 11 | main = "git_fetch.py", 12 | visibility = ["PUBLIC"], 13 | ) 14 | -------------------------------------------------------------------------------- /julia/tools/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | prelude = native 8 | 9 | prelude.python_bootstrap_binary( 10 | name = "parse_julia_cmd", 11 | main = "parse_julia_cmd.py", 12 | visibility = ["PUBLIC"], 13 | ) 14 | -------------------------------------------------------------------------------- /test/tools/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | prelude = native 8 | 9 | prelude.python_bootstrap_binary( 10 | name = "inject_test_env", 11 | main = "inject_test_env.py", 12 | visibility = ["PUBLIC"], 13 | ) 14 | -------------------------------------------------------------------------------- /toolchains/apple/xcode_version_checker/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | export_file( 8 | name = "xcode_version_checker", 9 | labels = ["buck2-only"], 10 | mode = "reference", 11 | visibility = ["PUBLIC"], 12 | ) 13 | -------------------------------------------------------------------------------- /haskell/tools/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | prelude = native 8 | 9 | prelude.python_bootstrap_binary( 10 | name = "script_template_processor", 11 | main = "script_template_processor.py", 12 | visibility = ["PUBLIC"], 13 | ) 14 | -------------------------------------------------------------------------------- /is_buck2_internal.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | yes = True 9 | -------------------------------------------------------------------------------- /apple/tools/re_compatibility_utils/BUCK: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | prelude = native 8 | 9 | prelude.python_library( 10 | name = "re_compatibility_utils", 11 | srcs = [ 12 | "writable.py", 13 | ], 14 | visibility = ["PUBLIC"], 15 | ) 16 | -------------------------------------------------------------------------------- /python_bootstrap/tools/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | prelude = native 8 | 9 | prelude.sh_binary( 10 | name = "win_python_wrapper", 11 | main = "win_python_wrapper.bat", 12 | target_compatible_with = ["config//os:windows"], 13 | visibility = ["PUBLIC"], 14 | ) 15 | -------------------------------------------------------------------------------- /apple/apple_platforms.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | APPLE_PLATFORMS_KEY = "_apple_platforms" 9 | -------------------------------------------------------------------------------- /pull_request_template.md: -------------------------------------------------------------------------------- 1 | IMPORTANT: Please don't raise pull requests here, but at 2 | [facebook/buck2](https://github.com/facebook/buck2/pulls). 3 | 4 | The [`prelude`](https://github.com/facebook/buck2/tree/main/prelude) directory 5 | is a mirror of this repo, but that repo also features CI tests and is more 6 | actively monitored. Any PR's landing there will automatically show up here at 7 | the same time. 8 | -------------------------------------------------------------------------------- /attributes.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # The specs you are looking for have moved into the prelude/decls directory 9 | -------------------------------------------------------------------------------- /erlang/toolchain/erlc_trampoline.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under both the MIT license found in the 5 | # LICENSE-MIT file in the root directory of this source tree and the Apache 6 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | # of this source tree. 8 | 9 | set -eu 10 | 11 | $1 "${@:2}" 1>&2 12 | -------------------------------------------------------------------------------- /apple/scene_kit_assets_types.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | SceneKitAssetsSpec = record( 9 | path = field(Artifact), 10 | ) 11 | -------------------------------------------------------------------------------- /matlab/matlab_info.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | MatlabToolchainInfo = provider(fields = { 9 | "matlab_exe": RunInfo, 10 | }) 11 | -------------------------------------------------------------------------------- /.buckconfig: -------------------------------------------------------------------------------- 1 | [repositories] 2 | prelude = . 3 | 4 | # We want to disable the following values when we don't have open source, 5 | # but our custom config format (yuk) doesn't accept inline comments. 6 | # Therefore, we hide the name of the group when not open source. 7 | 8 | [repository_aliases] 9 | [not_repository_aliases] # @oss-enable 10 | config = ovr_config 11 | 12 | [buildfile] 13 | [not_buildfile] # @oss-enable 14 | name = TARGETS 15 | -------------------------------------------------------------------------------- /apple/tools/code_signing/dummy_binary_for_signing.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | int main() { 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /csharp/toolchain.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | CSharpToolchainInfo = provider(fields = [ 9 | "csc", 10 | "framework_dirs", 11 | ]) 12 | -------------------------------------------------------------------------------- /lua/lua_binary.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def lua_binary_impl(_ctx: AnalysisContext) -> list[Provider]: 9 | return [DefaultInfo()] 10 | -------------------------------------------------------------------------------- /windows/tools/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | prelude = native 8 | 9 | prelude.export_file( 10 | name = "msvc_hermetic_exec.bat", 11 | src = "msvc_hermetic_exec.bat", 12 | ) 13 | 14 | prelude.command_alias( 15 | name = "msvc_hermetic_exec", 16 | exe = ":msvc_hermetic_exec.bat", 17 | visibility = ["PUBLIC"], 18 | ) 19 | -------------------------------------------------------------------------------- /apple/tools/selective_debugging/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # pyre-strict 9 | 10 | 11 | class MachOException(Exception): 12 | pass 13 | -------------------------------------------------------------------------------- /haskell/haskell_ide.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def haskell_ide_impl(_ctx: AnalysisContext) -> list[Provider]: 9 | return [DefaultInfo()] 10 | -------------------------------------------------------------------------------- /lua/lua_library.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def lua_library_impl(_ctx: AnalysisContext) -> list[Provider]: 9 | return [DefaultInfo()] 10 | -------------------------------------------------------------------------------- /is_buck2.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//:is_buck2_internal.bzl?v2_only", "yes") 9 | 10 | def is_buck2(): 11 | return yes == True 12 | -------------------------------------------------------------------------------- /erlang/common_test/common/include/artifact_annotations.hrl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) Meta Platforms, Inc. and affiliates. 2 | %% 3 | %% This source code is licensed under both the MIT license found in the 4 | %% LICENSE-MIT file in the root directory of this source tree and the Apache 5 | %% License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | %% of this source tree. 7 | 8 | -define(GENERIC_BLOB, 1). 9 | -define(GENERIC_TEXT_LOG, 2). 10 | -------------------------------------------------------------------------------- /erlang/toolchain/escript_trampoline.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under both the MIT license found in the 5 | # LICENSE-MIT file in the root directory of this source tree and the Apache 6 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | # of this source tree. 8 | 9 | cmd=("$2" "$1/run.escript" "${@:3}") 10 | 11 | "${cmd[@]}" 12 | -------------------------------------------------------------------------------- /lua/cxx_lua_extension.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def cxx_lua_extension_impl(_ctx: AnalysisContext) -> list[Provider]: 9 | return [DefaultInfo()] 10 | -------------------------------------------------------------------------------- /is_full_meta_repo.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def is_full_meta_repo() -> bool: 9 | return read_root_config("buck2", "is_full_meta_repo", None) == "true" 10 | -------------------------------------------------------------------------------- /third-party/hmaptool/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | prelude = native # Avoid warnings and auto-formatters 8 | 9 | prelude.export_file( 10 | name = "_hmaptool", 11 | src = "hmaptool", 12 | mode = "reference", 13 | ) 14 | 15 | prelude.command_alias( 16 | name = "hmaptool", 17 | exe = ":_hmaptool", 18 | visibility = ["PUBLIC"], 19 | ) 20 | -------------------------------------------------------------------------------- /apple/apple_core_data_types.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | AppleCoreDataSpec = record( 9 | module = field(str | None), 10 | path = field(Artifact), 11 | ) 12 | -------------------------------------------------------------------------------- /apple/tools/code_signing/test_resources/Entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | application-identifier 6 | ABCDE12345.com.example.TestApp 7 | keychain-access-groups 8 | 9 | ABCDE12345.com.example.TestApp 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /platforms/apple/arch.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | _APPLE_ARCHES = [ 9 | "arm64", 10 | "arm64_32", 11 | "x86_64", 12 | ] 13 | 14 | AppleArch = enum(*_APPLE_ARCHES) 15 | -------------------------------------------------------------------------------- /toolchains/apple/xcode_version_checker/README: -------------------------------------------------------------------------------- 1 | - Run `make` to compile the `xcode_version_checker` binary. 2 | - Run `make all` to compile the `xcode_version_checker` binary and run all tests. 3 | - Run `make test` to just run tests. 4 | - Run `make clean` to delete tests and intermediate binaries. 5 | 6 | We cannot include this as part of the toolchain because of 7 | bootstrapping issues: i.e., compiling it requires an 8 | `apple_toolchain` but its needed to define an `apple_toolchain`. 9 | -------------------------------------------------------------------------------- /http_archive/tools/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | load("@prelude//http_archive/exec_deps.bzl", "http_archive_exec_deps") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | prelude = native 9 | 10 | http_archive_exec_deps( 11 | name = "exec_deps", 12 | visibility = ["PUBLIC"], 13 | ) 14 | 15 | prelude.python_bootstrap_binary( 16 | name = "create_exclusion_list", 17 | main = "create_exclusion_list.py", 18 | ) 19 | -------------------------------------------------------------------------------- /playground/test.bxl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def _impl(ctx): 9 | ctx.output.print("123") 10 | 11 | playground = bxl_main( 12 | impl = _impl, 13 | cli_args = {}, 14 | ) 15 | -------------------------------------------------------------------------------- /windows/tools/msvc_hermetic_exec.bat: -------------------------------------------------------------------------------- 1 | @REM Copyright (c) Meta Platforms, Inc. and affiliates. 2 | @REM 3 | @REM This source code is licensed under both the MIT license found in the 4 | @REM LICENSE-MIT file in the root directory of this source tree and the Apache 5 | @REM License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | @REM of this source tree. 7 | 8 | @echo off 9 | %* "/d1trimfile:%cd%\" "/d2trimfile:%cd%\" "/experimental:deterministic" "/pathmap:%cd%\=" 10 | -------------------------------------------------------------------------------- /apple/swift/swift_types.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | SWIFT_EXTENSION = ".swift" 9 | 10 | SWIFTMODULE_EXTENSION = ".swiftmodule" 11 | 12 | SwiftCompilationModes = ["wmo", "incremental", "auto"] 13 | -------------------------------------------------------------------------------- /cache_mode.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | CacheModeInfo = provider(fields = {"allow_cache_uploads": provider_field(typing.Any, default = None), "cache_bust_genrules": provider_field(typing.Any, default = None)}) 9 | -------------------------------------------------------------------------------- /android/tools/com/facebook/buck_generated/AppWithoutResourcesStub.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | package com.facebook.buck_generated; 11 | 12 | final class AppWithoutResourcesStub {} 13 | -------------------------------------------------------------------------------- /cxx/gcno.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # Provider that exposes the .gcno files produced during compilation 9 | GcnoFilesInfo = provider(fields = { 10 | "gcno_files": provider_field(list[Artifact]), 11 | }) 12 | -------------------------------------------------------------------------------- /docs/rules.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # We only want to document the rules in the prelude, so have a module that 9 | # only reexports those. 10 | 11 | load("@prelude//:rules.bzl", _rules = "rules") 12 | 13 | load_symbols(_rules) 14 | -------------------------------------------------------------------------------- /genrule_toolchain.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | GenruleToolchainInfo = provider( 9 | doc = "Genrule toolchain info", 10 | fields = { 11 | "zip_scrubber": provider_field(typing.Any, default = None), 12 | }, 13 | ) 14 | -------------------------------------------------------------------------------- /python/tools/sourcedb_merger/tests/main.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under both the MIT license found in the 5 | # LICENSE-MIT file in the root directory of this source tree and the Apache 6 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | # of this source tree. 8 | 9 | PYTHONPATH="$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")" 10 | export PYTHONPATH 11 | exec python3 -m unittest sourcedb_merger.tests 12 | -------------------------------------------------------------------------------- /zip_file/zip_file_toolchain.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | ZipFileToolchainInfo = provider( 9 | doc = "ZipFile toolchain info", 10 | fields = { 11 | "create_zip": provider_field(typing.Any, default = None), 12 | }, 13 | ) 14 | -------------------------------------------------------------------------------- /haskell/ide/README.md: -------------------------------------------------------------------------------- 1 | # Haskell Language Server integration 2 | 3 | This integration allows loading `haskell_binary` and `haskell_library` targets 4 | on Haskell Language Server. This is accomplished via a BXL script that is used 5 | to drive a hie-bios "bios" cradle. 6 | 7 | # Usage 8 | 9 | To print the list of GHC flags and targets for a Haskell source file: 10 | 11 | buck2 bxl prelude//haskell/ide/ide.bxl -- --bios true --file 12 | 13 | 14 | To integrate with hie_bios, copy `hie.yaml` to your repo root 15 | -------------------------------------------------------------------------------- /apple/user/apple_selected_debug_path_file.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # The file name used to store the user's selected debug path in selective debugging 9 | # Will save to the root of app bundle 10 | SELECTED_DEBUG_PATH_FILE_NAME = "SelectedDebugPaths.txt" 11 | -------------------------------------------------------------------------------- /android/build_only_native_code.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def is_build_only_native_code(): 9 | return select( 10 | { 11 | "DEFAULT": False, 12 | "prelude//android/constraints:build_only_native_code": True, 13 | }, 14 | ) 15 | -------------------------------------------------------------------------------- /toolchains/execution_host.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//utils:host.bzl", "HostOSTypes") 9 | 10 | _ExecutionHostOSTypes = HostOSTypes + ["fat"] # Fat toolchains are compatible on multiple OSes. 11 | 12 | ExecutionHostOSType = enum(*_ExecutionHostOSTypes) 13 | -------------------------------------------------------------------------------- /erlang/common_test/test_exec/src/test_exec.app.src: -------------------------------------------------------------------------------- 1 | %% Copyright (c) Meta Platforms, Inc. and affiliates. 2 | %% 3 | %% This source code is licensed under both the MIT license found in the 4 | %% LICENSE-MIT file in the root directory of this source tree and the Apache 5 | %% License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | %% of this source tree. 7 | 8 | {application, test_exec, [ 9 | {vsn, "1.0.0"}, 10 | {env, [ 11 | {test_env, "override_me"}, 12 | {test_runner, "override_me"}, 13 | {ct_daemon_hooks, []} 14 | ]} 15 | ]}. 16 | -------------------------------------------------------------------------------- /erlang/shell/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | erlang_application( 8 | name = "buck2_shell_utils", 9 | srcs = glob(["src/*.erl"]), 10 | applications = [ 11 | "kernel", 12 | "stdlib", 13 | ], 14 | erl_opts = [ 15 | "+debug_info", 16 | "+warnings_as_errors", 17 | ], 18 | included_applications = [ 19 | "prelude//erlang/common_test/test_exec:test_exec", 20 | ], 21 | shell_libs = [], 22 | visibility = ["PUBLIC"], 23 | ) 24 | -------------------------------------------------------------------------------- /os_lookup/targets/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | load("//os_lookup:defs.bzl", "os_lookup") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | os_lookup( 9 | name = "os_lookup", 10 | cpu = select({ 11 | "DEFAULT": None, 12 | "config//cpu:arm64": "arm64", 13 | "config//cpu:x86_64": "x86_64", 14 | }), 15 | platform = select({ 16 | "DEFAULT": "linux", 17 | "config//os:macos": "macos", 18 | "config//os:windows": "windows", 19 | }), 20 | visibility = ["PUBLIC"], 21 | ) 22 | -------------------------------------------------------------------------------- /prelude.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//:native.bzl", _native = "native") 9 | 10 | # Public symbols in this file become globals everywhere except `bzl` files in prelude. 11 | # Additionally, members of `native` struct also become globals in `BUCK` files. 12 | native = _native 13 | -------------------------------------------------------------------------------- /apple/apple_swift_stdlib.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | _SKIP_COPYING_SWIFT_STDLIB_EXTENSIONS = [ 9 | ".framework", 10 | ".appex", 11 | ] 12 | 13 | def should_copy_swift_stdlib(bundle_extension: str) -> bool: 14 | return bundle_extension not in _SKIP_COPYING_SWIFT_STDLIB_EXTENSIONS 15 | -------------------------------------------------------------------------------- /platforms/apple/sdk.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | _APPLE_SDKS = [ 9 | "iphoneos", 10 | "iphonesimulator", 11 | "maccatalyst", 12 | "macosx", 13 | "visionos", 14 | "visionsimulator", 15 | "watchos", 16 | "watchsimulator", 17 | ] 18 | 19 | AppleSdk = enum(*_APPLE_SDKS) 20 | -------------------------------------------------------------------------------- /apple/tools/resource_broker/timeouts.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # pyre-strict 9 | 10 | DEFAULT_OPERATION_TIMEOUT = 10 11 | 12 | # Simulator boot is an expensive command and can take a long time to complete 13 | # depending on machine configuration and current machine load. 14 | SIMULATOR_BOOT_TIMEOUT = 90 15 | -------------------------------------------------------------------------------- /toolchains/msvc/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | load(":tools.bzl", "find_msvc_tools") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | python_bootstrap_binary( 9 | name = "vswhere", 10 | main = "vswhere.py", 11 | visibility = ["PUBLIC"], 12 | ) 13 | 14 | python_bootstrap_binary( 15 | name = "run_msvc_tool", 16 | main = "run_msvc_tool.py", 17 | visibility = ["PUBLIC"], 18 | ) 19 | 20 | find_msvc_tools( 21 | name = "msvc_tools", 22 | target_compatible_with = ["config//os:windows"], 23 | visibility = ["PUBLIC"], 24 | ) 25 | -------------------------------------------------------------------------------- /kotlin/tools/compile_kotlin/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | prelude = native 8 | 9 | prelude.python_bootstrap_binary( 10 | name = "compile_kotlin", 11 | main = "compile_kotlin.py", 12 | visibility = ["PUBLIC"], 13 | deps = [ 14 | ":compile_kotlin_lib", 15 | ], 16 | ) 17 | 18 | prelude.python_bootstrap_library( 19 | name = "compile_kotlin_lib", 20 | srcs = [ 21 | "compile_kotlin.py", 22 | ], 23 | deps = [ 24 | "prelude//java/tools:utils_lib", 25 | ], 26 | ) 27 | -------------------------------------------------------------------------------- /apple/apple_bundle_attrs.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def get_apple_info_plist_build_system_identification_attrs(): 9 | return { 10 | "info_plist_identify_build_system": attrs.option(attrs.bool(), default = None), 11 | "_info_plist_identify_build_system_default": attrs.bool(default = False), 12 | } 13 | -------------------------------------------------------------------------------- /apple/apple_dsym_config.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//utils:buckconfig.bzl", "read_list") 9 | 10 | def apple_dsym_config() -> dict[str, typing.Any]: 11 | return { 12 | "_dsymutil_extra_flags": read_list("apple", "dsymutil_extra_flags", delimiter = " ", default = [], root_cell = True), 13 | } 14 | -------------------------------------------------------------------------------- /erlang/common_test/common/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | erlang_application( 8 | name = "common", 9 | srcs = glob([ 10 | "src/*.erl", 11 | "src/*.hrl", 12 | ]), 13 | applications = [ 14 | "kernel", 15 | "stdlib", 16 | ], 17 | erl_opts = [ 18 | "+debug_info", 19 | "+warnings_as_errors", 20 | ], 21 | includes = glob(["include/*.hrl"]), 22 | shell_libs = [], 23 | use_global_parse_transforms = False, 24 | visibility = ["PUBLIC"], 25 | ) 26 | -------------------------------------------------------------------------------- /kotlin/kotlin_utils.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # kotlinc is strict about the target that you can pass, e.g. 9 | # error: unknown JVM target version: 8. Supported versions: 1.6, 1.8, 9, 10, 11, 12 10 | def get_kotlinc_compatible_target(target: str) -> str: 11 | return "1.6" if target == "6" else "1.8" if target == "8" else target 12 | -------------------------------------------------------------------------------- /matlab/matlab_toolchain.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load(":matlab_info.bzl", "MatlabToolchainInfo") 9 | 10 | def matlab_toolchain(): 11 | return attrs.default_only( 12 | attrs.toolchain_dep( 13 | default = "toolchains//:matlab", 14 | providers = [MatlabToolchainInfo], 15 | ), 16 | ) 17 | -------------------------------------------------------------------------------- /utils/source_listing.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//:is_buck2.bzl", "is_buck2") 9 | load(":source_listing_impl.bzl?v2_only", "SourceListingInfoAlias", "source_listing_impl") 10 | 11 | SourceListingInfo = SourceListingInfoAlias 12 | 13 | def source_listing(): 14 | if is_buck2(): 15 | source_listing_impl() 16 | -------------------------------------------------------------------------------- /rust/with_workspace.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | package_key = "rust.workspaces" 9 | 10 | def with_rust_workspace(targets): 11 | if isinstance(targets, str): 12 | targets = [targets] 13 | 14 | parent = read_parent_package_value(package_key) or [] 15 | write_package_value(package_key, parent + targets, overwrite = True) 16 | -------------------------------------------------------------------------------- /android/min_sdk_version.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | _MIN_SDK_VERSION = 19 9 | _MAX_SDK_VERSION = 33 10 | 11 | def get_min_sdk_version_constraint_value_name(min_sdk: int) -> str: 12 | return "min_sdk_version_{}".format(min_sdk) 13 | 14 | def get_min_sdk_version_range() -> range: 15 | return range(_MIN_SDK_VERSION, _MAX_SDK_VERSION) 16 | -------------------------------------------------------------------------------- /rust/rust_common.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load(":with_workspace.bzl", "package_key") 9 | 10 | def rust_common_macro_wrapper(rust_rule): 11 | def rust_common_impl(**kwargs): 12 | workspaces = read_package_value(package_key) or [] 13 | rust_rule(_workspaces = workspaces, **kwargs) 14 | 15 | return rust_common_impl 16 | -------------------------------------------------------------------------------- /cxx/tools/defs.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def _cxx_hacks_impl(_ctx): 9 | return [DefaultInfo(), TemplatePlaceholderInfo( 10 | unkeyed_variables = { 11 | "cxx-header-tree": "/dev/null/HACK-CXX-HEADER-TREE", 12 | }, 13 | )] 14 | 15 | cxx_hacks = rule( 16 | impl = _cxx_hacks_impl, 17 | attrs = {}, 18 | ) 19 | -------------------------------------------------------------------------------- /abi/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | config_setting( 8 | name = "gnu", 9 | constraint_values = [ 10 | "prelude//abi/constraints:gnu", 11 | ], 12 | visibility = ["PUBLIC"], 13 | ) 14 | 15 | config_setting( 16 | name = "msvc", 17 | constraint_values = [ 18 | "prelude//abi/constraints:msvc", 19 | ], 20 | visibility = ["PUBLIC"], 21 | ) 22 | 23 | config_setting( 24 | name = "musl", 25 | constraint_values = [ 26 | "prelude//abi/constraints:musl", 27 | ], 28 | visibility = ["PUBLIC"], 29 | ) 30 | -------------------------------------------------------------------------------- /utils/strings.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def strip_prefix(prefix: str, s: str) -> [str, None]: 9 | """ 10 | If the string `s` starts with `prefix`, return the result of stripping the 11 | latter from the former. Return `None` otherwise. 12 | """ 13 | 14 | if s.startswith(prefix): 15 | return s[len(prefix):] 16 | 17 | return None 18 | -------------------------------------------------------------------------------- /toolchains/apple/xcode_version_checker/test/Xcode_14.2.0_14C18_fb_version.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildVersion 6 | 49 7 | CFBundleShortVersionString 8 | 14.2 9 | CFBundleVersion 10 | 21534 11 | ProductBuildVersion 12 | 14C18 13 | ProjectName 14 | IDEFrameworks 15 | SourceVersion 16 | 21534000000000000 17 | 18 | 19 | -------------------------------------------------------------------------------- /julia/julia_toolchain.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load(":julia_info.bzl", "JuliaToolchainInfo") 9 | 10 | def _toolchain(lang: str, providers: list[typing.Any]) -> Attr: 11 | return attrs.default_only(attrs.toolchain_dep(default = "toolchains//:" + lang, providers = providers)) 12 | 13 | def julia_toolchain(): 14 | return _toolchain("julia", [JuliaToolchainInfo]) 15 | -------------------------------------------------------------------------------- /apple/apple_package_config.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | IpaCompressionLevel = enum( 9 | "min", 10 | "max", 11 | "default", 12 | "none", 13 | ) 14 | 15 | def apple_package_config() -> dict[str, typing.Any]: 16 | return { 17 | "_ipa_compression_level": read_root_config("apple", "ipa_compression_level", IpaCompressionLevel("default").value), 18 | } 19 | -------------------------------------------------------------------------------- /abi/constraints/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | # Used by open source projects to support `prelude//` 8 | 9 | constraint_setting( 10 | name = "abi", 11 | visibility = ["PUBLIC"], 12 | ) 13 | 14 | constraint_value( 15 | name = "gnu", 16 | constraint_setting = ":abi", 17 | visibility = ["PUBLIC"], 18 | ) 19 | 20 | constraint_value( 21 | name = "msvc", 22 | constraint_setting = ":abi", 23 | visibility = ["PUBLIC"], 24 | ) 25 | 26 | constraint_value( 27 | name = "musl", 28 | constraint_setting = ":abi", 29 | visibility = ["PUBLIC"], 30 | ) 31 | -------------------------------------------------------------------------------- /apple/apple_sdk.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//apple:apple_toolchain_types.bzl", "AppleToolchainInfo") 9 | 10 | def get_apple_sdk_name(ctx: AnalysisContext) -> str: 11 | """ 12 | Get the SDK defined on the toolchain. 13 | Will throw if the `_apple_toolchain` is not present. 14 | """ 15 | return ctx.attrs._apple_toolchain[AppleToolchainInfo].sdk_name 16 | -------------------------------------------------------------------------------- /python/tools/fail_with_message.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under both the MIT license found in the 5 | # LICENSE-MIT file in the root directory of this source tree and the Apache 6 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | # of this source tree. 8 | 9 | # pyre-strict 10 | 11 | import sys 12 | from pathlib import Path 13 | 14 | 15 | def main() -> None: 16 | print(Path(sys.argv[1]).read_text()) 17 | if len(sys.argv) == 3: 18 | Path(sys.argv[2]).touch() 19 | sys.exit(1) 20 | 21 | 22 | if __name__ == "__main__": 23 | main() 24 | -------------------------------------------------------------------------------- /apple/apple_stripping.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//cxx:cxx_context.bzl", "get_cxx_toolchain_info") 9 | 10 | def apple_strip_args(ctx: AnalysisContext) -> cmd_args: 11 | cxx_toolchain_info = get_cxx_toolchain_info(ctx) 12 | flags = cxx_toolchain_info.strip_flags_info.strip_non_global_flags 13 | return cmd_args(flags) if flags != None else cmd_args(["-x", "-T"]) 14 | -------------------------------------------------------------------------------- /linking/types.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # Ways a library can request to be linked (e.g. usually specific via a rule 9 | # param like `preferred_linkage`). The actual link style used for a library is 10 | # usually determined by a combination of this and the link style being exported 11 | # via a provider. 12 | Linkage = enum( 13 | "any", 14 | "static", 15 | "shared", 16 | ) 17 | -------------------------------------------------------------------------------- /tests/remote_test_execution_toolchain.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | RemoteTestExecutionToolchainInfo = provider( 9 | fields = [ 10 | # The profile to use by default. 11 | "default_profile", 12 | # A dictionary of string names to pre-registered profiles. Rules can 13 | # use the profile name to references these. 14 | "profiles", 15 | ], 16 | ) 17 | -------------------------------------------------------------------------------- /java/dex_toolchain.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # TODO(T107163344) These should be part of the Android toolchain! 9 | # Move out once we have overlays. 10 | DexToolchainInfo = provider( 11 | doc = "Dex toolchain info", 12 | fields = { 13 | "android_jar": provider_field(typing.Any, default = None), 14 | "d8_command": provider_field(typing.Any, default = None), 15 | }, 16 | ) 17 | -------------------------------------------------------------------------------- /kotlin/tools/kapt_base64_encoder/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//kotlin/tools:defs.bzl", "java_bootstrap_binary", "java_bootstrap_library") 2 | load("@prelude//utils:source_listing.bzl", "source_listing") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | java_bootstrap_library( 9 | name = "kapt_base64_encoder_lib", 10 | srcs = [ 11 | "com/facebook/kapt/KaptBase64Encoder.java", 12 | ], 13 | source = "8", 14 | target = "8", 15 | ) 16 | 17 | java_bootstrap_binary( 18 | name = "kapt_base64_encoder", 19 | main_class = "com.facebook.kapt.KaptBase64Encoder", 20 | visibility = ["PUBLIC"], 21 | deps = [ 22 | ":kapt_base64_encoder_lib", 23 | ], 24 | ) 25 | -------------------------------------------------------------------------------- /matlab/matlab.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load(":matlab_program.bzl", "matlab_program_impl") 9 | load(":matlab_toolchain.bzl", "matlab_toolchain") 10 | 11 | implemented_rules = { 12 | "matlab_program": matlab_program_impl, 13 | } 14 | 15 | extra_attributes = { 16 | "matlab_program": { 17 | "main": attrs.source(), 18 | "_matlab_toolchain": matlab_toolchain(), 19 | }, 20 | } 21 | -------------------------------------------------------------------------------- /user/rule_spec.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | RuleRegistrationSpec = record( 9 | name = field(str), 10 | impl = field(typing.Callable), 11 | attrs = field(dict[str, Attr]), 12 | # TODO(nga): should be `transition | None`, but `transition` does not work as type. 13 | cfg = field(typing.Any | None, None), 14 | is_toolchain_rule = field(bool, False), 15 | doc = field(str, ""), 16 | ) 17 | -------------------------------------------------------------------------------- /apple/apple_modular_utility.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # We use a fixed module cache location. This works around issues with 9 | # multi-user setups with MobileOnDemand and allows us to share the 10 | # module cache with Xcode, LLDB and arc focus. 11 | # 12 | # TODO(T123737676): This needs to be changed to use $TMPDIR in a 13 | # wrapper for modular clang compilation. 14 | MODULE_CACHE_PATH = "/tmp/buck-module-cache" 15 | -------------------------------------------------------------------------------- /utils/arglike.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # Command-line argument-like. For example, a string, or an artifact. 9 | # Precise list is defined in `ValueAsCommandLineLike::as_command_line`. 10 | # Defining as Any, but can be defined as union type, 11 | # but that might be expensive to check at runtime. 12 | # In the future we will have compiler-time only types, 13 | # and this type could be refined. 14 | ArgLike = typing.Any 15 | -------------------------------------------------------------------------------- /apple/apple_resource_utility.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load(":apple_bundle_destination.bzl", "AppleBundleDestination") 9 | load( 10 | ":apple_resource_types.bzl", 11 | "AppleResourceDestination", # @unused Used as a type 12 | ) 13 | 14 | def apple_bundle_destination_from_resource_destination(res_destination: AppleResourceDestination) -> AppleBundleDestination: 15 | return AppleBundleDestination(res_destination.value) 16 | -------------------------------------------------------------------------------- /tools/audit_providers_universe.bxl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def _impl(ctx): 9 | ts = ctx.target_universe(ctx.cli_args.universe).lookup(ctx.cli_args.target) 10 | ctx.output.print(pstr({t: a.providers() for t, a in ctx.analysis(ts).items()})) 11 | 12 | run = bxl_main( 13 | impl = _impl, 14 | cli_args = { 15 | "target": cli_args.target_label(), 16 | "universe": cli_args.target_label(), 17 | }, 18 | ) 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Buck2 Prelude 2 | 3 | This repo contains a copy of the Buck2 Prelude, which is often included as a 4 | submodule with a Buck2 project. To obtain a copy of this repo, and set up other 5 | details of a Buck2, you should usually run `buck2 init --git`. Most information 6 | can be found on the main 7 | [Buck2 GitHub project](https://github.com/facebook/buck2). 8 | 9 | Pull requests and issues should be raised at 10 | [facebook/buck2](https://github.com/facebook/buck2) as that project is more 11 | closely monitored and contains CI checks. 12 | 13 | ## License 14 | 15 | Buck2 Prelude is both MIT and Apache License, Version 2.0 licensed, as found in 16 | the [LICENSE-MIT](LICENSE-MIT) and [LICENSE-APACHE](LICENSE-APACHE) files. 17 | -------------------------------------------------------------------------------- /apple/tools/resource_broker/idb_companion.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # pyre-strict 9 | 10 | import os 11 | import signal 12 | from dataclasses import dataclass 13 | from io import TextIOWrapper 14 | 15 | 16 | @dataclass 17 | class IdbCompanion: 18 | socket_address: str 19 | pid: int 20 | stderr: TextIOWrapper 21 | 22 | def cleanup(self) -> None: 23 | os.kill(self.pid, signal.SIGTERM) 24 | self.stderr.close() 25 | -------------------------------------------------------------------------------- /debugging/ensure_dwp.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # split dwarf targets have ["dwp"] subtargets. this function ensures that the dwp file is materialized 9 | def ensure_dwp(ctx: bxl.Context, target: bxl.ConfiguredTargetNode): 10 | providers = ctx.analysis(target).providers() 11 | subtargets = providers[DefaultInfo].sub_targets 12 | 13 | if "dwp" in subtargets: 14 | ctx.output.ensure(subtargets["dwp"][DefaultInfo].default_outputs[0]) 15 | -------------------------------------------------------------------------------- /toolchains/genrule.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//:genrule_toolchain.bzl", "GenruleToolchainInfo") 9 | 10 | def _system_genrule_toolchain_impl(_ctx): 11 | return [ 12 | DefaultInfo(), 13 | GenruleToolchainInfo( 14 | zip_scrubber = None, 15 | ), 16 | ] 17 | 18 | system_genrule_toolchain = rule( 19 | impl = _system_genrule_toolchain_impl, 20 | attrs = {}, 21 | is_toolchain_rule = True, 22 | ) 23 | -------------------------------------------------------------------------------- /cxx/dist_lto/tools/dist_lto_copy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under both the MIT license found in the 5 | # LICENSE-MIT file in the root directory of this source tree and the Apache 6 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | # of this source tree. 8 | 9 | import argparse 10 | import shutil 11 | import sys 12 | from typing import List 13 | 14 | 15 | def main(argv: List[str]) -> int: 16 | parser = argparse.ArgumentParser() 17 | parser.add_argument("--to") 18 | parser.add_argument("--from", dest="from_") 19 | args = parser.parse_args(argv[1:]) 20 | shutil.copy(args.from_, args.to) 21 | return 0 22 | 23 | 24 | sys.exit(main(sys.argv)) 25 | -------------------------------------------------------------------------------- /java/utils/java_more_utils.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load( 9 | "@prelude//os_lookup:defs.bzl", 10 | "OsLookup", # @unused Used as type 11 | ) 12 | load("@prelude//utils:expect.bzl", "expect") 13 | 14 | def get_path_separator_for_exec_os(ctx: AnalysisContext) -> str: 15 | expect(hasattr(ctx.attrs, "_exec_os_type"), "Expect ctx.attrs._exec_os_type is defined.") 16 | is_windows = ctx.attrs._exec_os_type[OsLookup].platform == "windows" 17 | return ";" if is_windows else ":" 18 | -------------------------------------------------------------------------------- /platforms/BUCK: -------------------------------------------------------------------------------- 1 | # Used by open source projects to provide a simple platform setting 2 | # This file exports a sub-set of the definitions from TARGETS.v2 for backwards-compatibility with buck1. 3 | # NOTE: These have no effect in BUCK1 and are only provided so imports can resolve. 4 | 5 | load("@prelude//utils:source_listing.bzl", "source_listing") 6 | 7 | oncall("build_infra") 8 | 9 | source_listing() 10 | 11 | config_setting( 12 | name = "runs_remote", 13 | visibility = ["PUBLIC"], 14 | ) 15 | 16 | config_setting( 17 | name = "runs_local", 18 | visibility = ["PUBLIC"], 19 | ) 20 | 21 | config_setting( 22 | name = "runs_only_local", 23 | visibility = ["PUBLIC"], 24 | ) 25 | 26 | config_setting( 27 | name = "runs_only_remote", 28 | visibility = ["PUBLIC"], 29 | ) 30 | -------------------------------------------------------------------------------- /apple/apple_code_signing_types.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # Provider which exposes a field from `apple_binary` to `apple_bundle` as it might be used during code signing. 9 | AppleEntitlementsInfo = provider(fields = { 10 | "entitlements_file": provider_field(Artifact | None, default = None), 11 | }) 12 | 13 | CodeSignType = enum( 14 | "skip", 15 | "adhoc", 16 | "distribution", 17 | ) 18 | 19 | CodeSignConfiguration = enum( 20 | "dry-run", 21 | "fast-adhoc", 22 | "none", 23 | ) 24 | -------------------------------------------------------------------------------- /cxx/platform.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//utils:platform_flavors_util.bzl", "by_platform") 9 | load(":cxx_context.bzl", "get_cxx_platform_info") 10 | 11 | def cxx_by_platform(ctx: AnalysisContext, xs: list[(str, typing.Any)]) -> list[typing.Any]: 12 | cxx_platform_info = get_cxx_platform_info(ctx) 13 | platform_flavors = [cxx_platform_info.name] 14 | if cxx_platform_info.deps_aliases: 15 | platform_flavors.extend(cxx_platform_info.deps_aliases) 16 | return by_platform(platform_flavors, xs) 17 | -------------------------------------------------------------------------------- /apple/tools/resource_broker/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | python_binary( 8 | name = "resource_broker", 9 | main = "main.py", 10 | visibility = ["PUBLIC"], 11 | deps = [ 12 | ":main", 13 | ], 14 | ) 15 | 16 | python_library( 17 | name = "main", 18 | srcs = ["main.py"], 19 | deps = [ 20 | ":lib", 21 | ], 22 | ) 23 | 24 | python_library( 25 | name = "lib", 26 | srcs = glob( 27 | [ 28 | "*.py", 29 | ], 30 | exclude = [ 31 | "main.py", 32 | ], 33 | ), 34 | deps = [ 35 | "fbsource//third-party/pypi/dataclasses-json:dataclasses-json", 36 | "fbsource//third-party/pypi/packaging:packaging", 37 | ], 38 | ) 39 | -------------------------------------------------------------------------------- /erlang/common_test/test_cli_lib/test/test_cli_e2e_SUITE_data/test_list_SUITE.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) Meta Platforms, Inc. and affiliates. 2 | %% This source code is licensed under both the MIT license found in the 3 | %% LICENSE-MIT file in the root directory of this source tree and the Apache 4 | %% License, Version 2.0 found in the LICENSE-APACHE file in the root directory 5 | %% of this source tree. 6 | %%% % @format 7 | -module(test_list_SUITE). 8 | 9 | -include_lib("stdlib/include/assert.hrl"). 10 | 11 | -export([all/0, groups/0]). 12 | 13 | -export([ 14 | test_pass/1, 15 | test_fail/1 16 | ]). 17 | 18 | all() -> 19 | [test_pass, {group, default}]. 20 | 21 | groups() -> 22 | [{default, [], [test_fail]}]. 23 | 24 | test_pass(_Config) -> 25 | ?assert(true). 26 | 27 | test_fail(_Config) -> 28 | ?assert(false). 29 | -------------------------------------------------------------------------------- /platforms/apple/platforms_map.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # @oss-disable: load("@prelude//platforms/apple/meta_only:platforms_map.bzl", _APPLE_PLATFORMS_MAP = "APPLE_PLATFORMS_MAP", _APPLE_SDK_DEFAULT_PLATFORM_MAP = "APPLE_SDK_DEFAULT_PLATFORM_MAP") 9 | 10 | APPLE_PLATFORMS_MAP = {} # TODO: Define OSS platforms map # @oss-enable 11 | # @oss-disable: APPLE_PLATFORMS_MAP = _APPLE_PLATFORMS_MAP 12 | 13 | APPLE_SDK_DEFAULT_PLATFORM_MAP = {} # @oss-enable 14 | # @oss-disable: APPLE_SDK_DEFAULT_PLATFORM_MAP = _APPLE_SDK_DEFAULT_PLATFORM_MAP 15 | -------------------------------------------------------------------------------- /apple/swift/swift_module_map.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//utils:arglike.bzl", "ArgLike") # @unused Used as a type 9 | load(":swift_toolchain_types.bzl", "SwiftCompiledModuleTset") 10 | 11 | def write_swift_module_map_with_deps( 12 | ctx: AnalysisContext, 13 | module_name: str, 14 | all_deps: SwiftCompiledModuleTset) -> ArgLike: 15 | return ctx.actions.write_json( 16 | module_name + ".swift_module_map.json", 17 | all_deps.project_as_json("swift_module_map"), 18 | with_inputs = True, 19 | ) 20 | -------------------------------------------------------------------------------- /python/tools/make_par/BUCK: -------------------------------------------------------------------------------- 1 | # META INTERNAL NOTES: 2 | # If this file is changed open source it will probably not import correctly, 3 | # as it is the only `TARGETS` (not `TARGETS.v2`) in the prelude. 4 | # Configuring the tools to do it right seemed more dangerous than just having a caveat on this one file. 5 | 6 | load("@prelude//utils:source_listing.bzl", "source_listing") 7 | 8 | oncall("build_infra") 9 | 10 | source_listing() 11 | 12 | export_file( 13 | name = "__run_lpar_main__.py", 14 | src = "__run_lpar_main__.py", 15 | visibility = ["PUBLIC"], 16 | ) 17 | 18 | export_file( 19 | name = "sitecustomize.py", 20 | src = "sitecustomize.py", 21 | visibility = ["PUBLIC"], 22 | ) 23 | 24 | export_file( 25 | name = "_lpar_bootstrap.sh.template", 26 | src = "_lpar_bootstrap.sh.template", 27 | visibility = ["PUBLIC"], 28 | ) 29 | -------------------------------------------------------------------------------- /apple/versions.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # All the target SDK versions currently in use. 9 | TARGET_SDK_VERSIONS = [ 10 | "1.0", 11 | "4.0", 12 | "7.0", 13 | "9.0", 14 | "10.0", 15 | "10.10", 16 | "10.12", 17 | "10.13", 18 | "10.14", 19 | "10.15", 20 | "11.0", 21 | "11.3", 22 | "12.0", 23 | "12.4", 24 | "13.0", 25 | "13.1", 26 | "13.4", 27 | "14.0", 28 | "14.2", 29 | "15.0", 30 | "15.1", 31 | "15.2", 32 | "15.5", 33 | "16.0", 34 | "16.1", 35 | "17.0", 36 | "18.0", 37 | ] 38 | -------------------------------------------------------------------------------- /utils/host.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | HostOSTypes = ["linux", "macos", "windows"] 9 | 10 | HostOSType = enum(*HostOSTypes) 11 | 12 | def _compute_get_host_os() -> HostOSType: 13 | info = host_info() 14 | if info.os.is_linux: 15 | return HostOSType("linux") 16 | elif info.os.is_macos: 17 | return HostOSType("macos") 18 | elif info.os.is_windows: 19 | return HostOSType("windows") 20 | else: 21 | fail("Unknown host OS") 22 | 23 | _HOST_OS = _compute_get_host_os() 24 | 25 | def get_host_os() -> HostOSType: 26 | return _HOST_OS 27 | -------------------------------------------------------------------------------- /validation_deps.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | VALIDATION_DEPS_ATTR_NAME = "validation_deps" 9 | VALIDATION_DEPS_ATTR_TYPE = attrs.set(attrs.dep(), sorted = True, default = []) 10 | 11 | def get_validation_deps_outputs(ctx: AnalysisContext) -> list[Artifact]: 12 | artifacts = [] 13 | if hasattr(ctx.attrs, VALIDATION_DEPS_ATTR_NAME): 14 | validation_deps = getattr(ctx.attrs, VALIDATION_DEPS_ATTR_NAME) 15 | for dep in validation_deps: 16 | default_info = dep[DefaultInfo] 17 | artifacts += default_info.default_outputs 18 | return artifacts 19 | -------------------------------------------------------------------------------- /java/keystore.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//java:java_providers.bzl", "KeystoreInfo") 9 | 10 | def keystore_impl(ctx: AnalysisContext) -> list[Provider]: 11 | sub_targets = {} 12 | sub_targets["keystore"] = [DefaultInfo(default_output = ctx.attrs.store)] 13 | sub_targets["properties"] = [DefaultInfo(default_output = ctx.attrs.properties)] 14 | 15 | return [ 16 | KeystoreInfo(store = ctx.attrs.store, properties = ctx.attrs.properties), 17 | DefaultInfo(default_outputs = [ctx.attrs.store, ctx.attrs.properties], sub_targets = sub_targets), 18 | ] 19 | -------------------------------------------------------------------------------- /python/typecheck/batch_files.bxl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load(":batch.bxl", "check_targets") 9 | 10 | def _run_entry_point(ctx: bxl.Context) -> None: 11 | targets = ctx.uquery().owner(ctx.cli_args.source) 12 | check_targets(ctx, targets) 13 | 14 | run = bxl_main( 15 | doc = "Run [typecheck] on the owning targets of given files.", 16 | impl = _run_entry_point, 17 | cli_args = { 18 | "source": cli_args.list( 19 | cli_args.string( 20 | doc = "Files whose owning targets need to be checked", 21 | ), 22 | ), 23 | }, 24 | ) 25 | -------------------------------------------------------------------------------- /erlang/common_test/cth_hooks/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | erlang_application( 8 | name = "cth_hooks", 9 | srcs = glob([ 10 | "src/*.erl", 11 | "src/*.hrl", 12 | ]), 13 | applications = [ 14 | "kernel", 15 | "stdlib", 16 | "common_test", 17 | ], 18 | erl_opts = [ 19 | "+debug_info", 20 | "+warnings_as_errors", 21 | ], 22 | shell_libs = [], 23 | use_global_parse_transforms = False, 24 | visibility = ["PUBLIC"], 25 | ) 26 | 27 | erlang_application( 28 | name = "compiled_suites", 29 | srcs = glob(["tests/cth_tpx_SUITE_data/*.erl"]), 30 | applications = ["stdlib"], 31 | erl_opts = [ 32 | "+debug_info", 33 | "+warnings_as_errors", 34 | ], 35 | visibility = ["PUBLIC"], 36 | ) 37 | -------------------------------------------------------------------------------- /go/transitions/tags_helper.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//utils:buckconfig.bzl", "read_list") 9 | 10 | allowed_tags = read_list("go", "allowed_tags", default = [], root_cell = True) 11 | 12 | def tag_to_constrant_value(): 13 | return {tag: "prelude//go/constraints:tag_{}__value".format(tag) for tag in allowed_tags} 14 | 15 | def selects_for_tags(): 16 | selects = [] 17 | for tag in allowed_tags: 18 | selects += select({ 19 | "DEFAULT": [], 20 | "prelude//go/constraints:tag_{}__value".format(tag): [tag], 21 | }) 22 | 23 | return selects 24 | -------------------------------------------------------------------------------- /go/constraints/defs.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//:native.bzl", "native") 9 | load("@prelude//go/transitions:tags_helper.bzl", "allowed_tags") 10 | 11 | def generate_tag_constraints(): 12 | for tag in allowed_tags: 13 | setting_name = "tag_" + tag 14 | native.constraint_setting( 15 | name = "tag_" + tag, 16 | visibility = ["PUBLIC"], 17 | ) 18 | 19 | native.constraint_value( 20 | name = setting_name + "__value", 21 | constraint_setting = ":" + setting_name, 22 | visibility = ["PUBLIC"], 23 | ) 24 | -------------------------------------------------------------------------------- /erlang/erlang_ls.config: -------------------------------------------------------------------------------- 1 | { 2 | "include_dirs": [ 3 | "./common_test", 4 | "./common_test/*/include", 5 | "./common_test/*/src" 6 | ], 7 | "apps_dirs": [ 8 | "./common_test/*" 9 | ], 10 | "compiler_telemetry_enabled": true, 11 | "deps_dirs": [ 12 | "../../third-party/vendor/*" 13 | ], 14 | "diagnostics": { 15 | "disabled": [ 16 | "crossref", 17 | "dialyzer", 18 | "elvis" 19 | ], 20 | "enabled": [ 21 | "edoc" 22 | ] 23 | }, 24 | "incremental_sync": true, 25 | "lenses": { 26 | "disabled": [ 27 | "suggest-spec", 28 | "function-references" 29 | ], 30 | "enabled": [ 31 | "server-info" 32 | ] 33 | }, 34 | "macros": [ 35 | { 36 | "name": "TEST" 37 | } 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /third-party/hmaptool/README.md: -------------------------------------------------------------------------------- 1 | # hmaptool 2 | 3 | This tool was copied from llvm-project. See https://github.com/llvm/llvm-project/blob/main/clang/utils/hmaptool/hmaptool 4 | 5 | ## About 6 | 7 | Header maps are binary files used by Xcode, which are used to map 8 | header names or paths to other locations. Clang has support for 9 | those since its inception, but there's not a lot of header map 10 | testing around. 11 | 12 | Since it's a binary format, testing becomes pretty much brittle 13 | and its hard to even know what's inside if you don't have the 14 | appropriate tools. 15 | 16 | Add a python based tool that allows creating and dumping header 17 | maps based on a json description of those. While here, rewrite 18 | tests to use the tool and remove the binary files from the tree. 19 | 20 | This tool was initially written by Daniel Dunbar. 21 | 22 | Thanks to Stella Stamenova for helping make this work on Windows. 23 | -------------------------------------------------------------------------------- /apple/apple_resource_dedupe_alias.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//user:rule_spec.bzl", "RuleRegistrationSpec") 9 | load("@prelude//apple/user/apple_resource_transition.bzl", "apple_resource_transition") 10 | 11 | def _impl(ctx: AnalysisContext) -> list[Provider]: 12 | return ctx.attrs.actual.providers 13 | 14 | registration_spec = RuleRegistrationSpec( 15 | name = "apple_resource_dedupe_alias", 16 | impl = _impl, 17 | attrs = { 18 | "actual": attrs.transition_dep(cfg = apple_resource_transition), 19 | "skip_universal_resource_dedupe": attrs.bool(default = False), 20 | }, 21 | ) 22 | -------------------------------------------------------------------------------- /matlab/matlab_program.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load(":matlab_info.bzl", "MatlabToolchainInfo") 9 | 10 | def matlab_program_impl(ctx: AnalysisContext) -> list[Provider]: 11 | toolchain = ctx.attrs._matlab_toolchain[MatlabToolchainInfo] 12 | 13 | cmd = cmd_args(toolchain.matlab_exe) 14 | cmd.add( 15 | "-batch", 16 | cmd_args( 17 | ctx.attrs.main.basename.removesuffix(".m"), 18 | quote = "shell", 19 | ), 20 | ) 21 | cmd.add("-sd", cmd_args(ctx.attrs.main, parent = 1)) 22 | 23 | return [DefaultInfo(default_output = None, other_outputs = [cmd]), RunInfo(cmd)] 24 | -------------------------------------------------------------------------------- /utils/platform_flavors_util.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def by_platform( 9 | platform_flavors: list[str], 10 | xs: list[(str, typing.Any)]) -> list[typing.Any]: 11 | """ 12 | Resolve platform-flavor-specific parameters, given the list of platform 13 | flavors to match against. Meant to mirror the usage of 14 | `PatternMatchedCollection`s in v1 for `platform_*` parameters. 15 | """ 16 | 17 | res = [] 18 | 19 | for (dtype, deps) in xs: 20 | for platform in platform_flavors: 21 | if regex_match(dtype, platform): 22 | res.append(deps) 23 | 24 | return res 25 | -------------------------------------------------------------------------------- /android/cpu_filters.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | CPU_FILTER_TO_ABI_DIRECTORY = { 9 | "arm64": "arm64-v8a", 10 | "armv7": "armeabi-v7a", 11 | "x86": "x86", 12 | "x86_64": "x86_64", 13 | } 14 | 15 | ALL_CPU_FILTERS = CPU_FILTER_TO_ABI_DIRECTORY.keys() 16 | 17 | CPU_FILTER_FOR_DEFAULT_PLATFORM = "arm64" 18 | 19 | # The "primary platform" is the one that we use for all 20 | # the non-native targets. We keep this consistent regardless 21 | # of which cpus the native libraries are built for so that 22 | # we get cache hits for the non-native targets across all 23 | # possible cpu filters. 24 | CPU_FILTER_FOR_PRIMARY_PLATFORM = "arm64" 25 | -------------------------------------------------------------------------------- /utils/pick.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def pick(override, underlying): 9 | return cmd_args(override) if override != None else underlying 10 | 11 | def pick_bin(override, underlying): 12 | return override[RunInfo] if override != None else underlying 13 | 14 | def pick_dep(override, underlying): 15 | return pick_raw(override, underlying) 16 | 17 | def pick_raw(override, underlying): 18 | return override if override != None else underlying 19 | 20 | def pick_and_add(override, additional, underlying): 21 | flags = [pick(override, underlying)] 22 | if additional: 23 | flags.append(additional) 24 | return cmd_args(flags) 25 | -------------------------------------------------------------------------------- /toolchains/apple/xcode_version_checker/src/xcode_exec_tester.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import "xcode_version_checks.h" 14 | 15 | int main(int argc, char const* argv[]) { 16 | @autoreleasepool { 17 | const int numberOfArgs = argc - 1; 18 | if (numberOfArgs < 1) { 19 | fprintf( 20 | stderr, "Expected at least one arguments: executable, aborting...\n"); 21 | return 1; 22 | } 23 | 24 | execTool(argv + 1, argc - 1); 25 | // `execTool` should never return, if it did, it means it failed to `execve` 26 | return 1; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /apple/tools/info_plist_processor/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | load("@prelude//apple/tools/defs.bzl", "meta_python_test") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | python_library( 9 | name = "preprocess", 10 | srcs = ["preprocess.py"], 11 | ) 12 | 13 | meta_python_test( 14 | name = "preprocess_test", 15 | srcs = ["preprocess_test.py"], 16 | deps = [":preprocess"], 17 | ) 18 | 19 | python_library( 20 | name = "process", 21 | srcs = ["process.py"], 22 | visibility = ["PUBLIC"], 23 | deps = ["prelude//apple/tools:plistlib_utils"], 24 | ) 25 | 26 | meta_python_test( 27 | name = "process_test", 28 | srcs = ["process_test.py"], 29 | deps = [":process"], 30 | ) 31 | 32 | python_binary( 33 | name = "tool", 34 | main = "main.py", 35 | visibility = ["PUBLIC"], 36 | deps = [ 37 | ":preprocess", 38 | ":process", 39 | ], 40 | ) 41 | -------------------------------------------------------------------------------- /apple/tools/defs.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # @oss-disable: load("@fbsource//tools/build_defs:python_platform.bzl", "set_platform_decorator_for_python") 9 | load("@prelude//:native.bzl", _native = "native") 10 | 11 | set_platform_decorator_for_python = lambda **kwargs: kwargs # @oss-enable 12 | 13 | def meta_python_test(name, **kwargs): 14 | # Set the platform attributes as needed for proper exec platform resolution 15 | kwargs = set_platform_decorator_for_python( 16 | # @oss-disable: set_python_constraint_overrides = True, 17 | **kwargs 18 | ) 19 | 20 | _native.python_test( 21 | name = name, 22 | **kwargs 23 | ) 24 | -------------------------------------------------------------------------------- /os_lookup/defs.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//decls/core_rules.bzl", "Platform", "TargetCpuType") 9 | 10 | OsLookup = provider(fields = {"cpu": provider_field(typing.Any, default = None), "platform": provider_field(typing.Any, default = None)}) 11 | 12 | def _os_lookup_impl(ctx: AnalysisContext): 13 | return [ 14 | DefaultInfo(), 15 | OsLookup( 16 | cpu = ctx.attrs.cpu, 17 | platform = ctx.attrs.platform, 18 | ), 19 | ] 20 | 21 | os_lookup = rule(impl = _os_lookup_impl, attrs = { 22 | "cpu": attrs.option(attrs.enum(TargetCpuType), default = None), 23 | "platform": attrs.enum(Platform), 24 | }) 25 | -------------------------------------------------------------------------------- /cxx/dist_lto/tools.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//cxx:cxx_toolchain_types.bzl", "DistLtoToolsInfo") 9 | 10 | def _impl(ctx): 11 | return [ 12 | DefaultInfo(), 13 | DistLtoToolsInfo( 14 | planner = ctx.attrs.planner[RunInfo], 15 | prepare = ctx.attrs.prepare[RunInfo], 16 | opt = ctx.attrs.opt[RunInfo], 17 | copy = ctx.attrs.copy[RunInfo], 18 | ), 19 | ] 20 | 21 | dist_lto_tools = rule( 22 | impl = _impl, 23 | attrs = { 24 | "copy": attrs.dep(), 25 | "opt": attrs.dep(), 26 | "planner": attrs.dep(), 27 | "prepare": attrs.dep(), 28 | }, 29 | ) 30 | -------------------------------------------------------------------------------- /erlang/common_test/test_cli_lib/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | erlang_application( 8 | name = "test_cli_lib", 9 | srcs = glob(["src/*.erl"]), 10 | applications = ["//erlang/common_test/test_binary:test_binary"], 11 | erl_opts = [ 12 | "+debug_info", 13 | "+warnings_as_errors", 14 | ], 15 | resources = [], 16 | visibility = ["PUBLIC"], 17 | ) 18 | 19 | erlang_tests( 20 | contacts = ["whatsapp_testing_infra"], 21 | labels = ["e2e"], 22 | suites = ["test/test_cli_e2e_SUITE.erl"], 23 | deps = [ 24 | "stdlib", 25 | ":test_cli_e2e_SUITE_fixtures", 26 | ":test_cli_lib", 27 | ], 28 | ) 29 | 30 | erlang_application( 31 | name = "test_cli_e2e_SUITE_fixtures", 32 | srcs = glob(["test/test_cli_e2e_SUITE_data/*.erl"]), 33 | applications = [], 34 | labels = ["test_application"], 35 | ) 36 | -------------------------------------------------------------------------------- /export_file.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # Implementation of the `export_file` build rule. 9 | 10 | def export_file_impl(ctx: AnalysisContext) -> list[DefaultInfo]: 11 | # mode is "copy" or "reference", defaulting to copy 12 | copy = ctx.attrs.mode != "reference" 13 | 14 | if copy: 15 | dest = ctx.label.name if ctx.attrs.out == None else ctx.attrs.out 16 | output = ctx.actions.copy_file(dest, ctx.attrs.src) 17 | elif ctx.attrs.out != None: 18 | fail("export_file does not allow specifying `out` without also specifying `mode = 'copy'`") 19 | else: 20 | output = ctx.attrs.src 21 | return [DefaultInfo(default_output = output)] 22 | -------------------------------------------------------------------------------- /julia/julia_test.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//test/inject_test_run_info.bzl", "inject_test_run_info") 9 | load(":julia_binary.bzl", "build_julia_command") 10 | 11 | def julia_test_impl(ctx: AnalysisContext) -> list[Provider]: 12 | cmd, json_info_file = build_julia_command(ctx) 13 | external_runner_test_info = ExternalRunnerTestInfo( 14 | type = "julia", 15 | command = [cmd], 16 | contacts = ctx.attrs.contacts, 17 | # FIXME: Consider setting to true 18 | run_from_project_root = False, 19 | ) 20 | 21 | return inject_test_run_info(ctx, external_runner_test_info) + [DefaultInfo(default_output = json_info_file)] 22 | -------------------------------------------------------------------------------- /python_bootstrap/tools/win_python_wrapper.bat: -------------------------------------------------------------------------------- 1 | @REM Copyright (c) Meta Platforms, Inc. and affiliates. 2 | @REM 3 | @REM This source code is licensed under both the MIT license found in the 4 | @REM LICENSE-MIT file in the root directory of this source tree and the Apache 5 | @REM License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | @REM of this source tree. 7 | 8 | :: A wrapper to set PYTHONPATH and run a python command with the specified interpreter 9 | :: First arg: paths to library that should be made available 10 | :: Second arg: path to python interpreter 11 | :: Third arg: path to python file that should be run 12 | :: Fourth and onwards: any other arg that should be passed 13 | @echo off 14 | 15 | :: See https://stackoverflow.com/questions/382587/how-to-get-batch-file-parameters-from-nth-position-on 16 | setlocal enabledelayedexpansion 17 | set args=;;;;;;%* 18 | set args=!args:;;;;;;%1 =! 19 | 20 | set PYTHONPATH=%~1 21 | %args% 22 | -------------------------------------------------------------------------------- /apple/tools/plistlib_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # pyre-strict 9 | 10 | import plistlib 11 | from io import BytesIO 12 | from typing import Any, Dict, IO 13 | 14 | 15 | def _is_fmt_binary(header: bytes) -> bool: 16 | return header[:8] == b"bplist00" 17 | 18 | 19 | def detect_format_and_load(fp: IO[bytes]) -> Dict[str, Any]: 20 | header = fp.read(32) 21 | fp.seek(0) 22 | if _is_fmt_binary(header): 23 | fmt = plistlib.FMT_BINARY 24 | else: 25 | fmt = plistlib.FMT_XML 26 | return plistlib.load(fp, fmt=fmt) 27 | 28 | 29 | def detect_format_and_loads(value: bytes) -> Dict[str, Any]: 30 | fp = BytesIO(value) 31 | return detect_format_and_load(fp) 32 | -------------------------------------------------------------------------------- /android/exopackage.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//utils:expect.bzl", "expect") 9 | 10 | SECONDARY_DEX = 1 11 | NATIVE_LIBRARY = 2 12 | RESOURCES = 4 13 | MODULES = 8 14 | ARCH64 = 16 15 | 16 | def get_exopackage_flags(exopackage_modes: list[str]) -> int: 17 | expect("modules" not in exopackage_modes, "Modular exopackage is not supported!") 18 | flags = 0 19 | 20 | for (name, flag) in [ 21 | ("secondary_dex", SECONDARY_DEX), 22 | ("native_library", NATIVE_LIBRARY), 23 | ("resources", RESOURCES), 24 | ("modules", MODULES), 25 | ("arch64", ARCH64), 26 | ]: 27 | if name in exopackage_modes: 28 | flags += flag 29 | 30 | return flags 31 | -------------------------------------------------------------------------------- /cpu/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | config_setting( 8 | name = "x86_64", 9 | constraint_values = [ 10 | "prelude//cpu/constraints:x86_64", 11 | ], 12 | visibility = ["PUBLIC"], 13 | ) 14 | 15 | config_setting( 16 | name = "x86_32", 17 | constraint_values = [ 18 | "prelude//cpu/constraints:x86_32", 19 | ], 20 | visibility = ["PUBLIC"], 21 | ) 22 | 23 | config_setting( 24 | name = "arm64", 25 | constraint_values = [ 26 | "prelude//cpu/constraints:arm64", 27 | ], 28 | visibility = ["PUBLIC"], 29 | ) 30 | 31 | config_setting( 32 | name = "arm32", 33 | constraint_values = [ 34 | "prelude//cpu/constraints:arm32", 35 | ], 36 | visibility = ["PUBLIC"], 37 | ) 38 | 39 | config_setting( 40 | name = "wasm32", 41 | constraint_values = [ 42 | "prelude//cpu/constraints:wasm32", 43 | ], 44 | visibility = ["PUBLIC"], 45 | ) 46 | -------------------------------------------------------------------------------- /debugging/common.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # Utility functions used by "fdb.bxl" 9 | 10 | load("@prelude//debugging/types.bzl", "TargetInfo") 11 | 12 | def target_name(node: bxl.ConfiguredTargetNode) -> str: 13 | return "{}:{}".format(str(node.label.path), node.label.name) 14 | 15 | def rule_type(node: bxl.ConfiguredTargetNode) -> str: 16 | return node.rule_type 17 | 18 | def create_target_info(target: bxl.ConfiguredTargetNode) -> TargetInfo: 19 | attrs = target.attrs_lazy() 20 | return TargetInfo( 21 | target = target_name(target), 22 | target_type = rule_type(target).removeprefix("prelude//rules.bzl:"), 23 | labels = attrs.get("labels").value() if attrs.get("labels") != None else [], 24 | ) 25 | -------------------------------------------------------------------------------- /test/tools/inject_test_env.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under both the MIT license found in the 5 | # LICENSE-MIT file in the root directory of this source tree and the Apache 6 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | # of this source tree. 8 | 9 | import argparse 10 | import json 11 | import os 12 | 13 | 14 | def main(): 15 | parser = argparse.ArgumentParser() 16 | parser.add_argument( 17 | "env_file", help="A JSON file containing the environment to inject" 18 | ) 19 | parser.add_argument("executable") 20 | parser.add_argument("args", nargs="*") 21 | 22 | args = parser.parse_args() 23 | 24 | with open(args.env_file) as env_file: 25 | env_from_file = json.load(env_file) 26 | env = {**os.environ, **env_from_file} 27 | 28 | os.execve(args.executable, [args.executable, *args.args], env) 29 | 30 | 31 | if __name__ == "__main__": 32 | main() 33 | -------------------------------------------------------------------------------- /go/tools/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | prelude = native 8 | 9 | prelude.python_bootstrap_binary( 10 | name = "concat_files", 11 | main = "concat_files.py", 12 | visibility = ["PUBLIC"], 13 | ) 14 | 15 | prelude.python_bootstrap_binary( 16 | name = "cgo_wrapper", 17 | main = "cgo_wrapper.py", 18 | visibility = ["PUBLIC"], 19 | ) 20 | 21 | prelude.python_bootstrap_binary( 22 | name = "gen_stdlib_importcfg", 23 | main = "gen_stdlib_importcfg.py", 24 | visibility = ["PUBLIC"], 25 | ) 26 | 27 | prelude.python_bootstrap_binary( 28 | name = "go_wrapper", 29 | main = "go_wrapper.py", 30 | visibility = ["PUBLIC"], 31 | ) 32 | 33 | prelude.go_binary( 34 | name = "testmaingen", 35 | srcs = [ 36 | "testmaingen.go", 37 | ], 38 | visibility = [ 39 | "PUBLIC", 40 | ], 41 | ) 42 | 43 | prelude.go_stdlib( 44 | name = "stdlib", 45 | visibility = ["PUBLIC"], 46 | ) 47 | -------------------------------------------------------------------------------- /utils/dicts.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//utils:expect.bzl", "expect") 9 | 10 | _DEFAULT_FMT = "found different values for key \"{0}\": {} != {}" 11 | 12 | def update_x(dst: dict[typing.Any, typing.Any], k: typing.Any, v: typing.Any, fmt = _DEFAULT_FMT): 13 | p = dst.setdefault(k, v) 14 | expect(p == v, fmt, k, p, v) 15 | 16 | def merge_x(dst: dict[typing.Any, typing.Any], src: dict[typing.Any, typing.Any], fmt = _DEFAULT_FMT): 17 | for k, v in src.items(): 18 | update_x(dst, k, v, fmt = fmt) 19 | 20 | def flatten_x(ds: list[dict[typing.Any, typing.Any]], fmt = _DEFAULT_FMT) -> dict[typing.Any, typing.Any]: 21 | out = {} 22 | for d in ds: 23 | merge_x(out, d, fmt = fmt) 24 | return out 25 | -------------------------------------------------------------------------------- /erlang/common_test/common/include/tpx_records.hrl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) Meta Platforms, Inc. and affiliates. 2 | %% 3 | %% This source code is licensed under both the MIT license found in the 4 | %% LICENSE-MIT file in the root directory of this source tree and the Apache 5 | %% License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | %% of this source tree. 7 | 8 | -record(test_spec_test_info, {name :: string(), filter :: string()}). 9 | 10 | -record(test_spec_test_case, {suite :: string(), testcases :: [#test_spec_test_info{}]}). 11 | 12 | -record(test, { 13 | name :: string(), 14 | suite :: string(), 15 | type :: junit_interfacer:test_result(), 16 | message :: junit_interfacer:optional(string()), 17 | stacktrace :: junit_interfacer:optional(string()), 18 | stdout :: junit_interfacer:optional(string()), 19 | stderr :: junit_interfacer:optional(string()), 20 | time :: junit_interfacer:optional(integer()) 21 | }). 22 | 23 | -record(test_case, { 24 | name :: string(), 25 | tests :: [#test{}] 26 | }). 27 | -------------------------------------------------------------------------------- /apple/swift/swift_toolchain_macro_layer.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def swift_toolchain_macro_impl(swift_toolchain_rule = None, **kwargs): 9 | bitcode = read_root_config("swift", "bitcode") 10 | if bitcode != None: 11 | kwargs["object_format"] = "object" 12 | if bitcode.lower() == "true": 13 | kwargs["object_format"] = "bc" 14 | elif bitcode.lower() == "ir": 15 | kwargs["object_format"] = "ir" 16 | elif bitcode.lower() == "irgen": 17 | kwargs["object_format"] = "irgen" 18 | elif bitcode.lower() in ["embed", "embed-bitcode", "object-embed-bitcode"]: 19 | kwargs["object_format"] = "object-embed-bitcode" 20 | 21 | swift_toolchain_rule( 22 | **kwargs 23 | ) 24 | -------------------------------------------------------------------------------- /apple/tools/selective_debugging/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | load("@prelude//apple/tools/defs.bzl", "meta_python_test") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | python_library( 9 | name = "lib", 10 | srcs = [ 11 | "macho.py", 12 | "macho_parser.py", 13 | "scrubber.py", 14 | "spec.py", 15 | "utils.py", 16 | ], 17 | deps = [ 18 | "prelude//apple/tools/re_compatibility_utils:re_compatibility_utils", 19 | ], 20 | ) 21 | 22 | python_binary( 23 | name = "tool", 24 | main = "main.py", 25 | visibility = ["PUBLIC"], 26 | deps = [ 27 | ":lib", 28 | ], 29 | ) 30 | 31 | meta_python_test( 32 | name = "tests", 33 | srcs = [ 34 | "scrubber_test.py", 35 | "spec_test.py", 36 | ], 37 | resources = glob([ 38 | "test_resources/*", 39 | ]), 40 | deps = [ 41 | "fbsource//third-party/pypi/importlib-resources:importlib-resources", 42 | ":lib", 43 | ], 44 | ) 45 | -------------------------------------------------------------------------------- /erlang/common_test/cth_hooks/src/method_ids.hrl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) Meta Platforms, Inc. and affiliates. 2 | %% 3 | %% This source code is licensed under both the MIT license found in the 4 | %% LICENSE-MIT file in the root directory of this source tree and the Apache 5 | %% License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | %% of this source tree. 7 | 8 | -ifndef(CTH_TPX_METHOD_IDS_HRL). 9 | -define(CTH_TPX_METHOD_IDS, true). 10 | 11 | -define(INIT_PER_SUITE, '[init_per_suite]'). 12 | -define(INIT_PER_GROUP, '[init_per_group]'). 13 | -define(INIT_PER_TESTCASE, '[init_per_testcase]'). 14 | -define(END_PER_TESTCASE, '[end_per_testcase]'). 15 | -define(END_PER_GROUP, '[end_per_group]'). 16 | -define(END_PER_SUITE, '[end_per_suite]'). 17 | -define(MAIN_TESTCASE, '[main_testcase]'). 18 | 19 | -type method_id() :: 20 | ?INIT_PER_SUITE | 21 | ?INIT_PER_GROUP | 22 | ?INIT_PER_TESTCASE | 23 | ?END_PER_TESTCASE | 24 | ?END_PER_GROUP | 25 | ?END_PER_SUITE | 26 | ?MAIN_TESTCASE. 27 | 28 | -endif. % CTH_TPX_METHOD_IDS_HRL 29 | -------------------------------------------------------------------------------- /rust/resources.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load( 9 | "@prelude//:artifacts.bzl", 10 | "ArtifactOutputs", # @unused Used as a type 11 | "single_artifact", 12 | ) 13 | load("@prelude//:paths.bzl", "paths") 14 | load("@prelude//utils:utils.bzl", "from_named_set") 15 | 16 | def rust_attr_resources(ctx: AnalysisContext) -> dict[str, ArtifactOutputs]: 17 | """ 18 | Return the resources provided by this rule, as a map of resource name to 19 | a tuple of the resource artifact and any "other" outputs exposed by it. 20 | """ 21 | resources = {} 22 | 23 | for name, resource in from_named_set(ctx.attrs.resources).items(): 24 | resources[paths.join(ctx.label.package, name)] = single_artifact(resource) 25 | 26 | return resources 27 | -------------------------------------------------------------------------------- /utils/selects.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | _SELECT_TYPE = type(select({"DEFAULT": []})) 9 | 10 | def _is_select(thing): 11 | return type(thing) == _SELECT_TYPE 12 | 13 | def _apply_helper(function, inner): 14 | if not _is_select(inner): 15 | return function(inner) 16 | return _apply(inner, function) 17 | 18 | def _apply(obj, function): 19 | """ 20 | If the object is a select, runs `select_map` with `function`. 21 | Otherwise, if the object is not a select, invokes `function` on `obj` directly. 22 | """ 23 | if not _is_select(obj): 24 | return function(obj) 25 | return select_map( 26 | obj, 27 | partial(_apply_helper, function), 28 | ) 29 | 30 | selects = struct( 31 | apply = _apply, 32 | ) 33 | -------------------------------------------------------------------------------- /toolchains/haskell.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//haskell:toolchain.bzl", "HaskellPlatformInfo", "HaskellToolchainInfo") 9 | 10 | def _system_haskell_toolchain(_ctx: AnalysisContext) -> list[Provider]: 11 | return [ 12 | DefaultInfo(), 13 | HaskellToolchainInfo( 14 | compiler = "ghc", 15 | packager = "ghc-pkg", 16 | linker = "ghc", 17 | haddock = "haddock", 18 | compiler_flags = [], 19 | linker_flags = [], 20 | ), 21 | HaskellPlatformInfo( 22 | name = host_info().arch, 23 | ), 24 | ] 25 | 26 | system_haskell_toolchain = rule( 27 | impl = _system_haskell_toolchain, 28 | attrs = {}, 29 | is_toolchain_rule = True, 30 | ) 31 | -------------------------------------------------------------------------------- /python/tools/sourcedb_merger/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | prelude = native 8 | 9 | prelude.python_bootstrap_library( 10 | name = "library", 11 | srcs = [ 12 | "inputs.py", 13 | "legacy_outputs.py", 14 | "outputs.py", 15 | ], 16 | visibility = ["PUBLIC"], 17 | ) 18 | 19 | prelude.python_bootstrap_binary( 20 | name = "merge", 21 | main = "merge.py", 22 | visibility = ["PUBLIC"], 23 | deps = [ 24 | ":library", 25 | ], 26 | ) 27 | 28 | prelude.python_bootstrap_binary( 29 | name = "legacy_merge", 30 | main = "legacy_merge.py", 31 | visibility = ["PUBLIC"], 32 | deps = [ 33 | ":library", 34 | ], 35 | ) 36 | 37 | # Run the test suite with this command: 38 | # buck2 run prelude//python/tools/sourcedb_merger:tests --target-platforms prelude//platforms:default 39 | prelude.sh_binary( 40 | name = "tests", 41 | main = "tests/main.sh", 42 | resources = glob(["**/*.py"]), 43 | ) 44 | -------------------------------------------------------------------------------- /apple/tools/code_signing/info_plist_metadata.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # pyre-strict 9 | 10 | from __future__ import annotations 11 | 12 | from dataclasses import dataclass 13 | from typing import IO, Optional 14 | 15 | from apple.tools.plistlib_utils import detect_format_and_load 16 | 17 | 18 | @dataclass 19 | class InfoPlistMetadata: 20 | bundle_id: str 21 | bundle_type: Optional[str] 22 | is_watchos_app: bool 23 | 24 | @staticmethod 25 | def from_file(info_plist_file: IO[bytes]) -> InfoPlistMetadata: 26 | root = detect_format_and_load(info_plist_file) 27 | return InfoPlistMetadata( 28 | root["CFBundleIdentifier"], 29 | root.get("CFBundlePackageType"), 30 | root.get("WKApplication", False), 31 | ) 32 | -------------------------------------------------------------------------------- /debugging/inspect_default.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//debugging/common.bzl", "create_target_info", "target_name") 9 | load("@prelude//debugging/ensure_dwp.bzl", "ensure_dwp") 10 | load("@prelude//debugging/types.bzl", "ExecInfo", "ScriptSettings") 11 | 12 | # "inspect_default" is reused across "fdb.bxl" to provide a fallback default information 13 | # in case special handling for the rule type isn't implemented yet 14 | def inspect_default(ctx: bxl.Context, _actions: AnalysisActions, target: bxl.ConfiguredTargetNode, settings: ScriptSettings) -> ExecInfo: 15 | ensure_dwp(ctx, target) 16 | 17 | return ExecInfo( 18 | target_name = target_name(settings.target), 19 | target_info = create_target_info(settings.target), 20 | data = None, 21 | ) 22 | -------------------------------------------------------------------------------- /toolchains/cxx/clang/tools.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//toolchains:cxx.bzl", "CxxToolsInfo") 9 | 10 | def _path_clang_tools_impl(_ctx) -> list[Provider]: 11 | return [ 12 | DefaultInfo(), 13 | CxxToolsInfo( 14 | compiler = "clang", 15 | compiler_type = "clang", 16 | cxx_compiler = "clang++", 17 | asm_compiler = "clang", 18 | asm_compiler_type = "clang", 19 | rc_compiler = None, 20 | cvtres_compiler = None, 21 | archiver = "ar", 22 | archiver_type = "gnu", 23 | linker = "clang++", 24 | linker_type = "gnu", 25 | ), 26 | ] 27 | 28 | path_clang_tools = rule( 29 | impl = _path_clang_tools_impl, 30 | attrs = {}, 31 | ) 32 | -------------------------------------------------------------------------------- /go/tools/concat_files.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | import argparse 9 | import sys 10 | from pathlib import Path 11 | 12 | 13 | def main(argv): 14 | parser = argparse.ArgumentParser(fromfile_prefix_chars="@") 15 | parser.add_argument("--output", required=True, type=Path) 16 | parser.add_argument("files", type=Path, nargs="*") 17 | args = parser.parse_args(argv[1:]) 18 | 19 | if len(args.files) == 0: 20 | print( 21 | "usage: concat_files.py --output out.txt in1.txt in2.txt", file=sys.stderr 22 | ) 23 | return 1 24 | 25 | with open(args.output, "wb") as outfile: 26 | for f in args.files: 27 | with open(f, "rb") as infile: 28 | outfile.write(infile.read()) 29 | 30 | return 0 31 | 32 | 33 | sys.exit(main(sys.argv)) 34 | -------------------------------------------------------------------------------- /BUCK: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | load(":native.bzl", prelude = "native") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | # Done to avoid triggering a lint rule that replaces glob with an fbcode macro 9 | globby = glob 10 | 11 | srcs = globby( 12 | ["**"], 13 | # Context: https://fb.workplace.com/groups/buck2users/posts/3121903854732641/ 14 | exclude = ["**/.pyre_configuration.local"], 15 | ) 16 | 17 | # Re-export filegroups that are behind package boundary violations for 18 | # Buck2. 19 | prelude.filegroup( 20 | name = "files", 21 | srcs = srcs, 22 | visibility = ["PUBLIC"], 23 | ) 24 | 25 | # Tests want BUCK.v2 instead of TARGETS.v2 26 | prelude.genrule( 27 | name = "copy_android_constraint", 28 | out = "BUCK.v2", 29 | cmd = "cp $(location prelude//android/constraints:files)/TARGETS.v2 $OUT", 30 | visibility = ["PUBLIC"], 31 | ) 32 | 33 | prelude.filegroup( 34 | name = "prelude", 35 | srcs = { 36 | "": ":files", 37 | "android/constraints/BUCK.v2": ":copy_android_constraint", 38 | }, 39 | visibility = ["PUBLIC"], 40 | ) 41 | -------------------------------------------------------------------------------- /cxx/debug.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # Model the various "split" debug scenarios (e.g. `-gsplit-dwarf`). 9 | SplitDebugMode = enum( 10 | # Debug info, if present, is inline in the object file, and will be linked 11 | # into executables and shared libraries (e.g. traditional behavior when 12 | # using `-g`). 13 | "none", 14 | # Debug info. if present is included in the object file, but will *not* be 15 | # linked into executables and shared libraries. This style usually requires 16 | # an additional step, separate from the link, to combine and package debug 17 | # info (e.g. `dSYM`, `dwp`). 18 | "single", 19 | # FIXME(agallagher): Add support for "split", which probably just requires 20 | # modifying `compile_cxx` to add a `.dwo` file as a hidden output in this 21 | # case. 22 | #"split", 23 | ) 24 | -------------------------------------------------------------------------------- /buck2_compatibility.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | Buck2Compatibility = enum( 9 | "unknown", # No warnings or failures, default state 10 | "compatible", # Compatible with Buck2, Buck1 will show warning to migrate to Buck2 11 | "incompatible", # Incompatible with Buck2, Buck2 will show warning about correctness of result 12 | "required", # Buck2 required, Buck1 will fail the build 13 | ) 14 | 15 | BUCK2_COMPATIBILITY_ATTRIB_NAME = "buck2_compatibility" 16 | BUCK2_COMPATIBILITY_ATTRIB_TYPE = attrs.enum(Buck2Compatibility.values(), default = "unknown") 17 | 18 | def check_buck2_compatibility(ctx: AnalysisContext): 19 | if hasattr(ctx.attrs, "buck2_compatibility") and ctx.attrs.buck2_compatibility == "incompatible": 20 | warning("The target '{}' is marked as incompatible with buck2, output might be incorrect".format(ctx.label)) 21 | -------------------------------------------------------------------------------- /test_suite.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def test_suite_impl(ctx: AnalysisContext) -> list[Provider]: 9 | # There is nothing to implement here: test_suite exists as a mechanism to "group" tests using 10 | # the `tests` attribute, and the `tests` attribute is supported for all rules. 11 | # We fill in the DefaultInfo so building the test_suite will build all the underlying test rules. 12 | test_targets = [] 13 | other_outputs = [] 14 | for test_dep in ctx.attrs.test_deps: 15 | test_targets.append(test_dep.label.raw_target()) 16 | default_info = test_dep[DefaultInfo] 17 | other_outputs.extend(default_info.default_outputs) 18 | other_outputs.extend(default_info.other_outputs) 19 | return [DefaultInfo(default_outputs = [ctx.actions.write("test_targets.txt", test_targets)], other_outputs = other_outputs)] 20 | -------------------------------------------------------------------------------- /erlang/common_test/test_cli_lib/test/test_cli_e2e_SUITE.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) Meta Platforms, Inc. and affiliates. 2 | %% This source code is licensed under both the MIT license found in the 3 | %% LICENSE-MIT file in the root directory of this source tree and the Apache 4 | %% License, Version 2.0 found in the LICENSE-APACHE file in the root directory 5 | %% of this source tree. 6 | %%% % @format 7 | -module(test_cli_e2e_SUITE). 8 | 9 | -include_lib("stdlib/include/assert.hrl"). 10 | 11 | -export([all/0]). 12 | 13 | -export([ 14 | test_list/1 15 | ]). 16 | 17 | all() -> 18 | [test_list]. 19 | 20 | test_list(_Config) -> 21 | Expected = 22 | "test_cli_e2e_SUITE:\n" 23 | "test_list_SUITE:\n" 24 | "\t1 - test_list_SUITE - .test_pass\n" 25 | "\t2 - test_list_SUITE - default.test_fail\n", 26 | ?assertEqual({ok, Expected}, test:list_impl("test_list_SUITE")), 27 | 28 | ?assertMatch({error, {invalid_regex, _}}, test:list_impl("^[a")), 29 | 30 | EmptyExpected = 31 | "test_cli_e2e_SUITE:\n" 32 | "test_list_SUITE:\n", 33 | ?assertEqual({ok, EmptyExpected}, test:list_impl("does_not_exist_SUITE")). 34 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Meta Platforms, Inc. and affiliates. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /erlang/common_test/test_exec/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | erlang_application( 8 | name = "test_exec", 9 | srcs = glob([ 10 | "src/*.erl", 11 | "src/*.hrl", 12 | ]), 13 | app_src = "src/test_exec.app.src", 14 | applications = [ 15 | "kernel", 16 | "stdlib", 17 | "debugger", 18 | "prelude//erlang/common_test/common:common", 19 | "prelude//erlang/common_test/cth_hooks:cth_hooks", 20 | ], 21 | erl_opts = [ 22 | "+debug_info", 23 | "+warnings_as_errors", 24 | ], 25 | includes = glob(["include/*.hrl"]), 26 | mod = ("test_exec", []), 27 | resources = read_root_config("erlang", "erlang_tests_default_config", "").split(), 28 | shell_libs = [], 29 | use_global_parse_transforms = False, 30 | visibility = ["PUBLIC"], 31 | ) 32 | 33 | erlang_tests( 34 | contacts = ["whatsapp_testing_infra"], 35 | labels = ["unit"], 36 | suites = ["test/ct_executor_SUITE.erl"], 37 | deps = [ 38 | "stdlib", 39 | ":test_exec", 40 | ], 41 | ) 42 | -------------------------------------------------------------------------------- /rust/tools/attrs.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def _internal_tool(default: str) -> Attr: 9 | return attrs.default_only(attrs.exec_dep(providers = [RunInfo], default = default)) 10 | 11 | # Factored out of prelude//toolchains/rust.bzl to keep only the user-facing 12 | # configurable attributes there. This list of internal tools is distracting and 13 | # expected to grow. 14 | internal_tool_attrs = { 15 | "failure_filter_action": _internal_tool("prelude//rust/tools:failure_filter_action"), 16 | "rustc_action": _internal_tool("prelude//rust/tools:rustc_action"), 17 | "rustdoc_coverage": _internal_tool("prelude//rust/tools:rustdoc_coverage"), 18 | "rustdoc_test_with_resources": _internal_tool("prelude//rust/tools:rustdoc_test_with_resources"), 19 | "transitive_dependency_symlinks_tool": _internal_tool("prelude//rust/tools:transitive_dependency_symlinks"), 20 | } 21 | -------------------------------------------------------------------------------- /cpu/constraints/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | # Used by open source projects to support `prelude//` 8 | 9 | constraint_setting( 10 | name = "cpu", 11 | visibility = ["PUBLIC"], 12 | ) 13 | 14 | constraint_value( 15 | name = "x86_64", 16 | constraint_setting = ":cpu", 17 | visibility = ["PUBLIC"], 18 | ) 19 | 20 | constraint_value( 21 | name = "x86_32", 22 | constraint_setting = ":cpu", 23 | visibility = ["PUBLIC"], 24 | ) 25 | 26 | # Represents various flavors of ARM64, e.g., arm64_32 27 | constraint_value( 28 | name = "arm64", 29 | constraint_setting = ":cpu", 30 | visibility = ["PUBLIC"], 31 | ) 32 | 33 | constraint_value( 34 | name = "arm64_32", 35 | constraint_setting = ":cpu", 36 | visibility = ["PUBLIC"], 37 | ) 38 | 39 | # Represents various flavors of ARM32, e.g., ARMv7k 40 | constraint_value( 41 | name = "arm32", 42 | constraint_setting = ":cpu", 43 | visibility = ["PUBLIC"], 44 | ) 45 | 46 | constraint_value( 47 | name = "wasm32", 48 | constraint_setting = ":cpu", 49 | visibility = ["PUBLIC"], 50 | ) 51 | -------------------------------------------------------------------------------- /apple/tools/bundling/test_resources/valid_incremental_state.json: -------------------------------------------------------------------------------- 1 | { 2 | "items": [ 3 | { 4 | "source": "repo/foo.txt", 5 | "destination_relative_to_bundle": "foo.txt", 6 | "digest": "foo_digest" 7 | }, 8 | { 9 | "source": "buck-out/bar.txt", 10 | "destination_relative_to_bundle": "Resources/bar.txt", 11 | "digest": "bar_digest" 12 | }, 13 | { 14 | "source": "buck-out/bar", 15 | "destination_relative_to_bundle": "Resources/bar", 16 | "resolved_symlink": "bar.txt" 17 | } 18 | ], 19 | "codesign_configuration": null, 20 | "codesigned": true, 21 | "codesigned_on_copy": [ 22 | { 23 | "path": "Resources/bar.txt" 24 | }, 25 | { 26 | "path": "Resources/baz.txt", 27 | "entitlements_digest": "abc" 28 | }, 29 | { 30 | "path": "Resources/qux.txt", 31 | "codesign_flags_override": ["--deep", "--force"] 32 | } 33 | ], 34 | "codesign_identity": "Johny Appleseed", 35 | "codesign_arguments": [ 36 | "--force", 37 | "--deep" 38 | ], 39 | "versioned_if_macos": true, 40 | "swift_stdlib_paths": [ 41 | "Frameworks/libswiftCore.dylib" 42 | ], 43 | "version": 7 44 | } 45 | -------------------------------------------------------------------------------- /apple/tools/bundling/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | load("@prelude//apple/tools/defs.bzl", "meta_python_test") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | python_binary( 9 | name = "assemble_bundle", 10 | main = "main.py", 11 | visibility = ["PUBLIC"], 12 | deps = [ 13 | "prelude//apple/tools/code_signing:lib", 14 | "prelude//apple/tools/re_compatibility_utils:re_compatibility_utils", 15 | ":lib", 16 | ], 17 | ) 18 | 19 | python_library( 20 | name = "lib", 21 | srcs = glob( 22 | [ 23 | "*.py", 24 | ], 25 | exclude = [ 26 | "*_test.py", 27 | "main.py", 28 | ], 29 | ), 30 | deps = [ 31 | "prelude//apple/tools/code_signing:lib", 32 | "prelude//apple/tools/re_compatibility_utils:re_compatibility_utils", 33 | ], 34 | ) 35 | 36 | meta_python_test( 37 | name = "bundling_test", 38 | srcs = glob(["*_test.py"]), 39 | resources = glob([ 40 | "test_resources/*", 41 | ]), 42 | deps = [ 43 | "fbsource//third-party/pkg_resources:pkg_resources", 44 | ":lib", 45 | ], 46 | ) 47 | -------------------------------------------------------------------------------- /cxx/cxx_toolchain_macro_layer.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def cxx_toolchain_macro_impl(cxx_toolchain_rule = None, **kwargs): 9 | # `cxx.linker_map_enabled` overrides toolchain behavior 10 | if "generate_linker_maps" not in kwargs: 11 | linker_map_enabled = read_root_config("cxx", "linker_map_enabled", "") 12 | kwargs["generate_linker_maps"] = linker_map_enabled.lower() == "true" 13 | 14 | bitcode = read_root_config("cxx", "bitcode") 15 | if bitcode != None: 16 | if bitcode.lower() == "false": 17 | kwargs["object_format"] = "native" 18 | elif bitcode.lower() == "true": 19 | kwargs["object_format"] = "bitcode" 20 | elif bitcode.lower() == "embed": 21 | kwargs["object_format"] = "embedded-bitcode" 22 | else: 23 | kwargs["object_format"] = "native" 24 | 25 | cxx_toolchain_rule( 26 | **kwargs 27 | ) 28 | -------------------------------------------------------------------------------- /go/tools/gen_stdlib_importcfg.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | import argparse 9 | import os 10 | import sys 11 | from pathlib import Path 12 | 13 | 14 | def main(argv): 15 | parser = argparse.ArgumentParser() 16 | parser.add_argument("--stdlib", type=Path, default=None) 17 | parser.add_argument("--output", type=Path, default=None) 18 | 19 | args = parser.parse_args() 20 | 21 | with open(args.output, "w") as f: 22 | for root, _dirs, files in os.walk(args.stdlib): 23 | for file in files: 24 | pkg_path = Path(root, file) 25 | pkg_name, _ = os.path.splitext(pkg_path.relative_to(args.stdlib)) 26 | # package names always use unix slashes 27 | pkg_name = pkg_name.replace("\\", "/") 28 | f.write(f"packagefile {pkg_name}={pkg_path}\n") 29 | 30 | 31 | if __name__ == "__main__": 32 | sys.exit(main(sys.argv)) 33 | -------------------------------------------------------------------------------- /http_archive/exec_deps.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | HttpArchiveExecDeps = provider(fields = { 9 | "create_exclusion_list": provider_field(typing.Any, default = None), 10 | "exec_os_type": provider_field(typing.Any, default = None), 11 | }) 12 | 13 | def _http_archive_exec_deps_impl(ctx: AnalysisContext) -> list[Provider]: 14 | return [ 15 | DefaultInfo(), 16 | HttpArchiveExecDeps( 17 | create_exclusion_list = ctx.attrs.create_exclusion_list, 18 | exec_os_type = ctx.attrs.exec_os_type, 19 | ), 20 | ] 21 | 22 | http_archive_exec_deps = rule( 23 | impl = _http_archive_exec_deps_impl, 24 | attrs = { 25 | "create_exclusion_list": attrs.default_only(attrs.dep(default = "prelude//http_archive/tools:create_exclusion_list")), 26 | "exec_os_type": attrs.default_only(attrs.dep(default = "prelude//os_lookup/targets:os_lookup")), 27 | }, 28 | ) 29 | -------------------------------------------------------------------------------- /python/sourcedb/merge.bxl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def do_merge( 9 | ctx: bxl.Context, 10 | bxl_actions: bxl.Actions, 11 | built_sourcedbs: dict[TargetLabel, Artifact], 12 | command_category: str) -> bxl.EnsuredArtifact: 13 | actions = bxl_actions.actions 14 | 15 | merger_input = actions.write_json("merge_input.json", built_sourcedbs) 16 | merger_output = actions.declare_output("merged_db.json") 17 | 18 | dependency_key = bxl_actions.exec_deps.keys()[0] 19 | 20 | command = cmd_args( 21 | bxl_actions.exec_deps[dependency_key][RunInfo], 22 | merger_input, 23 | "--output", 24 | merger_output.as_output(), 25 | # Declare that the merger result depends on all sourcedbs 26 | hidden = built_sourcedbs.values(), 27 | ) 28 | 29 | actions.run(command, category = command_category) 30 | return ctx.output.ensure(merger_output) 31 | -------------------------------------------------------------------------------- /third-party/tools/create_build.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import shutil 3 | import json 4 | import sys 5 | import os 6 | 7 | 8 | def main(argv): 9 | parser = argparse.ArgumentParser(fromfile_prefix_chars="@") 10 | parser.add_argument( 11 | "--manifest", dest="manifests", nargs=2, action="append", default=[] 12 | ) 13 | parser.add_argument("--path", dest="paths", nargs=2, action="append", default=[]) 14 | parser.add_argument("output") 15 | args = parser.parse_args(argv[1:]) 16 | 17 | os.makedirs(args.output) 18 | 19 | all_paths = [] 20 | all_paths.extend(args.paths) 21 | 22 | for bdst, manifest in args.manifests: 23 | with open(manifest) as mf: 24 | manifest = json.load(mf) 25 | for dst, src, _ in manifest: 26 | dst = os.path.join(bdst, dst) 27 | all_paths.append((dst, src)) 28 | 29 | for dst, src in all_paths: 30 | fdst = os.path.join(args.output, dst) 31 | os.makedirs(os.path.dirname(fdst), exist_ok=True) 32 | if os.path.isdir(src): 33 | shutil.copytree(src, fdst, symlinks=True, dirs_exist_ok=True) 34 | else: 35 | shutil.copy(src, fdst) 36 | 37 | 38 | sys.exit(main(sys.argv)) 39 | -------------------------------------------------------------------------------- /python/tools/sourcedb_merger/legacy_merge.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fbpython 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under both the MIT license found in the 5 | # LICENSE-MIT file in the root directory of this source tree and the Apache 6 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | # of this source tree. 8 | 9 | # pyre-strict 10 | 11 | 12 | import argparse 13 | import pathlib 14 | import sys 15 | 16 | from typing import Sequence 17 | 18 | import inputs 19 | import legacy_outputs 20 | 21 | 22 | def run_merge(input_file: str, output_file: str) -> None: 23 | target_entries = inputs.load_targets_and_build_maps_from_path(input_file) 24 | merge_result = legacy_outputs.merge_partial_build_maps(target_entries) 25 | merge_result.write_json_file(pathlib.Path(output_file)) 26 | 27 | 28 | def main(argv: Sequence[str]) -> None: 29 | parser = argparse.ArgumentParser() 30 | parser.add_argument("input", type=str) 31 | parser.add_argument("-o", "--output", required=True, type=str) 32 | arguments = parser.parse_args(argv[1:]) 33 | 34 | run_merge(arguments.input, arguments.output) 35 | 36 | 37 | if __name__ == "__main__": 38 | main(sys.argv) 39 | -------------------------------------------------------------------------------- /python/tools/sourcedb_merger/merge.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env fbpython 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under both the MIT license found in the 5 | # LICENSE-MIT file in the root directory of this source tree and the Apache 6 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | # of this source tree. 8 | 9 | # pyre-strict 10 | 11 | 12 | import argparse 13 | import pathlib 14 | import sys 15 | 16 | from typing import Sequence 17 | 18 | import inputs 19 | import outputs 20 | 21 | 22 | def run_merge(input_file: str, output_file: str) -> None: 23 | target_entries = inputs.load_targets_and_build_maps_from_path(input_file) 24 | merged_build_map = outputs.merge_partial_build_maps(target_entries) 25 | merged_build_map.write_build_map_json_file(pathlib.Path(output_file)) 26 | 27 | 28 | def main(argv: Sequence[str]) -> None: 29 | parser = argparse.ArgumentParser() 30 | parser.add_argument("input", type=str) 31 | parser.add_argument("-o", "--output", required=True, type=str) 32 | arguments = parser.parse_args(argv[1:]) 33 | 34 | run_merge(arguments.input, arguments.output) 35 | 36 | 37 | if __name__ == "__main__": 38 | main(sys.argv) 39 | -------------------------------------------------------------------------------- /erlang/common_test/test_binary/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | erlang_escript( 8 | name = "escript", 9 | emu_args = [ 10 | "+A0", 11 | "+S1:1", 12 | "+sbtu", 13 | "-mode minimal", 14 | ], 15 | # magic label special-cased by tooling to make vendored json available 16 | labels = ["erlang_test_runner"], 17 | main_module = "test_binary", 18 | visibility = ["PUBLIC"], 19 | deps = [ 20 | ":test_binary", 21 | ], 22 | ) 23 | 24 | erlang_application( 25 | name = "test_binary", 26 | srcs = glob([ 27 | "src/*.erl", 28 | "src/*.hrl", 29 | ]), 30 | applications = [ 31 | "kernel", 32 | "stdlib", 33 | "syntax_tools", 34 | "xmerl", 35 | "prelude//erlang/common_test/common:common", 36 | "prelude//erlang/common_test/cth_hooks:cth_hooks", 37 | "prelude//erlang/common_test/test_exec:test_exec", 38 | ], 39 | erl_opts = [ 40 | "+debug_info", 41 | "+warnings_as_errors", 42 | ], 43 | includes = glob(["include/*.hrl"]), 44 | use_global_parse_transforms = False, 45 | visibility = ["PUBLIC"], 46 | ) 47 | -------------------------------------------------------------------------------- /configurations/util.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def _configuration_info_union(infos): 9 | if len(infos) == 0: 10 | return ConfigurationInfo( 11 | constraints = {}, 12 | values = {}, 13 | ) 14 | if len(infos) == 1: 15 | return infos[0] 16 | constraints = {k: v for info in infos for (k, v) in info.constraints.items()} 17 | values = {k: v for info in infos for (k, v) in info.values.items()} 18 | return ConfigurationInfo( 19 | constraints = constraints, 20 | values = values, 21 | ) 22 | 23 | def _constraint_values_to_configuration(values): 24 | return ConfigurationInfo(constraints = { 25 | info[ConstraintValueInfo].setting.label: info[ConstraintValueInfo] 26 | for info in values 27 | }, values = {}) 28 | 29 | util = struct( 30 | configuration_info_union = _configuration_info_union, 31 | constraint_values_to_configuration = _constraint_values_to_configuration, 32 | ) 33 | -------------------------------------------------------------------------------- /rust/tools/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | load(":tool_rules.bzl", "get_rustc_cfg") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | prelude = native 9 | 10 | get_rustc_cfg( 11 | name = "rustc_cfg", 12 | visibility = ["PUBLIC"], 13 | ) 14 | 15 | prelude.python_bootstrap_binary( 16 | name = "rustc_action", 17 | main = "rustc_action.py", 18 | visibility = ["PUBLIC"], 19 | ) 20 | 21 | prelude.python_bootstrap_binary( 22 | name = "rustdoc_test_with_resources", 23 | main = "rustdoc_test_with_resources.py", 24 | visibility = ["PUBLIC"], 25 | ) 26 | 27 | prelude.python_bootstrap_binary( 28 | name = "failure_filter_action", 29 | main = "failure_filter_action.py", 30 | visibility = ["PUBLIC"], 31 | ) 32 | 33 | prelude.python_bootstrap_binary( 34 | name = "transitive_dependency_symlinks", 35 | main = "transitive_dependency_symlinks.py", 36 | visibility = ["PUBLIC"], 37 | ) 38 | 39 | prelude.python_bootstrap_binary( 40 | name = "buildscript_run", 41 | main = "buildscript_run.py", 42 | visibility = ["PUBLIC"], 43 | ) 44 | 45 | prelude.python_bootstrap_binary( 46 | name = "rustdoc_coverage", 47 | main = "rustdoc_coverage.py", 48 | visibility = ["PUBLIC"], 49 | ) 50 | -------------------------------------------------------------------------------- /alias.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # Implementation of aliases build rules. 9 | 10 | def alias_impl(ctx: AnalysisContext) -> list[Provider]: 11 | return ctx.attrs.actual.providers 12 | 13 | def configured_alias_impl(ctx: AnalysisContext) -> list[Provider]: 14 | if ctx.attrs.configured_actual != None and ctx.attrs.fallback_actual != None: 15 | fail("cannot set both of `configured_actual` and `fallback_actual`") 16 | if ctx.attrs.configured_actual != None: 17 | return ctx.attrs.configured_actual.providers 18 | if ctx.attrs.fallback_actual != None: 19 | return ctx.attrs.fallback_actual.providers 20 | fail("must set one of `configured_actual` or `fallback_actual`") 21 | 22 | def toolchain_alias_impl(ctx: AnalysisContext) -> list[Provider]: 23 | return ctx.attrs.actual.providers 24 | 25 | def versioned_alias_impl(_ctx: AnalysisContext) -> list[Provider]: 26 | # Should be intercepted in macro stub and converted to `alias`. 27 | fail("unsupported") 28 | -------------------------------------------------------------------------------- /toolchains/remote_test_execution.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//decls:re_test_common.bzl", "re_test_common") 9 | load("@prelude//tests:remote_test_execution_toolchain.bzl", "RemoteTestExecutionToolchainInfo") 10 | load("@prelude//utils:utils.bzl", "map_val") 11 | 12 | def _impl(ctx: AnalysisContext) -> list[Provider]: 13 | return [ 14 | DefaultInfo(), 15 | RemoteTestExecutionToolchainInfo( 16 | default_profile = map_val(ctx.attrs.profiles.get, ctx.attrs.default_profile), 17 | profiles = ctx.attrs.profiles, 18 | ), 19 | ] 20 | 21 | remote_test_execution_toolchain = rule( 22 | impl = _impl, 23 | is_toolchain_rule = True, 24 | attrs = { 25 | "default_profile": attrs.option(attrs.string(), default = None), 26 | "profiles": attrs.dict( 27 | key = attrs.string(), 28 | value = attrs.option(re_test_common.opts_for_tests_arg()), 29 | default = {}, 30 | ), 31 | }, 32 | ) 33 | -------------------------------------------------------------------------------- /kotlin/kotlin_test.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//java:java_test.bzl", "build_junit_test") 9 | load("@prelude//kotlin:kotlin_library.bzl", "build_kotlin_library") 10 | load("@prelude//test/inject_test_run_info.bzl", "inject_test_run_info") 11 | 12 | def kotlin_test_impl(ctx: AnalysisContext) -> list[Provider]: 13 | if ctx.attrs._build_only_native_code: 14 | return [DefaultInfo()] 15 | 16 | java_providers = build_kotlin_library(ctx, ctx.attrs.srcs) 17 | external_runner_test_info = build_junit_test(ctx, java_providers.java_library_info, java_providers.java_packaging_info, java_providers.class_to_src_map) 18 | 19 | return inject_test_run_info(ctx, external_runner_test_info) + [ 20 | java_providers.java_library_intellij_info, 21 | java_providers.java_library_info, 22 | java_providers.java_packaging_info, 23 | java_providers.template_placeholder_info, 24 | java_providers.default_info, 25 | java_providers.class_to_src_map, 26 | ] 27 | -------------------------------------------------------------------------------- /apple/tools/resource_broker/idb_target.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # pyre-strict 9 | 10 | import json 11 | from dataclasses import dataclass 12 | from enum import Enum 13 | from typing import List, Optional 14 | 15 | from dataclasses_json import dataclass_json 16 | 17 | 18 | class SimState(str, Enum): 19 | booted = "Booted" 20 | shutdown = "Shutdown" 21 | 22 | 23 | @dataclass_json 24 | @dataclass 25 | class IdbTarget: 26 | name: str 27 | os_version: str 28 | udid: str 29 | state: SimState 30 | host: str = "" 31 | port: int = 0 32 | 33 | 34 | @dataclass 35 | class SimulatorInfo: 36 | udid: str 37 | device_set_path: str 38 | 39 | 40 | def managed_simulators_from_stdout(stdout: Optional[str]) -> List[IdbTarget]: 41 | if not stdout: 42 | return [] 43 | targets = map( 44 | # pyre-ignore[16]: `from_dict` is dynamically provided by `dataclass_json` 45 | IdbTarget.from_dict, 46 | json.loads(stdout), 47 | ) 48 | return list(targets) 49 | -------------------------------------------------------------------------------- /http_archive/tools/create_exclusion_list.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under both the MIT license found in the 5 | # LICENSE-MIT file in the root directory of this source tree and the Apache 6 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | # of this source tree. 8 | 9 | import argparse 10 | import re 11 | import subprocess 12 | 13 | 14 | def main() -> None: 15 | parser = argparse.ArgumentParser() 16 | parser.add_argument("--tar-flag", action="append", default=[]) 17 | parser.add_argument("--tar-archive") 18 | parser.add_argument("--exclude", action="append") 19 | parser.add_argument("--out") 20 | args = parser.parse_args() 21 | 22 | exclusions = [re.compile(e) for e in args.exclude] 23 | files = subprocess.check_output( 24 | ["tar", "--list", "-f", args.tar_archive] + args.tar_flag, encoding="utf-8" 25 | ) 26 | files = [f.strip() for f in files.split()] 27 | 28 | with open(args.out, "w", encoding="utf-8") as out: 29 | for f in files: 30 | if all(excl.match(f) is None for excl in exclusions): 31 | continue 32 | out.write("{}\n".format(f)) 33 | 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /apple/tools/code_signing/read_provisioning_profile_command_factory.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # pyre-strict 9 | 10 | from abc import ABCMeta, abstractmethod 11 | from pathlib import Path 12 | from typing import List, Union 13 | 14 | 15 | class IReadProvisioningProfileCommandFactory(metaclass=ABCMeta): 16 | @abstractmethod 17 | def read_provisioning_profile_command(self, path: Path) -> List[Union[str, Path]]: 18 | raise NotImplementedError 19 | 20 | 21 | class DefaultReadProvisioningProfileCommandFactory( 22 | IReadProvisioningProfileCommandFactory 23 | ): 24 | # See `DEFAULT_READ_COMMAND` in `AppleConfig.java` in Buck v1 25 | _command = [ 26 | "openssl", 27 | "smime", 28 | "-inform", 29 | "der", 30 | "-verify", 31 | "-noverify", 32 | "-nosigs", 33 | "-in", 34 | ] 35 | 36 | def read_provisioning_profile_command(self, path: Path) -> List[Union[str, Path]]: 37 | return DefaultReadProvisioningProfileCommandFactory._command + [path] 38 | -------------------------------------------------------------------------------- /decls/lua_common.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # TODO(cjhopman): This was generated by scripts/hacks/rules_shim_with_docs.py, 9 | # but should be manually edited going forward. There may be some errors in 10 | # the generated docs, and so those should be verified to be accurate and 11 | # well-formatted (and then delete this TODO) 12 | 13 | def _srcs_arg(): 14 | return { 15 | "srcs": attrs.named_set(attrs.source(), sorted = True, default = [], doc = """ 16 | The set of `.lua` files included in this library. 17 | """), 18 | } 19 | 20 | def _base_module_arg(): 21 | return { 22 | "base_module": attrs.option(attrs.string(), default = None, doc = """ 23 | The package for which the given specified sources and resources should reside in their final 24 | location in the top-level binary. If unset, the project relative directory that houses the 25 | BUCK file is used. 26 | """), 27 | } 28 | 29 | lua_common = struct( 30 | srcs_arg = _srcs_arg, 31 | base_module_arg = _base_module_arg, 32 | ) 33 | -------------------------------------------------------------------------------- /rust/rust-analyzer/check.bxl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def check_targets_impl(ctx: BxlContext) -> None: 9 | target_universe = ctx.uquery().owner(ctx.cli_args.file) 10 | owners = ctx.cquery().owner(ctx.cli_args.file, target_universe) 11 | nodes = ctx.cquery().kind("^(rust_binary|rust_library|rust_test)$", owners) 12 | 13 | if len(nodes) == 0: 14 | return 15 | 16 | diag_kind = "clippy.json" if ctx.cli_args.use_clippy else "diag.json" 17 | build_result = ctx.build([ 18 | node.label.with_sub_target(diag_kind) 19 | for node in nodes 20 | ]) 21 | 22 | dict_output = ctx.output.ensure_multiple(build_result) 23 | 24 | out = [ 25 | artifacts[0].abs_path() 26 | for artifacts in dict_output.values() 27 | if len(artifacts) == 1 28 | ] 29 | 30 | ctx.output.print_json(out) 31 | 32 | check = bxl_main( 33 | impl = check_targets_impl, 34 | cli_args = { 35 | "file": cli_args.string(), 36 | "use-clippy": cli_args.bool(), 37 | }, 38 | ) 39 | -------------------------------------------------------------------------------- /go/tools/cgo_wrapper.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under both the MIT license found in the 5 | # LICENSE-MIT file in the root directory of this source tree and the Apache 6 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | # of this source tree. 8 | 9 | # pyre-unsafe 10 | 11 | import argparse 12 | import os 13 | import subprocess 14 | import sys 15 | from pathlib import Path 16 | 17 | 18 | def main(argv): 19 | parser = argparse.ArgumentParser(fromfile_prefix_chars="@") 20 | parser.add_argument("--cgo", action="append", default=[]) 21 | parser.add_argument("--output", required=True, type=Path) 22 | parser.add_argument("srcs", type=Path, nargs="*") 23 | args = parser.parse_args(argv[1:]) 24 | 25 | output = args.output.resolve(strict=False) 26 | # the only reason we need this whapper is to create `-objdir`, 27 | # because neither `go tool cgo` nor buck can create it. 28 | os.makedirs(output, exist_ok=True) 29 | 30 | env = os.environ.copy() 31 | 32 | cmd = [] 33 | cmd.extend(args.cgo) 34 | cmd.append(f"-objdir={output}") 35 | cmd.append("--") 36 | 37 | cmd.extend(args.srcs) 38 | return subprocess.call(cmd, env=env) 39 | 40 | 41 | sys.exit(main(sys.argv)) 42 | -------------------------------------------------------------------------------- /rust/targets.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//os_lookup:defs.bzl", "OsLookup") 9 | load("@prelude//decls/core_rules.bzl", "Platform", "TargetCpuType") 10 | 11 | _platform = enum(*Platform) 12 | _cpu = enum(*TargetCpuType) 13 | 14 | _OS_TRIPLES = { 15 | (_platform("linux"), _cpu("arm64")): "aarch64-unknown-linux-gnu", 16 | (_platform("linux"), _cpu("x86_64")): "x86_64-unknown-linux-gnu", 17 | (_platform("macos"), _cpu("arm64")): "aarch64-apple-darwin", 18 | (_platform("macos"), _cpu("x86_64")): "x86_64-apple-darwin", 19 | (_platform("windows"), _cpu("arm64")): "aarch64-pc-windows-msvc", 20 | (_platform("windows"), _cpu("x86_64")): "x86_64-pc-windows-msvc", 21 | } 22 | 23 | def _exec_triple(ctx: AnalysisContext) -> [str, None]: 24 | exec_os = ctx.attrs._exec_os_type[OsLookup] 25 | if exec_os.platform and exec_os.cpu: 26 | return _OS_TRIPLES.get((_platform(exec_os.platform), _cpu(exec_os.cpu))) 27 | else: 28 | return None 29 | 30 | targets = struct( 31 | exec_triple = _exec_triple, 32 | ) 33 | -------------------------------------------------------------------------------- /rust/tools/tool_rules.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//rust:rust_toolchain.bzl", "RustToolchainInfo") 9 | load("@prelude//decls/toolchains_common.bzl", "toolchains_common") 10 | 11 | def _get_rustc_cfg_impl(ctx: AnalysisContext) -> list[Provider]: 12 | toolchain_info = ctx.attrs._rust_toolchain[RustToolchainInfo] 13 | 14 | out = ctx.actions.declare_output("rustc.cfg") 15 | 16 | cmd = [ 17 | toolchain_info.compiler, 18 | cmd_args("--print=cfg=", out.as_output(), delimiter = ""), 19 | cmd_args("--target=", toolchain_info.rustc_target_triple, delimiter = ""), 20 | cmd_args("--sysroot="), # We do not need a sysroot here, and not all platforms we support have one available (e.g. mips64-unknown-linux-gnuabi64) 21 | ] 22 | 23 | ctx.actions.run(cmd, category = "rustc_cfg") 24 | 25 | return [DefaultInfo(default_output = out)] 26 | 27 | get_rustc_cfg = rule( 28 | impl = _get_rustc_cfg_impl, 29 | attrs = { 30 | "_rust_toolchain": toolchains_common.rust(), 31 | }, 32 | ) 33 | -------------------------------------------------------------------------------- /cxx/cxx_utility.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def cxx_attrs_get_allow_cache_upload(attrs: struct, default: [None, bool] = None) -> bool: 9 | default_value = default if default != None else False 10 | if not hasattr(attrs, "allow_cache_upload"): 11 | return default_value 12 | value = attrs.allow_cache_upload 13 | return value if value != None else default_value 14 | 15 | def cxx_toolchain_allow_cache_upload_args(): 16 | doc = """ 17 | Whether to allow uploading of object files to cache when the compile 18 | action is executed locally and the configuration allows uploads (i.e., 19 | there is a cache configured and the client has permission to write to it). 20 | """ 21 | return { 22 | "c_compiler_allow_cache_upload": attrs.option( 23 | attrs.bool(), 24 | default = None, 25 | doc = doc, 26 | ), 27 | "cxx_compiler_allow_cache_upload": attrs.option( 28 | attrs.bool(), 29 | default = None, 30 | doc = doc, 31 | ), 32 | } 33 | -------------------------------------------------------------------------------- /debugging/inspect_java.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//debugging/common.bzl", "create_target_info", "target_name") 9 | load("@prelude//debugging/types.bzl", "ExecInfo", "JavaInfo", "ScriptSettings", "TargetExtraInfo") 10 | load("@prelude//java/class_to_srcs.bzl", "JavaClassToSourceMapInfo") 11 | 12 | def inspect_java_rule(ctx: bxl.Context, _actions: AnalysisActions, target: bxl.ConfiguredTargetNode, settings: ScriptSettings) -> ExecInfo: 13 | providers = ctx.analysis(target).providers() 14 | debuginfo = providers[JavaClassToSourceMapInfo].debuginfo if JavaClassToSourceMapInfo in providers else None 15 | if debuginfo: 16 | ctx.output.ensure(debuginfo) 17 | 18 | return ExecInfo( 19 | target_name = target_name(settings.target), 20 | target_info = create_target_info(settings.target), 21 | data = TargetExtraInfo( 22 | exec_info_version = 1, 23 | debugger = "fdb:debugger:jdwp", 24 | java = JavaInfo( 25 | classmap_file = debuginfo, 26 | ), 27 | ), 28 | ) 29 | -------------------------------------------------------------------------------- /apple/apple_asset_catalog_compilation_options.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | AppleAssetCatalogsCompilationOptions = record( 9 | enable_notices = field(bool), 10 | enable_warnings = field(bool), 11 | enable_errors = field(bool), 12 | compress_pngs = field(bool), 13 | optimization = field(str), 14 | output_format = field(str), 15 | extra_flags = field(list[str]), 16 | ) 17 | 18 | def get_apple_asset_catalogs_compilation_options(ctx: AnalysisContext) -> AppleAssetCatalogsCompilationOptions: 19 | options = ctx.attrs.asset_catalogs_compilation_options 20 | 21 | return AppleAssetCatalogsCompilationOptions( 22 | enable_notices = options.get("notices", True), 23 | enable_warnings = options.get("warnings", True), 24 | enable_errors = options.get("errors", True), 25 | compress_pngs = options.get("compress_pngs", True), 26 | optimization = options.get("optimization", "space"), 27 | output_format = options.get("output_format", "human-readable-text"), 28 | extra_flags = options.get("extra_flags", []), 29 | ) 30 | -------------------------------------------------------------------------------- /erlang/common_test/test_exec/src/test_exec.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) Meta Platforms, Inc. and affiliates. 2 | %% 3 | %% This source code is licensed under both the MIT license found in the 4 | %% LICENSE-MIT file in the root directory of this source tree and the Apache 5 | %% License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | %% of this source tree. 7 | 8 | %% % @format 9 | 10 | %% @doc The test_exec application deals with running 11 | %% the test as part of a separate sub-process along 12 | %% with the epmd daemon. 13 | -module(test_exec). 14 | 15 | -behavior(application). 16 | 17 | -export([start/2, stop/1, kill_process/1]). 18 | -include_lib("common/include/buck_ct_records.hrl"). 19 | 20 | start(_Type, _Args) -> 21 | case application:get_env(test_exec, test_env) of 22 | {ok, #test_env{} = TestEnv} -> 23 | test_exec_sup:start_link(TestEnv); 24 | _ -> 25 | %% hack to make startup not fail if no config is set 26 | {ok, spawn(fun() -> ok end)} 27 | end. 28 | 29 | stop(_State) -> ok. 30 | 31 | -spec kill_process(port()) -> ok. 32 | kill_process(Port) -> 33 | case erlang:port_info(Port, os_pid) of 34 | undefined -> 35 | ok; 36 | {os_pid, OsPid} -> 37 | os:cmd(io_lib:format("kill -9 ~p", [OsPid])), 38 | spawn(fun() -> port_close(Port) end), 39 | ok 40 | end. 41 | -------------------------------------------------------------------------------- /android/constraints/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//android:min_sdk_version.bzl", "get_min_sdk_version_constraint_value_name", "get_min_sdk_version_range") 2 | load("@prelude//utils:source_listing.bzl", "source_listing") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | prelude = native # Avoid warnings and auto-formatters 9 | 10 | prelude.constraint_setting( 11 | name = "maybe_build_only_native_code", 12 | visibility = ["PUBLIC"], 13 | ) 14 | 15 | prelude.constraint_value( 16 | name = "build_only_native_code", 17 | constraint_setting = ":maybe_build_only_native_code", 18 | visibility = ["PUBLIC"], 19 | ) 20 | 21 | prelude.constraint_setting( 22 | name = "maybe_merge_native_libraries", 23 | visibility = ["PUBLIC"], 24 | ) 25 | 26 | prelude.constraint_value( 27 | name = "merge_native_libraries", 28 | constraint_setting = ":maybe_merge_native_libraries", 29 | visibility = ["PUBLIC"], 30 | ) 31 | 32 | prelude.filegroup( 33 | name = "files", 34 | srcs = glob( 35 | ["**"], 36 | ), 37 | visibility = ["PUBLIC"], 38 | ) 39 | 40 | prelude.constraint_setting( 41 | name = "min_sdk_version", 42 | visibility = ["PUBLIC"], 43 | ) 44 | 45 | [ 46 | prelude.constraint_value( 47 | name = get_min_sdk_version_constraint_value_name(min_sdk), 48 | constraint_setting = ":min_sdk_version", 49 | ) 50 | for min_sdk in get_min_sdk_version_range() 51 | ] 52 | -------------------------------------------------------------------------------- /apple/swift/swift_pcm_compilation_types.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | SwiftPCMUncompiledInfo = provider( 9 | # @unsorted-dict-items 10 | fields = { 11 | "name": provider_field(typing.Any, default = None), 12 | "is_transient": provider_field(typing.Any, default = None), # If True represents a transient apple_library target, that can't be compiled into pcm, but which we need to pass up for BUCK1 compatibility, because it can re-export some deps. 13 | "exported_preprocessor": provider_field(typing.Any, default = None), # CPreprocessor 14 | "exported_deps": provider_field(typing.Any, default = None), # [Dependency] 15 | "propagated_preprocessor_args_cmd": provider_field(typing.Any, default = None), # cmd_args 16 | "uncompiled_sdk_modules": provider_field(typing.Any, default = None), # [str] a list of required sdk modules 17 | }, 18 | ) 19 | 20 | # A tset can't be returned from the rule, so we need to wrap it into a provider. 21 | WrappedSwiftPCMCompiledInfo = provider(fields = { 22 | "tset": provider_field(typing.Any, default = None), # Tset of `SwiftCompiledModuleInfo` 23 | }) 24 | -------------------------------------------------------------------------------- /erlang/common_test/common/src/buck_ct_parser.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) Meta Platforms, Inc. and affiliates. 2 | %% 3 | %% This source code is licensed under both the MIT license found in the 4 | %% LICENSE-MIT file in the root directory of this source tree and the Apache 5 | %% License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | %% of this source tree. 7 | 8 | %%% % @format 9 | %%%------------------------------------------------------------------- 10 | %%% @doc 11 | %%% Utilities method to parse string args given to the test binary 12 | %%% via user input. 13 | %%% @end 14 | 15 | -module(buck_ct_parser). 16 | -compile(warn_missing_spec). 17 | 18 | %% Public API 19 | -export([parse_str/1]). 20 | 21 | -spec parse_str(binary()) -> term(). 22 | parse_str(<<"">>) -> 23 | []; 24 | parse_str(StrArgs) -> 25 | try 26 | {ok, Tokens, _} = erl_scan:string(unicode:characters_to_list([StrArgs, "."])), 27 | erl_parse:parse_term(Tokens) 28 | of 29 | {ok, Term} -> 30 | Term; 31 | {error, Reason} -> 32 | error(lists:flatten(io_lib:format("Error parsing StrArgs ~p, Reason: ~p", [StrArgs, Reason]))) 33 | catch 34 | E:R:S -> 35 | error( 36 | lists:flatten( 37 | io_lib:format("Error parsing StrArgs ~p, error ~ts", [StrArgs, erl_error:format_exception(E, R, S)]) 38 | ) 39 | ) 40 | end. 41 | -------------------------------------------------------------------------------- /java/jar_genrule.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//:genrule.bzl", "process_genrule") 9 | load("@prelude//java:java_toolchain.bzl", "JavaToolchainInfo") 10 | load("@prelude//utils:expect.bzl", "expect") 11 | 12 | def jar_genrule_impl(ctx: AnalysisContext) -> list[Provider]: 13 | output_name = "{}.jar".format(ctx.label.name) 14 | providers = process_genrule(ctx, output_name, None) 15 | expect( 16 | len(providers) == 1, 17 | "expected exactly one provider of type DefaultInfo from {} ({})" 18 | .format(ctx.label.name, providers), 19 | ) 20 | 21 | default_info = providers[0] # DefaultInfo type 22 | outputs = default_info.default_outputs 23 | expect( 24 | len(outputs) == 1, 25 | "expected exactly one output from {} ({})" 26 | .format(ctx.label.name, outputs), 27 | ) 28 | output_jar = outputs[0] 29 | 30 | java_toolchain = ctx.attrs._java_toolchain[JavaToolchainInfo] 31 | java_cmd = cmd_args(java_toolchain.java[RunInfo]) 32 | java_cmd.add("-jar", output_jar) 33 | 34 | providers.append(RunInfo(args = java_cmd)) 35 | return providers 36 | -------------------------------------------------------------------------------- /apple/apple_asset_catalog_types.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | StringWithSourceTarget = record( 9 | # Target providing the string value 10 | source = field(Label), 11 | value = field(str), 12 | ) 13 | 14 | AppleAssetCatalogSpec = record( 15 | # At most one per given `apple_bundle` (including all transitive catalog dependencies), 16 | # optional reference in a form of a name (extension omitted) of an .appiconset which 17 | # contains an image set representing an application icon. 18 | # This set should be contained in one of catalogs referenced by `dirs` attribute. 19 | app_icon = field([StringWithSourceTarget, None]), 20 | dirs = field(list[Artifact]), 21 | # Same as `app_icon` but with an application launch image semantics. 22 | launch_image = field([StringWithSourceTarget, None]), 23 | ) 24 | 25 | AppleAssetCatalogResult = record( 26 | # Directory which contains compiled assets ready to be copied into application bundle 27 | compiled_catalog = field(Artifact), 28 | # .plist file to be merged into main application Info.plist file, containing information about compiled assets 29 | catalog_plist = field(Artifact), 30 | ) 31 | -------------------------------------------------------------------------------- /erlang/common_test/common/src/bounded_buffer.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) Meta Platforms, Inc. and affiliates. 2 | %% 3 | %% This source code is licensed under both the MIT license found in the 4 | %% LICENSE-MIT file in the root directory of this source tree and the Apache 5 | %% License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | %% of this source tree. 7 | 8 | %%%------------------------------------------------------------------- 9 | %%% @doc 10 | %%% A bounded FIFO queue 11 | %%% @end 12 | %%% % @format 13 | 14 | -module(bounded_buffer). 15 | 16 | -compile(warn_missing_spec). 17 | 18 | %% Public API 19 | -export([new/1, put/2, get_elements/1]). 20 | -export_type([buffer/1]). 21 | 22 | -opaque buffer(T) :: {{queue:queue(T), integer()}, integer(), boolean()}. 23 | 24 | -spec new(integer()) -> buffer(term()). 25 | new(MaxElements) -> {{queue:new(), 0}, MaxElements, false}. 26 | 27 | -spec put(buffer(T), T) -> buffer(T). 28 | put({{Queue, LenQueue}, MaxElements, Truncated}, Chars) when LenQueue < MaxElements -> 29 | {{queue:in(Chars, Queue), LenQueue + 1}, MaxElements, Truncated}; 30 | put({{Queue, LenQueue}, MaxElements, _Truncated} = _Buffer, Chars) when LenQueue == MaxElements -> 31 | {_, NewQueue} = queue:out(Queue), 32 | {{queue:in(Chars, NewQueue), LenQueue}, MaxElements, true}. 33 | 34 | -spec get_elements(buffer(T)) -> {[T], boolean()}. 35 | get_elements({{Queue, _LenQueue}, _MaxElements, Truncated}) -> 36 | {queue:to_list(Queue), Truncated}. 37 | -------------------------------------------------------------------------------- /erlang/shell/shell.bxl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def _deduped_paths(paths): 9 | return list({ 10 | str(path): path.abs_path() 11 | for path in paths 12 | }.values()) 13 | 14 | def _ebin_paths(ctx): 15 | target_universe = ctx.uquery().owner(ctx.cli_args.source) 16 | test_target = ctx.cquery().kind("erlang_test", ctx.cquery().owner(ctx.cli_args.source, target_universe)) 17 | app_target = ctx.cquery().kind("erlang_app$", ctx.cquery().owner(ctx.cli_args.source, target_universe)) 18 | 19 | target = test_target + app_target 20 | 21 | paths = [] 22 | failed_targets = [] 23 | for k, value in ctx.build(target).items(): 24 | for _ in value.failures(): 25 | failed_targets.append(str(k.raw_target())) 26 | break 27 | paths.extend(ctx.output.ensure_multiple(value.artifacts())) 28 | 29 | if failed_targets: 30 | fail("failed to build {} targets: {}".format(len(failed_targets), failed_targets)) 31 | 32 | ctx.output.print(sep = "\n", *_deduped_paths(paths)) 33 | 34 | ebin_paths = bxl_main( 35 | impl = _ebin_paths, 36 | cli_args = { 37 | "source": cli_args.string(), 38 | }, 39 | ) 40 | -------------------------------------------------------------------------------- /toolchains/apple/xcode_version_checker/src/xcode_version_checks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. 3 | * 4 | * This source code is licensed under both the MIT license found in the 5 | * LICENSE-MIT file in the root directory of this source tree and the Apache 6 | * License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | * of this source tree. 8 | */ 9 | 10 | #ifndef __XCODE_VERSION_CHECKS_H__ 11 | #define __XCODE_VERSION_CHECKS_H__ 12 | 13 | #import 14 | 15 | BOOL checkVersionsMatch(NSString* shortVersion, NSString* expectedShortVersion); 16 | void execTool(char const* arguments[], int argumentsCount); 17 | BOOL checkPlistValueMatch( 18 | NSString* plistPath, 19 | NSString* plistKey, 20 | NSString* expectedValue, 21 | BOOL (*comparator)(NSString* value, NSString* expectedValue), 22 | BOOL logComparisonFailure); 23 | 24 | BOOL checkProductBuildVersionMatch( 25 | NSString* productBuild, 26 | NSString* expectedProductBuild); 27 | BOOL checkVersionPlistProductBuildMatch( 28 | NSString* plistPath, 29 | NSString* expectedProductBuild, 30 | BOOL logComparisonFailure); 31 | BOOL checkXcodeProductBuildMatch(NSString* expectedProductBuild); 32 | 33 | BOOL checkVersionPlistShortVersionMatch( 34 | NSString* plistPath, 35 | NSString* expectedShortVersion, 36 | BOOL logComparisonFailure); 37 | BOOL checkXcodeShortVersionMatch(NSString* expectedShortVersion); 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /apple/tools/re_compatibility_utils/writable.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # pyre-strict 9 | 10 | import os 11 | import platform 12 | import stat 13 | 14 | 15 | def make_path_user_writable(path: str) -> None: 16 | # On Linux, `os.chmod()` does not support setting the permissions on a symlink. 17 | # `chmod` manpage says: 18 | # > AT_SYMLINK_NOFOLLOW If pathname is a symbolic link, do not 19 | # > dereference it: instead operate on the link itself. 20 | # > This flag is not currently implemented. 21 | # 22 | # In Python, an exception will be thrown: 23 | # > NotImplementedError: chmod: follow_symlinks unavailable on this platform 24 | # 25 | # Darwin supports permission setting on symlinks. 26 | follow_symlinks = platform.system() != "Darwin" 27 | st = os.stat(path, follow_symlinks=False) 28 | os.chmod(path, st.st_mode | stat.S_IWUSR, follow_symlinks=follow_symlinks) 29 | 30 | 31 | def make_dir_recursively_writable(dir: str) -> None: 32 | for dirpath, _, filenames in os.walk(dir): 33 | make_path_user_writable(dirpath) 34 | for filename in filenames: 35 | make_path_user_writable(os.path.join(dirpath, filename)) 36 | -------------------------------------------------------------------------------- /erlang/toolchain/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//erlang:erlang_toolchain.bzl", "erlang_parse_transform", "toolchain_utilities") 2 | load("@prelude//utils:source_listing.bzl", "source_listing") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | erlang_parse_transform( 9 | name = "transform_project_root", 10 | src = "transform_project_root.erl", 11 | visibility = ["PUBLIC"], 12 | ) 13 | 14 | # export escripts for testing 15 | filegroup( 16 | name = "util_scripts", 17 | srcs = glob([ 18 | "*.escript", 19 | "*.sh", 20 | "*.erl", 21 | ]), 22 | visibility = ["PUBLIC"], 23 | ) 24 | 25 | toolchain_utilities( 26 | name = "toolchain_utilities", 27 | app_src_script = "app_src_builder.escript", 28 | boot_script_builder = "boot_script_builder.escript", 29 | core_parse_transforms = [":transform_project_root"], 30 | dependency_analyzer = "dependency_analyzer.escript", 31 | dependency_finalizer = "dependency_finalizer.escript", 32 | edoc = "edoc_cli.escript", 33 | erlc_trampoline = "erlc_trampoline.sh", 34 | escript_builder = "escript_builder.escript", 35 | escript_trampoline = "escript_trampoline.sh", 36 | include_erts = "include_erts.escript", 37 | release_variables_builder = "release_variables_builder.escript", 38 | utility_modules = [ 39 | "edoc_doclet_chunks.erl", 40 | "edoc_report.erl", 41 | "epp_dodger.erl", 42 | "json.erl", 43 | ], 44 | visibility = ["PUBLIC"], 45 | ) 46 | -------------------------------------------------------------------------------- /ide_integrations/xcode.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | XCODE_ARGSFILES_SUB_TARGET = "xcode-argsfiles" 9 | 10 | XCODE_DATA_SUB_TARGET = "xcode-data" 11 | _XCODE_DATA_FILE_NAME = "xcode_data.json" 12 | 13 | XcodeDataInfo = provider(fields = { 14 | "data": provider_field(typing.Any, default = None), # {str: _a} 15 | }) 16 | 17 | def generate_xcode_data( 18 | ctx: AnalysisContext, 19 | rule_type: str, 20 | output: Artifact | None, 21 | populate_rule_specific_attributes_func: [typing.Callable, None] = None, 22 | **kwargs) -> (list[DefaultInfo], XcodeDataInfo): 23 | data = { 24 | "rule_type": rule_type, 25 | "target": ctx.label, 26 | } 27 | if output: 28 | data["output"] = output 29 | if populate_rule_specific_attributes_func: 30 | data.update(populate_rule_specific_attributes_func(ctx, **kwargs)) 31 | 32 | data["extra_xcode_files"] = [] 33 | if hasattr(ctx.attrs, "extra_xcode_files"): 34 | data["extra_xcode_files"] = ctx.attrs.extra_xcode_files 35 | 36 | json_file = ctx.actions.write_json(_XCODE_DATA_FILE_NAME, data) 37 | return [DefaultInfo(default_output = json_file)], XcodeDataInfo(data = data) 38 | -------------------------------------------------------------------------------- /rust/named_deps.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//utils:argfile.bzl", "at_argfile") 9 | load("@prelude//utils:type_defs.bzl", "is_list") 10 | load(":context.bzl", "CompileContext") 11 | 12 | # Write a file containing all the dynamically-generated dependency names. This 13 | # isn't used in the course of any Buck builds, but is needed by rust-project to 14 | # supply an accurate dependency graph to rust-analyzer.. 15 | def write_named_deps_names( 16 | ctx: AnalysisContext, 17 | compile_ctx: CompileContext) -> Artifact | None: 18 | if not is_list(ctx.attrs.named_deps): 19 | return None 20 | 21 | named_deps_names = ctx.actions.declare_output("named_deps") 22 | ctx.actions.run( 23 | cmd_args( 24 | compile_ctx.toolchain_info.rustc_action, 25 | cmd_args(named_deps_names.as_output(), format = "--echo={}"), 26 | at_argfile( 27 | actions = ctx.actions, 28 | name = "named_deps.args", 29 | args = [name for name, _dep in ctx.attrs.named_deps], 30 | allow_args = True, 31 | ), 32 | ), 33 | category = "named_deps", 34 | ) 35 | return named_deps_names 36 | -------------------------------------------------------------------------------- /erlang/toolchain/include_erts.escript: -------------------------------------------------------------------------------- 1 | %% #!/usr/bin/env escript 2 | %% -*- erlang -*- 3 | %%! +sbtu 4 | 5 | %% Copyright (c) Meta Platforms, Inc. and affiliates. 6 | %% 7 | %% This source code is licensed under both the MIT license found in the 8 | %% LICENSE-MIT file in the root directory of this source tree and the Apache 9 | %% License, Version 2.0 found in the LICENSE-APACHE file in the root directory 10 | %% of this source tree. 11 | 12 | %%% % @format 13 | %%%------------------------------------------------------------------- 14 | %%% @doc 15 | %%% Copy ERTS for releases to the given location 16 | %%% 17 | %%% usage: 18 | %%% include_erts.escript target_location 19 | %%% @end 20 | 21 | -module(include_erts). 22 | -author("loscher@meta.com"). 23 | 24 | -export([main/1]). 25 | 26 | -spec main([string()]) -> ok. 27 | main([TargetPath]) -> 28 | case filelib:wildcard(filename:join(code:root_dir(), "erts-*")) of 29 | [ErtsPath] -> ok = copy_dir(ErtsPath, TargetPath); 30 | Paths -> io:format("expected exactly one erts but found: ~p~n", [Paths]) 31 | end; 32 | main(_) -> 33 | usage(). 34 | 35 | -spec usage() -> ok. 36 | usage() -> 37 | io:format("needs exactly one argument: include_erts.escript target_location~n"). 38 | 39 | copy_dir(From, To) -> 40 | Cmd = lists:flatten( 41 | io_lib:format("cp -r ~s ~s", [From, To]) 42 | ), 43 | io:format("~s~n", [os:cmd(Cmd)]), 44 | case filelib:is_dir(To) of 45 | true -> ok; 46 | false -> erlang:halt(1) 47 | end. 48 | -------------------------------------------------------------------------------- /apple/tools/code_signing/identity.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # pyre-strict 9 | 10 | from __future__ import annotations 11 | 12 | import re 13 | from dataclasses import dataclass 14 | from enum import Enum 15 | from typing import List 16 | 17 | 18 | @dataclass 19 | class CodeSigningIdentity: 20 | fingerprint: str 21 | subject_common_name: str 22 | 23 | class _ReGroupName(str, Enum): 24 | fingerprint = "fingerprint" 25 | subject_common_name = "subject_common_name" 26 | 27 | _re_string: str = ( 28 | '(?P<{fingerprint}>[A-F0-9]{{40}}) "(?P<{subject_common_name}>.+)"(?!.*CSSMERR_.+)'.format( 29 | fingerprint=_ReGroupName.fingerprint, 30 | subject_common_name=_ReGroupName.subject_common_name, 31 | ) 32 | ) 33 | 34 | _pattern: re.Pattern[str] = re.compile(_re_string) 35 | 36 | @classmethod 37 | def parse_security_stdout(cls, text: str) -> List[CodeSigningIdentity]: 38 | return [ 39 | CodeSigningIdentity( 40 | match.group(cls._ReGroupName.fingerprint), 41 | match.group(cls._ReGroupName.subject_common_name), 42 | ) 43 | for match in re.finditer(cls._pattern, text) 44 | ] 45 | -------------------------------------------------------------------------------- /toolchains/conan/BUCK: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | 3 | oncall("build_infra") 4 | 5 | source_listing() 6 | 7 | export_file( 8 | name = "buckler", 9 | src = "buckler/conanfile.py", 10 | visibility = ["PUBLIC"], 11 | ) 12 | 13 | python_bootstrap_library( 14 | name = "conan_common", 15 | srcs = ["conan_common.py"], 16 | ) 17 | 18 | python_bootstrap_binary( 19 | name = "conan_generate", 20 | main = "conan_generate.py", 21 | visibility = ["PUBLIC"], 22 | deps = [":conan_common"], 23 | ) 24 | 25 | python_bootstrap_binary( 26 | name = "conan_init", 27 | main = "conan_init.py", 28 | visibility = ["PUBLIC"], 29 | deps = [":conan_common"], 30 | ) 31 | 32 | python_bootstrap_binary( 33 | name = "conan_lock", 34 | main = "conan_lock.py", 35 | visibility = ["PUBLIC"], 36 | deps = [":conan_common"], 37 | ) 38 | 39 | python_bootstrap_binary( 40 | name = "conan_package", 41 | main = "conan_package.py", 42 | visibility = ["PUBLIC"], 43 | deps = [":conan_common"], 44 | ) 45 | 46 | python_bootstrap_binary( 47 | name = "conan_package_extract", 48 | main = "conan_package_extract.py", 49 | visibility = ["PUBLIC"], 50 | ) 51 | 52 | python_bootstrap_binary( 53 | name = "conan_update", 54 | main = "conan_update.py", 55 | visibility = ["PUBLIC"], 56 | ) 57 | 58 | python_bootstrap_binary( 59 | name = "lock_generate", 60 | main = "lock_generate.py", 61 | visibility = ["PUBLIC"], 62 | deps = [":conan_common"], 63 | ) 64 | -------------------------------------------------------------------------------- /android/util.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # A wrapper around AnalysisContext that makes it easier to define subtargets without needing to pass information 9 | # for them all the way back to the outermost analysis impl. 10 | EnhancementContext = record( 11 | ctx = AnalysisContext, 12 | actions = AnalysisActions, 13 | attrs = typing.Any, 14 | label = Label, 15 | 16 | # methods 17 | debug_output = typing.Callable, 18 | get_sub_targets = typing.Callable, 19 | ) 20 | 21 | def create_enhancement_context(ctx: AnalysisContext) -> EnhancementContext: 22 | extra_sub_targets = {} 23 | 24 | def debug_output(name: str, output: Artifact, other_outputs = [], sub_targets: dict[str, typing.Any] = {}): 25 | """Adds a subtarget to expose debugging outputs.""" 26 | extra_sub_targets[name] = [DefaultInfo(default_outputs = [output], other_outputs = other_outputs, sub_targets = sub_targets)] 27 | 28 | def get_sub_targets(): 29 | return extra_sub_targets 30 | 31 | return EnhancementContext( 32 | ctx = ctx, 33 | actions = ctx.actions, 34 | attrs = ctx.attrs, 35 | label = ctx.label, 36 | debug_output = debug_output, 37 | get_sub_targets = get_sub_targets, 38 | ) 39 | -------------------------------------------------------------------------------- /toolchains/apple/xcode_version_checker/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS = -x objective-c -lobjc -fobjc-arc -fobjc-weak -O3 -Wall 2 | 3 | .PHONY: all clean test 4 | 5 | xcode_version_checker: xcode_version_checker.x86_64 xcode_version_checker.arm64 6 | lipo -create -output xcode_version_checker xcode_version_checker.x86_64 xcode_version_checker.arm64 7 | xcode_version_checker.x86_64: src/xcode_version_checker.m src/xcode_version_checks.m 8 | $(CC) $(CFLAGS) src/xcode_version_checker.m src/xcode_version_checks.m -o xcode_version_checker.x86_64 -target x86_64-apple-macos 9 | xcode_version_checker.arm64: src/xcode_version_checker.m src/xcode_version_checks.m 10 | $(CC) $(CFLAGS) src/xcode_version_checker.m src/xcode_version_checks.m -o xcode_version_checker.arm64 -target arm64-apple-macos 11 | 12 | all: xcode_version_checker test 13 | 14 | test: xcode_version_tester xcode_exec_tester 15 | ./xcode_version_tester $(abspath test/Xcode_14.2.0_14C18_fb_version.plist) 16 | ./xcode_exec_tester "/usr/bin/true" 17 | ./xcode_exec_tester "/bin/bash" "-c" "! /usr/bin/false" 18 | 19 | xcode_version_tester: src/xcode_version_tester.m src/xcode_version_checks.m 20 | $(CC) $(CFLAGS) src/xcode_version_tester.m src/xcode_version_checks.m -o xcode_version_tester 21 | 22 | xcode_exec_tester: src/xcode_exec_tester.m src/xcode_version_checks.m 23 | $(CC) $(CFLAGS) src/xcode_exec_tester.m src/xcode_version_checks.m -o xcode_exec_tester 24 | 25 | clean: 26 | rm -f xcode_version_checker.x86_64 27 | rm -f xcode_version_checker.arm64 28 | rm -f xcode_version_tester 29 | rm -f xcode_exec_tester 30 | -------------------------------------------------------------------------------- /erlang/common_test/test_exec/test/ct_executor_SUITE.erl: -------------------------------------------------------------------------------- 1 | %% Copyright (c) Meta Platforms, Inc. and affiliates. 2 | %% This source code is licensed under both the MIT license found in the 3 | %% LICENSE-MIT file in the root directory of this source tree and the Apache 4 | %% License, Version 2.0 found in the LICENSE-APACHE file in the root directory 5 | %% of this source tree. 6 | %%% % @format 7 | -module(ct_executor_SUITE). 8 | 9 | -include_lib("stdlib/include/assert.hrl"). 10 | 11 | -export([all/0]). 12 | 13 | -export([ 14 | test_split_args/1 15 | ]). 16 | 17 | all() -> 18 | [test_split_args]. 19 | 20 | test_split_args(_Config) -> 21 | ?assertEqual( 22 | {[{output_dir, ""}, {providers, [something]}, {suite, a_suite}], [{dir, ""}, {suite, a_suite}, {group, a_group}]}, 23 | ct_executor:split_args([ 24 | {output_dir, ""}, 25 | {providers, [something]}, 26 | {suite, a_suite}, 27 | ct_args, 28 | {dir, ""}, 29 | {suite, a_suite}, 30 | {group, a_group} 31 | ]) 32 | ), 33 | ?assertEqual( 34 | {[{output_dir, ""}, {providers, [something]}, {suite, a_suite}], []}, 35 | ct_executor:split_args([{output_dir, ""}, {providers, [something]}, {suite, a_suite}, ct_args]) 36 | ), 37 | ?assertEqual( 38 | {[], [{dir, ""}, {suite, a_suite}, {group, a_group}]}, 39 | ct_executor:split_args([ct_args, {dir, ""}, {suite, a_suite}, {group, a_group}]) 40 | ), 41 | ?assertEqual({[], []}, ct_executor:split_args([ct_args])). 42 | -------------------------------------------------------------------------------- /cxx/tools/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | load(":defs.bzl", "cxx_hacks") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | prelude = native 9 | 10 | prelude.python_bootstrap_binary( 11 | name = "hmap_wrapper.py", 12 | main = "hmap_wrapper.py", 13 | ) 14 | 15 | prelude.command_alias( 16 | name = "hmap_wrapper", 17 | args = [ 18 | "--hmap-tool=$(exe_target prelude//third-party/hmaptool:hmaptool)", 19 | ], 20 | exe = ":hmap_wrapper.py", 21 | labels = ["buck2-only"], 22 | visibility = ["PUBLIC"], 23 | ) 24 | 25 | prelude.python_bootstrap_binary( 26 | name = "make_comp_db", 27 | main = "make_comp_db.py", 28 | visibility = ["PUBLIC"], 29 | ) 30 | 31 | prelude.python_bootstrap_binary( 32 | name = "dep_file_processor", 33 | main = "dep_file_processor.py", 34 | visibility = ["PUBLIC"], 35 | deps = [ 36 | ":dep_file_processors", 37 | ], 38 | ) 39 | 40 | prelude.python_bootstrap_library( 41 | name = "dep_file_processors", 42 | srcs = [ 43 | "dep_file_utils.py", 44 | "makefile_to_dep_file.py", 45 | "show_headers_to_dep_file.py", 46 | "show_includes_to_dep_file.py", 47 | ], 48 | visibility = ["PUBLIC"], 49 | ) 50 | 51 | prelude.python_bootstrap_binary( 52 | name = "linker_wrapper", 53 | main = "linker_wrapper.py", 54 | visibility = ["PUBLIC"], 55 | ) 56 | 57 | # Required to support the $(cxx-header-tree) macro 58 | cxx_hacks( 59 | name = "cxx_hacks", 60 | visibility = ["PUBLIC"], 61 | ) 62 | -------------------------------------------------------------------------------- /python/typecheck/batch.bxl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//utils:utils.bzl", "flatten") 9 | load("@prelude//python/sourcedb/filter.bxl", "do_filter") 10 | 11 | def check_targets(ctx: bxl.Context, targets: typing.Any) -> None: 12 | checked_targets = ctx.configured_targets(do_filter(ctx.uquery(), targets)) 13 | 14 | build_result = ctx.build([ 15 | target.label.with_sub_target("typecheck") 16 | for target in checked_targets 17 | ]) 18 | output = ctx.output.ensure_multiple(build_result) 19 | 20 | ctx.output.print_json({ 21 | "artifacts": { 22 | label.raw_target(): [artifact.rel_path() for artifact in artifacts] 23 | for label, artifacts in output.items() 24 | }, 25 | "root": ctx.root(), 26 | }) 27 | 28 | def _run_entry_point(ctx: bxl.Context) -> None: 29 | targets = flatten(ctx.cli_args.target) 30 | check_targets(ctx, targets) 31 | 32 | run = bxl_main( 33 | doc = "Run [typecheck] on a set of targets or target patterns.", 34 | impl = _run_entry_point, 35 | cli_args = { 36 | "target": cli_args.list( 37 | cli_args.target_expr( 38 | doc = "Target pattern to run type checking on", 39 | ), 40 | ), 41 | }, 42 | ) 43 | -------------------------------------------------------------------------------- /apple/tools/code_signing/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//utils:source_listing.bzl", "source_listing") 2 | load("@prelude//apple/tools/defs.bzl", "meta_python_test") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | configured_alias( 9 | name = "dummy_binary_for_signing_configured", 10 | actual = ":dummy_binary_for_signing", 11 | platform = "config//platform/macos:base", 12 | ) 13 | 14 | cxx_binary( 15 | name = "dummy_binary_for_signing", 16 | srcs = ["dummy_binary_for_signing.c"], 17 | default_target_platform = "config//platform/macos:base", 18 | ) 19 | 20 | python_library( 21 | name = "lib", 22 | srcs = glob( 23 | [ 24 | "*.py", 25 | ], 26 | exclude = [ 27 | "*_test.py", 28 | "main.py", 29 | ], 30 | ), 31 | resources = [":dummy_binary_for_signing_configured"], 32 | visibility = ["PUBLIC"], 33 | deps = [ 34 | "prelude//apple/tools:plistlib_utils", 35 | "prelude//apple/tools/info_plist_processor:process", 36 | ], 37 | ) 38 | 39 | meta_python_test( 40 | name = "tests", 41 | srcs = glob(["*_test.py"]), 42 | resources = glob([ 43 | "test_resources/*", 44 | ]), 45 | deps = [ 46 | "fbsource//third-party/pkg_resources:pkg_resources", 47 | ":lib", 48 | ], 49 | ) 50 | 51 | python_binary( 52 | name = "codesign_bundle", 53 | main = "main.py", 54 | visibility = ["PUBLIC"], 55 | deps = [ 56 | "fbsource//third-party/pypi/typed-argument-parser:typed-argument-parser", 57 | ":lib", 58 | ], 59 | ) 60 | -------------------------------------------------------------------------------- /apple/tools/resource_broker/macos.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # pyre-strict 9 | 10 | import asyncio 11 | from typing import cast, List 12 | 13 | from .idb_companion import IdbCompanion 14 | 15 | from .utils import IdbCompanionProcess, spawn_companion, wait_for_idb_companions 16 | 17 | 18 | def _boot_macos_companion_command(grpc_domain_sock: str) -> List[str]: 19 | return [ 20 | "idb_companion", 21 | "--udid", 22 | "mac", 23 | "--grpc-domain-sock", 24 | grpc_domain_sock, 25 | ] 26 | 27 | 28 | async def macos_idb_companions() -> List[IdbCompanion]: 29 | addresses = [(i, f"/tmp/buck2_idb_companion_mac_{i}") for i in range(10)] 30 | awaitables = [ 31 | spawn_companion( 32 | command=_boot_macos_companion_command(addr), 33 | log_file_suffix=f"macos_companion_{i}.log", 34 | ) 35 | for i, addr in addresses 36 | ] 37 | results = await asyncio.gather(*awaitables, return_exceptions=True) 38 | 39 | if exception := next(filter(lambda r: isinstance(r, BaseException), results), None): 40 | [r.cleanup() for r in results if isinstance(r, IdbCompanionProcess)] 41 | raise cast(BaseException, exception) 42 | 43 | return await wait_for_idb_companions(cast(List[IdbCompanionProcess], results)) 44 | -------------------------------------------------------------------------------- /android/bundletool_util.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//android:android_toolchain.bzl", "AndroidToolchainInfo") 9 | load("@prelude//java:java_providers.bzl", "KeystoreInfo") # @unused used as type 10 | 11 | def derive_universal_apk( 12 | ctx: AnalysisContext, 13 | android_toolchain: AndroidToolchainInfo, 14 | app_bundle: Artifact, 15 | keystore: [KeystoreInfo, None]) -> Artifact: 16 | output_apk = ctx.actions.declare_output("universal.apk") 17 | 18 | bundle_apks_builder_args = cmd_args([ 19 | android_toolchain.bundle_apks_builder[RunInfo], 20 | "--input-bundle", 21 | app_bundle, 22 | "--p7zip", 23 | android_toolchain.p7zip, 24 | "--aapt2", 25 | android_toolchain.aapt2, 26 | "--zipalign", 27 | android_toolchain.zipalign[RunInfo], 28 | "--output-apk", 29 | output_apk.as_output(), 30 | ]) 31 | 32 | if keystore: 33 | bundle_apks_builder_args.add(cmd_args([ 34 | "--keystore", 35 | keystore.store, 36 | "--keystore-properties", 37 | keystore.properties, 38 | ])) 39 | 40 | ctx.actions.run(bundle_apks_builder_args, category = "bundle_build", identifier = "build_universal_apk") 41 | 42 | return output_apk 43 | -------------------------------------------------------------------------------- /python/tools/make_source_db_no_deps.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under both the MIT license found in the 5 | # LICENSE-MIT file in the root directory of this source tree and the Apache 6 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | # of this source tree. 8 | 9 | # pyre-strict 10 | 11 | """ 12 | Creates a Python Source DB JSON file from Python manifest JSON file (e.g. for use with Pyre). 13 | 14 | Sources and dependencies are passed in via source manifest files, which are 15 | merged by this script: 16 | 17 | $ ./make_source_db_no_deps.py \ 18 | my_rule.manifest.json \ 19 | --output db_no_deps.json 20 | 21 | The output format of the source DB is: 22 | 23 | { 24 | : , 25 | : , 26 | ... 27 | } 28 | """ 29 | 30 | import argparse 31 | import json 32 | import sys 33 | from typing import List, Tuple 34 | 35 | 36 | def _load(path: str) -> List[Tuple[str, str, str]]: 37 | with open(path) as f: 38 | return json.load(f) 39 | 40 | 41 | def main(argv: List[str]) -> None: 42 | parser = argparse.ArgumentParser(fromfile_prefix_chars="@") 43 | parser.add_argument("--output", type=argparse.FileType("w"), default=sys.stdout) 44 | parser.add_argument("sources") 45 | args = parser.parse_args(argv[1:]) 46 | 47 | sources = {name: path for name, path, _ in _load(args.sources)} 48 | json.dump(sources, args.output, indent=2) 49 | args.output.close() 50 | 51 | 52 | sys.exit(main(sys.argv)) 53 | -------------------------------------------------------------------------------- /toolchains/msvc/run_msvc_tool.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Meta Platforms, Inc. and affiliates. 3 | # 4 | # This source code is licensed under both the MIT license found in the 5 | # LICENSE-MIT file in the root directory of this source tree and the Apache 6 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 7 | # of this source tree. 8 | 9 | import json 10 | import os 11 | import subprocess 12 | import sys 13 | from typing import List, NamedTuple 14 | 15 | 16 | class Tool(NamedTuple): 17 | # Path of the executable 18 | exe: str 19 | # Paths to prepend onto $LIB 20 | LIB: List[str] 21 | # Paths to prepend onto $PATH 22 | PATH: List[str] 23 | # Paths to prepend onto $INCLUDE 24 | INCLUDE: List[str] 25 | 26 | 27 | def prepend_env(env, key, entries): 28 | entries = ";".join(entries) 29 | if key in env: 30 | env[key] = entries + ";" + env[key] 31 | else: 32 | env[key] = entries 33 | 34 | 35 | def main(): 36 | tool_json, arguments = sys.argv[1], sys.argv[2:] 37 | with open(tool_json, encoding="utf-8") as f: 38 | tool = Tool(**json.load(f)) 39 | 40 | env = os.environ.copy() 41 | prepend_env(env, "LIB", tool.LIB) 42 | prepend_env(env, "PATH", tool.PATH) 43 | prepend_env(env, "INCLUDE", tool.INCLUDE) 44 | 45 | if tool.exe is None: 46 | print("Tool not found", file=sys.stderr) 47 | sys.exit(1) 48 | else: 49 | completed_process = subprocess.run([tool.exe, *arguments], env=env) 50 | sys.exit(completed_process.returncode) 51 | 52 | 53 | if __name__ == "__main__": 54 | main() 55 | -------------------------------------------------------------------------------- /apple/mockingbird/mockingbird_types.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | MockingbirdLibraryInfoTSet = transitive_set() 9 | 10 | MockingbirdTargetType = enum("library", "test") 11 | 12 | MockingbirdLibraryInfo = provider( 13 | fields = { 14 | # The name of the target. 15 | "name": provider_field(str), 16 | # Contains a tset with this target's MockingbirdLibraryRecord as the value 17 | # and all of its dependency's MockingbirdLibraryRecord in the children. 18 | "tset": provider_field(MockingbirdLibraryInfoTSet), 19 | }, 20 | ) 21 | 22 | MockingbirdLibraryRecord = record( 23 | # The names of this target's dependencies. 24 | dep_names = field(list[str]), 25 | # The names of this target's exported dependencies. 26 | exported_dep_names = field(list[str]), 27 | # The name of the target. 28 | name = str, 29 | # Swift sources in this target. 30 | srcs = field(list[Artifact]), 31 | # Whether this is a library or a test. 32 | type = field(MockingbirdTargetType), 33 | # Symlinked directory containing the source files. 34 | src_dir = field(Artifact), 35 | ) 36 | 37 | MockingbirdSourcesInfo = provider( 38 | fields = { 39 | # Source files containing the auto generated mocks produced by mockingbird-cli. 40 | "srcs": provider_field(list[Artifact]), 41 | }, 42 | ) 43 | -------------------------------------------------------------------------------- /decls/d_common.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | # TODO(cjhopman): This was generated by scripts/hacks/rules_shim_with_docs.py, 9 | # but should be manually edited going forward. There may be some errors in 10 | # the generated docs, and so those should be verified to be accurate and 11 | # well-formatted (and then delete this TODO) 12 | 13 | def _deps_arg(): 14 | return { 15 | "deps": attrs.list(attrs.dep(), default = [], doc = """ 16 | The set of dependencies of this rule. 17 | Each element should be a string specifying a d\\_library rule defined elsewhere 18 | (e.g. `':foo'` or '//foo:bar'). 19 | """), 20 | } 21 | 22 | def _srcs_arg(): 23 | return { 24 | "srcs": attrs.named_set(attrs.source(), sorted = True, default = [], doc = """ 25 | The set of D source files to be compiled by this rule. 26 | Each element should be a string specifying a source file (e.g. `'foo/bar.d'`). 27 | """), 28 | } 29 | 30 | def _linker_flags_arg(): 31 | return { 32 | "linker_flags": attrs.list(attrs.string(), default = [], doc = """ 33 | The list of flags to be passed to the linker. 34 | Each element should be a string specifying a linker flag (e.g. `'--as-needed'`). 35 | """), 36 | } 37 | 38 | d_common = struct( 39 | deps_arg = _deps_arg, 40 | srcs_arg = _srcs_arg, 41 | linker_flags_arg = _linker_flags_arg, 42 | ) 43 | -------------------------------------------------------------------------------- /cxx/dist_lto/tools/BUCK.v2: -------------------------------------------------------------------------------- 1 | load("@prelude//cxx/dist_lto:tools.bzl", "dist_lto_tools") 2 | load("@prelude//utils:source_listing.bzl", "source_listing") 3 | 4 | oncall("build_infra") 5 | 6 | source_listing() 7 | 8 | prelude = native 9 | 10 | prelude.python_bootstrap_binary( 11 | name = "dist_lto_planner", 12 | main = "dist_lto_planner.py", 13 | visibility = ["PUBLIC"], 14 | ) 15 | 16 | prelude.python_bootstrap_binary( 17 | name = "dist_lto_opt", 18 | main = "dist_lto_opt.py", 19 | visibility = ["PUBLIC"], 20 | ) 21 | 22 | prelude.python_bootstrap_binary( 23 | name = "dist_lto_opt_darwin", 24 | main = "dist_lto_opt_darwin.py", 25 | visibility = ["PUBLIC"], 26 | ) 27 | 28 | prelude.python_bootstrap_binary( 29 | name = "dist_lto_prepare", 30 | main = "dist_lto_prepare.py", 31 | visibility = ["PUBLIC"], 32 | ) 33 | 34 | prelude.python_bootstrap_binary( 35 | name = "dist_lto_copy", 36 | main = "dist_lto_copy.py", 37 | visibility = ["PUBLIC"], 38 | ) 39 | 40 | dist_lto_tools( 41 | name = "dist_lto_tools_darwin", 42 | copy = ":dist_lto_copy", 43 | opt = ":dist_lto_opt_darwin", 44 | planner = ":dist_lto_planner", 45 | prepare = ":dist_lto_prepare", 46 | visibility = ["PUBLIC"], 47 | ) 48 | 49 | dist_lto_tools( 50 | name = "dist_lto_tools", 51 | copy = ":dist_lto_copy", 52 | opt = ":dist_lto_opt", 53 | planner = ":dist_lto_planner", 54 | prepare = ":dist_lto_prepare", 55 | visibility = ["PUBLIC"], 56 | ) 57 | 58 | prelude.python_test( 59 | name = "test_dist_lto_opt", 60 | srcs = [ 61 | "dist_lto_opt.py", 62 | "tests/test_dist_lto_opt.py", 63 | ], 64 | ) 65 | -------------------------------------------------------------------------------- /cxx/target_sdk_version.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | def _version_is_greater(left: str, right: str) -> bool: 9 | # Assumes version strings are in dotted format 1.2.4. 10 | # After comparing components the longer remainder is 11 | # considered larger. 12 | left_components = left.split(".") 13 | right_components = right.split(".") 14 | for pair in zip(left_components, right_components): 15 | x = int(pair[0]) 16 | y = int(pair[1]) 17 | if x < y: 18 | return False 19 | elif x > y: 20 | return True 21 | 22 | return len(left_components) > len(right_components) 23 | 24 | def get_target_sdk_version(ctx: AnalysisContext) -> [None, str]: 25 | min_version = ctx.attrs.min_sdk_version 26 | target_version = ctx.attrs.target_sdk_version 27 | if min_version == None and target_version == None: 28 | return None 29 | elif min_version != None and target_version == None: 30 | return min_version 31 | elif min_version == None and target_version != None: 32 | fail("Cannot set target_sdk_version without min_sdk_version") 33 | elif _version_is_greater(min_version, target_version): 34 | warning("Target SDK version {} is less than minimum supported version {}".format(target_version, min_version)) 35 | return min_version 36 | else: 37 | return target_version 38 | -------------------------------------------------------------------------------- /decls/git_rules.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load(":common.bzl", "prelude_rule") 9 | 10 | git_fetch = prelude_rule( 11 | name = "git_fetch", 12 | docs = """ 13 | Checkout a commit from a git repository. 14 | """, 15 | examples = """ 16 | ``` 17 | git_fetch( 18 | name = "serde.git", 19 | repo = "https://github.com/serde-rs/serde", 20 | rev = "fccb9499bccbaca0b7eef91a3a82dfcb31e0b149", 21 | ) 22 | ``` 23 | """, 24 | further = None, 25 | attrs = ( 26 | # @unsorted-dict-items 27 | { 28 | "repo": attrs.string(doc = """ 29 | Url suitable as a git remote. 30 | """), 31 | "rev": attrs.string(doc = """ 32 | 40-digit hex SHA-1 of the git commit. 33 | """), 34 | "contacts": attrs.list(attrs.string(), default = []), 35 | "default_host_platform": attrs.option(attrs.configuration_label(), default = None), 36 | "labels": attrs.list(attrs.string(), default = []), 37 | "licenses": attrs.list(attrs.source(), default = []), 38 | "_git_fetch_tool": attrs.default_only(attrs.exec_dep(providers = [RunInfo], default = "prelude//git/tools:git_fetch")), 39 | } 40 | ), 41 | ) 42 | 43 | git_rules = struct( 44 | git_fetch = git_fetch, 45 | ) 46 | -------------------------------------------------------------------------------- /apple/apple_resource_types.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load("@prelude//:artifacts.bzl", "ArtifactOutputs") 9 | 10 | # Represents the values for the `destination` field of `apple_resource` 11 | AppleResourceDestination = enum( 12 | "executables", 13 | "frameworks", 14 | "loginitems", 15 | "plugins", 16 | "resources", 17 | "xpcservices", 18 | ) 19 | 20 | # Defines _where_ resources need to be placed in an `apple_bundle` 21 | AppleResourceSpec = record( 22 | files = field(list[[Artifact, Dependency]], []), 23 | dirs = field(list[Artifact], []), 24 | content_dirs = field(list[Artifact], []), 25 | destination = AppleResourceDestination, 26 | variant_files = field(list[Artifact], []), 27 | # Map from locale to list of files for that locale, e.g. 28 | # `{ "ru.lproj" : ["Localizable.strings"] }` 29 | named_variant_files = field(dict[str, list[Artifact]], {}), 30 | codesign_files_on_copy = field(bool, False), 31 | codesign_entitlements = field(Artifact | None, None), 32 | codesign_flags_override = field(list[str] | None, None), 33 | ) 34 | 35 | # Used when invoking `ibtool`, `actool`, `mapc` and `momc` 36 | AppleResourceProcessingOptions = record( 37 | prefer_local = field(bool, False), 38 | allow_cache_upload = field(bool, False), 39 | ) 40 | 41 | CxxResourceSpec = record( 42 | resources = field(dict[str, ArtifactOutputs], {}), 43 | ) 44 | -------------------------------------------------------------------------------- /android/prebuilt_native_library.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load( 9 | "@prelude//android:android_providers.bzl", 10 | "PrebuiltNativeLibraryDir", 11 | "merge_android_packageable_info", 12 | ) 13 | 14 | def prebuilt_native_library_impl(ctx: AnalysisContext) -> list[Provider]: 15 | if ctx.attrs.is_asset and ctx.attrs.has_wrap_script: 16 | fail("Cannot use `is_asset` and `has_wrap_script` in the same rule") 17 | 18 | prebuilt_native_library_dir = PrebuiltNativeLibraryDir( 19 | raw_target = ctx.label.raw_target(), 20 | dir = ctx.attrs.native_libs, 21 | for_primary_apk = ctx.attrs.has_wrap_script, 22 | is_asset = ctx.attrs.is_asset, 23 | ) 24 | android_packageable_info = merge_android_packageable_info( 25 | ctx.label, 26 | ctx.actions, 27 | ctx.attrs.deps, 28 | prebuilt_native_library_dir = prebuilt_native_library_dir, 29 | ) 30 | return [ 31 | # Buck1 copies the input directory and returns it as the output path. We don't 32 | # copy; we could just return the input directory itself as the output path, but 33 | # we're avoiding that (due to potential confusion from the output path being an 34 | # input directory) until we have an actual need for prebuilt_native_library 35 | # having an output path. 36 | DefaultInfo(), 37 | android_packageable_info, 38 | ] 39 | -------------------------------------------------------------------------------- /haskell/link_info.bzl: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under both the MIT license found in the 4 | # LICENSE-MIT file in the root directory of this source tree and the Apache 5 | # License, Version 2.0 found in the LICENSE-APACHE file in the root directory 6 | # of this source tree. 7 | 8 | load( 9 | "@prelude//cxx:cxx_toolchain_types.bzl", 10 | "CxxToolchainInfo", 11 | ) 12 | load( 13 | "@prelude//haskell:library_info.bzl", 14 | "HaskellLibraryInfoTSet", 15 | ) 16 | load( 17 | "@prelude//linking:link_info.bzl", 18 | "LinkStyle", 19 | ) 20 | 21 | # A list of `HaskellLibraryInfo`s. 22 | HaskellLinkInfo = provider( 23 | # Contains a list of HaskellLibraryInfo records. 24 | fields = { 25 | "info": provider_field(dict[LinkStyle, HaskellLibraryInfoTSet]), 26 | "prof_info": provider_field(dict[LinkStyle, HaskellLibraryInfoTSet]), 27 | }, 28 | ) 29 | 30 | # HaskellProfLinkInfo exposes the MergedLinkInfo of a target and all of its 31 | # dependencies built for profiling. This allows top-level targets (e.g. 32 | # `haskell_binary`) to be defined with profiling enabled by default. 33 | HaskellProfLinkInfo = provider( 34 | fields = { 35 | "prof_infos": provider_field(typing.Any, default = None), # MergedLinkInfo 36 | }, 37 | ) 38 | 39 | def cxx_toolchain_link_style(ctx: AnalysisContext) -> LinkStyle: 40 | return ctx.attrs._cxx_toolchain[CxxToolchainInfo].linker_info.link_style 41 | 42 | def attr_link_style(ctx: AnalysisContext) -> LinkStyle: 43 | if ctx.attrs.link_style != None: 44 | return LinkStyle(ctx.attrs.link_style) 45 | else: 46 | return cxx_toolchain_link_style(ctx) 47 | --------------------------------------------------------------------------------