Skip to main content

Rules

The rules of the prelude that have a reference page. A build file can use them without a load().

RuleCategoryDescription
aliascoreAn alias() gives another name to a target.
android_aarandroidAn android_aar() rule is used to generate an Android AAR.
android_app_modularityandroidAn android_app_modularity() rule is used to determine the modular structure of an Android app.
android_binaryandroidAn android_binary() rule is used to generate an Android APK.
android_build_configandroidAn android_build_config() rule is used to generate a BuildConfig class with global configuration variables that other android_library() rules can compile against.
android_bundleandroidAn android_bundle() rule is used to generate an Android App Bundle (AAB).
android_emulatorsandroid
android_instrumentation_apkandroidAn android_instrumentation_apk() rule is used to generate an Android Instrumentation APK.
android_instrumentation_testandroidAn android_instrumentation_test() rule is used to define apks that should be used to run Android instrumentation tests.
android_libraryandroidAn android_library() rule is used to define a set of Java files that can be compiled together against the Android SDK.
android_manifestandroidAn android_manifest() rule is used to generate an Android Manifest to be used by android_binary() and android_aar() rules.
android_prebuilt_aarandroidAn android_prebuilt_aar() rule takes an .aar file and makes it available as an Android dependency.
android_resourceandroidAn android_resource() rule is used to bundle Android resources that are traditionally stored in res and assets directories.
apk_genruleandroidAn apk_genrule() rule is used to post-process an APK.
apple_app_intentsappleAn apple_app_intents() rule represents App Intents definitions for Apple platforms.
apple_asset_catalogappleAn apple_asset_catalog() rule contains resources stored in Apple asset catalog directories.
apple_binaryappleAn apple_binary() rule builds a native executable - such as an iOS or OSX app - from the supplied set of Objective-C/C++ source files and dependencies.
apple_bundleappleAn apple_bundle() rule takes an Apple binary and all of the resources and asset catalogs in the rule's transitive dependencies and generates a bundle containing all of those files.
apple_info_plistappleAn apple_info_plist() rule defines mutations to apply to an Info.plist file.
apple_ipa_packageappleAn apple_ipa_package() rule packages an apple_bundle() into an IPA file for distribution.
apple_libraryappleAn apple_library() rule represents a set of Objective-C/C++/Swift source files and is similar to a cxx_library() rule with which it shares many attributes.
apple_library_for_distributionappleAn apple_library_for_distribution() rule creates a library for distribution (for instance via a Framework or Xcframework) with link group support.
apple_macos_bundleappleAn apple_macos_bundle() rule generates a macOS application bundle.
apple_metal_libraryappleAn apple_metal_library() rule contains .metal and .h source files to be bundled together to create a .metallib
apple_packageappleAn apple_package() rule takes the output of an apple_bundle() rule and compresses it in an IPA (iOS App Store Package) file.
apple_provisioning_profile_sourcesappleAn apple_provisioning_profile_sources() rule specifies a set of provisioning profile targets that are available for code signing Apple bundles.
apple_resourceappleAn apple_resource() rule contains sets of resource directories, files and file variants that can be bundled in an application bundle.
apple_resource_dedupe_aliasappleAn apple_resource_dedupe_alias() rule creates an alias for a resource target with a resource configuration transition applied.
apple_selective_debuggingappleAn apple_selective_debugging() rule configures which targets have debug information included in the final binary.
apple_simulatorsappleAn apple_simulators() rule configures the Apple simulator environment used for running tests.
apple_spm_packageappleAn apple_spm_package() rule packages a set of dependencies into a Swift Package Manager (SPM) compatible package.
apple_static_archiveappleAn apple_static_archive() rule combines one or more Apple libraries into a single static archive (.a file).
apple_testappleAn apple_test() rule contains Objective-C/C++ code which can be built and used to test code contained in other rules.
apple_toolchainappleAn apple_toolchain() rule defines the set of tools and settings used to build Apple targets.
apple_toolsappleThe apple_tools rule exposes a set of supplementary tools required by the Apple rules internally.
apple_universal_executableappleAn apple_universal_executable() rule takes a target via its binary attribute, builds it for multiple architectures and combines the result into a single binary using lipo.
apple_watchos_bundleappleAn apple_watchos_bundle() rule generates a watchOS application bundle.
apple_xcframeworkappleAn apple_xcframework() rule packages a framework target built for multiple platforms (e.g., iOS device, iOS simulator, macOS) into a single .xcframework bundle that can be distributed and consumed by Xcode projects or other build systems.
apple_xcuitestappleAn apple_xcuitest() rule defines an XCUITest UI test target.
build_variantscoreA build_variants() rule lists the named ways of building one target: for each variant, the target platform to build for, and the buckconfigs, modefiles and modifiers to build with.
command_aliascoreThe command_alias rule enables you to wrap build rules that create binaries and to pre-apply command-line arguments and environment variables.
config_settingcoreconfig_setting() accepts a list of constraint_values and a list of values (buckconfig keys + expected values) and matches if all of those match.
configuration_aliascoreconfiguration_alias() acts like alias() but for configuration targets.
configured_aliascoreA configured_alias() is an alias for a target as it is built for one platform.
constraintcoreUnified constraint rule that defines both a constraint setting and its possible values.
constraint_settingcoreDeprecated: use constraint() instead.
constraint_valuecoreDeprecated: use constraint() instead.
core_data_modelappleAn core_data_model() rule contains models for Apple's Core Data framework.
csharp_binary.NETA csharp_binary() rule builds a .Net executable from the supplied set of C# source files and dependencies by invoking csc.
csharp_library.NETA csharp_library() rule builds a .Net library from the supplied set of C# source files and dependencies by invoking csc.
cxx_binarycxxA cxx_binary() rule builds a native executable from the supplied set of C/C++ source files and dependencies.
cxx_flagscxxA cxx_flags() target holds flags that C++ targets pull in through their flags attribute.
cxx_genrulecxxA cxx_genrule() enables you to run shell commands as part of the Buck build process.
cxx_headers_bundlecxxBundles transitive exported C/C++ headers from C/C++ libraries, allowing them to e.g. be consumed via the resourcess parameter in other rules.
cxx_librarycxxA cxx_library() rule specifies a set of C/C++ source files and also provides flags that specify how those files should be built.
cxx_lua_extensionluaA cxx_lua_extension() rule is a variant of a C/C++ library which is built as a Lua module.
cxx_precompiled_headercxxA cxx_precompiled_header rule specifies a single header file that can be precompiled and made available for use in other build rules such as a cxx_library() or a cxx_binary().
cxx_python_extensionpythonA cxx_python_extension() rule is a variant of a C/C++ library which is built as a Python module.
cxx_testcxxA cxx_test() rule builds a C/C++ binary against a C/C++ testing framework and runs it as part of test.
cxx_toolchaincxxA cxx_toolchain() rule declares a complete C/C++ toolchain — a set of compilers (C, C++, Objective-C, asm, CUDA, HIP, etc.), preprocessors, linker, archiver, and binary utilities (strip, objcopy, dwp, nm, etc.) — along with the flags and behavior options that control how each tool is invoked.
cxx_toolchain_overridecxx
cxx_universal_executableappleA cxx_universal_executable() rule takes a target via its binary attribute, builds it for multiple architectures and combines the result into a single binary using lipo.
cython_librarycythonA rule that compiles Cython (.pyx) sources into Python C extensions.
cython_static_extensioncythonA rule that compiles a single Cython (.pyx) source into a statically-linkable Python C extension.
cython_toolchaincythonA toolchain rule that provides the Cython compiler configuration.
erlang_apperlangThis rule is the main rule for Erlang applications.
erlang_app_includeserlangThis rule is a supplementary rule for Erlang applications.
erlang_escripterlangThe erlang_escript target builds and runs bundled escripts.
erlang_otp_binarieserlangThis target defines the executables for the Erlang toolchains, and is required to defined a toolchain.
erlang_releaseerlangThe erlang_release target builds OTP releases.
erlang_testerlangThe erlang_test ruls defines a test target for a single test suite.
exec_platform_marker_constraintcoreSpecial constraint rule for defining execution platform markers.
export_filecoreAn export_file() takes a single file or folder and exposes it so other rules can use it.
extract_archivecoreExtracts an archive into a directory.
filegroupcoreThis rule provides access to a set of files.
gen_aidlandroidA gen_aidl() rule is used to generate .java files from .aidl files.
genrulecoreA genrule() is used to generate files from a shell command.
git_fetchgitCheckout a commit from a git repository.
go_binarygoA go_binary() rule builds a native executable from the supplied set of Go source files and dependencies.
go_bootstrap_binarygoA go_bootstrap_binary() rule builds a minimal Go executable used during bootstrap, where the full go_binary() machinery is not yet available.
go_exported_librarygoA go_exported_library() rule builds a C library from the supplied set of Go source files and dependencies.
go_librarygoA go_library() rule builds a native library from the supplied set of Go source files and dependencies.
go_stdlibgoA go_stdlib() rule represents the Go standard library for the target configuration.
go_testgoA go_test() rule builds a native binary from the specified Go source and resource files—and a generated main file.
gwt_binaryjavaA gwt_binary() rule produces a GWT (Google Web Toolkit) application by invoking the GWT compiler against the listed modules.
haskell_binaryhaskellA haskell_binary() rule represents a groups of Haskell sources and deps which build an executable.
haskell_ghcihaskellA haskell_ghci() rule produces a deployable script that launches a GHCi session with the given sources and dependencies preloaded.
haskell_haddockhaskellA haskell_haddock() rule generates Haddock documentation for the given Haskell dependencies.
haskell_idehaskellA haskell_ide() rule defines a project set for use with an LSP-based Haskell IDE (such as ghcide/HLS).
haskell_libraryhaskellA haskell_library() rule is used to identity a group of Haskell sources.
haskell_prebuilt_libraryhaskellA prebuilt_haskell_library() rule is used to identify Haskell prebuilt libraries and their associated interface files.
http_archivecoreAn http_archive() rule is used to download and extract archives from the Internet to be used as dependencies for other rules.
http_filecoreAn http_file() rule is used to download files from the Internet to be used as dependencies for other rules.
jar_genrulejavaA jar_genrule() is a variant of genrule() whose output is packaged into a JAR file.
java_annotation_processorjavaA java_annotation_processor() rule declares a Java annotation processor (identified by processor_class) that can be referenced from java_library() and kotlin_library() rules to run during compilation.
java_binaryjavaA java_binary() rule is used to create a JAR file of the compiled .class files and resources of the java_library() rules on which it depends.
java_libraryjavaA java_library() rule defines a set of Java files that can be compiled together.
java_pluginjavaA java_plugin() rule declares a javac plugin (identified by plugin_name) that can be referenced from java_library() and kotlin_library() rules to run during compilation.
java_testjavaA java_test() rule is used to define a set of .java files that contain tests to run via JUnit.
js_bundlejsA js_bundle() rule builds a JavaScript bundle from one or more entry points, pulling in js_library() dependencies and invoking a worker tool to perform the bundling.
js_bundle_genrulejsjs_bundle_genrule is a genrule that acts on a js_bundle and provides a bunch of additional environment variables for the genrule to use.
js_libraryjsA js_library() rule groups together JavaScript source files and assets so they can be consumed by a js_bundle().
julia_binaryjulia
julia_jll_libraryjulia
julia_libraryjulia
julia_testjulia
keystoreandroidA keystore() contains the data for a key pair created by the keytool executable that comes with the JDK.
kotlin_librarykotlinA kotlin_library() rule is used to define a set of Kotlin files that can be compiled together.
kotlin_testkotlinA kotlin_test() rule is used to define a set of .kt files that contain tests to run via JUnit.
link_group_mapcxx
llvm_link_bitcodecxxAn llvm_link_bitcode() rule combines a set of LLVM bitcode inputs into a single bitcode object using llvm-link.
lua_binaryluaA lua_binary() rule is used to build an executable that uses Lua sources from all transitive lua_library() dependencies.
lua_libraryluaA lua_library() rule is used to group together Lua sources to be packaged into a top-level lua_binary() rule.
matlab_programmatlab
mockingbird_mockappleA mockingbird_mock() rule generates mock implementations using the Mockingbird mocking framework.
ndk_toolchainandroid
nodejs_binarynodejsA runnable Node.js script, executed with the toolchain's Node runtime and no custom loaders.
nodejs_buildnodejsRuns a Node.js build tool, such as a bundler, as a build action, and outputs the directory it writes.
nodejs_librarynodejsA Node.js library that packages code as a regular node_modules package loadable by Node without custom loaders.
nodejs_node_modulesnodejsA prebuilt node_modules directory tree, for third-party packages with no nodejs_library target (e.g. a yarn install output).
nodejs_runtimenodejsA Node.js runtime that an app runs on or ships with, provided as NodejsRuntimeInfo.
nodejs_testnodejsA Node.js test, run with the toolchain's Node runtime and no custom loaders.
ocaml_binaryocamlA ocaml_binary() rule builds both native and bytecode executables from the supplied set of OCaml and C source files and dependencies.
ocaml_libraryocamlA ocaml_library() rule builds a native and a bytecode libraries from the supplied set of OCaml source files and dependencies.
ocaml_objectocaml
ocaml_sharedocaml
platformcoreDeclares a platform, which is a build configuration composed of constraint values.
prebuilt_apple_frameworkappleA prebuilt_apple_framework() rule represents a set of Objective-C/C++ source files and is very similar to a prebuilt_cxx_library() rule.
prebuilt_cxx_librarycxxA prebuilt_cxx_library() rule represents a set of native libraries and C/C++ header files and provides various flags to control how they are linked and exported.
prebuilt_cxx_library_groupcxxA prebuilt_cxx_library_group() rule represents a group of native libraries which should be handled together in a single rule, perhaps using special link-line construction.
prebuilt_dotnet_library.NETA prebuilt_dotnet_library() rule is used to include prebuilt .Net assembles into your .Net code.
prebuilt_jarjavaA prebuilt_jar() rule is used to identify a JAR file that is checked into our repository as a precompiled binary rather than one that is built from source by Buck.
prebuilt_native_libraryandroidA prebuilt_native_library() rule is used to bundle native libraries (i.e., .so files) for Android.
prebuilt_ocaml_libraryocamlA prebuilt_ocaml_library() rule wraps a precompiled OCaml library (bytecode and/or native) along with any companion C libraries so it can be consumed as a dependency by ocaml_binary() and ocaml_library() rules.
prebuilt_python_librarypythonA prebuilt_python_library() rule is used to include prebuilt python packages into the output of a top-level python_binary() or python_test() rule.
python_binarypythonA python_binary() rule is used to build an executable Python package that includes Python sources and resources from all transitive dependencies.
python_bootstrap_binarypythonA python_bootstrap_binary() rule declares a Python binary intended to be used in scripts that bootstrap other aspects of the Buck2 prelude.
python_bootstrap_binary_stage0python
python_bootstrap_librarypythonA python_bootstrap_library() rule groups together Python sources that may be consumed by python_bootstrap_binary() targets or by other python_bootstrap_library() rules.
python_librarypythonA python_library() rule is used to group together Python source files and resources to be passed together in as a dep of other rules.
python_needed_coverage_testpythonA python_needed_coverage_test() rule wraps an existing python_test() target so that it runs as a coverage-collecting bundle and is checked against per-module coverage thresholds.
python_runtime_bundlepythonA python_runtime_bundle() rule declares a bundled Python runtime — a full install of Python including the interpreter, standard library, headers, and optionally libpython.so and additional shared libraries — that can be embedded in a PAR to produce a fully hermetic distribution.
python_testpythonA python_test() rule defines a set of .py files that contain tests to run via the Python unit testing framework.
remote_filecoreA remote_file() rule is used to download files from the Internet to be used as dependencies for other rules.
required_reasons_toolsappleA required_reasons_tools() rule bundles the tools used to validate Apple Required Reasons API (RRAPI) usage against a bundle's .xcprivacy privacy manifest.
resource_group_mapappleA resource_group_map() rule defines a mapping of resource groups for an apple_bundle().
robolectric_testandroidA robolectric_test() rule is used to define a set of .java files that contain tests to run via JUnit with Robolectric test runner.
rust_binaryrustA rust_binary() rule builds a native executable from the supplied set of Rust source files and dependencies.
rust_libraryrustA rust_library() rule builds a native library from the supplied set of Rust source files and dependencies.
rust_python_extensionrustA rust_python_extension() rule builds a Python extension module from Rust source code (typically using PyO3), producing a .so or a Windows .pyd.
rust_testrustA rust_test() rule builds a Rust test native executable from the supplied set of Rust source files and dependencies and runs this test.
scene_kit_assetsappleA scene_kit_assets() rule specifies a SceneKit asset catalog (.scnassets directory) to be included in an apple_bundle().
sh_binaryshellAn sh_binary() is used to execute a shell script.
sh_testshellA sh_test() is a test rule that can pass results to the test runner by invoking a shell script.
swift_toolchainappleA swift_toolchain() rule defines the Swift compiler and associated tools used to build Swift code in Apple targets.
test_suitecoreA test_suite() is used to create a grouping of tests that should all be run by just testing this rule.
toolchain_aliascoretoolchain_alias acts like alias but for toolchain rules.
transformation_speccxxA transformation_spec() rule declares a list of transformation rules that map targets (by Label, by build target pattern, or by build graph pattern) to a TransformationKind (debug or optimized).
versioned_aliascore
windows_resourcecxxA windows_resource() rule specifies a set of Window's Resource File (.rc) that are compiled into object files.
worker_toolcoreSome external tools have high startup costs.
write_filecoreWrites a text file from lines given in the build file.
xcode_filesapple
zip_filecoreA zip_file() allows builds to create basic zip files in a platform-agnostic way.