diff --git a/about/faq.mdx b/about/faq.mdx index fa5a4d0c..dd5be8a9 100644 --- a/about/faq.mdx +++ b/about/faq.mdx @@ -157,6 +157,10 @@ Bazel returns a non-zero exit code if the build or test invocation fails, and th Further details on exit codes are in the [User Manual](/docs/user-manual). +## What future features can we expect in Bazel? + +See our [Roadmaps](/about/roadmap). + ## Can I use Bazel for my INSERT LANGUAGE HERE project? Bazel is extensible. Anyone can add support for new languages. Many languages are supported: see the [build encyclopedia](/reference/be/overview) for a list of recommendations and [awesomebazel.com](https://awesomebazel.com/) for a more comprehensive list. diff --git a/about/intro.mdx b/about/intro.mdx index 242a7993..a531ac2a 100644 --- a/about/intro.mdx +++ b/about/intro.mdx @@ -9,7 +9,7 @@ It uses a human-readable, high-level build language. Bazel supports projects in multiple languages and builds outputs for multiple platforms. Bazel supports large codebases across multiple repositories, and large numbers of users. -## Benefits {#benefits} +## Benefits Bazel offers the following advantages: @@ -38,7 +38,7 @@ Bazel offers the following advantages: supported, and you can extend Bazel to support any other language or framework. -## Using Bazel {#using-bazel} +## Using Bazel To build or test a project with Bazel, you typically do the following: @@ -71,7 +71,7 @@ In addition to building, you can also use Bazel to run [tests](/reference/test-encyclopedia) and [query](/query/guide) the build to trace dependencies in your code. -## Bazel build process {#bazel-build-process} +## Bazel build process When running a build or a test, Bazel does the following: @@ -91,7 +91,7 @@ correctness, you can set up Bazel to run builds and tests [hermetically](/basics/hermeticity) through sandboxing, minimizing skew and maximizing [reproducibility](/run/build#correct-incremental-rebuilds). -### Action graph {#action-graph} +### Action graph The action graph represents the build artifacts, the relationships between them, and the build actions that Bazel will perform. Thanks to this graph, Bazel can @@ -100,7 +100,7 @@ file content as well as changes to actions, such as build or test commands, and know what build work has previously been done. The graph also enables you to easily [trace dependencies](/query/guide) in your code. -## Getting started tutorials {#getting-started-tutorials} +## Getting started tutorials To get started with Bazel, see [Getting Started](/start/) or jump directly to the Bazel tutorials: diff --git a/about/vision.mdx b/about/vision.mdx index dafc64b6..da0ed02d 100644 --- a/about/vision.mdx +++ b/about/vision.mdx @@ -45,7 +45,7 @@ Bazel's abstraction layer — instructions specific to languages, platforms, and toolchains implemented in a simple extensibility language — allows it to be easily applied to any context. -## Bazel core competencies {#bazel-core-competencies} +## Bazel core competencies 1. Bazel supports **multi-language, multi-platform** builds and tests. You can run a single command to build and test your entire source tree, no matter @@ -62,7 +62,7 @@ easily applied to any context. possible. Bazel interfaces with de-facto standard tools for a given language/platform. -## Serving language communities {#language-communities} +## Serving language communities Software engineering evolves in the context of language communities — typically, self-organizing groups of people who use common tools and practices. @@ -73,7 +73,7 @@ available that integrate with the workflows and conventions of that community. Bazel is committed to be extensible and open, and to support good rulesets for any language. -### Requirements of a good ruleset {#ruleset-requirements} +### Requirements of a good ruleset 1. The rules need to support efficient **building and testing** for the language, including code coverage. diff --git a/about/why.mdx b/about/why.mdx index 6ddd3225..6224abf6 100644 --- a/about/why.mdx +++ b/about/why.mdx @@ -9,7 +9,7 @@ build tool with [integrated testing](#integrated-testing) that supports multiple [languages](#multi-language), [repositories](#multi-repository), and [platforms](#multi-platform) in an industry-leading [ecosystem](#ecosystem). -## Bazel is fast {#fast} +## Bazel is fast Bazel knows exactly what input files each build command needs, avoiding unnecessary work by re-running only when the set of input files have @@ -22,7 +22,7 @@ This is supported by multiple caching layers, in memory, on disk and on the remote build farm, if available. At Google, we routinely achieve cache hit rates north of 99%. -## Bazel is correct {#correct} +## Bazel is correct Bazel ensures that your binaries are built *only* from your own source code. Bazel actions run in individual sandboxes and Bazel tracks @@ -34,7 +34,7 @@ by bit. Say goodbye to endless `make clean` invocations and to chasing phantom bugs that were in fact resolved in source code that never got built. -## Bazel is extensible {#extensible} +## Bazel is extensible Harness the full power of Bazel by writing your own rules and macros to customize Bazel for your specific needs across a wide range of projects. @@ -44,7 +44,7 @@ in-house programming language that's a subset of Python. Starlark makes rule-writing accessible to most developers, while also creating rules that can be used across the ecosystem. -## Integrated testing {#integrated-testing} +## Integrated testing Bazel's [integrated test runner](/docs/user-manual#running-tests) knows and runs only those tests needing to be re-run, using remote execution @@ -55,28 +55,28 @@ Bazel [provides facilities](/remote/bep) to upload test results to a central location, thereby facilitating efficient communication of test outcomes, be it on CI or by individual developers. -## Multi-language support {#multi-language} +## Multi-language support Bazel supports many common programming languages including C++, Java, Kotlin, Python, Go, and Rust. You can build multiple binaries (for example, backend, web UI and mobile app) in the same Bazel invocation without being constrained to one language's idiomatic build tool. -## Multi-repository support {#multi-repository} +## Multi-repository support Bazel can [gather source code from multiple locations](/external/overview): you don't need to vendor your dependencies (but you can!), you can instead point Bazel to the location of your source code or prebuilt artifacts (e.g. a git repository or Maven Central), and it takes care of the rest. -## Multi-platform support {#multi-platform} +## Multi-platform support Bazel can simultaneously build projects for multiple platforms including Linux, macOS, Windows, and Android. It also provides powerful [cross-compilation capabilities](/extending/platforms) to build code for one platform while running the build on another. -## Wide ecosystem {#ecosystem} +## Wide ecosystem [Industry leaders](/community/users) love Bazel, building a large community of developers who use and contribute to Bazel. Find a tools, services diff --git a/advanced/performance/build-performance-metrics.mdx b/advanced/performance/build-performance-metrics.mdx index 46a77324..8391ea87 100644 --- a/advanced/performance/build-performance-metrics.mdx +++ b/advanced/performance/build-performance-metrics.mdx @@ -23,7 +23,7 @@ how you can use these metrics to detect and fix build performance issues. There are a few main ways to extract metrics from your Bazel builds, namely: -## Build Event Protocol (BEP) {#build-event-protocol} +## Build Event Protocol (BEP) Bazel outputs a variety of protocol buffers [`build_event_stream.proto`](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto) @@ -32,7 +32,7 @@ can be aggregated by a backend specified by you. Depending on your use cases, you might decide to aggregate the metrics in various ways, but here we will go over some concepts and proto fields that would be useful in general to consider. -## Bazel’s query / cquery / aquery commands {#bazel-commands-query-cquery-aquery} +## Bazel’s query / cquery / aquery commands Bazel provides 3 different query modes ([query](/query/quickstart), [cquery](/query/cquery) and [aquery](/query/aquery)) that allow users @@ -41,14 +41,14 @@ respectively. The query language provides a [suite of functions](/query/language#functions) usable across the different query modes, that allows you to customize your queries according to your needs. -## JSON Trace Profiles {#json-trace-profiles} +## JSON Trace Profiles For every build-like Bazel invocation, Bazel writes a trace profile in JSON format. The [JSON trace profile](/advanced/performance/json-trace-profile) can be very useful to quickly understand what Bazel spent time on during the invocation. -## Execution Log {#execution-log} +## Execution Log The [execution log](/remote/cache-remote) can help you to troubleshoot and fix missing remote cache hits due to machine and environment differences or @@ -60,7 +60,7 @@ make comparisons between local and remote machine performance or to find out which part of the spawn execution is consistently slower than expected (for example due to queuing). -## Execution Graph Log {#execution-graph-log} +## Execution Graph Log While the JSON trace profile contains the critical path information, sometimes you need additional information on the dependency graph of the executed actions. @@ -76,7 +76,7 @@ by removing a particular node from the execution graph. The data helps you predict the impact of changes to the build and action graph before you actually do them. -## Benchmarking with bazel-bench {#bazel-bench} +## Benchmarking with bazel-bench [Bazel bench](https://github.com/bazelbuild/bazel-bench) is a benchmarking tool for Git projects to benchmark build performance in the diff --git a/advanced/performance/iteration-speed.mdx b/advanced/performance/iteration-speed.mdx index 763af9c9..2bbf8398 100644 --- a/advanced/performance/iteration-speed.mdx +++ b/advanced/performance/iteration-speed.mdx @@ -7,7 +7,7 @@ title: 'Optimize Iteration Speed' This page describes how to optimize Bazel's build performance when running Bazel repeatedly. -## Bazel's Runtime State {#bazel-runtime-state} +## Bazel's Runtime State A Bazel invocation involves several interacting parts. @@ -32,7 +32,7 @@ A Bazel invocation involves several interacting parts. * The result of the Bazel invocation is made available in the output tree. -## Running Bazel Iteratively {#run-iteratively} +## Running Bazel Iteratively In a typical developer workflow, it is common to build (or run) a piece of code repeatedly, often at a very high frequency (e.g. to resolve some compilation @@ -64,7 +64,7 @@ cache can be kept locally [remotely](https://bazel.build/remote/caching). The cache can be shared among Bazel servers, and indeed among developers. -## Avoid discarding the analysis cache {#avoid-discarding-cache} +## Avoid discarding the analysis cache Bazel will print a warning if either the analysis cache was discarded or the server was restarted. Either of these should be avoided during iterative use: diff --git a/advanced/performance/json-trace-profile.mdx b/advanced/performance/json-trace-profile.mdx index 0e936455..80c698c0 100644 --- a/advanced/performance/json-trace-profile.mdx +++ b/advanced/performance/json-trace-profile.mdx @@ -76,7 +76,7 @@ $ zcat $(../bazel-6.0.0rc1-linux-x86_64 info output_base)/command.profile.gz | j [...] ``` -## Profile information {#profile-information} +## Profile information The profile contains multiple rows. Usually the bulk of rows represent Bazel threads and their corresponding events, but some special rows are also included. @@ -99,7 +99,7 @@ Figure 1 shows a profile created with Bazel v5.3.1 and includes these rows: * `Garbage Collector`: Displays minor and major Garbage Collection (GC) pauses. -## Common performance issues {#common-performance-issues} +## Common performance issues When analyzing performance profiles, look for: @@ -117,7 +117,7 @@ When analyzing performance profiles, look for: or Bazel itself to introduce more parallelism. This can also happen when there is an unusual amount of GC. -## Profile file format {#profile-file-format} +## Profile file format The top-level object contains metadata (`otherData`) and the actual tracing data (`traceEvents`). The metadata contains extra info, for example the invocation ID diff --git a/advanced/performance/memory.mdx b/advanced/performance/memory.mdx index 017d9cb3..844e691b 100644 --- a/advanced/performance/memory.mdx +++ b/advanced/performance/memory.mdx @@ -6,14 +6,14 @@ title: 'Optimize Memory' This page describes how to limit and reduce the memory Bazel uses. -## Running Bazel with Limited RAM {#running-bazel} +## Running Bazel with Limited RAM In certain situations, you may want Bazel to use minimal memory. You can set the maximum heap via the startup flag [`--host_jvm_args`](/docs/user-manual#host-jvm-args), like `--host_jvm_args=-Xmx2g`. -### Trade incremental build speeds for memory {#trade-incremental} +### Trade incremental build speeds for memory If your builds are too big, Bazel may throw an `OutOfMemoryError` (OOM) when it doesn't have enough memory. You can make Bazel use less memory, at the cost @@ -40,7 +40,7 @@ prevent most re-execution). incremental builds have to build from scratch (except for the on-disk action cache). Alone, it does not affect the high-water mark of the current build. -### Trade build flexibility for memory with Skyfocus (Experimental) {#trade-flexibility} +### Trade build flexibility for memory with Skyfocus (Experimental) If you want to make Bazel use less memory *and* retain incremental build speeds, you can tell Bazel the working set of files that you will be modifying, and @@ -59,11 +59,11 @@ changes to files outside of the working set will be disallowed, until you issue `bazel clean` or restart the Bazel server. If you want to specify an exact set of files or directories, use the -`--experimental_active_directories` flag, like so: +`--experimental_working_set` flag, like so: ```sh bazel build //pkg:target --experimental_enable_skyfocus ---experimental_active_directories=path/to/another/dir,path/to/tests/dir +--experimental_working_set=path/to/another/dir,path/to/tests/dir ``` You can also pass `--experimental_skyfocus_dump_post_gc_stats` to show the @@ -72,7 +72,7 @@ memory reduction amount: Putting it altogether, you should see something like this: ```none -$ bazel test //pkg:target //tests/... --experimental_enable_skyfocus --experimental_active_directories=dir1,dir2,dir3/subdir --experimental_skyfocus_dump_post_gc_stats +$ bazel test //pkg:target //tests/... --experimental_enable_skyfocus --experimental_working_set dir1,dir2,dir3/subdir --experimental_skyfocus_dump_post_gc_stats INFO: --experimental_enable_skyfocus is enabled. Blaze will reclaim memory not needed to build the working set. Run 'blaze dump --skyframe=working_set' to show the working set, after this command. WARNING: Changes outside of the working set will cause a build error. INFO: Analyzed 149 targets (4533 packages loaded, 169438 targets configured). @@ -89,7 +89,7 @@ and incremental builds to handle changes to files under `dir1`, `dir2`, and `dir3/subdir` will retain their fast speeds, with the tradeoff that Bazel cannot rebuild changed files outside of these directories. -## Memory Profiling {#memory-profiling} +## Memory Profiling Bazel comes with a built-in memory profiler that can help you check your rule’s memory use. Read more about this process on the diff --git a/basics/dependencies.mdx b/basics/dependencies.mdx index 79d73e45..1d3bf8f1 100644 --- a/basics/dependencies.mdx +++ b/basics/dependencies.mdx @@ -67,7 +67,8 @@ targets, we’ve made some strides in mitigating the downside by investing in tooling to automatically manage `BUILD` files to avoid burdening developers. Some of these tools, such as `buildifier` and `buildozer`, are available with -Bazel in the [`buildtools` directory](https://github.com/bazelbuild/buildtools). +Bazel in the [`buildtools` +directory](https://github.com/bazelbuild/buildtools). ## Minimizing Module Visibility @@ -107,7 +108,8 @@ transitive dependencies (Figure 1). Suppose target A depends on target B, which depends on a common library target C. Should target A be able to use classes defined in target C? -[![Transitive dependencies](/images/transitive-dependencies.png)](/images/transitive-dependencies.png) +[![Transitive +dependencies](/images/transitive-dependencies.png)](/images/transitive-dependencies.png) **Figure 1**. Transitive dependencies @@ -141,7 +143,9 @@ dependencies and adding them to a `BUILD` files without any developer intervention. But even without such tools, we’ve found the trade-off to be well worth it as the codebase scales: explicitly adding a dependency to `BUILD` file is a one-time cost, but dealing with implicit transitive dependencies can cause -ongoing problems as long as the build target exists. Bazel [enforces strict transitive dependencies](https://blog.bazel.build/2017/06/28/sjd-unused_deps.html) +ongoing problems as long as the build target exists. Bazel [enforces strict +transitive +dependencies](https://blog.bazel.build/2017/06/28/sjd-unused_deps.html) on Java code by default. ### External dependencies @@ -190,7 +194,8 @@ so in theory there’s no reason that different versions of the same external dependency couldn’t both be declared in the build system under different names. That way, each target could choose which version of the dependency it wanted to use. This causes a lot of problems in practice, so Google enforces a strict -[One-Version Rule](https://opensource.google/docs/thirdparty/oneversion/) for +[One-Version +Rule](https://opensource.google/docs/thirdparty/oneversion/) for all third-party dependencies in our codebase. The biggest problem with allowing multiple versions is the diamond dependency @@ -229,7 +234,8 @@ Bazel did not use to automatically download transitive dependencies. It used to employ a `WORKSPACE` file that required all transitive dependencies to be listed, which led to a lot of pain when managing external dependencies. Bazel has since added support for automatic transitive external dependency management -in the form of the `MODULE.bazel` file. See [external dependency overview](/external/overview) for more details. +in the form of the `MODULE.bazel` file. See [external dependency +overview](/external/overview) for more details. Yet again, the choice here is one between convenience and scalability. Small projects might prefer not having to worry about managing transitive dependencies diff --git a/basics/hermeticity.mdx b/basics/hermeticity.mdx index 8f165a21..dcee3a9e 100644 --- a/basics/hermeticity.mdx +++ b/basics/hermeticity.mdx @@ -7,7 +7,7 @@ title: 'Hermeticity' This page covers hermeticity, the benefits of using hermetic builds, and strategies for identifying non-hermetic behavior in your builds. -## Overview {#overview} +## Overview When given the same input source code and product configuration, a hermetic build system always returns the same output by isolating the build from changes @@ -30,7 +30,7 @@ The two important aspects of hermeticity are: unique hash code. Hermetic build systems use this hash to identify changes to the build's input. -## Benefits {#benefits} +## Benefits The major benefits of hermetic builds are: @@ -45,7 +45,7 @@ The major benefits of hermetic builds are: * **Reproducibility**: Hermetic builds are good for troubleshooting because you know the exact conditions that produced the build. -## Identifying non-hermeticity {#nonhermeticity} +## Identifying non-hermeticity If you are preparing to switch to Bazel, migration is easier if you improve your existing builds' hermeticity in advance. Some common sources of @@ -61,7 +61,7 @@ non-hermeticity in builds are: tree, fixing the source tree for target A. Then trying to build target B may fail. -## Troubleshooting non-hermetic builds {#troubleshooting-nonhermeticity} +## Troubleshooting non-hermetic builds Starting with local execution, issues that affect local cache hits reveal non-hermetic actions. @@ -94,7 +94,7 @@ Note: Make your build fully hermetic when mixing remote and local execution, using Bazel’s “dynamic strategy” functionality. Running Bazel inside the remote Docker container will enable the build to execute the same in both environments. -## Hermeticity with Bazel {#hermeticity-bazel} +## Hermeticity with Bazel For more information about how other projects have had success using hermetic builds with Bazel, see these BazelCon talks: diff --git a/brand/index.mdx b/brand/index.mdx index 0386d939..2a21cd43 100644 --- a/brand/index.mdx +++ b/brand/index.mdx @@ -10,7 +10,7 @@ the Apache-licensed Bazel repositories on GitHub. Any use of the Bazel Trademarks other than those permitted in these guidelines must be approved in advance. -## Purpose of the Brand Guidelines {#purpose-brand} +## Purpose of the Brand Guidelines These guidelines exist to ensure that the Bazel project can share its technology under open source licenses while making sure that the "Bazel" brand is protected @@ -18,7 +18,7 @@ as a meaningful source identifier in a way that's consistent with trademark law. By adhering to these guidelines, you help to promote the freedom to use and develop high-quality Bazel technology. -## Acceptable Uses {#acceptable-uses} +## Acceptable Uses Given the open nature of Bazel, you may use the Bazel trademark to refer to the project without prior written permission. Examples of these approved references @@ -38,7 +38,7 @@ Examples: * \[Your Product\] is compatible with Bazel * \[XYZ\] Conference for Bazel Users -## General Guidelines {#general-guidelines} +## General Guidelines * The Bazel name may never be used or registered in a manner that would cause confusion as to Google's sponsorship, affiliation, or endorsement. @@ -57,7 +57,7 @@ Examples: materials without prior written permission from [product@bazel.build](mailto:product@bazel.build). -## Usage for Events and Community Groups {#usage-events} +## Usage for Events and Community Groups The Bazel word mark may be used referentially in events, community groups, or other gatherings related to the Bazel build system, but it may not be used in a @@ -79,7 +79,7 @@ Examples of naming conventions that require prior written permission: * BazelCon * Bazel Conference -## Contact Us {#contact-us} +## Contact Us Please do not hesitate to contact us at [product@bazel.build](mailto:product@bazel.build) if you are unsure whether your diff --git a/build/style-guide.mdx b/build/style-guide.mdx index 3502de48..cfc3cf86 100644 --- a/build/style-guide.mdx +++ b/build/style-guide.mdx @@ -4,7 +4,7 @@ title: 'BUILD Style Guide' -## Prefer DAMP BUILD files over DRY {#prefer-damp-build-files-over-dry} +## Prefer DAMP BUILD files over DRY The DRY principle — "Don't Repeat Yourself" — encourages uniqueness by introducing abstractions such as variables and functions to avoid redundancy in @@ -18,7 +18,7 @@ maintain. code, but do need to be maintained by people and tools. That makes DAMP better for them than DRY. -## BUILD.bazel file formatting {#formatting} +## BUILD.bazel file formatting `BUILD` file formatting follows the same approach as Go, where a standardized tool takes care of most formatting issues. @@ -30,7 +30,7 @@ generate `BUILD` files. `BUILD` file formatting must match the output of `buildifier`. -### Formatting example {#formatting-example} +### Formatting example ```python # Test code implementing the Foo controller. @@ -55,7 +55,7 @@ py_test( ) ``` -## File structure {#file-structure} +## File structure **Recommendation**: Use the following order (every element is optional): @@ -79,7 +79,7 @@ changes (for example, to keep or remove a comment when deleting a rule). cc_library(name = "cc") ``` -## References to targets in the current package {#targets-current-package} +## References to targets in the current package Files should be referred to by their paths relative to the package directory (without ever using up-references, such as `..`). Generated files should be @@ -102,7 +102,7 @@ genrule( ) ``` -## Target naming {#target-naming} +## Target naming Target names should be descriptive. If a target contains one source file, the target should generally have a name derived from that source (for example, a @@ -146,7 +146,7 @@ recommendations that are broadly used at Google: * **`java_proto_library`**: `_java_proto` * **`java_lite_proto_library`**: `_java_proto_lite` -## Visibility {#visibility} +## Visibility Visibility should be scoped as tightly as possible, while still allowing access by tests and reverse dependencies. Use `__pkg__` and `__subpackages__` as @@ -158,7 +158,7 @@ project's public API. These could be libraries that are designed to be depended on by external projects or binaries that could be used by an external project's build process. -## Dependencies {#dependencies} +## Dependencies Dependencies should be restricted to direct dependencies (dependencies needed by the sources listed in the rule). Do not list transitive dependencies. @@ -173,12 +173,12 @@ dependencies of several targets into a variable reduces maintainability, makes it impossible for tools to change the dependencies of a target, and can lead to unused dependencies. -## Globs {#globs} +## Globs Indicate "no targets" with `[]`. Do not use a glob that matches nothing: it is more error-prone and less obvious than an empty list. -### Recursive {#recursive} +### Recursive Do not use recursive globs to match source files (for example, `glob(["**/*.java"])`). @@ -193,11 +193,11 @@ remote caching and parallelism. It is good practice to author a `BUILD` file in each directory and define a dependency graph between them. -### Non-recursive {#non-recursive} +### Non-recursive Non-recursive globs are generally acceptable. -## Avoid list comprehensions {#list-comprehensions} +## Avoid list comprehensions Avoid using list comprehensions at the top level of a `BUILD.bazel` file. Automate repetitive calls by creating each named target with a separate @@ -239,7 +239,7 @@ my_java_test(name = "test_fake_10", ... ``` -## Don't use deps variables {#no-dep-vars} +## Don't use deps variables Don't use list variables to encapsulate common dependencies: @@ -289,7 +289,7 @@ Let [Gazelle](https://github.com/bazel-contrib/bazel-gazelle) and other tools maintain them. There will be repetition, but you won't have to think about how to manage the dependencies. -## Prefer literal strings {#literal-strings} +## Prefer literal strings Although Starlark provides string operators for concatenation (`+`) and formatting (`%`), use them with caution. It is tempting to factor out common @@ -340,7 +340,7 @@ proto_library( [buildozer]: https://github.com/bazelbuild/buildtools/blob/main/buildozer/README.md -## Limit the symbols exported by each `.bzl` file {#limit-symbols} +## Limit the symbols exported by each `.bzl` file Minimize the number of symbols (rules, macros, constants, functions) exported by each public `.bzl` (Starlark) file. We recommend that a file should export @@ -352,7 +352,7 @@ symbols, causing changes to single files to force Bazel to rebuild many targets. [bzl_library]: https://github.com/bazelbuild/bazel-skylib/blob/main/README.md#bzl_library -## Other conventions {#other-conventions} +## Other conventions * Use uppercase and underscores to declare constants (such as `GLOBAL_CONSTANT`), use lowercase and underscores to declare variables (such as `my_variable`). @@ -371,7 +371,7 @@ symbols, causing changes to single files to force Bazel to rebuild many targets. "deflake this target by rerunning it once". `flaky = True` unambiguously says "this test is flaky". -## Differences with Python style guide {#differences-python-style-guide} +## Differences with Python style guide Although compatibility with [Python style guide](https://www.python.org/dev/peps/pep-0008/) diff --git a/community/recommended-rules.mdx b/community/recommended-rules.mdx index 7f5eef81..86daa056 100644 --- a/community/recommended-rules.mdx +++ b/community/recommended-rules.mdx @@ -11,7 +11,7 @@ This is a set of high quality rules, which will provide a good experience to our users. We make a distinction between the supported rules, and the hundreds of rules you can find on the Internet. -## Nomination {#nomination} +## Nomination If a ruleset meets the requirements below, a rule maintainer can nominate it to be part of the _recommended rules_ by filing a @@ -20,7 +20,7 @@ to be part of the _recommended rules_ by filing a After a review by the [Bazel core team](/contribute/policy), it will be recommended on the Bazel website. -## Requirements for the rule maintainers {#requirements-rule-maintainers} +## Requirements for the rule maintainers * The ruleset provides an important feature, useful to a large number of Bazel users (for example, support for a widely popular language). @@ -37,14 +37,14 @@ will be recommended on the Bazel website. should be fixed within two weeks. Migration issues should be reported to the Bazel team quickly. -## Requirements for Bazel developers {#requirements-dev} +## Requirements for Bazel developers * Recommended rules are frequently tested with Bazel at head (at least once a day). * No change in Bazel may break a recommended rule (with the default set of flags). If it happens, the change should be fixed or rolled back. -## Demotion {#demotion} +## Demotion If there is a concern that a particular ruleset is no longer meeting the requirements, a [GitHub issue](https://github.com/bazelbuild/bazel/) should be diff --git a/community/sig.mdx b/community/sig.mdx index 3b4d6635..ae5f9189 100644 --- a/community/sig.mdx +++ b/community/sig.mdx @@ -5,7 +5,8 @@ title: 'Bazel Special Interest Groups' Bazel hosts Special Interest Groups (SIGs) to focus collaboration on particular -areas and to support communication and coordination between [Bazel owners, maintainers, and contributors](/contribute/policy). This policy +areas and to support communication and coordination between [Bazel owners, +maintainers, and contributors](/contribute/policy). This policy applies to [`bazelbuild`](http://github.com/bazelbuild). SIGs do their work in public. The ideal scope for a SIG covers a well-defined diff --git a/community/users.mdx b/community/users.mdx index 227ee4bb..3f027c01 100644 --- a/community/users.mdx +++ b/community/users.mdx @@ -11,7 +11,7 @@ contact [product@bazel.build](mailto:product@bazel.build). This page lists companies and OSS projects that are known to use Bazel. This does not constitute an endorsement. -## Companies using Bazel {#companies-using-bazel} +## Companies using Bazel ### [acqio](https://acqio.com.br) @@ -320,9 +320,11 @@ safety systems_. Pigweed is an open-source solution for sustained, robust, and rapid embedded product development for large teams. Pigweed has shipped in millions of devices, including Google's suite of Pixel devices, Nest thermostats, -[satellites](https://www.spinlaunch.com/), and [autonomous aerial drones](https://www.flyzipline.com/). +[satellites](https://www.spinlaunch.com/), and [autonomous aerial +drones](https://www.flyzipline.com/). -Pigweed [uses Bazel as its primary build system](https://pigweed.dev/seed/0111-build-systems.html). The [Bazel for +Pigweed [uses Bazel as its primary build +system](https://pigweed.dev/seed/0111-build-systems.html). The [Bazel for Embedded][pw-bazel-great] blog post discusses why we think it's a great build system for embedded projects! @@ -379,10 +381,6 @@ Snap, the developer of Snapchat messaging app, has migrated from Buck to Bazel in 2020 ([source](https://twitter.com/wew/status/1326957862816509953)). For more details about their process, see their [engineering blog](https://eng.snap.com/blog/). -### [Spotify](https://spotify.com) - -Spotify is using Bazel to build their iOS and Android Apps ([source](https://twitter.com/BalestraPatrick/status/1573355078995566594)). - ### [Stripe](https://stripe.com) @@ -493,7 +491,7 @@ Zenly is a live map of your friends and family. It’s the most fun way to meet *** -## Open source projects using Bazel {#open-source-projects-using-Bazel} +## Open source projects using Bazel ### [Abseil](https://abseil.io/) @@ -723,6 +721,10 @@ networks. Sorbet is a fast, powerful type checker for a subset of Ruby. It scales to codebases with millions of lines of code and can be adopted incrementally. +### [Spotify](https://spotify.com) + +Spotify is using Bazel to build their iOS and Android Apps ([source](https://twitter.com/BalestraPatrick/status/1573355078995566594)). + ### [Tink](https://github.com/google/tink) Tink is a multi-language, cross-platform, open source library that provides @@ -750,4 +752,4 @@ architecture. ### [ZhihuDailyPurify](https://github.com/izzyleung/ZhihuDailyPurify) ZhihuDailyPurify is a light weight version of Zhihu Daily, a Chinese -question-and-answer webs. +question-and-answer webs. \ No newline at end of file diff --git a/concepts/build-files.mdx b/concepts/build-files.mdx index b85f472c..66d01f8c 100644 --- a/concepts/build-files.mdx +++ b/concepts/build-files.mdx @@ -50,7 +50,7 @@ team. `BUILD` file authors should comment liberally to document the role of each build target, whether or not it is intended for public use, and to document the role of the package itself. -## Loading an extension {#load} +## Loading an extension Bazel extensions are files ending in `.bzl`. Use the `load` statement to import a symbol from an extension. @@ -92,7 +92,7 @@ loaded from another file. You can use [load visibility](/concepts/visibility#load-visibility) to restrict who may load a `.bzl` file. -## Types of build rules {#types-of-build-rules} +## Types of build rules The majority of build rules come in families, grouped together by language. For example, `cc_binary`, `cc_library` @@ -132,6 +132,23 @@ for anyone to create new rules. and binaries and tests can depend on libraries, with the expected separate-compilation behavior. + + + + + +
+ + Labels + + + + Dependencies + +
+ ## File encoding `BUILD` and `.bzl` files should be encoded in UTF-8, of which ASCII is a valid diff --git a/concepts/build-ref.mdx b/concepts/build-ref.mdx index ee67bcc6..e8839d40 100644 --- a/concepts/build-ref.mdx +++ b/concepts/build-ref.mdx @@ -11,7 +11,7 @@ each package is a directory that contains a set of related source files and one `BUILD` file. The `BUILD` file specifies what software outputs can be built from the source. -### Repositories {#repositories} +### Repositories Source files used in a Bazel build are organized in _repositories_ (often shortened to _repos_). A repo is a directory tree with a boundary marker file at @@ -19,9 +19,10 @@ its root; such a boundary marker file could be `MODULE.bazel`, `REPO.bazel`, or in legacy contexts, `WORKSPACE` or `WORKSPACE.bazel`. The repo in which the current Bazel command is being run is called the _main -repo_. Other, (external) repos are defined by _repo rules_; see [external dependencies overview](/external/overview) for more information. +repo_. Other, (external) repos are defined by _repo rules_; see [external +dependencies overview](/external/overview) for more information. -## Workspace {#workspace} +## Workspace A _workspace_ is the environment shared by all Bazel commands run from the same main repo. It encompasses the main repo and the set of all defined external @@ -31,7 +32,7 @@ Note that historically the concepts of "repository" and "workspace" have been conflated; the term "workspace" has often been used to refer to the main repository, and sometimes even used as a synonym of "repository". -## Packages {#packages} +## Packages The primary unit of code organization in a repository is the _package_. A package is a collection of related files and a specification of how they can be @@ -55,7 +56,7 @@ src/my/app/tests/BUILD src/my/app/tests/test.cc ``` -## Targets {#targets} +## Targets A package is a container of _targets_, which are defined in the package's `BUILD` file. Most targets are one of two principal kinds, _files_ and _rules_. @@ -96,4 +97,9 @@ have three properties: the list of packages they contain, their name, and other package groups they include. The only allowed ways to refer to them are from the `visibility` attribute of rules or from the `default_visibility` attribute of the `package` function; they do not generate or consume files. For more -information, refer to the [`package_group` documentation](/reference/be/functions#package_group). +information, refer to the [`package_group` +documentation](/reference/be/functions#package_group). + + + Labels + diff --git a/concepts/dependencies.mdx b/concepts/dependencies.mdx index e03c1af7..bdb65f04 100644 --- a/concepts/dependencies.mdx +++ b/concepts/dependencies.mdx @@ -18,7 +18,7 @@ of _actual dependencies_ and the graph of _declared dependencies_. Most of the time, the two graphs are so similar that this distinction need not be made, but it is useful for the discussion below. -## Actual and declared dependencies {#actual-and-declared-dependencies} +## Actual and declared dependencies A target `X` is _actually dependent_ on target `Y` if `Y` must be present, built, and up-to-date in order for `X` to be built correctly. _Built_ could @@ -59,7 +59,7 @@ dependencies don't appear in the `BUILD` file. Because the rule doesn't directly depend on the provider, there is no way to track changes, as shown in the following example timeline: -### 1. Declared dependencies match actual dependencies {#this-is-fine} +### 1. Declared dependencies match actual dependencies At first, everything works. The code in package `a` uses code in package `b`. The code in package `b` uses code in package `c`, and thus `a` transitively @@ -131,7 +131,7 @@ function foo() { The declared dependencies overapproximate the actual dependencies. All is well. -### 2. Adding an undeclared dependency {#undeclared-dependency} +### 2. Adding an undeclared dependency A latent hazard is introduced when someone adds code to `a` that creates a direct _actual_ dependency on `c`, but forgets to declare it in the build file @@ -177,7 +177,7 @@ The declared dependencies no longer overapproximate the actual dependencies. This may build ok, because the transitive closures of the two graphs are equal, but masks a problem: `a` has an actual but undeclared dependency on `c`. -### 3. Divergence between declared and actual dependency graphs {#divergence} +### 3. Divergence between declared and actual dependency graphs The hazard is revealed when someone refactors `b` so that it no longer depends on `c`, inadvertently breaking `a` through no @@ -241,7 +241,7 @@ dependencies, even when transitively closed; the build is likely to fail. The problem could have been averted by ensuring that the actual dependency from `a` to `c` introduced in Step 2 was properly declared in the `BUILD` file. -## Types of dependencies {#types-of-dependencies} +## Types of dependencies Most build rules have three attributes for specifying different kinds of generic dependencies: `srcs`, `deps` and `data`. These are explained below. For @@ -252,16 +252,16 @@ Many rules also have additional attributes for rule-specific kinds of dependencies, for example, `compiler` or `resources`. These are detailed in the [Build Encyclopedia](/reference/be/). -### `srcs` dependencies {#srcs-dependencies} +### `srcs` dependencies Files consumed directly by the rule or rules that output source files. -### `deps` dependencies {#deps-dependencies} +### `deps` dependencies Rule pointing to separately-compiled modules providing header files, symbols, libraries, data, etc. -### `data` dependencies {#data-dependencies} +### `data` dependencies A build target might need some data files to run correctly. These data files aren't source code: they don't affect how the target is built. For example, a @@ -298,7 +298,7 @@ you can refer to these files by joining the paths of the test's source directory and the workspace-relative path, for example, `${TEST_SRCDIR}/workspace/path/to/data/file`. -## Using labels to reference directories {#using-labels-reference-directories} +## Using labels to reference directories As you look over our `BUILD` files, you might notice that some `data` labels refer to directories. These labels end with `/.` or `/` like these examples, @@ -366,3 +366,21 @@ filegroup( ``` You can then reference the label `my_data` as the data dependency in your test. + + + + + + +
+ + BUILD files + + + + Visibility + +
+ diff --git a/concepts/labels.mdx b/concepts/labels.mdx index 3f14e001..b221e34f 100644 --- a/concepts/labels.mdx +++ b/concepts/labels.mdx @@ -12,7 +12,8 @@ form looks like: ``` The first part of the label is the repository name, `@@myrepo`. The double-`@` -syntax signifies that this is a [*canonical* repo name](/external/overview#canonical-repo-name), which is unique within +syntax signifies that this is a [*canonical* repo +name](/external/overview#canonical-repo-name), which is unique within the workspace. Labels with canonical repo names unambiguously identify a target no matter which context they appear in. @@ -116,7 +117,7 @@ used from external repositories. For information about the different ways you can refer to targets, see [target patterns](/run/build#specifying-build-targets). -### Lexical specification of a label {#labels-lexical-specification} +### Lexical specification of a label Label syntax discourages use of metacharacters that have special meaning to the shell. This helps to avoid inadvertent quoting problems, and makes it easier to @@ -125,7 +126,7 @@ construct tools and scripts that manipulate labels, such as the The precise details of allowed target names are below. -### Target names — `package-name:target-name` {#target-names} +### Target names — `package-name:target-name` `target-name` is the name of the target within the package. The name of a rule is the value of the `name` attribute in the rule's declaration in a `BUILD` @@ -156,7 +157,7 @@ However, there are some situations where use of a slash is convenient, or sometimes even necessary. For example, the name of certain rules must match their principal source file, which may reside in a subdirectory of the package. -### Package names — `//package-name:target-name` {#package-names} +### Package names — `//package-name:target-name` The name of a package is the name of the directory containing its `BUILD` file, relative to the top-level directory of the containing repository. @@ -187,7 +188,7 @@ On a practical level: `//:foo`), it's best to leave that package empty so all meaningful packages have descriptive names. -## Rules {#rules} +## Rules A rule specifies the relationship between inputs and outputs, and the steps to build the outputs. Rules can be of one of many different @@ -240,3 +241,20 @@ the build. This directed acyclic graph over targets is called the _target graph_ or _build dependency graph_, and is the domain over which the [Bazel Query tool](/query/guide) operates. + + + + + + +
+ + Targets + + + + BUILD files + +
diff --git a/concepts/platforms.mdx b/concepts/platforms.mdx index 09cede52..e560ea4d 100644 --- a/concepts/platforms.mdx +++ b/concepts/platforms.mdx @@ -20,9 +20,9 @@ See also: * [Toolchains][Toolchains] * [Background][Background] -## Status {#status} +## Status -### C++ {#cxx} +### C++ C++ rules use platforms to select toolchains when `--incompatible_enable_cc_toolchain_resolution` is set. @@ -45,7 +45,7 @@ To test your C++ project with platforms, see [Migrating Your Project](#migrating-your-project) and [Configuring C++ toolchains]. -### Java {#java} +### Java Java rules use platforms to select toolchains. @@ -54,7 +54,7 @@ This replaces legacy flags `--java_toolchain`, `--host_java_toolchain`, See [Java and Bazel](/docs/bazel-and-java) for details. -### Android {#android} +### Android Android rules use platforms to select toolchains when `--incompatible_enable_android_toolchain_resolution` is set. @@ -73,15 +73,16 @@ This will be enabled by default in Bazel 7.0 ([#16285](https://github.com/bazelb To test your Android project with platforms, see [Migrating Your Project](#migrating-your-project). -### Apple {#apple} +### Apple [Apple rules] do not support platforms and are not yet scheduled for support. You can still use platform APIs with Apple builds (for example, when building -with a mixture of Apple rules and pure C++) with [platform mappings](#platform-mappings). +with a mixture of Apple rules and pure C++) with [platform +mappings](#platform-mappings). -### Other languages {#other-languages} +### Other languages * [Go rules] fully support platforms * [Rust rules] fully support platforms. @@ -89,7 +90,7 @@ with a mixture of Apple rules and pure C++) with [platform mappings](#platform-m If you own a language rule set, see [Migrating your rule set] for adding support. -## Background {#background} +## Background *Platforms* and *toolchains* were introduced to standardize how software projects target different architectures and cross-compile. @@ -109,7 +110,7 @@ Bazel is intended for large, multi-language, multi-platform projects. This demands more principled support for these concepts, including a clear standard API. -### Need for migration {#migration} +### Need for migration Upgrading to the new API requires two efforts: releasing the API and upgrading rule logic to use it. @@ -124,7 +125,7 @@ plus fair warning for project owners to test against upcoming changes. This is why this is an ongoing migration. -### Goal {#goal} +### Goal This migration is complete when all projects build with the form: @@ -150,7 +151,7 @@ deprecated and removed as soon as it's safe to do so. Ultimately, this will be the *sole* way to configure architectures. -## Migrating your project {#migrating-your-project} +## Migrating your project If you build with languages that support platforms, your build should already work with an invocation like: @@ -184,7 +185,7 @@ For your project to build, you need to check the following: If you still have problems, [reach out](#questions) for support. -### Default platforms {#default-platforms} +### Default platforms Project owners should define explicit [platforms][Defining Constraints and Platforms] to describe the architectures @@ -197,7 +198,7 @@ so there's no need to explicitly define it. It maps the local machine's `OS` and `CPU` with `constraint_value`s declared in [`@platforms`](https://github.com/bazelbuild/platforms). -### `select()` {#select} +### `select()` Projects can [`select()`][select()] on [`constraint_value` targets][constraint_value Rule] but not complete @@ -234,7 +235,7 @@ When migrating your project to platforms, you must either convert them to `constraint_values` or use [platform mappings](#platform-mappings) to support both styles during migration. -### Transitions {#transitions} +### Transitions [Starlark transitions][Starlark transitions] change flags down parts of your build graph. If your project uses a transition that @@ -243,10 +244,11 @@ sets `--cpu`, `--crossstool_top`, or other legacy flags, rules that read When migrating your project to platforms, you must either convert changes like `return { "//command_line_option:cpu": "arm" }` to `return { -"//command_line_option:platforms": "//:my_arm_platform" }` or use [platform mappings](#platform-mappings) to support both styles during migration. +"//command_line_option:platforms": "//:my_arm_platform" }` or use [platform +mappings](#platform-mappings) to support both styles during migration. window. -## Migrating your rule set {#migrating-your-rule-set} +## Migrating your rule set If you own a rule set and want to support platforms, you need to: @@ -271,7 +273,7 @@ If you own a rule set and want to support platforms, you need to: If you need to mix with rules that don't support platforms, you may need [platform mappings](#platform-mappings) to bridge the gap. -### Common platform properties {#common-platform-properties} +### Common platform properties Common, cross-language platform properties like `OS` and `CPU` should be declared in [`@platforms`](https://github.com/bazelbuild/platforms). @@ -285,7 +287,7 @@ If your rules use custom-purpose OSes or CPUs, these should be declared in your rule's repo vs. [`@platforms`](https://github.com/bazelbuild/platforms). -## Platform mappings {#platform-mappings} +## Platform mappings *Platform mappings* is a temporary API that lets platform-aware logic mix with legacy logic in the same build. This is a blunt tool that's only intended to @@ -325,7 +327,7 @@ workspace root. You can also set See the [platform mappings design] for details. -## API review {#api-review} +## API review A [`platform`][platform Rule] is a collection of [`constraint_value` targets][constraint_value Rule]: @@ -362,8 +364,10 @@ attributes declare a language's tools (like `compiler = this information to rules that need to build with these tools. Toolchains declare the `constraint_value`s of machines they can -[target][target_compatible_with Attribute](`target_compatible_with = ["@platforms//os:linux"]`) and machines their tools can -[run on][exec_compatible_with Attribute](`exec_compatible_with = ["@platforms//os:mac"]`). +[target][target_compatible_with Attribute] +(`target_compatible_with = ["@platforms//os:linux"]`) and machines their tools can +[run on][exec_compatible_with Attribute] +(`exec_compatible_with = ["@platforms//os:mac"]`). When building `$ bazel build //:myproject --platforms=//:myplatform`, Bazel automatically selects a toolchain that can run on the build machine and @@ -375,7 +379,7 @@ command line with [`--extra_toolchains`][extra_toolchains Flag]. For more information see [here][Toolchains]. -## Questions {#questions} +## Questions For general support and questions about the migration timeline, contact [bazel-discuss] or the owners of the appropriate rules. @@ -383,7 +387,7 @@ For general support and questions about the migration timeline, contact For discussions on the design and evolution of the platform/toolchain APIs, contact [bazel-dev]. -## See also {#see-also} +## See also * [Configurable Builds - Part 1] * [Platforms] diff --git a/concepts/visibility.mdx b/concepts/visibility.mdx index 45ad798f..fa5cf3aa 100644 --- a/concepts/visibility.mdx +++ b/concepts/visibility.mdx @@ -13,7 +13,7 @@ library's public API and its implementation details, and help enforce structure as your workspace grows. You can also use visibility when deprecating a public API to allow current users while denying new ones. -## Target visibility {#target-visibility} +## Target visibility **Target visibility** controls who may depend on your target — that is, who may use your target's label inside an attribute such as `deps`. A target will fail @@ -39,7 +39,7 @@ The following subsections describe the attribute's format, how to apply it to various kinds of targets, and the interaction between the visibility system and symbolic macros. -### Visibility specifications {#visibility-specifications} +### Visibility specifications All rule targets have a `visibility` attribute that takes a list of labels. Each label has one of the following forms. With the exception of the last form, these @@ -86,7 +86,7 @@ Note: The `visibility` attribute may not specify non-`package_group` targets. Doing so triggers a "Label does not refer to a package group" or "Cycle in dependency graph" error. -### Rule target visibility {#rule-target-visibility} +### Rule target visibility A rule target's visibility is determined by taking its `visibility` attribute -- or a suitable default if not given -- and appending the location where the @@ -136,7 +136,7 @@ convenient for prototyping or in small codebases, but the risk of inadvertently creating public targets increases as the codebase grows. It's better to be explicit about which targets are part of a package's public interface. -### Generated file target visibility {#generated-file-target-visibility} +### Generated file target visibility A generated file target has the same visibility as the rule target that generates it. @@ -167,7 +167,7 @@ some_rule( ) ``` -### Source file target visibility {#source-file-target-visibility} +### Source file target visibility Source file targets can either be explicitly declared using [`exports_files`](/reference/be/functions#exports_files), or implicitly created @@ -200,7 +200,7 @@ source file. For example, instead of calling `exports_files` on a `.java` file, wrap the file in a non-private `java_library` target. Generally, rule targets should only directly reference source files that live in the same package. -#### Example {#source-file-visibility-example} +#### Example File `//frobber/data/BUILD`: @@ -217,7 +217,7 @@ cc_binary( ) ``` -### Config setting visibility {#config-setting-visibility} +### Config setting visibility Historically, Bazel has not enforced visibility for [`config_setting`](/reference/be/general#config_setting) targets that are @@ -239,12 +239,12 @@ Avoid relying on the legacy behavior. Any `config_setting` that is intended to be used outside the current package should have an explicit `visibility`, if the package does not already specify a suitable `default_visibility`. -### Package group target visibility {#package-group-target-visibility} +### Package group target visibility `package_group` targets do not have a `visibility` attribute. They are always publicly visible. -### Visibility of implicit dependencies {#visibility-implicit-dependencies} +### Visibility of implicit dependencies Some rules have [implicit dependencies](/extending/rules#private_attributes_and_implicit_dependencies) — dependencies that are not spelled out in a `BUILD` file but are inherent to @@ -262,12 +262,12 @@ respect to the `cc_library` target. If you want to restrict the usage of a rule to certain packages, use [load visibility](#load-visibility) instead. -### Visibility and symbolic macros {#symbolic-macros} +### Visibility and symbolic macros This section describes how the visibility system interacts with [symbolic macros](/extending/macros). -#### Locations within symbolic macros {#locations-within-symbolic-macros} +#### Locations within symbolic macros A key detail of the visibility system is how we determine the location of a declaration. For targets that are not declared in a symbolic macro, the location @@ -304,7 +304,7 @@ composes, in the sense that a chain of nested calls to submacros may each pass the caller at each level, without exposing any of the macros' implementation details. -#### Delegating privileges to a submacro {#delegating-privileges-to-a-submacro} +#### Delegating privileges to a submacro The visibility model has a special feature to allow a macro to delegate its permissions to a submacro. This is important for factoring and composing macros. @@ -380,7 +380,7 @@ label-typed attributes. Note: Visibility delegation does not work for labels that were not passed into the macro, such as labels derived by string manipulation. -#### Finalizers {#finalizers} +#### Finalizers Targets declared in a rule finalizer (a symbolic macro with `finalizer = True`), in addition to seeing targets following the usual symbolic macro visibility @@ -399,7 +399,7 @@ finalizer, the finalizer cannot see such a target. Note, however, that a `native.existing_rules()`-based legacy macro will also be unable to see such a target. -## Transitive visibility {#transitive-visibility} +## Transitive visibility **Transitive visibility** is a way of restricting who may depend on a target, including when the dependency is only indirect. It applies separately from the @@ -461,7 +461,7 @@ Transitive visibility also applies to targets that are declared in symbolic macros. However, unlike ordinary target visibility, it only considers the package these targets live in, not the package that defined the symbolic macro. -## Load visibility {#load-visibility} +## Load visibility **Load visibility** controls whether a `.bzl` file may be loaded from other `BUILD` or `.bzl` files outside the current package. @@ -486,7 +486,7 @@ not be done for submitted code. Load visibility is available as of Bazel 6.0. -### Declaring load visibility {#declaring-load-visibility} +### Declaring load visibility To set the load visibility of a `.bzl` file, call the [`visibility()`](/rules/lib/globals/bzl#visibility) function from within the file. @@ -503,7 +503,7 @@ that do not call `visibility()` are always loadable from anywhere in the workspace. It is a good idea to add `visibility("private")` to the top of any new `.bzl` file that is not specifically intended for use outside the package. -### Example {#load-visibility-example} +### Example ```starlark # //mylib/internal_defs.bzl @@ -537,11 +537,11 @@ load("//mylib:internal_defs.bzl", "helper") # error ... ``` -### Load visibility practices {#load-visibility-practices} +### Load visibility practices This section describes tips for managing load visibility declarations. -#### Factoring visibilities {#factoring-visibilities} +#### Factoring visibilities When multiple `.bzl` files should have the same visibility, it can be helpful to factor their package specifications into a common list. For example: @@ -579,7 +579,7 @@ visibility(clients) This helps prevent accidental skew between the various `.bzl` files' visibilities. It also is more readable when the `clients` list is large. -#### Composing visibilities {#composing-visibilities} +#### Composing visibilities Sometimes a `.bzl` file might need to be visible to an allowlist that is composed of multiple smaller allowlists. This is analogous to how a @@ -599,7 +599,7 @@ load("//some_big_client:defs.bzl", "their_remaining_uses") visibility(our_packages + their_remaining_uses) ``` -#### Deduplicating with package groups {#deduplicating-with-package-groups} +#### Deduplicating with package groups Unlike target visibility, you cannot define a load visibility in terms of a `package_group`. If you want to reuse the same allowlist for both target @@ -622,7 +622,7 @@ package_group( This only works if the list does not contain any negative package specifications. -#### Protecting individual symbols {#protecting-individual-symbols} +#### Protecting individual symbols Any Starlark symbol whose name begins with an underscore cannot be loaded from another file. This makes it easy to create private symbols, but does not allow @@ -664,7 +664,7 @@ visibility("public") public_util = _public_util ``` -#### bzl-visibility Buildifier lint {#bzl-visibility-buildifier-lint} +#### bzl-visibility Buildifier lint There is a [Buildifier lint](https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#bzl-visibility) that provides a warning if users load a file from a directory named `internal` diff --git a/configure/attributes.mdx b/configure/attributes.mdx index 4f03c453..7bc3f41e 100644 --- a/configure/attributes.mdx +++ b/configure/attributes.mdx @@ -4,14 +4,15 @@ title: 'Configurable Build Attributes' -**_Configurable attributes_**, commonly known as [`select()`](/reference/be/functions#select), is a Bazel feature that lets users toggle the values +**_Configurable attributes_**, commonly known as [`select()`]( +/reference/be/functions#select), is a Bazel feature that lets users toggle the values of build rule attributes at the command line. This can be used, for example, for a multiplatform library that automatically chooses the appropriate implementation for the architecture, or for a feature-configurable binary that can be customized at build time. -## Example {#configurable-build-example} +## Example ```python # myapp/BUILD @@ -86,7 +87,7 @@ are *non-configurable*, and these are clearly annotated. For example, `config_setting`'s own [`values`](/reference/be/general#config_setting.values) attribute is non-configurable. -## `select()` and dependencies {#select-and-dependencies} +## `select()` and dependencies Certain attributes change the build parameters for all transitive dependencies under a target. For example, `genrule`'s `tools` changes `--cpu` to the CPU of @@ -142,7 +143,7 @@ build parameters, which include `--cpu=arm`. The `tools` attribute changes `--cpu` to `x86` for `tool1` and its transitive dependencies. The `select` on `tool1` uses `tool1`'s build parameters, which include `--cpu=x86`. -## Configuration conditions {#configuration-conditions} +## Configuration conditions Each key in a configurable attribute is a label reference to a [`config_setting`](/reference/be/general#config_setting) or @@ -154,7 +155,7 @@ easy to maintain "standard" conditions users can reference from multiple places. `constraint_value` provides support for [multi-platform behavior](#platforms). -### Built-in flags {#built-in-flags} +### Built-in flags Flags like `--cpu` are built into Bazel: the build tool natively understands them for all builds in all projects. These are specified with @@ -188,7 +189,7 @@ it only affects how Bazel reports progress to the user. Targets can't use that flag to construct their results. The exact set of supported flags isn't documented. In practice, most flags that "make sense" work. -### Custom flags {#custom-flags} +### Custom flags You can model your own project-specific flags with [Starlark build settings][BuildSettings]. Unlike built-in flags, these are @@ -224,7 +225,7 @@ compatibility. Prefer Starlark build settings whenever possible. `values`, `flag_values`, and `define_values` evaluate independently. The `config_setting` matches if all values across all of them match. -## The default condition {#default-condition} +## The default condition The built-in condition `//conditions:default` matches when no other condition matches. @@ -260,7 +261,7 @@ Conditions checked: For even clearer errors, you can set custom messages with `select()`'s [`no_match_error`](#custom-error-messages) attribute. -## Platforms {#platforms} +## Platforms While the ability to specify multiple flags on the command line provides flexibility, it can also be burdensome to individually set each one every time @@ -362,7 +363,7 @@ check against single values. Platforms are still under development. See the [documentation](/concepts/platforms) for details. -## Combining `select()`s {#combining-selects} +## Combining `select()`s `select` can appear multiple times in the same attribute: @@ -408,9 +409,10 @@ sh_library( ) ``` -If you need a `select` to match when multiple conditions match, consider [AND chaining](#and-chaining). +If you need a `select` to match when multiple conditions match, consider [AND +chaining](#and-chaining). -## OR chaining {#or-chaining} +## OR chaining Consider the following: @@ -453,7 +455,7 @@ duplication. For more direct support, use one of the following: -### `selects.with_or` {#selects-with-or} +### `selects.with_or` The [with_or](https://github.com/bazelbuild/bazel-skylib/blob/main/docs/selects_doc.md#selectswith_or) @@ -476,7 +478,7 @@ sh_binary( ) ``` -### `selects.config_setting_group` {#selects-config-setting-or-group} +### `selects.config_setting_group` The @@ -519,7 +521,7 @@ different attributes. It's an error for multiple conditions to match unless one is an unambiguous "specialization" of the others or they all resolve to the same value. See [here](#configurable-build-example) for details. -## AND chaining {#and-chaining} +## AND chaining If you need a `select` branch to match when multiple conditions match, use the [Skylib](https://github.com/bazelbuild/bazel-skylib) macro @@ -551,7 +553,7 @@ sh_binary( Unlike OR chaining, existing `config_setting`s can't be directly `AND`ed inside a `select`. You have to explicitly wrap them in a `config_setting_group`. -## Custom error messages {#custom-error-messages} +## Custom error messages By default, when no condition matches, the target the `select()` is attached to fails with the error: @@ -586,7 +588,7 @@ ERROR: Configurable attribute "deps" doesn't match this configuration: Please build with an Android or Windows toolchain ``` -## Rules compatibility {#rules-compatibility} +## Rules compatibility Rule implementations receive the *resolved values* of configurable attributes. For example, given: @@ -634,7 +636,7 @@ Second, macros that just need to iterate over *all* `select` paths, while technically feasible, lack a coherent UI. Further design is necessary to change this. -## Bazel query and cquery {#query-and-cquery} +## Bazel query and cquery Bazel [`query`](/query/guide) operates over Bazel's [loading phase](/reference/glossary#loading-phase). @@ -695,9 +697,9 @@ $ bazel cquery 'deps(//myapp:my_lib)' --//myapp:dog_type=pug //myapp:bar_dep ``` -## FAQ {#faq} +## FAQ -### Why doesn't select() work in macros? {#faq-select-macro} +### Why doesn't select() work in macros? select() *does* work in rules! See [Rules compatibility](#rules-compatibility) for details. @@ -809,7 +811,7 @@ DEBUG: /myworkspace/myapp/defs.bzl:23:3: Invoking macro sad_macro_less_sad. DEBUG: /myworkspace/myapp/defs.bzl:15:3: My name is sad_macro_less_sad with custom message: FIRST STRING. ``` -### Why does select() always return true? {#faq-boolean-select} +### Why does select() always return true? Because *macros* (but not rules) by definition [can't evaluate `select()`s](#faq-select-macro), any attempt to do so @@ -855,7 +857,7 @@ So what they're really evaluting is the `select()` object itself. According to standards, all objects aside from a very small number of exceptions automatically return true. -### Can I read select() like a dict? {#faq-inspectable-select} +### Can I read select() like a dict? Macros [can't](#faq-select-macro) evaluate select(s) because macros evaluate before Bazel knows what the build's command line parameters are. Can they at least read @@ -911,7 +913,7 @@ def selecty_genrule(name, select_cmd): ) ``` -### Why doesn't select() work with bind()? {#faq-select-bind} +### Why doesn't select() work with bind()? First of all, do not use `bind()`. It is deprecated in favor of `alias()`. @@ -957,7 +959,7 @@ located at `@alternative//:ssl`. But really, stop using `bind()`. -### Why doesn't my select() choose what I expect? {#faq-select-choose-condition} +### Why doesn't my select() choose what I expect? If `//myapp:foo` has a `select()` that doesn't choose the condition you expect, use [cquery](/query/cquery) and `bazel config` to debug: @@ -1008,7 +1010,7 @@ Caution: To prevent restarting the Bazel server, invoke `bazel config` with the same command line flags as the `bazel cquery`. The `config` command relies on the configuration nodes from the still-running server of the previous command. -### Why doesn't `select()` work with platforms? {#faq-select-platforms} +### Why doesn't `select()` work with platforms? Bazel doesn't support configurable attributes checking whether a given platform is the target platform because the semantics are unclear. diff --git a/configure/best-practices.mdx b/configure/best-practices.mdx index 7f9f57fe..deecf9dd 100644 --- a/configure/best-practices.mdx +++ b/configure/best-practices.mdx @@ -23,7 +23,7 @@ should make a project more readable, less error-prone, and faster to build. This page uses the requirement levels described in [this RFC](https://www.ietf.org/rfc/rfc2119.txt). -## Running builds and tests {#running-builds-tests} +## Running builds and tests A project should always be able to run `bazel build //...` and `bazel test //...` successfully on its stable branch. Targets that are necessary @@ -34,14 +34,14 @@ tagging allows targets to be filtered at a more fine-grained level than the "manual" tag and allows someone inspecting the `BUILD` file to understand what a target's restrictions are. -## Third-party dependencies {#third-party-dependencies} +## Third-party dependencies You may declare third-party dependencies: * Either declare them as remote repositories in the `MODULE.bazel` file. * Or put them in a directory called `third_party/` under your workspace directory. -## Depending on binaries {#binaries} +## Depending on binaries Everything should be built from source whenever possible. Generally this means that, instead of depending on a library `some-library.so`, you'd create a @@ -53,7 +53,7 @@ was built with incompatible flags or a different architecture. There are also some features like coverage, static analysis, or dynamic analysis that only work on the source. -## Versioning {#versioning} +## Versioning Prefer building all code from head whenever possible. When versions must be used, avoid including the version in the target name (for example, `//guava`, @@ -64,7 +64,7 @@ you could end up with a library that tries to depend on two different versions. If you created a misleading alias to point both targets to one `guava` library, then the `BUILD` files are misleading. -## Using the `.bazelrc` file {#bazelrc-file} +## Using the `.bazelrc` file For project-specific options, use the configuration file your `workspace/.bazelrc` (see [bazelrc format](/run/bazelrc)). @@ -84,7 +84,7 @@ The open-source generates a custom bazelrc file that matches your Bazel version and provides a preset of recommended flags. -## Packages {#packages} +## Packages Every directory that contains buildable files should be a package. If a `BUILD` file refers to files in subdirectories (such as, `srcs = ["a/b/C.java"]`) it's diff --git a/configure/coverage.mdx b/configure/coverage.mdx index 1eacadfc..f8e3e7b6 100644 --- a/configure/coverage.mdx +++ b/configure/coverage.mdx @@ -21,7 +21,7 @@ While a lot of customization is possible, this document focuses on producing and consuming [`lcov`][lcov] reports, which is currently the most well-supported route. -## Creating a coverage report {#creating-a-coverage-report} +## Creating a coverage report ### Preparation @@ -85,7 +85,7 @@ To view the result, simply open the `index.html` file produced in the For further help and information around the `genhtml` tool, or the `lcov` coverage format, see [the lcov project][lcov]. -## Remote execution {#remote-execution} +## Remote execution Running with remote test execution currently has a few caveats: diff --git a/configure/integrate-cpp.mdx b/configure/integrate-cpp.mdx index 599fbd8f..107ab810 100644 --- a/configure/integrate-cpp.mdx +++ b/configure/integrate-cpp.mdx @@ -4,7 +4,7 @@ title: 'Integrating with C++ Rules' This page describes how to integrate with C++ rules on various levels. -## Accessing the C++ toolchain {#access-c-toolchain} +## Accessing the C++ toolchain You should use the helper functions available at [`@rules_cc//cc:find_cc_toolchain.bzl`](https://github.com/bazelbuild/rules_cc/blob/main/cc/find_cc_toolchain.bzl) @@ -14,9 +14,10 @@ To depend on a C++ toolchain in your rule, set the `toolchains` parameter to `use_cc_toolchain()`. Then, in the rule implementation, use `find_cpp_toolchain(ctx)` to get the [`CcToolchainInfo`](/rules/lib/providers/CcToolchainInfo). A complete working -example can be found [in the rules_cc examples](https://github.com/bazelbuild/rules_cc/blob/main/examples/write_cc_toolchain_cpu/write_cc_toolchain_cpu.bzl). +example can be found [in the rules_cc +examples](https://github.com/bazelbuild/rules_cc/blob/main/examples/write_cc_toolchain_cpu/write_cc_toolchain_cpu.bzl). -## Generating command lines and environment variables using the C++ toolchain {#generate-command-lines-toolchain} +## Generating command lines and environment variables using the C++ toolchain Typically, you would integrate with the C++ toolchain to have the same command line flags as C++ rules do, but without using C++ actions directly. @@ -24,7 +25,8 @@ This is because when writing our own actions, they must behave consistently with the C++ toolchain - for example, passing C++ command line flags to a tool that invokes the C++ compiler behind the scenes. -C++ rules use a special way of constructing command lines based on [feature configuration](/docs/cc-toolchain-config-reference). To construct a command line, +C++ rules use a special way of constructing command lines based on [feature +configuration](/docs/cc-toolchain-config-reference). To construct a command line, you need the following: * `features` and `action_configs` - these come from the `CcToolchainConfigInfo` @@ -43,7 +45,7 @@ eventually be removed. A complete working example can be found [in the rules_cc examples](https://github.com/bazelbuild/rules_cc/blob/main/examples/my_c_compile/my_c_compile.bzl). -## Implementing Starlark rules that depend on C++ rules and/or that C++ rules can depend on {#implement-starlark-rules} +## Implementing Starlark rules that depend on C++ rules and/or that C++ rules can depend on Most C++ rules provide [`CcInfo`](/rules/lib/providers/CcInfo), @@ -65,7 +67,7 @@ it should wrap it in, for example, `JavaCcInfo`. A complete working example can be found [in the rules_cc examples](https://github.com/bazelbuild/rules_cc/blob/main/examples/my_c_archive/my_c_archive.bzl). -## Reusing logic and actions of C++ rules {#reuse-logic-c-rules} +## Reusing logic and actions of C++ rules _Not stable yet; This section will be updated once the API stabilizes. Follow [#4570](https://github.com/bazelbuild/bazel/issues/4570) for up-to-date diff --git a/configure/windows.mdx b/configure/windows.mdx index 573f660d..67a36c83 100644 --- a/configure/windows.mdx +++ b/configure/windows.mdx @@ -7,16 +7,16 @@ title: 'Using Bazel on Windows' This page covers Best Practices for using Bazel on Windows. For installation instructions, see [Install Bazel on Windows](/install/windows). -## Known issues {#known-issues} +## Known issues Windows-related Bazel issues are marked with the "area-Windows" label on GitHub. [GitHub-Windows]. [GitHub-Windows]: https://github.com/bazelbuild/bazel/issues?q=is%3Aopen+is%3Aissue+label%3Aarea-Windows -## Best practices {#best-practices} +## Best practices -### Avoid long path issues {#long-path-issues} +### Avoid long path issues Some tools have the [Maximum Path Length Limitation](https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation) on Windows, including the MSVC compiler. To avoid hitting this issue, you can specify a short output directory for Bazel by the [\-\-output_user_root](/reference/command-line-reference#flag--output_user_root) flag. @@ -27,7 +27,7 @@ For example, add the following line to your bazelrc file: startup --output_user_root=C:/tmp ``` -### Enable symlink support {#symlink} +### Enable symlink support Some features require Bazel to be able to create file symlinks on Windows, either by enabling @@ -51,7 +51,7 @@ build --enable_runfiles {/* TODO(pcloudy): https://github.com/bazelbuild/bazel/issues/6402 Write a doc about runfiles library and add a link to it here */} -### Running Bazel: MSYS2 shell vs. command prompt vs. PowerShell {#running-bazel-shells} +### Running Bazel: MSYS2 shell vs. command prompt vs. PowerShell **Recommendation:** Run Bazel from the command prompt (`cmd.exe`) or from PowerShell. @@ -66,9 +66,9 @@ that _look like_ Unix paths (such as `//foo:bar`) into Windows paths. See [this StackOverflow answer](https://stackoverflow.com/a/49004265/7778502) for details. -### Using Bazel without Bash (MSYS2) {#using-bazel-without-bash} +### Using Bazel without Bash (MSYS2) -#### Using bazel build without Bash {#bazel-build-without-bash} +#### Using bazel build without Bash Bazel versions before 1.0 used to require Bash to build some rules. @@ -86,7 +86,7 @@ in the [bazel-skylib repository](https://github.com/bazelbuild/bazel-skylib/tree/main/rules). When built on Windows, **these rules do not require Bash**. -#### Using bazel test without Bash {#bazel-test-without-bash} +#### Using bazel test without Bash Bazel versions before 1.0 used to require Bash to `bazel test` anything. @@ -95,7 +95,7 @@ Starting with Bazel 1.0, you can test any rule without Bash, except when: - you use `--run_under` - the test rule itself requires Bash (because its executable is a shell script) -#### Using bazel run without Bash {#bazel-run-without-bash} +#### Using bazel run without Bash Bazel versions before 1.0 used to require Bash to `bazel run` anything. @@ -104,7 +104,7 @@ Starting with Bazel 1.0, you can run any rule without Bash, except when: - you use `--run_under` or `--script_path` - the test rule itself requires Bash (because its executable is a shell script) -#### Using sh\_binary and sh\_* rules, and ctx.actions.run_shell() without Bash {#sh-rules-without-bash} +#### Using sh\_binary and sh\_* rules, and ctx.actions.run_shell() without Bash You need Bash to build and test `sh_*` rules, and to build and test Starlark rules that use `ctx.actions.run_shell()` and `ctx.resolve_command()`. This @@ -115,7 +115,7 @@ In the future, there may be an option to use Windows Subsystem for Linux (WSL) to build these rules, but currently it is not a priority for the Bazel-on-Windows subteam. -### Setting environment variables {#set-environment-variables} +### Setting environment variables Environment variables you set in the Windows Command Prompt (`cmd.exe`) are only set in that command prompt session. If you start a new `cmd.exe`, you need to @@ -123,9 +123,9 @@ set the variables again. To always set the variables when `cmd.exe` starts, you can add them to the User variables or System variables in the `Control Panel > System Properties > Advanced > Environment Variables...` dialog box. -## Build on Windows {#using} +## Build on Windows -### Build C++ with MSVC {#build_cpp} +### Build C++ with MSVC To build C++ targets with MSVC, you need: @@ -162,7 +162,8 @@ To build C++ targets with MSVC, you need: set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC ``` -* The [Windows SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk). +* The [Windows + SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk). The Windows SDK contains header files and libraries you need when building Windows applications, including Bazel itself. By default, the latest Windows SDK installed will @@ -181,7 +182,8 @@ To build C++ targets with MSVC, you need: If everything is set up, you can build a C++ target now! -Try building a target from one of our [sample projects](https://github.com/bazelbuild/bazel/tree/master/examples): +Try building a target from one of our [sample +projects](https://github.com/bazelbuild/bazel/tree/master/examples): ``` bazel-bin\examples\java-native\src\main\java\com\example\myproject\hello-world.exe ``` -### Build Python {#python} +### Build Python To build Python targets, you need: @@ -401,7 +406,8 @@ On Windows, Bazel builds two output files for `py_binary` rules: You can either run the executable file (it has a `.exe` extension) or you can run Python with the self-extracting zip file as the argument. -Try building a target from one of our [sample projects](https://github.com/bazelbuild/bazel/tree/master/examples): +Try building a target from one of our [sample +projects](https://github.com/bazelbuild/bazel/tree/master/examples): ``` Yes: Preserving graph order - No: On the preservation of graph order -### Names {#names} +### Names - Capitalize proper nouns, such as Bazel and Starlark. @@ -59,7 +59,7 @@ This section contains basic writing tips. - For example, if you're writing about issuing commands on a terminal, don't use both terminal and command line on the page. -### Page scope {#page-scope} +### Page scope - Each page should have one purpose and that should be defined at the beginning. This helps readers find what they need quicker. @@ -71,7 +71,7 @@ This section contains basic writing tips. there is no clear action, you can include links to similar concepts, examples, or other avenues for exploration. -### Subject {#subject} +### Subject In Bazel documentation, the audience should primarily be users—the people using Bazel to build their software. @@ -94,7 +94,7 @@ Bazel to build their software. - No: Bazel is evolving, and we will make changes to Bazel that at times will be incompatible and require some changes from Bazel users. -### Temporal {#temporal} +### Temporal Where possible, avoid terms that orient things in time, such as referencing specific dates (Q2 2022) or saying "now", "currently", or "soon." These go @@ -107,7 +107,7 @@ specify a version level instead, such as "Bazel X.x and higher supports - No: Bazel will soon support remote caching, likely in October 2017. -### Tense {#tense} +### Tense - Use present tense. Avoid past or future tense unless absolutely necessary for clarity. @@ -125,7 +125,7 @@ specify a version level instead, such as "Bazel X.x and higher supports - No: X is initiated by Bazel and then afterward Y will be built with the output. -### Tone {#tone} +### Tone Write with a business friendly tone. @@ -137,9 +137,9 @@ Write with a business friendly tone. - Avoid overly formal language. Write as though you're explaining the concept to someone who is curious about tech, but doesn't know the details. -## Formatting {#format} +## Formatting -### File type {#file-type} +### File type For readability, wrap lines at 80 characters. Long links or code snippets may be longer, but should start on a new line. For example: @@ -148,7 +148,7 @@ Note: Where possible, use Markdown instead of HTML in your files. Follow the [GitHub Markdown Syntax Guide](https://guides.github.com/features/mastering-markdown/#syntax) for recommended Markdown style. -### Links {#links} +### Links - Use descriptive link text instead of "here" or "below". This practice makes it easier to scan a doc and is better for screen readers. @@ -159,7 +159,7 @@ for recommended Markdown style. - Yes: For more details, see [link]. - No: See [link] for more information. -### Lists {#lists} +### Lists - Use an ordered list to describe how to accomplish a task with steps - Use an unordered list to list things that aren't task based. (There should @@ -169,7 +169,7 @@ for recommended Markdown style. 1. Start with verbs that are the same tense. 1. Use an ordered list if there are steps to follow. -### Placeholders {#placeholders} +### Placeholders - Use angle brackets to denote a variable that users should change. In Markdown, escape the angle brackets with a back slash: `\`. @@ -181,11 +181,11 @@ for recommended Markdown style. - Especially for complicated code samples, use placeholders that make sense in context. -### Table of contents {#toc} +### Table of contents Use the auto-generated TOC supported by the site. Don't add a manual TOC. -## Code {#code} +## Code Code samples are developers' best friends. You probably know how to write these already, but here are a few tips. @@ -194,7 +194,7 @@ If you're referencing a small snippet of code, you can embed it in a sentence. If you want the reader to use the code, such as copying a command, use a code block. -### Code blocks {#code-blocks} +### Code blocks - Keep it short. Eliminate all redundant or unnecessary text from a code sample. @@ -207,7 +207,7 @@ block. - Separate commands and output into different code blocks. -### Inline code formatting {#code-format} +### Inline code formatting - Use code style for filenames, directories, paths, and small bits of code. - Use inline code styling instead of _italics_, "quotes," or **bolding**. diff --git a/contribute/index.mdx b/contribute/index.mdx index a0a279a7..ee667729 100644 --- a/contribute/index.mdx +++ b/contribute/index.mdx @@ -6,28 +6,31 @@ title: 'Contributing to Bazel' There are many ways to help the Bazel project and ecosystem. -## Provide feedback {#feedback} +## Provide feedback As you use Bazel, you may find things that can be improved. You can help by [reporting issues](http://github.com/bazelbuild/bazel/issues) when: - - Bazel crashes or you encounter a bug that can [only be resolved using `bazel clean`](/run/build#correct-incremental-rebuilds). + - Bazel crashes or you encounter a bug that can [only be resolved using `bazel + clean`](/run/build#correct-incremental-rebuilds). - The documentation is incomplete or unclear. You can also report issues from the page you are viewing by using the "Create issue" link at the top right corner of the page. - An error message could be improved. -## Participate in the community {#community} +## Participate in the community You can engage with the Bazel community by: - - Answering questions [on Stack Overflow](https://stackoverflow.com/questions/tagged/bazel). + - Answering questions [on Stack Overflow]( + https://stackoverflow.com/questions/tagged/bazel). - Helping other users [on Slack](https://slack.bazel.build). - - Improving documentation or [contributing examples](https://github.com/bazelbuild/examples). + - Improving documentation or [contributing examples]( + https://github.com/bazelbuild/examples). - Sharing your experience or your tips, for example, on a blog or social media. -## Contribute code {#contribute-code} +## Contribute code Bazel is a large project and making a change to the Bazel source code can be difficult. @@ -39,7 +42,8 @@ You can contribute to the Bazel ecosystem by: - Contributing to Bazel-related tools, for example, migration tools. - Improving Bazel integration with other IDEs and tools. -Before making a change, [create a GitHub issue](http://github.com/bazelbuild/bazel/issues) +Before making a change, [create a GitHub +issue](http://github.com/bazelbuild/bazel/issues) or email [bazel-discuss@](mailto:bazel-discuss@googlegroups.com). The most helpful contributions fix bugs or add features (as opposed @@ -50,7 +54,7 @@ portability, and the impact on memory usage and performance. To learn about how to submit a change, see the [patch acceptance process](/contribute/patch-acceptance). -## Bazel's code description {#code-description} +## Bazel's code description Bazel has a large codebase with code in multiple locations. See the [codebase guide](/contribute/codebase) for more details. @@ -69,7 +73,7 @@ Bazel is organized as follows: [compiling Bazel](/install/compile-source) section. -### Searching Bazel's source code {#search-code} +### Searching Bazel's source code To quickly search through Bazel's source code, use [Bazel Code Search](https://source.bazel.build/). You can navigate Bazel's diff --git a/contribute/maintainers-guide.mdx b/contribute/maintainers-guide.mdx index a2331742..30cf9780 100644 --- a/contribute/maintainers-guide.mdx +++ b/contribute/maintainers-guide.mdx @@ -6,7 +6,8 @@ title: 'Guide for Bazel Maintainers' This is a guide for the maintainers of the Bazel open source project. -If you are looking to contribute to Bazel, read [Contributing to Bazel](/contribute) instead. +If you are looking to contribute to Bazel, read [Contributing to +Bazel](/contribute) instead. The objectives of this page are to: @@ -23,22 +24,23 @@ subteams to manage aspects of the open source project. These are: * **Developer Experience Gardeners**: Encourage external contributions, review issues and pull requests, and make our development workflow more open. -## Releases {#releases} +## Releases * [Release Playbook](https://github.com/bazelbuild/continuous-integration/blob/master/docs/release-playbook.md) * [Testing local changes with downstream projects](https://github.com/bazelbuild/continuous-integration/blob/master/docs/downstream-testing.md) -## Continuous Integration {#integration} +## Continuous Integration Read the Green team's guide to Bazel's CI infrastructure on the [bazelbuild/continuous-integration](https://github.com/bazelbuild/continuous-integration/blob/master/buildkite/README.md) repository. -## Lifecycle of an Issue {#lifecycle-issue} +## Lifecycle of an Issue 1. A user creates an issue by choosing one of the [issue templates](https://github.com/bazelbuild/bazel/issues/new/choose) - and it enters the pool of [unreviewed open issues](https://github.com/bazelbuild/bazel/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+-label%3Auntriaged+-label%3Ap2+-label%3Ap1+-label%3Ap3+-label%3Ap4+-label%3Ateam-Starlark+-label%3Ateam-Rules-CPP+-label%3Ateam-Rules-Java+-label%3Ateam-XProduct+-label%3Ateam-Android+-label%3Ateam-Apple+-label%3Ateam-Configurability++-label%3Ateam-Performance+-label%3Ateam-Rules-Server+-label%3Ateam-Core+-label%3Ateam-Rules-Python+-label%3Ateam-Remote-Exec+-label%3Ateam-Local-Exec+-label%3Ateam-Bazel). + and it enters the pool of [unreviewed open + issues](https://github.com/bazelbuild/bazel/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+-label%3Auntriaged+-label%3Ap2+-label%3Ap1+-label%3Ap3+-label%3Ap4+-label%3Ateam-Starlark+-label%3Ateam-Rules-CPP+-label%3Ateam-Rules-Java+-label%3Ateam-XProduct+-label%3Ateam-Android+-label%3Ateam-Apple+-label%3Ateam-Configurability++-label%3Ateam-Performance+-label%3Ateam-Rules-Server+-label%3Ateam-Core+-label%3Ateam-Rules-Python+-label%3Ateam-Remote-Exec+-label%3Ateam-Local-Exec+-label%3Ateam-Bazel). 1. A member on the Developer Experience (DevEx) subteam rotation reviews the issue. 1. If the issue is **not a bug** or a **feature request**, the DevEx member @@ -58,22 +60,25 @@ repository. 1. After reviewing the issue, the DevEx member decides if the issue requires immediate attention. If it does, they will assign the **P0** [priority](#priority) label and an owner from the list of team leads. -1. The DevEx member assigns the `untriaged` label and exactly one [team label](#team-labels) for routing. +1. The DevEx member assigns the `untriaged` label and exactly one [team + label](#team-labels) for routing. 1. The DevEx member also assigns exactly one `type:` label, such as `type: bug` or `type: feature request`, according to the type of the issue. 1. For platform-specific issues, the DevEx member assigns one `platform:` label, such as `platform:apple` for Mac-specific issues. 1. If the issue is low priority and can be worked on by a new community contributor, the DevEx member assigns the `good first issue` label. -At this stage, the issue enters the pool of [untriaged open issues](https://github.com/bazelbuild/bazel/issues?q=is%3Aissue+is%3Aopen+label%3Auntriaged). +At this stage, the issue enters the pool of [untriaged open +issues](https://github.com/bazelbuild/bazel/issues?q=is%3Aissue+is%3Aopen+label%3Auntriaged). Each Bazel subteam will triage all issues under labels they own, preferably on a weekly basis. The subteam will review and evaluate the issue and provide a -resolution, if possible. If you are an owner of a team label, see [this section](#label-own) for more information. +resolution, if possible. If you are an owner of a team label, see [this section +](#label-own) for more information. When an issue is resolved, it can be closed. -## Lifecycle of a Pull Request {#lifecycle-pull-request} +## Lifecycle of a Pull Request 1. A user creates a pull request. 1. If you a member of a Bazel team and sending a PR against your own area, @@ -93,12 +98,12 @@ When an issue is resolved, it can be closed. 1. When the commit merges into master, GitHub automatically closes the PR. -## My team owns a label. What should I do? {#label-own} +## My team owns a label. What should I do? Subteams need to triage all issues in the [labels they own](#team-labels), preferably on a weekly basis. -### Issues {#issues} +### Issues 1. Filter the list of issues by your team label **and** the `untriaged` label. 1. Review the issue. @@ -109,9 +114,10 @@ preferably on a weekly basis. issue is either P0 or P1 we assume that is actively worked on. 1. Remove the `untriaged` label. -Note that you need to be in the [bazelbuild organization](https://github.com/bazelbuild) to be able to add or remove labels. +Note that you need to be in the [bazelbuild +organization](https://github.com/bazelbuild) to be able to add or remove labels. -### Pull Requests {#pull-requests} +### Pull Requests Pull requests (PRs) are a primary way that external contributors add value to Bazel. As an open source project, it is important to ensure that PRs are @@ -152,7 +158,7 @@ reviewed and handled in a timely and efficient manner. When closing a PR, be polite and explain the reason for closure. -## Priority {#priority} +## Priority The following definitions for priority will be used by the maintainers to triage issues. @@ -162,7 +168,8 @@ issues. unusable, or a downed service that severely impacts development of the Bazel project. This includes regressions introduced in a new release that blocks a significant number of users, or an incompatible breaking change that was not - compliant to the [Breaking Change](https://docs.google.com/document/d/1q5GGRxKrF_mnwtaPKI487P8OdDRh2nN7jX6U-FXnHL0/edit?pli=1#heading=h.ceof6vpkb3ik) + compliant to the [Breaking + Change](https://docs.google.com/document/d/1q5GGRxKrF_mnwtaPKI487P8OdDRh2nN7jX6U-FXnHL0/edit?pli=1#heading=h.ceof6vpkb3ik) policy. No practical workaround exists. * [**P1**](https://github.com/bazelbuild/bazel/labels/P1) - Critical defect or feature which should be addressed in the next release, or a serious issue that @@ -180,7 +187,7 @@ issues. or feature request that is unlikely to get closed. Can also be kept open for a potential re-prioritization if more users are impacted. -## Team labels {#team-labels} +## Team labels * [`team-Android`](https://github.com/bazelbuild/bazel/labels/team-Android): Issues for Android team * Contact: [ahumesky](https://github.com/ahumesky) diff --git a/contribute/naming.mdx b/contribute/naming.mdx index 5c71e429..144b08af 100644 --- a/contribute/naming.mdx +++ b/contribute/naming.mdx @@ -6,17 +6,18 @@ title: 'Naming a Bazel related project' First, thank you for contributing to the Bazel ecosystem! Please reach out to the Bazel community on the -[bazel-discuss mailing list](https://groups.google.com/forum/#!forum/bazel-discuss) to share your project and its suggested name. +[bazel-discuss mailing list](https://groups.google.com/forum/#!forum/bazel-discuss +) to share your project and its suggested name. If you are building a Bazel related tool or sharing your Skylark rules, we recommend following these guidelines for the name of your project: -## Naming Starlark rules {#name-starlark-rules} +## Naming Starlark rules See [Deploying new Starlark rules](/rules/deploying) in the docs. -## Naming other Bazel related tools {#name-related-tools} +## Naming other Bazel related tools This section applies if you are building a tool to enrich the Bazel ecosystem. For example, a new IDE plugin or a new build system migrator. diff --git a/contribute/patch-acceptance.mdx b/contribute/patch-acceptance.mdx index 2fca9f1a..867c046f 100644 --- a/contribute/patch-acceptance.mdx +++ b/contribute/patch-acceptance.mdx @@ -13,16 +13,19 @@ code base. need a corresponding issue for tracking. 1. If you're proposing significant changes, write a [design document](/contribute/design-documents). -1. Ensure you've signed a [Contributor License Agreement](https://cla.developers.google.com). +1. Ensure you've signed a [Contributor License + Agreement](https://cla.developers.google.com). 1. Prepare a git commit that implements the feature. Don't forget to add tests and update the documentation. If your change has user-visible effects, please [add release notes](/contribute/release-notes). If it is an incompatible change, read the [guide for rolling out breaking changes](/contribute/breaking-changes). 1. Create a pull request on [GitHub](https://github.com/bazelbuild/bazel/pulls). If you're new to GitHub, - read [about pull requests](https://help.github.com/articles/about-pull-requests/). Note that + read [about pull + requests](https://help.github.com/articles/about-pull-requests/). Note that we restrict permissions to create branches on the main Bazel repository, so - you will need to push your commit to [your own fork of the repository](https://help.github.com/articles/working-with-forks/). + you will need to push your commit to [your own fork of the + repository](https://help.github.com/articles/working-with-forks/). 1. A Bazel maintainer should assign you a reviewer within 7 business days (excluding holidays in the USA and Germany). If you aren't assigned a reviewer in that time, you can ping `@bazelbuild/triage` on the PR. diff --git a/contribute/policy.mdx b/contribute/policy.mdx index 557955f3..1bf00290 100644 --- a/contribute/policy.mdx +++ b/contribute/policy.mdx @@ -48,7 +48,7 @@ rule sets. Contributors with a record of consistent, responsible past contributions who are planning major contributions in the future could be considered to become qualified Maintainers. -## Contribution policy {#contribution-policy} +## Contribution policy The Bazel project accepts contributions from external contributors. Here are the contribution policies for Google-managed and Community-managed areas of code. diff --git a/contribute/release-notes.mdx b/contribute/release-notes.mdx index fd78602a..83e1d75b 100644 --- a/contribute/release-notes.mdx +++ b/contribute/release-notes.mdx @@ -10,7 +10,7 @@ Commit descriptions in Bazel include a `RELNOTES:` tag followed by a release note. This is used by the Bazel team to track changes in each release and write the release announcement. -## Overview {#overview} +## Overview * Is your change a bugfix? In that case, you don't need a release note. Please include a reference to the GitHub issue. @@ -18,9 +18,10 @@ the release announcement. * If the change adds / removes / changes Bazel in a user-visible way, then it may be advantageous to mention it. -If the change is significant, follow the [design document policy](/contribute/design-documents) first. +If the change is significant, follow the [design document +policy](/contribute/design-documents) first. -## Guidelines {#guidelines} +## Guidelines The release notes will be read by our users, so it should be short (ideally one sentence), avoid jargon (Bazel-internal terminology), should focus on what the @@ -59,10 +60,12 @@ change is about. the user will wonder is "when?" and we don't want them to start worrying about their current builds breaking at some unknown time. -## Process {#process} +## Process -As part of the [release process](https://github.com/bazelbuild/continuous-integration/blob/master/docs/release-playbook.md), -we collect the `RELNOTES` tags of every commit. We copy everything in a [Google Doc](https://docs.google.com/document/d/1wDvulLlj4NAlPZamdlEVFORks3YXJonCjyuQMUQEmB0/edit) +As part of the [release +process](https://github.com/bazelbuild/continuous-integration/blob/master/docs/release-playbook.md), +we collect the `RELNOTES` tags of every commit. We copy everything in a [Google +Doc](https://docs.google.com/document/d/1wDvulLlj4NAlPZamdlEVFORks3YXJonCjyuQMUQEmB0/edit) where we review, edit, and organize the notes. The release manager sends an email to the @@ -70,4 +73,6 @@ The release manager sends an email to the Bazel contributors are invited to contribute to the document and make sure their changes are correctly reflected in the announcement. -Later, the announcement will be submitted to the [Bazel blog](https://blog.bazel.build/), using the [bazel-blog repository](https://github.com/bazelbuild/bazel-blog/tree/master/_posts). +Later, the announcement will be submitted to the [Bazel +blog](https://blog.bazel.build/), using the [bazel-blog +repository](https://github.com/bazelbuild/bazel-blog/tree/master/_posts). diff --git a/contribute/search.mdx b/contribute/search.mdx index 7bbea560..43c90754 100644 --- a/contribute/search.mdx +++ b/contribute/search.mdx @@ -2,14 +2,14 @@ title: 'Searching the codebase' --- -## Product overview {#product-overview} +## Product overview Bazel's [code search and source browsing interface](https://source.bazel.build) is a web-based tool for browsing Bazel source code repositories. You can use these features to navigate among different repositories, branches, and files. You can also view history, diffs, and blame information. -## Getting started {#getting-started} +## Getting started Note: For the best experience, use the latest version of Chrome, Safari, or Firefox. @@ -29,9 +29,9 @@ commit. At the top of the screen is a search box. You can use this box to search for specific files and code. -## Working with repositories {#working-with-repositories} +## Working with repositories -### Opening a repository {#opening-a-repository} +### Opening a repository To open a repository, click its name from the main screen. @@ -41,11 +41,11 @@ repository and allows you to move quickly to another location such as another repository, or another location within a repository, such as a file, branch, or commit. -### Switch repositories {#switch-repositories} +### Switch repositories To switch to a different repository, select the repository from the Breadcrumb toolbar. -### View a repository at a specific commit {#view-a-repository-at-a-specific-commit} +### View a repository at a specific commit To view a repository at a specific commit: @@ -56,7 +56,7 @@ To view a repository at a specific commit: The interface now shows the repository as it existed at that commit. -### Open a branch, commit, or tag {#open-a-branch-commit-or-tag} +### Open a branch, commit, or tag By default, the code search and source browsing interface opens a repository to the default branch. To open a different branch, from the Breadcrumb toolbar, @@ -72,7 +72,7 @@ branch using a branch name, a tag name, or through a search box. * To search for a branch, commit, or tag, select the corresponding item and type a search term in the search box. -## Working with files {#working-with-files} +## Working with files When you select a repository from the main screen, the screen changes to display a view of that repository. If a README file exists, its contents appear in the @@ -90,13 +90,13 @@ three components: * A **File path** box, which displays the name of the current file or folder and its corresponding path -### Open a file {#open-a-file} +### Open a file You can open a file by browsing to its directory and selecting it. The view of the repository updates to show the contents of the file in the file pane, and its location in the repository in the tree pane. -### View file changes {#view-file-changes} +### View file changes To view file changes: @@ -105,7 +105,7 @@ To view file changes: The file pane updates to display who made changes to the file and when. -### View change history {#view-change-history} +### View change history To view the change history of a file: @@ -113,7 +113,7 @@ To view the change history of a file: 1. Click **HISTORY**, located in the upper-right corner. The **Change history** pane appears, showing the commits for this file. -### View code reviews {#view-code-reviews} +### View code reviews For Gerrit code reviews, you can open the tool directly from the Change History pane. @@ -128,7 +128,7 @@ To view the code review for a file: The Gerrit Code Review tool opens in a new browser window. -### Open a file at a specific commit {#open-a-file-at-a-specific-commit} +### Open a file at a specific commit To open a file at a specific commit: @@ -138,7 +138,7 @@ To open a file at a specific commit: 1. Hover over a commit. A **VIEW** button appears. 1. Click the **VIEW** button. -### Compare a file to a different commit {#compare-a-file-to-a-different-commit} +### Compare a file to a different commit To compare a file at a different commit: @@ -157,7 +157,7 @@ To change either file, hover over the commit in the Change History pane. Then, click either the **Left** or **Right** button to have the open the commit on the left or right side of the diff. -### Browsing cross references {#browsing-cross-references} +### Browsing cross references Another way to browse source repositories is through the use of cross references. These references appear automatically as hyperlinks within a given @@ -188,7 +188,7 @@ You can continue to browse cross references using the Cross Reference pane, just as you can in the File pane. When you do, the pane displays a breadcrumb trail, which you can use to navigate between different cross references. -## Searching for code {#search} +## Searching for code You can search for specific files or code snippets using the search box located at the top of the screen. Searches are always against the default branch. @@ -272,7 +272,7 @@ f: -## Additional Support {#additional-support} +## Additional Support To report an issue, click the **Feedback** button that appears in the top right-hand corner of the screen and enter your feedback in the provided form. diff --git a/contribute/statemachine-guide.mdx b/contribute/statemachine-guide.mdx index 4db66dfa..e98a96e8 100644 --- a/contribute/statemachine-guide.mdx +++ b/contribute/statemachine-guide.mdx @@ -52,7 +52,7 @@ virtually all recomputation when a SkyFunction restarts (assuming that `SkyKeyComputeState` does not fall out of cache) by exposing suspend and resume execution hooks. -### Stateful computations inside `SkyKeyComputeState` {#stateful-computations} +### Stateful computations inside `SkyKeyComputeState` From an object-oriented design standpoint, it makes sense to consider storing computational objects inside `SkyKeyComputeState` instead of pure data values. @@ -164,7 +164,7 @@ subtasks, those lookups and subtasks will complete before the next state begins. Tip: (Corollary) If subtasks are complex `StateMachine`s or recursively create subtasks, they all *transitively* complete before the next state begins. -### SkyValue lookups {#skyvalue-lookups} +### SkyValue lookups `StateMachine`s use `Tasks.lookUp` overloads to look up SkyValues. They are analogous to `SkyFunction.Environment.getValue` and @@ -174,7 +174,8 @@ instead, batches[^4] as many lookups as possible before doing so. The value might not be immediately available, for example, requiring a Skyframe restart, so the caller specifies what to do with the resulting value using a callback. -The `StateMachine` processor ([`Driver`s and bridging to SkyFrame](#drivers-and-bridging)) guarantees that the value is available before +The `StateMachine` processor ([`Driver`s and bridging to +SkyFrame](#drivers-and-bridging)) guarantees that the value is available before the next state begins. An example follows. ``` @@ -260,7 +261,7 @@ Though `Subtask1` and `Subtask2` are logically concurrent, everything runs in a single thread so the "concurrent" update of `i` does not need any synchronization. -### Structured concurrency {#structured-concurrency} +### Structured concurrency Since every `lookUp` and `enqueue` must resolve before advancing to the next state, it means that concurrency is naturally limited to tree-structures. It's @@ -285,7 +286,8 @@ and solutions to certain control flow problems. ### Sequential states This is the most common and straightforward control flow pattern. An example of -this is shown in [Stateful computations inside `SkyKeyComputeState`](#stateful-computations). +this is shown in [Stateful computations inside +`SkyKeyComputeState`](#stateful-computations). ### Branching @@ -384,7 +386,7 @@ class M2 implements StateMachine { } ``` -#### `runAfter` injection {#runafter-injection} +#### `runAfter` injection Sometimes, abusing `Tasks.enqueue` is impossible because there are other parallel subtasks or `Tasks.lookUp` calls that must be completed before *S* @@ -545,10 +547,11 @@ section describes the propagation of data values. ### Implementing `Tasks.lookUp` callbacks -There’s an example of implementing a `Tasks.lookUp` callback in [SkyValue lookups](#skyvalue-lookups). This section provides rationale and suggests +There’s an example of implementing a `Tasks.lookUp` callback in [SkyValue +lookups](#skyvalue-lookups). This section provides rationale and suggests approaches for handling multiple SkyValues. -#### `Tasks.lookUp` callbacks {#tasks-lookup-callbacks} +#### `Tasks.lookUp` callbacks The `Tasks.lookUp` method takes a callback, `sink`, as a parameter. @@ -669,7 +672,7 @@ because the value types are different. When that’s not the case, falling back lambda-based implementations or full inner-class instances that implement the appropriate callbacks is viable. -### Propagating values between `StateMachine`s {#propagating-values} +### Propagating values between `StateMachine`s So far, this document has only explained how to arrange work in a subtask, but subtasks also need to report a values back to the caller. Since subtasks are @@ -709,7 +712,8 @@ class BarProducer implements StateMachine { Tip: It would be tempting to use the more concise signature void `accept(Bar value)` rather than the stuttery `void acceptBarValue(Bar value)` above. However, `Consumer` is a common overload of `void accept(Bar value)`, -so doing this often leads to violations of the [Overloads: never split](https://google.github.io/styleguide/javaguide.html#s3.4.2-ordering-class-contents) +so doing this often leads to violations of the [Overloads: never +split](https://google.github.io/styleguide/javaguide.html#s3.4.2-ordering-class-contents) style-guide rule. Tip: Using a custom `ResultSink` type instead of a generic one from @@ -772,11 +776,14 @@ pattern after accepting output from either a subtask or SkyValue lookup. Note that the implementation of `acceptBarError` eagerly forwards the result to the `Caller.ResultSink`, as required by [Error bubbling](#error-bubbling). -Alternatives for top-level `StateMachine`s are described in [`Driver`s and bridging to SkyFunctions](#drivers-and-bridging). +Alternatives for top-level `StateMachine`s are described in [`Driver`s and +bridging to SkyFunctions](#drivers-and-bridging). -### Error handling {#error-handling} +### Error handling -There's a couple of examples of error handling already in [`Tasks.lookUp` callbacks](#tasks-lookup-callbacks) and [Propagating values between `StateMachines`](#propagating-values). Exceptions, other than +There's a couple of examples of error handling already in [`Tasks.lookUp` +callbacks](#tasks-lookup-callbacks) and [Propagating values between +`StateMachines`](#propagating-values). Exceptions, other than `InterruptedException` are not thrown, but instead passed around through callbacks as values. Such callbacks often have exclusive-or semantics, with exactly one of a value or error being passed. @@ -784,7 +791,7 @@ exactly one of a value or error being passed. The next section describes a a subtle, but important interaction with Skyframe error handling. -#### Error bubbling (--nokeep\_going) {#error-bubbling} +#### Error bubbling (--nokeep\_going) Warning: Errors need to be eagerly propagated all the way back to the SkyFunction for error bubbling to function correctly. @@ -807,7 +814,7 @@ If a `Driver` is being utilized directly, it is essential to check for propagated errors from the SkyFunction, even if the machine has not finished processing. -### Event Handling {#event-handling} +### Event Handling For SkyFunctions that need to emit events, a `StoredEventHandler` is injected into SkyKeyComputeState and further injected into `StateMachine`s that require @@ -816,7 +823,7 @@ certain events unless they are replayed but this was subsequently fixed. `StoredEventHandler` injection is preserved because it simplifies the implementation of events emitted from error handling callbacks. -## `Driver`s and bridging to SkyFunctions {#drivers-and-bridging} +## `Driver`s and bridging to SkyFunctions A `Driver` is responsible for managing the execution of `StateMachine`s, beginning with a specified root `StateMachine`. As `StateMachine`s can @@ -931,7 +938,7 @@ private Result computeResult(State state, Skyfunction.Environment env) } ``` -### Embedding `Driver` {#embedding-driver} +### Embedding `Driver` If the `StateMachine` produces a value and raises no exceptions, embedding `Driver` is another possible implementation, as shown in the following example. @@ -1054,7 +1061,7 @@ performance that approaches hand-written callback code. ## Appendix -### Callback Hell {#callback-hell} +### Callback Hell Callback hell is an infamous problem in asynchronous code that uses callbacks. It stems from the fact that the continuation for a subsequent step is nested @@ -1107,7 +1114,7 @@ Callback hell may also occur if the [`runAfter` injection](#runafter-injection) pattern is used too densely, but this can be avoided by interspersing injections with sequential steps. -#### Example: Chained SkyValue lookups {#chained-skyvalue-lookups} +#### Example: Chained SkyValue lookups It is often the case that the application logic requires dependent chains of SkyValue lookups, for example, if a second SkyKey depends on the first SkyValue. @@ -1179,7 +1186,8 @@ states. Where it is possible, local stack `step` variables are young generation variables and efficiently GC'd. For `StateMachine` variables, breaking things down into subtasks and following -the recommended pattern for [Propagating values between `StateMachine`s](#propagating-values) is also helpful. Observe that when +the recommended pattern for [Propagating values between +`StateMachine`s](#propagating-values) is also helpful. Observe that when following the pattern, only child `StateMachine`s have references to parent `StateMachine`s and not vice versa. This means that as children complete and update the parents using result callbacks, the children naturally fall out of @@ -1199,9 +1207,10 @@ state sequence `foo`, followed by `bar`. `foo` no longer includes the behavior `bar`. As a result, method names for states tend to be narrower in scope, potentially reflecting local behavior. -### Concurrency tree diagram {#concurrency-tree-diagram} +### Concurrency tree diagram -The following is an alternative view of the diagram in [Structured concurrency](#structured-concurrency) that better depicts the tree structure. +The following is an alternative view of the diagram in [Structured +concurrency](#structured-concurrency) that better depicts the tree structure. The blocks form a small tree. ![Structured Concurrency 3D](/contribute/images/structured-concurrency-3d.svg) diff --git a/contribute/windows-chocolatey-maintenance.mdx b/contribute/windows-chocolatey-maintenance.mdx index d961d471..c6aee8fb 100644 --- a/contribute/windows-chocolatey-maintenance.mdx +++ b/contribute/windows-chocolatey-maintenance.mdx @@ -7,7 +7,7 @@ title: 'Maintaining Bazel Chocolatey package on Windows' Note: The Chocolatey package is experimental; please provide feedback (`@petemounce` in issue tracker). -## Prerequisites {#prerequisites} +## Prerequisites You need: @@ -19,7 +19,7 @@ You need: * (to publish) to have set up that API key for the chocolatey source locally via `choco apikey -k -s https://chocolatey.org/` -## Build {#build} +## Build Compile bazel with msys2 shell and `compile.sh`. @@ -34,7 +34,7 @@ created. The `build.ps1` script supports `mode` values `local`, `rc` and `release`. -## Test {#test} +## Test 0. Build the package (with `-mode local`) @@ -56,7 +56,7 @@ The `build.ps1` script supports `mode` values `local`, `rc` and `release`. Chocolatey's moderation process automates checks here as well. -## Release {#release} +## Release Modify `tools/parameters.json` for the new release's URI and checksum once the release has been published to github releases. diff --git a/contribute/windows-scoop-maintenance.mdx b/contribute/windows-scoop-maintenance.mdx index eb607de8..58e2a6c4 100644 --- a/contribute/windows-scoop-maintenance.mdx +++ b/contribute/windows-scoop-maintenance.mdx @@ -7,7 +7,7 @@ title: 'Maintaining Bazel Scoop package on Windows' Note: The Scoop package is experimental. To provide feedback, go to `@excitoon` in issue tracker. -## Prerequisites {#prerequisites} +## Prerequisites You need: @@ -19,7 +19,7 @@ You need: [e-mail](mailto:vladimir.chebotarev@gmail.com) or [Telegram](http://telegram.me/excitoon). -## Release process {#release-process} +## Release process Scoop packages are very easy to maintain. Once you have the URL of released Bazel, you need to make appropriate changes in diff --git a/docs/android-build-performance.mdx b/docs/android-build-performance.mdx index e94f77e6..0d5edc77 100644 --- a/docs/android-build-performance.mdx +++ b/docs/android-build-performance.mdx @@ -8,7 +8,7 @@ This page contains information on optimizing build performance for Android apps specifically. For general build performance optimization with Bazel, see [Optimizing Performance](/rules/performance). -## Recommended flags {#recommended-flags} +## Recommended flags The flags are in the [`bazelrc` configuration syntax](/run/bazelrc#bazelrc-syntax-semantics), so diff --git a/docs/android-instrumentation-test.mdx b/docs/android-instrumentation-test.mdx index e7be4e54..14d95bd3 100644 --- a/docs/android-instrumentation-test.mdx +++ b/docs/android-instrumentation-test.mdx @@ -4,7 +4,8 @@ title: 'Android Instrumentation Tests' -_If you're new to Bazel, start with the [Building Android with Bazel](/start/android-app) tutorial._ +_If you're new to Bazel, start with the [Building Android with +Bazel](/start/android-app ) tutorial._ ![Running Android instrumentation tests in parallel](/docs/images/android_test.gif "Android instrumentation test") @@ -19,11 +20,13 @@ emulators in a sandbox, ensuring that tests always run from a clean state. Each test gets an isolated emulator instance, allowing tests to run in parallel without passing states between them. -For more information on Android instrumentation tests, check out the [Android developer documentation](https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests.html). +For more information on Android instrumentation tests, check out the [Android +developer +documentation](https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests.html). Please file issues in the [GitHub issue tracker](https://github.com/bazelbuild/bazel/issues). -## How it works {#how-it-works} +## How it works When you run `bazel test` on an `android_instrumentation_test` target for the first time, Bazel performs the following steps: @@ -40,7 +43,7 @@ In subsequent test runs, Bazel boots the emulator from the clean, cached state created in step 2, so there are no leftover states from previous runs. Caching emulator state also speeds up test runs. -## Prerequisites {#prerequisites} +## Prerequisites Ensure your environment satisfies the following prerequisites: @@ -57,7 +60,8 @@ This results in output similar to the following: release 4.1.0 ``` -- **KVM**. Bazel requires emulators to have [hardware acceleration](https://developer.android.com/studio/run/emulator-acceleration.html#accel-check) +- **KVM**. Bazel requires emulators to have [hardware + acceleration](https://developer.android.com/studio/run/emulator-acceleration.html#accel-check) with KVM on Linux. You can follow these [installation instructions](https://help.ubuntu.com/community/KVM/Installation) for Ubuntu. @@ -103,7 +107,7 @@ The output is the following: sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386 ``` -## Getting started {#getting-started} +## Getting started Here is a typical target dependency graph of an `android_instrumentation_test`: @@ -112,7 +116,7 @@ Here is a typical target dependency graph of an `android_instrumentation_test`: **Figure 2.** Target dependency graph of an `android_instrumentation_test`. -### BUILD file {#build-file} +### BUILD file The graph translates into a `BUILD` file like this: @@ -172,9 +176,11 @@ The main attributes of the rule `android_instrumentation_test` are: - `target_device`: An `android_device` target. This target describes the specifications of the Android emulator which Bazel uses to create, launch and - run the tests. See the [section on choosing an Android device](#android-device-target) for more information. + run the tests. See the [section on choosing an Android + device](#android-device-target) for more information. -The test app's `AndroidManifest.xml` must include [an `` tag](https://developer.android.com/studio/test/#configure_instrumentation_manifest_settings). +The test app's `AndroidManifest.xml` must include [an `` +tag](https://developer.android.com/studio/test/#configure_instrumentation_manifest_settings). This tag must specify the attributes for the **package of the target app** and the **fully qualified class name of the instrumentation test runner**, `androidx.test.runner.AndroidJUnitRunner`. @@ -203,7 +209,7 @@ Here is an example `AndroidTestManifest.xml` for the test app: ``` -### WORKSPACE dependencies {#workspace-dependencies} +### WORKSPACE dependencies In order to use this rule, your project needs to depend on these external repositories: @@ -211,7 +217,8 @@ repositories: - `@androidsdk`: The Android SDK. Download this through Android Studio. - `@android_test_support`: Hosts the test runner, emulator launcher, and - `android_device` targets. You can find the [latest release here](https://github.com/android/android-test/releases). + `android_device` targets. You can find the [latest release + here](https://github.com/android/android-test/releases). Enable these dependencies by adding the following lines to your `WORKSPACE` file: @@ -235,16 +242,17 @@ load("@android_test_support//:repo.bzl", "android_test_repositories") android_test_repositories() ``` -## Maven dependencies {#maven-dependencies} +## Maven dependencies -For managing dependencies on Maven artifacts from repositories, such as [Google Maven](https://maven.google.com) or [Maven Central](https://central.maven.org), +For managing dependencies on Maven artifacts from repositories, such as [Google +Maven](https://maven.google.com) or [Maven Central](https://central.maven.org), you should use a Maven resolver, such as [`rules_jvm_external`](https://github.com/bazelbuild/rules_jvm_external). The rest of this page shows how to use `rules_jvm_external` to resolve and fetch dependencies from Maven repositories. -## Choosing an android_device target {#android-device-target} +## Choosing an android_device target `android_instrumentation_test.target_device` specifies which Android device to run the tests on. These `android_device` targets are defined in @@ -299,7 +307,7 @@ bazel query 'filter("x86_qemu2$", kind(android_device, @android_test_support//to Bazel currently supports x86-based emulators only. For better performance, use `QEMU2` `android_device` targets instead of `QEMU` ones. -## Running tests {#running-tests} +## Running tests To run tests, add these lines to your project's `project root:/.bazelrc` file. @@ -334,7 +342,7 @@ Then, use one of the configurations to run tests: Use __only one configuration__ or tests will fail. -### Headless testing {#headless-testing} +### Headless testing With `Xvfb`, it is possible to test with emulators without the graphical interface, also known as headless testing. To disable the graphical interface @@ -344,7 +352,7 @@ when running tests, pass the test argument `--enable_display=false` to Bazel: bazel test //my/test:target --test_arg=--enable_display=false ``` -### GUI testing {#gui-testing} +### GUI testing If the `$DISPLAY` environment variable is set, it's possible to enable the graphical interface of the emulator while the test is running. To do this, pass @@ -354,7 +362,7 @@ these test arguments to Bazel: bazel test //my/test:target --test_arg=--enable_display=true --test_env=DISPLAY ``` -### Testing with a local emulator or device {#testing-local-emulator} +### Testing with a local emulator or device Bazel also supports testing directly on a locally launched emulator or connected device. Pass the flags @@ -364,12 +372,13 @@ If there is more than one connected device, pass the flag `--test_arg=--device_serial_number=$device_id` where `$device_id` is the id of the device/emulator listed in `adb devices`. -## Sample projects {#sample-projects} +## Sample projects -If you are looking for canonical project samples, see the [Android testing samples](https://github.com/googlesamples/android-testing#experimental-bazel-support) +If you are looking for canonical project samples, see the [Android testing +samples](https://github.com/googlesamples/android-testing#experimental-bazel-support) for projects using Espresso and UIAutomator. -## Espresso setup {#espresso-setup} +## Espresso setup If you write UI tests with [Espresso](https://developer.android.com/training/testing/espresso/) (`androidx.test.espresso`), you can use the following snippets to set up your @@ -451,9 +460,9 @@ android_binary( ) ``` -## Tips {#tips} +## Tips -### Reading test logs {#reading-test-logs} +### Reading test logs Use `--test_output=errors` to print logs for failing tests, or `--test_output=all` to print all test output. If you're looking for an @@ -521,7 +530,7 @@ $ tree bazel-testlogs/ui/espresso/BasicSample/BasicSampleInstrumentationTest 4 directories, 41 files ``` -### Reading emulator logs {#reading-emulator-logs} +### Reading emulator logs The emulator logs for `android_device` targets are stored in the `/tmp/` directory with the name `emulator_xxxxx.log`, where `xxxxx` is a @@ -533,7 +542,7 @@ Use this command to find the latest emulator log: ls -1t /tmp/emulator_*.log | head -n 1 ``` -### Testing against multiple API levels {#testing-multiple-apis} +### Testing against multiple API levels If you would like to test against multiple API levels, you can use a list comprehension to create test targets for each API level. For example: @@ -553,9 +562,10 @@ API_LEVELS = [ ) for API_LEVEL in API_LEVELS] ``` -## Known issues {#known-issues} +## Known issues -- [Forked adb server processes are not terminated after tests](https://github.com/bazelbuild/bazel/issues/4853) +- [Forked adb server processes are not terminated after + tests](https://github.com/bazelbuild/bazel/issues/4853) - While APK building works on all platforms (Linux, macOS, Windows), testing only works on Linux. - Even with `--config=local_adb`, users still need to specify diff --git a/docs/android-ndk.mdx b/docs/android-ndk.mdx index abd76409..00b73162 100644 --- a/docs/android-ndk.mdx +++ b/docs/android-ndk.mdx @@ -4,9 +4,10 @@ title: 'Using the Android Native Development Kit with Bazel' -_If you're new to Bazel, please start with the [Building Android with Bazel](/start/android-app) tutorial._ +_If you're new to Bazel, please start with the [Building Android with +Bazel](/start/android-app ) tutorial._ -## Overview {#overview} +## Overview Bazel can run in many different build configurations, including several that use the Android Native Development Kit (NDK) toolchain. This means that normal @@ -21,11 +22,11 @@ Android apps and uses [`rules_android_ndk`](https://github.com/bazelbuild/rules_android_ndk) for NDK toolchain discovery and registration. -## Prerequisites {#prerequisites} +## Prerequisites Please ensure that you have installed the Android SDK and NDK. -### NDK and SDK setup {#ndk-sdk-setup} +### NDK and SDK setup External repository setup varies depending on whether you are using WORKSPACE or bzlmod (MODULE.bazel). *Bzlmod is the preferred solution for Bazel 7+.* @@ -34,7 +35,7 @@ each other. If you are using one dependency management solution, you don't need to add the boilerplate for the other. -#### Bzlmod MODULE.bazel setup {#ndk-sdk-setup-bzlmod} +#### Bzlmod MODULE.bazel setup Add the following snippet to your MODULE.bazel: @@ -56,7 +57,7 @@ use_repo(android_sdk_repository_extension, "androidsdk") register_toolchains("@androidsdk//:sdk-toolchain", "@androidsdk//:all") ``` -#### Legacy WORKSPACE setup {#ndk-sdk-setup-workspace} +#### Legacy WORKSPACE setup Add the following snippet to your `WORKSPACE`: @@ -84,7 +85,7 @@ Compatibility notes for WORKSPACE: For more information about the `android_ndk_repository` rule, see its [docstring](https://github.com/bazelbuild/rules_android_ndk/blob/7b4300f6d731139ca097f3332a5aebae5b0d91d0/rules.bzl#L18-L25). -## Quick start {#quick-start} +## Quick start To build C++ for Android, simply add `cc_library` dependencies to your `android_binary` or `android_library` rules. @@ -154,9 +155,10 @@ targeted the architectures specified by `--android_platforms`. See the section on [configuring the target ABI](#configuring-target-abi) for more details. -## Example setup {#example-setup} +## Example setup -This example is available in the [Bazel examples repository](https://github.com/bazelbuild/examples/tree/master/android/ndk). +This example is available in the [Bazel examples +repository](https://github.com/bazelbuild/examples/tree/master/android/ndk). In the `BUILD.bazel` file, three targets are defined with the `android_binary`, `android_library`, and `cc_library` rules. @@ -207,7 +209,7 @@ public class MainActivity extends AppCompatActivity { Note: The name of the native library is derived from the name of the top level `android_binary` target. In this example, it is `app`. -## Configuring the target ABI {#configuring-target-abi} +## Configuring the target ABI To configure the target ABI, use the `--android_platforms` flag as follows: @@ -263,7 +265,7 @@ for more information on these ABIs. Multi-ABI Fat APKs are not recommended for release builds since they increase the size of the APK, but can be useful for development and QA builds. -## Selecting a C++ standard {#selecting-c-standard} +## Selecting a C++ standard Use the following flags to build according to a C++ standard: @@ -295,7 +297,7 @@ cc_library( ) ``` -## Building a `cc_library` for Android without using `android_binary` {#cclibrary-android} +## Building a `cc_library` for Android without using `android_binary` To build a standalone `cc_binary` or `cc_library` for Android without using an `android_binary`, use the `--platforms` flag. diff --git a/docs/bazel-and-android.mdx b/docs/bazel-and-android.mdx index d447f3f9..bf3625c9 100644 --- a/docs/bazel-and-android.mdx +++ b/docs/bazel-and-android.mdx @@ -8,17 +8,17 @@ This page contains resources that help you use Bazel with Android projects. It links to a tutorial, build rules, and other information specific to building Android projects with Bazel. -## Getting started {#getting-started} +## Getting started The following resources will help you work with Bazel on Android projects: -* [Tutorial: Building an Android app](/start/android-app). This +* [Tutorial: Building an Android app](/start/android-app ). This tutorial is a good place to start learning about Bazel commands and concepts, and how to build Android apps with Bazel. * [Codelab: Building Android Apps with Bazel](https://developer.android.com/codelabs/bazel-android-intro#0). This codelab explains how to build Android apps with Bazel. -## Features {#features} +## Features Bazel has Android rules for building and testing Android apps, integrating with the SDK/NDK, and creating emulator images. There are also Bazel plugins for @@ -39,7 +39,7 @@ Android Studio and IntelliJ. * [Android build performance](/docs/android-build-performance). This page provides information on optimizing build performance for Android apps. -## Further reading {#further-reading} +## Further reading * Integrating with dependencies from Google Maven and Maven Central with [rules_jvm_external](https://github.com/bazelbuild/rules_jvm_external). * Learn [How Android Builds Work in Bazel](https://blog.bazel.build/2018/02/14/how-android-builds-work-in-bazel.html). diff --git a/docs/bazel-and-apple.mdx b/docs/bazel-and-apple.mdx index 3024f4ea..6e4a06fe 100644 --- a/docs/bazel-and-apple.mdx +++ b/docs/bazel-and-apple.mdx @@ -8,7 +8,7 @@ This page contains resources that help you use Bazel to build macOS and iOS projects. It links to a tutorial, build rules, and other information specific to using Bazel to build and test for those platforms. -## Working with Bazel {#working-with-bazel} +## Working with Bazel The following resources will help you work with Bazel on macOS and iOS projects: @@ -17,14 +17,14 @@ The following resources will help you work with Bazel on macOS and iOS projects: * [General Apple rules](https://github.com/bazelbuild/rules_apple) * [Integration with Xcode](/install/ide) -## Migrating to Bazel {#migrating-to-bazel} +## Migrating to Bazel If you currently build your macOS and iOS projects with Xcode, follow the steps in the migration guide to start building them with Bazel: * [Migrating from Xcode to Bazel](/migrate/xcode) -## Apple apps and new rules {#apple-apps-new-rules} +## Apple apps and new rules **Note**: Creating new rules is for advanced build and test scenarios. You do not need it when getting started with Bazel. @@ -50,7 +50,7 @@ when building your macOS and iOS projects: * [`ObjcProvider`](/rules/lib/providers/ObjcProvider) * [`XcodeVersionConfig`](/rules/lib/providers/XcodeVersionConfig) -## Xcode selection {#xcode-selection} +## Xcode selection If your build requires Xcode, Bazel will select an appropriate version based on the `--xcode_config` and `--xcode_version` flags. The `--xcode_config` consumes diff --git a/docs/bazel-and-cpp.mdx b/docs/bazel-and-cpp.mdx index ee12316b..73e502cb 100644 --- a/docs/bazel-and-cpp.mdx +++ b/docs/bazel-and-cpp.mdx @@ -8,7 +8,7 @@ This page contains resources that help you use Bazel with C++ projects. It links to a tutorial, build rules, and other information specific to building C++ projects with Bazel. -## Working with Bazel {#working-with-bazel} +## Working with Bazel The following resources will help you work with Bazel on C++ projects: @@ -23,12 +23,12 @@ The following resources will help you work with Bazel on C++ projects: * [Tutorial: Configuring C++ toolchains](/tutorials/ccp-toolchain-config) * [Integrating with C++ rules](/configure/integrate-cpp) -## Best practices {#best-practices} +## Best practices In addition to [general Bazel best practices](/configure/best-practices), below are best practices specific to C++ projects. -### BUILD files {#build-files} +### BUILD files Follow the guidelines below when creating your BUILD files: @@ -64,7 +64,7 @@ Follow the guidelines below when creating your BUILD files: ) ``` -### Include paths {#include-paths} +### Include paths Follow these guidelines for include paths: @@ -82,7 +82,7 @@ Follow these guidelines for include paths: [`strip_include_prefix`](/reference/be/c-cpp#cc_library.strip_include_prefix) arguments on the `cc_library` rule target. -### Toolchain features {#toolchain-features} +### Toolchain features The following optional [features](/docs/cc-toolchain-config-reference#features) can improve the hygiene of a C++ project. They can be enabled using the diff --git a/docs/bazel-and-java.mdx b/docs/bazel-and-java.mdx index cc456800..bd5af010 100644 --- a/docs/bazel-and-java.mdx +++ b/docs/bazel-and-java.mdx @@ -8,21 +8,21 @@ This page contains resources that help you use Bazel with Java projects. It links to a tutorial, build rules, and other information specific to building Java projects with Bazel. -## Working with Bazel {#working-with-bazel} +## Working with Bazel The following resources will help you work with Bazel on Java projects: * [Tutorial: Building a Java Project](/start/java) * [Java rules](/reference/be/java) -## Migrating to Bazel {#migrating-to-bazel} +## Migrating to Bazel If you currently build your Java projects with Maven, follow the steps in the migration guide to start building your Maven projects with Bazel: * [Migrating from Maven to Bazel](/migrate/maven) -## Java versions {#java-versions} +## Java versions There are two relevant versions of Java that are set with configuration flags: @@ -30,7 +30,7 @@ There are two relevant versions of Java that are set with configuration flags: * the version of the Java runtime that is used to execute the code and to test it -### Configuring the version of the source code in your repository {#config-source-code} +### Configuring the version of the source code in your repository Without an additional configuration, Bazel assumes all Java source files in the repository are written in a single Java version. To specify the version of the @@ -40,7 +40,7 @@ should set this flag so that Bazel and its users can reference the source code's Java version number. For more details, see [Java language version flag](/docs/user-manual#java-language-version). -### Configuring the JVM used to execute and test the code {#config-jvm} +### Configuring the JVM used to execute and test the code Bazel uses one JDK for compilation and another JVM to execute and test the code. @@ -55,14 +55,14 @@ machine. To configure the JVM used for execution and testing use `--java_runtime_version` flag. The default value is `local_jdk`. -### Hermetic testing and compilation {#hermetic-testing} +### Hermetic testing and compilation To create a hermetic compile, you can use command line flag `--java_runtime_version=remotejdk_11`. The code is compiled for, executed, and tested on the JVM downloaded from a remote repository. For more details, see [Java runtime version flag](/docs/user-manual#java_runtime_version). -### Configuring compilation and execution of build tools in Java {#config-build-tools-java} +### Configuring compilation and execution of build tools in Java There is a second pair of JDK and JVM used to build and execute tools, which are used in the build process, but are not in the build results. That JDK and JVM @@ -70,7 +70,7 @@ are controlled using `--tool_java_language_version` and `--tool_java_runtime_version`. Default values are `11` and `remotejdk_11`, respectively. -#### Compiling using locally installed JDK {#compile-using-jdk} +#### Compiling using locally installed JDK Bazel by default compiles using remote JDK, because it is overriding JDK's internals. The compilation toolchains using locally installed JDK are configured, @@ -83,17 +83,17 @@ however, mind that this may not work on JDK of arbitrary vendors. For more details, see [configuring Java toolchains](#config-java-toolchains). -## Best practices {#best-practices} +## Best practices In addition to [general Bazel best practices](/configure/best-practices), below are best practices specific to Java projects. -### Directory structure {#directory-structure} +### Directory structure Prefer Maven's standard directory layout (sources under `src/main/java`, tests under `src/test/java`). -### BUILD files {#build-files} +### BUILD files Follow these guidelines when creating your `BUILD` files: @@ -121,7 +121,7 @@ Follow these guidelines when creating your `BUILD` files: * Tests should be in a matching directory under `src/test` and depend on this library. -## Creating new rules for advanced Java builds {#rules-advanced-java-builds} +## Creating new rules for advanced Java builds **Note**: Creating new rules is for advanced build and test scenarios. You do not need it when getting started with Bazel. @@ -141,7 +141,7 @@ projects: * [`JavaRuntimeInfo`](/rules/lib/providers/JavaRuntimeInfo) * [`JavaToolchainInfo`](/rules/lib/providers/JavaToolchainInfo) -## Configuring the Java toolchains {#config-java-toolchains} +## Configuring the Java toolchains Bazel uses two types of Java toolchains: @@ -150,7 +150,7 @@ Bazel uses two types of Java toolchains: * compilation, used to compile Java sources, controlled with the `--java_language_version` flag -### Configuring additional execution toolchains {#config-execution-toolchains} +### Configuring additional execution toolchains Execution toolchain is the JVM, either local or from a repository, with some additional information about its version, operating system, and CPU @@ -197,7 +197,7 @@ use_repo(custom_jdk, "openjdk_canary_linux_arm", "openjdk_canary_linux_arm_toolc register_toolchains("@openjdk_canary_linux_arm_toolchain_config_repo//:all") ``` -### Configuring additional compilation toolchains {#config-compilation-toolchains} +### Configuring additional compilation toolchains Compilation toolchain is composed of JDK and multiple tools that Bazel uses during the compilation and that provides additional features, such as: Error @@ -279,7 +279,7 @@ Predefined configurations: built from sources (this may be useful on operating system with different libc) -#### Configuring JVM and Java compiler flags {#config-jvm-flags} +#### Configuring JVM and Java compiler flags You may configure JVM and javac flags either with flags or with `default_java_toolchain` attributes. @@ -290,7 +290,7 @@ The relevant flags are `--jvmopt`, `--host_jvmopt`, `--javacopt`, and The relevant `default_java_toolchain` attributes are `javacopts`, `jvm_opts`, `javabuilder_jvm_opts`, and `turbine_jvm_opts`. -#### Package specific Java compiler flags configuration {#package-java-compiler-flags} +#### Package specific Java compiler flags configuration You can configure different Java compiler flags for specific source files using `package_configuration` attribute of `default_java_toolchain`. @@ -327,7 +327,7 @@ package_group( ) ``` -#### Multiple versions of Java source code in a single repository {#java-source-single-repo} +#### Multiple versions of Java source code in a single repository Bazel only supports compiling a single version of Java sources in a build. build. This means that when building a Java test or an application, all diff --git a/docs/cc-toolchain-config-reference.mdx b/docs/cc-toolchain-config-reference.mdx index dade7b66..e34eb846 100644 --- a/docs/cc-toolchain-config-reference.mdx +++ b/docs/cc-toolchain-config-reference.mdx @@ -2,7 +2,7 @@ title: 'C++ Toolchain Configuration' --- -## Overview {#overview} +## Overview To invoke the compiler with the right options, Bazel needs some knowledge about the compiler internals, such as include directories and important flags. @@ -59,7 +59,7 @@ The artifacts to be shipped to the sandbox are declared in the `cc_toolchain` target. For example, with the `cc_toolchain.linker_files` attribute you can specify the linker binary and toolchain libraries to ship into the sandbox. -## Toolchain selection {#toolchain-selection} +## Toolchain selection The toolchain selection logic operates as follows: @@ -93,7 +93,7 @@ fully fledged C++ features in Bazel without modifying the Bazel binary. C++ rules support multiple unique actions documented in detail [in the Bazel source code](https://source.bazel.build/bazel/+/4f547a7ea86df80e4c76145ffdbb0c8b75ba3afa:tools/build_defs/cc/action_names.bzl). -## Features {#features} +## Features A feature is an entity that requires command-line flags, actions, constraints on the execution environment, or dependency alterations. A feature @@ -121,7 +121,7 @@ A feature is enabled in one of the following ways: Features can have interdependencies, depend on command line flags, `BUILD` file settings, and other variables. -### Feature relationships {#feature-relationships} +### Feature relationships Dependencies are typically managed directly with Bazel, which simply enforces the requirements and manages conflicts intrinsic to the nature of the features @@ -130,25 +130,23 @@ constraints for use directly within the Starlark rule that govern feature support and expansion. These are: - - + + - - + + - - - - + - - + - -
ConstraintDescriptionConstraint + Description +
-
-requires = [
+   
requires = [
    feature_set (features = [
        'feature-name-1',
        'feature-name-2'
    ]),
-]
-    
+]
- Feature-level. The feature is supported only if the specified required + Feature-level. The feature is supported only if the specified required features are enabled. For example, when a feature is only supported in certain build modes (opt, dbg, or fastbuild). If `requires` contains multiple `feature_set`s @@ -157,47 +155,35 @@ requires = [
implies = ['feature']
-

- Feature-level. This feature implies the specified feature(s). +

implies = ['feature']
+

Feature-level. This feature implies the specified feature(s). Enabling a feature also implicitly enables all features implied by it - (that is, it functions recursively). -

-

- Also provides the ability to factor common subsets of functionality out of + (that is, it functions recursively).

+

Also provides the ability to factor common subsets of functionality out of a set of features, such as the common parts of sanitizers. Implied - features cannot be disabled. -

+ features cannot be disabled.

provides = ['feature']
-

- Feature-level. Indicates that this feature is one of several mutually +

provides = ['feature']
+

Feature-level. Indicates that this feature is one of several mutually exclusive alternate features. For example, all of the sanitizers could - specify provides = ["sanitizer"]. -

-

- This improves error handling by listing the alternatives if the user asks - for two or more mutually exclusive features at once. -

+ specify provides = ["sanitizer"].

+

This improves error handling by listing the alternatives if the user asks + for two or more mutually exclusive features at once.

-
-with_features = [
+   
with_features = [
   with_feature_set(
     features = ['feature-1'],
     not_features = ['feature-2'],
   ),
-]
-    
+]
- Flag set-level. A feature can specify multiple flag sets with multiple. + Flag set-level. A feature can specify multiple flag sets with multiple. When with_features is specified, the flag set will only expand to the build command if there is at least one with_feature_set for which all of the features in the specified features set @@ -209,7 +195,7 @@ with_features = [
-## Actions {#actions} +## Actions Actions provide the flexibility to modify the circumstances under which an action executes without assuming how the action will be run. An @@ -230,117 +216,149 @@ that implements an action (such as `CppCompileAction`). In particular, the "assembler actions" and "compiler actions" in the table below are `CppCompileAction`, while the link actions are `CppLinkAction`. -### Assembler actions {#assembler-actions} +### Assembler actions - - + + - - + + - - + + - - + +
ActionDescriptionAction + Description +
preprocess-assembleAssemble with preprocessing. Typically for .S files.preprocess-assemble + Assemble with preprocessing. Typically for .S files. +
assembleAssemble without preprocessing. Typically for .s files.assemble + Assemble without preprocessing. Typically for .s files. +
-### Compiler actions {#compiler-actions} +### Compiler actions - - + + - - + + - - + + - - + + - - + + - - +
ActionDescriptionAction + Description +
cc-flags-make-variablePropagates CC_FLAGS to genrules.cc-flags-make-variable + Propagates CC_FLAGS to genrules. +
c-compileCompile as C.c-compile + Compile as C. +
c++-compileCompile as C++.c++-compile + Compile as C++. +
c++-header-parsing - Run the compiler's parser on a header file to ensure that the header is + c++-header-parsing + Run the compiler's parser on a header file to ensure that the header is self-contained, as it will otherwise produce compilation errors. Applies only to toolchains that support modules.
-### Link actions {#link-actions} +### Link actions - - + + - - + + - - + + - - + + - - + +
ActionDescriptionAction + Description +
c++-link-dynamic-libraryLink a shared library containing all of its dependencies.c++-link-dynamic-library + Link a shared library containing all of its dependencies. +
c++-link-nodeps-dynamic-libraryLink a shared library only containing cc_library sources.c++-link-nodeps-dynamic-library + Link a shared library only containing cc_library sources. +
c++-link-executableLink a final ready-to-run library.c++-link-executable + Link a final ready-to-run library. +
-### AR actions {#ar-actions} +### AR actions AR actions assemble object files into archive libraries (`.a` files) via `ar` and encode some semantics into the name. - - + + - - + + - - + +
ActionDescriptionAction + Description +
c++-link-static-libraryCreate a static library (archive).c++-link-static-library + Create a static library (archive). +
-### LTO actions {#lto-actions} +### LTO actions - - + + - - + + - - + + - - + +
ActionDescriptionAction + Description +
lto-backendThinLTO action compiling bitcodes into native objects.lto-backend + ThinLTO action compiling bitcodes into native objects. +
lto-indexThinLTO action generating global index.lto-index + ThinLTO action generating global index. +
-## Using action_config {#using-action-config} +## Using action_config The `action_config` is a Starlark struct that describes a Bazel action by specifying the tool (binary) to invoke during the action and sets of @@ -350,39 +368,41 @@ execution. The `action_config()` constructor has the following parameters: - - + + - - + + - - + - - + - - + - - + @@ -404,28 +424,30 @@ within the same toolchain. This prevents ambiguity in tool paths and enforces the intention behind `action_config` - that an action's properties are clearly described in a single place in the toolchain. -### Using tool constructor {#using-tool-constructor} +### Using tool constructor An`action_config` can specify a set of tools via its `tools` parameter. The `tool()` constructor takes in the following parameters:
AttributeDescriptionAttribute + Description +
action_name - The Bazel action to which this action corresponds. + action_name + The Bazel action to which this action corresponds. Bazel uses this attribute to discover per-action tool and execution requirements.
tools - The executable to invoke. The tool applied to the action will be the + tools + The executable to invoke. The tool applied to the action will be the first tool in the list with a feature set that matches the feature configuration. Default value must be provided.
flag_sets - A list of flags that applies to a group of actions. Same as for a + flag_sets + A list of flags that applies to a group of actions. Same as for a feature.
env_sets - A list of environment constraints that applies to a group of actions. + env_sets + A list of environment constraints that applies to a group of actions. Same as for a feature.
- - + + - - + + - - + - - + @@ -439,7 +461,7 @@ with a `with_feature` set matching the feature configuration is found for more information). You should end your tool lists with a default tool that corresponds to an empty feature configuration. -### Example usage {#example-usage} +### Example usage Features and actions can be used together to implement Bazel actions with diverse cross-platform semantics. For example, debug symbol generation on @@ -531,7 +553,7 @@ follows: ), ] -### Flag groups {#flag-groups} +### Flag groups `CcToolchainConfigInfo` allows you to bundle flags into groups that serve a specific purpose. You can specify a flag within using pre-defined variables @@ -577,9 +599,7 @@ A variable can repeat multiple times. For example: expands to: -``` -iprefix= -isystem= -iprefix= -isystem= -``` Variables can correspond to structures accessible using dot-notation. For example: @@ -602,7 +622,7 @@ example: ], ) -### Conditional expansion {#conditional-expansion} +### Conditional expansion Flag groups support conditional expansion based on the presence of a particular variable or its field using the `expand_if_available`, `expand_if_not_available`, @@ -634,12 +654,12 @@ Note: The `--whole_archive` and `--no_whole_archive` options are added to the build command only when a currently iterated library has an `is_whole_archive` field. -## CcToolchainConfigInfo reference {#cctoolchainconfiginfo-reference} +## CcToolchainConfigInfo reference This section provides a reference of build variables, features, and other information required to successfully configure C++ rules. -### CcToolchainConfigInfo build variables {#cctoolchainconfiginfo-build-variables} +### CcToolchainConfigInfo build variables The following is a reference of `CcToolchainConfigInfo` build variables. @@ -647,313 +667,365 @@ Note: The **Action** column indicates the relevant action type, if applicable.
FieldDescriptionField + Description +
path - Path to the tool in question (relative to the current location). + path + Path to the tool in question (relative to the current location).
with_features - A list of feature sets out of which at least one must be satisfied + with_features + A list of feature sets out of which at least one must be satisfied for this tool to apply.
- - - + + + - + - + - + - + - + - + - + - - + - - + - - + - - + - - + - - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - - + - - + - + - + - - + - - + - + - + - + - + - - + - + - + - - + - + - + - + - + - + - + - + - + - - + - + - + - - + - - - + + - + - - + - + - + - + - + - + - + -
VariableActionDescriptionVariable + Action + Description +
source_filesource_file + compileSource file to compile.Source file to compile. +
input_fileinput_file + stripArtifact to strip.Artifact to strip. +
output_fileoutput_file + compile, stripCompilation output.Compilation output. +
output_assembly_fileoutput_assembly_file + compile - Emitted assembly file. Applies only when the + Emitted assembly file. Applies only when the compile action emits assembly text, typically when using the --save_temps flag. The contents are the same as for output_file.
output_preprocess_fileoutput_preprocess_file + compile - Preprocessed output. Applies only to compile + Preprocessed output. Applies only to compile actions that only preprocess the source files, typically when using the --save_temps flag. The contents are the same as for output_file.
includesincludes + compile - Sequence of files the compiler must + Sequence of files the compiler must unconditionally include in the compiled source.
include_pathsinclude_paths + compile - Sequence directories in which the compiler + Sequence directories in which the compiler searches for headers included using #include<foo.h> and #include "foo.h".
quote_include_pathsquote_include_paths + compile - Sequence of -iquote includes - + Sequence of -iquote includes - directories in which the compiler searches for headers included using #include "foo.h".
system_include_pathssystem_include_paths + compile - Sequence of -isystem includes - + Sequence of -isystem includes - directories in which the compiler searches for headers included using #include <foo.h>.
dependency_filedependency_file + compileThe .d dependency file generated by the compiler.The .d dependency file generated by the compiler. +
preprocessor_definespreprocessor_defines + compileSequence of defines, such as --DDEBUG.Sequence of defines, such as --DDEBUG. +
picpic + compileCompiles the output as position-independent code.Compiles the output as position-independent code. +
gcov_gcno_filegcov_gcno_file + compileThe gcov coverage file.The gcov coverage file. +
per_object_debug_info_fileper_object_debug_info_file + compileThe per-object debug info (.dwp) file.The per-object debug info (.dwp) file. +
stripoptsstripopts + stripSequence of stripopts.Sequence of stripopts. +
legacy_compile_flagslegacy_compile_flags + compile - Sequence of flags from legacy + Sequence of flags from legacy CROSSTOOL fields such as compiler_flag, optional_compiler_flag, cxx_flag, and optional_cxx_flag.
user_compile_flagsuser_compile_flags + compile - Sequence of flags from either the + Sequence of flags from either the copt rule attribute or the --copt, --cxxopt, and --conlyopt flags.
unfiltered_compile_flagsunfiltered_compile_flags + compile - Sequence of flags from the - unfiltered_cxx_flag legacy CROSSTOOL field or the + Sequence of flags from the + unfiltered_cxx_flag legacy CROSSTOOL field or the unfiltered_compile_flags feature. These are not filtered by the nocopts rule attribute.
sysrootsysroot + The sysroot.The sysroot. +
runtime_library_search_directoriesruntime_library_search_directories + link - Entries in the linker runtime search path (usually + Entries in the linker runtime search path (usually set with the -rpath flag).
library_search_directorieslibrary_search_directories + link - Entries in the linker search path (usually set with + Entries in the linker search path (usually set with the -L flag).
libraries_to_linklibraries_to_link + linkFlags providing files to link as inputs in the linker invocation.Flags providing files to link as inputs in the linker invocation. +
def_file_pathdef_file_path + linkLocation of def file used on Windows with MSVC.Location of def file used on Windows with MSVC. +
linker_param_filelinker_param_file + link - Location of linker param file created by bazel to + Location of linker param file created by bazel to overcome command line length limit.
output_execpathoutput_execpath + linkExecpath of the output of the linker.Execpath of the output of the linker. +
generate_interface_librarygenerate_interface_library + link - "yes" or "no" depending on whether interface library should + "yes" or "no" depending on whether interface library should be generated.
interface_library_builder_pathinterface_library_builder_path + linkPath to the interface library builder tool.Path to the interface library builder tool. +
interface_library_input_pathinterface_library_input_path + linkInput for the interface library ifso builder tool.Input for the interface library ifso builder tool. +
interface_library_output_pathinterface_library_output_path + linkPath where to generate interface library using the ifso builder tool.Path where to generate interface library using the ifso builder tool. +
legacy_link_flagslegacy_link_flags + linkLinker flags coming from the legacy CROSSTOOL fields.Linker flags coming from the legacy CROSSTOOL fields. +
user_link_flagsuser_link_flags + link - Linker flags coming from the --linkopt + Linker flags coming from the --linkopt or linkopts attribute.
linkstamp_pathslinkstamp_paths + linkA build variable giving linkstamp paths.A build variable giving linkstamp paths. +
force_picforce_pic + link - Presence of this variable indicates that PIC/PIE code should + Presence of this variable indicates that PIC/PIE code should be generated (Bazel option `--force_pic` was passed).
strip_debug_symbolsstrip_debug_symbols + link - Presence of this variable indicates that the debug + Presence of this variable indicates that the debug symbols should be stripped.
is_cc_testlink - Truthy when current action is a cc_test + is_cc_test + linkTruthy when current action is a cc_test linking action, false otherwise.
is_using_fissionis_using_fission + compile, link - Presence of this variable indicates that fission (per-object debug info) - is activated. Debug info will be in .dwo files instead + Presence of this variable indicates that fission (per-object debug info) + is activated. Debug info will be in .dwo files instead of .o files and the compiler and linker need to know this.
fdo_instrument_pathfdo_instrument_path + compile, linkPath to the directory that stores FDO instrumentation profile. Path to the directory that stores FDO instrumentation profile. +
fdo_profile_pathfdo_profile_path + compilePath to FDO profile. Path to FDO profile. +
fdo_prefetch_hints_pathfdo_prefetch_hints_path + compilePath to the cache prefetch profile. Path to the cache prefetch profile. +
cs_fdo_instrument_pathcs_fdo_instrument_path + compile, link - Path to the directory that stores context sensitive FDO - instrumentation profile. + Path to the directory that stores context sensitive FDO + instrumentation profile.
-### Well-known features {#wellknown-features} +### Well-known features The following is a reference of features and their activation conditions. - - + + - - + + - - + + - - + + - - + - - + - - + - - + - - + - - + - + - + - +
FeatureDocumentationFeature + Documentation +
opt | dbg | fastbuildEnabled by default based on compilation mode.opt | dbg | fastbuild + Enabled by default based on compilation mode. +
static_linking_mode | dynamic_linking_modeEnabled by default based on linking mode.static_linking_mode | dynamic_linking_mode + Enabled by default based on linking mode. +
per_object_debug_info - Enabled if the supports_fission feature is specified and + per_object_debug_info + Enabled if the supports_fission feature is specified and enabled and the current compilation mode is specified in the --fission flag.
supports_start_end_lib - If enabled (and the option --start_end_lib is set), Bazel + supports_start_end_lib + If enabled (and the option --start_end_lib is set), Bazel will not link against static libraries but instead use the --start-lib/--end-lib linker options to link against objects directly. This speeds up the build since Bazel doesn't have to build @@ -961,25 +1033,25 @@ conditions.
supports_interface_shared_libraries - If enabled (and the option --interface_shared_objects is + supports_interface_shared_libraries + If enabled (and the option --interface_shared_objects is set), Bazel will link targets that have linkstatic set to False (cc_tests by default) against interface shared libraries. This makes incremental relinking faster.
supports_dynamic_linker - If enabled, C++ rules will know the toolchain can produce shared + supports_dynamic_linker + If enabled, C++ rules will know the toolchain can produce shared libraries.
static_link_cpp_runtimes - If enabled, Bazel will link the C++ runtime statically in static linking + static_link_cpp_runtimes + If enabled, Bazel will link the C++ runtime statically in static linking mode and dynamically in dynamic linking mode. Artifacts specified in the cc_toolchain.static_runtime_lib or cc_toolchain.dynamic_runtime_lib attribute (depending on the @@ -987,21 +1059,24 @@ conditions.
supports_pic - If enabled, toolchain will know to use PIC objects for dynamic libraries. + supports_pic + If enabled, toolchain will know to use PIC objects for dynamic libraries. The `pic` variable is present whenever PIC compilation is needed. If not enabled by default, and `--force_pic` is passed, Bazel will request `supports_pic` and validate that the feature is enabled. If the feature is missing, or couldn't - be enabled, `--force_pic` cannot be used. + be enabled, `--force_pic` cannot be used.
static_linking_mode | dynamic_linking_mode + static_linking_mode | dynamic_linking_mode + Enabled by default based on linking mode.
no_legacy_featuresno_legacy_features + Prevents Bazel from adding legacy features to the C++ configuration when present. See the complete list of @@ -1009,14 +1084,15 @@ conditions.
shorten_virtual_includesshorten_virtual_includes + If enabled, virtual include header files are linked under bin/_virtual_includes/<hash of target path> instead of bin/<target package path>/_virtual_includes/<target name>. Useful on Windows to avoid long path issue with MSVC.
-#### Legacy features patching logic {#legacy-features-patching-logic} +#### Legacy features patching logic

Bazel applies the following changes to the toolchain's features for backwards diff --git a/docs/configurable-attributes.mdx b/docs/configurable-attributes.mdx index 8048f3a6..367317fb 100644 --- a/docs/configurable-attributes.mdx +++ b/docs/configurable-attributes.mdx @@ -4,14 +4,15 @@ title: 'Configurable Build Attributes' -**_Configurable attributes_**, commonly known as [`select()`](/reference/be/functions#select), is a Bazel feature that lets users toggle the values +**_Configurable attributes_**, commonly known as [`select()`]( +/reference/be/functions#select), is a Bazel feature that lets users toggle the values of build rule attributes at the command line. This can be used, for example, for a multiplatform library that automatically chooses the appropriate implementation for the architecture, or for a feature-configurable binary that can be customized at build time. -## Example {#configurable-build-example} +## Example ```python # myapp/BUILD @@ -87,7 +88,7 @@ are *non-configurable*, and these are clearly annotated. For example, `config_setting`'s own [`values`](/reference/be/general#config_setting.values) attribute is non-configurable. -## `select()` and dependencies {#select-and-dependencies} +## `select()` and dependencies Certain attributes change the build parameters for all transitive dependencies under a target. For example, `genrule`'s `tools` changes `--cpu` to the CPU of @@ -143,7 +144,7 @@ build parameters, which include `--cpu=arm`. The `tools` attribute changes `--cpu` to `x86` for `tool1` and its transitive dependencies. The `select` on `tool1` uses `tool1`'s build parameters, which include `--cpu=x86`. -## Configuration conditions {#configuration-conditions} +## Configuration conditions Each key in a configurable attribute is a label reference to a [`config_setting`](/reference/be/general#config_setting) or @@ -155,7 +156,7 @@ easy to maintain "standard" conditions users can reference from multiple places. `constraint_value` provides support for [multi-platform behavior](#platforms). -### Built-in flags {#built-in-flags} +### Built-in flags Flags like `--cpu` are built into Bazel: the build tool natively understands them for all builds in all projects. These are specified with @@ -189,7 +190,7 @@ it only affects how Bazel reports progress to the user. Targets can't use that flag to construct their results. The exact set of supported flags isn't documented. In practice, most flags that "make sense" work. -### Custom flags {#custom-flags} +### Custom flags You can model your own project-specific flags with [Starlark build settings][BuildSettings]. Unlike built-in flags, these are @@ -225,7 +226,7 @@ compatibility. Prefer Starlark build settings whenever possible. `values`, `flag_values`, and `define_values` evaluate independently. The `config_setting` matches if all values across all of them match. -## The default condition {#default-condition} +## The default condition The built-in condition `//conditions:default` matches when no other condition matches. @@ -261,7 +262,7 @@ Conditions checked: For even clearer errors, you can set custom messages with `select()`'s [`no_match_error`](#custom-error-messages) attribute. -## Platforms {#platforms} +## Platforms While the ability to specify multiple flags on the command line provides flexibility, it can also be burdensome to individually set each one every time @@ -363,7 +364,7 @@ check against single values. Platforms are still under development. See the [documentation](/concepts/platforms) for details. -## Combining `select()`s {#combining-selects} +## Combining `select()`s `select` can appear multiple times in the same attribute: @@ -409,9 +410,10 @@ sh_library( ) ``` -If you need a `select` to match when multiple conditions match, consider [AND chaining](#and-chaining). +If you need a `select` to match when multiple conditions match, consider [AND +chaining](#and-chaining). -## OR chaining {#or-chaining} +## OR chaining Consider the following: @@ -454,7 +456,7 @@ duplication. For more direct support, use one of the following: -### `selects.with_or` {#selects-with-or} +### `selects.with_or` The [with_or](https://github.com/bazelbuild/bazel-skylib/blob/main/docs/selects_doc.md#selectswith_or) @@ -477,7 +479,7 @@ sh_binary( ) ``` -### `selects.config_setting_group` {#selects-config-setting-or-group} +### `selects.config_setting_group` The @@ -520,7 +522,7 @@ different attributes. It's an error for multiple conditions to match unless one is an unambiguous "specialization" of the others or they all resolve to the same value. See [here](#configurable-build-example) for details. -## AND chaining {#and-chaining} +## AND chaining If you need a `select` branch to match when multiple conditions match, use the [Skylib](https://github.com/bazelbuild/bazel-skylib) macro @@ -552,7 +554,7 @@ sh_binary( Unlike OR chaining, existing `config_setting`s can't be directly `AND`ed inside a `select`. You have to explicitly wrap them in a `config_setting_group`. -## Custom error messages {#custom-error-messages} +## Custom error messages By default, when no condition matches, the target the `select()` is attached to fails with the error: @@ -587,7 +589,7 @@ ERROR: Configurable attribute "deps" doesn't match this configuration: Please build with an Android or Windows toolchain ``` -## Rules compatibility {#rules-compatibility} +## Rules compatibility Rule implementations receive the *resolved values* of configurable attributes. For example, given: @@ -635,7 +637,7 @@ Second, macros that just need to iterate over *all* `select` paths, while technically feasible, lack a coherent UI. Further design is necessary to change this. -## Bazel query and cquery {#query-and-cquery} +## Bazel query and cquery Bazel [`query`](/query/guide) operates over Bazel's [loading phase](/reference/glossary#loading-phase). @@ -696,9 +698,9 @@ $ bazel cquery 'deps(//myapp:my_lib)' --//myapp:dog_type=pug //myapp:bar_dep ``` -## FAQ {#faq} +## FAQ -### Why doesn't select() work in macros? {#faq-select-macro} +### Why doesn't select() work in macros? select() *does* work in rules! See [Rules compatibility](#rules-compatibility) for details. @@ -810,7 +812,7 @@ DEBUG: /myworkspace/myapp/defs.bzl:23:3: Invoking macro sad_macro_less_sad. DEBUG: /myworkspace/myapp/defs.bzl:15:3: My name is sad_macro_less_sad with custom message: FIRST STRING. ``` -### Why does select() always return true? {#faq-boolean-select} +### Why does select() always return true? Because *macros* (but not rules) by definition [can't evaluate `select()`s](#faq-select-macro), any attempt to do so @@ -856,7 +858,7 @@ So what they're really evaluting is the `select()` object itself. According to standards, all objects aside from a very small number of exceptions automatically return true. -### Can I read select() like a dict? {#faq-inspectable-select} +### Can I read select() like a dict? Macros [can't](#faq-select-macro) evaluate select(s) because macros evaluate before Bazel knows what the build's command line parameters are. Can they at least read @@ -912,7 +914,7 @@ def selecty_genrule(name, select_cmd): ) ``` -### Why doesn't select() work with bind()? {#faq-select-bind} +### Why doesn't select() work with bind()? First of all, do not use `bind()`. It is deprecated in favor of `alias()`. @@ -961,7 +963,7 @@ located at `@alternative//:ssl`. But really, stop using `bind()`. -### Why doesn't my select() choose what I expect? {#faq-select-choose-condition} +### Why doesn't my select() choose what I expect? If `//myapp:foo` has a `select()` that doesn't choose the condition you expect, use [cquery](/query/cquery) and `bazel config` to debug: @@ -1012,7 +1014,7 @@ Caution: To prevent restarting the Bazel server, invoke `bazel config` with the same command line flags as the `bazel cquery`. The `config` command relies on the configuration nodes from the still-running server of the previous command. -### Why doesn't `select()` work with platforms? {#faq-select-platforms} +### Why doesn't `select()` work with platforms? Bazel doesn't support configurable attributes checking whether a given platform is the target platform because the semantics are unclear. diff --git a/docs/mobile-install.mdx b/docs/mobile-install.mdx index 5039aa75..8bc4a679 100644 --- a/docs/mobile-install.mdx +++ b/docs/mobile-install.mdx @@ -11,7 +11,7 @@ This page describes how `bazel mobile-install` makes iterative development for Android much faster. It describes the benefits of this approach versus the drawbacks of separate build and install steps. -## Summary {#summary} +## Summary To install small changes to an Android app very quickly, do the following: @@ -36,7 +36,7 @@ When in doubt, look at the contact us on [Google Groups](https://groups.google.com/forum/#!forum/bazel-discuss), or [file a GitHub issue](https://github.com/bazelbuild/rules_android/issues) -## Introduction {#introduction} +## Introduction One of the most important attributes of a developer's toolchain is speed: there is a world of difference between changing the code and seeing it run within a @@ -52,7 +52,7 @@ change was not unusual on larger projects like Google Maps. using a combination of change pruning, work sharding, and clever manipulation of Android internals, all without changing any of your app's code. -## Problems with traditional app installation {#problems-app-install} +## Problems with traditional app installation Building an Android app has some issues, including: @@ -73,7 +73,7 @@ time. This is a good tradeoff for users because they typically install an app once and use it many times, but results in slower development where an app is installed many times and each version is run at most a handful of times. -## The approach of `bazel mobile-install` {#approach-mobile-install} +## The approach of `bazel mobile-install` `bazel mobile-install `makes the following improvements: @@ -94,7 +94,7 @@ installed many times and each version is run at most a handful of times. tool to combine sharded APKs on the connected device and provide a cohesive experience. -### Sharded Dexing {#sharded-dexing} +### Sharded Dexing Sharded dexing is reasonably straightforward: once the .jar files are built, a [tool](https://github.com/bazelbuild/rules_android/blob/main/src/tools/java/com/google/devtools/build/android/ziputils/DexMapper.java) @@ -122,7 +122,7 @@ app. Generally speaking, the more shards, the faster the build and the installation will be, but the slower app startup becomes, because the dynamic linker has to do more work. The sweet spot is usually between 10 and 50 shards. -### Incremental deployment {#incremental-deployment} +### Incremental deployment Incremental APK shard transfer and installation is now handled by the `apkdeployer` utility described in ["The approach of mobile-install"](#approach-mobile-install). @@ -145,9 +145,9 @@ See the [`ApkPreInstaller`](https://cs.android.com/android-studio/platform/tools and [`ApkInstaller`](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:deploy/deployer/src/main/java/com/android/tools/deployer/ApkInstaller.java) classes for implementation details. -## Results {#results} +## Results -### Performance {#performance} +### Performance In general, `bazel mobile-install` results in a 4x to 10x speedup of building and installing large apps after a small change. @@ -159,7 +159,7 @@ The following numbers were computed for a few Google products: This, of course, depends on the nature of the change: recompilation after changing a base library takes more time. -### Limitations {#limitations} +### Limitations The tricks the stub application plays don't work in every case. The following cases highlight where it does not work as expected: @@ -180,7 +180,7 @@ The following cases highlight where it does not work as expected: flags inform Bazel where the Starlark mobile-install aspect is and which rules are supported. -### A brief history of mobile-install {#mobile-install-history} +### A brief history of mobile-install Earlier Bazel versions _natively_ included built-in build and test rules for popular languages and ecosystems such as C++, Java, and Android. These rules were therefore referred to as _native_ rules. Bazel 8 (released in 2024) removed diff --git a/docs/sandboxing.mdx b/docs/sandboxing.mdx index aaadcd79..68697953 100644 --- a/docs/sandboxing.mdx +++ b/docs/sandboxing.mdx @@ -28,7 +28,7 @@ generated outputs. Bazel then uses an operating-system-provided technique, containers on Linux and `sandbox-exec` on macOS, to constrain the action within `execroot/`. -## Reasons for sandboxing {#sandboxing-reasons} +## Reasons for sandboxing - Without action sandboxing, Bazel doesn't know if a tool uses undeclared input files (files that are not explicitly listed in the dependencies of an @@ -47,10 +47,10 @@ containers on Linux and `sandbox-exec` on macOS, to constrain the action within having to install the tools on every machine in the cluster every time you want to try out a new compiler or make a change to an existing tool. -## What sandbox strategy to use {#sandboxing-strategies} +## What sandbox strategy to use You can choose which kind of sandboxing to use, if any, with the -[strategy flags](/docs/user-manual#strategy-options). Using the `sandboxed` +[strategy flags](user-manual.html#strategy-options). Using the `sandboxed` strategy makes Bazel pick one of the sandbox implementations listed below, preferring an OS-specific sandbox to the less hermetic generic one. [Persistent workers](/remote/persistent) run in a generic sandbox if you pass @@ -100,7 +100,7 @@ Dynamic execution usually requires sandboxing for local execution. To opt out, pass the `--experimental_local_lockfree_output` flag. Dynamic execution silently sandboxes [persistent workers](/remote/persistent). -## Downsides to sandboxing {#sandboxing_downsides} +## Downsides to sandboxing - Sandboxing incurs extra setup and teardown cost. How big this cost is depends on many factors, including the shape of the build and the @@ -116,11 +116,11 @@ sandboxes [persistent workers](/remote/persistent). to be sandboxed. Workers that do not support multiplex sandboxing run as singleplex workers under dynamic execution, which can cost extra memory. -## Debugging {#debugging} +## Debugging Follow the strategies below to debug issues with sandboxing. -### Deactivated namespaces {#deactivated-namespaces} +### Deactivated namespaces On some platforms, such as [Google Kubernetes Engine](https://cloud.google.com/kubernetes-engine/) @@ -132,14 +132,14 @@ exists and contains a 0, you can activate user namespaces by running: sudo sysctl kernel.unprivileged_userns_clone=1 ``` -### Rule execution failures {#rule-failures} +### Rule execution failures The sandbox may fail to execute rules because of the system setup. If you see a message like `namespace-sandbox.c:633: execvp(argv[0], argv): No such file or directory`, try to deactivate the sandbox with `--strategy=Genrule=local` for genrules, and `--spawn_strategy=local` for other rules. -### Detailed debugging for build failures {#debugging-build-failures} +### Detailed debugging for build failures If your build failed, use `--verbose_failures` and `--sandbox_debug` to make Bazel show the exact command it ran when your build failed, including the part diff --git a/docs/user-manual.mdx b/docs/user-manual.mdx index e901366a..94c6d99a 100644 --- a/docs/user-manual.mdx +++ b/docs/user-manual.mdx @@ -6,13 +6,13 @@ This page covers the options that are available with various Bazel commands, such as `bazel build`, `bazel run`, and `bazel test`. This page is a companion to the list of Bazel's commands in [Build with Bazel](/run/build). -## Target syntax {#target-syntax} +## Target syntax Some commands, like `build` or `test`, can operate on a list of targets. They use a syntax more flexible than labels, which is documented in [Specifying targets to build](/run/build#specifying-build-targets). -## Options {#build-options} +## Options The following sections describe the options available during a build. When `--long` is used on a help command, the on-line @@ -23,9 +23,9 @@ Most options can only be specified once. When specified multiple times, the last instance wins. Options that can be specified multiple times are identified in the on-line help with the text 'may be used multiple times'. -### Package location {#package-location} +### Package location -#### `--package_path` {#package-path} +#### `--package_path` **WARNING:** The `--package_path` option is deprecated. Bazel prefers packages in the main repository to be under the workspace root. @@ -78,7 +78,7 @@ Example: Building from an empty client % bazel build --package_path /some/other/path //foo -#### `--deleted_packages` {#flag--deleted_packages} +#### `--deleted_packages` This option specifies a comma-separated list of packages which Bazel should consider deleted, and not attempt to load from any directory @@ -86,17 +86,17 @@ on the package path. This can be used to simulate the deletion of packages witho actually deleting them. This option can be passed multiple times, in which case the individual lists are concatenated. -### Error checking {#error-checking} +### Error checking These options control Bazel's error-checking and/or warnings. -#### `--[no]check_visibility` {#check-visibility} +#### `--[no]check_visibility` If this option is set to false, visibility checks are demoted to warnings. The default value of this option is true, so that by default, visibility checking is done. -#### `--output_filter=regex` {#output-filter} +#### `--output_filter=regex` The `--output_filter` option will only show build and compilation warnings for targets that match the regular expression. If a target does not @@ -116,19 +116,21 @@ Here are some typical values for this option: `--output_filter=` - Show everything. + Show everything. + `--output_filter=DONT_MATCH_ANYTHING` - Show nothing. + Show nothing. + -### Tool flags {#tool-flags} +### Tool flags These options control which options Bazel will pass to other tools. -#### `--copt=cc-option` {#copt} +#### `--copt=cc-option` This option takes an argument which is to be passed to the compiler. The argument will be passed to the compiler whenever it is invoked @@ -157,35 +159,35 @@ Similarly, compiler options that only have an effect at link time (such as `-l`) should be specified in `--linkopt`, not in `--copt`. -#### `--host_copt=cc-option` {#host-copt} +#### `--host_copt=cc-option` This option takes an argument which is to be passed to the compiler for source files that are compiled in the exec configuration. This is analogous to the [`--copt`](#copt) option, but applies only to the exec configuration. -#### `--host_conlyopt=cc-option` {#host-conlyopt} +#### `--host_conlyopt=cc-option` This option takes an argument which is to be passed to the compiler for C source files that are compiled in the exec configuration. This is analogous to the [`--conlyopt`](#cconlyopt) option, but applies only to the exec configuration. -#### `--host_cxxopt=cc-option` {#host-cxxopt} +#### `--host_cxxopt=cc-option` This option takes an argument which is to be passed to the compiler for C++ source files that are compiled in the exec configuration. This is analogous to the [`--cxxopt`](#cxxopt) option, but applies only to the exec configuration. -#### `--host_linkopt=linker-option` {#host-linkopt} +#### `--host_linkopt=linker-option` This option takes an argument which is to be passed to the linker for source files that are compiled in the exec configuration. This is analogous to the [`--linkopt`](#linkopt) option, but applies only to the exec configuration. -#### `--conlyopt=cc-option` {#cconlyopt} +#### `--conlyopt=cc-option` This option takes an argument which is to be passed to the compiler when compiling C source files. @@ -196,7 +198,7 @@ not to C++ compilation or linking. So you can pass C-specific options Note: copts parameters listed in specific cc_library or cc_binary build rules are placed on the compiler command line _after_ these options. -#### `--cxxopt=cc-option` {#cxxopt} +#### `--cxxopt=cc-option` This option takes an argument which is to be passed to the compiler when compiling C++ source files. @@ -214,7 +216,7 @@ For example: Note: copts parameters listed in specific cc_library or cc_binary build rules are placed on the compiler command line _after_ these options. -#### `--linkopt=linker-option` {#linkopt} +#### `--linkopt=linker-option` This option takes an argument which is to be passed to the compiler when linking. @@ -231,7 +233,7 @@ Build rules can also specify link options in their attributes. This option's settings always take precedence. Also see [cc_library.linkopts](/reference/be/c-cpp#cc_library.linkopts). -#### `--strip (always|never|sometimes)` {#strip} +#### `--strip (always|never|sometimes)` This option determines whether Bazel will strip debugging information from all binaries and shared libraries, by invoking the linker with the `-Wl,--strip-debug` option. @@ -264,7 +266,7 @@ pass `--stripopt=--strip-all` and explicitly build the `--stripopt`, this applies a strip action after the final binary is linked rather than including stripping in all of the build's link actions. -#### `--stripopt=strip-option` {#stripopt} +#### `--stripopt=strip-option` This is an additional option to pass to the `strip` command when generating a [`*.stripped` binary](/reference/be/c-cpp#cc_binary_implicit_outputs). The default @@ -273,7 +275,7 @@ is `-S -p`. This option can be used multiple times. Note: `--stripopt` does not apply to the stripping of the main binary with `[--strip](#flag--strip)=(always|sometimes)`. -#### `--fdo_instrument=profile-output-dir` {#fdo-instrument} +#### `--fdo_instrument=profile-output-dir` The `--fdo_instrument` option enables the generation of FDO (feedback directed optimization) profile output when the @@ -292,7 +294,7 @@ data file(s) is dumped. For example: The options `--fdo_instrument` and `--fdo_optimize` cannot be used at the same time. -#### `--fdo_optimize=profile-zip` {#fdo-optimize} +#### `--fdo_optimize=profile-zip` The `--fdo_optimize` option enables the use of the per-object file profile information to perform FDO (feedback @@ -313,7 +315,7 @@ extension. The options `--fdo_instrument` and `--fdo_optimize` cannot be used at the same time. -#### `--java_language_version=version` {#java-language-version} +#### `--java_language_version=version` This option specifies the version of Java sources. For example: @@ -326,12 +328,12 @@ Default value is 11. Possible values are: 8, 9, 10, 11, 17, and 21 and may be extended by registering custom Java toolchains using `default_java_toolchain`. -#### `--tool_java_language_version=version` {#tool-java-language-version} +#### `--tool_java_language_version=version` The Java language version used to build tools that are executed during a build. Default value is 11. -#### `--java_runtime_version=version` {#java-runtime-version} +#### `--java_runtime_version=version` This option specifies the version of JVM to use to execute the code and run the tests. For example: @@ -348,12 +350,12 @@ Possible values are: `local_jdk`, `local_jdk_version`, You can extend the values by registering custom JVM using either `local_java_repository` or `remote_java_repository` repository rules. -#### `--tool_java_runtime_version=version` {#tool-java-runtime-version} +#### `--tool_java_runtime_version=version` The version of JVM used to execute tools that are needed during a build. Default value is `remotejdk_11`. -#### `--jvmopt=jvm-option` {#jvmopt} +#### `--jvmopt=jvm-option` This option allows option arguments to be passed to the Java VM. It can be used with one big argument, or multiple times with individual arguments. For example: @@ -365,7 +367,7 @@ with one big argument, or multiple times with individual arguments. For example: will use the server VM for launching all Java binaries and set the startup heap size for the VM to 256 MB. -#### `--javacopt=javac-option` {#javacopt} +#### `--javacopt=javac-option` This option allows option arguments to be passed to javac. It can be used with one big argument, or multiple times with individual arguments. For example: @@ -390,7 +392,7 @@ of all affected classes. Also note that javacopts parameters listed in specific java_library or java_binary build rules will be placed on the javac command line _after_ these options. -#### `--strict_java_deps (default|strict|off|warn|error)` {#strict-java-deps} +#### `--strict_java_deps (default|strict|off|warn|error)` This option controls whether javac checks for missing direct dependencies. Java targets must explicitly declare all directly used targets as @@ -406,11 +408,11 @@ of a direct dependency of the current target. target to fail to build if any missing direct dependencies are found. This is also the default behavior when the flag is unspecified. -### Build semantics {#build-semantics} +### Build semantics These options affect the build commands and/or the output file contents. -#### `--compilation_mode (fastbuild|opt|dbg)` (-c) {#compilation-mode} +#### `--compilation_mode (fastbuild|opt|dbg)` (-c) The `--compilation_mode` option (often shortened to `-c`, especially `-c opt`) takes an argument of `fastbuild`, `dbg` @@ -431,7 +433,7 @@ needing to do a full rebuild _every_ time. Debugging information will not be generated in `opt` mode unless you also pass `--copt -g`. -#### `--cpu=cpu` {#cpu} +#### `--cpu=cpu` This option specifies the target CPU architecture to be used for the compilation of binaries during the build. @@ -440,7 +442,7 @@ Note: A particular combination of crosstool version, compiler version, and target CPU is allowed only if it has been specified in the currently used CROSSTOOL file. -#### `--action_env=VAR=VALUE` {#action-env} +#### `--action_env=VAR=VALUE` Specifies the set of environment variables available during the execution of all actions. Variables can be either specified by name, in which case the value will be taken from the @@ -450,7 +452,7 @@ invocation environment. This `--action_env` flag can be specified multiple times. If a value is assigned to the same variable across multiple `--action_env` flags, the latest assignment wins. -#### `--experimental_action_listener=label` {#experimental-action-listener} +#### `--experimental_action_listener=label` Warning: Extra actions are deprecated. Use [aspects](/extending/aspects) @@ -460,7 +462,7 @@ The `experimental_action_listener` option instructs Bazel to use details from the [`action_listener`](/reference/be/extra-actions#action_listener) rule specified by label to insert [`extra_actions`](/reference/be/extra-actions#extra_action) into the build graph. -#### `--[no]experimental_extra_action_top_level_only` {#experimental-extra-action-top-level-only} +#### `--[no]experimental_extra_action_top_level_only` Warning: Extra actions are deprecated. Use [aspects](/extending/aspects) instead. @@ -469,7 +471,7 @@ If this option is set to true, extra actions specified by the [ `--experimental_action_listener`](#experimental-action-listener) command line option will only be scheduled for top level targets. -#### `--experimental_extra_action_filter=regex` {#experimental-extra-action-filter} +#### `--experimental_extra_action_filter=regex` Warning: Extra actions are deprecated. Use [aspects](/extending/aspects) instead. @@ -489,17 +491,16 @@ regular expression. The following example will limit scheduling of `extra_actions` to only apply to actions of which the owner's label contains '/bar/': -

-% bazel build --experimental_action_listener=//test:al //foo/... \
+
% bazel build --experimental_action_listener=//test:al //foo/... \
   --experimental_extra_action_filter=.*/bar/.*
 
-#### `--host_cpu=cpu` {#host-cpu} +#### `--host_cpu=cpu` This option specifies the name of the CPU architecture that should be used to build host tools. -#### `--android_platforms=platform[,platform]*` {#android-platforms} +#### `--android_platforms=platform[,platform]*` The platforms to build the transitive `deps` of `android_binary` rules (specifically for native dependencies like C++). For @@ -516,7 +517,7 @@ with `--android_platforms`. The `.so` file's name prefixes the name of the `android_binary` rule with "lib". For example, if the name of the `android_binary` is "foo", then the file is `libfoo.so`. -#### `--per_file_copt=[+-]regex[,[+-]regex]...@option[,option]...` {#per-file-copt} +#### `--per_file_copt=[+-]regex[,[+-]regex]...@option[,option]...` When present, any C++ file with a label or an execution path matching one of the inclusion regex expressions and not matching any of the exclusion expressions will be built @@ -557,7 +558,7 @@ to the C++ compiler. If an option contains a `,` it has to be quoted like so adds the `-O0` and the `-fprofile-arcs` options to the command line of the C++ compiler for all `.cc` files in `//foo/` except `file.cc`. -#### `--dynamic_mode=mode` {#dynamic-mode} +#### `--dynamic_mode=mode` Determines whether C++ binaries will be linked dynamically, interacting with the [linkstatic attribute](/reference/be/c-cpp#cc_binary.linkstatic) on build rules. @@ -573,7 +574,7 @@ Modes: [mostly static](/reference/be/c-cpp#cc_binary.linkstatic) mode. If `-static` is set in linkopts, targets will change to fully static. -#### `--fission (yes|no|[dbg][,opt][,fastbuild])` {#fission} +#### `--fission (yes|no|[dbg][,opt][,fastbuild])` Enables [Fission](https://gcc.gnu.org/wiki/DebugFission), which writes C++ debug information to dedicated .dwo files instead of .o files, where it would @@ -586,13 +587,13 @@ settings. When set to `yes`, Fission is enabled universally. When set to `no`, Fission is disabled universally. Default is no. -#### `--force_ignore_dash_static` {#force-ignore-dash-static} +#### `--force_ignore_dash_static` If this flag is set, any `-static` options in linkopts of `cc_*` rules BUILD files are ignored. This is only intended as a workaround for C++ hardening builds. -#### `--[no]force_pic` {#force-pic} +#### `--[no]force_pic` If enabled, all C++ compilations produce position-independent code ("-fPIC"), links prefer PIC pre-built libraries over non-PIC libraries, and links produce @@ -602,38 +603,38 @@ Note: Dynamically linked binaries (for example `--dynamic_mode fully`) generate PIC code regardless of this flag's setting. So this flag is for cases where users want PIC code explicitly generated for static links. -#### `--android_resource_shrinking` {#flag--android_resource_shrinking} +#### `--android_resource_shrinking` Selects whether to perform resource shrinking for android_binary rules. Sets the default for the [shrink_resources attribute](/reference/be/android#android_binary.shrink_resources) on android_binary rules; see the documentation for that rule for further details. Defaults to off. -#### `--custom_malloc=malloc-library-target` {#custom-malloc} +#### `--custom_malloc=malloc-library-target` When specified, always use the given malloc implementation, overriding all `malloc="target"` attributes, including in those targets that use the default (by not specifying any `malloc`). -#### `--crosstool_top=label` {#crosstool-top} +#### `--crosstool_top=label` This option specifies the location of the crosstool compiler suite to be used for all C++ compilation during a build. Bazel will look in that location for a CROSSTOOL file and uses that to automatically determine settings for `--compiler`. -#### `--host_crosstool_top=label` {#host-crosstool-top} +#### `--host_crosstool_top=label` If not specified, Bazel uses the value of `--crosstool_top` to compile code in the exec configuration, such as tools run during the build. The main purpose of this flag is to enable cross-compilation. -#### `--apple_crosstool_top=label` {#apple-crosstool-top} +#### `--apple_crosstool_top=label` The crosstool to use for compiling C/C++ rules in the transitive `deps` of objc_*, ios__*, and apple_* rules. For those targets, this flag overwrites `--crosstool_top`. -#### `--compiler=version` {#compiler} +#### `--compiler=version` This option specifies the C/C++ compiler version (such as `gcc-4.1.0`) to be used for the compilation of binaries during the build. If you want to @@ -643,7 +644,7 @@ specifying this flag. Note: Only certain combinations of crosstool version, compiler version, and target CPU are allowed. -#### `--android_sdk=label` {#android-sdk} +#### `--android_sdk=label` Deprecated. This shouldn't be directly specified. @@ -654,30 +655,30 @@ rule. The Android SDK will be automatically selected if an `android_sdk_repository` rule is defined in the WORKSPACE file. -#### `--java_toolchain=label` {#java-toolchain} +#### `--java_toolchain=label` No-op. Kept only for backwards compatibility. -#### `--host_java_toolchain=label` {#host-java-toolchain} +#### `--host_java_toolchain=label` No-op. Kept only for backwards compatibility. -#### `--javabase=(label)` {#javabase} +#### `--javabase=(label)` No-op. Kept only for backwards compatibility. -#### `--host_javabase=label` {#host-javabase} +#### `--host_javabase=label` No-op. Kept only for backwards compatibility. -### Execution strategy {#execution-strategy} +### Execution strategy These options affect how Bazel will execute the build. They should not have any significant effect on the output files generated by the build. Typically their main effect is on the speed of the build. -#### `--spawn_strategy=strategy` {#spawn-strategy} +#### `--spawn_strategy=strategy` This option controls where and how commands are executed. @@ -694,7 +695,7 @@ This option controls where and how commands are executed. * `remote` causes commands to be executed remotely; this is only available if a remote executor has been configured separately. -#### `--strategy mnemonic=strategy` {#strategy} +#### `--strategy mnemonic=strategy` This option controls where and how commands are executed, overriding the [--spawn_strategy](#spawn-strategy) (and @@ -703,7 +704,7 @@ Genrule) on a per-mnemonic basis. See [--spawn_strategy](#spawn-strategy) for the supported strategies and their effects. -#### `--strategy_regexp==` {#strategy-regexp} +#### `--strategy_regexp==` This option specifies which strategy should be used to execute commands that have descriptions matching a certain `regex_filter`. See @@ -725,11 +726,11 @@ other flags for specifying strategy. 'Compiling //foo/bar/baz' with the `local` strategy and falls back to `sandboxed` if it fails. -#### `--genrule_strategy=strategy` {#genrule-strategy} +#### `--genrule_strategy=strategy` This is a deprecated short-hand for `--strategy=Genrule=strategy`. -#### `--jobs=n` (-j) {#jobs} +#### `--jobs=n` (-j) This option, which takes an integer argument, specifies a limit on the number of jobs that should be executed concurrently during the @@ -743,7 +744,7 @@ based on some (very crude) estimates of the resource consumption of each job. The behavior of the scheduler can be controlled by the `--local_resources` option. -#### `--progress_report_interval=n` {#progress-report-interval} +#### `--progress_report_interval=n` Bazel periodically prints a progress report on jobs that are not finished yet (such as long running tests). This option sets the @@ -757,7 +758,7 @@ that progress is reported once every minute. When bazel is using cursor control, as specified by [`--curses`](#curses), progress is reported every second. -#### `--local_resources resources or resource expression` {#local-resources} +#### `--local_resources resources or resource expression` These options specify the amount of local resources (RAM in MB and number of CPU logical cores) that Bazel can take into consideration when scheduling build and test activities to run locally. They take @@ -767,7 +768,7 @@ an float, or a keyword (HOST_RAM or HOST_CPUS) optionally followed by `[-|*`floa The flags are independent; one or both may be set. By default, Bazel estimates the amount of RAM and number of CPU cores directly from the local system's configuration. -#### `--[no]build_runfile_links` {#build-runfile-links} +#### `--[no]build_runfile_links` This option, which is enabled by default, specifies whether the runfiles symlinks for tests and binaries should be built in the output directory. @@ -789,7 +790,7 @@ does the cost of this operation, and for some large builds it can contribute significantly to overall build time, particularly because each individual test (or application) requires its own runfiles tree. -#### `--[no]build_runfile_manifests` {#build-runfile-manifests} +#### `--[no]build_runfile_manifests` This option, which is enabled by default, specifies whether runfiles manifests should be written to the output tree. @@ -798,7 +799,7 @@ Disabling it implies `--nobuild_runfile_links`. It can be disabled when executing tests remotely, as runfiles trees will be created remotely from in-memory manifests. -#### `--[no]discard_analysis_cache` {#discard-analysis-cache} +#### `--[no]discard_analysis_cache` When this option is enabled, Bazel will discard the analysis cache right before execution starts, thus freeing up additional memory @@ -806,7 +807,7 @@ right before execution starts, thus freeing up additional memory The drawback is that further incremental builds will be slower. See also [memory-saving mode](/configure/memory). -#### `--[no]keep_going` (-k) {#keep-going} +#### `--[no]keep_going` (-k) As in GNU Make, the execution phase of a build stops when the first error is encountered. Sometimes it is useful to try to build as @@ -823,7 +824,7 @@ unless `--keep_going` is specified, in which case the build will proceed to the execution phase, but only for the targets that were successfully analyzed. -#### `--[no]use_ijars` {#use-ijars} +#### `--[no]use_ijars` This option changes the way `java_library` targets are compiled by Bazel. Instead of using the output of a @@ -842,7 +843,7 @@ is not visible you will get an error that the member does not exist. Changing the `--use_ijars` setting will force a recompilation of all affected classes. -#### `--[no]interface_shared_objects` {#interface-shared-objects} +#### `--[no]interface_shared_objects` This option enables _interface shared objects_, which makes binaries and other shared libraries depend on the _interface_ of a shared object, @@ -850,11 +851,11 @@ rather than its implementation. When only the implementation changes, Bazel can avoid rebuilding targets that depend on the changed shared library unnecessarily. -### Output selection {#output-selection} +### Output selection These options determine what to build or test. -#### `--[no]build` {#build} +#### `--[no]build` This option causes the execution phase of the build to occur; it is on by default. When it is switched off, the execution phase is @@ -863,7 +864,7 @@ skipped, and only the first two phases, loading and analysis, occur. This option can be useful for validating BUILD files and detecting errors in the inputs, without actually building anything. -#### `--[no]build_tests_only` {#build-tests-only} +#### `--[no]build_tests_only` If specified, Bazel will build only what is necessary to run the `*_test` and `test_suite` rules that were not filtered due to their @@ -878,7 +879,7 @@ testing. This is useful because running `bazel test --build_tests_only foo/...` may not detect all build breakages in the `foo` tree. -#### `--[no]check_up_to_date` {#check-up-to-date} +#### `--[no]check_up_to_date` This option causes Bazel not to perform a build, but merely check whether all specified targets are up-to-date. If so, the build @@ -890,7 +891,7 @@ checks) without incurring the cost of a build. See also [`--check_tests_up_to_date`](#check-tests-up-to-date). -#### `--[no]compile_one_dependency` {#compile-one-dependency} +#### `--[no]compile_one_dependency` Compile a single dependency of the argument files. This is useful for syntax checking source files in IDEs, for example, by rebuilding a single @@ -905,7 +906,7 @@ multiple rules with the same preference, the one that appears first in the BUILD file is chosen. An explicitly named target pattern which does not reference a source file results in an error. -#### `--save_temps` {#save-temps} +#### `--save_temps` The `--save_temps` option causes temporary outputs from the compiler to be saved. These include .s files (assembler code), .i (preprocessed C) and .ii @@ -926,7 +927,7 @@ To ensure that Bazel prints the location of the additional output files, check t your [`--show_result n`](#show-result) setting is high enough. -#### `--build_tag_filters=tag[,tag]*` {#build-tag-filters} +#### `--build_tag_filters=tag[,tag]*` If specified, Bazel will build only targets that have at least one required tag (if any of them are specified) and does not have any excluded tags. Build tag @@ -938,7 +939,7 @@ When running tests, Bazel ignores `--build_tag_filters` for test targets, which are built and run even if they do not match this filter. To avoid building them, filter test targets using `--test_tag_filters` or by explicitly excluding them. -#### `--test_size_filters=size[,size]*` {#test-size-filters} +#### `--test_size_filters=size[,size]*` If specified, Bazel will test (or build if `--build_tests_only` is also specified) only test targets with the given size. Test size filter @@ -960,7 +961,7 @@ will test only small and medium tests inside //foo. By default, test size filtering is not applied. -#### `--test_timeout_filters=timeout[,timeout]*` {#test-timeout-filters} +#### `--test_timeout_filters=timeout[,timeout]*` If specified, Bazel will test (or build if `--build_tests_only` is also specified) only test targets with the given timeout. Test timeout filter @@ -971,7 +972,7 @@ for example syntax. By default, test timeout filtering is not applied. -#### `--test_tag_filters=tag[,tag]*` {#test-tag-filters} +#### `--test_tag_filters=tag[,tag]*` If specified, Bazel will test (or build if `--build_tests_only` is also specified) only test targets that have at least one required tag @@ -993,7 +994,7 @@ By default, test tag filtering is not applied. Note that you can also filter on test's `size` and `local` tags in this manner. -#### `--test_lang_filters=string[,string]*` {#test-lang-filters} +#### `--test_lang_filters=string[,string]*` Specifies a comma-separated list of strings referring to names of test rule classes. To refer to the rule class `foo_test`, use the string "foo". Bazel will @@ -1001,7 +1002,7 @@ test (or build if `--build_tests_only` is also specified) only targets of the referenced rule classes. To instead exclude those targets, use the string "-foo". For example, -

+

   % bazel test --test_lang_filters=foo,bar //baz/...
 
@@ -1027,7 +1028,7 @@ Warning: The option name "--test_lang_filter" is vestigal and is therefore unfortunately misleading; don't make assumptions about the semantics based on the name. -#### `--test_filter=filter-expression` {#test-filter} +#### `--test_filter=filter-expression` Specifies a filter that the test runner may use to pick a subset of tests for running. All targets specified in the invocation are built, but depending on @@ -1040,12 +1041,12 @@ substring, or regexp. `--test_filter` is a convenience over passing different `--test_arg` filter arguments, but not all frameworks support it. -### Verbosity {#verbosity} +### Verbosity These options control the verbosity of Bazel's output, either to the terminal, or to additional log files. -#### `--explain=logfile` {#explain} +#### `--explain=logfile` This option, which requires a filename argument, causes the dependency checker in `bazel build`'s execution phase to @@ -1060,7 +1061,7 @@ when you see an execution step executed unexpectedly. This option may carry a small performance penalty, so you might want to remove it when it is no longer needed. -#### `--verbose_explanations` {#verbose-explanations} +#### `--verbose_explanations` This option increases the verbosity of the explanations generated when the [--explain](#explain) option is enabled. @@ -1078,31 +1079,31 @@ generated explanation file and the performance penalty of using If `--explain` is not enabled, then `--verbose_explanations` has no effect. -#### `--profile=file` {#profile} +#### `--profile=file` This option, which takes a filename argument, causes Bazel to write profiling data into a file. The data then can be analyzed or parsed using the `bazel analyze-profile` command. The Build profile can be useful in understanding where Bazel's `build` command is spending its time. -#### `--[no]show_loading_progress` {#show-loading-progress} +#### `--[no]show_loading_progress` This option causes Bazel to output package-loading progress messages. If it is disabled, the messages won't be shown. -#### `--[no]show_progress` {#show-progress} +#### `--[no]show_progress` This option causes progress messages to be displayed; it is on by default. When disabled, progress messages are suppressed. -#### `--show_progress_rate_limit=n` {#show-progress-rate} +#### `--show_progress_rate_limit=n` This option causes bazel to display at most one progress message per `n` seconds, where n is a real number. The default value for this option is 0.02, meaning bazel will limit the progress messages to one per every 0.02 seconds. -#### `--show_result=n` {#show-result} +#### `--show_result=n` This option controls the printing of result information at the end of a `bazel build` command. By default, if a single @@ -1136,23 +1137,23 @@ filename to the shell, to run built executables. The "up-to-date" or "failed" messages for each target can be easily parsed by scripts which drive a build. -#### `--sandbox_debug` {#sandbox-debug} +#### `--sandbox_debug` This option causes Bazel to print extra debugging information when using sandboxing for action execution. This option also preserves sandbox directories, so that the files visible to actions during execution can be examined. -#### `--subcommands` (`-s`) {#subcommands} +#### `--subcommands` (`-s`) This option causes Bazel's execution phase to print the full command line for each command prior to executing it. -``` - >>>> # //examples/cpp:hello-world [action 'Linking examples/cpp/hello-world'] +
+  >>>>> # //examples/cpp:hello-world [action 'Linking examples/cpp/hello-world']
   (cd /home/johndoe/.cache/bazel/_bazel_johndoe/4c084335afceb392cfbe7c31afee3a9f/bazel && \
     exec env - \
     /usr/bin/gcc -o bazel-out/local-fastbuild/bin/examples/cpp/hello-world -B/usr/bin/ -Wl,-z,relro,-z,now -no-canonical-prefixes -pass-exit-codes -Wl,-S -Wl,@bazel-out/local_linux-fastbuild/bin/examples/cpp/hello-world-2.params)
-```
+
Where possible, commands are printed in a Bourne shell compatible syntax, so that they can be easily copied and pasted to a shell command prompt. @@ -1172,7 +1173,7 @@ For logging subcommands to a file in a tool-friendly format, see and [--execution_log_binary_file](/reference/command-line-reference#flag--execution_log_binary_file). -#### `--verbose_failures` {#verbose-failures} +#### `--verbose_failures` This option causes Bazel's execution phase to print the full command line for commands that failed. This can be invaluable for debugging a @@ -1181,14 +1182,14 @@ failing build. Failing commands are printed in a Bourne shell compatible syntax, suitable for copying and pasting to a shell prompt. -### Workspace status {#workspace-status} +### Workspace status Use these options to "stamp" Bazel-built binaries: to embed additional information into the binaries, such as the source control revision or other workspace-related information. You can use this mechanism with rules that support the `stamp` attribute, such as `genrule`, `cc_binary`, and more. -#### `--workspace_status_command=program` {#workspace-status-command} +#### `--workspace_status_command=program` This flag lets you specify a binary that Bazel runs before each build. The program can report information about the status of the workspace, such as the current source control revision. @@ -1261,7 +1262,7 @@ echo "STABLE_USER_NAME $USER" Pass this program's path with `--workspace_status_command`, and the stable status file will include the STABLE lines and the volatile status file will include the rest of the lines. -#### `--[no]stamp` {#stamp} +#### `--[no]stamp` This option, in conjunction with the `stamp` rule attribute, controls whether to embed build information in binaries. @@ -1280,23 +1281,23 @@ their dependencies have not changed. Setting `--nostamp` is generally desireable for build performance, as it reduces input volatility and maximizes build caching. -### Platform {#platform} +### Platform Use these options to control the host and target platforms that configure how builds work, and to control what execution platforms and toolchains are available to Bazel rules. Please see background information on [Platforms](/extending/platforms) and [Toolchains](/extending/toolchains). -#### `--platforms=labels` {#platforms} +#### `--platforms=labels` The labels of the platform rules describing the target platforms for the current command. -#### `--host_platform=label` {#host-platform} +#### `--host_platform=label` The label of a platform rule that describes the host system. -#### `--extra_execution_platforms=labels` {#extra-execution-platforms} +#### `--extra_execution_platforms=labels` The platforms that are available as execution platforms to run actions. Platforms can be specified by exact target, or as a target pattern. These @@ -1305,29 +1306,29 @@ platforms will be considered before those declared in MODULE.bazel files by This option accepts a comma-separated list of platforms in order of priority. If the flag is passed multiple times, the most recent overrides. -#### `--extra_toolchains=labels` {#extra-toolchains} +#### `--extra_toolchains=labels` The toolchain rules to be considered during toolchain resolution. Toolchains can be specified by exact target, or as a target pattern. These toolchains will be considered before those declared in MODULE.bazel files by [register_toolchains()](/rules/lib/globals/module#register_toolchains). -#### `--toolchain_resolution_debug=regex` {#toolchain-resolution-debug} +#### `--toolchain_resolution_debug=regex` Print debug information while finding toolchains if the toolchain type matches the regex. Multiple regexes can be separated by commas. The regex can be negated by using a `-` at the beginning. This might help developers of Bazel or Starlark rules with debugging failures due to missing toolchains. -### Miscellaneous {#miscellaneous} +### Miscellaneous -#### `--flag_alias=alias_name=target_path` {#flag-alias} +#### `--flag_alias=alias_name=target_path` A convenience flag used to bind longer Starlark build settings to a shorter name. For more details, see the [Starlark Configurations](/extending/config#using-build-setting-aliases). -#### `--symlink_prefix=string` {#symlink-prefix} +#### `--symlink_prefix=string` Changes the prefix of the generated convenience symlinks. The default value for the symlink prefix is `bazel-` which @@ -1355,7 +1356,7 @@ Some common values of this option: `--symlink_prefix=.bazel/` will cause Bazel to create symlinks called `bin` (etc) inside a hidden directory `.bazel`. -#### `--platform_suffix=string` {#platform-suffix} +#### `--platform_suffix=string` Adds a suffix to the configuration short name, which is used to determine the output directory. Setting this option to different values puts the files into @@ -1363,12 +1364,12 @@ different directories, for example to improve cache hit rates for builds that otherwise clobber each others output files, or to keep the output files around for comparisons. -#### `--default_visibility=(private|public)` {#default-visibility} +#### `--default_visibility=(private|public)` Temporary flag for testing bazel default visibility changes. Not intended for general use but documented for completeness' sake. -#### `--starlark_cpu_profile=_file_` {#starlark-cpu-profile} +#### `--starlark_cpu_profile=_file_` This flag, whose value is the name of a file, causes Bazel to gather statistics about CPU usage by all Starlark threads, @@ -1399,14 +1400,14 @@ Showing nodes accounting for 3.34s, 100% of 3.34s total For different views of the same data, try the `pprof` commands `svg`, `web`, and `list`. -## Using Bazel for releases {#bazel-for-releases} +## Using Bazel for releases Bazel is used both by software engineers during the development cycle, and by release engineers when preparing binaries for deployment to production. This section provides a list of tips for release engineers using Bazel. -### Significant options {#significant-options} +### Significant options When using Bazel for release builds, the same issues arise as for other scripts that perform a build. For more details, see @@ -1425,7 +1426,7 @@ These options are also important: with a distinct identifier, such as "64bit" vs. "32bit". This option differentiates the `bazel-bin` (etc.) symlinks. -## Running tests {#running-tests} +## Running tests To build and run tests with bazel, type `bazel test` followed by the name of the test targets. @@ -1438,9 +1439,9 @@ their prerequisites are built, meaning that test execution is interleaved with building. Doing so usually results in significant speed gains. -### Options for `bazel test` {#bazel-test-options} +### Options for `bazel test` -#### `--cache_test_results=(yes|no|auto)` (`-t`) {#cache-test-results} +#### `--cache_test_results=(yes|no|auto)` (`-t`) If this option is set to 'auto' (the default) then Bazel will only rerun a test if any of the following conditions applies: @@ -1468,7 +1469,7 @@ their `.bazelrc` file may find the abbreviations `-t` (on) or `-t-` (off) convenient for overriding the default on a particular run. -#### `--check_tests_up_to_date` {#check-tests-up-to-date} +#### `--check_tests_up_to_date` This option tells Bazel not to run the tests, but to merely check and report the cached test results. If there are any tests which have not been @@ -1483,7 +1484,7 @@ This option also implies This option may be useful for pre-submit checks. -#### `--test_verbose_timeout_warnings` {#test-verbose-timeout-warnings} +#### `--test_verbose_timeout_warnings` This option tells Bazel to explicitly warn the user if a test's timeout is significantly longer than the test's actual execution time. While a test's @@ -1500,14 +1501,14 @@ Note: Each test shard is allotted the timeout of the entire `XX_test` target. Using this option does not affect a test's timeout value, merely warns if Bazel thinks the timeout could be restricted further. -#### `--[no]test_keep_going` {#test-keep-going} +#### `--[no]test_keep_going` By default, all tests are run to completion. If this flag is disabled, however, the build is aborted on any non-passing test. Subsequent build steps and test invocations are not run, and in-flight invocations are canceled. Do not specify both `--notest_keep_going` and `--keep_going`. -#### `--flaky_test_attempts=attempts` {#flaky-test-attempts} +#### `--flaky_test_attempts=attempts` This option specifies the maximum number of times a test should be attempted if it fails for any reason. A test that initially fails but eventually @@ -1522,7 +1523,7 @@ default), only a single attempt is allowed for regular tests, and an integer value to override the maximum limit of test attempts. Bazel allows a maximum of 10 test attempts in order to prevent abuse of the system. -#### `--runs_per_test=[regex@]number` {#runs-per-test} +#### `--runs_per_test=[regex@]number` This option specifies the number of times each test should be executed. All test executions are treated as separate tests (fallback functionality @@ -1543,7 +1544,7 @@ which match the regex (`--runs_per_test=^//pizza:.*@4` runs all tests under `//pizza/` 4 times). This form of `--runs_per_test` may be specified more than once. -#### `--[no]runs_per_test_detects_flakes` {#run-per-test-detects-flakes} +#### `--[no]runs_per_test_detects_flakes` If this option is specified (by default it is not), Bazel will detect flaky test shards through `--runs_per_test`. If one or more runs for a single shard @@ -1551,7 +1552,7 @@ fail and one or more runs for the same shard pass, the target will be considered flaky with the flag. If unspecified, the target will report a failing status. -#### `--test_summary=output_style` {#test-summary} +#### `--test_summary=output_style` Specifies how the test result summary should be displayed. @@ -1564,7 +1565,7 @@ Specifies how the test result summary should be displayed. only each test. The names of test output files are omitted. * `none` does not print test summary. -#### `--test_output=output_style` {#test-output} +#### `--test_output=output_style` Specifies how test output should be displayed: @@ -1582,12 +1583,12 @@ Specifies how test output should be displayed: * `streamed` streams stdout/stderr output from each test in real-time. -#### `--java_debug` {#java-debug} +#### `--java_debug` This option causes the Java virtual machine of a java test to wait for a connection from a JDWP-compliant debugger before starting the test. This option implies `--test_output=streamed`. -#### `--[no]verbose_test_summary` {#verbose-test-summary} +#### `--[no]verbose_test_summary` By default this option is enabled, causing test times and other additional information (such as test attempts) to be printed to the test summary. If @@ -1595,7 +1596,7 @@ information (such as test attempts) to be printed to the test summary. If include only test name, test status and cached test indicator and will be formatted to stay within 80 characters when possible. -#### `--test_tmpdir=path` {#test-tmpdir} +#### `--test_tmpdir=path` Specifies temporary directory for tests executed locally. Each test will be executed in a separate subdirectory inside this directory. The directory will @@ -1605,7 +1606,7 @@ By default, bazel will place this directory under Bazel output base directory. Note: This is a directory for running tests, not storing test results (those are always stored under the `bazel-out` directory). -#### `--test_timeout=seconds` OR `--test_timeout=seconds,seconds,seconds,seconds` {#test-timeout} +#### `--test_timeout=seconds` OR `--test_timeout=seconds,seconds,seconds,seconds` Overrides the timeout value for all tests by using specified number of seconds as a new timeout value. If only one value is provided, then it will @@ -1627,7 +1628,7 @@ the size tag. So a test of size 'small' which declares a 'long' timeout will have the same effective timeout that a 'large' tests has with no explicit timeout. -#### `--test_arg=arg` {#test-arg} +#### `--test_arg=arg` Passes command-line options/flags/arguments to each test process. This option can be used multiple times to pass several arguments. For example, @@ -1645,7 +1646,7 @@ target being run is a test target. (As with any other flag, if it's passed in a `bazel run` command after a `--` token, it's not processed by Bazel but forwarded verbatim to the executed target.) -#### `--test_env=variable=_value_` OR `--test_env=variable` {#test-env} +#### `--test_env=variable=_value_` OR `--test_env=variable` Specifies additional variables that must be injected into the test environment for each test. If value is not specified it will be @@ -1655,7 +1656,7 @@ command. The environment can be accessed from within a test by using `System.getenv("var")` (Java), `getenv("var")` (C or C++), -#### `--run_under=command-prefix` {#test-run-under} +#### `--run_under=command-prefix` This specifies a prefix that the test runner will insert in front of the test command before running it. The @@ -1685,7 +1686,7 @@ Examples: --run_under='/usr/bin/valgrind --quiet --num-callers=20'
-#### Test selection {#test-selection} +#### Test selection As documented under [Output selection options](#output-selection), you can filter tests by [size](#test-size-filters), @@ -1695,12 +1696,12 @@ you can filter tests by [size](#test-size-filters), [general name filter](#test-filter) can forward particular filter args to the test runner. -#### Other options for `bazel test` {#bazel-test-other-options} +#### Other options for `bazel test` The syntax and the remaining options are exactly like [`bazel build`](/run/build). -## Running executables {#running-executables} +## Running executables The `bazel run` command is similar to `bazel build`, except it is used to build _and run_ a single target. Here is a typical session @@ -1755,9 +1756,9 @@ The following extra environment variables are also available to the binary: These can be used, for example, to interpret file names on the command line in a user-friendly way. -### Options for `bazel run` {#bazel-run-options} +### Options for `bazel run` -#### `--run_under=command-prefix` {#run-run-under} +#### `--run_under=command-prefix` This has the same effect as the `--run_under` option for `bazel test` ([see above](#test-run-under)), @@ -1775,7 +1776,7 @@ suppress the outputs from Bazel itself with the `--ui_event_filters` and For example: `bazel run --ui_event_filters=-info,-stdout,-stderr --noshow_progress //java/myapp:myapp` -### Executing tests {#executing-tests} +### Executing tests `bazel run` can also execute test binaries, which has the effect of running the test in a close approximation of the environment described at @@ -1783,9 +1784,9 @@ running the test in a close approximation of the environment described at `--test_*` arguments have an effect when running a test in this manner except `--test_arg` . -## Cleaning build outputs {#cleaning-build-outputs} +## Cleaning build outputs -### The `clean` command {#clean} +### The `clean` command Bazel has a `clean` command, analogous to that of Make. It deletes the output directories for all build configurations performed @@ -1828,7 +1829,7 @@ these bugs are a high priority to be fixed. If you ever find an incorrect incremental build, file a bug report, and report bugs in the tools rather than using `clean`. -## Querying the dependency graph {#querying-dependency-graph} +## Querying the dependency graph Bazel includes a query language for asking questions about the dependency graph used during the build. The query language is used @@ -1866,7 +1867,7 @@ all genrules required to build all the tests in the PEBL tree." bazel query --output location 'kind(genrule, deps(kind(".*_test rule", foo/bar/pebl/...)))' -## Querying the action graph {#aquery} +## Querying the action graph Caution: The aquery command is still experimental and its API will change. @@ -1887,9 +1888,9 @@ It supports the same set of functions that is also available to traditional For more details, see [Action Graph Query](/query/aquery). -## Miscellaneous commands and options {#misc-commands-options} +## Miscellaneous commands and options -### `help` {#help} +### `help` The `help` command provides on-line help. By default, it shows a summary of available commands and help topics, as shown in @@ -1899,14 +1900,14 @@ topic. Most topics are Bazel commands, such as `build` or `query`, but there are some additional help topics that do not correspond to commands. -#### `--[no]long` (`-l`) {#long} +#### `--[no]long` (`-l`) By default, `bazel help [topic]` prints only a summary of the relevant options for a topic. If the `--long` option is specified, the type, default value and full description of each option is also printed. -### `shutdown` {#shutdown} +### `shutdown` Bazel server processes may be stopped by using the `shutdown` command. This command causes the Bazel server to exit as soon as it @@ -1926,7 +1927,7 @@ useful for scripts that initiate a lot of builds, as any memory leaks in the Bazel server could cause it to crash spuriously on occasion; performing a conditional restart preempts this condition. -### `info` {#info} +### `info` The `info` command prints various values associated with the Bazel server instance, or with a specific build configuration. @@ -1939,7 +1940,7 @@ the value for that one key. (This is especially convenient when scripting Bazel, as it avoids the need to pipe the result through `sed -ne /key:/s/key://p`: -#### Configuration-independent data {#configuration-independent-data} +#### Configuration-independent data * `release`: the release label for this Bazel instance, or "development version" if this is not a released @@ -1993,12 +1994,11 @@ through `sed -ne /key:/s/key://p`: Example: the process ID of the Bazel server. -
-% bazel info server_pid
+
% bazel info server_pid
 1285
 
-#### Configuration-specific data {#configuration-specific-data} +#### Configuration-specific data These data may be affected by the configuration options passed to `bazel info`, for @@ -2038,14 +2038,13 @@ configuration. This is guaranteed to be correct even in cases where the `bazel-bin` symlink cannot be created for some reason (such as if you are building from a read-only directory). -
-% bazel info --cpu=piii bazel-bin
+
% bazel info --cpu=piii bazel-bin
 /var/tmp/_bazel_johndoe/fbd0e8a34f61ce5d491e3da69d959fe6/execroot/io_bazel/bazel-out/piii-opt/bin
 % bazel info --cpu=k8 bazel-bin
 /var/tmp/_bazel_johndoe/fbd0e8a34f61ce5d491e3da69d959fe6/execroot/io_bazel/bazel-out/k8-opt/bin
 
-### `version` and `--version` {#version} +### `version` and `--version` The version command prints version details about the built Bazel binary, including the changelist at which it was built and the date. @@ -2064,7 +2063,7 @@ are: a Bazel server or unpacking the server archive. `bazel --version` can be run from anywhere - it does not require a workspace directory. -### `mobile-install` {#mobile-install} +### `mobile-install` The `mobile-install` command installs apps to mobile devices. Currently only Android devices running ART are supported. @@ -2078,7 +2077,7 @@ transparent to the app. The following options are supported: -#### `--incremental` {#incremental} +#### `--incremental` If set, Bazel tries to install the app incrementally, that is, only those parts that have changed since the last build. This cannot update resources @@ -2092,23 +2091,23 @@ when a full install is needed. If you are using a device with Marshmallow or later, consider the [`--split_apks`](#split-apks) flag. -#### `--split_apks` {#split-apks} +#### `--split_apks` Whether to use split apks to install and update the application on the device. Works only with devices with Marshmallow or later. Note that the [`--incremental`](#incremental) flag is not necessary when using `--split_apks`. -#### `--start_app` {#start-app} +#### `--start_app` Starts the app in a clean state after installing. Equivalent to `--start=COLD`. -#### `--debug_app` {#debug-app} +#### `--debug_app` Waits for debugger to be attached before starting the app in a clean state after installing. Equivalent to `--start=DEBUG`. -#### `--start=_start_type_` {#start} +#### `--start=_start_type_` How the app should be started after installing it. Supported _start_type_s are: @@ -2121,21 +2120,20 @@ How the app should be started after installing it. Supported _start_type_s are: Note: If more than one of `--start=_start_type_`, `--start_app` or `--debug_app` is set, the last value is used. -#### `--adb=path` {#adb} +#### `--adb=path` Indicates the `adb` binary to be used. The default is to use the adb in the Android SDK specified by [`--android_sdk`](#android-sdk). -#### `--adb_arg=serial` {#adb-arg} +#### `--adb_arg=serial` Extra arguments to `adb`. These come before the subcommand in the command line and are typically used to specify which device to install to. For example, to select the Android device or emulator to use: -
-% bazel mobile-install --adb_arg=-s --adb_arg=deadbeef
+
% bazel mobile-install --adb_arg=-s --adb_arg=deadbeef
 
invokes `adb` as @@ -2144,12 +2142,12 @@ invokes `adb` as adb -s deadbeef install ...
-#### `--incremental_install_verbosity=number` {#incremental-install-verbosity} +#### `--incremental_install_verbosity=number` The verbosity for incremental install. Set to 1 for debug logging to be printed to the console. -### `dump` {#dump} +### `dump` The `dump` command prints to stdout a dump of the internal state of the Bazel server. This command is intended @@ -2172,7 +2170,7 @@ Following options are supported: [pprof](https://github.com/google/pprof) compatible .gz file to the specified path. You must enable memory tracking for this to work. -#### Memory tracking {#memory-tracking} +#### Memory tracking Some `dump` commands require memory tracking. To turn this on, you have to pass startup flags to Bazel: @@ -2206,13 +2204,13 @@ Example: % pprof -flame $HOME/prof.gz
-### `analyze-profile` {#analyze-profile} +### `analyze-profile` The `analyze-profile` command analyzes a [JSON trace profile](/advanced/performance/json-trace-profile) previously gathered during a Bazel invocation. -### `canonicalize-flags` {#canonicalize-flags} +### `canonicalize-flags` The [`canonicalize-flags`](/reference/command-line-reference#canonicalize-flags-options) command, which takes a list of options for a Bazel command and returns a list of @@ -2235,7 +2233,7 @@ As an example: --test_tag_filters=-lint
-### Startup options {#startup-options} +### Startup options The options described in this section affect the startup of the Java virtual machine used by Bazel server process, and they apply to all @@ -2248,7 +2246,7 @@ All of the options described in this section must be specified using the syntax. Also, these options must appear _before_ the name of the Bazel command. Use `startup --key=value` to list these in a `.bazelrc` file. -#### `--output_base=dir` {#output-base} +#### `--output_base=dir` This option requires a path argument, which must specify a writable directory. Bazel will use this location to write all its @@ -2285,7 +2283,7 @@ by an incremental build of `//bar`. Note: We recommend you do not use an NFS or similar networked file system for the root directory, as the higher access latency will cause noticeably slower builds. -#### `--output_user_root=dir` {#output-user-root} +#### `--output_user_root=dir` Points to the root directory where output and install bases are created. The directory must either not exist or be owned by the calling user. In the past, @@ -2307,7 +2305,7 @@ base) if there is a better location in your filesystem layout. Note: We recommend you do not use an NFS or similar networked file system for the root directory, as the higher access latency will cause noticeably slower builds. -#### `--server_javabase=dir` {#server-javabase} +#### `--server_javabase=dir` Specifies the Java virtual machine in which _Bazel itself_ runs. The value must be a path to the directory containing a JDK or JRE. It should not be a label. @@ -2326,7 +2324,7 @@ This flag was previously named `--host_javabase` (sometimes referred to as the build flag [--host_javabase](#host-javabase) (sometimes referred to as the 'right-hand side' `--host_javabase`). -#### `--host_jvm_args=string` {#host-jvm-args} +#### `--host_jvm_args=string` Specifies a startup option to be passed to the Java virtual machine in which _Bazel itself_ runs. This can be used to set the stack size, for example: @@ -2348,7 +2346,7 @@ the `--jvm_flags` argument which all `java_binary` and `java_test` programs support. Alternatively for tests, use `bazel test --test_arg=--jvm_flags=foo ...`. -#### `--host_jvm_debug` {#host-java-debug} +#### `--host_jvm_debug` This option causes the Java virtual machine to wait for a connection from a JDWP-compliant debugger before @@ -2358,14 +2356,14 @@ intended for use by Bazel developers. Note: This does _not_ affect any JVMs used by subprocesses of Bazel: applications, tests, tools, etc. -#### `--autodetect_server_javabase` {#autodetect-server-javabase} +#### `--autodetect_server_javabase` This option causes Bazel to automatically search for an installed JDK on startup, and to fall back to the installed JRE if the embedded JRE isn't available. `--explicit_server_javabase` can be used to pick an explicit JRE to run Bazel with. -#### `--batch` {#batch} +#### `--batch` Batch mode causes Bazel to not use the [standard client/server mode](/run/client-server), but instead runs a bazel @@ -2392,7 +2390,7 @@ for the purpose of build isolation, you should use the command option in-memory state is kept between builds. In order to restart the Bazel server and JVM after a build, please explicitly do so using the "shutdown" command. -#### `--max_idle_secs=n` {#max-idle-secs} +#### `--max_idle_secs=n` This option specifies how long, in seconds, the Bazel server process should wait after the last client request, before it exits. The @@ -2420,7 +2418,7 @@ there was already a server running, that server will continue to run until it has been idle for the usual time. Of course, the existing server's idle timer will be reset. -#### `--[no]shutdown_on_low_sys_mem` {#shutdown-on-low-sys-mem} +#### `--[no]shutdown_on_low_sys_mem` If enabled and `--max_idle_secs` is set to a positive duration, after the build server has been idle for a while, shut down the server when the system is @@ -2430,7 +2428,7 @@ In addition to running an idle check corresponding to max_idle_secs, the build s starts monitoring available system memory after the server has been idle for some time. If the available system memory becomes critically low, the server will exit. -#### `--[no]block_for_lock` {#block-for-lock} +#### `--[no]block_for_lock` If enabled, Bazel will wait for other Bazel commands holding the server lock to complete before progressing. If disabled, Bazel will @@ -2440,27 +2438,27 @@ proceed. Developers might use this in presubmit checks to avoid long waits caused by another Bazel command in the same client. -#### `--io_nice_level=n` {#io-nice-level} +#### `--io_nice_level=n` Sets a level from 0-7 for best-effort IO scheduling. 0 is highest priority, 7 is lowest. The anticipatory scheduler may only honor up to priority 4. Negative values are ignored. -#### `--batch_cpu_scheduling` {#batch-cpu-scheduling} +#### `--batch_cpu_scheduling` Use `batch` CPU scheduling for Bazel. This policy is useful for workloads that are non-interactive, but do not want to lower their nice value. See 'man 2 sched_setscheduler'. This policy may provide for better system interactivity at the expense of Bazel throughput. -### Miscellaneous options {#misc-options} +### Miscellaneous options -#### `--[no]announce_rc` {#announce-rc} +#### `--[no]announce_rc` Controls whether Bazel announces startup options and command options read from the bazelrc files when starting up. -#### `--color (yes|no|auto)` {#color} +#### `--color (yes|no|auto)` This option determines whether Bazel will use colors to highlight its output on the screen. @@ -2473,7 +2471,7 @@ If this option is set to `no`, color output is disabled, regardless of whether the output is going to a terminal and regardless of the setting of the TERM environment variable. -#### `--config=name` {#config} +#### `--config=name` Selects additional config section from [the rc files](/run/bazelrc#bazelrc-file-locations); for the current `command`, @@ -2481,7 +2479,7 @@ it also pulls in the options from `command:name` if such a section exists. Can b specified multiple times to add flags from several config sections. Expansions can refer to other definitions (for example, expansions can be chained). -#### `--curses (yes|no|auto)` {#curses} +#### `--curses (yes|no|auto)` This option determines whether Bazel will use cursor controls in its screen output. This results in less scrolling data, and a more @@ -2493,7 +2491,7 @@ If this option is set to `no`, use of cursor controls is disabled. If this option is set to `auto`, use of cursor controls will be enabled under the same conditions as for `--color=auto`. -#### `--[no]show_timestamps` {#show-timestamps} +#### `--[no]show_timestamps` If specified, a timestamp is added to each message generated by Bazel specifying the time at which the message was displayed. diff --git a/extending/auto-exec-groups.mdx b/extending/auto-exec-groups.mdx index 48100b71..9fee9783 100644 --- a/extending/auto-exec-groups.mdx +++ b/extending/auto-exec-groups.mdx @@ -8,7 +8,7 @@ Automatic execution groups select an [execution platform][exec_platform] for each toolchain type. In other words, one target can have multiple execution platforms without defining execution groups. -## Quick summary {#quick-summary} +## Quick summary Automatic execution groups are closely connected to toolchains. If you are using toolchains, you need to set them on the affected actions (actions which use an @@ -29,9 +29,11 @@ doesn't detect that ([the error](#first-error-message) is raised), you can set If you need to use multiple toolchains on a single execution platform (an action uses executable or tools from two or more toolchains), you need to manually -define [exec_groups][exec_groups](check [When should I use a custom exec_group?][multiple_toolchains_exec_groups] section). +define [exec_groups][exec_groups] (check +[When should I use a custom exec_group?][multiple_toolchains_exec_groups] +section). -## History {#history} +## History Before AEGs, the execution platform was selected on a rule level. For example: @@ -42,7 +44,8 @@ my_rule = rule( ) ``` -Rule `my_rule` registers two toolchain types. This means that the [Toolchain Resolution](https://bazel.build/extending/toolchains#toolchain-resolution) used +Rule `my_rule` registers two toolchain types. This means that the [Toolchain +Resolution](https://bazel.build/extending/toolchains#toolchain-resolution) used to find an execution platform which supports both toolchain types. The selected execution platform was used for each registered action inside the rule, unless specified differently with [exec_groups][exec_groups]. @@ -51,7 +54,7 @@ platform even if they used tools from different toolchains (execution platform is selected for each target). This resulted in failures when there was no execution platform supporting all toolchains. -## Current state {#current-state} +## Current state With AEGs, the execution platform is selected for each toolchain type. The implementation function of the earlier example, `my_rule`, would look like: @@ -82,14 +85,14 @@ on different execution platforms. The same is effective with [ctx.actions.run_shell][run_shell] where `toolchain` parameter should be added when `tools` are from a toolchain. -## Difference between custom exec groups and automatic exec groups {#difference-custom} +## Difference between custom exec groups and automatic exec groups As the name suggests, AEGs are exec groups created automatically for each toolchain type registered on a rule. There is no need to manually specify them, unlike the "classic" exec groups. Moreover, name of AEG is automatically set to its toolchain type (e.g. `//tools:toolchain_type_1`). -### When should I use a custom exec_group? {#when-should-use-exec-groups} +### When should I use a custom exec_group? Custom exec_groups are needed only in case where multiple toolchains need to execute on a single execution platform. In all other cases there's no need to @@ -116,22 +119,22 @@ my_rule = rule( ) ``` -## Migration of AEGs {#migration-aegs} +## Migration of AEGs Internally in google3, Blaze is already using AEGs. Externally for Bazel, migration is in the process. Some rules are already using this feature (e.g. Java and C++ rules). -### Which Bazel versions support this migration? {#which-bazel} +### Which Bazel versions support this migration? AEGs are fully supported from Bazel 7. -### How to enable AEGs? {#how-enable} +### How to enable AEGs? Set `--incompatible_auto_exec_groups` to true. More information about the flag on [the GitHub issue][github_flag]. -### How to enable AEGs inside a particular rule? {#how-enable-particular-rule} +### How to enable AEGs inside a particular rule? Set the `_use_auto_exec_groups` attribute on a rule. @@ -147,16 +150,16 @@ This enables AEGs only in `my_rule` and its actions start using the new logic when selecting the execution platform. Incompatible flag is overridden with this attribute. -### How to disable AEGs in case of an error? {#how-disable} +### How to disable AEGs in case of an error? Set `--incompatible_auto_exec_groups` to false to completely disable AEGs in your project ([flag's GitHub issue][github_flag]), or disable a particular rule by setting `_use_auto_exec_groups` attribute to `False` ([more details about the attribute](#how-enable-particular-rule)). -### Error messages while migrating to AEGs {#potential-problems} +### Error messages while migrating to AEGs -#### Couldn't identify if tools are from implicit dependencies or a toolchain. Please set the toolchain parameter. If you're not using a toolchain, set it to 'None'. {#first-error-message} +#### Couldn't identify if tools are from implicit dependencies or a toolchain. Please set the toolchain parameter. If you're not using a toolchain, set it to 'None'. * In this case you get a stack of calls before the error happened and you can clearly see which exact action needs the toolchain parameter. Check which toolchain is used for the action and set it with the toolchain param. If no @@ -167,7 +170,7 @@ by setting `_use_auto_exec_groups` attribute to `False` * This means that you've set the toolchain parameter on the action but didn't register it on the rule. Register the toolchain or set `None` inside the action. -## Additional material {#additional-material} +## Additional material For more information, check design document: [Automatic exec groups for toolchains][aegs_design_doc]. diff --git a/extending/concepts.mdx b/extending/concepts.mdx index 988538fa..893e9cc5 100644 --- a/extending/concepts.mdx +++ b/extending/concepts.mdx @@ -19,17 +19,19 @@ Before learning the more advanced concepts, first: * Learn how you can [share variables](/build/share-variables) between two `BUILD` files. -## Macros and rules {#macros-and-rules} +## Macros and rules A macro is a function that instantiates rules. Macros come in two flavors: -[symbolic macros](/extending/macros) (new in Bazel 8) and [legacy macros](/extending/legacy-macros). The two flavors of macros are defined +[symbolic macros](/extending/macros) (new in Bazel 8) and [legacy +macros](/extending/legacy-macros). The two flavors of macros are defined differently, but behave almost the same from the point of view of a user. A macro is useful when a `BUILD` file is getting too repetitive or too complex, as it lets you reuse some code. The function is evaluated as soon as the `BUILD` file is read. After the evaluation of the `BUILD` file, Bazel has little information about macros. If your macro generates a `genrule`, Bazel will behave *almost* as if you declared that `genrule` in the `BUILD` file. (The one -exception is that targets declared in a symbolic macro have [special visibility semantics](/extending/macros#visibility): a symbolic macro can hide its internal +exception is that targets declared in a symbolic macro have [special visibility +semantics](/extending/macros#visibility): a symbolic macro can hide its internal targets from the rest of the package.) A [rule](/extending/rules) is more powerful than a macro. It can access Bazel @@ -42,7 +44,7 @@ complex, it is often a good idea to make it a rule. Support for a new language is typically done with a rule. Rules are for advanced users, and most users will never have to write one; they will only load and call existing rules. -## Evaluation model {#evaluation-model} +## Evaluation model A build consists of three phases. @@ -76,7 +78,8 @@ they will not be executed. ## Creating extensions * [Create your first macro](/rules/macro-tutorial) in order to reuse some code. - Then [learn more about macros](/extending/macros) and [using them to create "custom verbs"](/rules/verbs-tutorial). + Then [learn more about macros](/extending/macros) and [using them to create + "custom verbs"](/rules/verbs-tutorial). * [Follow the rules tutorial](/rules/rules-tutorial) to get started with rules. Next, you can read more about the [rules concepts](/extending/rules). @@ -91,7 +94,8 @@ them within reach: ## Going further In addition to [macros](/extending/macros) and [rules](/extending/rules), you -may want to write [aspects](/extending/aspects) and [repository rules](/external/repo). +may want to write [aspects](/extending/aspects) and [repository +rules](/external/repo). * Use [Buildifier](https://github.com/bazelbuild/buildtools) consistently to format and lint your code. diff --git a/extending/config.mdx b/extending/config.mdx index 2e1331c0..717bb72f 100644 --- a/extending/config.mdx +++ b/extending/config.mdx @@ -23,7 +23,7 @@ and more, all completely from .bzl files (no Bazel release required). See the `bazelbuild/examples` repo for [examples](https://github.com/bazelbuild/examples/tree/HEAD/configurations). -## User-defined build settings {#user-defined-build-settings} +## User-defined build settings A build setting is a single piece of [configuration](/extending/rules#configurations) @@ -41,14 +41,11 @@ register changes). They also can be set via the command line (if they're designated as `flags`, see more below), but can also be set via [user-defined transitions](#user-defined-transitions). -### Defining build settings {#defining-build-settings} +### Defining build settings [End to end example](https://github.com/bazelbuild/examples/tree/HEAD/configurations/basic_build_setting) -Note: Before defining your own build setting, check if one of the [predefined -settings](#predefined-settings) is suitable. - -#### The `build_setting` `rule()` parameter {#rule-parameter} +#### The `build_setting` `rule()` parameter Build settings are rules like any other rule and are differentiated using the Starlark `rule()` function's `build_setting` @@ -77,7 +74,7 @@ writer have some debug mode that you'd like to turn on inside test rules, you don't want to give users the ability to indiscriminately turn on that feature inside other non-test rules. -#### Using ctx.build_setting_value {#ctx-build-setting-value} +#### Using ctx.build_setting_value Like all rules, build setting rules have [implementation functions](/extending/rules#implementation-function). The basic Starlark-type value of the build settings can be accessed via the @@ -113,7 +110,7 @@ But all other references to the value of the build setting (such as in transitio will see its basic Starlark-typed value, not this post implementation function value. -#### Defining multi-set string flags {#multi-set-string-flags} +#### Defining multi-set string flags String settings have an additional `allow_multiple` parameter which allows the flag to be set multiple times on the command line or in bazelrcs. Their default @@ -146,7 +143,7 @@ $ bazel build //my/target --//example:roasts=blonde \ The above is parsed to `{"//example:roasts": ["blonde", "medium,dark"]}` and `ctx.build_setting_value` returns the list `["blonde", "medium,dark"]`. -#### Instantiating build settings {#instantiating-build-settings} +#### Instantiating build settings Rules defined with the `build_setting` parameter have an implicit mandatory `build_setting_default` attribute. This attribute takes on the same type as @@ -174,23 +171,7 @@ flavor( ) ``` -#### Scope - -Build settings are by default only applied to the `target` [configuration] -(/extending/rules#configurations), and won't be applied to the `exec` -configuration. To have the build setting applied to both the `target` and `exec` -configurations set the `scope` attribute to `"universal"`. - -```python -# example/BUILD -load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") -bool_flag( - name = "use_this_for_compiler_and_sources", - scope = "universal" -) -``` - -### Predefined settings {#predefined-settings} +### Predefined settings [End to end example](https://github.com/bazelbuild/examples/tree/HEAD/configurations/use_skylib_build_setting) @@ -214,9 +195,9 @@ string_flag( For a complete list, see [Common build setting rules](https://github.com/bazelbuild/bazel-skylib/blob/main/rules/common_settings.bzl). -### Using build settings {#using-build-settings} +### Using build settings -#### Depending on build settings {#depending-on-build-settings} +#### Depending on build settings If a target would like to read a piece of configuration information, it can directly depend on the build setting via a regular attribute dependency. @@ -281,7 +262,7 @@ kotlin_binary = rule( ``` -#### Using build settings on the command line {#build-settings-command-line} +#### Using build settings on the command line Similar to most native flags, you can use the command line to set build settings [that are marked as flags](#rule-parameter). The build @@ -299,7 +280,7 @@ $ bazel build //my/target --//example:boolean_flag $ bazel build //my/target --no//example:boolean_flag ``` -#### Using build setting aliases {#using-build-setting-aliases} +#### Using build setting aliases You can set an alias for your build setting target path to make it easier to read on the command line. Aliases function similarly to native flags and also make use @@ -331,7 +312,7 @@ $ bazel build //my/target --//experimental/user/starlark_configurations/basic_bu Best Practice: While it possible to set aliases on the command line, leaving them in a `.bazelrc` reduces command line clutter. -### Label-typed build settings {#label-typed-build-settings} +### Label-typed build settings [End to end example](https://github.com/bazelbuild/examples/tree/HEAD/configurations/label_typed_build_setting) @@ -385,7 +366,7 @@ label_flag( ) ``` -### Build settings and select() {#build-settings-and-select} +### Build settings and select() [End to end example](https://github.com/bazelbuild/examples/tree/HEAD/configurations/select_on_build_setting) @@ -403,7 +384,7 @@ config_setting( ) ``` -## User-defined transitions {#user-defined-transitions} +## User-defined transitions A configuration [transition](/rules/lib/builtins/transition#transition) @@ -412,7 +393,7 @@ build graph. Important: Transitions have [memory and performance impact](#memory-performance-considerations). -### Defining {#defining} +### Defining Transitions define configuration changes between rules. For example, a request like "compile my dependency for a different CPU than its parent" is handled by a @@ -443,7 +424,7 @@ hot_chocolate_transition = transition( The `transition()` function takes in an implementation function, a set of build settings to read(`inputs`), and a set of build settings to write (`outputs`). The implementation function has two parameters, `settings` and -`attr`. `settings` is a dictionary `{String : Object}` of all settings declared +`attr`. `settings` is a dictionary {`String`:`Object`} of all settings declared in the `inputs` parameter to `transition()`. `attr` is a dictionary of attributes and values of the rule to which the @@ -471,7 +452,7 @@ parameter of the transition function. This is true even if a build setting is not actually changed over the course of the transition - its original value must be explicitly passed through in the returned dictionary. -### Defining 1:2+ transitions {#defining-1-2-transitions} +### Defining 1:2+ transitions [End to end example](https://github.com/bazelbuild/examples/tree/HEAD/configurations/multi_arch_binary) @@ -516,7 +497,7 @@ multi_arch_transition = transition( ) ``` -### Attaching transitions {#attaching-transitions} +### Attaching transitions [End to end example](https://github.com/bazelbuild/examples/tree/HEAD/configurations/attaching_transitions_to_rules) @@ -530,7 +511,7 @@ If you need to do this, contact bazel-discuss@googlegroups.com for help with figuring out workarounds. -### Incoming edge transitions {#incoming-edge-transitions} +### Incoming edge transitions Incoming edge transitions are activated by attaching a `transition` object (created by `transition()`) to `rule()`'s `cfg` parameter: @@ -546,7 +527,7 @@ drink_rule = rule( Incoming edge transitions must be 1:1 transitions. -### Outgoing edge transitions {#outgoing-edge-transitions} +### Outgoing edge transitions Outgoing edge transitions are activated by attaching a `transition` object (created by `transition()`) to an attribute's `cfg` parameter: @@ -564,7 +545,7 @@ Outgoing edge transitions can be 1:1 or 1:2+. See [Accessing attributes with transitions](#accessing-attributes-with-transitions) for how to read these keys. -### Transitions on native options {#transitions-native-options} +### Transitions on native options [End to end example](https://github.com/bazelbuild/examples/tree/HEAD/configurations/transition_on_native_flag) @@ -583,7 +564,7 @@ cpu_transition = transition( outputs = ["//command_line_option:cpu"] ``` -#### Unsupported native options {#unsupported-native-options} +#### Unsupported native options Bazel doesn't support transitioning on `--define` with `"//command_line_option:define"`. Instead, use a custom @@ -603,7 +584,7 @@ As a workaround, you can explicitly itemize the flags that *are* part of the configuration in your transition. This requires maintaining the `--config`'s expansion in two places, which is a known UI blemish. -### Transitions on allow multiple build settings {#transitions-multiple-build-settings} +### Transitions on allow multiple build settings When setting build settings that [allow multiple values](#defining-multi-set-string-flags), the value of the @@ -636,7 +617,7 @@ coffee_transition = transition( ) ``` -### No-op transitions {#no-op-transitions} +### No-op transitions If a transition returns `{}`, `[]`, or `None`, this is shorthand for keeping all settings at their original values. This can be more convenient than explicitly @@ -665,7 +646,7 @@ hot_chocolate_transition = transition( ) ``` -### Accessing attributes with transitions {#accessing-attributes-with-transitions} +### Accessing attributes with transitions [End to end example](https://github.com/bazelbuild/examples/tree/HEAD/configurations/read_attr_in_transition) @@ -734,14 +715,14 @@ multi_arch_rule = rule( See [complete example](https://github.com/bazelbuild/examples/tree/main/configurations/multi_arch_binary) here. -## Integration with platforms and toolchains {#integration-platforms-toolchains} +## Integration with platforms and toolchains Many native flags today, like `--cpu` and `--crosstool_top` are related to toolchain resolution. In the future, explicit transitions on these types of flags will likely be replaced by transitioning on the [target platform](/extending/platforms). -## Memory and performance considerations {#memory-performance-considerations} +## Memory and performance considerations Adding transitions, and therefore new configurations, to your build comes at a cost: larger build graphs, less comprehensible build graphs, and slower @@ -749,7 +730,7 @@ builds. It's worth considering these costs when considering using transitions in your build rules. Below is an example of how a transition might create exponential growth of your build graph. -### Badly behaved builds: a case study {#badly-behaved-builds} +### Badly behaved builds: a case study ![Scalability graph](/rules/scalability-graph.png "Scalability graph") @@ -800,7 +781,7 @@ corresponding memory and performance consequences. TODO: Add strategies for measurement and mitigation of these issues. -## Further reading {#further-reading} +## Further reading For more details on modifying build configurations, see: diff --git a/extending/depsets.mdx b/extending/depsets.mdx index 8f0f31b0..4e84d3f2 100644 --- a/extending/depsets.mdx +++ b/extending/depsets.mdx @@ -113,7 +113,8 @@ need to ensure that if `B` depends on `A`, then `A.o` comes before `B.o` on the linker’s command line. Other tools might have the opposite requirement. Three traversal orders are supported: `postorder`, `preorder`, and -`topological`. The first two work exactly like [tree traversals](https://en.wikipedia.org/wiki/Tree_traversal#Depth-first_search) +`topological`. The first two work exactly like [tree +traversals](https://en.wikipedia.org/wiki/Tree_traversal#Depth-first_search) except that they operate on DAGs and skip already visited nodes. The third order works as a topological sort from root to leaves, essentially the same as preorder except that shared children are listed only after all of their parents. diff --git a/extending/exec-groups.mdx b/extending/exec-groups.mdx index 68003af0..aa70cb1e 100644 --- a/extending/exec-groups.mdx +++ b/extending/exec-groups.mdx @@ -8,14 +8,14 @@ Execution groups allow for multiple execution platforms within a single target. Each execution group has its own [toolchain](/extending/toolchains) dependencies and performs its own [toolchain resolution](/extending/toolchains#toolchain-resolution). -## Current status {#current-status} +## Current status Execution groups for certain natively declared actions, like `CppLink`, can be used inside `exec_properties` to set per-action, per-target execution requirements. For more details, see the [Default execution groups](#exec-groups-for-native-rules) section. -## Background {#background} +## Background Execution groups allow the rule author to define sets of actions, each with a potentially different execution platform. Multiple execution platforms can allow @@ -28,7 +28,7 @@ unique and can only reference a single action. This is especially helpful in allocating extra resources to specific memory and processing intensive actions like linking in C++ builds without over-allocating to less demanding tasks. -## Defining execution groups {#defining-exec-groups} +## Defining execution groups During rule definition, rule authors can [declare](/rules/lib/globals/bzl#exec_group) @@ -68,11 +68,12 @@ built. As on native rules, the `test` execution group is present by default on Starlark test rules. -## Accessing execution groups {#accessing-exec-groups} +## Accessing execution groups In the rule implementation, you can declare that actions should be run on the execution platform of an execution group. You can do this by using the `exec_group` -param of action generating methods, specifically [`ctx.actions.run`](/rules/lib/builtins/actions#run) and +param of action generating methods, specifically [`ctx.actions.run`] +(/rules/lib/builtins/actions#run) and [`ctx.actions.run_shell`](/rules/lib/builtins/actions#run_shell). ```python @@ -105,7 +106,7 @@ that execution group in the action declaration, that may potentially cause issues. A mismatch like this may not immediately cause failures, but is a latent problem. -### Default execution groups {#exec-groups-for-native-rules} +### Default execution groups The following execution groups are predefined: @@ -113,7 +114,7 @@ The following execution groups are predefined: the [execution platform section of the Test Encyclopedia](/reference/test-encyclopedia#execution-platform)). * `cpp_link`: C++ linking actions. -## Using execution groups to set execution properties {#using-exec-groups-for-exec-properties} +## Using execution groups to set execution properties Execution groups are integrated with the [`exec_properties`](/reference/be/common-definitions#common-attributes) @@ -139,7 +140,7 @@ All actions with `exec_group = "link"` would see the exec properties dictionary as `{"mem": "16g"}`. As you see here, execution-group-level settings override target-level settings. -## Using execution groups to set platform constraints {#using-exec-groups-for-platform-constraints} +## Using execution groups to set platform constraints Execution groups are also integrated with the [`exec_compatible_with`](/reference/be/common-definitions#common-attributes) and @@ -177,7 +178,7 @@ my_test( ) ``` -### Execution groups for native rules {#execution-groups-for-native-rules} +### Execution groups for native rules The following execution groups are available for actions defined by native rules: @@ -185,7 +186,7 @@ rules: * `test`: Test runner actions. * `cpp_link`: C++ linking actions. -### Execution groups and platform execution properties {#platform-execution-properties} +### Execution groups and platform execution properties It is possible to define `exec_properties` for arbitrary execution groups on platform targets (unlike `exec_properties` set directly on a target, where diff --git a/extending/legacy-macros.mdx b/extending/legacy-macros.mdx index 564f1211..9c2b8e28 100644 --- a/extending/legacy-macros.mdx +++ b/extending/legacy-macros.mdx @@ -9,9 +9,9 @@ create targets. By the end of the [loading phase](/extending/concepts#evaluation-model), legacy macros don't exist anymore, and Bazel sees only the concrete set of instantiated rules. -## Why you shouldn't use legacy macros (and should use Symbolic macros instead) {#no-legacy-macros} +## Why you shouldn't use legacy macros (and should use Symbolic macros instead) -Where possible you should use [symbolic macros](/extending/macros#macros). +Where possible you should use [symbolic macros](macros.md#macros). Symbolic macros @@ -20,9 +20,9 @@ Symbolic macros * Take typed attributes, which in turn means automatic label and select conversion. * Are more readable -* Will soon have [lazy evaluation](/extending/macros#laziness) +* Will soon have [lazy evaluation](macros.md#laziness) -## Usage {#usage} +## Usage The typical use case for a macro is when you want to reuse a rule. @@ -116,7 +116,7 @@ by other targets in the workspace. Note: Similar to `$@` for outputs, `$<` expands to the locations of files in the `srcs` attribute list. -## Expanding macros {#expanding-macros} +## Expanding macros When you want to investigate what a macro does, use the `query` command with `--output=build` to see the expanded form: @@ -132,7 +132,7 @@ genrule( ) ``` -## Instantiating native rules {#instantiating-native-rules} +## Instantiating native rules Native rules (rules that don't need a `load()` statement) can be instantiated from the [native](/rules/lib/toplevel/native) module: @@ -151,10 +151,10 @@ the macro), use the function [native.package_name()](/rules/lib/toplevel/native#package_name). Note that `native` can only be used in `.bzl` files, and not in `BUILD` files. -## Label resolution in macros {#label-resolution} +## Label resolution in macros Since legacy macros are evaluated in the -[loading phase](/extending/concepts#evaluation-model), label strings such as +[loading phase](concepts.md#evaluation-model), label strings such as `"//foo:bar"` that occur in a legacy macro are interpreted relative to the `BUILD` file in which the macro is used rather than relative to the `.bzl` file in which it is defined. This behavior is generally undesirable for macros that @@ -190,7 +190,7 @@ relative to the package of the file that contains the `select` call. If this is not chosen, wrap the label string with [native.package_relative_label()](/rules/lib/toplevel/native#package_relative_label). -## Debugging {#debugging} +## Debugging * `bazel query --output=build //my/path:all` will show you how the `BUILD` file looks after evaluation. All legacy macros, globs, loops are expanded. @@ -213,7 +213,7 @@ not chosen, wrap the label string with `debugging` parameter that defaults to `False` before submitting the code to the depot. -## Errors {#errors} +## Errors If you want to throw an error, use the [fail](/rules/lib/globals/all#fail) function. Explain clearly to the user what went wrong and how to fix their @@ -226,7 +226,7 @@ def my_macro(name, deps, visibility=None): # ... ``` -## Conventions {#conventions} +## Conventions * All public functions (functions that don't start with underscore) that instantiate rules must have a `name` argument. This argument should not be diff --git a/extending/macros.mdx b/extending/macros.mdx index 44b7faae..136665d0 100644 --- a/extending/macros.mdx +++ b/extending/macros.mdx @@ -12,7 +12,7 @@ Macros are mainly used for encapsulation and code reuse of existing rules and other macros. Macros come in two flavors: symbolic macros, which are described on this page, -and [legacy macros](/extending/legacy-macros). Where possible, we recommend using +and [legacy macros](legacy-macros.md). Where possible, we recommend using symbolic macros for code clarity. Symbolic macros offer typed arguments (string to label conversion, relative to @@ -25,15 +25,16 @@ referring to **symbolic macros**. An executable example of symbolic macros can be found in the [examples repository](https://github.com/bazelbuild/examples/tree/main/macros). -## Usage {#usage} +## Usage Macros are defined in `.bzl` files by calling the [`macro()`](https://bazel.build/rules/lib/globals/bzl.html#macro) function with two required parameters: `attrs` and `implementation`. -### Attributes {#attributes} +### Attributes -`attrs` accepts a dictionary of attribute name to [attribute types](https://bazel.build/rules/lib/toplevel/attr#members), which represents +`attrs` accepts a dictionary of attribute name to [attribute +types](https://bazel.build/rules/lib/toplevel/attr#members), which represents the arguments to the macro. Two common attributes – `name` and `visibility` – are implicitly added to all macros and are not included in the dictionary passed to `attrs`. @@ -57,7 +58,7 @@ Attribute type declarations accept the as an unconfigurable `select` – `"foo"` will become `select({"//conditions:default": "foo"})`. Learn more in [selects](#selects). -#### Attribute inheritance {#attribute-inheritance} +#### Attribute inheritance Macros are often intended to wrap a rule (or another macro), and the macro's author often wants to forward the bulk of the wrapped symbol's attributes @@ -67,7 +68,9 @@ To support this pattern, a macro can *inherit attributes* from a rule or another macro by passing the [rule](https://bazel.build/rules/lib/builtins/rule) or [macro symbol](https://bazel.build/rules/lib/builtins/macro) to `macro()`'s `inherit_attrs` argument. (You can also use the special string `"common"` -instead of a rule or macro symbol to inherit the [common attributes defined for all Starlark build rules](https://bazel.build/reference/be/common-definitions#common-attributes).) +instead of a rule or macro symbol to inherit the [common attributes defined for +all Starlark build +rules](https://bazel.build/reference/be/common-definitions#common-attributes).) Only public attributes get inherited, and the attributes in the macro's own `attrs` dictionary override inherited attributes with the same name. You can also *remove* inherited attributes by using `None` as a value in the `attrs` @@ -107,7 +110,7 @@ def _my_macro_impl(name, visibility, tags, **kwargs): ... ``` -### Implementation {#implementation} +### Implementation `implementation` accepts a function which contains the logic of the macro. Implementation functions often create targets by calling one or more rules, and @@ -141,7 +144,7 @@ invokes the inherited rule or submacro. (This helps ensure that your macro won't be broken if the rule or macro which from which you are inheriting adds a new attribute.) -### Declaration {#declaration} +### Declaration Macros are declared by loading and calling their definition in a `BUILD` file. @@ -177,9 +180,9 @@ my_macro(name = "abc", srcs = ["src.cc"]) This is generally not useful in `BUILD` files, but is helpful when programmatically wrapping a macro inside another macro. -## Details {#usage-details} +## Details -### Naming conventions for targets created {#naming} +### Naming conventions for targets created The names of any targets or submacros created by a symbolic macro must either match the macro's `name` parameter or must be prefixed by `name` followed @@ -196,7 +199,7 @@ exclusivity is not enforced. We are in the progress of implementing [lazy evaluation](#laziness) as a performance improvement for Symbolic macros, which will be impaired in packages that violate the naming schema. -### Restrictions {#restrictions} +### Restrictions Symbolic macros have some additional restrictions compared to legacy macros. @@ -216,7 +219,7 @@ Symbolic macros * can't refer to private targets of their callers (see [visibility and macros](#visibility) for more details). -### Visibility and macros {#visibility} +### Visibility and macros The [visibility](/concepts/visibility) system helps protect the implementation details of both (symbolic) macros and their callers. @@ -335,7 +338,7 @@ Remember that legacy macros are entirely transparent to the visibility system, and behave as though their location is whatever BUILD file or symbolic macro they were called from. -#### Finalizers and visibility {#finalizers-and-visibility} +#### Finalizers and visibility Targets declared in a rule finalizer, in addition to seeing targets following the usual symbolic macro visibility rules, can *also* see all targets which are @@ -350,7 +353,7 @@ that a finalizer's targets cannot see it under the visibility system – even though the finalizer can *introspect* its attributes using `native.existing_rules()`. -### Selects {#selects} +### Selects If an attribute is `configurable` (the default) and its value is not `None`, then the macro implementation function will see the attribute value as wrapped @@ -389,7 +392,7 @@ not always possible for an attribute to take on a `None` value, but it can happen for the `attr.label()` type, and for any inherited non-mandatory attribute. -## Finalizers {#finalizers} +## Finalizers A rule finalizer is a special symbolic macro which – regardless of its lexical position in a BUILD file – is evaluated in the final stage of loading a package, @@ -421,7 +424,7 @@ my_finalizer = macro( ) ``` -## Laziness {#laziness} +## Laziness IMPORTANT: We are in the process of implementing lazy macro expansion and evaluation. This feature is not available yet. @@ -432,7 +435,7 @@ unrelated macros. In the future, non-finalizer symbolic macros will only be evaluated if they're required for the build. The prefix naming schema helps Bazel determine which macro to expand given a requested target. -## Migration troubleshooting {#troubleshooting} +## Migration troubleshooting Here are some common migration headaches and how to fix them. diff --git a/extending/platforms.mdx b/extending/platforms.mdx index f95f5e6a..9304d80b 100644 --- a/extending/platforms.mdx +++ b/extending/platforms.mdx @@ -72,7 +72,7 @@ builds target the same machine Bazel runs on. Build rules can [@platforms/cpu](https://github.com/bazelbuild/platforms/blob/main/cpu/BUILD) constraints. -## Generally useful constraints and platforms {#useful-constraints-platforms} +## Generally useful constraints and platforms To keep the ecosystem consistent, Bazel team maintains a repository with constraint definitions for the most popular CPU architectures and operating @@ -83,7 +83,7 @@ Bazel ships with the following special platform definition: `@platforms//host` (aliased as `@bazel_tools//tools:host_platform`). This auto-detects the OS and CPU properties of the machine Bazel runs on. -## Defining constraints {#constraints} +## Defining constraints Constraints are modeled with the [`constraint_setting`][constraint_setting] and [`constraint_value`][constraint_value] build rules. @@ -113,7 +113,7 @@ the `x86` constraint as `//cpus:x86`. If visibility allows, you can extend an existing `constraint_setting` by defining your own value for it. -## Defining platforms {#platforms} +## Defining platforms The [`platform`](/reference/be/platforms-and-toolchains#platform) build rule defines a platform as a collection of `constraint_value`s: @@ -135,7 +135,7 @@ Platforms may only have one `constraint_value` for a given `constraint_setting`. This means, for example, a platform can't have two CPUs unless you create another `constraint_setting` type to model the second value. -## Skipping incompatible targets {#skipping-incompatible-targets} +## Skipping incompatible targets When building for a specific target platform it is often desirable to skip targets that will never work on that platform. For example, your Windows device @@ -165,7 +165,7 @@ incompatible with all else. Incompatibility is transitive. Any targets that transitively depend on an incompatible target are themselves considered incompatible. -### When are targets skipped? {#when-targets-skipped} +### When are targets skipped? Targets are skipped when they are considered incompatible and included in the build as part of a target pattern expansion. For example, the following two @@ -200,7 +200,7 @@ FAILED: Build did NOT complete successfully Incompatible explicit targets are silently skipped if `--skip_incompatible_explicit_targets` is enabled. -### More expressive constraints {#expressive-constraints} +### More expressive constraints For more flexibility in expressing constraints, use the `@platforms//:incompatible` @@ -252,11 +252,12 @@ cc_library( ) ``` -### Detecting incompatible targets using `bazel cquery` {#cquery-incompatible-target-detection} +### Detecting incompatible targets using `bazel cquery` You can use the [`IncompatiblePlatformProvider`](/rules/lib/providers/IncompatiblePlatformProvider) -in `bazel cquery`'s [Starlark output format](/query/cquery#output-format-definition) to distinguish +in `bazel cquery`'s [Starlark output +format](/query/cquery#output-format-definition) to distinguish incompatible targets from compatible ones. This can be used to filter out incompatible targets. The example below will @@ -277,4 +278,5 @@ $ bazel cquery //... --output=starlark --starlark:file=example.cquery ### Known Issues -Incompatible targets [ignore visibility restrictions](https://github.com/bazelbuild/bazel/issues/16044). +Incompatible targets [ignore visibility +restrictions](https://github.com/bazelbuild/bazel/issues/16044). diff --git a/extending/rules.mdx b/extending/rules.mdx index 8a4efe20..248ee328 100644 --- a/extending/rules.mdx +++ b/extending/rules.mdx @@ -170,7 +170,7 @@ dependency graph of targets. -### Private attributes and implicit dependencies {#private_attributes_and_implicit_dependencies} +### Private attributes and implicit dependencies A dependency attribute with a default value creates an *implicit dependency*. It is implicit because it's a part of the target graph that the user doesn't @@ -451,7 +451,8 @@ def _example_library_impl(ctx): If `DefaultInfo` is not returned by a rule implementation or the `files` parameter is not specified, `DefaultInfo.files` defaults to all -*predeclared outputs* (generally, those created by [output attributes](#output_attributes)). +*predeclared outputs* (generally, those created by [output +attributes](#output_attributes)). Rules that perform actions should provide default outputs, even if those outputs are not expected to be directly used. Actions that are not in the graph of the @@ -542,7 +543,7 @@ provider instances satisfy certain invariants, or to give users a cleaner API fo obtaining an instance. This is done by passing an `init` callback to the -[`provider`](/rules/lib/globals/bzl#provider) function. If this callback is given, the +[`provider`](/rules/lib/globals/bzl.html#provider) function. If this callback is given, the return type of `provider()` changes to be a tuple of two values: the provider symbol that is the ordinary return value when `init` is not used, and a "raw constructor". @@ -994,7 +995,8 @@ By using `configuration_field`, the dependency on the Java LCOV merger tool can be avoided as long as coverage is not requested. When the test is run, it should emit coverage information in the form of one or -more [LCOV files](https://manpages.debian.org/unstable/lcov/geninfo.1.en.html#TRACEFILE_FORMAT) +more [LCOV files] +(https://manpages.debian.org/unstable/lcov/geninfo.1.en.html#TRACEFILE_FORMAT) with unique names into the directory specified by the `COVERAGE_DIR` environment variable. Bazel will then merge these files into a single LCOV file using the `_lcov_merger` tool. If present, it will also collect C/C++ coverage using the diff --git a/extending/toolchains.mdx b/extending/toolchains.mdx index 33f8bac9..249eaf06 100644 --- a/extending/toolchains.mdx +++ b/extending/toolchains.mdx @@ -11,7 +11,7 @@ pages before continuing. This page covers why toolchains are needed, how to define and use them, and how Bazel selects an appropriate toolchain based on platform constraints. -## Motivation {#motivation} +## Motivation Let's first look at the problem toolchains are designed to solve. Suppose you are writing rules to support the "bar" programming language. Your `bar_binary` @@ -124,7 +124,7 @@ automatically resolves this to a particular target (a toolchain) based on the applicable platform constraints. Neither the rule author nor the target author need know the complete set of available platforms and toolchains. -## Writing rules that use toolchains {#writing-rules-toolchains} +## Writing rules that use toolchains Under the toolchain framework, instead of having rules depend directly on tools, they instead depend on *toolchain types*. A toolchain type is a simple target @@ -183,7 +183,7 @@ Bazel's procedure for resolving toolchains to targets is described made a dependency of the `bar_binary` target, not the whole space of candidate toolchains. -### Mandatory and Optional Toolchains {#optional-toolchains} +### Mandatory and Optional Toolchains By default, when a rule expresses a toolchain type dependency using a bare label (as shown above), the toolchain type is considered to be **mandatory**. If Bazel @@ -232,7 +232,7 @@ You can mix and match forms in the same rule, also. However, if the same toolchain type is listed multiple times, it will take the most strict version, where mandatory is more strict than optional. -### Writing aspects that use toolchains {#writing-aspects-toolchains} +### Writing aspects that use toolchains Aspects have access to the same toolchain API as rules: you can define required toolchain types, access toolchains via the context, and use them to generate new @@ -251,7 +251,7 @@ def _bar_aspect_impl(target, ctx): return [] ``` -## Defining toolchains {#toolchain-definitions} +## Defining toolchains To define some toolchains for a given toolchain type, you need three things: @@ -483,7 +483,7 @@ bar_toolchain( ) ``` -## Registering and building with toolchains {#registering-building-toolchains} +## Registering and building with toolchains At this point all the building blocks are assembled, and you just need to make the toolchains available to Bazel's resolution procedure. This is done by @@ -539,7 +539,7 @@ has `@platforms//os:linux` and therefore resolve the This will end up building `//bar_tools:barc_linux` but not `//bar_tools:barc_windows`. -## Toolchain resolution {#toolchain-resolution} +## Toolchain resolution Note: [Some Bazel rules](/concepts/platforms#status) do not yet support toolchain resolution. @@ -583,7 +583,8 @@ The set of available toolchains, in priority order, is created from 4. Toolchains registered in the "WORKSPACE suffix"; this is only used by certain native rules bundled with the Bazel installation. -**NOTE:** [Pseudo-targets like `:all`, `:*`, and `/...`](/run/build#specifying-build-targets) are ordered by Bazel's package +**NOTE:** [Pseudo-targets like `:all`, `:*`, and +`/...`](/run/build#specifying-build-targets) are ordered by Bazel's package loading mechanism, which uses a lexicographic ordering. The resolution steps are as follows. @@ -631,7 +632,7 @@ additional constraints not specified by the toolchain. This lets developers define arbitrarily precise platforms that don't lose toolchain compatibility because of unrelated hardware variants. -## Debugging toolchains {#debugging-toolchains} +## Debugging toolchains If you are adding toolchain support to an existing rule, use the `--toolchain_resolution_debug=regex` flag. During toolchain resolution, the flag diff --git a/external/extension.mdx b/external/extension.mdx index 9a8dae94..15a1961d 100644 --- a/external/extension.mdx +++ b/external/extension.mdx @@ -6,7 +6,8 @@ title: 'Module extensions' Module extensions allow users to extend the module system by reading input data from modules across the dependency graph, performing necessary logic to resolve -dependencies, and finally creating repos by calling [repo rules](/external/repo). These extensions have capabilities similar to repo +dependencies, and finally creating repos by calling [repo +rules](/external/repo). These extensions have capabilities similar to repo rules, which enables them to perform file I/O, send network requests, and so on. Among other things, they allow Bazel to interact with other package management systems while also respecting the dependency graph built out of Bazel modules. diff --git a/external/faq.mdx b/external/faq.mdx index 7b1a31e8..480658fb 100644 --- a/external/faq.mdx +++ b/external/faq.mdx @@ -9,9 +9,9 @@ title: 'Frequently asked questions' This page answers some frequently asked questions about external dependencies in Bazel. -## MODULE.bazel {#module-bazel} +## MODULE.bazel -### How should I version a Bazel module? {#module-versioning-best-practices} +### How should I version a Bazel module? Setting `version` with the [`module`] directive in the source archive `MODULE.bazel` can have several downsides and unintended side effects if not @@ -63,7 +63,7 @@ expected when sorting (the empty string is treated as the highest version). [non-registry override]: module.md#non-registry_overrides [`rules-template`]: https://github.com/bazel-contrib/rules-template -### What is a compatibility level? {#compatibility-level} +### What is a compatibility level? You should stop using `compatibility_level`. @@ -76,7 +76,7 @@ failures provide clear error messages and actionable migration paths. **Legacy documentation:** -The [`compatibility_level`](/external/module#compatibility_level) of a Bazel module +The [`compatibility_level`](module.md#compatibility_level) of a Bazel module should be incremented _in the same commit_ that introduces a backwards incompatible ("breaking") change. @@ -90,7 +90,7 @@ and is discouraged. To avoid this situation, the `compatibility_level` should be incremented _only_ when the breaking change affects most use cases and isn't easy to migrate and/or work-around. -### Why does MODULE.bazel not support `load`s? {#why-does-module-bazel-not-support-loads} +### Why does MODULE.bazel not support `load`s? During dependency resolution, the MODULE.bazel file of all referenced external dependencies are fetched from registries. At this stage, the source archives of @@ -114,27 +114,29 @@ generally interested in, and they can be solved without `load`s: `load`s in MODULE.bazel files, `include` cannot be used in non-root modules. * Users of the old WORKSPACE system might remember declaring a repo, and then immediately `load`ing from that repo to perform complex logic. This - capability has been replaced by [module extensions](/external/extension). + capability has been replaced by [module extensions](extension). -### Can I specify a SemVer range for a `bazel_dep`? {#can-i-specify-a-semver-range-for-a-bazel-dep} +### Can I specify a SemVer range for a `bazel_dep`? No. Some other package managers like [npm][npm-semver] and [Cargo][cargo-semver] support version ranges (implicitly or explicitly), and this often requires a constraint solver (making the output harder to predict for users) and makes version resolution nonreproducible without a lockfile. -Bazel instead uses [Minimal Version Selection](/external/module#version-selection) like +Bazel instead uses [Minimal Version Selection](module#version-selection) like Go, which in contrast makes the output easy to predict and guarantees reproducibility. This is a tradeoff that matches Bazel's design goals. -Furthermore, Bazel module versions are [a superset of SemVer](/external/module#version-format), so what makes sense in a strict SemVer +Furthermore, Bazel module versions are [a superset of +SemVer](module#version-format), so what makes sense in a strict SemVer environment doesn't always carry over to Bazel module versions. -### Can I automatically get the latest version for a `bazel_dep`? {#can-i-automatically-get-the-latest-version-for-a-bazel-dep} +### Can I automatically get the latest version for a `bazel_dep`? Some users occasionally ask for the ability to specify `bazel_dep(name = "foo", version = "latest")` to automatically get the latest version of a dep. This is -similar to [the question about SemVer ranges](#can-i-specify-a-semver-range-for-a-bazel-dep), and the answer is also +similar to [the question about SemVer +ranges](#can-i-specify-a-semver-range-for-a-bazel-dep), and the answer is also no. The recommended solution here is to have automation take care of this. For @@ -145,7 +147,7 @@ Sometimes, users asking this question are really looking for a way to quickly iterate during local development. This can be achieved by using a [`local_path_override`](/rules/lib/globals/module#local_path_override). -### Why all these `use_repo`s? {#why-all-these-use-repos} +### Why all these `use_repo`s? Module extension usages in MODULE.bazel files sometimes come with a big `use_repo` directive. For example, a typical usage of the @@ -182,9 +184,9 @@ an [`extension_metadata`](/rules/lib/builtins/module_ctx#extension_metadata) object from its implementation function. The user can run the `bazel mod tidy` command to update the `use_repo` directives for these module extensions. -## Bzlmod migration {#bzlmod-migration} +## Bzlmod migration -### Which is evaluated first, MODULE.bazel or WORKSPACE? {#which-is-evaluated-first-module-bazel-or-workspace} +### Which is evaluated first, MODULE.bazel or WORKSPACE? When both `--enable_bzlmod` and `--enable_workspace` are set, it's natural to wonder which system is consulted first. The short answer is that MODULE.bazel @@ -192,7 +194,8 @@ wonder which system is consulted first. The short answer is that MODULE.bazel The long answer is that "which evaluates first" is not the right question to ask; rather, the right question to ask is: in the context of the repo with -[canonical name](/external/overview#canonical-repo-name) `@@foo`, what does the [apparent repo name](/external/overview#apparent-repo-name) `@bar` resolve to? Alternatively, what +[canonical name](overview#canonical-repo-name) `@@foo`, what does the [apparent +repo name](overview#apparent-repo-name) `@bar` resolve to? Alternatively, what is the repo mapping of `@@base`? Labels with apparent repo names (a single leading `@`) can refer to different @@ -201,7 +204,8 @@ things based on the context they're resolved from. When you see a label what the context repo is: for example, if the label is in a BUILD file located in the repo `@@foo`, then the context repo is `@@foo`. -Then, depending on what the context repo is, the ["repository visibility" table](/external/migration#repository-visibility) in the migration guide can +Then, depending on what the context repo is, the ["repository +visibility" table](migration#repository-visibility) in the migration guide can be used to find out which repo an apparent name actually resolves to. * If the context repo is the main repo (`@@`): @@ -247,13 +251,14 @@ Of note, labels in the Bazel command line (including Starlark flags, label-typed flag values, and build/test target patterns) are treated as having the main repo as the context repo. -## Other {#other} +## Other -### How do I prepare and run an offline build? {#how-do-i-prepare-and-run-an-offline-build} +### How do I prepare and run an offline build? Use the `bazel fetch` command to prefetch repos. You can use the `--repo` flag (like `bazel fetch --repo @foo`) to fetch only the repo `@foo` (resolved in the -context of the main repo, see [question above](#which-is-evaluated-first-module-bazel-or-workspace)), or use a target +context of the main repo, see [question +above](#which-is-evaluated-first-module-bazel-or-workspace)), or use a target pattern (like `bazel fetch @foo//:bar`) to fetch all transitive dependencies of `@foo//:bar` (this is equivalent to `bazel build --nobuild @foo//:bar`). @@ -261,9 +266,9 @@ To make sure no fetches happen during a build, use `--nofetch`. More precisely, this makes any attempt to run a non-local repository rule fail. If you want to fetch repos _and_ modify them to test locally, consider using -the [`bazel vendor`](/external/vendor) command. +the [`bazel vendor`](vendor) command. -### How do I insulate my builds from the Internet? {#how-do-i-insulate-my-builds-from-the-internet} +### How do I insulate my builds from the Internet? Here are some websites on the publicly accessible Internet that a typical Bazel build relies on, and what you can do to insulate yourself from potential @@ -289,13 +294,13 @@ outages, especially as an enterprise Bazel user. download cache as mentioned in the previous bullet point will also help Bazel completely avoid accessing the Internet for source archives. -### How do I use HTTP proxies? {#how-do-i-use-http-proxies} +### How do I use HTTP proxies? Bazel respects the `http_proxy` and `HTTPS_PROXY` environment variables commonly accepted by other programs, such as [curl](https://everything.curl.dev/usingcurl/proxies/env.html). -### How do I make Bazel prefer IPv6 in dual-stack IPv4/IPv6 setups? {#ipv6} +### How do I make Bazel prefer IPv6 in dual-stack IPv4/IPv6 setups? On IPv6-only machines, Bazel can download dependencies with no changes. However, on dual-stack IPv4/IPv6 machines Bazel follows the same convention as Java, @@ -303,17 +308,21 @@ preferring IPv4 if enabled. In some situations, for example when the IPv4 network cannot resolve/reach external addresses, this can cause `Network unreachable` exceptions and build failures. In these cases, you can override Bazel's behavior to prefer IPv6 by using the -[`java.net.preferIPv6Addresses=true` system property](https://docs.oracle.com/javase/8/docs/api/java/net/doc-files/net-properties.html). +[`java.net.preferIPv6Addresses=true` system +property](https://docs.oracle.com/javase/8/docs/api/java/net/doc-files/net-properties.html). Specifically: -* Use `--host_jvm_args=-Djava.net.preferIPv6Addresses=true` [startup option](/docs/user-manual#startup-options), for example by adding the +* Use `--host_jvm_args=-Djava.net.preferIPv6Addresses=true` [startup + option](/docs/user-manual#startup-options), for example by adding the following line in your [`.bazelrc` file](/run/bazelrc): `startup --host_jvm_args=-Djava.net.preferIPv6Addresses=true` * When running Java build targets that need to connect to the internet (such as for integration tests), use the - `--jvmopt=-Djava.net.preferIPv6Addresses=true` [tool flag](/docs/user-manual#jvmopt). For example, include in your [`.bazelrc` file](/run/bazelrc): + `--jvmopt=-Djava.net.preferIPv6Addresses=true` [tool + flag](/docs/user-manual#jvmopt). For example, include in your [`.bazelrc` + file](/run/bazelrc): `build --jvmopt=-Djava.net.preferIPv6Addresses` @@ -321,9 +330,10 @@ Specifically: [`rules_jvm_external`](https://github.com/bazelbuild/rules_jvm_external) for dependency version resolution, also add `-Djava.net.preferIPv6Addresses=true` to the `COURSIER_OPTS` environment - variable to [provide JVM options for Coursier](https://github.com/bazelbuild/rules_jvm_external#provide-jvm-options-for-coursier-with-coursier_opts). + variable to [provide JVM options for + Coursier](https://github.com/bazelbuild/rules_jvm_external#provide-jvm-options-for-coursier-with-coursier_opts). -### Can repo rules be run remotely with remote execution? {#can-repo-rules-be-run-remotely-with-remote-execution} +### Can repo rules be run remotely with remote execution? No; or at least, not yet. Users employing remote execution services to speed up their builds may notice that repo rules are still run locally. For example, an @@ -346,7 +356,9 @@ build rules, which would naturally allow them to be run remotely, but conversely raise new architectural concerns (for example, the `query` commands would potentially need to run actions, complicating their design). -For more previous discussion on this topic, see [A way to support repositories that need Bazel for being fetched](https://github.com/bazelbuild/bazel/discussions/20464). +For more previous discussion on this topic, see [A way to support repositories +that need Bazel for being +fetched](https://github.com/bazelbuild/bazel/discussions/20464). [npm-semver]: https://docs.npmjs.com/about-semantic-versioning [cargo-semver]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#version-requirement-syntax diff --git a/external/lockfile.mdx b/external/lockfile.mdx index 6d66c2a6..d0eff0f8 100644 --- a/external/lockfile.mdx +++ b/external/lockfile.mdx @@ -14,7 +14,7 @@ in project dependencies. Furthermore, the lockfile improves stability by preventing unexpected updates or breaking changes in external libraries, thereby reducing the risk of introducing bugs. -## Lockfile Generation {#lockfile-generation} +## Lockfile Generation The lockfile is generated under the workspace root with the name `MODULE.bazel.lock`. It is created or updated during the build process, @@ -28,7 +28,7 @@ remains focused on the specific set of dependencies required for the current build, providing an accurate representation of the project's resolved dependencies. -## Lockfile Usage {#lockfile-usage} +## Lockfile Usage The lockfile can be controlled by the flag [`--lockfile_mode`](/reference/command-line-reference#flag--lockfile_mode) to @@ -50,7 +50,7 @@ lockfile. The available modes are: expected to always produce the same result. * `off`: The lockfile is neither checked nor updated. -## Lockfile Benefits {#lockfile-benefits} +## Lockfile Benefits The lockfile offers several benefits and can be utilized in various ways: @@ -69,7 +69,7 @@ The lockfile offers several benefits and can be utilized in various ways: locking the dependencies to specific versions, the risk of introducing bugs due to incompatible or untested updates is reduced. -### Hidden lockfile {#hidden-lockfile} +### Hidden lockfile Bazel also maintains another lockfile at `"$(bazel info output_base)"/MODULE.bazel.lock`. The format and contents of this @@ -78,7 +78,7 @@ optimization. While it can be deleted together with the output base via `bazel clean --expunge`, any need to do so is a bug in either Bazel itself or a module extension. -## Lockfile Contents {#lockfile-contents} +## Lockfile Contents The lockfile contains all the necessary information to determine whether the project state has changed. It also includes the result of building the project @@ -149,7 +149,7 @@ explanations for each section: } ``` -### Registry File Hashes {#registry-file-hashes} +### Registry File Hashes The `registryFileHashes` section contains the hashes of all files from remote registries accessed during module resolution. Since the resolution @@ -165,7 +165,7 @@ Bazel uses the hashes from the lockfile to look up registry files in the repository cache before downloading them, which speeds up subsequent resolutions. -### Selected Yanked Versions {#selected-yanked-versions} +### Selected Yanked Versions The `selectedYankedVersions` section contains the yanked versions of modules that were selected by module resolution. Since this usually result in an error @@ -177,7 +177,7 @@ This field is needed since, compared to module files, yanked version information is inherently mutable and thus can't be referenced by a hash. This information can be updated via `bazel mod deps --lockfile_mode=refresh`. -### Module Extensions {#module-extensions} +### Module Extensions The `moduleExtensions` section is a map that includes only the extensions used in the current invocation or previously invoked, while excluding any extensions @@ -212,7 +212,7 @@ Module extensions can opt out of being included in the lockfile by setting the returning metadata with `reproducible = True`. By doing so, they promise that they will always create the same repositories when given the same inputs. -## Best Practices {#best-practices} +## Best Practices To maximize the benefits of the lockfile feature, consider the following best practices: @@ -238,12 +238,12 @@ By following these best practices, you can effectively utilize the lockfile feature in Bazel, leading to more efficient, reliable, and collaborative software development workflows. -## Merge Conflicts {#merge-conflicts} +## Merge Conflicts The lockfile format is designed to minimize merge conflicts, but they can still happen. -### Automatic Resolution {#automatic-resolution} +### Automatic Resolution Bazel provides a custom [git merge driver](https://git-scm.com/docs/gitattributes#_defining_a_custom_merge_driver) @@ -271,7 +271,7 @@ git config --global merge.bazel-lockfile-merge.name "Merge driver for the Baze git config --global merge.bazel-lockfile-merge.driver "jq -s '${jq_script}' -- %O %A %B > %A.jq_tmp && mv %A.jq_tmp %A" ``` -### Manual Resolution {#manual-resolution} +### Manual Resolution Simple merge conflicts in the `registryFileHashes` and `selectedYankedVersions` fields can be safely resolved by keeping all the entries from both sides of the diff --git a/external/migration.mdx b/external/migration.mdx index c3030533..b6277bf2 100644 --- a/external/migration.mdx +++ b/external/migration.mdx @@ -4,14 +4,15 @@ title: 'Bzlmod Migration Guide' -Due to the [shortcomings of WORKSPACE](/external/overview#workspace-shortcomings), Bzlmod is replacing the +Due to the [shortcomings of +WORKSPACE](/external/overview#workspace-shortcomings), Bzlmod is replacing the legacy WORKSPACE system. The WORKSPACE file is already disabled in Bazel 8 (late 2024) and will be removed in Bazel 9 (late 2025). This guide helps you migrate your project to Bzlmod and drop WORKSPACE for managing external dependencies. -## Why migrate to Bzlmod? {#why-migrate-to-bzlmod} +## Why migrate to Bzlmod? -* There are many [advantages](/external/overview#benefits) compared to the legacy +* There are many [advantages](overview#benefits) compared to the legacy WORKSPACE system, which helps to ensure a healthy growth of the Bazel ecosystem. @@ -22,7 +23,7 @@ your project to Bzlmod and drop WORKSPACE for managing external dependencies. * Migration to Bzlmod is a necessary step in order to use future Bazel versions (mandatory in Bazel 9). -## How to migrate to Bzlmod? {#how-migrate-to-bzlmod} +## How to migrate to Bzlmod? Recommended migration process: @@ -30,15 +31,16 @@ Recommended migration process: streamline the migration process as much as possible. 2. If there are errors left after using the migration tool, resolve them manually. For understanding the main differences between concepts inside - `WORKSPACE` and `MODULE.bazel` files, check [WORKSPACE versus Bzlmod](#workspace-vs-bzlmod) section. + `WORKSPACE` and `MODULE.bazel` files, check [WORKSPACE versus + Bzlmod](#workspace-vs-bzlmod) section. -## WORKSPACE vs Bzlmod {#workspace-vs-bzlmod} +## WORKSPACE vs Bzlmod Bazel's WORKSPACE and Bzlmod offer similar features with different syntax. This section explains how to migrate from specific WORKSPACE functionalities to Bzlmod. -### Define the root of a Bazel workspace {#define-root} +### Define the root of a Bazel workspace The WORKSPACE file marks the source root of a Bazel project, this responsibility is replaced by MODULE.bazel in Bazel version 6.3 and later. With Bazel versions @@ -52,7 +54,7 @@ your workspace root, maybe with comments like: # See MODULE.bazel for external dependencies setup. ``` -### Enable Bzlmod in your bazelrc {#enable-bzlmod} +### Enable Bzlmod in your bazelrc `.bazelrc` lets you set flags that apply every time your run Bazel. To enable Bzlmod, use the `--enable_bzlmod` flag, and apply it to the `common` command so @@ -65,7 +67,7 @@ it applies to every command: common --enable_bzlmod ``` -### Specify repository name for your workspace {#specify-repo-name} +### Specify repository name for your workspace * **WORKSPACE** @@ -99,7 +101,7 @@ it applies to every command: ) ``` -### Fetch external dependencies as Bazel modules {#fetch-bazel-modules} +### Fetch external dependencies as Bazel modules If your dependency is a Bazel project, you should be able to depend on it as a Bazel module when it also adopts Bzlmod. @@ -140,7 +142,9 @@ Bazel module when it also adopts Bzlmod. * **Bzlmod** - With Bzlmod, as long as your dependency is available in [Bazel Central Registry](https://registry.bazel.build) or your custom [Bazel registry](/external/registry), you can simply depend on it with a + With Bzlmod, as long as your dependency is available in [Bazel Central + Registry](https://registry.bazel.build) or your custom [Bazel + registry](/external/registry), you can simply depend on it with a [`bazel_dep`](/rules/lib/globals/module#bazel_dep) directive. ```python @@ -171,7 +175,8 @@ repository. If your dependency is not a Bazel project or not yet available in any Bazel registry, you can introduce it using -[`use_repo_rule`](/external/module#use_repo_rule) or [module extensions](/external/extension). +[`use_repo_rule`](/external/module#use_repo_rule) or [module +extensions](/external/extension). * **WORKSPACE** @@ -245,7 +250,7 @@ registry, you can introduce it using use_repo(non_module_dependencies, "data_file") ``` -### Resolve conflict external dependencies with module extension {#conflict-deps-module-extension} +### Resolve conflict external dependencies with module extension A project can provide a macro that introduces external repositories based on inputs from its callers. But what if there are multiple callers in the @@ -255,7 +260,7 @@ Assume the project `foo` provides the following macro which takes `version` as an argument. ```python -## repositories.bzl in foo {#repositories.bzl-foo} +## repositories.bzl in foo load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") def data_deps(version = "1.0"): http_file( @@ -340,7 +345,7 @@ def data_deps(version = "1.0"): resolve this conflict and automatically select version `3.0` for the data dependency. -### Integrate third party package manager {#integrate-package-manager} +### Integrate third party package manager Following the last section, since module extension provides a way to collect information from the dependency graph, perform custom logic to resolve @@ -364,7 +369,7 @@ repository. [pkg-mgr-example]: https://github.com/bazelbuild/examples/tree/main/bzlmod/05-integrate_third_party_package_manager -### Detect toolchains on the host machine {#detect-toolchain} +### Detect toolchains on the host machine When Bazel build rules need to detect what toolchains are available on your host machine, they use repository rules to inspect the host machine and generate @@ -437,7 +442,7 @@ toolchain info as external repositories. use_repo(sh_config_ext, "local_config_sh") ``` -### Register toolchains & execution platforms {#register-toolchains} +### Register toolchains & execution platforms Following the last section, after introducing a repository hosting toolchain information (e.g. `local_config_sh`), you probably want to register the @@ -502,7 +507,7 @@ order of precedence during toolchain selection (from highest to lowest): [register_execution_platforms]: /rules/lib/globals/module#register_execution_platforms -### Introduce local repositories {#introduce-local-deps} +### Introduce local repositories You may need to introduce a dependency as a local repository when you need a local version of the dependency for debugging or you want to incorporate a @@ -551,7 +556,7 @@ directory in your workspace as external repository. extension. It's also trivial to implement a custom version of `local_repository` repository rule if this is a blocking issue for you. -### Bind targets {#bind-targets} +### Bind targets The [`bind`](/reference/be/workspace#bind) rule in WORKSPACE is deprecated and not supported in Bzlmod. It was introduced to give a target an alias in the @@ -588,7 +593,7 @@ away from this by: * Replace all usages of `//external:openssl` with `//third_party:openssl`. -### Fetch versus Sync {#fetch-sync} +### Fetch versus Sync Fetch and sync commands are used to download external repos locally and keep them updated. Sometimes also to allow building offline using the `--nofetch` @@ -609,12 +614,13 @@ flag after fetching all repos needed for a build. The fetch result is cached and to force a fetch you must include the `--force` option during the fetch process. -## Manual migration {#manual-migration} +## Manual migration This section provides useful information and guidance for your **manual** Bzlmod -migration process. For more automatized migration process, check [recommended migration process](#how-migrate-to-bzlmod) section. +migration process. For more automatized migration process, check [recommended +migration process](#how-migrate-to-bzlmod) section. -### Know your dependencies in WORKSPACE {#know-deps-in-workspace} +### Know your dependencies in WORKSPACE The first step of migration is to understand what dependencies you have. It could be hard to figure out what exact dependencies are introduced in the @@ -626,7 +632,8 @@ macros. Fortunately, the flag [`--experimental_repository_resolved_file`][resolved_file_flag] can help. This flag essentially generates a "lock file" of all fetched external -dependencies in your last Bazel command. You can find more details in this [blog post](https://blog.bazel.build/2018/07/09/bazel-sync-and-resolved-file.html). +dependencies in your last Bazel command. You can find more details in this [blog +post](https://blog.bazel.build/2018/07/09/bazel-sync-and-resolved-file.html). [resolved_file_flag]: /reference/command-line-reference#flag--experimental_repository_resolved_file @@ -667,11 +674,13 @@ You may also know `bazel query` can be used for inspecting repository rules with bazel query --output=build //external: ``` -While it is more convenient and much faster, [bazel query can lie about external dependency version](https://github.com/bazelbuild/bazel/issues/12947), +While it is more convenient and much faster, [bazel query can lie about +external dependency version](https://github.com/bazelbuild/bazel/issues/12947), so be careful using it! Querying and inspecting external -dependencies with Bzlmod is going to achieved by a [new subcommand](https://github.com/bazelbuild/bazel/issues/15365). +dependencies with Bzlmod is going to achieved by a [new +subcommand](https://github.com/bazelbuild/bazel/issues/15365). -#### Built-in default dependencies {#builtin-default-deps} +#### Built-in default dependencies If you check the file generated by `--experimental_repository_resolved_file`, you are going to find many dependencies that are not defined in your WORKSPACE. @@ -684,7 +693,7 @@ Bazel module. [bazel_tools]: https://github.com/bazelbuild/bazel/blob/master/src/MODULE.tools -### Hybrid mode for gradual migration {#hybrid-mode} +### Hybrid mode for gradual migration Bzlmod and WORKSPACE can work side by side, which allows migrating dependencies from the WORKSPACE file to Bzlmod to be a gradual process. @@ -693,7 +702,7 @@ Note: In practice, loading "*_deps" macros in WORKSPACE often causes confusions with Bzlmod dependencies, therefore we recommend starting with a WORKSPACE.bzlmod file and avoid loading transitive dependencies with macros. -#### WORKSPACE.bzlmod {#workspace.bzlmod} +#### WORKSPACE.bzlmod During the migration, Bazel users may need to switch between builds with and without Bzlmod enabled. WORKSPACE.bzlmod support is implemented to make the @@ -713,10 +722,11 @@ Using the WORKSPACE.bzlmod file can make the migration easier because: * When Bzlmod is enabled, you can better track what dependencies are left to migrate with WORKSPACE.bzlmod. -#### Repository visibility {#repository-visibility} +#### Repository visibility Bzlmod is able to control which other repositories are visible from a given -repository, check [repository names and strict deps](/external/module#repository_names_and_strict_deps) for more details. +repository, check [repository names and strict +deps](/external/module#repository_names_and_strict_deps) for more details. Here is a summary of repository visibilities from different types of repositories when also taking WORKSPACE into consideration. @@ -729,7 +739,8 @@ repositories when also taking WORKSPACE into consideration. | WORKSPACE Repos | All visible | Not visible | Not visible | All visible | Note: For the root module, if a repository `@foo` is defined in WORKSPACE and -`@foo` is also used as an [apparent repository name](/external/overview#apparent-repo-name) in MODULE.bazel, then `@foo` +`@foo` is also used as an [apparent repository +name](/external/overview#apparent-repo-name) in MODULE.bazel, then `@foo` refers to the one introduced in MODULE.bazel. Note: For a module extension generated repository `@bar`, if `@foo` is used as @@ -738,7 +749,7 @@ another repository generated by the same module extension and direct dependencies of the module hosting the module extension, then for repository `@bar`, `@foo` refers to the latter. -### Manual migration process {#manual-migration-process} +### Manual migration process A typical Bzlmod migration process can look like this: @@ -753,7 +764,7 @@ A typical Bzlmod migration process can look like this: extension, or leave it in the WORKSPACE.bzlmod for later migration. 1. Go back to 4 and repeat until all dependencies are available. -## Publish Bazel modules {#publish-modules} +## Publish Bazel modules If your Bazel project is a dependency for other projects, you can publish your project in the [Bazel Central Registry](https://registry.bazel.build/). @@ -774,7 +785,9 @@ the project. Take note of a few things when creating the source archive: GitHub isn't going to guarantee the checksum of source archives generated on demand. In short, URLs in the form of `https://github.com///releases/download/...` is considered stable - while `https://github.com///archive/...` is not. Check [GitHub Archive Checksum Outage](https://blog.bazel.build/2023/02/15/github-archive-checksum.html) + while `https://github.com///archive/...` is not. Check [GitHub + Archive Checksum + Outage](https://blog.bazel.build/2023/02/15/github-archive-checksum.html) for more context. * **Make sure the source tree follows the layout of the original repository.** @@ -803,10 +816,11 @@ Pull Request. [bcr_contrib_guide]: https://github.com/bazelbuild/bazel-central-registry/tree/main/docs#contribute-a-bazel-module -It is **highly recommended** to set up the [Publish to BCR](https://github.com/bazel-contrib/publish-to-bcr) GitHub App for your +It is **highly recommended** to set up the [Publish to +BCR](https://github.com/bazel-contrib/publish-to-bcr) GitHub App for your repository to automate the process of submitting your module to the BCR. -## Best practices {#best-practices} +## Best practices This section documents a few best practices you should follow for better managing your external dependencies. @@ -831,14 +845,14 @@ still build without dev dependencies and overrides. -## Community migration progress {#migration-progress} +## Community migration progress You can check the [Bazel Central Registry](https://registry.bazel.build) to find out if your dependencies are already available. Otherwise feel free to join this [GitHub discussion](https://github.com/bazelbuild/bazel/discussions/18329) to upvote or post the dependencies that are blocking your migration. -## Report issues {#reporting-issues} +## Report issues Please check the [Bazel GitHub issue list][bzlmod_github_issue] for known Bzlmod issues. Feel free to file new issues or feature requests that can help unblock diff --git a/external/migration_tool.mdx b/external/migration_tool.mdx index cf59c153..fe3c591c 100644 --- a/external/migration_tool.mdx +++ b/external/migration_tool.mdx @@ -14,7 +14,7 @@ management system. **Note**: If you want to try out the AI driven Bzlmod migration, check [Bzlmod Migration Agent Setup][gemini_cli_setup]. -## Core Functionality {#migration-tool-core-functionality} +## Core Functionality The script's primary functions are: @@ -52,7 +52,7 @@ The migration tool supports: recommendations for correctness. * Use the migration tool with Bazel 7 (not supported with Bazel 8). -## How to Use the Migration Tool {#migration-tool-how-to-use} +## How to Use the Migration Tool Before you begin: @@ -65,7 +65,7 @@ Before you begin: bazel build --nobuild --enable_workspace --noenable_bzlmod ``` -### Command for running the script {#migration-script-command} +### Command for running the script Once the prerequisites are met, run the following commands to use the migration tool: @@ -86,7 +86,7 @@ cd <your project root> migrate2bzlmod -t <targets> -### Files generated by this script {#migration-script-files} +### Files generated by this script * `MODULE.bazel` - The central manifest file for Bzlmod, which declares the project's metadata and its direct dependencies on other Bazel modules. @@ -102,9 +102,10 @@ migrate2bzlmod -t <targets> script. * `extension_for_XXX` - A file containing a module extension definition. The migration tool generates these files for dependencies that - are not standard Bazel modules but can be managed using Bzlmod's [module extensions](/external/extension). + are not standard Bazel modules but can be managed using Bzlmod's [module + extensions](/external/extension). -### Flags {#migration-script-flags} +### Flags Flags available in this migration scripts are: @@ -115,13 +116,13 @@ Flags available in this migration scripts are: dependencies, introduce them in MODULE.bazel and rerun generation of resolved dependencies. -### Post-migration cleanup {#post-migration-cleanup} +### Post-migration cleanup * Delete `migration_info.md`, `resolved_deps.py` and `query_direct_deps`. * Clean up comments from `MODULE.bazel` file which were used for the migration, such as `# -- bazel_dep definitions -- #`. -## Migration Example {#migration-tool-example} +## Migration Example To see the migration script in action, consider the following scenario when Python, Maven and Go dependencies are declared in `WORKSPACE` file. @@ -299,7 +300,8 @@ def my_custom_macro(name): The end goal is to have `MODULE.bazel` file and delete the `WORKSPACE` file, without impacting the user experience. -The first step is to follow [How to Use the Migration Tool](#migration-tool-how-to-use), which mostly is checking the bazel version +The first step is to follow [How to Use the Migration +Tool](#migration-tool-how-to-use), which mostly is checking the bazel version (it must be Bazel 7) and adding an alias to the migration script. Then, running `migrate2bzlmod -t=//...` outputs: @@ -341,7 +343,7 @@ which gives the following important information: * `migration_info.md` file contains details about the migration. Check details [at this section](#migration-tool-report-generation). -### Transformations {#migration-tool-transformations} +### Transformations This section illustrates the migration of code from the `WORKSPACE` file to `MODULE.bazel`. @@ -595,12 +597,12 @@ extension_for_my_custom_macro = module_extension(implementation = _extension_for
-## Tips with debugging {#migration-tool-tips} +## Tips with debugging This section provides useful commands and information to help debug issues that may arise during the Bzlmod migration. -### Useful tips {#debugging-useful-tips} +### Useful tips * Override version - Not rarely it happens that upgrading the version of a dependency causes troubles. Bzlmod could change the version of the @@ -629,10 +631,11 @@ may arise during the Bzlmod migration. `bazel vendor --enable_bzlmod --vendor_dir=vendor_src --repo=@protobuf` -### Migration Report Generation {#migration-tool-report-generation} +### Migration Report Generation This file is updated with each run of the migration script or it's generated -from scratch if it's the first run or if the [`--i` flag](#migration-script-flags) is used. The report contains: +from scratch if it's the first run or if the [`--i` +flag](#migration-script-flags) is used. The report contains: * Command for local testing. * List of direct dependencies (at least the ones which are directly used in @@ -703,7 +706,7 @@ from scratch if it's the first run or if the [`--i` flag](#migration-script-flag to the `MODULE.bazel` file. * `gazelle_override` is used for adding specific directives. -## Useful links {#useful-links} +## Useful links * Official pages for the external extensions * [rules_jvm_external](https://github.com/bazelbuild/rules_jvm_external/blob/master/docs/bzlmod.md) @@ -714,7 +717,7 @@ from scratch if it's the first run or if the [`--i` flag](#migration-script-flag * [Moving to Bzlmod](https://www.youtube.com/watch?v=W9uXRYLVHUk). * [How Uber Manages Go Dependencies with Bzlmod](https://www.youtube.com/watch?v=hIqzkUE_pSY). -## Feedback {#feedback} +## Feedback If you would like to contribute, do so by creating an Issue or PR at [bazel-central-registry](https://github.com/bazelbuild/bazel-central-registry). diff --git a/external/mod-command.mdx b/external/mod-command.mdx index 9eea1572..8ca69da8 100644 --- a/external/mod-command.mdx +++ b/external/mod-command.mdx @@ -9,7 +9,7 @@ why a certain module or a version of a module is present in the graph, view the repo definitions backing modules, inspect usages of module extensions and repos they generate, among other functions. -## Syntax {#syntax} +## Syntax ```sh bazel mod [] [ [...]] @@ -64,9 +64,11 @@ The available subcommands and their respective required arguments are: * ``: All present versions of the module ``. -* `@`: The repo with the given [apparent name](/external/overview#apparent-repo-name) in the context of the `--base_module`. +* `@`: The repo with the given [apparent + name](overview#apparent-repo-name) in the context of the `--base_module`. -* `@@`: The repo with the given [canonical name](/external/overview#canonical-repo-name). +* `@@`: The repo with the given [canonical + name](overview#canonical-repo-name). In a context requiring specifying modules, ``s referring to repos that correspond to modules (as opposed to extension-generated repos) can also be @@ -90,14 +92,15 @@ The following options only affect the subcommands that print graphs (`graph`, information about the version resolution of each module. If the module version changed during resolution, show either which version replaced it or what was the original version, the reason it was replaced, and which modules - requested the new version if the reason was [Minimal Version Selection](/external/module#version-selection). + requested the new version if the reason was [Minimal Version + Selection](module#version-selection). * `--include_unused` *default: "false"*: Include in the output graph the modules which were originally present in the dependency graph, but became unused after module resolution. -* `--extension_info mode`: Include information about the module extension - usages as part of the output graph (see [example](#mod-example7)). `mode` +* `--extension_info `: Include information about the module extension + usages as part of the output graph (see [example](#mod-example7)). `` can be one of: * `hidden` *(default)*: Don't show anything about extensions. @@ -137,8 +140,8 @@ The following options only affect the subcommands that print graphs (`graph`, Therefore, the `"ascii"` charset is present to also support the usage on legacy platforms which cannot use Unicode. -* `--output mode`: Include information about the module extension usages as - part of the output graph. `mode' can be one of: +* `--output `: Include information about the module extension usages as + part of the output graph. `' can be one of: * `text` *(default)*: A human-readable representation of the output graph (flattened as a tree). @@ -157,8 +160,8 @@ The following options only affect the subcommands that print graphs (`graph`, ### show_repo options `show_repo` supports a different set of output formats: -* `--output mode`: Change how repository definitions are displayed. - `mode` can be one of: +* `--output `: Change how repository definitions are displayed. + `` can be one of: * `text` *(default)*: Display repo definitions in Starlark. * `streamed_proto`: Prints a [length-delimited](https://protobuf.dev/programming-guides/encoding/#size-limit) @@ -181,7 +184,7 @@ Other options include: * `--extension_usages [,[,...]]`: Filters `show_extension` to only display extension usages from the specified modules. -## Examples {#examples} +## Examples Some possible usages of the `mod` command on a real Bazel project are showcased below to give you a general idea on how you can use it to inspect your project's @@ -210,10 +213,10 @@ use_repo(toolchains, my_jdk="remotejdk17_linux")
- Graph Before Resolution + Graph Before Resolution
Graph Before Resolution
-{/* digraph mygraph { +
- Graph After Resolution + Graph After Resolution
Graph After Resolution
-{/* digraph mygraph { + diff --git a/external/module.mdx b/external/module.mdx index f4fe31a4..b3f035da 100644 --- a/external/module.mdx +++ b/external/module.mdx @@ -32,7 +32,7 @@ By default, Bazel then [selects](#version-selection) one version of each module to use. Bazel represents each module with a repo, and consults the registry again to learn how to define each of the repos. -## Version format {#version-format} +## Version format Bazel has a diverse ecosystem and projects use various versioning schemes. The most popular by far is [SemVer](https://semver.org), but there are @@ -56,9 +56,10 @@ Any valid SemVer version is a valid Bazel module version. Additionally, two SemVer versions `a` and `b` compare `a < b` if and only if the same holds when they're compared as Bazel module versions. -Finally, to learn more about module versioning, [see the `MODULE.bazel` FAQ](/external/faq#module-versioning-best-practices). +Finally, to learn more about module versioning, [see the `MODULE.bazel` +FAQ](faq#module-versioning-best-practices). -## Version selection {#version-selection} +## Version selection Consider the diamond dependency problem, a staple in the versioned dependency management space. Suppose you have the dependency graph: @@ -110,7 +111,8 @@ serves multiple purposes: version, regardless of which versions of the dependency are requested in the dependency graph. * With the `registry` attribute, you can force this dependency to come from a - specific registry, instead of following the normal [registry selection](/external/registry#selecting_registries) process. + specific registry, instead of following the normal [registry + selection](/external/registry#selecting_registries) process. * With the `patch*` attributes, you can specify a set of patches to apply to the downloaded module. @@ -151,19 +153,22 @@ Bazel supports the following non-registry overrides: Note that setting a version value in the source archive `MODULE.bazel` can have downsides when the module is being overridden with a non-registry override. To -learn more about this [see the `MODULE.bazel` FAQ](/external/faq#module-versioning-best-practices). +learn more about this [see the `MODULE.bazel` +FAQ](faq#module-versioning-best-practices). -## Define repos that don't represent Bazel modules {#use_repo_rule} +## Define repos that don't represent Bazel modules With `bazel_dep`, you can define repos that represent other Bazel modules. Sometimes there is a need to define a repo that does _not_ represent a Bazel module; for example, one that contains a plain JSON file to be read as data. -In this case, you could use the [`use_repo_rule` directive](/rules/lib/globals/module#use_repo_rule) to directly define a repo +In this case, you could use the [`use_repo_rule` +directive](/rules/lib/globals/module#use_repo_rule) to directly define a repo by invoking a repo rule. This repo will only be visible to the module it's defined in. -Under the hood, this is implemented using the same mechanism as [module extensions](/external/extension), which lets you define repos with more +Under the hood, this is implemented using the same mechanism as [module +extensions](/external/extension), which lets you define repos with more flexibility. ## Repository names and strict deps diff --git a/external/overview.mdx b/external/overview.mdx index ed819f7e..36464341 100644 --- a/external/overview.mdx +++ b/external/overview.mdx @@ -13,9 +13,10 @@ machine outside your current workspace. This document gives an overview of the system before examining some of the concepts in more detail. -## Overview of the system {#overview} +## Overview of the system -Bazel's external dependency system works on the basis of [*Bazel modules*](#module), each of which is a versioned Bazel project, and +Bazel's external dependency system works on the basis of [*Bazel +modules*](#module), each of which is a versioned Bazel project, and [*repositories*](#repository) (or repos), which are directory trees containing source files. @@ -32,7 +33,8 @@ bazel_dep(name = "platforms", version = "0.0.11") ``` From there, Bazel looks up all transitive dependency modules in a -[*Bazel registry*](/external/registry) — by default, the [Bazel Central Registry](https://bcr.bazel.build/). The registry provides the +[*Bazel registry*](registry) — by default, the [Bazel Central +Registry](https://bcr.bazel.build/). The registry provides the dependencies' `MODULE.bazel` files, which allows Bazel to discover the entire transitive dependency graph before performing version resolution. @@ -42,7 +44,7 @@ Bazel consults the registry again to learn how to define a repo for each module of the time, these are just archives downloaded from the internet and extracted. Modules can also specify customized pieces of data called *tags*, which are -consumed by [*module extensions*](/external/extension) after module resolution +consumed by [*module extensions*](extension) after module resolution to define additional repos. These extensions can perform actions like file I/O and sending network requests. Among other things, they allow Bazel to interact with other package management systems while also respecting the dependency graph @@ -54,23 +56,23 @@ created by module extensions -- form the [*workspace*](#workspace) together. External repos (non-main repos) are fetched on demand, for example when they're referred to by labels (like `@repo//pkg:target`) in BUILD files. -## Benefits {#benefits} +## Benefits Bazel's external dependency system offers a wide range of benefits. -### Automatic Dependency Resolution {#automatic-dependency-resolution} +### Automatic Dependency Resolution - **Deterministic Version Resolution**: Bazel adopts the deterministic - [MVS](/external/module#version-selection) version resolution algorithm, + [MVS](module#version-selection) version resolution algorithm, minimizing conflicts and addressing diamond dependency issues. - **Simplified Dependency Management**: `MODULE.bazel` declares only direct dependencies, while transitive dependencies are automatically resolved, providing a clearer overview of the project's dependencies. -- **[Strict Dependency visibility](/external/module#repository_names_and_strict_deps)**: +- **[Strict Dependency visibility](module#repository_names_and_strict_deps)**: Only direct dependencies are visible, ensuring correctness and predictability. -### Ecosystem Integration {#ecosystem-integration} +### Ecosystem Integration - **[Bazel Central Registry](https://registry.bazel.build/)**: A centralized repository for discovering and managing common dependencies as Bazel @@ -91,37 +93,38 @@ Bazel's external dependency system offers a wide range of benefits. * [rules_rust](https://bazelbuild.github.io/rules_rust/crate_universe_bzlmod.html) for Cargo. -### Advanced Features {#advanced-features} +### Advanced Features -- **[Module Extensions](/external/extension)**: The +- **[Module Extensions](extension)**: The [`use_repo_rule`](/rules/lib/globals/module#use_repo_rule) and module extension features allow flexible use of custom repository rules and resolution logic to introduce any non-Bazel dependencies. -- **[`bazel mod` Command](/external/mod-command)**: The sub-command offers +- **[`bazel mod` Command](mod-command)**: The sub-command offers powerful ways to inspect external dependencies. You know exactly how an external dependency is defined and where it comes from. -- **[Vendor Mode](/external/vendor)**: Pre-fetch the exact external dependencies you +- **[Vendor Mode](vendor)**: Pre-fetch the exact external dependencies you need to facilitate offline builds. -- **[Lockfile](/external/lockfile)**: The lockfile improves build reproducibility and +- **[Lockfile](lockfile)**: The lockfile improves build reproducibility and accelerates dependency resolution. -- **(Upcoming) [BCR Provenance Attestations](https://github.com/bazelbuild/bazel-central-registry/discussions/2721)**: +- **(Upcoming) [BCR Provenance + Attestations](https://github.com/bazelbuild/bazel-central-registry/discussions/2721)**: Strengthen supply chain security by ensuring verified provenance of dependencies. -## Concepts {#concepts} +## Concepts This section gives more detail on concepts related to external dependencies. -### Module {#module} +### Module A Bazel project that can have multiple versions, each of which can have dependencies on other modules. In a local Bazel workspace, a module is represented by a repository. -For more details, see [Bazel modules](/external/module). +For more details, see [Bazel modules](module). -### Repository {#repository} +### Repository A directory tree with a boundary marker file at its root, containing source files that can be used in a Bazel build. Often shortened to just **repo**. @@ -132,14 +135,14 @@ legacy contexts, `WORKSPACE` or `WORKSPACE.bazel`. Any repo boundary marker file will signify the boundary of a repo; multiple such files can coexist in a directory. -### Main repository {#main-repository} +### Main repository The repository in which the current Bazel command is being run. The root of the main repository is also known as the **workspace root**. -### Workspace {#workspace} +### Workspace The environment shared by all Bazel commands run in the same main repository. It encompasses the main repo and the set of all defined external repos. @@ -148,7 +151,7 @@ Note that historically the concepts of "repository" and "workspace" have been conflated; the term "workspace" has often been used to refer to the main repository, and sometimes even used as a synonym of "repository". -### Canonical repository name {#canonical-repo-name} +### Canonical repository name The name by which a repository is always addressable. Within the context of a workspace, each repository has a single canonical name. A target inside a repo @@ -157,7 +160,7 @@ whose canonical name is `canonical_name` can be addressed by the label The main repository always has the empty string as the canonical name. -### Apparent repository name {#apparent-repo-name} +### Apparent repository name The name by which a repository is addressable in the context of a certain other repo. This can be thought of as a repo's "nickname": The repo with the canonical @@ -169,7 +172,7 @@ name `michael` might have the apparent name `mike` in the context of the repo Conversely, this can be understood as a **repository mapping**: each repo maintains a mapping from "apparent repo name" to a "canonical repo name". -### Repository rule {#repo-rule} +### Repository rule A schema for repository definitions that tells Bazel how to materialize a repository. For example, it could be "download a zip archive from a certain URL @@ -177,7 +180,7 @@ and extract it", or "fetch a certain Maven artifact and make it available as a `java_import` target", or simply "symlink a local directory". Every repo is **defined** by calling a repo rule with an appropriate number of arguments. -See [Repository rules](/external/repo) for more information about how to write +See [Repository rules](repo) for more information about how to write your own repository rules. The most common repo rules by far are @@ -186,7 +189,7 @@ from a URL and extracts it, and [`local_repository`](/rules/lib/repo/local#local_repository), which symlinks a local directory that is already a Bazel repository. -### Fetch a repository {#fetch-repository} +### Fetch a repository The action of making a repo available on local disk by running its associated repo rule. The repos defined in a workspace are not available on local disk @@ -208,7 +211,7 @@ failure. See [fetch options](/reference/command-line-reference#fetch-options) for more information about controlling fetch. -### Directory layout {#directory-layout} +### Directory layout After being fetched, the repo can be found in the subdirectory `external` in the [output base](/remote/output-directories), under its canonical name. @@ -220,7 +223,7 @@ canonical name `canonical_name`: ls $(bazel info output_base)/external/ canonical_name ``` -### REPO.bazel file {#repo.bazel} +### REPO.bazel file The [`REPO.bazel`](/rules/lib/globals/repo) file is used to mark the topmost boundary of the directory tree that constitutes a repo. It doesn't need to @@ -228,7 +231,8 @@ contain anything to serve as a repo boundary file; however, it can also be used to specify some common attributes for all build targets inside the repo. The syntax of a `REPO.bazel` file is similar to `BUILD` files, except that no -`load` statements are supported. The `repo()` function takes the same arguments as the [`package()` function](/reference/be/functions#package) in `BUILD` files; whereas `package()` +`load` statements are supported. The `repo()` function takes the same arguments as the [`package()` +function](/reference/be/functions#package) in `BUILD` files; whereas `package()` specifies common attributes for all build targets inside the package, `repo()` analogously does so for all build targets inside the repo. @@ -241,7 +245,7 @@ repo( ) ``` -## The legacy WORKSPACE system {#workspace-system} +## The legacy WORKSPACE system In older Bazel versions (before 9.0), external dependencies were introduced by defining repos in the `WORKSPACE` (or `WORKSPACE.bazel`) file. This file has a @@ -266,7 +270,7 @@ all other repos. See the [full list](/rules/lib/globals/workspace) of functions available in `WORKSPACE` files. -### Shortcomings of the `WORKSPACE` system {#workspace-shortcomings} +### Shortcomings of the `WORKSPACE` system In the years after the `WORKSPACE` system was introduced, users reported many pain points, including: @@ -289,10 +293,10 @@ pain points, including: Due to the shortcomings of WORKSPACE, the new module-based system (codenamed "Bzlmod") gradually replaced the legacy WORKSPACE system between Bazel 6 and 9. -Read the [Bzlmod migration guide](/external/migration) on how to migrate +Read the [Bzlmod migration guide](migration) on how to migrate to Bzlmod. -### External links on Bzlmod {#external-links} +### External links on Bzlmod * [Bzlmod usage examples in bazelbuild/examples](https://github.com/bazelbuild/examples/tree/main/bzlmod) * [Bazel External Dependencies Overhaul](https://docs.google.com/document/d/1moQfNcEIttsk6vYanNKIy3ZuK53hQUFq1b1r0rmsYVg/edit) diff --git a/external/registry.mdx b/external/registry.mdx index 2bd0c114..45ce13b3 100644 --- a/external/registry.mdx +++ b/external/registry.mdx @@ -21,15 +21,17 @@ An index registry must have the following format: * `/modules`: A directory containing a subdirectory for each module in this registry * `/modules/$MODULE`: A directory containing a subdirectory for each version - of the module named `$MODULE`, as well as the [`metadata.json` file](#metadata-json) containing metadata for this module. + of the module named `$MODULE`, as well as the [`metadata.json` + file](#metadata-json) containing metadata for this module. * `/modules/$MODULE/$VERSION`: A directory containing the following files: * `MODULE.bazel`: The `MODULE.bazel` file of this module version. Note that this is the `MODULE.bazel` file read during Bazel's external dependency resolution, _not_ the one from the source archive (unless - there's a [non-registry override](/external/module#non-registry_overrides)). Also note that it's + there's a [non-registry + override](/external/module#non-registry_overrides)). Also note that it's best to use this file to set the version of a release and avoid doing so in the source archive `MODULE.bazel` file. To learn more about module - versioning, [see the FAQ](/external/faq#module-versioning-best-practices). + versioning, [see the FAQ](faq.md#module-versioning-best-practices). * [`source.json`](#source-json): A JSON file containing information on how to fetch the source of this module version * `patches/`: An optional directory containing patch files, only used when @@ -37,7 +39,7 @@ An index registry must have the following format: * `overlay/`: An optional directory containing overlay files, only used when `source.json` has "archive" type -### `bazel_registry.json` {#bazel-registry-json} +### `bazel_registry.json` `bazel_registry.json` is an optional file that specifies metadata applying to the entire registry. It can contain the following fields: @@ -55,7 +57,7 @@ the entire registry. It can contain the following fields: * `module_base_path`: a string, specifying the base path for modules with `local_path` type in the `source.json` file -### `metadata.json` {#metadata-json} +### `metadata.json` `metadata.json` is an optional JSON file containing information about the module, with the following fields: @@ -63,14 +65,15 @@ module, with the following fields: * `versions`: An array of strings, each denoting a version of the module available in this registry. This array should match the children of the module directory. -* `yanked_versions`: A JSON object specifying the [*yanked* versions](/external/module#yanked_versions) of this module. The keys +* `yanked_versions`: A JSON object specifying the [*yanked* + versions](/external/module#yanked_versions) of this module. The keys should be versions to yank, and the values should be descriptions of why the version is yanked, ideally containing a link to more information. Note that the BCR requires more information in the `metadata.json` file. -### `source.json` {#source-json} +### `source.json` `source.json` is a required JSON file containing information about how to fetch a specific version of a module. The schema of this file depends on its `type` @@ -129,12 +132,12 @@ field, which defaults to `archive`. `--registry=file://`. Otherwise, Bazel will throw an error -## Bazel Central Registry {#bazel-central-registry} +## Bazel Central Registry -The Bazel Central Registry (BCR) at https://bcr.bazel.build/ is an index +The Bazel Central Registry (BCR) at is an index registry with contents backed by the GitHub repo [`bazelbuild/bazel-central-registry`][bcr-repo]. You can browse its contents -using the web frontend at https://registry.bazel.build/. +using the web frontend at . The Bazel community maintains the BCR, and contributors are welcome to submit pull requests. See the [BCR contribution diff --git a/external/repo.mdx b/external/repo.mdx index 958d403e..b878f030 100644 --- a/external/repo.mdx +++ b/external/repo.mdx @@ -76,7 +76,8 @@ specified. The input parameter `repository_ctx` can be used to access attribute values, and non-hermetic functions (finding a binary, executing a binary, creating a file in -the repository or downloading a file from the Internet). See [the API docs](/rules/lib/builtins/repository_ctx) for more context. Example: +the repository or downloading a file from the Internet). See [the API +docs](/rules/lib/builtins/repository_ctx) for more context. Example: ```python def _impl(repository_ctx): @@ -145,7 +146,8 @@ definition has the `configure` attribute set, use `bazel fetch --force ## Examples -- [C++ auto-configured toolchain](https://cs.opensource.google/bazel/bazel/+/master:tools/cpp/cc_configure.bzl;drc=644b7d41748e09eff9e47cbab2be2263bb71f29a;l=176): +- [C++ auto-configured + toolchain](https://cs.opensource.google/bazel/bazel/+/master:tools/cpp/cc_configure.bzl;drc=644b7d41748e09eff9e47cbab2be2263bb71f29a;l=176): it uses a repo rule to automatically create the C++ configuration files for Bazel by looking for the local C++ compiler, the environment and the flags the C++ compiler supports. diff --git a/external/vendor.mdx b/external/vendor.mdx index ab82c46c..f2642ddf 100644 --- a/external/vendor.mdx +++ b/external/vendor.mdx @@ -8,7 +8,7 @@ Vendor mode is a feature that lets you create a local copy of external dependencies. This is useful for offline builds, or when you want to control the source of an external dependency. -## Enable vendor mode {#enable-vendor-mode} +## Enable vendor mode You can enable vendor mode by specifying `--vendor_dir` flag. @@ -22,10 +22,12 @@ common --vendor_dir=vendor_src The vendor directory can be either a relative path to your workspace root or an absolute path. -## Vendor a specific external repository {#vendor-specific-repository} +## Vendor a specific external repository You can use the `vendor` command with the `--repo` flag to specify which repo -to vendor, it accepts both [canonical repo name](/external/overview#canonical-repo-name) and [apparent repo name](/external/overview#apparent-repo-name). +to vendor, it accepts both [canonical repo +name](/external/overview#canonical-repo-name) and [apparent repo +name](/external/overview#apparent-repo-name). For example, running: @@ -42,7 +44,7 @@ bazel vendor --vendor_dir=vendor_src --repo=@@rules_cc+ will both get rules_cc to be vendored under `/vendor_src/rules_cc+`. -## Vendor external dependencies for given targets {#vendor-target-dependencies} +## Vendor external dependencies for given targets To vendor all external dependencies required for building given target patterns, you can run `bazel vendor `. @@ -60,7 +62,7 @@ Under the hood, it's doing a `bazel build --nobuild` command to analyze the target patterns, therefore build flags could be applied to this command and affect the result. -### Build the target offline {#build-the-target-offline} +### Build the target offline With the external dependencies vendored, you can build the target offline by @@ -78,7 +80,7 @@ Note: If you make changes to the targets to build, the external dependencies, the build configuration, or the Bazel version, you may need to re-vendor to make sure offline build still works. -## Vendor all external dependencies {#vendor-all-dependencies} +## Vendor all external dependencies To vendor all repos in your transitive external dependencies graph, you can run: @@ -95,7 +97,7 @@ Note that vendoring all dependencies has a few **disadvantages**: Therefore, consider vendoring for specific targets first. -## Configure vendor mode with VENDOR.bazel {#configure-vendor-mode} +## Configure vendor mode with VENDOR.bazel You can control how given repos are handled with the VENDOR.bazel file located under the vendor directory. @@ -130,7 +132,7 @@ Note: Repository rules with [`configure`](/rules/lib/globals/bzl#repository_rule.configure) set to true are always excluded from vendoring. -## Understand how vendor mode works {#how-vendor-mode-works} +## Understand how vendor mode works Bazel fetches external dependencies of a project under `$(bazel info output_base)/external`. Vendoring external dependencies means moving out @@ -154,14 +156,14 @@ without pinning the repo, the changed vendored source will be used, but it will be overwritten if its existing marker file is outdated and the repo is vendored again. -### Vendor registry files {#vendor-registry-files} +### Vendor registry files Bazel has to perform the Bazel module resolution in order to fetch external dependencies, which may require accessing registry files through internet. To achieve offline build, Bazel vendors all registry files fetched from network under the `/_registries` directory. -### Vendor symlinks {#vendor-symlinks} +### Vendor symlinks External repositories may contain symlinks pointing to other files or directories. To make sure symlinks work correctly, Bazel uses the following diff --git a/help.mdx b/help.mdx index e6a1d79e..9956d928 100644 --- a/help.mdx +++ b/help.mdx @@ -7,7 +7,7 @@ title: 'Getting Help' This page lists Bazel resources beyond the documentation and covers how to get support from the Bazel team and community. -## Search existing material {#search-material} +## Search existing material In addition to the documentation, you can find helpful information by searching: @@ -17,7 +17,7 @@ In addition to the documentation, you can find helpful information by searching: * [Stack Overflow](https://stackoverflow.com/questions/tagged/bazel) * [`awesome-bazel` resources](https://github.com/jin/awesome-bazel) -## Watch videos {#videos} +## Watch videos There are recordings of Bazel talks at various conferences, such as: @@ -34,7 +34,7 @@ There are recordings of Bazel talks at various conferences, such as: * Bazel day on [Google Open Source Live](https://opensourcelive.withgoogle.com/events/bazel) -## Ask the Bazel community {#community} +## Ask the Bazel community If there are no existing answers, you can ask the community by: @@ -44,11 +44,12 @@ If there are no existing answers, you can ask the community by: * Chatting with other Bazel contributors on [Slack](https://slack.bazel.build/) * Consulting a [Bazel community expert](/community/experts) -## Understand Bazel's support level {#support-level} +## Understand Bazel's support level Please read the [release page](/release) to understand Bazel's release model and what level of support Bazel provides. -## File a bug {#file-bug} +## File a bug -If you encounter a bug or want to request a feature, file a [GitHub Issue](https://github.com/bazelbuild/bazel/issues). +If you encounter a bug or want to request a feature, file a [GitHub +Issue](https://github.com/bazelbuild/bazel/issues). diff --git a/install/bazelisk.mdx b/install/bazelisk.mdx index 3acb1147..a3189cb7 100644 --- a/install/bazelisk.mdx +++ b/install/bazelisk.mdx @@ -18,12 +18,13 @@ For more details, see ## Updating Bazel Bazel has a [backward compatibility policy](/release/backward-compatibility) -(see [guidance for rolling out incompatible changes](/contribute/breaking-changes) if you +(see [guidance for rolling out incompatible +changes](/contribute/breaking-changes) if you are the author of one). That page summarizes best practices on how to test and migrate your project with upcoming incompatible changes and how to provide feedback to the incompatible change authors. -### Managing Bazel versions with Bazelisk {#manage-with-bazelisk} +### Managing Bazel versions with Bazelisk [Bazelisk](https://github.com/bazelbuild/bazelisk) helps you manage Bazel versions. @@ -37,7 +38,7 @@ Bazelisk can: * Help migrate your project for incompatible changes (see above) * Easily try release candidates -### Recommended migration process {#migration-process} +### Recommended migration process Within minor updates to any LTS release, any project can be prepared for the next release without breaking diff --git a/install/compile-source.mdx b/install/compile-source.mdx index 9479e0cb..7a05ce47 100644 --- a/install/compile-source.mdx +++ b/install/compile-source.mdx @@ -14,9 +14,9 @@ To build Bazel from source, you can do one of the following: * Build it [without an existing Bazel binary](#bootstrap-bazel) which is known as _bootstrapping_. -## Build Bazel using Bazel {#build-bazel-using-bazel} +## Build Bazel using Bazel -### Summary {#summary} +### Summary 1. Get the latest Bazel release from the [GitHub release page](https://github.com/bazelbuild/bazel/releases) or with @@ -48,14 +48,15 @@ To build Bazel from source, you can do one of the following: Detailed instructions follow below. -### Step 1: Get the latest Bazel release {#build-bazel-install-bazel} +### Step 1: Get the latest Bazel release **Goal**: Install or download a release version of Bazel. Make sure you can run it by typing `bazel` in a terminal. **Reason**: To build Bazel from a GitHub source tree, you need a pre-existing Bazel binary. You can install one from a package manager or download one from -GitHub. See [Installing Bazel](/install). (Or you can [build from scratch (bootstrap)](#bootstrap-bazel).) +GitHub. See [Installing Bazel](/install). (Or you can [build from +scratch (bootstrap)](#bootstrap-bazel).) **Troubleshooting**: @@ -76,7 +77,7 @@ GitHub. See [Installing Bazel](/install). (Or you can [build from scratch (boots You must make the binary executable by running `chmod +x /path/to/bazel`. -### Step 2: Download Bazel's sources from GitHub {#build-bazel-git} +### Step 2: Download Bazel's sources from GitHub If you are familiar with Git, then just git clone https://github.com/bazelbuild/bazel @@ -90,12 +91,12 @@ Otherwise: For example create a `bazel-src` directory under your home directory and extract there. -### Step 3: Install prerequisites {#build-bazel-prerequisites} +### Step 3: Install prerequisites Install the same prerequisites as for bootstrapping (see below) -- JDK, C++ compiler, MSYS2 (if you are building on Windows), etc. -### Step 4a: Build Bazel on Ubuntu Linux, macOS, and other Unix-like systems {#build-bazel-on-unixes} +### Step 4a: Build Bazel on Ubuntu Linux, macOS, and other Unix-like systems For instructions for Windows, see [Build Bazel on Windows](#build-bazel-on-windows). @@ -123,7 +124,7 @@ For instructions for Windows, see [Build Bazel on Windows](#build-bazel-on-windo 4. The output will be at `bazel-bin/src/bazel-dev` (or `bazel-bin/src/bazel`). -### Step 4b: Build Bazel on Windows {#build-bazel-on-windows} +### Step 4b: Build Bazel on Windows For instructions for Unix-like systems, see [Ubuntu Linux, macOS, and other Unix-like systems](#build-bazel-on-unixes). @@ -154,7 +155,7 @@ For instructions for Unix-like systems, see 4. The output will be at `bazel-bin\src\bazel-dev.exe` (or `bazel-bin\src\bazel.exe`). -### Step 5: Install the built binary {#build-bazel-install} +### Step 5: Install the built binary Actually, there's nothing to install. @@ -164,11 +165,11 @@ your PATH so that you can run "bazel" everywhere.) --- -## Build Bazel from scratch (bootstrapping) {#bootstrap-bazel} +## Build Bazel from scratch (bootstrapping) You can also build Bazel from scratch, without using an existing Bazel binary. -### Step 1: Download Bazel's sources (distribution archive) {#download-distfile} +### Step 1: Download Bazel's sources (distribution archive) (This step is the same for all platforms.) @@ -191,11 +192,11 @@ You can also build Bazel from scratch, without using an existing Bazel binary. You should verify the signature made by Bazel's [release key](https://bazel.build/bazel-release.pub.gpg) 3D5919B448457EE0. -### Step 2a: Bootstrap Bazel on Ubuntu Linux, macOS, and other Unix-like systems {#bootstrap-unix-overview} +### Step 2a: Bootstrap Bazel on Ubuntu Linux, macOS, and other Unix-like systems For instructions for Windows, see [Bootstrap Bazel on Windows](#bootstrap-windows). -#### 2.1. Install the prerequisites {#bootstrap-unix-prereq} +#### 2.1. Install the prerequisites * **Bash** @@ -214,7 +215,7 @@ following command: sudo apt-get install build-essential openjdk-21-jdk python3 zip unzip ``` -#### 2.2. Bootstrap Bazel on Unix {#bootstrap-unix} +#### 2.2. Bootstrap Bazel on Unix 1. Open a shell or Terminal window. @@ -231,12 +232,12 @@ To build the `bazel` binary in a reproducible way, also set [`SOURCE_DATE_EPOCH`](https://reproducible-builds.org/specs/source-date-epoch/) in the "Run the compilation script" step. -### Step 2b: Bootstrap Bazel on Windows {#bootstrap-windows-overview} +### Step 2b: Bootstrap Bazel on Windows For instructions for Unix-like systems, see [Bootstrap Bazel on Ubuntu Linux, macOS, and other Unix-like systems](#bootstrap-unix). -#### 2.1. Install the prerequisites {#bootstrap-windows-prereq} +#### 2.1. Install the prerequisites * [MSYS2 shell](https://msys2.github.io/) @@ -247,7 +248,8 @@ For instructions for Unix-like systems, see ``` * **The Visual C++ compiler.** Install the Visual C++ compiler either as part - of Visual Studio 2015 or newer, or by installing the latest [Build Tools for Visual Studio 2017](https://aka.ms/BuildTools). + of Visual Studio 2015 or newer, or by installing the latest [Build Tools + for Visual Studio 2017](https://aka.ms/BuildTools). * **JDK.** Version 21 is required. @@ -256,7 +258,7 @@ For instructions for Unix-like systems, see [https://www.python.org](https://www.python.org)). Versions installed via pacman in MSYS2 will not work. -#### 2.2. Bootstrap Bazel on Windows {#bootstrap-windows} +#### 2.2. Bootstrap Bazel on Windows 1. Open the MSYS2 shell. diff --git a/install/completion.mdx b/install/completion.mdx index b7e1cb86..1d1d1b76 100644 --- a/install/completion.mdx +++ b/install/completion.mdx @@ -8,7 +8,7 @@ You can enable command-line completion (also known as tab-completion) in Bash and Zsh. This lets you tab-complete command names, flags names and flag values, and target names. -## Bash {#bash} +## Bash Bazel comes with a Bash completion script. @@ -64,7 +64,7 @@ If you installed Bazel: source /path/to/bazel-complete.bash ``` -## Zsh {#zsh} +## Zsh Bazel comes with a Zsh completion script. diff --git a/install/docker-container.mdx b/install/docker-container.mdx index 928c9433..b1efb76c 100644 --- a/install/docker-container.mdx +++ b/install/docker-container.mdx @@ -9,7 +9,7 @@ the [abseil-cpp](https://github.com/abseil/abseil-cpp) project using Bazel inside the Bazel container, and how to build this project directly from the host machine using the Bazel container with directory mounting. -## Build Abseil project from your host machine with directory mounting {#build-abseil} +## Build Abseil project from your host machine with directory mounting The instructions in this section allow you to build using the Bazel container with the sources checked out in your host environment. A container is started up @@ -59,7 +59,7 @@ docker run \ build --config={asan | tsan | msan} -- //absl/... -//absl/types:variant_test ``` -## Build Abseil project from inside the container {#build-abseil-inside-container} +## Build Abseil project from inside the container The instructions in this section allow you to build using the Bazel container with the sources inside the container. By starting a container at the beginning @@ -94,7 +94,7 @@ MemorySanitizer (msan) accordingly. ubuntu@5a99103747c6:~/abseil-cpp$ bazel build --config={asan | tsan | msan} -- //absl/... -//absl/types:variant_test ``` -## Explore the Bazel container {#explore-bazel-container} +## Explore the Bazel container If you haven't already, start an interactive shell inside the Bazel container. @@ -130,6 +130,6 @@ Build timestamp: 1685725198 Build timestamp as int: 1685725198 ``` -## Explore the Bazel Dockerfile {#explore-bazel-dockerfile} +## Explore the Bazel Dockerfile If you want to check how the Bazel Docker image is built, you can find its Dockerfile at [bazelbuild/continuous-integration/bazel/oci](https://github.com/bazelbuild/continuous-integration/tree/master/bazel/oci). diff --git a/install/ide.mdx b/install/ide.mdx index d43d0696..abe1f895 100644 --- a/install/ide.mdx +++ b/install/ide.mdx @@ -16,15 +16,17 @@ If you are interested in developing an editor or IDE plugin for Bazel, please join the `#ide` channel on the [Bazel Slack](https://slack.bazel.build) or start a discussion on [GitHub](https://github.com/bazelbuild/bazel/discussions). -## IDEs and editors {#ides-editors} +## IDEs and editors -### IntelliJ, Android Studio, and CLion {#intellij-android-clion} +### IntelliJ, Android Studio, and CLion Official Bazel plugins exist for many of the JetBrains-associated IDEs. Full documentation is linked from the listings on the JetBrains Marketplace: -* [IntelliJ plugin](https://plugins.jetbrains.com/plugin/22977-bazel) -* [Android Studio plugin](https://plugins.jetbrains.com/plugin/9185-android-studio-with-bazel) +* [IntelliJ + plugin](https://plugins.jetbrains.com/plugin/22977-bazel) +* [Android Studio + plugin](https://plugins.jetbrains.com/plugin/9185-android-studio-with-bazel) * [CLion plugin](https://plugins.jetbrains.com/plugin/9554-clion-with-bazel) Features: @@ -43,14 +45,14 @@ To manually install older versions, download the zip files from the JetBrains Marketplace or from [GitHub Releases](https://github.com/bazelbuild/intellij/releases) and install the zip file from the IDE's plugin browser. -### Xcode {#xcode} +### Xcode [rules_xcodeproj](https://github.com/buildbuddy-io/rules_xcodeproj), [Tulsi](https://tulsi.bazel.build), and [XCHammer](https://github.com/pinterest/xchammer) generate Xcode projects from Bazel `BUILD` files. -### Visual Studio Code {#visual-studio-code} +### Visual Studio Code Official plugin for VS Code. @@ -60,43 +62,45 @@ Features: * Starlark debugger for `.bzl` files during a build (set breakpoints, step through code, inspect variables, and so on) -Find [the plugin on the Visual Studio marketplace](https://marketplace.visualstudio.com/items?itemName=BazelBuild.vscode-bazel) +Find [the plugin on the Visual Studio +marketplace](https://marketplace.visualstudio.com/items?itemName=BazelBuild.vscode-bazel) or the [OpenVSX marketplace](https://open-vsx.org/extension/BazelBuild/vscode-bazel). The plugin is [open source](https://github.com/bazelbuild/vscode-bazel). See also: [Autocomplete for Source Code](#autocomplete-for-source-code) -### Atom {#atom} +### Atom Find the [`language-bazel` package](https://atom.io/packages/language-bazel) on the Atom package manager. See also: [Autocomplete for Source Code](#autocomplete-for-source-code) -### Vim {#vim} +### Vim See [`bazelbuild/vim-bazel` on GitHub](https://github.com/bazelbuild/vim-bazel) See also: [Autocomplete for Source Code](#autocomplete-for-source-code) -### Emacs {#emacs} +### Emacs -See [`bazelbuild/bazel-emacs-mode` on GitHub](https://github.com/bazelbuild/emacs-bazel-mode) +See [`bazelbuild/bazel-emacs-mode` on +GitHub](https://github.com/bazelbuild/emacs-bazel-mode) See also: [Autocomplete for Source Code](#autocomplete-for-source-code) -### Visual Studio {#visual-studio} +### Visual Studio [Lavender](https://github.com/tmandry/lavender) is an experimental project for generating Visual Studio projects that use Bazel for building. -### Eclipse {#eclipse} +### Eclipse [Bazel Eclipse Feature](https://github.com/salesforce/bazel-eclipse) is a set of plugins for importing Bazel packages into an Eclipse workspace as Eclipse projects. -## Autocomplete for Source Code {#autocomplete-for-source-code} +## Autocomplete for Source Code ### C Language Family (C++, C, Objective-C, Objective-C++, and CUDA) @@ -112,12 +116,13 @@ consumes the Protobuf output of Bazel to extract the compile commands. [`georgewfraser/java-language-server`](https://github.com/georgewfraser/java-language-server) - Java Language Server (LSP) with support for Bazel-built projects -## Automatically run build and test on file change {#bazel-watcher} +## Automatically run build and test on file change [Bazel watcher](https://github.com/bazelbuild/bazel-watcher) is a tool for building Bazel targets when source files change. -## Building your own IDE plugin {#build-own-plugin} +## Building your own IDE plugin -Read the [**IDE support** blog post](https://blog.bazel.build/2016/06/10/ide-support.html) to learn more about +Read the [**IDE support** blog +post](https://blog.bazel.build/2016/06/10/ide-support.html) to learn more about the Bazel APIs to use when building an IDE plugin. diff --git a/install/index.mdx b/install/index.mdx index 912ac212..84d9b146 100644 --- a/install/index.mdx +++ b/install/index.mdx @@ -11,7 +11,7 @@ to the packages for more details. You can find available Bazel releases on our [release page](/release). -## Community-supported packages {#community-supported-packages} +## Community-supported packages Bazel community members maintain these packages. The Bazel team doesn't officially support them. Contact the package maintainers for support. @@ -22,13 +22,13 @@ officially support them. Contact the package maintainers for support. * [Fedora](https://copr.fedorainfracloud.org/coprs/lihaohong/bazel) * [FreeBSD](https://www.freshports.org/devel/bazel) * [Homebrew](https://formulae.brew.sh/formula/bazel) -* [mise](/install/mise) +* [mise](install/mise) * [Nixpkgs](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/build-managers/bazel) * [openSUSE](/install/suse) * [Scoop](https://github.com/scoopinstaller/scoop-main/blob/master/bucket/bazel.json) * [Raspberry Pi](https://github.com/koenvervloesem/bazel-on-arm/blob/master/README.md) -## Community-supported architectures {#community-supported-architectures} +## Community-supported architectures * [ppc64el](https://ftp2.osuosl.org/pub/ppc64el/bazel/) diff --git a/install/suse.mdx b/install/suse.mdx index 82ce1bdd..741b108f 100644 --- a/install/suse.mdx +++ b/install/suse.mdx @@ -14,7 +14,7 @@ available Bazel versions via openSUSE's [software search](https://software.opens The commands below must be run either via `sudo` or while logged in as `root`. -## Installing Bazel on openSUSE {#install-opensuse} +## Installing Bazel on openSUSE Run the following commands to install the package. If you need a specific version, you can install it via the specific `bazelXXX` package, otherwise, diff --git a/install/ubuntu.mdx b/install/ubuntu.mdx index c1e4e32e..5e55569e 100644 --- a/install/ubuntu.mdx +++ b/install/ubuntu.mdx @@ -34,9 +34,9 @@ Bazel comes with two completion scripts. After installing Bazel, you can: * Access the [bash completion script](/install/completion#bash) * Install the [zsh completion script](/install/completion#zsh) -## Using Bazel's apt repository {#install-on-ubuntu} +## Using Bazel's apt repository -### Step 1: Add Bazel distribution URI as a package source {#add-dis-uri} +### Step 1: Add Bazel distribution URI as a package source **Note:** This is a one-time setup step. @@ -54,7 +54,7 @@ The component name "jdk1.8" is kept only for legacy reasons and doesn't relate to supported or included JDK versions. Bazel releases are Java-version agnostic. Changing the "jdk1.8" component name would break existing users of the repo. -### Step 2: Install and update Bazel {#install-bazel} +### Step 2: Install and update Bazel ```posix-terminal sudo apt update && sudo apt install bazel @@ -87,7 +87,7 @@ sudo ln -s /usr/bin/bazel-1.0.0 /usr/bin/bazel bazel --version # 1.0.0 ``` -### Step 3: Install a JDK (optional) {#install-jdk} +### Step 3: Install a JDK (optional) Bazel includes a private, bundled JRE as its runtime and doesn't require you to install any specific version of Java. @@ -98,7 +98,7 @@ However, if you want to build Java code using Bazel, you have to install a JDK. sudo apt install default-jdk ``` -## Using the binary installer {#binary-installer} +## Using the binary installer Generally, you should use the apt repository, but the binary installer can be useful if you don't have admin permissions on your machine or @@ -109,7 +109,7 @@ The binary installers can be downloaded from Bazel's [GitHub releases page](http The installer contains the Bazel binary and extracts it into your `$HOME/bin` folder. Some additional libraries must be installed manually for Bazel to work. -### Step 1: Install required packages {#install-packages} +### Step 1: Install required packages Bazel needs a C++ compiler and unzip / zip in order to work: @@ -123,7 +123,7 @@ If you want to build Java code using Bazel, install a JDK: sudo apt-get install default-jdk ``` -### Step 2: Run the installer {#run-installer} +### Step 2: Run the installer Next, download the Bazel binary installer named `bazel-version-installer-linux-x86_64.sh` from the [Bazel releases page on GitHub](https://github.com/bazelbuild/bazel/releases). @@ -140,7 +140,7 @@ The `--user` flag installs Bazel to the `$HOME/bin` directory on your system and sets the `.bazelrc` path to `$HOME/.bazelrc`. Use the `--help` command to see additional installation options. -### Step 3: Set up your environment {#set-environment} +### Step 3: Set up your environment If you ran the Bazel installer with the `--user` flag as above, the Bazel executable is installed in your `$HOME/bin` directory. @@ -153,7 +153,7 @@ export PATH="$PATH:$HOME/bin" You can also add this command to your `~/.bashrc` or `~/.zshrc` file to make it permanent. -## Using the Bazel Docker container {#docker-container} +## Using the Bazel Docker container We publish Docker container with Bazel installed for each Bazel version at `gcr.io/bazel-public/bazel`. You can use the Docker container as follows: diff --git a/install/windows.mdx b/install/windows.mdx index dc2edb0a..50b387d6 100644 --- a/install/windows.mdx +++ b/install/windows.mdx @@ -8,12 +8,12 @@ This page describes the requirements and steps to install Bazel on Windows. It also includes troubleshooting and other ways to install Bazel, such as using Chocolatey or Scoop. -## Installing Bazel {#installing-bazel} +## Installing Bazel This section covers the prerequisites, environment setup, and detailed steps during installation on Windows. -### Check your system {#check-system} +### Check your system Recommended: 64 bit Windows 10, version 1703 (Creators Update) or newer @@ -23,23 +23,24 @@ To check your Windows version: * Type `winver` in the search box and press Enter. * You should see the About Windows box with your Windows version information. -### Install the prerequisites {#install-prerequisites} +### Install the prerequisites * [Microsoft Visual C++ Redistributable](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170) -### Download Bazel {#download-bazel} +### Download Bazel *Recommended*: [Use Bazelisk](/install/bazelisk) Alternatively you can: -* [Download the Bazel binary (`bazel-version-windows-x86_64.exe`) from GitHub](https://github.com/bazelbuild/bazel/releases). +* [Download the Bazel binary (`bazel-version-windows-x86_64.exe`) from + GitHub](https://github.com/bazelbuild/bazel/releases). * [Install Bazel from Chocolatey](#chocolately) * [Install Bazel from Scoop](#scoop) * [Build Bazel from source](/install/compile-source) -### Set up your environment {#set-environment} +### Set up your environment To make Bazel easily accessible from command prompts or PowerShell by default, you can rename the Bazel binary to `bazel.exe` and add it to your default paths. @@ -49,7 +50,7 @@ set PATH=%PATH%;path to the Bazel binary You can also change your system `PATH` environment variable to make it permanent. Check out how to [set environment variables](/configure/windows#set-environment-variables). -### Done {#done} +### Done "Success: You've installed Bazel." @@ -66,7 +67,7 @@ Next, you can check out more tips and guidance here: * [Best practices on Windows](/configure/windows#best-practices) * [Tutorials](/start/#tutorials) -## Installing compilers and language runtimes {#install-compilers} +## Installing compilers and language runtimes Depending on which languages you want to build, you will need: @@ -115,7 +116,7 @@ Depending on which languages you want to build, you will need: Also supported: Python 2.7 or newer for Windows x86-64 -## Troubleshooting {#troubleshooting} +## Troubleshooting ### Bazel does not find Bash or bash.exe @@ -194,9 +195,9 @@ If that doesn't help: If you open a new cmd.exe or PowerShell terminal and run Bazel now, it will find Visual C++. -## Other ways to install Bazel {#install-options} +## Other ways to install Bazel -### Using Chocolatey {#chocolately} +### Using Chocolatey 1. Install the [Chocolatey](https://chocolatey.org) package manager @@ -210,10 +211,11 @@ If that doesn't help: its dependencies, such as the MSYS2 shell. This will not install Visual C++ though. -See [Chocolatey installation and package maintenance guide](/contribute/windows-chocolatey-maintenance) for more +See [Chocolatey installation and package maintenance +guide](/contribute/windows-chocolatey-maintenance) for more information about the Chocolatey package. -### Using Scoop {#scoop} +### Using Scoop 1. Install the [Scoop](https://scoop.sh/) package manager using the following PowerShell command: @@ -227,9 +229,10 @@ information about the Chocolatey package. scoop install bazel ``` -See [Scoop installation and package maintenance guide](/contribute/windows-scoop-maintenance) for more +See [Scoop installation and package maintenance +guide](/contribute/windows-scoop-maintenance) for more information about the Scoop package. -### Build from source {#build-from-source} +### Build from source To build Bazel from scratch instead of installing, see [Compiling from source](/install/compile-source). diff --git a/migrate/maven.mdx b/migrate/maven.mdx index 3b564450..0ca2b5c0 100644 --- a/migrate/maven.mdx +++ b/migrate/maven.mdx @@ -16,13 +16,14 @@ Note: While Bazel supports downloading and publishing Maven artifacts with , it does not directly support Maven-based plugins. Maven plugins can't be directly run by Bazel since there's no Maven compatibility layer. -## Before you begin {#before-you-begin} +## Before you begin * [Install Bazel](/install) if it's not yet installed. -* If you're new to Bazel, go through the tutorial [Introduction to Bazel: Build Java](/start/java) before you start migrating. The tutorial explains +* If you're new to Bazel, go through the tutorial [Introduction to Bazel: + Build Java](/start/java) before you start migrating. The tutorial explains Bazel's concepts, structure, and label syntax. -## Differences between Maven and Bazel {#dif-maven-bazel} +## Differences between Maven and Bazel * Maven uses top-level `pom.xml` file(s). Bazel supports multiple build files and multiple targets per `BUILD` file, allowing for builds that are more @@ -34,7 +35,7 @@ directly run by Bazel since there's no Maven compatibility layer. `BUILD` files. Best practice is to add a `BUILD` file to each new Java package. -## Migrate from Maven to Bazel {#migrate-maven-bazel} +## Migrate from Maven to Bazel The steps below describe how to migrate your project to Bazel: @@ -43,7 +44,8 @@ The steps below describe how to migrate your project to Bazel: 3. [Create more BUILD files](#3-build) 4. [Build using Bazel](#4-build) -Examples below come from a migration of the [Guava project](https://github.com/google/guava) from Maven to Bazel. The +Examples below come from a migration of the [Guava +project](https://github.com/google/guava) from Maven to Bazel. The Guava project used is release `v31.1`. The examples using Guava do not walk through each step in the migration, but they do show the files and contents that are generated or added manually for the migration. @@ -53,7 +55,7 @@ $ git clone https://github.com/google/guava.git && cd guava $ git checkout v31.1 ``` -### 1. Create the MODULE.bazel file {#1-build} +### 1. Create the MODULE.bazel file Create a file named `MODULE.bazel` at the root of your project. If your project has no external dependencies, this file can be empty. @@ -61,12 +63,14 @@ has no external dependencies, this file can be empty. If your project depends on files or packages that are not in one of the project's directories, specify these external dependencies in the MODULE.bazel file. You can use `rules_jvm_external` to manage dependencies from Maven. For -instructions about using this ruleset, see [the README](https://github.com/bazelbuild/rules_jvm_external/#rules_jvm_external) +instructions about using this ruleset, see [the +README](https://github.com/bazelbuild/rules_jvm_external/#rules_jvm_external) . -#### Guava project example: external dependencies {#guava-1} +#### Guava project example: external dependencies -You can list the external dependencies of the [Guava project](https://github.com/google/guava) with the +You can list the external dependencies of the [Guava +project](https://github.com/google/guava) with the [`rules_jvm_external`](https://github.com/bazelbuild/rules_jvm_external) ruleset. @@ -90,7 +94,7 @@ maven.install( use_repo(maven, "maven") ``` -### 2. Create one BUILD file {#2-build} +### 2. Create one BUILD file Now that you have your workspace defined and external dependencies (if applicable) listed, you need to create `BUILD` files to describe how your @@ -160,7 +164,8 @@ your build by adding more `BUILD` files with more granular targets. * `resources`: Use globbing to list all resources in your project. * `deps`: You need to determine which external dependencies your project needs. - * Take a look at the [example below of this top-level BUILD file](#guava-2) from the migration of the Guava project. + * Take a look at the [example below of this top-level BUILD + file](#guava-2) from the migration of the Guava project. 3. Now that you have a `BUILD` file at the root of your project, build your project to ensure that it works. On the command line, from your workspace @@ -169,7 +174,7 @@ your build by adding more `BUILD` files with more granular targets. The project has now been successfully built with Bazel. You will need to add more `BUILD` files to allow incremental builds of the project. -#### Guava project example: start with one BUILD file {#guava-2} +#### Guava project example: start with one BUILD file When migrating the Guava project to Bazel, initially one `BUILD` file is used to build the entire project. Here are the contents of this initial `BUILD` file in @@ -193,7 +198,7 @@ java_library( ) ``` -### 3. Create more BUILD files (optional) {#3-build} +### 3. Create more BUILD files (optional) Bazel does work with just one `BUILD file`, as you saw after completing your first build. You should still consider breaking the build into smaller chunks by @@ -225,7 +230,7 @@ Tips for adding more `BUILD` files: that the project continues to build with Bazel as you add each build file. Run `bazel build //...` to ensure all of your targets still build. -### 4. Build using Bazel {#4-build} +### 4. Build using Bazel You've been building using Bazel as you add `BUILD` files to validate the setup of the build. diff --git a/migrate/xcode.mdx b/migrate/xcode.mdx index 5f6a05a2..311f5e62 100644 --- a/migrate/xcode.mdx +++ b/migrate/xcode.mdx @@ -7,7 +7,7 @@ describes the differences between Xcode and Bazel, and provides the steps for converting an Xcode project to a Bazel project. It also provides troubleshooting solutions to address common errors. -## Differences between Xcode and Bazel {#dif-xcode-bazel} +## Differences between Xcode and Bazel * Bazel requires you to explicitly specify every build target and its dependencies, plus the corresponding build settings via build rules. @@ -26,26 +26,28 @@ solutions to address common errors. `bazel build` and `bazel test` commands provide build and test capabilities with certain limitations described later in this guide. -## Before you begin {#before-you-begin} +## Before you begin Before you begin, do the following: 1. [Install Bazel](/install) if you have not already done so. -2. If you're not familiar with Bazel and its concepts, complete the [iOS app tutorial](/start/ios-app)). You should understand the Bazel workspace, +2. If you're not familiar with Bazel and its concepts, complete the [iOS app + tutorial](/start/ios-app)). You should understand the Bazel workspace, including the `MODULE.bazel` and `BUILD` files, as well as the concepts of targets, build rules, and Bazel packages. 3. Analyze and understand the project's dependencies. -### Analyze project dependencies {#analyze-project-dependencies} +### Analyze project dependencies Unlike Xcode, Bazel requires you to explicitly declare all dependencies for every target in the `BUILD` file. -For more information on external dependencies, see [Working with external dependencies](/docs/external). +For more information on external dependencies, see [Working with external +dependencies](/docs/external). -## Build or test an Xcode project with Bazel {#build-xcode-project} +## Build or test an Xcode project with Bazel To build or test an Xcode project with Bazel, do the following: @@ -67,7 +69,7 @@ To build or test an Xcode project with Bazel, do the following: 6. [Generate the Xcode project with rules_xcodeproj](#generate-the-xcode-project-with-rules_xcodeproj) -### Step 1: Create the `MODULE.bazel` file {#create-workspace} +### Step 1: Create the `MODULE.bazel` file Create a `MODULE.bazel` file in a new directory. This directory becomes the Bazel workspace root. If the project uses no external dependencies, this file @@ -78,18 +80,19 @@ the project's directories, specify these external dependencies in the Note: Place the project source code within the directory tree containing the `MODULE.bazel` file. -### Step 2: (Experimental) Integrate SwiftPM dependencies {#integrate-swiftpm} +### Step 2: (Experimental) Integrate SwiftPM dependencies To integrate SwiftPM dependencies into the Bazel workspace with [swift_bazel](https://github.com/cgrindel/swift_bazel), you must -convert them into Bazel packages as described in the [following tutorial](https://chuckgrindel.com/swift-packages-in-bazel-using-swift_bazel/) +convert them into Bazel packages as described in the [following +tutorial](https://chuckgrindel.com/swift-packages-in-bazel-using-swift_bazel/) . Note: SwiftPM support is a manual process with many variables. SwiftPM integration with Bazel has not been fully verified and is not officially supported. -### Step 3: Create a `BUILD` file {#create-build-file} +### Step 3: Create a `BUILD` file Once you have defined the workspace and external dependencies, you need to create a `BUILD` file that tells Bazel how the project is structured. Create the @@ -100,9 +103,10 @@ initial build of the project as follows: * [Step 3b: (Optional) Add the test target(s)](#step-3b-optional-add-the-test-target-s) * [Step 3c: Add the library target(s)](#step-3c-add-the-library-target-s) -**Tip:** To learn more about packages and other Bazel concepts, see [Workspaces, packages, and targets](/concepts/build-ref). +**Tip:** To learn more about packages and other Bazel concepts, see [Workspaces, +packages, and targets](/concepts/build-ref). -#### Step 3a: Add the application target {#add-app-target} +#### Step 3a: Add the application target Add a [`macos_application`](https://github.com/bazelbuild/rules_apple/blob/master/doc/rules-macos.md#macos_application) @@ -126,9 +130,10 @@ In the target, specify the following at the minimum: application supports. This ensures Bazel builds the application with the correct API levels. -#### Step 3b: (Optional) Add the test target(s) {#add-test-target} +#### Step 3b: (Optional) Add the test target(s) -Bazel's [Apple build rules](https://github.com/bazelbuild/rules_apple) support running +Bazel's [Apple build +rules](https://github.com/bazelbuild/rules_apple) support running unit and UI tests on all Apple platforms. Add test targets as follows: * [`macos_unit_test`](https://github.com/bazelbuild/rules_apple/blob/master/doc/rules-macos.md#macos_unit_test) @@ -153,7 +158,7 @@ with the project and adjust them as necessary. For tests that require the iOS simulator, also specify the `ios_application` target name as the value of the `test_host` attribute. -#### Step 3c: Add the library target(s) {#add-library-target} +#### Step 3c: Add the library target(s) Add an [`objc_library`](/reference/be/objective-c#objc_library) target for each Objective-C library and a @@ -176,7 +181,8 @@ all sources and/or headers of a certain type. Use it carefully as it might include files you do not want Bazel to build. You can browse existing examples for various types of applications directly in -the [rules_apple examples directory](https://github.com/bazelbuild/rules_apple/tree/master/examples/). For +the [rules_apple examples +directory](https://github.com/bazelbuild/rules_apple/tree/master/examples/). For example: * [macOS application targets](https://github.com/bazelbuild/rules_apple/tree/master/examples/macos) @@ -185,13 +191,14 @@ example: * [Multi platform applications (macOS, iOS, watchOS, tvOS)](https://github.com/bazelbuild/rules_apple/tree/master/examples/multi_platform) -For more information on build rules, see [Apple Rules for Bazel](https://github.com/bazelbuild/rules_apple). +For more information on build rules, see [Apple Rules for +Bazel](https://github.com/bazelbuild/rules_apple). At this point, it is a good idea to test the build: `bazel build //:` -### Step 4: (Optional) Granularize the build {#granularize-build} +### Step 4: (Optional) Granularize the build If the project is large, or as it grows, consider chunking it into multiple Bazel packages. This increased granularity provides: @@ -225,7 +232,7 @@ Tips for granularizing the project: * Build the project after each major change to the `BUILD` files and fix build errors as you encounter them. -### Step 5: Run the build {#run-build} +### Step 5: Run the build Run the fully migrated build to ensure it completes with no errors or warnings. Run every application and test target individually to more easily find sources @@ -237,7 +244,7 @@ For example: bazel build //:my-target ``` -### Step 6: Generate the Xcode project with rules_xcodeproj {#generate-the-xcode-project-with-rules_xcodeproj} +### Step 6: Generate the Xcode project with rules_xcodeproj When building with Bazel, the `MODULE.bazel` and `BUILD` files become the source of truth about the build. To make Xcode aware of this, you must generate a @@ -245,7 +252,7 @@ Bazel-compatible Xcode project using [rules_xcodeproj](https://github.com/buildbuddy-io/rules_xcodeproj#features) . -### Troubleshooting {#troubleshooting} +### Troubleshooting Bazel errors can arise when it gets out of sync with the selected Xcode version, like when you apply an update. Here are some things to try if you're diff --git a/navigation.json b/navigation.json index a3d046ca..fd3c4b14 100644 --- a/navigation.json +++ b/navigation.json @@ -8,14 +8,6 @@ } ] }, - { - "version": "9.1", - "languages": [ - { - "$ref": "./navigation/9.1.en.json" - } - ] - }, { "version": "9.0", "languages": [ @@ -24,14 +16,6 @@ } ] }, - { - "version": "8.6", - "languages": [ - { - "$ref": "./navigation/8.6.en.json" - } - ] - }, { "version": "8.5", "languages": [ diff --git a/query/aquery.mdx b/query/aquery.mdx index be9a633f..151565b7 100644 --- a/query/aquery.mdx +++ b/query/aquery.mdx @@ -33,7 +33,7 @@ action 'Writing file some_file_name' Outputs: [...] ``` -## Basic syntax {#basic-syntax} +## Basic syntax A simple example of the syntax for `aquery` is as follows: @@ -60,7 +60,7 @@ $ bazel aquery 'deps(//src/target_a)' $ bazel aquery 'inputs(".*cpp", deps(//src/target_a))' ``` -## Using aquery functions {#using-aquery-functions} +## Using aquery functions There are three `aquery` functions: @@ -100,17 +100,17 @@ An example of the syntax error produced: deps(inputs(".*cpp", //src/target_a)) ``` -## Options {#options} +## Options -### Build options {#build-options} +### Build options `aquery` runs on top of a regular Bazel build and thus inherits the set of [options](/reference/command-line-reference#build-options) available during a build. -### Aquery options {#aquery-options} +### Aquery options -#### `--output=(text|summary|commands|proto|jsonproto|textproto), default=text` {#output} +#### `--output=(text|summary|commands|proto|jsonproto|textproto), default=text` The default output format (`text`) is human-readable, use `proto`, `textproto`, or `jsonproto` for machine-readable format. @@ -122,25 +122,25 @@ one command per line. In general, do not depend on the order of output. For more information, see the [core query ordering contract](/query/language#graph-order). -#### `--include_commandline, default=true` {#include-commandline} +#### `--include_commandline, default=true` Includes the content of the action command lines in the output (potentially large). -#### `--include_artifacts, default=true` {#include-artifacts} +#### `--include_artifacts, default=true` Includes names of the action inputs and outputs in the output (potentially large). -#### `--include_aspects, default=true` {#include-aspects} +#### `--include_aspects, default=true` Whether to include Aspect-generated actions in the output. -#### `--include_param_files, default=false` {#include-param-files} +#### `--include_param_files, default=false` Include the content of the param files used in the command (potentially large). Warning: Enabling this flag will automatically enable the `--include_commandline` flag. -#### `--include_file_write_contents, default=false` {#include-file-write-contents} +#### `--include_file_write_contents, default=false` Include file contents for the `actions.write()` action and the contents of the manifest file for the `SourceSymlinkManifest` action The file contents is @@ -151,16 +151,16 @@ FileWriteContents: [] ``` line -#### `--skyframe_state, default=false` {#skyframe-state} +#### `--skyframe_state, default=false` Without performing extra analysis, dump the Action Graph from Skyframe. Note: Specifying a target with `--skyframe_state` is currently not supported. This flag is only available with `--output=proto` or `--output=textproto`. -## Other tools and features {#other-tools-features} +## Other tools and features -### Querying against the state of Skyframe {#querying-against-skyframe} +### Querying against the state of Skyframe [Skyframe](/reference/skyframe) is the evaluation and incrementality model of Bazel. On each instance of Bazel server, Skyframe stores the dependency graph @@ -198,14 +198,14 @@ With `--skyframe_state` mode, `aquery` takes the content of the Action Graph that Skyframe keeps on the instance of Bazel, (optionally) performs filtering on it and outputs the content, without re-running the analysis phase. -#### Special considerations {#special-considerations} +#### Special considerations -##### Output format {#output-format} +##### Output format `--skyframe_state` is currently only available for `--output=proto` and `--output=textproto` -##### Non-inclusion of target labels in the query expression {#target-labels-non-inclusion} +##### Non-inclusion of target labels in the query expression Currently, `--skyframe_state` queries the whole action graph that exists on Skyframe, regardless of the targets. Having the target label specified in the query together with @@ -225,7 +225,7 @@ regardless of the targets. Having the target label specified in the query togeth $ bazel aquery --output=proto --skyframe_state 'inputs(".*.java")' ``` -### Comparing aquery outputs {#comparing-aquery-outputs} +### Comparing aquery outputs You can compare the outputs of two different aquery invocations using the `aquery_differ` tool. For instance: when you make some changes to your rule definition and want to verify that the @@ -264,7 +264,7 @@ command line/inputs in each aquery output, ...). The result of running the above ... ``` -#### Command options {#command-options} +#### Command options `--before, --after`: The aquery output files to be compared @@ -274,7 +274,7 @@ files. Support is provided for `proto` and `textproto` aquery output. `--attrs=(cmdline|inputs), default=cmdline`: the attributes of actions to be compared. -### Aspect-on-aspect {#aspect-on-aspect} +### Aspect-on-aspect It is possible for [Aspects](/extending/aspects) to be applied on top of each other. The aquery output of the action generated by @@ -324,7 +324,7 @@ Each `AspectDescriptor` has the following format: sorted in topological order of the [dependency graph](/extending/aspects#aspect_basics). -### Linking with the JSON profile {#linking-with-json-profile} +### Linking with the JSON profile While aquery provides information about the actions being run in a build (why they're being run, their inputs/outputs), the [JSON profile](/rules/performance#performance-profiling) @@ -339,9 +339,9 @@ is included by default by aquery. We don't currently provide a canonical tool to combine these 2 data sources, but you should be able to build your own script with the above information. -## Known issues {#known-issues} +## Known issues -### Handling shared actions {#handling-shared-actions} +### Handling shared actions Sometimes actions are [shared](https://source.bazel.build/bazel/+/master:src/main/java/com/google/devtools/build/lib/actions/Actions.java;l=59;drc=146d51aa1ec9dcb721a7483479ef0b1ac21d39f1) @@ -356,9 +356,9 @@ equivalent Artifacts appear duplicated. The list of aquery issues/planned features can be found on [GitHub](https://github.com/bazelbuild/bazel/labels/team-Performance). -## FAQs {#faqs} +## FAQs -### The ActionKey remains the same even though the content of an input file changed. {#actionkey-same} +### The ActionKey remains the same even though the content of an input file changed. In the context of aquery, the `ActionKey` refers to the `String` gotten from [ActionAnalysisMetadata#getKey](https://source.bazel.build/bazel/+/master:src/main/java/com/google/devtools/build/lib/actions/ActionAnalysisMetadata.java;l=89;drc=8b856f5484f0117b2aebc302f849c2a15f273310): @@ -386,6 +386,6 @@ In the context of aquery, the `ActionKey` refers to the `String` gotten from This excludes the changes to the content of the input files, and is not to be confused with [RemoteCacheClient#ActionKey](https://source.bazel.build/bazel/+/master:src/main/java/com/google/devtools/build/lib/remote/common/RemoteCacheClient.java;l=38;drc=21577f202eb90ce94a337ebd2ede824d609537b6). -## Updates {#updates} +## Updates For any issues/feature requests, please file an issue [here](https://github.com/bazelbuild/bazel/issues/new). diff --git a/query/cquery.mdx b/query/cquery.mdx index f7195d40..d35ea829 100644 --- a/query/cquery.mdx +++ b/query/cquery.mdx @@ -8,7 +8,8 @@ title: 'Configurable Query (cquery)' [`select()`](/docs/configurable-attributes) and build options' effects on the build graph. -It achieves this by running over the results of Bazel's [analysis phase](/extending/concepts#evaluation-model), +It achieves this by running over the results of Bazel's [analysis +phase](/extending/concepts#evaluation-model), which integrates these effects. `query`, by contrast, runs over the results of Bazel's loading phase, before options are evaluated. @@ -66,7 +67,7 @@ Since `cquery` runs over the configured target graph. it doesn't have insight into artifacts like build actions nor access to [`test_suite`](/reference/be/general#test_suite) rules as they are not configured targets. For the former, see [`aquery`](/query/aquery). -## Basic syntax {#basic-syntax} +## Basic syntax A simple `cquery` call looks like: @@ -88,7 +89,7 @@ phases. Unless otherwise specified, `cquery` parses the target(s) listed in the query expression. See [`--universe_scope`](#universe-scope) for querying dependencies of top-level build targets. -## Configurations {#configurations} +## Configurations The line: @@ -112,7 +113,7 @@ prefix of a complete ID, similar to [Git short hashes](https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection#_revision_selection). To see complete IDs, run `$ bazel config`. -## Target pattern evaluation {#target-pattern-evaluation} +## Target pattern evaluation `//foo` has a different meaning for `cquery` than for `query`. This is because `cquery` evaluates _configured_ targets and the build graph may have multiple @@ -139,23 +140,23 @@ $ bazel cquery //foo --universe_scope=//foo,//genrule_with_foo_as_tool If you want to precisely declare which instance to query over, use the [`config`](#config) function. -See `query`'s [target pattern documentation](/query/language#target-patterns) for more information on target +See `query`'s [target pattern +documentation](/query/language#target-patterns) for more information on target patterns. -## Functions {#functions} +## Functions Of the [set of functions](/query/language#functions "list of query functions") supported by `query`, `cquery` supports all but [`allrdeps`](/query/language#allrdeps), [`buildfiles`](/query/language#buildfiles), -[`loadfiles`](/query/language#loadfiles), [`rbuildfiles`](/query/language#rbuildfiles), [`siblings`](/query/language#siblings), [`tests`](/query/language#tests), and [`visible`](/query/language#visible). `cquery` also introduces the following new functions: -### config {#config} +### config `expr ::= config(expr, word)` @@ -185,17 +186,17 @@ If not all results of the first argument can be found in the specified configuration, only those that can be found are returned. If no results can be found in the specified configuration, the query fails. -## Options {#options} +## Options -### Build options {#build-options} +### Build options `cquery` runs over a regular Bazel build and thus inherits the set of [options](/reference/command-line-reference#build-options) available during a build. -### Using cquery options {#using-cquery-options} +### Using cquery options -#### `--universe_scope` (comma-separated list) {#universe-scope} +#### `--universe_scope` (comma-separated list) Often, the dependencies of configured targets go through [transitions](/extending/rules#configurations), @@ -258,13 +259,13 @@ configurations you don't care about. It could also help specify which configuration version of a target you're looking for. You should set this flag if your query expression is more complex than `deps(//foo)`. -#### `--implicit_deps` (boolean, default=True) {#implicit-deps} +#### `--implicit_deps` (boolean, default=True) Setting this flag to false filters out all results that aren't explicitly set in the BUILD file and instead set elsewhere by Bazel. This includes filtering resolved toolchains. -#### `--tool_deps` (boolean, default=True) {#tool-deps} +#### `--tool_deps` (boolean, default=True) Setting this flag to false filters out all configured targets for which the path from the queried target to them crosses a transition between the target @@ -276,19 +277,19 @@ non-target configuration, setting `--notool_deps` will only return targets also in non-target configurations. This setting generally does not affect filtering of resolved toolchains. -#### `--include_aspects` (boolean, default=True) {#include-aspects} +#### `--include_aspects` (boolean, default=True) Include dependencies added by [aspects](/extending/aspects). If this flag is disabled, `cquery somepath(X, Y)` and `cquery deps(X) | grep 'Y'` omit Y if X only depends on it through an aspect. -## Output formats {#output-formats} +## Output formats By default, cquery outputs results in a dependency-ordered list of label and configuration pairs. There are other options for exposing the results as well. -### Transitions {#transitions} +### Transitions ``` --transitions=lite @@ -312,7 +313,7 @@ information about rule class transitions and attribute transitions including a detailed diff of the options before and after the transition. `LITE` mode outputs the same information without the options diff. -### Protocol message output {#protocol-message-output} +### Protocol message output ``` --output=proto @@ -327,7 +328,7 @@ has a list of `ConfiguredTarget` messages and a list of `Configuration` messages. Each `ConfiguredTarget` has a `configuration_id` whose value is equal to that of the `id` field from the corresponding `Configuration` message. -#### --[no]proto:include_configurations {#proto-include-configurations} +#### --[no]proto:include_configurations By default, cquery results return configuration information as part of each configured target. If you'd like to omit this information and get proto output @@ -340,7 +341,7 @@ Note: While selects are resolved both at the top level of returned targets and within attributes, all possible inputs for selects are still included as `rule_input` fields. -### Graph output {#graph-output} +### Graph output ``` --output=graph @@ -351,7 +352,7 @@ This option generates output as a Graphviz-compatible .dot file. See `query`'s also supports [`--graph:node_limit`](/query/language#graph-nodelimit) and [`--graph:factored`](/query/language#graph-factored). -### Files output {#files-output} +### Files output ``` --output=files @@ -375,7 +376,7 @@ files of `//pkg:foo` in *all* configurations that occur in the build (also see the [section on target pattern evaluation](#target-pattern-evaluation)). If that is not desired, wrap you query in [`config(..., target)`](#config). -### Defining the output format using Starlark {#output-format-definition} +### Defining the output format using Starlark ``` --output=starlark @@ -390,7 +391,7 @@ in the query result. Alternatively, for convenience, you may specify just the body of a function declared as `def format(target): return expr` by using the `--starlark:expr` flag. -#### 'cquery' Starlark dialect {#cquery-starlark} +#### 'cquery' Starlark dialect The cquery Starlark environment differs from a BUILD or .bzl file. It includes all core Starlark @@ -398,7 +399,7 @@ all core Starlark plus a few cquery-specific ones described below, but not (for example) `glob`, `native`, or `rule`, and it does not support load statements. -##### build_options(target) {#build-options-function} +##### build_options(target) `build_options(target)` returns a map whose keys are build option identifiers (see [Configurations](/extending/config)) and whose values are their Starlark @@ -408,14 +409,14 @@ from this map. If the target is an input file, `build_options(target)` returns None, as input file targets have a null configuration. -##### providers(target) {#providers} +##### providers(target) `providers(target)` returns a map whose keys are names of [providers](/extending/rules#providers) (for example, `"DefaultInfo"`) and whose values are their Starlark values. Providers whose values are not legal Starlark values are omitted from this map. -#### Examples {#output-format-definition-examples} +#### Examples Print a space-separated list of the base names of all files produced by `//foo`: @@ -516,7 +517,7 @@ Extract a value from a user defined Provider. $ bazel cquery //baz --output=starlark --starlark:file=example.cquery ``` -## cquery vs. query {#cquery-vs-query} +## cquery vs. query `cquery` and `query` complement each other and excel in different niches. Consider the following to decide which is right for you: @@ -541,7 +542,8 @@ different niches. Consider the following to decide which is right for you: It's therefore prone to picking up results from past queries. For example, `genrule` exerts an exec transition on its `tools` attribute - -that is, it configures its tools in the [exec configuration](https://bazel.build/rules/rules#configurations). +that is, it configures its tools in the [exec configuration] +(https://bazel.build/rules/rules#configurations). You can see the lingering effects of that transition below. @@ -580,9 +582,9 @@ evaluate. To disable this, run `blaze clean` before your `cquery` to ensure a fresh analysis graph. -## Troubleshooting {#troubleshooting} +## Troubleshooting -### Recursive target patterns (`/...`) {#recursive-target-patterns} +### Recursive target patterns (`/...`) If you encounter: diff --git a/query/guide.mdx b/query/guide.mdx index 705faf1d..37edd13b 100644 --- a/query/guide.mdx +++ b/query/guide.mdx @@ -16,7 +16,7 @@ command line. To execute a query while ignoring errors such as missing targets, use the `--keep_going` flag. -## Finding the dependencies of a rule {#finding-rule-dependencies} +## Finding the dependencies of a rule To see the dependencies of `//foo`, use the `deps` function in bazel query: @@ -30,7 +30,7 @@ $ bazel query "deps(//foo)" This is the set of all targets required to build `//foo`. -## Tracing the dependency chain between two packages {#tracing-dependency-chain} +## Tracing the dependency chain between two packages The library `//third_party/zlib:zlibonly` isn't in the BUILD file for `//foo`, but it is an indirect dependency. How can @@ -91,7 +91,7 @@ $ bazel query "allpaths(//foo, third_party/...)" //third_party/openssl:crypto ``` -### Aside: implicit dependencies {#implicit-dependencies} +### Aside: implicit dependencies The BUILD file for `//foo` never references `//translations/tools:aggregator`. So, where's the direct dependency? @@ -104,7 +104,7 @@ but added in by the build tool. The full set of implicit dependencies is currently undocumented. Using `--noimplicit_deps` allows you to filter out these deps from your query results. For cquery, this will include resolved toolchains. -## Reverse dependencies {#reverse-dependencies} +## Reverse dependencies You might want to know the set of targets that depends on some target. For instance, if you're going to change some code, you might want to know what other code @@ -115,55 +115,41 @@ Bazel's [Sky Query](/query/language#sky-query) supports the `allrdeps` function which allows you to query reverse dependencies in a universe you specify. -## Miscellaneous uses {#miscellaneous-uses} +## Miscellaneous uses You can use `bazel query` to analyze many dependency relationships. -### What exists ... {#what-exists} +### What exists ... -#### What packages exist beneath `foo`? {#what-exists-beneath-foo} +#### What packages exist beneath `foo`? -``` -bazel query 'foo/...' --output package -``` +```bazel query 'foo/...' --output package``` -#### What rules are defined in the `foo` package? {#rules-defined-in-foo} +#### What rules are defined in the `foo` package? -``` -bazel query 'kind(rule, foo:*)' --output label_kind -``` +```bazel query 'kind(rule, foo:*)' --output label_kind``` -#### What files are generated by rules in the `foo` package? {#files-generated-by-rules} +#### What files are generated by rules in the `foo` package? -``` -bazel query 'kind("generated file", //foo:*)' -``` +```bazel query 'kind("generated file", //foo:*)'``` -#### What targets are generated by starlark macro `foo`? {#targets-generated-by-foo} +#### What targets are generated by starlark macro `foo`? -``` -bazel query 'attr(generator_function, foo, //path/to/search/...)' -``` +```bazel query 'attr(generator_function, foo, //path/to/search/...)'``` -#### What's the set of BUILD files needed to build `//foo`? {#build-files-required} +#### What's the set of BUILD files needed to build `//foo`? -``` -bazel query 'buildfiles(deps(//foo))' | cut -f1 -d: -``` +```bazel query 'buildfiles(deps(//foo))' | cut -f1 -d:``` -#### What are the individual tests that a `test_suite` expands to? {#individual-tests-in-testsuite} +#### What are the individual tests that a `test_suite` expands to? -``` -bazel query 'tests(//foo:smoke_tests)' -``` +```bazel query 'tests(//foo:smoke_tests)'``` -#### Which of those are C++ tests? {#cxx-tests} +#### Which of those are C++ tests? -``` -bazel query 'kind(cc_.*, tests(//foo:smoke_tests))' -``` +```bazel query 'kind(cc_.*, tests(//foo:smoke_tests))'``` -#### Which of those are small? Medium? Large? {#size-of-tests} +#### Which of those are small? Medium? Large? ``` bazel query 'attr(size, small, tests(//foo:smoke_tests))' @@ -173,147 +159,113 @@ bazel query 'attr(size, medium, tests(//foo:smoke_tests))' bazel query 'attr(size, large, tests(//foo:smoke_tests))' ``` -#### What are the tests beneath `foo` that match a pattern? {#tests-beneath-foo} +#### What are the tests beneath `foo` that match a pattern? -``` -bazel query 'filter("pa?t", kind(".*_test rule", //foo/...))' -``` +```bazel query 'filter("pa?t", kind(".*_test rule", //foo/...))'``` The pattern is a regex and is applied to the full name of the rule. It's similar to doing -``` -bazel query 'kind(".*_test rule", //foo/...)' | grep -E 'pa?t' -``` +```bazel query 'kind(".*_test rule", //foo/...)' | grep -E 'pa?t'``` -#### What package contains file `path/to/file/bar.java`? {#barjava-package} +#### What package contains file `path/to/file/bar.java`? -``` -bazel query path/to/file/bar.java --output=package -``` +``` bazel query path/to/file/bar.java --output=package``` -#### What is the build label for `path/to/file/bar.java?` {#barjava-build-label} +#### What is the build label for `path/to/file/bar.java?` -``` -bazel query path/to/file/bar.java -``` +```bazel query path/to/file/bar.java``` -#### What rule target(s) contain file `path/to/file/bar.java` as a source? {#barjava-rule-targets} +#### What rule target(s) contain file `path/to/file/bar.java` as a source? ``` fullname=$(bazel query path/to/file/bar.java) bazel query "attr('srcs', $fullname, ${fullname//:*/}:*)" ``` -### What package dependencies exist ... {#package-dependencies} +### What package dependencies exist ... -#### What packages does `foo` depend on? (What do I need to check out to build `foo`) {#packages-foo-depends-on} +#### What packages does `foo` depend on? (What do I need to check out to build `foo`) -``` -bazel query 'buildfiles(deps(//foo:foo))' --output package -``` +```bazel query 'buildfiles(deps(//foo:foo))' --output package``` Note: `buildfiles` is required in order to correctly obtain all files referenced by `subinclude`; see the reference manual for details. -#### What packages does the `foo` tree depend on, excluding `foo/contrib`? {#packages-foo-tree-depends-on} +#### What packages does the `foo` tree depend on, excluding `foo/contrib`? -``` -bazel query 'deps(foo/... except foo/contrib/...)' --output package -``` +```bazel query 'deps(foo/... except foo/contrib/...)' --output package``` -### What rule dependencies exist ... {#rule-dependencies} +### What rule dependencies exist ... -#### What genproto rules does bar depend upon? {#genproto-rules} +#### What genproto rules does bar depend upon? -``` -bazel query 'kind(genproto, deps(bar/...))' -``` +```bazel query 'kind(genproto, deps(bar/...))'``` -#### Find the definition of some JNI (C++) library that is transitively depended upon by a Java binary rule in the servlet tree. {#jni-library} +#### Find the definition of some JNI (C++) library that is transitively depended upon by a Java binary rule in the servlet tree. -``` -bazel query 'some(kind(cc_.*library, deps(kind(java_binary, //java/com/example/frontend/...))))' --output location -``` +```bazel query 'some(kind(cc_.*library, deps(kind(java_binary, //java/com/example/frontend/...))))' --output location``` -##### ...Now find the definitions of all the Java binaries that depend on them {#java-binaries} +##### ...Now find the definitions of all the Java binaries that depend on them -``` -bazel query 'let jbs = kind(java_binary, //java/com/example/frontend/...) in +```bazel query 'let jbs = kind(java_binary, //java/com/example/frontend/...) in let cls = kind(cc_.*library, deps($jbs)) in $jbs intersect allpaths($jbs, $cls)' ``` -### What file dependencies exist ... {#file-dependencies} +### What file dependencies exist ... -#### What's the complete set of Java source files required to build foo? {#java-source-files} +#### What's the complete set of Java source files required to build foo? Source files: -``` -bazel query 'kind("source file", deps(//path/to/target/foo/...))' | grep java$ -``` +```bazel query 'kind("source file", deps(//path/to/target/foo/...))' | grep java$``` Generated files: -``` -bazel query 'kind("generated file", deps(//path/to/target/foo/...))' | grep java$ -``` +```bazel query 'kind("generated file", deps(//path/to/target/foo/...))' | grep java$``` -#### What is the complete set of Java source files required to build QUX's tests? {#qux-tests} +#### What is the complete set of Java source files required to build QUX's tests? Source files: -``` -bazel query 'kind("source file", deps(kind(".*_test rule", javatests/com/example/qux/...)))' | grep java$ -``` +```bazel query 'kind("source file", deps(kind(".*_test rule", javatests/com/example/qux/...)))' | grep java$``` Generated files: -``` -bazel query 'kind("generated file", deps(kind(".*_test rule", javatests/com/example/qux/...)))' | grep java$ -``` +```bazel query 'kind("generated file", deps(kind(".*_test rule", javatests/com/example/qux/...)))' | grep java$``` -### What differences in dependencies between X and Y exist ... {#differences-in-dependencies} +### What differences in dependencies between X and Y exist ... -#### What targets does `//foo` depend on that `//foo:foolib` does not? {#foo-targets} +#### What targets does `//foo` depend on that `//foo:foolib` does not? -``` -bazel query 'deps(//foo) except deps(//foo:foolib)' -``` +```bazel query 'deps(//foo) except deps(//foo:foolib)'``` -#### What C++ libraries do the `foo` tests depend on that the `//foo` production binary does _not_ depend on? {#foo-cxx-libraries} +#### What C++ libraries do the `foo` tests depend on that the `//foo` production binary does _not_ depend on? -``` -bazel query 'kind("cc_library", deps(kind(".*test rule", foo/...)) except deps(//foo))' -``` +```bazel query 'kind("cc_library", deps(kind(".*test rule", foo/...)) except deps(//foo))'``` -### Why does this dependency exist ... {#why-dependencies} +### Why does this dependency exist ... -#### Why does `bar` depend on `groups2`? {#dependency-bar-groups2} +#### Why does `bar` depend on `groups2`? -``` -bazel query 'somepath(bar/...,groups2/...:*)' -``` +```bazel query 'somepath(bar/...,groups2/...:*)'``` Once you have the results of this query, you will often find that a single target stands out as being an unexpected or egregious and undesirable dependency of `bar`. The query can then be further refined to: -#### Show me a path from `docker/updater:updater_systest` (a `py_test`) to some `cc_library` that it depends upon: {#path-docker-cclibrary} +#### Show me a path from `docker/updater:updater_systest` (a `py_test`) to some `cc_library` that it depends upon: -``` -bazel query 'let cc = kind(cc_library, deps(docker/updater:updater_systest)) in - somepath(docker/updater:updater_systest, $cc)' -``` +```bazel query 'let cc = kind(cc_library, deps(docker/updater:updater_systest)) in + somepath(docker/updater:updater_systest, $cc)'``` -#### Why does library `//photos/frontend:lib` depend on two variants of the same library `//third_party/jpeglib` and `//third_party/jpeg`? {#library-two-variants} +#### Why does library `//photos/frontend:lib` depend on two variants of the same library `//third_party/jpeglib` and `//third_party/jpeg`? This query boils down to: "show me the subgraph of `//photos/frontend:lib` that depends on both libraries". When shown in topological order, the last element of the result is the most likely culprit. -``` -bazel query 'allpaths(//photos/frontend:lib, //third_party/jpeglib) +```bazel query 'allpaths(//photos/frontend:lib, //third_party/jpeglib) intersect allpaths(//photos/frontend:lib, //third_party/jpeg)' //photos/frontend:lib @@ -325,49 +277,41 @@ bazel query 'allpaths(//photos/frontend:lib, //third_party/jpeglib) //third_party/jpeg/img:renderer ``` -### What depends on ... {#depends-on} +### What depends on ... -#### What rules under bar depend on Y? {#rules-bar-y} +#### What rules under bar depend on Y? -``` -bazel query 'bar/... intersect allpaths(bar/..., Y)' -``` +```bazel query 'bar/... intersect allpaths(bar/..., Y)'``` Note: `X intersect allpaths(X, Y)` is the general idiom for the query "which X depend on Y?" If expression X is non-trivial, it may be convenient to bind a name to it using `let` to avoid duplication. -#### What targets directly depend on T, in T's package? {#targets-t} +#### What targets directly depend on T, in T's package? -``` -bazel query 'same_pkg_direct_rdeps(T)' -``` +```bazel query 'same_pkg_direct_rdeps(T)'``` -### How do I break a dependency ... {#break-dependency} +### How do I break a dependency ... {/* TODO find a convincing value of X to plug in here */} -#### What dependency paths do I have to break to make `bar` no longer depend on X? {#break-dependency-bar-x} +#### What dependency paths do I have to break to make `bar` no longer depend on X? To output the graph to a `svg` file: -``` -bazel query 'allpaths(bar/...,X)' --output graph | dot -Tsvg > /tmp/dep.svg -``` +```bazel query 'allpaths(bar/...,X)' --output graph | dot -Tsvg > /tmp/dep.svg``` -### Misc {#misc} +### Misc -#### How many sequential steps are there in the `//foo-tests` build? {#steps-footests} +#### How many sequential steps are there in the `//foo-tests` build? Unfortunately, the query language can't currently give you the longest path from x to y, but it can find the (or rather _a_) most distant node from the starting point, or show you the _lengths_ of the longest path from x to every y that it depends on. Use `maxrank`: -``` -bazel query 'deps(//foo-tests)' --output maxrank | tail -1 -85 //third_party/zlib:zutil.c -``` +```bazel query 'deps(//foo-tests)' --output maxrank | tail -1 +85 //third_party/zlib:zutil.c``` The result indicates that there exist paths of length 85 that must occur in order in this build. diff --git a/query/language.mdx b/query/language.mdx index ee539b29..1f7de67d 100644 --- a/query/language.mdx +++ b/query/language.mdx @@ -13,7 +13,7 @@ For practical use cases, see the [Bazel Query How-To](/query/guide). In addition to `query`, which runs on the post-loading phase target graph, Bazel includes *action graph query* and *configurable query*. -### Action graph query {#aquery} +### Action graph query The action graph query (`aquery`) operates on the post-analysis Configured Target Graph and exposes information about **Actions**, **Artifacts**, and @@ -23,7 +23,7 @@ For example, the actual commands run and their inputs, outputs, and mnemonics. For more details, see the [aquery reference](/query/aquery). -### Configurable query {#cquery} +### Configurable query Traditional Bazel query runs on the post-loading phase target graph and therefore has no concept of configurations and their related concepts. Notably, @@ -34,7 +34,7 @@ doesn't provide all of the functionality of this original query. For more details, see the [cquery reference](/query/cquery). -## Examples {#examples} +## Examples How do people use `bazel query`? Here are typical examples: @@ -52,7 +52,7 @@ the `foo_bin` target does not? kind("cc_library", deps(kind(".*test rule", foo/...)) except deps(//foo:foo_bin)) ``` -## Tokens: The lexical syntax {#tokens} +## Tokens: The lexical syntax Expressions in the query language are composed of the following tokens: @@ -136,7 +136,7 @@ tokens: Whitespace characters outside of a quoted word are ignored. -## Bazel query language concepts {#language-concepts} +## Bazel query language concepts The Bazel query language is a language of expressions. Every expression evaluates to a **partially-ordered set** of targets, @@ -149,7 +149,7 @@ aspects of it, for example: * **Set:** The partial order of the targets is not interesting. * **Graph:** The partial order of targets is significant. -### Cycles in the dependency graph {#dependency-graph-cycles} +### Cycles in the dependency graph Build dependency graphs should be acyclic. @@ -161,7 +161,7 @@ operates over may contain cycles that do not exist in the configured target graph. Cycles in the configured target graph are detected and reported as errors by [`bazel cquery`](/query/cquery) and [`bazel aquery`](/query/aquery). -### Implicit dependencies {#implicit-dependencies} +### Implicit dependencies In addition to build dependencies that are defined explicitly in `BUILD` files, Bazel adds additional _implicit_ dependencies to rules. Implicit dependencies @@ -179,7 +179,7 @@ Note that, as query does not consider configurations, potential toolchain required toolchain types. See [toolchain documentation](/extending/toolchains#writing-rules-toolchains). -### Soundness {#soundness} +### Soundness Bazel query language expressions operate over the build dependency graph, which is the graph implicitly defined by all @@ -199,7 +199,7 @@ because, for example, the query tool will include all the files needed to support message translation, even though you don't intend to use that feature in your build. -### On the preservation of graph order {#graph-order} +### On the preservation of graph order Operations preserve any ordering constraints inherited from their subexpressions. You can think of @@ -235,7 +235,7 @@ Operators that introduce ordering constraints include: `allpaths`, `deps`, `rdeps`, `somepath`, and the target pattern wildcards `package:*`, `dir/...`, etc. -### Sky query {#sky-query} +### Sky query _Sky Query_ is a mode of query that operates over a specified _universe scope_. @@ -299,7 +299,7 @@ As well, Sky Query does its work by introspecting the graph, which is what the default implementation does. Thus, there are some circumstances in which it is faster and uses less memory. -## Expressions: Syntax and semantics of the grammar {#expressions} +## Expressions: Syntax and semantics of the grammar This is the grammar of the Bazel query language, expressed in EBNF notation: @@ -319,7 +319,7 @@ expr ::= word The following sections describe each of the productions of this grammar in order. -### Target patterns {#target-patterns} +### Target patterns ``` expr ::= word @@ -362,7 +362,7 @@ _graph_ over those targets. (No guarantees are made about the relative ordering of the result nodes against other nodes.) For more details, see the [graph order](#graph-order) section. -### Variables {#variables} +### Variables ```none expr ::= let name = expr{{ '' }}1{{ '' }} in expr{{ '' }}2{{ '' }} @@ -400,7 +400,7 @@ the language can also be expressed without them. However, they improve the conciseness of many queries, and may also lead to more efficient query evaluation. -### Parenthesized expressions {#parenthesized-expressions} +### Parenthesized expressions ```none expr ::= (expr) @@ -409,7 +409,7 @@ expr ::= (expr) Parentheses associate subexpressions to force an order of evaluation. A parenthesized expression evaluates to the value of its argument. -### Algebraic set operations: intersection, union, set difference {#algebraic-set-operations} +### Algebraic set operations: intersection, union, set difference ```none expr ::= expr intersect expr @@ -453,7 +453,7 @@ x intersect (y union z) Important: Use parentheses where there is any danger of ambiguity in reading a query expression. -### Read targets from an external source: set {#set} +### Read targets from an external source: set ```none expr ::= set(word *) @@ -491,7 +491,7 @@ Note: `set()` introduces no graph ordering constraints, so path information may be lost when saving and reloading sets of nodes using it. For more details, see the [graph order](#graph-order) section below. -## Functions {#functions} +## Functions ```none expr ::= word '(' int | word | expr ... ')' @@ -521,7 +521,7 @@ functions are available: * [`visible`](#visible) -### Transitive closure of dependencies: deps {#deps} +### Transitive closure of dependencies: deps ```none expr ::= deps(expr) @@ -551,7 +551,7 @@ correspond to the ranks shown in the [`minrank`](#output-ranked) output format.) If the depth parameter is omitted, the search is unbounded: it computes the reflexive transitive closure of prerequisites. -### Transitive closure of reverse dependencies: rdeps {#rdeps} +### Transitive closure of reverse dependencies: rdeps ```none expr ::= rdeps(expr, expr) @@ -575,7 +575,7 @@ numbers correspond to the ranks shown in the [`minrank`](#output-ranked) output format.) If the depth parameter is omitted, the search is unbounded. -### Transitive closure of all reverse dependencies: allrdeps {#allrdeps} +### Transitive closure of all reverse dependencies: allrdeps ``` expr ::= allrdeps(expr) @@ -590,7 +590,7 @@ evaluated to, instead of being separately specified. Thus, if `--universe_scope=//foo/...` was passed, then `allrdeps(//bar)` is equivalent to `rdeps(//foo/..., //bar)`. -### Direct reverse dependencies in the same package: same_pkg_direct_rdeps {#same_pkg_direct_rdeps} +### Direct reverse dependencies in the same package: same_pkg_direct_rdeps ``` expr ::= same_pkg_direct_rdeps(expr) @@ -599,7 +599,7 @@ expr ::= same_pkg_direct_rdeps(expr) The `same_pkg_direct_rdeps(x)` operator evaluates to the full set of targets that are in the same package as a target in the argument set, and which directly depend on it. -### Dealing with a target's package: siblings {#siblings} +### Dealing with a target's package: siblings ``` expr ::= siblings(expr) @@ -608,7 +608,7 @@ expr ::= siblings(expr) The `siblings(x)` operator evaluates to the full set of targets that are in the same package as a target in the argument set. -### Arbitrary choice: some {#some} +### Arbitrary choice: some ``` expr ::= some(expr) @@ -637,7 +637,7 @@ equivalent to `//foo:main`. It is an error if the specified argument set is empty, as in the expression `some(//foo:main intersect //bar:baz)`. -### Path operators: somepath, allpaths {#somepath-allpaths} +### Path operators: somepath, allpaths ``` expr ::= somepath(expr, expr) @@ -661,7 +661,7 @@ See the section on [graph order](#graph-order) for more details.
- Somepath + Somepath
somepath(S1 + S2, E), one possible result.
{/* digraph somepath1 { @@ -692,7 +692,7 @@ See the section on [graph order](#graph-order) for more details.
- Somepath + Somepath
somepath(S1 + S2, E), another possible result.
{/* digraph somepath2 { @@ -721,7 +721,7 @@ See the section on [graph order](#graph-order) for more details.
- Allpaths + Allpaths
allpaths(S1 + S2, E)
{/* digraph allpaths { @@ -754,7 +754,7 @@ See the section on [graph order](#graph-order) for more details. -### Target kind filtering: kind {#kind} +### Target kind filtering: kind ``` expr ::= kind(word, expr) @@ -815,7 +815,7 @@ file` and `.*_test`, are not considered words by the parser. When matching for `package group`, targets ending in `:all` may not yield any results. Use `:all-targets` instead. -### Target name filtering: filter {#filter} +### Target name filtering: filter ``` expr ::= filter(word, expr) @@ -867,7 +867,7 @@ filter("\.cc$", deps(//foo)) will provide a list of all `.cc` files used to build `//foo`. -### Rule attribute filtering: attr {#attr} +### Rule attribute filtering: attr ``` expr ::= attr(word, word, expr) @@ -960,7 +960,7 @@ some_rule( This works because the character before `key=value` will be `{` or a space and the character after `key=value` will be a comma or `}`. -### Rule visibility filtering: visible {#visible} +### Rule visibility filtering: visible ``` expr ::= visible(expr, expr) @@ -983,7 +983,7 @@ visible(//foo, //bar:*) will select all targets in the package `//bar` that `//foo` can depend on without violating visibility restrictions. -### Evaluation of rule attributes of type label: labels {#labels} +### Evaluation of rule attributes of type label: labels ``` expr ::= labels(word, expr) @@ -1000,7 +1000,7 @@ the `//foo` rule. If there are multiple rules with `srcs` attributes in the inputs set, the union of their `srcs` is returned. -### Expand and filter test_suites: tests {#tests} +### Expand and filter test_suites: tests ``` expr ::= tests(expr) @@ -1025,7 +1025,7 @@ foo:*`: this may include tests belonging to other packages, that are referenced directly or indirectly via `test_suite` rules. -### Executable targets: executables {#executables} +### Executable targets: executables ``` expr ::= executables(expr) @@ -1039,7 +1039,7 @@ or any other rule that sets `executable = True` in its definition. This doesn't include test targets, which can be added to the result with the [`tests`](#tests) operator. -### Package definition files: buildfiles {#buildfiles} +### Package definition files: buildfiles ``` expr ::= buildfiles(expr) @@ -1075,7 +1075,7 @@ target `//a:b.bzl`), but this isn't necessarily the case. Therefore, misleading when formatted in a structured way, such as [`--output=xml`](#xml). -### Package definition files: rbuildfiles {#rbuildfiles} +### Package definition files: rbuildfiles ``` expr ::= rbuildfiles(word, ...) @@ -1107,7 +1107,7 @@ outputs of the `buildfiles` operator are targets corresponding to all packages a files needed by a given input. However, the inputs of the `rbuildfiles` operator are not those targets, but rather the path fragments that correspond to those targets. -### Package definition files: loadfiles {#loadfiles} +### Package definition files: loadfiles ``` expr ::= loadfiles(expr) @@ -1124,7 +1124,7 @@ necessarily the case. Therefore, `loadfiles` doesn't compose well with other que operators and its results can be misleading when formatted in a structured way, such as [`--output=xml`](#xml). -## Output formats {#output-formats} +## Output formats `bazel query` generates a graph. You specify the content, format, and ordering by which @@ -1143,9 +1143,10 @@ an output format other than `graph` is used. Similarly, `--xml:line_numbers` applies only when `--output=xml` is being used. -### On the ordering of results {#results-ordering} +### On the ordering of results -Although query expressions always follow the "[law of conservation of graph order](#graph-order)", _presenting_ the results may be done +Although query expressions always follow the "[law of +conservation of graph order](#graph-order)", _presenting_ the results may be done in either a dependency-ordered or unordered manner. This does **not** influence the targets in the result set or how the query is computed. It only affects how the results are printed to stdout. Moreover, nodes that are @@ -1180,7 +1181,7 @@ in which they were visited. Printing nodes in this order may be slower, so it should be used only when determinism is important. -### Print the source form of targets as they would appear in BUILD {#target-source-form} +### Print the source form of targets as they would appear in BUILD ``` --output build @@ -1196,7 +1197,7 @@ giving the name of the macro that was evaluated to produce the effective rule. Although the output uses the same syntax as `BUILD` files, it is not guaranteed to produce a valid `BUILD` file. -### Print the label of each target {#print-label-target} +### Print the label of each target ``` --output label @@ -1224,7 +1225,7 @@ below) format, the distinction becomes clear: the two targets have the same name, but one has kind `sh_binary rule` and the other kind `source file`. -### Print the label and kind of each target {#print-target-label} +### Print the label and kind of each target ``` --output label_kind @@ -1234,7 +1235,7 @@ Like `label`, this output format prints the labels of each target in the resulting graph, in topological order, but it additionally precedes the label by the [_kind_](#kind) of the target. -### Print targets in protocol buffer format {#print-target-proto} +### Print targets in protocol buffer format ``` --output proto @@ -1244,7 +1245,7 @@ Prints the query output as a [`QueryResult`](https://github.com/bazelbuild/bazel/blob/master/src/main/protobuf/build.proto) protocol buffer. -### Print targets in length-delimited protocol buffer format {#print-target-length-delimited-proto} +### Print targets in length-delimited protocol buffer format ``` --output streamed_proto @@ -1259,7 +1260,7 @@ protocol buffers. This is useful to _(i)_ get around of protocol buffers when there are too many targets to fit in a single `QueryResult` or _(ii)_ to start processing while Bazel is still outputting. -### Print targets in text proto format {#print-target-textproto} +### Print targets in text proto format ``` --output textproto @@ -1270,7 +1271,7 @@ Similar to `--output proto`, prints the protocol buffer but in [text format](https://protobuf.dev/reference/protobuf/textformat-spec/). -### Print targets in ndjson format {#print-target-streamed-jsonproto} +### Print targets in ndjson format ``` --output streamed_jsonproto @@ -1280,7 +1281,7 @@ Similar to `--output streamed_proto`, prints a stream of [`Target`](https://github.com/bazelbuild/bazel/blob/master/src/main/protobuf/build.proto) protocol buffers but in [ndjson](https://github.com/ndjson/ndjson-spec) format. -### Print the label of each target, in rank order {#print-target-label-rank-order} +### Print the label of each target, in rank order ``` --output minrank --output maxrank @@ -1291,7 +1292,8 @@ and `maxrank` output formats print the labels of each target in the resulting graph, but instead of appearing in topological order, they appear in rank order, preceded by their rank number. These are unaffected by the result ordering -`--[no]order_results` flag (see [notes on the ordering of results](#result-order)). +`--[no]order_results` flag (see [notes on +the ordering of results](#result-order)). There are two variants of this format: `minrank` ranks each node by the length of the shortest path from a root node to it. @@ -1328,7 +1330,7 @@ are specified, respectively. -
Out ranked + Out ranked
@@ -1355,7 +1357,7 @@ are specified, respectively.
   
-### Print the location of each target {#print-target-location} +### Print the location of each target ``` --output location @@ -1378,11 +1380,9 @@ generates it is printed. (The query tool does not have sufficient information to find the actual location of the generated file, and in any case, it might not exist if a build has not yet been performed.) -### Print the set of packages {#print-package-set} +### Print the set of packages -``` ---output package -``` +```--output package``` This option prints the name of all packages to which some target in the result set belongs. The names are printed in @@ -1398,11 +1398,9 @@ In conjunction with the `deps(...)` query, this output option can be used to find the set of packages that must be checked out in order to build a given set of targets. -### Display a graph of the result {#display-result-graph} +### Display a graph of the result -``` ---output graph -``` +```--output graph``` This option causes the query result to be printed as a directed graph in the popular AT&T GraphViz format. Typically the @@ -1426,7 +1424,7 @@ same `genrule`; in the factored graph, all these files are represented by a single node. This behavior may be disabled with the `--nograph:factored` option. -#### `--graph:node_limit n` {#graph-nodelimit} +#### `--graph:node_limit n` The option specifies the maximum length of the label string for a graph node in the output. Longer labels will be truncated; -1 @@ -1436,7 +1434,7 @@ handle labels exceeding 1024 characters, which is the default value of this option. This option has no effect unless `--output=graph` is being used. -#### `--[no]graph:factored` {#graph-factored} +#### `--[no]graph:factored` By default, graphs are displayed in factored form, as explained [above](#output-graph). @@ -1446,11 +1444,9 @@ impractical, but the simpler format may ease processing by other tools (such as grep). This option has no effect unless `--output=graph` is being used. -### XML {#xml} +### XML -``` ---output xml -``` +```--output xml``` This option causes the resulting targets to be printed in an XML form. The output starts with an XML header such as this @@ -1527,12 +1523,12 @@ attribute, whose value is the target's label, and a `location` attribute, whose value is the target's location as printed by the [`--output location`](#print-target-location). -#### `--[no]xml:line_numbers` {#xml-linenumbers} +#### `--[no]xml:line_numbers` By default, the locations displayed in the XML output contain line numbers. When `--noxml:line_numbers` is specified, line numbers are not printed. -#### `--[no]xml:default_values` {#xml-defaultvalues} +#### `--[no]xml:default_values` By default, XML output does not include rule attribute whose value is the default value for that kind of attribute (for example, if it @@ -1540,13 +1536,13 @@ were not specified in the `BUILD` file, or the default value was provided explicitly). This option causes such attribute values to be included in the XML output. -### Regular expressions {#regular-expressions} +### Regular expressions Regular expressions in the query language use the Java regex library, so you can use the full syntax for [`java.util.regex.Pattern`](https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html). -### Querying with external repositories {#querying-external-repositories} +### Querying with external repositories If the build depends on rules from [external repositories](/external/overview) then query results will include these dependencies. For diff --git a/query/quickstart.mdx b/query/quickstart.mdx index d2085b8b..eebcec98 100644 --- a/query/quickstart.mdx +++ b/query/quickstart.mdx @@ -205,7 +205,7 @@ dot -Tpng < graph.in > graph.png ``` If you open up `graph.png`, you should see something like this. The graph below has been simplified to make the essential path details clearer in this guide. -![Diagram showing a relationship from cafe to chef to the dishes: pizza and mac and cheese which diverges into the separate ingredients: cheese, tomatoes, dough, and macaroni.](/query/images/query_graph1.png "Dependency graph") +![Diagram showing a relationship from cafe to chef to the dishes: pizza and mac and cheese which diverges into the separate ingredients: cheese, tomatoes, dough, and macaroni.](images/query_graph1.png "Dependency graph") This helps when you want to see the outputs of the different query functions throughout this guide. @@ -421,7 +421,7 @@ bazel query --noimplicit_deps 'deps(:runner)' --output graph > graph2.in dot -Tpng < graph2.in > graph2.png ``` -[![The same graph as the first one except now there is a spoke stemming from the chef target with smoothie which leads to banana and strawberry](/query/images/query_graph2.png "Updated dependency graph")](/query/images/query_graph2.png) +[![The same graph as the first one except now there is a spoke stemming from the chef target with smoothie which leads to banana and strawberry](images/query_graph2.png "Updated dependency graph")](images/query_graph2.png) Looking at `graph2.png`, you can see that `Smoothie` has no shared dependencies with other dishes but is just another target that the `Chef` relies on. @@ -465,7 +465,7 @@ bazel query "allpaths(//src/main/java/com/example/restaurant/..., //src/main/jav //src/main/java/com/example/restaurant:chef ``` -![Output path of cafe to chef to pizza,mac and cheese to cheese](/query/images/query_graph3.png "Output path for dependency") +![Output path of cafe to chef to pizza,mac and cheese to cheese](images/query_graph3.png "Output path for dependency") The output of `allpaths()` is a little harder to read as it is a flattened list of the dependencies. Visualizing this graph using Graphviz makes the relationship clearer to understand. diff --git a/reference/be/c-cpp.mdx b/reference/be/c-cpp.mdx index 84b19d3e..214f06b4 100644 --- a/reference/be/c-cpp.mdx +++ b/reference/be/c-cpp.mdx @@ -4,21 +4,21 @@ title: 'C / C++ Rules' ## Rules -* [cc_binary](#cc_binary) -* [cc_import](#cc_import) -* [cc_library](#cc_library) -* [cc_shared_library](#cc_shared_library) -* [cc_static_library](#cc_static_library) -* [cc_test](#cc_test) -* [cc_toolchain](#cc_toolchain) -* [fdo_prefetch_hints](#fdo_prefetch_hints) -* [fdo_profile](#fdo_profile) -* [memprof_profile](#memprof_profile) -* [propeller_optimize](#propeller_optimize) +* [cc\_binary](#cc_binary) +* [cc\_import](#cc_import) +* [cc\_library](#cc_library) +* [cc\_shared\_library](#cc_shared_library) +* [cc\_static\_library](#cc_static_library) +* [cc\_test](#cc_test) +* [cc\_toolchain](#cc_toolchain) +* [fdo\_prefetch\_hints](#fdo_prefetch_hints) +* [fdo\_profile](#fdo_profile) +* [memprof\_profile](#memprof_profile) +* [propeller\_optimize](#propeller_optimize) -## cc_binary +## cc\_binary -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/cc_binary.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/cc_binary.bzl) ``` cc_binary(name, deps, srcs, data, additional_compiler_inputs, additional_linker_inputs, args, aspect_hints, compatible_with, conlyopts, copts, cxxopts, defines, deprecation, dynamic_deps, env, exec_compatible_with, exec_group_compatible_with, exec_properties, features, hdrs_check, includes, licenses, link_extra_lib, linkopts, linkshared, linkstatic, local_defines, malloc, module_interfaces, nocopts, output_licenses, package_metadata, reexport_deps, restricted_to, stamp, tags, target_compatible_with, testonly, toolchains, visibility, win_def_file) @@ -59,11 +59,11 @@ be `main`. | `defines` | List of strings; default is `[]` List of defines to add to the compile line of this and all dependent targets. Subject to ["Make" variable](/reference/be/make-variables) substitution and [Bourne shell tokenization](/reference/be/common-definitions#sh-tokenization). Each string, which must consist of a single Bourne shell token, is prepended with `-D` and added to the compile command line to this target, as well as to every rule that depends on it. Be very careful, since this may have far-reaching effects -- the defines are added to every target that depends on this target. When in doubt, add define values to [`local_defines`](#cc_binary.local_defines) instead. | | `dynamic_deps` | List of [labels](/concepts/labels); default is `[]` These are other `cc_shared_library` dependencies the current target depends on. The `cc_shared_library` implementation will use the list of `dynamic_deps` (transitively, i.e. also the `dynamic_deps` of the current target's `dynamic_deps`) to decide which `cc_libraries` in the transitive `deps` should not be linked in because they are already provided by a different `cc_shared_library`. | | `hdrs_check` | String; default is `""` Deprecated, no-op. | -| `includes` | List of strings; default is `[]` List of include dirs to be added to the compile line. Subject to ["Make variable"](/reference/be/make-variables) substitution. Each string is prepended with the package path and passed to the C++ toolchain for expansion via the "include_paths" CROSSTOOL feature. A toolchain running on a POSIX system with typical feature definitions will produce `-isystem path_to_package/include_entry`. This should only be used for third-party libraries that do not conform to the Google style of writing #include statements. Unlike [COPTS](#cc_binary.copts), these flags are added for this rule and every rule that depends on it. (Note: not the rules it depends upon!) Be very careful, since this may have far-reaching effects. When in doubt, add "-I" flags to [COPTS](#cc_binary.copts) instead. The added `include` paths will include generated files as well as files in the source tree. | +| `includes` | List of strings; default is `[]` List of include dirs to be added to the compile line. Subject to ["Make variable"](/reference/be/make-variables) substitution. Each string is prepended with the package path and passed to the C++ toolchain for expansion via the "include\_paths" CROSSTOOL feature. A toolchain running on a POSIX system with typical feature definitions will produce `-isystem path_to_package/include_entry`. This should only be used for third-party libraries that do not conform to the Google style of writing #include statements. Unlike [COPTS](#cc_binary.copts), these flags are added for this rule and every rule that depends on it. (Note: not the rules it depends upon!) Be very careful, since this may have far-reaching effects. When in doubt, add "-I" flags to [COPTS](#cc_binary.copts) instead. The added `include` paths will include generated files as well as files in the source tree. | | `link_extra_lib` | [Label](/concepts/labels); default is `"@bazel_tools//tools/cpp:link_extra_lib"` Control linking of extra libraries. By default, C++ binaries are linked against `@bazel_tools//tools/cpp:link_extra_lib`, which by default depends on the label flag `@bazel_tools//tools/cpp:link_extra_libs`. Without setting the flag, this library is empty by default. Setting the label flag allows linking optional dependencies, such as overrides for weak symbols, interceptors for shared library functions, or special runtime libraries (for malloc replacements, prefer `malloc` or `--custom_malloc`). Setting this attribute to `None` disables this behaviour. | | `linkopts` | List of strings; default is `[]` Add these flags to the C++ linker command. Subject to ["Make" variable](make-variables) substitution, [Bourne shell tokenization](common-definitions#sh-tokenization) and [label expansion](common-definitions#label-expansion). Each string in this attribute is added to `LINKOPTS` before linking the binary target. Each element of this list that does not start with `$` or `-` is assumed to be the label of a target in `deps`. The list of files generated by that target is appended to the linker options. An error is reported if the label is invalid, or is not declared in `deps`. | -| `linkshared` | Boolean; default is `False` Create a shared library. To enable this attribute, include `linkshared=True` in your rule. By default this option is off. The presence of this flag means that linking occurs with the `-shared` flag to `gcc`, and the resulting shared library is suitable for loading into for example a Java program. However, for build purposes it will never be linked into the dependent binary, as it is assumed that shared libraries built with a [cc_binary](#cc_binary) rule are only loaded manually by other programs, so it should not be considered a substitute for the [cc_library](#cc_library) rule. For sake of scalability we recommend avoiding this approach altogether and simply letting `java_library` depend on `cc_library` rules instead. If you specify both `linkopts=['-static']` and `linkshared=True`, you get a single completely self-contained unit. If you specify both `linkstatic=True` and `linkshared=True`, you get a single, mostly self-contained unit. | -| `linkstatic` | Boolean; default is `True` For [`cc_binary`](/reference/be/c-cpp#cc_binary) and [`cc_test`](/reference/be/c-cpp#cc_test): link the binary in static mode. For `cc_library.link_static`: see below. By default this option is on for `cc_binary` and off for the rest. If enabled and this is a binary or test, this option tells the build tool to link in `.a`'s instead of `.so`'s for user libraries whenever possible. System libraries such as libc (but *not* the C/C++ runtime libraries, see below) are still linked dynamically, as are libraries for which there is no static library. So the resulting executable will still be dynamically linked, hence only *mostly* static. There are really three different ways to link an executable: * STATIC with fully_static_link feature, in which everything is linked statically; e.g. "`gcc -static foo.o libbar.a libbaz.a -lm`". This mode is enabled by specifying `fully_static_link` in the [`features`](/reference/be/common-definitions#features) attribute. * STATIC, in which all user libraries are linked statically (if a static version is available), but where system libraries (excluding C/C++ runtime libraries) are linked dynamically, e.g. "`gcc foo.o libfoo.a libbaz.a -lm`". This mode is enabled by specifying `linkstatic=True`. * DYNAMIC, in which all libraries are linked dynamically (if a dynamic version is available), e.g. "`gcc foo.o libfoo.so libbaz.so -lm`". This mode is enabled by specifying `linkstatic=False`. If the `linkstatic` attribute or `fully_static_link` in `features` is used outside of `//third_party` please include a comment near the rule to explain why. The `linkstatic` attribute has a different meaning if used on a [`cc_library()`](/reference/be/c-cpp#cc_library) rule. For a C++ library, `linkstatic=True` indicates that only static linking is allowed, so no `.so` will be produced. linkstatic=False does not prevent static libraries from being created. The attribute is meant to control the creation of dynamic libraries. There should be very little code built with `linkstatic=False` in production. If `linkstatic=False`, then the build tool will create symlinks to depended-upon shared libraries in the `*.runfiles` area. | +| `linkshared` | Boolean; default is `False` Create a shared library. To enable this attribute, include `linkshared=True` in your rule. By default this option is off. The presence of this flag means that linking occurs with the `-shared` flag to `gcc`, and the resulting shared library is suitable for loading into for example a Java program. However, for build purposes it will never be linked into the dependent binary, as it is assumed that shared libraries built with a [cc\_binary](#cc_binary) rule are only loaded manually by other programs, so it should not be considered a substitute for the [cc\_library](#cc_library) rule. For sake of scalability we recommend avoiding this approach altogether and simply letting `java_library` depend on `cc_library` rules instead. If you specify both `linkopts=['-static']` and `linkshared=True`, you get a single completely self-contained unit. If you specify both `linkstatic=True` and `linkshared=True`, you get a single, mostly self-contained unit. | +| `linkstatic` | Boolean; default is `True` For [`cc_binary`](/reference/be/c-cpp#cc_binary) and [`cc_test`](/reference/be/c-cpp#cc_test): link the binary in static mode. For `cc_library.link_static`: see below. By default this option is on for `cc_binary` and off for the rest. If enabled and this is a binary or test, this option tells the build tool to link in `.a`'s instead of `.so`'s for user libraries whenever possible. System libraries such as libc (but *not* the C/C++ runtime libraries, see below) are still linked dynamically, as are libraries for which there is no static library. So the resulting executable will still be dynamically linked, hence only *mostly* static. There are really three different ways to link an executable: * STATIC with fully\_static\_link feature, in which everything is linked statically; e.g. "`gcc -static foo.o libbar.a libbaz.a -lm`". This mode is enabled by specifying `fully_static_link` in the [`features`](/reference/be/common-definitions#features) attribute. * STATIC, in which all user libraries are linked statically (if a static version is available), but where system libraries (excluding C/C++ runtime libraries) are linked dynamically, e.g. "`gcc foo.o libfoo.a libbaz.a -lm`". This mode is enabled by specifying `linkstatic=True`. * DYNAMIC, in which all libraries are linked dynamically (if a dynamic version is available), e.g. "`gcc foo.o libfoo.so libbaz.so -lm`". This mode is enabled by specifying `linkstatic=False`. If the `linkstatic` attribute or `fully_static_link` in `features` is used outside of `//third_party` please include a comment near the rule to explain why. The `linkstatic` attribute has a different meaning if used on a [`cc_library()`](/reference/be/c-cpp#cc_library) rule. For a C++ library, `linkstatic=True` indicates that only static linking is allowed, so no `.so` will be produced. linkstatic=False does not prevent static libraries from being created. The attribute is meant to control the creation of dynamic libraries. There should be very little code built with `linkstatic=False` in production. If `linkstatic=False`, then the build tool will create symlinks to depended-upon shared libraries in the `*.runfiles` area. | | `local_defines` | List of strings; default is `[]` List of defines to add to the compile line. Subject to ["Make" variable](/reference/be/make-variables) substitution and [Bourne shell tokenization](/reference/be/common-definitions#sh-tokenization). Each string, which must consist of a single Bourne shell token, is prepended with `-D` and added to the compile command line for this target, but not to its dependents. Unlike `defines`, the defines are only added to the compile command line for this target. | | `malloc` | [Label](/concepts/labels); default is `"@bazel_tools//tools/cpp:malloc"` Override the default dependency on malloc. By default, C++ binaries are linked against `//tools/cpp:malloc`, which is an empty library so the binary ends up using libc malloc. This label must refer to a `cc_library`. If compilation is for a non-C++ rule, this option has no effect. The value of this attribute is ignored if `linkshared=True` is specified. | | `module_interfaces` | List of [labels](/concepts/labels); default is `[]` The list of files are regarded as C++20 Modules Interface. C++ Standard has no restriction about module interface file extension * Clang use cppm * GCC can use any source file extension * MSVC use ixx The use is guarded by the flag `--experimental_cpp_modules`. | @@ -72,9 +72,9 @@ be `main`. | `stamp` | Integer; default is `-1` Whether to encode build information into the binary. Possible values: * `stamp = 1`: Always stamp the build information into the binary, even in [`--nostamp`](/docs/user-manual#flag--stamp) builds. **This setting should be avoided**, since it potentially kills remote caching for the binary and any downstream actions that depend on it. * `stamp = 0`: Always replace build information by constant values. This gives good build result caching. * `stamp = -1`: Embedding of build information is controlled by the [`--[no]stamp`](/docs/user-manual#flag--stamp) flag. Stamped binaries are *not* rebuilt unless their dependencies change. | | `win_def_file` | [Label](/concepts/labels); default is `None` The Windows DEF file to be passed to linker. This attribute should only be used when Windows is the target platform. It can be used to [export symbols](https://msdn.microsoft.com/en-us/library/d91k01sh.aspx) during linking a shared library. | -## cc_import +## cc\_import -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/cc_import.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/cc_import.bzl) ``` cc_import(name, deps, data, hdrs, alwayslink, aspect_hints, compatible_with, defines, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, includes, interface_library, linkopts, objects, package_metadata, pic_objects, pic_static_library, restricted_to, shared_library, static_library, strip_include_prefix, system_provided, tags, target_compatible_with, testonly, toolchains, visibility) @@ -228,7 +228,7 @@ cc_import( | `hdrs` | List of [labels](/concepts/labels); default is `[]` The list of header files published by this precompiled library to be directly included by sources in dependent rules. | | `alwayslink` | Boolean; default is `False` If enabled, any binary that depends (directly or indirectly) on this C++ precompiled library will link in all the object files archived in the static library, even if some contain no symbols referenced by the binary. This is useful if your code isn't explicitly called by code in the binary, e.g., if your code registers to receive some callback provided by some service. If `alwayslink` doesn't work with VS 2017 on Windows, that is due to a [known issue](https://github.com/bazelbuild/bazel/issues/3949), please upgrade your VS 2017 to the latest version. | | `defines` | List of strings; default is `[]` List of defines to add to the compile line of this and all dependent targets. Subject to ["Make" variable](/reference/be/make-variables) substitution and [Bourne shell tokenization](/reference/be/common-definitions#sh-tokenization). Each string, which must consist of a single Bourne shell token, is prepended with `-D` and added to the compile command line to this target, as well as to every rule that depends on it. Be very careful, since this may have far-reaching effects -- the defines are added to every target that depends on this target. | -| `includes` | List of strings; default is `[]` List of include dirs to be added to the compile line. Subject to ["Make variable"](/reference/be/make-variables) substitution. Each string is prepended with the package path and passed to the C++ toolchain for expansion via the "include_paths" CROSSTOOL feature. A toolchain running on a POSIX system with typical feature definitions will produce `-isystem path_to_package/include_entry`. This should only be used for third-party libraries that do not conform to the Google style of writing #include statements. Unlike [COPTS](#cc_binary.copts), these flags are added for this rule and every rule that depends on it. (Note: not the rules it depends upon!) Be very careful, since this may have far-reaching effects. When in doubt, add "-I" flags to [COPTS](#cc_binary.copts) instead. The default `include` path doesn't include generated files. If you need to `#include` a generated header file, list it in the `srcs`. | +| `includes` | List of strings; default is `[]` List of include dirs to be added to the compile line. Subject to ["Make variable"](/reference/be/make-variables) substitution. Each string is prepended with the package path and passed to the C++ toolchain for expansion via the "include\_paths" CROSSTOOL feature. A toolchain running on a POSIX system with typical feature definitions will produce `-isystem path_to_package/include_entry`. This should only be used for third-party libraries that do not conform to the Google style of writing #include statements. Unlike [COPTS](#cc_binary.copts), these flags are added for this rule and every rule that depends on it. (Note: not the rules it depends upon!) Be very careful, since this may have far-reaching effects. When in doubt, add "-I" flags to [COPTS](#cc_binary.copts) instead. The default `include` path doesn't include generated files. If you need to `#include` a generated header file, list it in the `srcs`. | | `interface_library` | [Label](/concepts/labels); default is `None` A single interface library for linking the shared library. Permitted file types: `.ifso`, `.tbd`, `.lib`, `.so` or `.dylib` | | `linkopts` | List of strings; default is `[]` Add these flags to the C++ linker command. Subject to ["Make" variable](make-variables) substitution, [Bourne shell tokenization](common-definitions#sh-tokenization) and [label expansion](common-definitions#label-expansion). Each string in this attribute is added to `LINKOPTS` before linking the binary target. Each element of this list that does not start with `$` or `-` is assumed to be the label of a target in `deps`. The list of files generated by that target is appended to the linker options. An error is reported if the label is invalid, or is not declared in `deps`. | | `objects` | List of [labels](/concepts/labels); default is `[]` | @@ -239,9 +239,9 @@ cc_import( | `strip_include_prefix` | String; default is `""` The prefix to strip from the paths of the headers of this rule. When set, the headers in the `hdrs` attribute of this rule are accessible at their path with this prefix cut off. If it's a relative path, it's taken as a package-relative one. If it's an absolute one, it's understood as a repository-relative path. The prefix in the `include_prefix` attribute is added after this prefix is stripped. This attribute is only legal under `third_party`. | | `system_provided` | Boolean; default is `False` If enabled, it indicates the shared library required at runtime is provided by the system. In this case, `interface_library` should be specified and `shared_library` should be empty. | -## cc_library +## cc\_library -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/cc_library.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/cc_library.bzl) ``` cc_library(name, deps, srcs, data, hdrs, additional_compiler_inputs, additional_linker_inputs, alwayslink, aspect_hints, compatible_with, conlyopts, copts, cxxopts, defines, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, hdrs_check, implementation_deps, include_prefix, includes, licenses, linkopts, linkstamp, linkstatic, local_defines, module_interfaces, package_metadata, restricted_to, strip_include_prefix, tags, target_compatible_with, testonly, textual_hdrs, toolchains, visibility, win_def_file) @@ -454,7 +454,7 @@ cc_library( | `hdrs_check` | String; default is `""` Deprecated, no-op. | | `implementation_deps` | List of [labels](/concepts/labels); default is `[]` The list of other libraries that the library target depends on. Unlike with `deps`, the headers and include paths of these libraries (and all their transitive deps) are only used for compilation of this library, and not libraries that depend on it. Libraries specified with `implementation_deps` are still linked in binary targets that depend on this library. | | `include_prefix` | String; default is `""` The prefix to add to the paths of the headers of this rule. When set, the headers in the `hdrs` attribute of this rule are accessible at is the value of this attribute prepended to their repository-relative path. The prefix in the `strip_include_prefix` attribute is removed before this prefix is added. This attribute is only legal under `third_party`. | -| `includes` | List of strings; default is `[]` List of include dirs to be added to the compile line. Subject to ["Make variable"](/reference/be/make-variables) substitution. Each string is prepended with the package path and passed to the C++ toolchain for expansion via the "include_paths" CROSSTOOL feature. A toolchain running on a POSIX system with typical feature definitions will produce `-isystem path_to_package/include_entry`. This should only be used for third-party libraries that do not conform to the Google style of writing #include statements. Unlike [COPTS](#cc_binary.copts), these flags are added for this rule and every rule that depends on it. (Note: not the rules it depends upon!) Be very careful, since this may have far-reaching effects. When in doubt, add "-I" flags to [COPTS](#cc_binary.copts) instead. The added `include` paths will include generated files as well as files in the source tree. | +| `includes` | List of strings; default is `[]` List of include dirs to be added to the compile line. Subject to ["Make variable"](/reference/be/make-variables) substitution. Each string is prepended with the package path and passed to the C++ toolchain for expansion via the "include\_paths" CROSSTOOL feature. A toolchain running on a POSIX system with typical feature definitions will produce `-isystem path_to_package/include_entry`. This should only be used for third-party libraries that do not conform to the Google style of writing #include statements. Unlike [COPTS](#cc_binary.copts), these flags are added for this rule and every rule that depends on it. (Note: not the rules it depends upon!) Be very careful, since this may have far-reaching effects. When in doubt, add "-I" flags to [COPTS](#cc_binary.copts) instead. The added `include` paths will include generated files as well as files in the source tree. | | `linkopts` | List of strings; default is `[]` See [`cc_binary.linkopts`](/reference/be/c-cpp#cc_binary.linkopts). The `linkopts` attribute is also applied to any target that depends, directly or indirectly, on this library via `deps` attributes (or via other attributes that are treated similarly: the [`malloc`](/reference/be/c-cpp#cc_binary.malloc) attribute of [`cc_binary`](/reference/be/c-cpp#cc_binary)). Dependency linkopts take precedence over dependent linkopts (i.e. dependency linkopts appear later in the command line). Linkopts specified in [`--linkopt`](../user-manual#flag--linkopt) take precedence over rule linkopts. | Note that the `linkopts` attribute only applies @@ -477,16 +477,16 @@ with the `linkshared=True` attribute. See [`cc_binary.linkshared`](/reference/be/c-cpp#cc_binary.linkshared). | `linkstamp` | [Label](/concepts/labels); default is `None` Simultaneously compiles and links the specified C++ source file into the final binary. This trickery is required to introduce timestamp information into binaries; if we compiled the source file to an object file in the usual way, the timestamp would be incorrect. A linkstamp compilation may not include any particular set of compiler flags and so should not depend on any particular header, compiler option, or other build variable. *This option should only be needed in the `base` package.* | -| `linkstatic` | Boolean; default is `False` For [`cc_binary`](/reference/be/c-cpp#cc_binary) and [`cc_test`](/reference/be/c-cpp#cc_test): link the binary in static mode. For `cc_library.link_static`: see below. By default this option is on for `cc_binary` and off for the rest. If enabled and this is a binary or test, this option tells the build tool to link in `.a`'s instead of `.so`'s for user libraries whenever possible. System libraries such as libc (but *not* the C/C++ runtime libraries, see below) are still linked dynamically, as are libraries for which there is no static library. So the resulting executable will still be dynamically linked, hence only *mostly* static. There are really three different ways to link an executable: * STATIC with fully_static_link feature, in which everything is linked statically; e.g. "`gcc -static foo.o libbar.a libbaz.a -lm`". This mode is enabled by specifying `fully_static_link` in the [`features`](/reference/be/common-definitions#features) attribute. * STATIC, in which all user libraries are linked statically (if a static version is available), but where system libraries (excluding C/C++ runtime libraries) are linked dynamically, e.g. "`gcc foo.o libfoo.a libbaz.a -lm`". This mode is enabled by specifying `linkstatic=True`. * DYNAMIC, in which all libraries are linked dynamically (if a dynamic version is available), e.g. "`gcc foo.o libfoo.so libbaz.so -lm`". This mode is enabled by specifying `linkstatic=False`. If the `linkstatic` attribute or `fully_static_link` in `features` is used outside of `//third_party` please include a comment near the rule to explain why. The `linkstatic` attribute has a different meaning if used on a [`cc_library()`](/reference/be/c-cpp#cc_library) rule. For a C++ library, `linkstatic=True` indicates that only static linking is allowed, so no `.so` will be produced. linkstatic=False does not prevent static libraries from being created. The attribute is meant to control the creation of dynamic libraries. There should be very little code built with `linkstatic=False` in production. If `linkstatic=False`, then the build tool will create symlinks to depended-upon shared libraries in the `*.runfiles` area. | +| `linkstatic` | Boolean; default is `False` For [`cc_binary`](/reference/be/c-cpp#cc_binary) and [`cc_test`](/reference/be/c-cpp#cc_test): link the binary in static mode. For `cc_library.link_static`: see below. By default this option is on for `cc_binary` and off for the rest. If enabled and this is a binary or test, this option tells the build tool to link in `.a`'s instead of `.so`'s for user libraries whenever possible. System libraries such as libc (but *not* the C/C++ runtime libraries, see below) are still linked dynamically, as are libraries for which there is no static library. So the resulting executable will still be dynamically linked, hence only *mostly* static. There are really three different ways to link an executable: * STATIC with fully\_static\_link feature, in which everything is linked statically; e.g. "`gcc -static foo.o libbar.a libbaz.a -lm`". This mode is enabled by specifying `fully_static_link` in the [`features`](/reference/be/common-definitions#features) attribute. * STATIC, in which all user libraries are linked statically (if a static version is available), but where system libraries (excluding C/C++ runtime libraries) are linked dynamically, e.g. "`gcc foo.o libfoo.a libbaz.a -lm`". This mode is enabled by specifying `linkstatic=True`. * DYNAMIC, in which all libraries are linked dynamically (if a dynamic version is available), e.g. "`gcc foo.o libfoo.so libbaz.so -lm`". This mode is enabled by specifying `linkstatic=False`. If the `linkstatic` attribute or `fully_static_link` in `features` is used outside of `//third_party` please include a comment near the rule to explain why. The `linkstatic` attribute has a different meaning if used on a [`cc_library()`](/reference/be/c-cpp#cc_library) rule. For a C++ library, `linkstatic=True` indicates that only static linking is allowed, so no `.so` will be produced. linkstatic=False does not prevent static libraries from being created. The attribute is meant to control the creation of dynamic libraries. There should be very little code built with `linkstatic=False` in production. If `linkstatic=False`, then the build tool will create symlinks to depended-upon shared libraries in the `*.runfiles` area. | | `local_defines` | List of strings; default is `[]` List of defines to add to the compile line. Subject to ["Make" variable](/reference/be/make-variables) substitution and [Bourne shell tokenization](/reference/be/common-definitions#sh-tokenization). Each string, which must consist of a single Bourne shell token, is prepended with `-D` and added to the compile command line for this target, but not to its dependents. Unlike `defines`, the defines are only added to the compile command line for this target. | | `module_interfaces` | List of [labels](/concepts/labels); default is `[]` The list of files are regarded as C++20 Modules Interface. C++ Standard has no restriction about module interface file extension * Clang use cppm * GCC can use any source file extension * MSVC use ixx The use is guarded by the flag `--experimental_cpp_modules`. | | `strip_include_prefix` | String; default is `""` The prefix to strip from the paths of the headers of this rule. When set, the headers in the `hdrs` attribute of this rule are accessible at their path with this prefix cut off. If it's a relative path, it's taken as a package-relative one. If it's an absolute one, it's understood as a repository-relative path. The prefix in the `include_prefix` attribute is added after this prefix is stripped. This attribute is only legal under `third_party`. | | `textual_hdrs` | List of [labels](/concepts/labels); default is `[]` The list of header files published by this library to be textually included by sources in dependent rules. This is the location for declaring header files that cannot be compiled on their own; that is, they always need to be textually included by other source files to build valid code. | | `win_def_file` | [Label](/concepts/labels); default is `None` The Windows DEF file to be passed to linker. This attribute should only be used when Windows is the target platform. It can be used to [export symbols](https://msdn.microsoft.com/en-us/library/d91k01sh.aspx) during linking a shared library. | -## cc_shared_library +## cc\_shared\_library -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/cc_shared_library.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/cc_shared_library.bzl) ``` cc_shared_library(name, deps, additional_linker_inputs, aspect_hints, compatible_with, deprecation, dynamic_deps, exec_compatible_with, exec_group_compatible_with, exec_properties, exports_filter, features, package_metadata, restricted_to, roots, shared_lib_name, static_deps, tags, target_compatible_with, testonly, toolchains, user_link_flags, visibility, win_def_file) @@ -619,19 +619,19 @@ dependency or make sure that the `exports_filter` doesn't catch this target. | Attributes | | | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | -| `deps` | List of [labels](/concepts/labels); default is `[]` Top level libraries that will unconditionally be statically linked into the shared library after being whole-archived. Any transitive library dependency of these direct deps will be linked into this shared library as long as they have not already been linked by a `cc_shared_library` in `dynamic_deps`. During analysis, the rule implementation will consider any target listed in `deps` as being exported by the shared library in order to give errors when multiple `cc_shared_libraries` export the same targets. The rule implementation does not take care of informing the linker about which symbols should be exported by the shared object. The user should take care of this via linker scripts or visibility declarations in the source code. The implementation will also trigger errors whenever the same library is linked statically into more than one `cc_shared_library`. This can be avoided by adding `"LINKABLE_MORE_THAN_ONCE"` to the `cc_library.tags` or by listing the `cc_library` as an export of one of the shared libraries so that one can be made a `dynamic_dep` of the other. | +| `deps` | List of [labels](/concepts/labels); default is `[]` Top level libraries that will unconditionally be statically linked into the shared library after being whole-archived. Any transitive library dependency of these direct deps will be linked into this shared library as long as they have not already been linked by a `cc_shared_library` in `dynamic_deps`. During analysis, the rule implementation will consider any target listed in `deps` as being exported by the shared library in order to give errors when multiple `cc_shared_libraries` export the same targets. The rule implementation does not take care of informing the linker about which symbols should be exported by the shared object. The user should take care of this via linker scripts or visibility declarations in the source code. The implementation will also trigger errors whenever the same library is linked statically into more than one `cc_shared_library`. This can be avoided by adding `"LINKABLE_MORE_THAN_ONCE"` to the `cc_library.tags` or by listing the `cc\_library` as an export of one of the shared libraries so that one can be made a `dynamic_dep` of the other. | | `additional_linker_inputs` | List of [labels](/concepts/labels); default is `[]` Any additional files that you may want to pass to the linker, for example, linker scripts. You have to separately pass any linker flags that the linker needs in order to be aware of this file. You can do so via the `user_link_flags` attribute. | | `dynamic_deps` | List of [labels](/concepts/labels); default is `[]` These are other `cc_shared_library` dependencies the current target depends on. The `cc_shared_library` implementation will use the list of `dynamic_deps` (transitively, i.e. also the `dynamic_deps` of the current target's `dynamic_deps`) to decide which `cc_libraries` in the transitive `deps` should not be linked in because they are already provided by a different `cc_shared_library`. | | `exports_filter` | List of strings; default is `[]` This attribute contains a list of targets that are claimed to be exported by the current shared library. Any target `deps` is already understood to be exported by the shared library. This attribute should be used to list any targets that are exported by the shared library but are transitive dependencies of `deps`. Note that this attribute is not actually adding a dependency edge to those targets, the dependency edge should instead be created by `deps`.The entries in this attribute are just strings. Keep in mind that when placing a target in this attribute, this is considered a claim that the shared library exports the symbols from that target. The `cc_shared_library` logic doesn't actually handle telling the linker which symbols should be exported. The following syntax is allowed: `//foo:__pkg__` to account for any target in foo/BUILD `//foo:__subpackages__` to account for any target in foo/BUILD or any other package below foo/ like foo/bar/BUILD | | `roots` | List of [labels](/concepts/labels); default is `[]` | -| `shared_lib_name` | String; default is `""` By default cc_shared_library will use a name for the shared library output file based on the target's name and the platform. This includes an extension and sometimes a prefix. Sometimes you may not want the default name, for example, when loading C++ shared libraries for Python the default lib\* prefix is often not desired, in which case you can use this attribute to choose a custom name. | +| `shared_lib_name` | String; default is `""` By default cc\_shared\_library will use a name for the shared library output file based on the target's name and the platform. This includes an extension and sometimes a prefix. Sometimes you may not want the default name, for example, when loading C++ shared libraries for Python the default lib\* prefix is often not desired, in which case you can use this attribute to choose a custom name. | | `static_deps` | List of strings; default is `[]` | -| `user_link_flags` | List of strings; default is `[]` Any additional flags that you may want to pass to the linker. For example, to make the linker aware of a linker script passed via additional_linker_inputs you can use the following: ``` cc_shared_library( name = "foo_shared", additional_linker_inputs = select({ "//src/conditions:linux": [ ":foo.lds", ":additional_script.txt", ], "//conditions:default": []}), user_link_flags = select({ "//src/conditions:linux": [ "-Wl,-rpath,kittens", "-Wl,--version-script=$(location :foo.lds)", "-Wl,--script=$(location :additional_script.txt)", ], "//conditions:default": []}), ... ) ``` | +| `user_link_flags` | List of strings; default is `[]` Any additional flags that you may want to pass to the linker. For example, to make the linker aware of a linker script passed via additional\_linker\_inputs you can use the following: ``` cc_shared_library( name = "foo_shared", additional_linker_inputs = select({ "//src/conditions:linux": [ ":foo.lds", ":additional_script.txt", ], "//conditions:default": []}), user_link_flags = select({ "//src/conditions:linux": [ "-Wl,-rpath,kittens", "-Wl,--version-script=$(location :foo.lds)", "-Wl,--script=$(location :additional_script.txt)", ], "//conditions:default": []}), ... ) ``` | | `win_def_file` | [Label](/concepts/labels); default is `None` The Windows DEF file to be passed to linker. This attribute should only be used when Windows is the target platform. It can be used to [export symbols](https://msdn.microsoft.com/en-us/library/d91k01sh.aspx) during linking a shared library. | -## cc_static_library +## cc\_static\_library -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/cc_static_library.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/cc_static_library.bzl) ``` cc_static_library(name, deps, aspect_hints, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, package_metadata, restricted_to, tags, target_compatible_with, testonly, toolchains, visibility) @@ -687,9 +687,9 @@ it in one of two ways: | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | | `deps` | List of [labels](/concepts/labels); default is `[]` The list of targets to combine into a static library, including all their transitive dependencies. Dependencies that do not provide any object files are not included in the static library, but their labels are collected in the file provided by the `linkdeps` output group. | -## cc_test +## cc\_test -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/cc_test.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/cc_test.bzl) ``` cc_test(name, deps, srcs, data, additional_compiler_inputs, additional_linker_inputs, args, aspect_hints, compatible_with, conlyopts, copts, cxxopts, defines, deprecation, dynamic_deps, env, env_inherit, exec_compatible_with, exec_group_compatible_with, exec_properties, features, flaky, hdrs_check, includes, licenses, link_extra_lib, linkopts, linkshared, linkstatic, local, local_defines, malloc, module_interfaces, nocopts, package_metadata, reexport_deps, restricted_to, shard_count, size, stamp, tags, target_compatible_with, testonly, timeout, toolchains, visibility, win_def_file) @@ -715,7 +715,7 @@ It would probably be good to comment why your test needs information package file suitable for debugging remotely deployed binaries. Else: an empty file. -See the [cc_binary()](/reference/be/c-cpp#cc_binary_args) arguments, except that +See the [cc\_binary()](/reference/be/c-cpp#cc_binary_args) arguments, except that the `stamp` argument is set to 0 by default for tests and that `cc_test` has extra [attributes common to all test rules (\*\_test)](/reference/be/common-definitions#common-attributes-tests). @@ -735,11 +735,11 @@ that `cc_test` has extra [attributes common to all test rules (\*\_test)](/refer | `defines` | List of strings; default is `[]` List of defines to add to the compile line of this and all dependent targets. Subject to ["Make" variable](/reference/be/make-variables) substitution and [Bourne shell tokenization](/reference/be/common-definitions#sh-tokenization). Each string, which must consist of a single Bourne shell token, is prepended with `-D` and added to the compile command line to this target, as well as to every rule that depends on it. Be very careful, since this may have far-reaching effects -- the defines are added to every target that depends on this target. When in doubt, add define values to [`local_defines`](#cc_binary.local_defines) instead. | | `dynamic_deps` | List of [labels](/concepts/labels); default is `[]` These are other `cc_shared_library` dependencies the current target depends on. The `cc_shared_library` implementation will use the list of `dynamic_deps` (transitively, i.e. also the `dynamic_deps` of the current target's `dynamic_deps`) to decide which `cc_libraries` in the transitive `deps` should not be linked in because they are already provided by a different `cc_shared_library`. | | `hdrs_check` | String; default is `""` Deprecated, no-op. | -| `includes` | List of strings; default is `[]` List of include dirs to be added to the compile line. Subject to ["Make variable"](/reference/be/make-variables) substitution. Each string is prepended with the package path and passed to the C++ toolchain for expansion via the "include_paths" CROSSTOOL feature. A toolchain running on a POSIX system with typical feature definitions will produce `-isystem path_to_package/include_entry`. This should only be used for third-party libraries that do not conform to the Google style of writing #include statements. Unlike [COPTS](#cc_binary.copts), these flags are added for this rule and every rule that depends on it. (Note: not the rules it depends upon!) Be very careful, since this may have far-reaching effects. When in doubt, add "-I" flags to [COPTS](#cc_binary.copts) instead. The added `include` paths will include generated files as well as files in the source tree. | +| `includes` | List of strings; default is `[]` List of include dirs to be added to the compile line. Subject to ["Make variable"](/reference/be/make-variables) substitution. Each string is prepended with the package path and passed to the C++ toolchain for expansion via the "include\_paths" CROSSTOOL feature. A toolchain running on a POSIX system with typical feature definitions will produce `-isystem path_to_package/include_entry`. This should only be used for third-party libraries that do not conform to the Google style of writing #include statements. Unlike [COPTS](#cc_binary.copts), these flags are added for this rule and every rule that depends on it. (Note: not the rules it depends upon!) Be very careful, since this may have far-reaching effects. When in doubt, add "-I" flags to [COPTS](#cc_binary.copts) instead. The added `include` paths will include generated files as well as files in the source tree. | | `link_extra_lib` | [Label](/concepts/labels); default is `"@bazel_tools//tools/cpp:link_extra_lib"` Control linking of extra libraries. By default, C++ binaries are linked against `@bazel_tools//tools/cpp:link_extra_lib`, which by default depends on the label flag `@bazel_tools//tools/cpp:link_extra_libs`. Without setting the flag, this library is empty by default. Setting the label flag allows linking optional dependencies, such as overrides for weak symbols, interceptors for shared library functions, or special runtime libraries (for malloc replacements, prefer `malloc` or `--custom_malloc`). Setting this attribute to `None` disables this behaviour. | | `linkopts` | List of strings; default is `[]` Add these flags to the C++ linker command. Subject to ["Make" variable](make-variables) substitution, [Bourne shell tokenization](common-definitions#sh-tokenization) and [label expansion](common-definitions#label-expansion). Each string in this attribute is added to `LINKOPTS` before linking the binary target. Each element of this list that does not start with `$` or `-` is assumed to be the label of a target in `deps`. The list of files generated by that target is appended to the linker options. An error is reported if the label is invalid, or is not declared in `deps`. | -| `linkshared` | Boolean; default is `False` Create a shared library. To enable this attribute, include `linkshared=True` in your rule. By default this option is off. The presence of this flag means that linking occurs with the `-shared` flag to `gcc`, and the resulting shared library is suitable for loading into for example a Java program. However, for build purposes it will never be linked into the dependent binary, as it is assumed that shared libraries built with a [cc_binary](#cc_binary) rule are only loaded manually by other programs, so it should not be considered a substitute for the [cc_library](#cc_library) rule. For sake of scalability we recommend avoiding this approach altogether and simply letting `java_library` depend on `cc_library` rules instead. If you specify both `linkopts=['-static']` and `linkshared=True`, you get a single completely self-contained unit. If you specify both `linkstatic=True` and `linkshared=True`, you get a single, mostly self-contained unit. | -| `linkstatic` | Boolean; default is `False` For [`cc_binary`](/reference/be/c-cpp#cc_binary) and [`cc_test`](/reference/be/c-cpp#cc_test): link the binary in static mode. For `cc_library.link_static`: see below. By default this option is on for `cc_binary` and off for the rest. If enabled and this is a binary or test, this option tells the build tool to link in `.a`'s instead of `.so`'s for user libraries whenever possible. System libraries such as libc (but *not* the C/C++ runtime libraries, see below) are still linked dynamically, as are libraries for which there is no static library. So the resulting executable will still be dynamically linked, hence only *mostly* static. There are really three different ways to link an executable: * STATIC with fully_static_link feature, in which everything is linked statically; e.g. "`gcc -static foo.o libbar.a libbaz.a -lm`". This mode is enabled by specifying `fully_static_link` in the [`features`](/reference/be/common-definitions#features) attribute. * STATIC, in which all user libraries are linked statically (if a static version is available), but where system libraries (excluding C/C++ runtime libraries) are linked dynamically, e.g. "`gcc foo.o libfoo.a libbaz.a -lm`". This mode is enabled by specifying `linkstatic=True`. * DYNAMIC, in which all libraries are linked dynamically (if a dynamic version is available), e.g. "`gcc foo.o libfoo.so libbaz.so -lm`". This mode is enabled by specifying `linkstatic=False`. If the `linkstatic` attribute or `fully_static_link` in `features` is used outside of `//third_party` please include a comment near the rule to explain why. The `linkstatic` attribute has a different meaning if used on a [`cc_library()`](/reference/be/c-cpp#cc_library) rule. For a C++ library, `linkstatic=True` indicates that only static linking is allowed, so no `.so` will be produced. linkstatic=False does not prevent static libraries from being created. The attribute is meant to control the creation of dynamic libraries. There should be very little code built with `linkstatic=False` in production. If `linkstatic=False`, then the build tool will create symlinks to depended-upon shared libraries in the `*.runfiles` area. | +| `linkshared` | Boolean; default is `False` Create a shared library. To enable this attribute, include `linkshared=True` in your rule. By default this option is off. The presence of this flag means that linking occurs with the `-shared` flag to `gcc`, and the resulting shared library is suitable for loading into for example a Java program. However, for build purposes it will never be linked into the dependent binary, as it is assumed that shared libraries built with a [cc\_binary](#cc_binary) rule are only loaded manually by other programs, so it should not be considered a substitute for the [cc\_library](#cc_library) rule. For sake of scalability we recommend avoiding this approach altogether and simply letting `java_library` depend on `cc_library` rules instead. If you specify both `linkopts=['-static']` and `linkshared=True`, you get a single completely self-contained unit. If you specify both `linkstatic=True` and `linkshared=True`, you get a single, mostly self-contained unit. | +| `linkstatic` | Boolean; default is `False` For [`cc_binary`](/reference/be/c-cpp#cc_binary) and [`cc_test`](/reference/be/c-cpp#cc_test): link the binary in static mode. For `cc_library.link_static`: see below. By default this option is on for `cc_binary` and off for the rest. If enabled and this is a binary or test, this option tells the build tool to link in `.a`'s instead of `.so`'s for user libraries whenever possible. System libraries such as libc (but *not* the C/C++ runtime libraries, see below) are still linked dynamically, as are libraries for which there is no static library. So the resulting executable will still be dynamically linked, hence only *mostly* static. There are really three different ways to link an executable: * STATIC with fully\_static\_link feature, in which everything is linked statically; e.g. "`gcc -static foo.o libbar.a libbaz.a -lm`". This mode is enabled by specifying `fully_static_link` in the [`features`](/reference/be/common-definitions#features) attribute. * STATIC, in which all user libraries are linked statically (if a static version is available), but where system libraries (excluding C/C++ runtime libraries) are linked dynamically, e.g. "`gcc foo.o libfoo.a libbaz.a -lm`". This mode is enabled by specifying `linkstatic=True`. * DYNAMIC, in which all libraries are linked dynamically (if a dynamic version is available), e.g. "`gcc foo.o libfoo.so libbaz.so -lm`". This mode is enabled by specifying `linkstatic=False`. If the `linkstatic` attribute or `fully_static_link` in `features` is used outside of `//third_party` please include a comment near the rule to explain why. The `linkstatic` attribute has a different meaning if used on a [`cc_library()`](/reference/be/c-cpp#cc_library) rule. For a C++ library, `linkstatic=True` indicates that only static linking is allowed, so no `.so` will be produced. linkstatic=False does not prevent static libraries from being created. The attribute is meant to control the creation of dynamic libraries. There should be very little code built with `linkstatic=False` in production. If `linkstatic=False`, then the build tool will create symlinks to depended-upon shared libraries in the `*.runfiles` area. | | `local_defines` | List of strings; default is `[]` List of defines to add to the compile line. Subject to ["Make" variable](/reference/be/make-variables) substitution and [Bourne shell tokenization](/reference/be/common-definitions#sh-tokenization). Each string, which must consist of a single Bourne shell token, is prepended with `-D` and added to the compile command line for this target, but not to its dependents. Unlike `defines`, the defines are only added to the compile command line for this target. | | `malloc` | [Label](/concepts/labels); default is `"@bazel_tools//tools/cpp:malloc"` Override the default dependency on malloc. By default, C++ binaries are linked against `//tools/cpp:malloc`, which is an empty library so the binary ends up using libc malloc. This label must refer to a `cc_library`. If compilation is for a non-C++ rule, this option has no effect. The value of this attribute is ignored if `linkshared=True` is specified. | | `module_interfaces` | List of [labels](/concepts/labels); default is `[]` The list of files are regarded as C++20 Modules Interface. C++ Standard has no restriction about module interface file extension * Clang use cppm * GCC can use any source file extension * MSVC use ixx The use is guarded by the flag `--experimental_cpp_modules`. | @@ -748,9 +748,9 @@ that `cc_test` has extra [attributes common to all test rules (\*\_test)](/refer | `stamp` | Integer; default is `0` Whether to encode build information into the binary. Possible values: * `stamp = 1`: Always stamp the build information into the binary, even in [`--nostamp`](/docs/user-manual#flag--stamp) builds. **This setting should be avoided**, since it potentially kills remote caching for the binary and any downstream actions that depend on it. * `stamp = 0`: Always replace build information by constant values. This gives good build result caching. * `stamp = -1`: Embedding of build information is controlled by the [`--[no]stamp`](/docs/user-manual#flag--stamp) flag. Stamped binaries are *not* rebuilt unless their dependencies change. | | `win_def_file` | [Label](/concepts/labels); default is `None` The Windows DEF file to be passed to linker. This attribute should only be used when Windows is the target platform. It can be used to [export symbols](https://msdn.microsoft.com/en-us/library/d91k01sh.aspx) during linking a shared library. | -## cc_toolchain +## cc\_toolchain -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/cc_toolchain.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/cc_toolchain.bzl) ``` cc_toolchain(name, all_files, ar_files, as_files, aspect_hints, compatible_with, compiler_files, compiler_files_without_includes, coverage_files, deprecation, dwp_files, dynamic_runtime_lib, exec_compatible_with, exec_group_compatible_with, exec_properties, exec_transition_for_inputs, features, libc_top, licenses, linker_files, module_map, objcopy_files, output_licenses, package_metadata, restricted_to, static_runtime_lib, strip_files, supports_header_parsing, supports_param_files, tags, target_compatible_with, testonly, toolchain_config, toolchain_identifier, toolchains, visibility) @@ -779,30 +779,30 @@ unnecessarily when invoking `bazel build //...` | Attributes | | | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | -| `all_files` | [Label](/concepts/labels); required Collection of all cc_toolchain artifacts. These artifacts will be added as inputs to all rules_cc related actions (with the exception of actions that are using more precise sets of artifacts from attributes below). Bazel assumes that `all_files` is a superset of all other artifact-providing attributes (e.g. linkstamp compilation needs both compile and link files, so it takes `all_files`). This is what `cc_toolchain.files` contains, and this is used by all Starlark rules using C++ toolchain. | -| `ar_files` | [Label](/concepts/labels); default is `None` Collection of all cc_toolchain artifacts required for archiving actions. | -| `as_files` | [Label](/concepts/labels); default is `None` Collection of all cc_toolchain artifacts required for assembly actions. | -| `compiler_files` | [Label](/concepts/labels); required Collection of all cc_toolchain artifacts required for compile actions. | -| `compiler_files_without_includes` | [Label](/concepts/labels); default is `None` Collection of all cc_toolchain artifacts required for compile actions in case when input discovery is supported (currently Google-only). | -| `coverage_files` | [Label](/concepts/labels); default is `None` Collection of all cc_toolchain artifacts required for coverage actions. If not specified, all_files are used. | -| `dwp_files` | [Label](/concepts/labels); required Collection of all cc_toolchain artifacts required for dwp actions. | -| `dynamic_runtime_lib` | [Label](/concepts/labels); default is `None` Dynamic library artifact for the C++ runtime library (e.g. libstdc++.so). This will be used when 'static_link_cpp_runtimes' feature is enabled, and we're linking dependencies dynamically. | +| `all_files` | [Label](/concepts/labels); required Collection of all cc\_toolchain artifacts. These artifacts will be added as inputs to all rules\_cc related actions (with the exception of actions that are using more precise sets of artifacts from attributes below). Bazel assumes that `all_files` is a superset of all other artifact-providing attributes (e.g. linkstamp compilation needs both compile and link files, so it takes `all_files`). This is what `cc_toolchain.files` contains, and this is used by all Starlark rules using C++ toolchain. | +| `ar_files` | [Label](/concepts/labels); default is `None` Collection of all cc\_toolchain artifacts required for archiving actions. | +| `as_files` | [Label](/concepts/labels); default is `None` Collection of all cc\_toolchain artifacts required for assembly actions. | +| `compiler_files` | [Label](/concepts/labels); required Collection of all cc\_toolchain artifacts required for compile actions. | +| `compiler_files_without_includes` | [Label](/concepts/labels); default is `None` Collection of all cc\_toolchain artifacts required for compile actions in case when input discovery is supported (currently Google-only). | +| `coverage_files` | [Label](/concepts/labels); default is `None` Collection of all cc\_toolchain artifacts required for coverage actions. If not specified, all\_files are used. | +| `dwp_files` | [Label](/concepts/labels); required Collection of all cc\_toolchain artifacts required for dwp actions. | +| `dynamic_runtime_lib` | [Label](/concepts/labels); default is `None` Dynamic library artifact for the C++ runtime library (e.g. libstdc++.so). This will be used when 'static\_link\_cpp\_runtimes' feature is enabled, and we're linking dependencies dynamically. | | `exec_transition_for_inputs` | Boolean; default is `False` Deprecated. No-op. | | `libc_top` | [Label](/concepts/labels); default is `None` A collection of artifacts for libc passed as inputs to compile/linking actions. | -| `linker_files` | [Label](/concepts/labels); required Collection of all cc_toolchain artifacts required for linking actions. | +| `linker_files` | [Label](/concepts/labels); required Collection of all cc\_toolchain artifacts required for linking actions. | | `module_map` | [Label](/concepts/labels); default is `None` Module map artifact to be used for modular builds. | -| `objcopy_files` | [Label](/concepts/labels); required Collection of all cc_toolchain artifacts required for objcopy actions. | +| `objcopy_files` | [Label](/concepts/labels); required Collection of all cc\_toolchain artifacts required for objcopy actions. | | `output_licenses` | List of strings; default is `[]` | -| `static_runtime_lib` | [Label](/concepts/labels); default is `None` Static library artifact for the C++ runtime library (e.g. libstdc++.a). This will be used when 'static_link_cpp_runtimes' feature is enabled, and we're linking dependencies statically. | -| `strip_files` | [Label](/concepts/labels); required Collection of all cc_toolchain artifacts required for strip actions. | -| `supports_header_parsing` | Boolean; default is `False` Set to True when cc_toolchain supports header parsing actions. | -| `supports_param_files` | Boolean; default is `True` Set to True when cc_toolchain supports using param files for linking actions. | +| `static_runtime_lib` | [Label](/concepts/labels); default is `None` Static library artifact for the C++ runtime library (e.g. libstdc++.a). This will be used when 'static\_link\_cpp\_runtimes' feature is enabled, and we're linking dependencies statically. | +| `strip_files` | [Label](/concepts/labels); required Collection of all cc\_toolchain artifacts required for strip actions. | +| `supports_header_parsing` | Boolean; default is `False` Set to True when cc\_toolchain supports header parsing actions. | +| `supports_param_files` | Boolean; default is `True` Set to True when cc\_toolchain supports using param files for linking actions. | | `toolchain_config` | [Label](/concepts/labels); required The label of the rule providing `cc_toolchain_config_info`. | -| `toolchain_identifier` | String; default is `""` The identifier used to match this cc_toolchain with the corresponding crosstool_config.toolchain. Until issue [#5380](https://github.com/bazelbuild/bazel/issues/5380) is fixed this is the recommended way of associating `cc_toolchain` with `CROSSTOOL.toolchain`. It will be replaced by the `toolchain_config` attribute ([#5380](https://github.com/bazelbuild/bazel/issues/5380)). | +| `toolchain_identifier` | String; default is `""` The identifier used to match this cc\_toolchain with the corresponding crosstool\_config.toolchain. Until issue [#5380](https://github.com/bazelbuild/bazel/issues/5380) is fixed this is the recommended way of associating `cc_toolchain` with `CROSSTOOL.toolchain`. It will be replaced by the `toolchain_config` attribute ([#5380](https://github.com/bazelbuild/bazel/issues/5380)). | -## fdo_prefetch_hints +## fdo\_prefetch\_hints -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/fdo/fdo_prefetch_hints.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/fdo/fdo_prefetch_hints.bzl) ``` fdo_prefetch_hints(name, aspect_hints, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, package_metadata, profile, restricted_to, tags, target_compatible_with, testonly, toolchains, visibility) @@ -823,11 +823,11 @@ fdo_prefetch_hints( | Attributes | | | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | -| `profile` | [Label](/concepts/labels); required Label of the hints profile. The hints file has the .afdo extension The label can also point to an fdo_absolute_path_profile rule. | +| `profile` | [Label](/concepts/labels); required Label of the hints profile. The hints file has the .afdo extension The label can also point to an fdo\_absolute\_path\_profile rule. | -## fdo_profile +## fdo\_profile -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/fdo/fdo_profile.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/fdo/fdo_profile.bzl) ``` fdo_profile(name, aspect_hints, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, memprof_profile, package_metadata, profile, proto_profile, restricted_to, tags, target_compatible_with, testonly, toolchains, visibility) @@ -849,12 +849,12 @@ fdo_profile( | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | | `memprof_profile` | [Label](/concepts/labels); default is `None` Label of the MemProf profile. The profile is expected to have either a .profdata extension (for an indexed/symbolized memprof profile), or a .zip extension for a zipfile containing a memprof.profdata file. | -| `profile` | [Label](/concepts/labels); required Label of the FDO profile or a rule which generates it. The FDO file can have one of the following extensions: .profraw for unindexed LLVM profile, .profdata for indexed LLVM profile, .zip that holds an LLVM profraw profile, .afdo for AutoFDO profile, .xfdo for XBinary profile. The label can also point to an fdo_absolute_path_profile rule. | +| `profile` | [Label](/concepts/labels); required Label of the FDO profile or a rule which generates it. The FDO file can have one of the following extensions: .profraw for unindexed LLVM profile, .profdata for indexed LLVM profile, .zip that holds an LLVM profraw profile, .afdo for AutoFDO profile, .xfdo for XBinary profile. The label can also point to an fdo\_absolute\_path\_profile rule. | | `proto_profile` | [Label](/concepts/labels); default is `None` Label of the protobuf profile. | -## memprof_profile +## memprof\_profile -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/fdo/memprof_profile.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/fdo/memprof_profile.bzl) ``` memprof_profile(name, aspect_hints, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, package_metadata, profile, restricted_to, tags, target_compatible_with, testonly, toolchains, visibility) @@ -875,11 +875,11 @@ memprof_profile( | Attributes | | | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | -| `profile` | [Label](/concepts/labels); required Label of the MEMPROF profile. The profile is expected to have either a .profdata extension (for an indexed/symbolized memprof profile), or a .zip extension for a zipfile containing a memprof.profdata file. The label can also point to an fdo_absolute_path_profile rule. | +| `profile` | [Label](/concepts/labels); required Label of the MEMPROF profile. The profile is expected to have either a .profdata extension (for an indexed/symbolized memprof profile), or a .zip extension for a zipfile containing a memprof.profdata file. The label can also point to an fdo\_absolute\_path\_profile rule. | -## propeller_optimize +## propeller\_optimize -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/fdo/propeller_optimize.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/fdo/propeller_optimize.bzl) ``` propeller_optimize(name, aspect_hints, cc_profile, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, ld_profile, package_metadata, restricted_to, tags, target_compatible_with, testonly, toolchains, visibility) diff --git a/reference/be/common-definitions.mdx b/reference/be/common-definitions.mdx index 6ae7a79a..6cab2c1f 100644 --- a/reference/be/common-definitions.mdx +++ b/reference/be/common-definitions.mdx @@ -59,7 +59,7 @@ but not all. | Attribute | Description | | --- | --- | -| `data` | List of [labels](/concepts/labels); default is `[]` Files needed by this rule at runtime. May list file or rule targets. Generally allows any target. The `runfiles` of targets in the `data` attribute appear in the `*.runfiles` area of any executable which is output by or has a runtime dependency on this target. This may include data files or binaries used when this target's [`srcs`](#typical.srcs) are executed. Typically, this includes the targets' default outputs and their transitive runfiles, but this depends on the implementation of the rules for those targets; most rules include their default outputs in their `runfiles`. See the [data dependencies](/concepts/dependencies#data-dependencies) section for more information about how to depend on and use data files. New rules should define a `data` attribute if they process inputs which might use other inputs at runtime. Rules' implementation functions must also [populate the target's runfiles](https://bazel.build/rules/rules#runfiles) from the outputs and runfiles of any `data` attribute, as well as runfiles from any dependency attribute which provides either source code or runtime dependencies. | +| `data` | List of [labels](/concepts/labels); default is `[]` Files needed by this rule at runtime. May list file or rule targets. Generally allows any target. The default outputs and runfiles of targets in the `data` attribute should appear in the `*.runfiles` area of any executable which is output by or has a runtime dependency on this target. This may include data files or binaries used when this target's [`srcs`](#typical.srcs) are executed. See the [data dependencies](/concepts/dependencies#data-dependencies) section for more information about how to depend on and use data files. New rules should define a `data` attribute if they process inputs which might use other inputs at runtime. Rules' implementation functions must also [populate the target's runfiles](https://bazel.build/rules/rules#runfiles) from the outputs and runfiles of any `data` attribute, as well as runfiles from any dependency attribute which provides either source code or runtime dependencies. | | `deps` | List of [labels](/concepts/labels); default is `[]` Dependencies for this target. Generally should only list rule targets. (Though some rules permit files to be listed directly in `deps`, this should be avoided when possible.) Language-specific rules generally limit the listed targets to those with specific [providers](https://bazel.build/extending/rules#providers). The precise semantics of what it means for a target to depend on another using `deps` are specific to the kind of rule, and the rule-specific documentation goes into more detail. For rules which process source code, `deps` generally specifies code dependencies used by the code in [`srcs`](#typical.srcs). Most often, a `deps` dependency is used to allow one module to use symbols defined in another module written in the same programming language and separately compiled. Cross-language dependencies are also permitted in many cases: For example, a `java_library` target may depend on C++ code in a `cc_library` target, by listing the latter in the `deps` attribute. See the definition of [dependencies](/concepts/build-ref#deps) for more information. | | `licenses` | List of strings; [nonconfigurable](#configurable-attributes); default is `["none"]` A list of license-type strings to be used for this particular target. This is part of a deprecated licensing API that Bazel no longer uses. Don't use this. | | `srcs` | List of [labels](/concepts/labels); default is `[]` Files processed or included by this rule. Generally lists files directly, but may list rule targets (like `filegroup` or `genrule`) to include their default outputs. Language-specific rules often require that the listed files have particular file extensions. | @@ -78,11 +78,11 @@ rules. | `exec_group_compatible_with` | Dictionary of strings to lists of [labels](/concepts/labels); [nonconfigurable](#configurable-attributes); default is `{}` A dictionary of exec group names to lists of `constraint_values` that must be present in the execution platform for the given exec group. This is in addition to any constraints already set on the exec group's definition. Constraints are used to restrict the list of available execution platforms. For more details, see the description of [toolchain resolution](/docs/toolchains#toolchain-resolution). and [exec groups](/extending/exec-groups) | | `exec_properties` | Dictionary of strings; default is `{}` A dictionary of strings that will be added to the `exec_properties` of a platform selected for this target. See `exec_properties` of the [platform](platforms-and-toolchains#platform) rule. If a key is present in both the platform and target-level properties, the value will be taken from the target. Keys can be prefixed with the name of an execution group followed by a `.` to apply them only to that particular exec group. | | `features` | List of *feature* strings; default is `[]` A feature is string tag that can be enabled or disabled on a target. The meaning of a feature depends on the rule itself. This `features` attribute is combined with the [package](/reference/be/functions#package) level `features` attribute. For example, if the features ["a", "b"] are enabled on the package level, and a target's `features` attribute contains ["-a", "c"], the features enabled for the rule will be "b" and "c". [See example](https://github.com/bazelbuild/examples/blob/main/rules/features/BUILD). | -| `package_metadata` | List of [labels](/concepts/labels); [nonconfigurable](#configurable-attributes); default is the package's `default_package_metadata` A list of labels that are associated metadata about this target. Typically, the labels are simple rules that return a provider of constant values. Rules and aspects may use these labels to perform some additional analysis on the build graph. The canonical use case is that of [rules_license](https://github.com/bazelbuild/rules_license). For that use case, `package_metadata` and `default_package_metadata` is used to attach information about a package's licence or version to targets. An aspect applied to a top-level binary can be used to gather those and produce compliance reports. | +| `package_metadata` | List of [labels](/concepts/labels); [nonconfigurable](#configurable-attributes); default is the package's `default_package_metadata` A list of labels that are associated metadata about this target. Typically, the labels are simple rules that return a provider of constant values. Rules and aspects may use these labels to perform some additional analysis on the build graph. The canonical use case is that of [rules\_license](https://github.com/bazelbuild/rules_license). For that use case, `package_metadata` and `default_package_metadata` is used to attach information about a package's licence or version to targets. An aspect applied to a top-level binary can be used to gather those and produce compliance reports. | | `restricted_to` | List of [labels](/concepts/labels); [nonconfigurable](#configurable-attributes); default is `[]` The list of environments this target can be built for, *instead* of default-supported environments. This is part of Bazel's constraint system. See `compatible_with` for details. | | `tags` | List of strings; [nonconfigurable](#configurable-attributes); default is `[]` *Tags* can be used on any rule. *Tags* on test and `test_suite` rules are useful for categorizing the tests. *Tags* on non-test targets are used to control sandboxed execution of `genrule`s and [Starlark](/rules/concepts) actions, and for parsing by humans and/or external tools. Bazel modifies the behavior of its sandboxing code if it finds the following keywords in the `tags` attribute of any test or `genrule` target, or the keys of `execution_requirements` for any Starlark action. * `no-sandbox` keyword results in the action or test never being sandboxed; it can still be cached or run remotely - use `no-cache` or `no-remote` to prevent either or both of those. * `no-cache` keyword results in the action or test never being cached (locally or remotely). Note: for the purposes of this tag, the disk cache is considered a local cache, whereas the HTTP and gRPC caches are considered remote. Other caches, such as Skyframe or the persistent action cache, are not affected. * `no-remote-cache` keyword results in the action or test never being cached remotely (but it may be cached locally; it may also be executed remotely). Note: for the purposes of this tag, the disk cache is considered a local cache, whereas the HTTP and gRPC caches are considered remote. Other caches, such as Skyframe or the persistent action cache, are not affected. If a combination of local disk cache and remote cache are used (combined cache), it's treated as a remote cache and disabled entirely unless `--incompatible_remote_results_ignore_disk` is set in which case the local components will be used. * `no-remote-exec` keyword results in the action or test never being executed remotely (but it may be cached remotely). * `no-remote` keyword prevents the action or test from being executed remotely or cached remotely. This is equivalent to using both `no-remote-cache` and `no-remote-exec`. * `no-remote-cache-upload` keyword disables upload part of remote caching of a spawn. it does not disable remote execution. * `local` keyword precludes the action or test from being remotely cached, remotely executed, or run inside the sandbox. For genrules and tests, marking the rule with the `local = True` attribute has the same effect. * `requires-network` keyword allows access to the external network from inside the sandbox. This tag only has an effect if sandboxing is enabled. * `block-network` keyword blocks access to the external network from inside the sandbox. In this case, only communication with localhost is allowed. This tag only has an effect if sandboxing is enabled. * `requires-fakeroot` runs the test or action as uid and gid 0 (i.e., the root user). This is only supported on Linux. This tag takes precedence over the `--sandbox_fake_username` command-line option. *Tags* on tests are generally used to annotate a test's role in your debug and release process. Typically, tags are most useful for C++ and Python tests, which lack any runtime annotation ability. The use of tags and size elements gives flexibility in assembling suites of tests based around codebase check-in policy. Bazel modifies test running behavior if it finds the following keywords in the `tags` attribute of the test rule: * `exclusive` will force the test to be run in the "exclusive" mode, ensuring that no other tests are running at the same time. Such tests will be executed in serial fashion after all build activity and non-exclusive tests have been completed. Remote execution is disabled for such tests because Bazel doesn't have control over what's running on a remote machine. * `exclusive-if-local` will force the test to be run in the "exclusive" mode if it is executed locally, but will run the test in parallel if it's executed remotely. * `manual` keyword will exclude the target from expansion of target pattern wildcards (`...`, `:*`, `:all`, etc.) and `test_suite` rules which do not list the test explicitly when computing the set of top-level targets to build/run for the `build`, `test`, and `coverage` commands. It does not affect target wildcard or test suite expansion in other contexts, including the `query` command. Note that `manual` does not imply that a target should not be built/run automatically by continuous build/test systems. For example, it may be desirable to exclude a target from `bazel test ...` because it requires specific Bazel flags, but still have it included in properly-configured presubmit or continuous test runs. * `external` keyword will force test to be unconditionally executed (regardless of `--cache_test_results` value). See [Tag Conventions](/reference/test-encyclopedia#tag-conventions) in the Test Encyclopedia for more conventions on tags attached to test targets. | | `target_compatible_with` | List of [labels](/concepts/labels); default is `[]` A list of `constraint_value`s that must be present in the target platform for this target to be considered *compatible*. This is in addition to any constraints already set by the rule type. If the target platform does not satisfy all listed constraints then the target is considered *incompatible*. Incompatible targets are skipped for building and testing when the target pattern is expanded (e.g. `//...`, `:all`). When explicitly specified on the command line, incompatible targets cause Bazel to print an error and cause a build or test failure. Targets that transitively depend on incompatible targets are themselves considered incompatible. They are also skipped for building and testing. An empty list (which is the default) signifies that the target is compatible with all platforms. All rules other than [Workspace Rules](workspace) support this attribute. For some rules this attribute has no effect. For example, specifying `target_compatible_with` for a `cc_toolchain` is not useful. See the [Platforms](/docs/platforms#skipping-incompatible-targets) page for more information about incompatible target skipping. | -| `testonly` | Boolean; [nonconfigurable](#configurable-attributes); default is `False` except for test and test suite targets If `True`, only testonly targets (such as tests) can depend on this target. Equivalently, a rule that is not `testonly` is not allowed to depend on any rule that is `testonly`. Tests (`*_test` rules) and test suites ([test_suite](/reference/be/general#test_suite) rules) are `testonly` by default. This attribute is intended to mean that the target should not be contained in binaries that are released to production. Because testonly is enforced at build time, not run time, and propagates virally through the dependency tree, it should be applied judiciously. For example, stubs and fakes that are useful for unit tests may also be useful for integration tests involving the same binaries that will be released to production, and therefore should probably not be marked testonly. Conversely, rules that are dangerous to even link in, perhaps because they unconditionally override normal behavior, should definitely be marked testonly. | +| `testonly` | Boolean; [nonconfigurable](#configurable-attributes); default is `False` except for test and test suite targets If `True`, only testonly targets (such as tests) can depend on this target. Equivalently, a rule that is not `testonly` is not allowed to depend on any rule that is `testonly`. Tests (`*_test` rules) and test suites ([test\_suite](/reference/be/general#test_suite) rules) are `testonly` by default. This attribute is intended to mean that the target should not be contained in binaries that are released to production. Because testonly is enforced at build time, not run time, and propagates virally through the dependency tree, it should be applied judiciously. For example, stubs and fakes that are useful for unit tests may also be useful for integration tests involving the same binaries that will be released to production, and therefore should probably not be marked testonly. Conversely, rules that are dangerous to even link in, perhaps because they unconditionally override normal behavior, should definitely be marked testonly. | | `toolchains` | List of [labels](/concepts/labels); [nonconfigurable](#configurable-attributes); default is `[]` The set of targets whose [Make variables](/reference/be/make-variables) this target is allowed to access. These targets are either instances of rules that provide `TemplateVariableInfo` or special targets for toolchain types built into Bazel. These include: * `@bazel_tools//tools/cpp:toolchain_type`* `@rules_java//toolchains:current_java_runtime` Note that this is distinct from the concept of [toolchain resolution](/docs/toolchains#toolchain-resolution) that is used by rule implementations for platform-dependent configuration. You cannot use this attribute to determine which specific `cc_toolchain` or `java_toolchain` a target will use. | | `visibility` | List of [labels](/concepts/labels); [nonconfigurable](#configurable-attributes); default varies The `visibility` attribute controls whether the target can be depended on by targets in other locations. See the documentation for [visibility](/concepts/visibility). For targets declared directly in a BUILD file or in legacy macros called from a BUILD file, the default value is the package's `default_visibility` if specified, or else `["//visibility:private"]`. For targets declared in one or more symbolic macros, the default value is always just `["//visibility:private"]` (which makes it useable only within the package containing the macro's code). | diff --git a/reference/be/extra-actions.mdx b/reference/be/extra-actions.mdx index 7e6e92cf..bf31904f 100644 --- a/reference/be/extra-actions.mdx +++ b/reference/be/extra-actions.mdx @@ -4,12 +4,12 @@ title: 'Extra Actions Rules' ## Rules -* [action_listener](#action_listener) -* [extra_action](#extra_action) +* [action\_listener](#action_listener) +* [extra\_action](#extra_action) -## action_listener +## action\_listener -[View rule sourceopen_in_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/extra/ActionListenerRule.java) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/extra/ActionListenerRule.java) ``` action_listener(name, aspect_hints, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, extra_actions, features, licenses, mnemonics, package_metadata, restricted_to, tags, target_compatible_with, testonly, visibility) @@ -66,9 +66,9 @@ extra_action( | `extra_actions` | List of [labels](/concepts/labels); required A list of `extra_action` targets this `action_listener` should add to the build graph. E.g. `[ "//my/tools:analyzer" ]`. | | `mnemonics` | List of strings; required A list of action mnemonics this `action_listener` should listen for, e.g. `[ "Javac" ]`. Mnemonics are not a public interface. There's no guarantee that the mnemonics and their actions don't change. | -## extra_action +## extra\_action -[View rule sourceopen_in_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/extra/ExtraActionRule.java) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/extra/ExtraActionRule.java) ``` extra_action(name, data, aspect_hints, cmd, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, licenses, out_templates, package_metadata, requires_action_output, restricted_to, tags, target_compatible_with, testonly, toolchains, tools, visibility) @@ -86,10 +86,10 @@ See [`action_listener`](/reference/be/extra-actions#action_listener) for details on how to enable `extra_action`s. The `extra_action`s run as a command-line. The command-line tool gets -access to a file containing a protocol buffer as $(EXTRA_ACTION_FILE) +access to a file containing a protocol buffer as $(EXTRA\_ACTION\_FILE) with detailed information on the original action it is shadowing. It also has access to all the input files the original action has access to. -See extra_actions_base.proto +See extra\_actions\_base.proto for details on the data stored inside the protocol buffer. Each proto file contains an ExtraActionInfo message. @@ -99,8 +99,8 @@ Just like all other actions, extra actions are sandboxed, and should be designed | Attributes | | | --- | --- | -| `name` | [Name](/concepts/labels#target-names); required A unique name for this target. You may refer to this rule by `label` in the `extra_actions` argument of [`action_listener`](/reference/be/extra-actions#action_listener) rules. | -| `cmd` | String; required The command to run. Like [genrule cmd attribute](/reference/be/general#genrule.cmd) with the following differences: 1. No heuristic label expansion. Only labels using $(location ...) are expanded. 2. An additional pass is applied to the string to replace all occurrences of the outputs created from the `out_templates` attribute. All occurrences of `$(output out_template)` are replaced with the path to the file denoted by `label`. E.g. out_template `$(ACTION_ID).analysis` can be matched with `$(output $(ACTION_ID).analysis)`. In effect, this is the same substitution as `$(location)` but with a different scope. | -| `out_templates` | List of strings; default is `[]` A list of templates for files generated by the `extra_action` command. The template can use the following variables: * $(ACTION_ID), an id uniquely identifying this `extra_action`. Used to generate a unique output file. | -| `requires_action_output` | Boolean; default is `False` Indicates this `extra_action` requires the output of the original action to be present as input to this `extra_action`. When true (default false), the extra_action can assume that the original action outputs are available as part of its inputs. | +| `name` | [Name](/concepts/labels#target-names); required A unique name for this target. You may refer to this rule by `label` in the `extra_actions` argument of [`action_listener`](/reference/be/extra-actions#action_listener) rules. | +| `cmd` | String; required The command to run. Like [genrule cmd attribute](/reference/be/general#genrule.cmd) with the following differences: 1. No heuristic label expansion. Only labels using $(location ...) are expanded. 2. An additional pass is applied to the string to replace all occurrences of the outputs created from the `out_templates` attribute. All occurrences of `$(output out_template)` are replaced with the path to the file denoted by `label`. E.g. out\_template `$(ACTION_ID).analysis` can be matched with `$(output $(ACTION_ID).analysis)`. In effect, this is the same substitution as `$(location)` but with a different scope. | +| `out_templates` | List of strings; default is `[]` A list of templates for files generated by the `extra_action` command. The template can use the following variables: * $(ACTION\_ID), an id uniquely identifying this `extra_action`. Used to generate a unique output file. | +| `requires_action_output` | Boolean; default is `False` Indicates this `extra_action` requires the output of the original action to be present as input to this `extra_action`. When true (default false), the extra\_action can assume that the original action outputs are available as part of its inputs. | | `tools` | List of [labels](/concepts/labels); default is `[]` A list of `tool` dependencies for this rule. See the definition of [dependencies](/concepts/build-ref#deps) for more information. The build system ensures these prerequisites are built before running the `extra_action` command; they are built using the [`exec`configuration](/docs/user-manual#configurations), since they must run as a tool during the build itself. The path of an individual `tools` target `//x:y` can be obtained using `$(location //x:y)`. All tools and their data dependencies are consolidated into a single tree within which the command can use relative paths. The working directory will be the root of that unified tree. | \ No newline at end of file diff --git a/reference/be/functions.mdx b/reference/be/functions.mdx index 7be48d5f..28f070ca 100644 --- a/reference/be/functions.mdx +++ b/reference/be/functions.mdx @@ -5,8 +5,8 @@ title: 'Functions' ## Contents * [package](#package) -* [package_group](#package_group) -* [exports_files](#exports_files) +* [package\_group](#package_group) +* [exports\_files](#exports_files) * [glob](#glob) * [select](#select) * [subpackages](#subpackages) @@ -33,9 +33,9 @@ file, before any rule. | Attribute | Description | | --- | --- | | `default_applicable_licenses` | Alias for [`default_package_metadata`](#package.default_package_metadata). | -| `default_visibility` | List of [labels](/concepts/labels); default is `[]` The default visibility of the top-level rule targets and symbolic macros in this package — that is, the targets and symbolic macros that are not themselves declared inside a symbolic macro. This attribute is ignored if the target or macro specifies a `visibility` value. For detailed information about the syntax of this attribute, see the documentation of [visibility](/concepts/visibility). The package default visibility does not apply to [exports_files](#exports_files), which is public by default. | +| `default_visibility` | List of [labels](/concepts/labels); default is `[]` The default visibility of the top-level rule targets and symbolic macros in this package — that is, the targets and symbolic macros that are not themselves declared inside a symbolic macro. This attribute is ignored if the target or macro specifies a `visibility` value. For detailed information about the syntax of this attribute, see the documentation of [visibility](/concepts/visibility). The package default visibility does not apply to [exports\_files](#exports_files), which is public by default. | | `default_deprecation` | String; default is `""` Sets the default [`deprecation`](common-definitions#common.deprecation) message for all rules in this package. | -| `default_package_metadata` | List of [labels](/concepts/labels); default is `[]` Sets a default list of metadata targets which apply to all other targets in the package. These are typically targets related to OSS package and license declarations. See [rules_license](https://github.com/bazelbuild/rules_license) for examples. | +| `default_package_metadata` | List of [labels](/concepts/labels); default is `[]` Sets a default list of metadata targets which apply to all other targets in the package. These are typically targets related to OSS package and license declarations. See [rules\_license](https://github.com/bazelbuild/rules_license) for examples. | | `default_testonly` | Boolean; default is `False` except as noted Sets the default [`testonly`](common-definitions#common.testonly) property for all rules in this package. In packages under `javatests` the default value is `True`. | | `features` | List strings; default is `[]` Sets various flags that affect the semantics of this BUILD file. This feature is mainly used by the people working on the build system to tag packages that need some kind of special handling. Do not use this unless explicitly requested by someone working on the build system. | @@ -50,7 +50,7 @@ on a rule, if present, override this specification. package(default_visibility = ["//foo:target"]) ``` -## package_group +## package\_group ``` package_group(name, packages, includes) @@ -132,7 +132,7 @@ package_group( ) ``` -## exports_files +## exports\_files ``` exports_files([label, ...], visibility, licenses) @@ -277,7 +277,7 @@ There are several important limitations and caveats: existence of BUILD files — that is, the same glob expression would include `x/y/z.cc` if there was no package called `x/y` or it was marked as deleted using the - [--deleted_packages](/docs/user-manual#flag--deleted_packages) + [--deleted\_packages](/docs/user-manual#flag--deleted_packages) flag. 5. The restriction above applies to all glob expressions, no matter which wildcards they use. @@ -389,7 +389,7 @@ that counts the number of lines in the file. ``` If the BUILD file above is in package //foo and the package contains three -matching files, a_test.cc, b_test.cc and c_test.cc then running +matching files, a\_test.cc, b\_test.cc and c\_test.cc then running `bazel query '//foo:all'` will list all rules that were generated: ``` @@ -456,7 +456,9 @@ Notes: considered to match if no other condition matches. If this condition is left out, some other rule must match to avoid an error. * `select` can be embedded *inside* a larger - attribute assignment. So `srcs = ["common.sh"] + select({ ":conditionA": ["myrule_a.sh"], ...})` and `srcs = select({ ":conditionA": ["a.sh"]}) + select({ ":conditionB": ["b.sh"]})` are valid expressions. + attribute assignment. So `srcs = ["common.sh"] + + select({ ":conditionA": ["myrule_a.sh"], ...})` and `srcs = select({ ":conditionA": ["a.sh"]}) + select({ ":conditionB": + ["b.sh"]})` are valid expressions. * `select` works with most, but not all, attributes. Incompatible attributes are marked `nonconfigurable` in their documentation. diff --git a/reference/be/general.mdx b/reference/be/general.mdx index c006aa8f..f8077b53 100644 --- a/reference/be/general.mdx +++ b/reference/be/general.mdx @@ -5,16 +5,16 @@ title: 'General Rules' ## Rules * [alias](#alias) -* [config_setting](#config_setting) +* [config\_setting](#config_setting) * [filegroup](#filegroup) * [genquery](#genquery) * [genrule](#genrule) -* [starlark_doc_extract](#starlark_doc_extract) -* [test_suite](#test_suite) +* [starlark\_doc\_extract](#starlark_doc_extract) +* [test\_suite](#test_suite) ## alias -[View rule sourceopen_in_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/Alias.java) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/Alias.java) ``` alias(name, actual, aspect_hints, compatible_with, deprecation, features, package_metadata, restricted_to, tags, target_compatible_with, testonly, visibility) @@ -63,9 +63,9 @@ alias( | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | | `actual` | [Label](/concepts/labels); required The target this alias refers to. It does not need to be a rule, it can also be an input file. | -## config_setting +## config\_setting -[View rule sourceopen_in_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/config/ConfigRuleClasses.java) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/config/ConfigRuleClasses.java) ``` config_setting(name, aspect_hints, constraint_values, define_values, deprecation, features, flag_values, licenses, package_metadata, tags, testonly, values, visibility) @@ -112,7 +112,7 @@ The following matches any build that sets ) ``` -The following matches any build that targets a platform with an x86_64 architecture and glibc +The following matches any build that targets a platform with an x86\_64 architecture and glibc version 2.25, assuming the existence of a `constraint_value` with label `//example:glibc_2_25`. Note that a platform still matches if it defines additional constraint values beyond these two. @@ -147,7 +147,8 @@ some build targets. `--myflag=a --myflag=b`, `--myflag=a --myflag=b --myflag=c`, `--myflag=a,b`, and `--myflag=c,b,a`. Exact semantics vary between flags. For example, `--copt` doesn't support multiple values *in the same - instance*: `--copt=a,b` produces `["a,b"]` while `--copt=a --copt=b` produces `["a", "b"]` (so `values = { "copt": "a,b" }` + instance*: `--copt=a,b` produces `["a,b"]` while `--copt=a + --copt=b` produces `["a", "b"]` (so `values = { "copt": "a,b" }` matches the former but not the latter). But `--ios_multi_cpus` (for Apple rules) *does*: `-ios_multi_cpus=a,b` and `ios_multi_cpus=a --ios_multi_cpus=b` both produce `["a", "b"]`. Check flag definitions and test your conditions carefully to verify exact expectations. @@ -169,13 +170,13 @@ some build targets. | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | | `constraint_values` | List of [labels](/concepts/labels); [nonconfigurable](common-definitions#configurable-attributes); default is `[]` The minimum set of `constraint_values` that the target platform must specify in order to match this `config_setting`. (The execution platform is not considered here.) Any additional constraint values that the platform has are ignored. See [Configurable Build Attributes](https://bazel.build/docs/configurable-attributes#platforms) for details. If two `config_setting`s match in the same `select` and one has all the same flags and `constraint_setting`s as the other plus additional ones, the one with more settings is chosen. This is known as "specialization". For example, a `config_setting` matching `x86` and `Linux` specializes a `config_setting` matching `x86`. If two `config_setting`s match and both have `constraint_value`s not present in the other, this is an error. | -| `define_values` | Dictionary: String -> String; [nonconfigurable](common-definitions#configurable-attributes); default is `{}` The same as [`values`](/reference/be/general#config_setting.values) but specifically for the `--define` flag. `--define` is special because its syntax (`--define KEY=VAL`) means `KEY=VAL` is a *value* from a Bazel flag perspective. That means: ``` config_setting( name = "a_and_b", values = { "define": "a=1", "define": "b=2", }) ``` doesn't work because the same key (`define`) appears twice in the dictionary. This attribute solves that problem: ``` config_setting( name = "a_and_b", define_values = { "a": "1", "b": "2", }) ``` correctly matches `bazel build //foo --define a=1 --define b=2`. `--define` can still appear in [`values`](/reference/be/general#config_setting.values) with normal flag syntax, and can be mixed freely with this attribute as long as dictionary keys remain distinct. | -| `flag_values` | Dictionary: [label](/concepts/labels) -> String; [nonconfigurable](common-definitions#configurable-attributes); default is `{}` The same as [`values`](/reference/be/general#config_setting.values) but for [user-defined build flags](https://bazel.build/rules/config#user-defined-build-settings). This is a distinct attribute because user-defined flags are referenced as labels while built-in flags are referenced as arbitrary strings. | -| `values` | Dictionary: String -> String; [nonconfigurable](common-definitions#configurable-attributes); default is `{}` The set of configuration values that match this rule (expressed as build flags) This rule inherits the configuration of the configured target that references it in a `select` statement. It is considered to "match" a Bazel invocation if, for every entry in the dictionary, its configuration matches the entry's expected value. For example `values = {"compilation_mode": "opt"}` matches the invocations `bazel build --compilation_mode=opt ...` and `bazel build -c opt ...` on target-configured rules. For convenience's sake, configuration values are specified as build flags (without the preceding `"--"`). But keep in mind that the two are not the same. This is because targets can be built in multiple configurations within the same build. For example, an exec configuration's "cpu" matches the value of `--host_cpu`, not `--cpu`. So different instances of the same `config_setting` may match the same invocation differently depending on the configuration of the rule using them. If a flag is not explicitly set at the command line, its default value is used. If a key appears multiple times in the dictionary, only the last instance is used. If a key references a flag that can be set multiple times on the command line (e.g. `bazel build --copt=foo --copt=bar --copt=baz ...`), a match occurs if *any* of those settings match. | +| `define_values` | Dictionary: String -> String; [nonconfigurable](common-definitions#configurable-attributes); default is `{}` The same as [`values`](/reference/be/general#config_setting.values) but specifically for the `--define` flag. `--define` is special because its syntax (`--define KEY=VAL`) means `KEY=VAL` is a *value* from a Bazel flag perspective. That means: ``` config_setting( name = "a_and_b", values = { "define": "a=1", "define": "b=2", }) ``` doesn't work because the same key (`define`) appears twice in the dictionary. This attribute solves that problem: ``` config_setting( name = "a_and_b", define_values = { "a": "1", "b": "2", }) ``` correctly matches `bazel build //foo --define a=1 --define b=2`. `--define` can still appear in [`values`](/reference/be/general#config_setting.values) with normal flag syntax, and can be mixed freely with this attribute as long as dictionary keys remain distinct. | +| `flag_values` | Dictionary: [label](/concepts/labels) -> String; [nonconfigurable](common-definitions#configurable-attributes); default is `{}` The same as [`values`](/reference/be/general#config_setting.values) but for [user-defined build flags](https://bazel.build/rules/config#user-defined-build-settings). This is a distinct attribute because user-defined flags are referenced as labels while built-in flags are referenced as arbitrary strings. | +| `values` | Dictionary: String -> String; [nonconfigurable](common-definitions#configurable-attributes); default is `{}` The set of configuration values that match this rule (expressed as build flags) This rule inherits the configuration of the configured target that references it in a `select` statement. It is considered to "match" a Bazel invocation if, for every entry in the dictionary, its configuration matches the entry's expected value. For example `values = {"compilation_mode": "opt"}` matches the invocations `bazel build --compilation_mode=opt ...` and `bazel build -c opt ...` on target-configured rules. For convenience's sake, configuration values are specified as build flags (without the preceding `"--"`). But keep in mind that the two are not the same. This is because targets can be built in multiple configurations within the same build. For example, an exec configuration's "cpu" matches the value of `--host_cpu`, not `--cpu`. So different instances of the same `config_setting` may match the same invocation differently depending on the configuration of the rule using them. If a flag is not explicitly set at the command line, its default value is used. If a key appears multiple times in the dictionary, only the last instance is used. If a key references a flag that can be set multiple times on the command line (e.g. `bazel build --copt=foo --copt=bar --copt=baz ...`), a match occurs if *any* of those settings match. | ## filegroup -[View rule sourceopen_in_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/filegroup/FilegroupRule.java) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/filegroup/FilegroupRule.java) ``` filegroup(name, srcs, data, aspect_hints, compatible_with, deprecation, features, licenses, output_group, package_metadata, restricted_to, tags, target_compatible_with, testonly, visibility) @@ -241,13 +242,13 @@ cc_library( | Attributes | | | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | -| `srcs` | List of [labels](/concepts/labels); default is `[]` The list of targets that are members of the file group. Targets named in the `srcs` attribute will be added to the `runfiles` of this `filegroup` rule. It is common to use the result of a [glob](/reference/be/functions#glob) expression for the value of the `srcs` attribute. | +| `srcs` | List of [labels](/concepts/labels); default is `[]` The list of targets that are members of the file group. It is common to use the result of a [glob](/reference/be/functions#glob) expression for the value of the `srcs` attribute. | | `data` | List of [labels](/concepts/labels); default is `[]` The list of files needed by this rule at runtime. Targets named in the `data` attribute will be added to the `runfiles` of this `filegroup` rule. When the `filegroup` is referenced in the `data` attribute of another rule its `runfiles` will be added to the `runfiles` of the depending rule. See the [data dependencies](/concepts/dependencies#data-dependencies) section and [general documentation of `data`](/reference/be/common-definitions#common.data) for more information about how to depend on and use data files. | | `output_group` | String; default is `""` The output group from which to gather artifacts from sources. If this attribute is specified, artifacts from the specified output group of the dependencies will be exported instead of the default output group. An "output group" is a category of output artifacts of a target, specified in that rule's implementation. | ## genquery -[View rule sourceopen_in_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/genquery/GenQueryRule.java) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/genquery/GenQueryRule.java) ``` genquery(name, deps, data, aspect_hints, compatible_with, compressed_output, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, expression, features, licenses, opts, package_metadata, restricted_to, scope, strict, tags, target_compatible_with, testonly, visibility) @@ -306,7 +307,7 @@ genquery( ## genrule -[View rule sourceopen_in_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/BazelGenRuleRule.java) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/bazel/rules/genrule/BazelGenRuleRule.java) ``` genrule(name, srcs, outs, aspect_hints, cmd, cmd_bash, cmd_bat, cmd_ps, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, executable, features, licenses, local, message, output_licenses, output_to_bindir, package_metadata, restricted_to, tags, target_compatible_with, testonly, toolchains, tools, visibility) @@ -323,7 +324,7 @@ Note that genrule requires a shell to interpret the command argument. It is also easy to reference arbitrary programs available on the PATH, however this makes the command non-hermetic and may not be reproducible. If you only need to run a single tool, consider using -[run_binary](https://github.com/bazelbuild/bazel-skylib/blob/main/docs/run_binary_doc.md) +[run\_binary](https://github.com/bazelbuild/bazel-skylib/blob/main/docs/run_binary_doc.md) instead. Like every other action, the action created by genrules should not assume anything about their @@ -466,7 +467,7 @@ genrule( | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. You may refer to this rule by name in the `srcs` or `deps` section of other `BUILD` rules. If the rule generates source files, you should use the `srcs` attribute. | | `srcs` | List of [labels](/concepts/labels); default is `[]` A list of inputs for this rule, such as source files to process. *This attributes is not suitable to list tools executed by the `cmd`; use the [`tools`](/reference/be/general#genrule.tools) attribute for them instead.* The build system ensures these prerequisites are built before running the genrule command; they are built using the same configuration as the original build request. The names of the files of these prerequisites are available to the command as a space-separated list in `$(SRCS)`; alternatively the path of an individual `srcs` target `//x:y` can be obtained using `$(location //x:y)`, or using `$<` provided it's the only entry in `srcs`. | | `outs` | List of [filenames](/concepts/build-ref#filename); [nonconfigurable](common-definitions#configurable-attributes); required A list of files generated by this rule. Output files must not cross package boundaries. Output filenames are interpreted as relative to the package. If the `executable` flag is set, `outs` must contain exactly one label. The genrule command is expected to create each output file at a predetermined location. The location is available in `cmd` using [genrule-specific "Make" variables](/reference/be/make-variables#predefined_genrule_variables) (`$@`, `$(OUTS)`, `$(@D)` or `$(RULEDIR)`) or using [`$(location)`](/reference/be/make-variables#predefined_label_variables) substitution. | -| `cmd` | String; default is `""` The command to run. Subject to [`$(location)`](/reference/be/make-variables#predefined_label_variables) and ["Make" variable](/reference/be/make-variables) substitution. 1. First [`$(location)`](/reference/be/make-variables#predefined_label_variables) substitution is applied, replacing all occurrences of `$(location label)` and of `$(locations label)` (and similar constructions using related variables `execpath`, `execpaths`, `rootpath` and `rootpaths`). 2. Next, ["Make" variables](/reference/be/make-variables) are expanded. Note that predefined variables `$(JAVA)`, `$(JAVAC)` and `$(JAVABASE)` expand under the *exec* configuration, so Java invocations that run as part of a build step can correctly load shared libraries and other dependencies. 3. Finally, the resulting command is executed using the Bash shell. If its exit code is non-zero the command is considered to have failed. This is the fallback of `cmd_bash`, `cmd_ps` and `cmd_bat`, if none of them are applicable. | +| `cmd` | String; default is `""` The command to run. Subject to [`$(location)`](/reference/be/make-variables#predefined_label_variables) and ["Make" variable](/reference/be/make-variables) substitution. 1. First [`$(location)`](/reference/be/make-variables#predefined_label_variables) substitution is applied, replacing all occurrences of `$(location label)` and of `$(locations label)` (and similar constructions using related variables `execpath`, `execpaths`, `rootpath` and `rootpaths`). 2. Next, ["Make" variables](/reference/be/make-variables) are expanded. Note that predefined variables `$(JAVA)`, `$(JAVAC)` and `$(JAVABASE)` expand under the *exec* configuration, so Java invocations that run as part of a build step can correctly load shared libraries and other dependencies. 3. Finally, the resulting command is executed using the Bash shell. If its exit code is non-zero the command is considered to have failed. This is the fallback of `cmd_bash`, `cmd_ps` and `cmd_bat`, if none of them are applicable. | If the command line length exceeds the platform limit (64K on Linux/macOS, 8K on Windows), then genrule will write the command to a script and execute that script to work around. This @@ -484,9 +485,9 @@ applies to all cmd attributes (`cmd`, `cmd_bash`, `cmd_ps`, | `toolchains` | List of [labels](/concepts/labels); [nonconfigurable](common-definitions#configurable-attributes); default is `[]` The set of targets whose [Make variables](/reference/be/make-variables) this genrule is allowed to access, or the [`toolchain_type`](/docs/toolchains) targets that this genrule will access. Toolchains accessed via `toolchain_type` must also provide a `TemplateVariableInfo` provider, which the target can use to access toolchain details. | | `tools` | List of [labels](/concepts/labels); default is `[]` A list of *tool* dependencies for this rule. See the definition of [dependencies](/concepts/build-ref#deps) for more information. The build system ensures these prerequisites are built before running the genrule command; they are built using the [*exec* configuration](/contribute/guide#configurations), since these tools are executed as part of the build. The path of an individual `tools` target `//x:y` can be obtained using `$(location //x:y)`. Any `*_binary` or tool to be executed by `cmd` must appear in this list, not in `srcs`, to ensure they are built in the correct configuration. | -## starlark_doc_extract +## starlark\_doc\_extract -[View rule sourceopen_in_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/starlarkdocextract/StarlarkDocExtractRule.java) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/starlarkdocextract/StarlarkDocExtractRule.java) ``` starlark_doc_extract(name, deps, src, data, allow_unused_doc_comments, aspect_hints, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, licenses, package_metadata, render_main_repo_name, restricted_to, symbol_names, tags, target_compatible_with, testonly, visibility) @@ -496,7 +497,7 @@ starlark_doc_extract(name, deps, src, data, allow_unused_doc_comments, aspect_hi macros), aspects, and providers defined or re-exported in a given `.bzl` or `.scl` file. The output of this rule is a `ModuleInfo` binary proto as defined in -[stardoc_output.proto](https://github.com/bazelbuild/bazel/blob/master/src/main/protobuf/stardoc_output.proto) +[stardoc\_output.proto](https://github.com/bazelbuild/bazel/blob/master/src/main/protobuf/stardoc_output.proto) in the Bazel source tree. #### Implicit output targets @@ -523,9 +524,9 @@ run with a single Bazel version. | `render_main_repo_name` | Boolean; default is `False` If true, render labels in the main repository in emitted documentation with a repo component (in other words, `//foo:bar.bzl` will be emitted as `@main_repo_name//foo:bar.bzl`). The name to use for the main repository is obtained from `module(name = ...)` in the main repository's `MODULE.bazel` file (if Bzlmod is enabled), or from `workspace(name = ...)` in the main repository's `WORKSPACE` file. This attribute should be set to `False` when generating documentation for Starlark files which are intended to be used only within the same repository, and to `True` when generating documentation for Starlark files which are intended to be used from other repositories. | | `symbol_names` | List of strings; default is `[]` An optional list of qualified names of exported functions, rules, providers, or aspects (or structs in which they are nested) for which to extract documentation. Here, a *qualified name* means the name under which an entity is made available to a user of the module, including any structs in which the entity is nested for namespacing. `starlark_doc_extract` emits documentation for an entity if and only if 1. each component of the entity's qualified name is public (in other words, the first character of each component of the qualified name is alphabetic, not `"_"`); *and* 2. 1. *either* the `symbol_names` list is empty (which is the default case), *or* 2. the entity's qualified name, or the qualified name of a struct in which the entity is nested, is in the `symbol_names` list. | -## test_suite +## test\_suite -[View rule sourceopen_in_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/test/TestSuiteRule.java) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/test/TestSuiteRule.java) ``` test_suite(name, aspect_hints, compatible_with, deprecation, features, licenses, package_metadata, restricted_to, tags, target_compatible_with, testonly, tests, visibility) @@ -536,7 +537,7 @@ allows projects to define sets of tests, such as "tests you must run before chec project's stress tests" or "all small tests." The `bazel test` command respects this sort of organization: For an invocation like `bazel test //some/test:suite`, Bazel first enumerates all test targets transitively included by the `//some/test:suite` target (we -call this "test_suite expansion"), then Bazel builds and tests those targets. +call this "test\_suite expansion"), then Bazel builds and tests those targets. #### Examples @@ -575,5 +576,5 @@ test_suite( | Attributes | | | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | -| `tags` | List of strings; [nonconfigurable](common-definitions#configurable-attributes); default is `[]` List of text tags such as "small" or "database" or "-flaky". Tags may be any valid string. Tags which begin with a "-" character are considered negative tags. The preceding "-" character is not considered part of the tag, so a suite tag of "-small" matches a test's "small" size. All other tags are considered positive tags. Optionally, to make positive tags more explicit, tags may also begin with the "+" character, which will not be evaluated as part of the text of the tag. It merely makes the positive and negative distinction easier to read. Only test rules that match **all** of the positive tags and **none** of the negative tags will be included in the test suite. Note that this does not mean that error checking for dependencies on tests that are filtered out is skipped; the dependencies on skipped tests still need to be legal (e.g. not blocked by visibility constraints). The `manual` tag keyword is treated differently than the above by the "test_suite expansion" performed by the `bazel test` command on invocations involving wildcard [target patterns](https://bazel.build/docs/build#specifying-build-targets). There, `test_suite` targets tagged "manual" are filtered out (and thus not expanded). This behavior is consistent with how `bazel build` and `bazel test` handle wildcard target patterns in general. Note that this is explicitly different from how `bazel query 'tests(E)'` behaves, as suites are always expanded by the `tests` query function, regardless of the `manual` tag. Note that a test's `size` is considered a tag for the purpose of filtering. If you need a `test_suite` that contains tests with mutually exclusive tags (e.g. all small and medium tests), you'll have to create three `test_suite` rules: one for all small tests, one for all medium tests, and one that includes the previous two. | +| `tags` | List of strings; [nonconfigurable](common-definitions#configurable-attributes); default is `[]` List of text tags such as "small" or "database" or "-flaky". Tags may be any valid string. Tags which begin with a "-" character are considered negative tags. The preceding "-" character is not considered part of the tag, so a suite tag of "-small" matches a test's "small" size. All other tags are considered positive tags. Optionally, to make positive tags more explicit, tags may also begin with the "+" character, which will not be evaluated as part of the text of the tag. It merely makes the positive and negative distinction easier to read. Only test rules that match **all** of the positive tags and **none** of the negative tags will be included in the test suite. Note that this does not mean that error checking for dependencies on tests that are filtered out is skipped; the dependencies on skipped tests still need to be legal (e.g. not blocked by visibility constraints). The `manual` tag keyword is treated differently than the above by the "test\_suite expansion" performed by the `bazel test` command on invocations involving wildcard [target patterns](https://bazel.build/docs/build#specifying-build-targets). There, `test_suite` targets tagged "manual" are filtered out (and thus not expanded). This behavior is consistent with how `bazel build` and `bazel test` handle wildcard target patterns in general. Note that this is explicitly different from how `bazel query 'tests(E)'` behaves, as suites are always expanded by the `tests` query function, regardless of the `manual` tag. Note that a test's `size` is considered a tag for the purpose of filtering. If you need a `test_suite` that contains tests with mutually exclusive tags (e.g. all small and medium tests), you'll have to create three `test_suite` rules: one for all small tests, one for all medium tests, and one that includes the previous two. | | `tests` | List of [labels](/concepts/labels); [nonconfigurable](common-definitions#configurable-attributes); default is `[]` A list of test suites and test targets of any language. Any `*_test` is accepted here, independent of the language. No `*_binary` targets are accepted however, even if they happen to run a test. Filtering by the specified `tags` is only done for tests listed directly in this attribute. If this attribute contains `test_suite`s, the tests inside those will not be filtered by this `test_suite` (they are considered to be filtered already). If the `tests` attribute is unspecified or empty, the rule will default to including all test rules in the current BUILD file that are not tagged as `manual`. These rules are still subject to `tag` filtering. | \ No newline at end of file diff --git a/reference/be/java.mdx b/reference/be/java.mdx index 777383d6..29f5f2f7 100644 --- a/reference/be/java.mdx +++ b/reference/be/java.mdx @@ -4,18 +4,18 @@ title: 'Java Rules' ## Rules -* [java_binary](#java_binary) -* [java_import](#java_import) -* [java_library](#java_library) -* [java_test](#java_test) -* [java_package_configuration](#java_package_configuration) -* [java_plugin](#java_plugin) -* [java_runtime](#java_runtime) -* [java_toolchain](#java_toolchain) +* [java\_binary](#java_binary) +* [java\_import](#java_import) +* [java\_library](#java_library) +* [java\_test](#java_test) +* [java\_package\_configuration](#java_package_configuration) +* [java\_plugin](#java_plugin) +* [java\_runtime](#java_runtime) +* [java\_toolchain](#java_toolchain) -## java_binary +## java\_binary -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_java/blob/master/java/bazel/rules/bazel_java_binary.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_java/blob/master/java/bazel/rules/bazel_java_binary.bzl) ``` java_binary(name, deps, srcs, data, resources, add_exports, add_opens, args, aspect_hints, bootclasspath, classpath_resources, compatible_with, create_executable, deploy_env, deploy_manifest_lines, deprecation, env, exec_compatible_with, exec_group_compatible_with, exec_properties, features, javacopts, jvm_flags, launcher, licenses, main_class, neverlink, output_licenses, package_metadata, plugins, resource_strip_prefix, restricted_to, runtime_deps, stamp, tags, target_compatible_with, testonly, toolchains, use_launcher, use_testrunner, visibility) @@ -115,7 +115,7 @@ java_binary( | `deploy_manifest_lines` | List of strings; default is `[]` A list of lines to add to the `META-INF/manifest.mf` file generated for the `*_deploy.jar` target. The contents of this attribute are *not* subject to ["Make variable"](make-variables) substitution. | | `javacopts` | List of strings; default is `[]` Extra compiler options for this binary. Subject to ["Make variable"](make-variables) substitution and [Bourne shell tokenization](common-definitions#sh-tokenization). These compiler options are passed to javac after the global compiler options. | | `jvm_flags` | List of strings; default is `[]` A list of flags to embed in the wrapper script generated for running this binary. Subject to [$(location)](/reference/be/make-variables#location) and ["Make variable"](make-variables) substitution, and [Bourne shell tokenization](common-definitions#sh-tokenization). The wrapper script for a Java binary includes a CLASSPATH definition (to find all the dependent jars) and invokes the right Java interpreter. The command line generated by the wrapper script includes the name of the main class followed by a `"$@"` so you can pass along other arguments after the classname. However, arguments intended for parsing by the JVM must be specified *before* the classname on the command line. The contents of `jvm_flags` are added to the wrapper script before the classname is listed. Note that this attribute has *no effect* on `*_deploy.jar` outputs. | -| `launcher` | [Label](/concepts/labels); default is `None` Specify a binary that will be used to run your Java program instead of the normal `bin/java` program included with the JDK. The target must be a `cc_binary`. Any `cc_binary` that implements the [Java Invocation API](http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/invocation.html) can be specified as a value for this attribute. By default, Bazel will use the normal JDK launcher (bin/java or java.exe). The related [`--java_launcher`](/docs/user-manual#flag--java_launcher) Bazel flag affects only those `java_binary` and `java_test` targets that have *not* specified a `launcher` attribute. Note that your native (C++, SWIG, JNI) dependencies will be built differently depending on whether you are using the JDK launcher or another launcher: * If you are using the normal JDK launcher (the default), native dependencies are built as a shared library named `{name}_nativedeps.so`, where `{name}` is the `name` attribute of this java_binary rule. Unused code is *not* removed by the linker in this configuration. * If you are using any other launcher, native (C++) dependencies are statically linked into a binary named `{name}_nativedeps`, where `{name}` is the `name` attribute of this java_binary rule. In this case, the linker will remove any code it thinks is unused from the resulting binary, which means any C++ code accessed only via JNI may not be linked in unless that `cc_library` target specifies `alwayslink = True`. When using any launcher other than the default JDK launcher, the format of the `*_deploy.jar` output changes. See the main [java_binary](#java_binary) docs for details. | +| `launcher` | [Label](/concepts/labels); default is `None` Specify a binary that will be used to run your Java program instead of the normal `bin/java` program included with the JDK. The target must be a `cc_binary`. Any `cc_binary` that implements the [Java Invocation API](http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/invocation.html) can be specified as a value for this attribute. By default, Bazel will use the normal JDK launcher (bin/java or java.exe). The related [`--java_launcher`](/docs/user-manual#flag--java_launcher) Bazel flag affects only those `java_binary` and `java_test` targets that have *not* specified a `launcher` attribute. Note that your native (C++, SWIG, JNI) dependencies will be built differently depending on whether you are using the JDK launcher or another launcher: * If you are using the normal JDK launcher (the default), native dependencies are built as a shared library named `{name}_nativedeps.so`, where `{name}` is the `name` attribute of this java\_binary rule. Unused code is *not* removed by the linker in this configuration. * If you are using any other launcher, native (C++) dependencies are statically linked into a binary named `{name}_nativedeps`, where `{name}` is the `name` attribute of this java\_binary rule. In this case, the linker will remove any code it thinks is unused from the resulting binary, which means any C++ code accessed only via JNI may not be linked in unless that `cc_library` target specifies `alwayslink = True`. When using any launcher other than the default JDK launcher, the format of the `*_deploy.jar` output changes. See the main [java\_binary](#java_binary) docs for details. | | `main_class` | String; default is `""` Name of class with `main()` method to use as entry point. If a rule uses this option, it does not need a `srcs=[...]` list. Thus, with this attribute one can make an executable from a Java library that already contains one or more `main()` methods. The value of this attribute is a class name, not a source file. The class must be available at runtime: it may be compiled by this rule (from `srcs`) or provided by direct or transitive dependencies (through `runtime_deps` or `deps`). If the class is unavailable, the binary will fail at runtime; there is no build-time check. | | `neverlink` | Boolean; default is `False` | | `plugins` | List of [labels](/concepts/labels); default is `[]` Java compiler plugins to run at compile-time. Every `java_plugin` specified in this attribute will be run whenever this rule is built. A library may also inherit plugins from dependencies that use `exported_plugins`. Resources generated by the plugin will be included in the resulting jar of this rule. | @@ -125,9 +125,9 @@ java_binary( | `use_launcher` | Boolean; default is `True` Whether the binary should use a custom launcher. If this attribute is set to false, the [launcher](/reference/be/java#java_binary.launcher) attribute and the related [`--java_launcher`](/docs/user-manual#flag--java_launcher) flag will be ignored for this target. | | `use_testrunner` | Boolean; default is `False` Use the test runner (by default `com.google.testing.junit.runner.BazelTestRunner`) class as the main entry point for a Java program, and provide the test class to the test runner as a value of `bazel.test_suite` system property. You can use this to override the default behavior, which is to use test runner for `java_test` rules, and not use it for `java_binary` rules. It is unlikely you will want to do this. One use is for `AllTest` rules that are invoked by another rule (to set up a database before running the tests, for example). The `AllTest` rule must be declared as a `java_binary`, but should still use the test runner as its main entry point. The name of a test runner class can be overridden with `main_class` attribute. | -## java_import +## java\_import -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_java/blob/master/java/bazel/rules/bazel_java_import.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_java/blob/master/java/bazel/rules/bazel_java_import.bzl) ``` java_import(name, deps, data, add_exports, add_opens, aspect_hints, compatible_with, constraints, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, exports, features, jars, licenses, neverlink, package_metadata, proguard_specs, restricted_to, runtime_deps, srcjar, tags, target_compatible_with, testonly, toolchains, visibility) @@ -155,21 +155,21 @@ libraries for `java_library` and | Attributes | | | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | -| `deps` | List of [labels](/concepts/labels); default is `[]` The list of other libraries to be linked in to the target. See [java_library.deps](/reference/be/java#java_library.deps). | +| `deps` | List of [labels](/concepts/labels); default is `[]` The list of other libraries to be linked in to the target. See [java\_library.deps](/reference/be/java#java_library.deps). | | `data` | List of [labels](/concepts/labels); default is `[]` The list of files needed by this rule at runtime. | | `add_exports` | List of strings; default is `[]` Allow this library to access the given `module` or `package`. This corresponds to the javac and JVM --add-exports= flags. | | `add_opens` | List of strings; default is `[]` Allow this library to reflectively access the given `module` or `package`. This corresponds to the javac and JVM --add-opens= flags. | | `constraints` | List of strings; default is `[]` Extra constraints imposed on this rule as a Java library. | -| `exports` | List of [labels](/concepts/labels); default is `[]` Targets to make available to users of this rule. See [java_library.exports](/reference/be/java#java_library.exports). | +| `exports` | List of [labels](/concepts/labels); default is `[]` Targets to make available to users of this rule. See [java\_library.exports](/reference/be/java#java_library.exports). | | `jars` | List of [labels](/concepts/labels); required The list of JAR files provided to Java targets that depend on this target. | | `neverlink` | Boolean; default is `False` Only use this library for compilation and not at runtime. Useful if the library will be provided by the runtime environment during execution. Examples of libraries like this are IDE APIs for IDE plug-ins or `tools.jar` for anything running on a standard JDK. | -| `proguard_specs` | List of [labels](/concepts/labels); default is `[]` Files to be used as Proguard specification. These will describe the set of specifications to be used by Proguard. If specified, they will be added to any `android_binary` target depending on this library. The files included here must only have idempotent rules, namely -dontnote, -dontwarn, assumenosideeffects, and rules that start with -keep. Other options can only appear in `android_binary`'s proguard_specs, to ensure non-tautological merges. | -| `runtime_deps` | List of [labels](/concepts/labels); default is `[]` Libraries to make available to the final binary or test at runtime only. See [java_library.runtime_deps](/reference/be/java#java_library.runtime_deps). | +| `proguard_specs` | List of [labels](/concepts/labels); default is `[]` Files to be used as Proguard specification. These will describe the set of specifications to be used by Proguard. If specified, they will be added to any `android_binary` target depending on this library. The files included here must only have idempotent rules, namely -dontnote, -dontwarn, assumenosideeffects, and rules that start with -keep. Other options can only appear in `android_binary`'s proguard\_specs, to ensure non-tautological merges. | +| `runtime_deps` | List of [labels](/concepts/labels); default is `[]` Libraries to make available to the final binary or test at runtime only. See [java\_library.runtime\_deps](/reference/be/java#java_library.runtime_deps). | | `srcjar` | [Label](/concepts/labels); default is `None` A JAR file that contains source code for the compiled JAR files. | -## java_library +## java\_library -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_java/blob/master/java/bazel/rules/bazel_java_library.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_java/blob/master/java/bazel/rules/bazel_java_library.bzl) ``` java_library(name, deps, srcs, data, resources, add_exports, add_opens, aspect_hints, bootclasspath, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, exported_plugins, exports, features, javabuilder_jvm_flags, javacopts, licenses, neverlink, package_metadata, plugins, proguard_specs, resource_strip_prefix, restricted_to, runtime_deps, tags, target_compatible_with, testonly, toolchains, visibility) @@ -201,13 +201,13 @@ This rule compiles and links sources into a `.jar` file. | `javacopts` | List of strings; default is `[]` Extra compiler options for this library. Subject to ["Make variable"](make-variables) substitution and [Bourne shell tokenization](common-definitions#sh-tokenization). These compiler options are passed to javac after the global compiler options. | | `neverlink` | Boolean; default is `False` Whether this library should only be used for compilation and not at runtime. Useful if the library will be provided by the runtime environment during execution. Examples of such libraries are the IDE APIs for IDE plug-ins or `tools.jar` for anything running on a standard JDK. Note that `neverlink = True` does not prevent the compiler from inlining material from this library into compilation targets that depend on it, as permitted by the Java Language Specification (e.g., `static final` constants of `String` or of primitive types). The preferred use case is therefore when the runtime library is identical to the compilation library. If the runtime library differs from the compilation library then you must ensure that it differs only in places that the JLS forbids compilers to inline (and that must hold for all future versions of the JLS). | | `plugins` | List of [labels](/concepts/labels); default is `[]` Java compiler plugins to run at compile-time. Every `java_plugin` specified in this attribute will be run whenever this rule is built. A library may also inherit plugins from dependencies that use `exported_plugins`. Resources generated by the plugin will be included in the resulting jar of this rule. | -| `proguard_specs` | List of [labels](/concepts/labels); default is `[]` Files to be used as Proguard specification. These will describe the set of specifications to be used by Proguard. If specified, they will be added to any `android_binary` target depending on this library. The files included here must only have idempotent rules, namely -dontnote, -dontwarn, assumenosideeffects, and rules that start with -keep. Other options can only appear in `android_binary`'s proguard_specs, to ensure non-tautological merges. | +| `proguard_specs` | List of [labels](/concepts/labels); default is `[]` Files to be used as Proguard specification. These will describe the set of specifications to be used by Proguard. If specified, they will be added to any `android_binary` target depending on this library. The files included here must only have idempotent rules, namely -dontnote, -dontwarn, assumenosideeffects, and rules that start with -keep. Other options can only appear in `android_binary`'s proguard\_specs, to ensure non-tautological merges. | | `resource_strip_prefix` | String; default is `""` The path prefix to strip from Java resources. If specified, this path prefix is stripped from every file in the `resources` attribute. It is an error for a resource file not to be under this directory. If not specified (the default), the path of resource file is determined according to the same logic as the Java package of source files. For example, a source file at `stuff/java/foo/bar/a.txt` will be located at `foo/bar/a.txt`. | | `runtime_deps` | List of [labels](/concepts/labels); default is `[]` Libraries to make available to the final binary or test at runtime only. Like ordinary `deps`, these will appear on the runtime classpath, but unlike them, not on the compile-time classpath. Dependencies needed only at runtime should be listed here. Dependency-analysis tools should ignore targets that appear in both `runtime_deps` and `deps`. | -## java_test +## java\_test -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_java/blob/master/java/bazel/rules/bazel_java_test.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_java/blob/master/java/bazel/rules/bazel_java_test.bzl) ``` java_test(name, deps, srcs, data, resources, add_exports, add_opens, args, aspect_hints, bootclasspath, classpath_resources, compatible_with, create_executable, deploy_manifest_lines, deprecation, env, env_inherit, exec_compatible_with, exec_group_compatible_with, exec_properties, features, flaky, javacopts, jvm_flags, launcher, licenses, local, main_class, neverlink, package_metadata, plugins, resource_strip_prefix, restricted_to, runtime_deps, shard_count, size, stamp, tags, target_compatible_with, test_class, testonly, timeout, toolchains, use_launcher, use_testrunner, visibility) @@ -222,7 +222,7 @@ test code. The test runner's main method is invoked instead of the main class be * `name_deploy.jar`: A Java archive suitable for deployment. (Only built if explicitly requested.) See the description of the `name_deploy.jar` output from - [java_binary](#java_binary) for more details. + [java\_binary](#java_binary) for more details. See the section on `java_binary()` arguments. This rule also supports all [attributes common @@ -267,7 +267,7 @@ java_test( | `deploy_manifest_lines` | List of strings; default is `[]` A list of lines to add to the `META-INF/manifest.mf` file generated for the `*_deploy.jar` target. The contents of this attribute are *not* subject to ["Make variable"](make-variables) substitution. | | `javacopts` | List of strings; default is `[]` Extra compiler options for this binary. Subject to ["Make variable"](make-variables) substitution and [Bourne shell tokenization](common-definitions#sh-tokenization). These compiler options are passed to javac after the global compiler options. | | `jvm_flags` | List of strings; default is `[]` A list of flags to embed in the wrapper script generated for running this binary. Subject to [$(location)](/reference/be/make-variables#location) and ["Make variable"](make-variables) substitution, and [Bourne shell tokenization](common-definitions#sh-tokenization). The wrapper script for a Java binary includes a CLASSPATH definition (to find all the dependent jars) and invokes the right Java interpreter. The command line generated by the wrapper script includes the name of the main class followed by a `"$@"` so you can pass along other arguments after the classname. However, arguments intended for parsing by the JVM must be specified *before* the classname on the command line. The contents of `jvm_flags` are added to the wrapper script before the classname is listed. Note that this attribute has *no effect* on `*_deploy.jar` outputs. | -| `launcher` | [Label](/concepts/labels); default is `None` Specify a binary that will be used to run your Java program instead of the normal `bin/java` program included with the JDK. The target must be a `cc_binary`. Any `cc_binary` that implements the [Java Invocation API](http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/invocation.html) can be specified as a value for this attribute. By default, Bazel will use the normal JDK launcher (bin/java or java.exe). The related [`--java_launcher`](/docs/user-manual#flag--java_launcher) Bazel flag affects only those `java_binary` and `java_test` targets that have *not* specified a `launcher` attribute. Note that your native (C++, SWIG, JNI) dependencies will be built differently depending on whether you are using the JDK launcher or another launcher: * If you are using the normal JDK launcher (the default), native dependencies are built as a shared library named `{name}_nativedeps.so`, where `{name}` is the `name` attribute of this java_binary rule. Unused code is *not* removed by the linker in this configuration. * If you are using any other launcher, native (C++) dependencies are statically linked into a binary named `{name}_nativedeps`, where `{name}` is the `name` attribute of this java_binary rule. In this case, the linker will remove any code it thinks is unused from the resulting binary, which means any C++ code accessed only via JNI may not be linked in unless that `cc_library` target specifies `alwayslink = True`. When using any launcher other than the default JDK launcher, the format of the `*_deploy.jar` output changes. See the main [java_binary](#java_binary) docs for details. | +| `launcher` | [Label](/concepts/labels); default is `None` Specify a binary that will be used to run your Java program instead of the normal `bin/java` program included with the JDK. The target must be a `cc_binary`. Any `cc_binary` that implements the [Java Invocation API](http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/invocation.html) can be specified as a value for this attribute. By default, Bazel will use the normal JDK launcher (bin/java or java.exe). The related [`--java_launcher`](/docs/user-manual#flag--java_launcher) Bazel flag affects only those `java_binary` and `java_test` targets that have *not* specified a `launcher` attribute. Note that your native (C++, SWIG, JNI) dependencies will be built differently depending on whether you are using the JDK launcher or another launcher: * If you are using the normal JDK launcher (the default), native dependencies are built as a shared library named `{name}_nativedeps.so`, where `{name}` is the `name` attribute of this java\_binary rule. Unused code is *not* removed by the linker in this configuration. * If you are using any other launcher, native (C++) dependencies are statically linked into a binary named `{name}_nativedeps`, where `{name}` is the `name` attribute of this java\_binary rule. In this case, the linker will remove any code it thinks is unused from the resulting binary, which means any C++ code accessed only via JNI may not be linked in unless that `cc_library` target specifies `alwayslink = True`. When using any launcher other than the default JDK launcher, the format of the `*_deploy.jar` output changes. See the main [java\_binary](#java_binary) docs for details. | | `main_class` | String; default is `""` Name of class with `main()` method to use as entry point. If a rule uses this option, it does not need a `srcs=[...]` list. Thus, with this attribute one can make an executable from a Java library that already contains one or more `main()` methods. The value of this attribute is a class name, not a source file. The class must be available at runtime: it may be compiled by this rule (from `srcs`) or provided by direct or transitive dependencies (through `runtime_deps` or `deps`). If the class is unavailable, the binary will fail at runtime; there is no build-time check. | | `neverlink` | Boolean; default is `False` | | `plugins` | List of [labels](/concepts/labels); default is `[]` Java compiler plugins to run at compile-time. Every `java_plugin` specified in this attribute will be run whenever this rule is built. A library may also inherit plugins from dependencies that use `exported_plugins`. Resources generated by the plugin will be included in the resulting jar of this rule. | @@ -278,9 +278,9 @@ java_test( | `use_launcher` | Boolean; default is `True` Whether the binary should use a custom launcher. If this attribute is set to false, the [launcher](/reference/be/java#java_binary.launcher) attribute and the related [`--java_launcher`](/docs/user-manual#flag--java_launcher) flag will be ignored for this target. | | `use_testrunner` | Boolean; default is `True` Use the test runner (by default `com.google.testing.junit.runner.BazelTestRunner`) class as the main entry point for a Java program, and provide the test class to the test runner as a value of `bazel.test_suite` system property. You can use this to override the default behavior, which is to use test runner for `java_test` rules, and not use it for `java_binary` rules. It is unlikely you will want to do this. One use is for `AllTest` rules that are invoked by another rule (to set up a database before running the tests, for example). The `AllTest` rule must be declared as a `java_binary`, but should still use the test runner as its main entry point. The name of a test runner class can be overridden with `main_class` attribute. | -## java_package_configuration +## java\_package\_configuration -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_java/blob/master/java/common/rules/java_package_configuration.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_java/blob/master/java/common/rules/java_package_configuration.bzl) ``` java_package_configuration(name, data, aspect_hints, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, javacopts, output_licenses, package_metadata, packages, restricted_to, system, tags, target_compatible_with, testonly, toolchains, visibility) @@ -326,9 +326,9 @@ java_toolchain( | `packages` | List of [labels](/concepts/labels); default is `[]` The set of `package_group`s the configuration should be applied to. | | `system` | [Label](/concepts/labels); default is `None` Corresponds to javac's --system flag. | -## java_plugin +## java\_plugin -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_java/blob/master/java/bazel/rules/bazel_java_plugin.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_java/blob/master/java/bazel/rules/bazel_java_plugin.bzl) ``` java_plugin(name, deps, srcs, data, resources, add_exports, add_opens, aspect_hints, bootclasspath, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, generates_api, javabuilder_jvm_flags, javacopts, licenses, neverlink, output_licenses, package_metadata, plugins, processor_class, proguard_specs, resource_strip_prefix, restricted_to, tags, target_compatible_with, testonly, toolchains, visibility) @@ -346,7 +346,7 @@ directly depend on it using * `libname.jar`: A Java archive. Arguments are a subset of (and with identical semantics to) those of -[java_library()](/reference/be/java#java_library), +[java\_library()](/reference/be/java#java_library), except for the addition of the `processor_class` and `generates_api` arguments. @@ -362,19 +362,19 @@ except for the addition of the `processor_class` and | `add_exports` | List of strings; default is `[]` Allow this library to access the given `module` or `package`. This corresponds to the javac and JVM --add-exports= flags. | | `add_opens` | List of strings; default is `[]` Allow this library to reflectively access the given `module` or `package`. This corresponds to the javac and JVM --add-opens= flags. | | `bootclasspath` | [Label](/concepts/labels); default is `None` Restricted API, do not use! | -| `generates_api` | Boolean; default is `False` This attribute marks annotation processors that generate API code. If a rule uses an API-generating annotation processor, other rules depending on it can refer to the generated code only if their compilation actions are scheduled after the generating rule. This attribute instructs Bazel to introduce scheduling constraints when --java_header_compilation is enabled. *WARNING: This attribute affects build performance, use it only if necessary.* | +| `generates_api` | Boolean; default is `False` This attribute marks annotation processors that generate API code. If a rule uses an API-generating annotation processor, other rules depending on it can refer to the generated code only if their compilation actions are scheduled after the generating rule. This attribute instructs Bazel to introduce scheduling constraints when --java\_header\_compilation is enabled. *WARNING: This attribute affects build performance, use it only if necessary.* | | `javabuilder_jvm_flags` | List of strings; default is `[]` Restricted API, do not use! | | `javacopts` | List of strings; default is `[]` Extra compiler options for this library. Subject to ["Make variable"](make-variables) substitution and [Bourne shell tokenization](common-definitions#sh-tokenization). These compiler options are passed to javac after the global compiler options. | | `neverlink` | Boolean; default is `False` Whether this library should only be used for compilation and not at runtime. Useful if the library will be provided by the runtime environment during execution. Examples of such libraries are the IDE APIs for IDE plug-ins or `tools.jar` for anything running on a standard JDK. Note that `neverlink = True` does not prevent the compiler from inlining material from this library into compilation targets that depend on it, as permitted by the Java Language Specification (e.g., `static final` constants of `String` or of primitive types). The preferred use case is therefore when the runtime library is identical to the compilation library. If the runtime library differs from the compilation library then you must ensure that it differs only in places that the JLS forbids compilers to inline (and that must hold for all future versions of the JLS). | | `output_licenses` | List of strings; default is `[]` | | `plugins` | List of [labels](/concepts/labels); default is `[]` Java compiler plugins to run at compile-time. Every `java_plugin` specified in this attribute will be run whenever this rule is built. A library may also inherit plugins from dependencies that use `exported_plugins`. Resources generated by the plugin will be included in the resulting jar of this rule. | | `processor_class` | String; default is `""` The processor class is the fully qualified type of the class that the Java compiler should use as entry point to the annotation processor. If not specified, this rule will not contribute an annotation processor to the Java compiler's annotation processing, but its runtime classpath will still be included on the compiler's annotation processor path. (This is primarily intended for use by [Error Prone plugins](https://errorprone.info/docs/plugins), which are loaded from the annotation processor path using [java.util.ServiceLoader](https://docs.oracle.com/javase/8/docs/api/java/util/ServiceLoader.html).) | -| `proguard_specs` | List of [labels](/concepts/labels); default is `[]` Files to be used as Proguard specification. These will describe the set of specifications to be used by Proguard. If specified, they will be added to any `android_binary` target depending on this library. The files included here must only have idempotent rules, namely -dontnote, -dontwarn, assumenosideeffects, and rules that start with -keep. Other options can only appear in `android_binary`'s proguard_specs, to ensure non-tautological merges. | +| `proguard_specs` | List of [labels](/concepts/labels); default is `[]` Files to be used as Proguard specification. These will describe the set of specifications to be used by Proguard. If specified, they will be added to any `android_binary` target depending on this library. The files included here must only have idempotent rules, namely -dontnote, -dontwarn, assumenosideeffects, and rules that start with -keep. Other options can only appear in `android_binary`'s proguard\_specs, to ensure non-tautological merges. | | `resource_strip_prefix` | String; default is `""` The path prefix to strip from Java resources. If specified, this path prefix is stripped from every file in the `resources` attribute. It is an error for a resource file not to be under this directory. If not specified (the default), the path of resource file is determined according to the same logic as the Java package of source files. For example, a source file at `stuff/java/foo/bar/a.txt` will be located at `foo/bar/a.txt`. | -## java_runtime +## java\_runtime -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_java/blob/master/java/common/rules/java_runtime.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_java/blob/master/java/common/rules/java_runtime.bzl) ``` java_runtime(name, srcs, aspect_hints, compatible_with, default_cds, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, hermetic_srcs, hermetic_static_libs, java, java_home, lib_ct_sym, lib_modules, output_licenses, package_metadata, restricted_to, tags, target_compatible_with, testonly, toolchains, version, visibility) @@ -408,16 +408,16 @@ java_runtime( | `output_licenses` | List of strings; default is `[]` | | `version` | Integer; default is `0` The feature version of the Java runtime. I.e., the integer returned by `Runtime.version().feature()`. | -## java_toolchain +## java\_toolchain -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_java/blob/master/java/common/rules/java_toolchain.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_java/blob/master/java/common/rules/java_toolchain.bzl) ``` java_toolchain(name, android_lint_data, android_lint_jvm_opts, android_lint_opts, android_lint_package_configuration, android_lint_runner, aspect_hints, bootclasspath, compatible_javacopts, compatible_with, deprecation, deps_checker, exec_compatible_with, exec_group_compatible_with, exec_properties, features, forcibly_disable_header_compilation, genclass, header_compiler, header_compiler_builtin_processors, header_compiler_direct, ijar, jacocorunner, java_runtime, javabuilder, javabuilder_data, javabuilder_jvm_opts, javac_supports_multiplex_workers, javac_supports_worker_cancellation, javac_supports_worker_multiplex_sandboxing, javac_supports_workers, javacopts, jspecify_implicit_deps, jspecify_javacopts, jspecify_packages, jspecify_processor, jspecify_processor_class, jspecify_stubs, jvm_opts, licenses, misc, oneversion, oneversion_allowlist, oneversion_allowlist_for_tests, oneversion_whitelist, package_configuration, package_metadata, proguard_allowlister, reduced_classpath_incompatible_processors, restricted_to, singlejar, source_version, tags, target_compatible_with, target_version, testonly, timezone_data, toolchains, tools, turbine_data, turbine_jvm_opts, visibility, xlint) ``` Specifies the configuration for the Java compiler. Which toolchain to be used can be changed through -the --java_toolchain argument. Normally you should not write those kind of rules unless you want to +the --java\_toolchain argument. Normally you should not write those kind of rules unless you want to tune your Java compiler. #### Examples @@ -441,7 +441,7 @@ java_toolchain( | Attributes | | | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | -| `android_lint_data` | List of [labels](/concepts/labels); default is `[]` Labels of tools available for label-expansion in android_lint_jvm_opts. | +| `android_lint_data` | List of [labels](/concepts/labels); default is `[]` Labels of tools available for label-expansion in android\_lint\_jvm\_opts. | | `android_lint_jvm_opts` | List of strings; default is `[]` The list of arguments for the JVM when invoking Android Lint. | | `android_lint_opts` | List of strings; default is `[]` The list of Android Lint arguments. | | `android_lint_package_configuration` | List of [labels](/concepts/labels); default is `[]` Android Lint Configuration that should be applied to the specified package groups. | @@ -449,16 +449,16 @@ java_toolchain( | `bootclasspath` | List of [labels](/concepts/labels); default is `[]` The Java target bootclasspath entries. Corresponds to javac's -bootclasspath flag. | | `compatible_javacopts` | null; default is `{}` Internal API, do not use! | | `deps_checker` | [Label](/concepts/labels); default is `None` Label of the ImportDepsChecker deploy jar. | -| `forcibly_disable_header_compilation` | Boolean; default is `False` Overrides --java_header_compilation to disable header compilation on platforms that do not support it, e.g. JDK 7 Bazel. | +| `forcibly_disable_header_compilation` | Boolean; default is `False` Overrides --java\_header\_compilation to disable header compilation on platforms that do not support it, e.g. JDK 7 Bazel. | | `genclass` | [Label](/concepts/labels); default is `None` Label of the GenClass deploy jar. | -| `header_compiler` | [Label](/concepts/labels); default is `None` Label of the header compiler. Required if --java_header_compilation is enabled. | +| `header_compiler` | [Label](/concepts/labels); default is `None` Label of the header compiler. Required if --java\_header\_compilation is enabled. | | `header_compiler_builtin_processors` | List of strings; default is `[]` Internal API, do not use! | | `header_compiler_direct` | [Label](/concepts/labels); default is `None` Optional label of the header compiler to use for direct classpath actions that do not include any API-generating annotation processors. This tool does not support annotation processing. | | `ijar` | [Label](/concepts/labels); default is `None` Label of the ijar executable. | | `jacocorunner` | [Label](/concepts/labels); default is `None` Label of the JacocoCoverageRunner deploy jar. | -| `java_runtime` | [Label](/concepts/labels); default is `None` The java_runtime to use with this toolchain. It defaults to java_runtime in execution configuration. | +| `java_runtime` | [Label](/concepts/labels); default is `None` The java\_runtime to use with this toolchain. It defaults to java\_runtime in execution configuration. | | `javabuilder` | [Label](/concepts/labels); default is `None` Label of the JavaBuilder deploy jar. | -| `javabuilder_data` | List of [labels](/concepts/labels); default is `[]` Labels of data available for label-expansion in javabuilder_jvm_opts. | +| `javabuilder_data` | List of [labels](/concepts/labels); default is `[]` Labels of data available for label-expansion in javabuilder\_jvm\_opts. | | `javabuilder_jvm_opts` | List of strings; default is `[]` The list of arguments for the JVM when invoking JavaBuilder. | | `javac_supports_multiplex_workers` | Boolean; default is `True` True if JavaBuilder supports running as a multiplex persistent worker, false if it doesn't. | | `javac_supports_worker_cancellation` | Boolean; default is `True` True if JavaBuilder supports cancellation of persistent workers, false if it doesn't. | @@ -476,15 +476,15 @@ java_toolchain( | `oneversion` | [Label](/concepts/labels); default is `None` Label of the one-version enforcement binary. | | `oneversion_allowlist` | [Label](/concepts/labels); default is `None` Label of the one-version allowlist. | | `oneversion_allowlist_for_tests` | [Label](/concepts/labels); default is `None` Label of the one-version allowlist for tests. | -| `oneversion_whitelist` | [Label](/concepts/labels); default is `None` Deprecated: use oneversion_allowlist instead | +| `oneversion_whitelist` | [Label](/concepts/labels); default is `None` Deprecated: use oneversion\_allowlist instead | | `package_configuration` | List of [labels](/concepts/labels); default is `[]` Configuration that should be applied to the specified package groups. | | `proguard_allowlister` | [Label](/concepts/labels); default is `"@bazel_tools//tools/jdk:proguard_whitelister"` Label of the Proguard allowlister. | | `reduced_classpath_incompatible_processors` | List of strings; default is `[]` Internal API, do not use! | | `singlejar` | [Label](/concepts/labels); default is `None` Label of the SingleJar executable. | | `source_version` | String; default is `""` The Java source version (e.g., '6' or '7'). It specifies which set of code structures are allowed in the Java source code. | | `target_version` | String; default is `""` The Java target version (e.g., '6' or '7'). It specifies for which Java runtime the class should be build. | -| `timezone_data` | [Label](/concepts/labels); default is `None` Label of a resource jar containing timezone data. If set, the timezone data is added as an implicitly runtime dependency of all java_binary rules. | -| `tools` | List of [labels](/concepts/labels); default is `[]` Labels of tools available for label-expansion in jvm_opts. | -| `turbine_data` | List of [labels](/concepts/labels); default is `[]` Labels of data available for label-expansion in turbine_jvm_opts. | +| `timezone_data` | [Label](/concepts/labels); default is `None` Label of a resource jar containing timezone data. If set, the timezone data is added as an implicitly runtime dependency of all java\_binary rules. | +| `tools` | List of [labels](/concepts/labels); default is `[]` Labels of tools available for label-expansion in jvm\_opts. | +| `turbine_data` | List of [labels](/concepts/labels); default is `[]` Labels of data available for label-expansion in turbine\_jvm\_opts. | | `turbine_jvm_opts` | List of strings; default is `[]` The list of arguments for the JVM when invoking turbine. | | `xlint` | List of strings; default is `[]` The list of warning to add or removes from default list. Precedes it with a dash to removes it. Please see the Javac documentation on the -Xlint options for more information. | \ No newline at end of file diff --git a/reference/be/make-variables.mdx b/reference/be/make-variables.mdx index 5b8c1797..beca1dae 100644 --- a/reference/be/make-variables.mdx +++ b/reference/be/make-variables.mdx @@ -153,7 +153,8 @@ instead. The predefined variables `execpath`, `execpaths`, `rootpath`, `rootpaths`, `location`, and -`locations` take label parameters (e.g. `$(execpath //foo:bar)`) and substitute the file paths denoted by that label. +`locations` take label parameters (e.g. `$(execpath +//foo:bar)`) and substitute the file paths denoted by that label. For source files, this is the path relative to your workspace root. For files that are outputs of rules, this is the file's *output path* @@ -258,7 +259,8 @@ not care about. **C++ toolchain variables** The following are defined in C++ toolchain rules and available to any rule -that sets `toolchains = ["@bazel_tools//tools/cpp:toolchain_type"]` +that sets `toolchains = +["@bazel_tools//tools/cpp:toolchain_type"]` Some rules, like `java_binary`, implicitly include the C++ toolchain in their rule definition. They inherit these variables automatically. @@ -296,7 +298,8 @@ rare cases. If you are tempted to use them, please [contact the Bazel devs](http **Java toolchain variables** The following are defined in Java toolchain rules and available to any rule -that sets `toolchains = ["@rules_java//toolchains:current_java_runtime"]` (or +that sets `toolchains = +["@rules_java//toolchains:current_java_runtime"]` (or `"@rules_java//toolchains:current_host_java_runtime"` for the host toolchain equivalent). diff --git a/reference/be/objective-c.mdx b/reference/be/objective-c.mdx index 44898db9..cae93d7f 100644 --- a/reference/be/objective-c.mdx +++ b/reference/be/objective-c.mdx @@ -4,12 +4,12 @@ title: 'Objective-C Rules' ## Rules -* [objc_import](#objc_import) -* [objc_library](#objc_library) +* [objc\_import](#objc_import) +* [objc\_library](#objc_library) -## objc_import +## objc\_import -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/objc_import.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/objc_import.bzl) ``` objc_import(name, deps, hdrs, alwayslink, archives, aspect_hints, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, includes, package_metadata, restricted_to, sdk_dylibs, sdk_frameworks, sdk_includes, tags, target_compatible_with, testonly, textual_hdrs, toolchains, visibility, weak_sdk_frameworks) @@ -35,9 +35,9 @@ attributes supported by `objc_library`. | `textual_hdrs` | List of [labels](/concepts/labels); default is `[]` The list of C, C++, Objective-C, and Objective-C++ files that are included as headers by source files in this rule or by users of this library. Unlike hdrs, these will not be compiled separately from the sources. | | `weak_sdk_frameworks` | List of strings; default is `[]` Names of SDK frameworks to weakly link with. For instance, "MediaAccessibility". In difference to regularly linked SDK frameworks, symbols from weakly linked frameworks do not cause an error if they are not present at runtime. | -## objc_library +## objc\_library -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/objc_library.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_cc/blob/master/cc/private/rules_impl/objc_library.bzl) ``` objc_library(name, deps, srcs, data, hdrs, alwayslink, aspect_hints, compatible_with, conlyopts, copts, cxxopts, defines, deprecation, enable_modules, exec_compatible_with, exec_group_compatible_with, exec_properties, features, implementation_deps, includes, linkopts, module_map, module_name, non_arc_srcs, package_metadata, pch, restricted_to, sdk_dylibs, sdk_frameworks, sdk_includes, stamp, tags, target_compatible_with, testonly, textual_hdrs, toolchains, visibility, weak_sdk_frameworks) @@ -54,16 +54,16 @@ This rule produces a static library from the given Objective-C source files. | `srcs` | List of [labels](/concepts/labels); default is `[]` The list of C, C++, Objective-C, and Objective-C++ source and header files, and/or (`.s`, `.S`, or `.asm`) assembly source files, that are processed to create the library target. These are your checked-in files, plus any generated files. Source files are compiled into .o files with Clang. Header files may be included/imported by any source or header in the srcs attribute of this target, but not by headers in hdrs or any targets that depend on this rule. Additionally, precompiled .o files may be given as srcs. Be careful to ensure consistency in the architecture of provided .o files and that of the build to avoid missing symbol linker errors. | | `hdrs` | List of [labels](/concepts/labels); default is `[]` The list of C, C++, Objective-C, and Objective-C++ header files published by this library to be included by sources in dependent rules. These headers describe the public interface for the library and will be made available for inclusion by sources in this rule or in dependent rules. Headers not meant to be included by a client of this library should be listed in the srcs attribute instead. These will be compiled separately from the source if modules are enabled. | | `alwayslink` | Boolean; default is `False` If 1, any bundle or binary that depends (directly or indirectly) on this library will link in all the object files for the files listed in `srcs` and `non_arc_srcs`, even if some contain no symbols referenced by the binary. This is useful if your code isn't explicitly called by code in the binary, e.g., if your code registers to receive some callback provided by some service. | -| `conlyopts` | List of strings; default is `[]` Extra flags to pass to the compiler for C files. Subject to ["Make variable"](/reference/be/make-variables) substitution and [Bourne shell tokenization](/reference/be/common-definitions#sh-tokenization). These flags will only apply to this target, and not those upon which it depends, or those which depend on it. Note that for the generated Xcode project, directory paths specified using "-I" flags in copts are parsed out, prepended with "$(WORKSPACE_ROOT)/" if they are relative paths, and added to the header search paths for the associated Xcode target. | -| `copts` | List of strings; default is `[]` Extra flags to pass to the compiler. Subject to ["Make variable"](/reference/be/make-variables) substitution and [Bourne shell tokenization](/reference/be/common-definitions#sh-tokenization). These flags will only apply to this target, and not those upon which it depends, or those which depend on it. Note that for the generated Xcode project, directory paths specified using "-I" flags in copts are parsed out, prepended with "$(WORKSPACE_ROOT)/" if they are relative paths, and added to the header search paths for the associated Xcode target. | -| `cxxopts` | List of strings; default is `[]` Extra flags to pass to the compiler for Objective-C++ and C++ files. Subject to ["Make variable"](/reference/be/make-variables) substitution and [Bourne shell tokenization](/reference/be/common-definitions#sh-tokenization). These flags will only apply to this target, and not those upon which it depends, or those which depend on it. Note that for the generated Xcode project, directory paths specified using "-I" flags in copts are parsed out, prepended with "$(WORKSPACE_ROOT)/" if they are relative paths, and added to the header search paths for the associated Xcode target. | +| `conlyopts` | List of strings; default is `[]` Extra flags to pass to the compiler for C files. Subject to ["Make variable"](/reference/be/make-variables) substitution and [Bourne shell tokenization](/reference/be/common-definitions#sh-tokenization). These flags will only apply to this target, and not those upon which it depends, or those which depend on it. Note that for the generated Xcode project, directory paths specified using "-I" flags in copts are parsed out, prepended with "$(WORKSPACE\_ROOT)/" if they are relative paths, and added to the header search paths for the associated Xcode target. | +| `copts` | List of strings; default is `[]` Extra flags to pass to the compiler. Subject to ["Make variable"](/reference/be/make-variables) substitution and [Bourne shell tokenization](/reference/be/common-definitions#sh-tokenization). These flags will only apply to this target, and not those upon which it depends, or those which depend on it. Note that for the generated Xcode project, directory paths specified using "-I" flags in copts are parsed out, prepended with "$(WORKSPACE\_ROOT)/" if they are relative paths, and added to the header search paths for the associated Xcode target. | +| `cxxopts` | List of strings; default is `[]` Extra flags to pass to the compiler for Objective-C++ and C++ files. Subject to ["Make variable"](/reference/be/make-variables) substitution and [Bourne shell tokenization](/reference/be/common-definitions#sh-tokenization). These flags will only apply to this target, and not those upon which it depends, or those which depend on it. Note that for the generated Xcode project, directory paths specified using "-I" flags in copts are parsed out, prepended with "$(WORKSPACE\_ROOT)/" if they are relative paths, and added to the header search paths for the associated Xcode target. | | `defines` | List of strings; default is `[]` Extra `-D` flags to pass to the compiler. They should be in the form `KEY=VALUE` or simply `KEY` and are passed not only to the compiler for this target (as `copts` are) but also to all `objc_` dependers of this target. Subject to ["Make variable"](/reference/be/make-variables) substitution and [Bourne shell tokenization](/reference/be/common-definitions#sh-tokenization). | -| `enable_modules` | Boolean; default is `False` Enables clang module support (via -fmodules). Setting this to 1 will allow you to @import system headers and other targets: @import UIKit; @import path_to_package_target; | +| `enable_modules` | Boolean; default is `False` Enables clang module support (via -fmodules). Setting this to 1 will allow you to @import system headers and other targets: @import UIKit; @import path\_to\_package\_target; | | `implementation_deps` | List of [labels](/concepts/labels); default is `[]` The list of other libraries that the library target depends on. Unlike with `deps`, the headers and include paths of these libraries (and all their transitive deps) are only used for compilation of this library, and not libraries that depend on it. Libraries specified with `implementation_deps` are still linked in binary targets that depend on this library. | | `includes` | List of strings; default is `[]` List of `#include/#import` search paths to add to this target and all depending targets. This is to support third party and open-sourced libraries that do not specify the entire workspace path in their `#import/#include` statements. The paths are interpreted relative to the package directory, and the genfiles and bin roots (e.g. `blaze-genfiles/pkg/includedir` and `blaze-out/pkg/includedir`) are included in addition to the actual client root. Unlike [COPTS](/reference/be/objective-c#objc_library.copts), these flags are added for this rule and every rule that depends on it. (Note: not the rules it depends upon!) Be very careful, since this may have far-reaching effects. When in doubt, add "-iquote" flags to [COPTS](/reference/be/objective-c#objc_library.copts) instead. | | `linkopts` | List of strings; default is `[]` Extra flags to pass to the linker. | | `module_map` | [Label](/concepts/labels); default is `None` custom Clang module map for this target. Use of a custom module map is discouraged. Most users should use module maps generated by Bazel. If specified, Bazel will not generate a module map for this target, but will pass the provided module map to the compiler. | -| `module_name` | String; default is `""` Sets the module name for this target. By default the module name is the target path with all special symbols replaced by \_, e.g. //foo/baz:bar can be imported as foo_baz_bar. | +| `module_name` | String; default is `""` Sets the module name for this target. By default the module name is the target path with all special symbols replaced by \_, e.g. //foo/baz:bar can be imported as foo\_baz\_bar. | | `non_arc_srcs` | List of [labels](/concepts/labels); default is `[]` The list of Objective-C files that are processed to create the library target that DO NOT use Automatic Reference Counting (ARC). The files in this attribute are treated very similar to those in the srcs attribute, but are compiled without ARC enabled. | | `pch` | [Label](/concepts/labels); default is `None` Header file to prepend to every source file being compiled (both arc and non-arc). Use of pch files is actively discouraged in BUILD files, and this should be considered deprecated. Since pch files are not actually precompiled this is not a build-speed enhancement, and instead is just a global dependency. From a build efficiency point of view you are actually better including what you need directly in your sources where you need it. | | `sdk_dylibs` | List of strings; default is `[]` Names of SDK .dylib libraries to link with. For instance, "libz" or "libarchive". "libc++" is included automatically if the binary has any C++ or Objective-C++ sources in its dependency tree. When linking a binary, all libraries named in that binary's transitive dependency graph are used. | diff --git a/reference/be/overview.mdx b/reference/be/overview.mdx index e3f46056..40d1725d 100644 --- a/reference/be/overview.mdx +++ b/reference/be/overview.mdx @@ -19,8 +19,8 @@ title: 'Bazel BUILD Encyclopedia of Functions' ## Functions * [package](/reference/be/functions#package) -* [package_group](/reference/be/functions#package_group) -* [exports_files](/reference/be/functions#exports_files) +* [package\_group](/reference/be/functions#package_group) +* [exports\_files](/reference/be/functions#exports_files) * [glob](/reference/be/functions#glob) * [select](/reference/be/functions#select) * [workspace](/rules/lib/globals/workspace#workspace) @@ -37,17 +37,17 @@ For non-native Starlark rules that ship separately from Bazel, see the list of | Language | Flags | Binary rules | Library rules | Test rules | Other rules | | --- | --- | --- | --- | --- | --- | -| C / C++ | | [cc_binary](c-cpp#cc_binary) | [cc_import](c-cpp#cc_import) [cc_library](c-cpp#cc_library) [cc_shared_library](c-cpp#cc_shared_library) [cc_static_library](c-cpp#cc_static_library) | [cc_test](c-cpp#cc_test) | [cc_toolchain](c-cpp#cc_toolchain) [fdo_prefetch_hints](c-cpp#fdo_prefetch_hints) [fdo_profile](c-cpp#fdo_profile) [memprof_profile](c-cpp#memprof_profile) [propeller_optimize](c-cpp#propeller_optimize) | -| Java | | [java_binary](java#java_binary) | [java_import](java#java_import) [java_library](java#java_library) | [java_test](java#java_test) | [java_package_configuration](java#java_package_configuration) [java_plugin](java#java_plugin) [java_runtime](java#java_runtime) [java_toolchain](java#java_toolchain) | -| Objective-C | | | [objc_import](objective-c#objc_import) [objc_library](objective-c#objc_library) | | | -| Protocol Buffer | | | [cc_proto_library](protocol-buffer#cc_proto_library) [java_lite_proto_library](protocol-buffer#java_lite_proto_library) [java_proto_library](protocol-buffer#java_proto_library) [proto_library](protocol-buffer#proto_library) [py_proto_library](protocol-buffer#py_proto_library) | | [proto_lang_toolchain](protocol-buffer#proto_lang_toolchain) [proto_toolchain](protocol-buffer#proto_toolchain) | -| Python | | [py_binary](python#py_binary) | [py_library](python#py_library) | [py_test](python#py_test) | [py_runtime](python#py_runtime) | -| Shell | | [sh_binary](shell#sh_binary) | [sh_library](shell#sh_library) | [sh_test](shell#sh_test) | | +| C / C++ | | [cc\_binary](c-cpp#cc_binary) | [cc\_import](c-cpp#cc_import) [cc\_library](c-cpp#cc_library) [cc\_shared\_library](c-cpp#cc_shared_library) [cc\_static\_library](c-cpp#cc_static_library) | [cc\_test](c-cpp#cc_test) | [cc\_toolchain](c-cpp#cc_toolchain) [fdo\_prefetch\_hints](c-cpp#fdo_prefetch_hints) [fdo\_profile](c-cpp#fdo_profile) [memprof\_profile](c-cpp#memprof_profile) [propeller\_optimize](c-cpp#propeller_optimize) | +| Java | | [java\_binary](java#java_binary) | [java\_import](java#java_import) [java\_library](java#java_library) | [java\_test](java#java_test) | [java\_package\_configuration](java#java_package_configuration) [java\_plugin](java#java_plugin) [java\_runtime](java#java_runtime) [java\_toolchain](java#java_toolchain) | +| Objective-C | | | [objc\_import](objective-c#objc_import) [objc\_library](objective-c#objc_library) | | | +| Protocol Buffer | | | [cc\_proto\_library](protocol-buffer#cc_proto_library) [java\_lite\_proto\_library](protocol-buffer#java_lite_proto_library) [java\_proto\_library](protocol-buffer#java_proto_library) [proto\_library](protocol-buffer#proto_library) [py\_proto\_library](protocol-buffer#py_proto_library) | | [proto\_lang\_toolchain](protocol-buffer#proto_lang_toolchain) [proto\_toolchain](protocol-buffer#proto_toolchain) | +| Python | | [py\_binary](python#py_binary) | [py\_library](python#py_library) | [py\_test](python#py_test) | [py\_runtime](python#py_runtime) | +| Shell | | [sh\_binary](shell#sh_binary) | [sh\_library](shell#sh_library) | [sh\_test](shell#sh_test) | | ### Language-agnostic native rules | Family | Rules | | --- | --- | -| Extra Actions | * [action_listener](extra-actions#action_listener)* [extra_action](extra-actions#extra_action) | -| General | * [alias](general#alias)* [config_setting](general#config_setting)* [filegroup](general#filegroup)* [genquery](general#genquery)* [genrule](general#genrule)* [starlark_doc_extract](general#starlark_doc_extract)* [test_suite](general#test_suite) | -| Platforms and Toolchains | * [constraint_setting](platforms-and-toolchains#constraint_setting)* [constraint_value](platforms-and-toolchains#constraint_value)* [platform](platforms-and-toolchains#platform)* [toolchain](platforms-and-toolchains#toolchain)* [toolchain_type](platforms-and-toolchains#toolchain_type) | \ No newline at end of file +| Extra Actions | * [action\_listener](extra-actions#action_listener)* [extra\_action](extra-actions#extra_action) | +| General | * [alias](general#alias)* [config\_setting](general#config_setting)* [filegroup](general#filegroup)* [genquery](general#genquery)* [genrule](general#genrule)* [starlark\_doc\_extract](general#starlark_doc_extract)* [test\_suite](general#test_suite) | +| Platforms and Toolchains | * [constraint\_setting](platforms-and-toolchains#constraint_setting)* [constraint\_value](platforms-and-toolchains#constraint_value)* [platform](platforms-and-toolchains#platform)* [toolchain](platforms-and-toolchains#toolchain)* [toolchain\_type](platforms-and-toolchains#toolchain_type) | \ No newline at end of file diff --git a/reference/be/platforms-and-toolchains.mdx b/reference/be/platforms-and-toolchains.mdx index 9561a689..db242ea4 100644 --- a/reference/be/platforms-and-toolchains.mdx +++ b/reference/be/platforms-and-toolchains.mdx @@ -8,22 +8,22 @@ The user should be familiar with the concepts explained [here](/extending/platfo ## Rules -* [constraint_setting](#constraint_setting) -* [constraint_value](#constraint_value) +* [constraint\_setting](#constraint_setting) +* [constraint\_value](#constraint_value) * [platform](#platform) * [toolchain](#toolchain) -* [toolchain_type](#toolchain_type) +* [toolchain\_type](#toolchain_type) -## constraint_setting +## constraint\_setting -[View rule sourceopen_in_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintSettingRule.java) ``` constraint_setting(name, aspect_hints, default_constraint_value, deprecation, features, licenses, tags, testonly, visibility) ``` This rule is used to introduce a new constraint type for which a platform may specify a value. -For instance, you might define a `constraint_setting` named "glibc_version" to represent +For instance, you might define a `constraint_setting` named "glibc\_version" to represent the capability for platforms to have different versions of the glibc library installed. For more details, see the [Platforms](https://bazel.build/docs/platforms) page. @@ -41,9 +41,9 @@ define a platform targeting an obscure cpu architecture. | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | | `default_constraint_value` | [Name](/concepts/labels#target-names); [nonconfigurable](common-definitions#configurable-attributes); default is `None` The label of the default value for this setting, to be used if no value is given. If this attribute is present, the `constraint_value` it points to must be defined in the same package as this `constraint_setting`. If a constraint setting has a default value, then whenever a platform does not include any constraint value for that setting, it is the same as if the platform had specified the default value. Otherwise, if there is no default value, the constraint setting is considered to be unspecified by that platform. In that case, the platform would not match against any constraint list (such as for a `config_setting`) that requires a particular value for that setting. | -## constraint_value +## constraint\_value -[View rule sourceopen_in_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/platform/ConstraintValueRule.java) ``` constraint_value(name, aspect_hints, constraint_setting, deprecation, features, licenses, tags, testonly, visibility) @@ -77,7 +77,7 @@ Platforms can then declare that they have the `mips` architecture as an alternat ## platform -[View rule sourceopen_in_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java) ``` platform(name, aspect_hints, constraint_values, deprecation, exec_properties, features, flags, licenses, missing_toolchain_error, parents, required_settings, tags, testonly, visibility) @@ -137,7 +137,8 @@ Some flags will accumulate values when they are repeated, such as `--features`, These flags are not compatible with setting the flags from the platform: instead, all previous values will be removed and overwritten with the values from the platform. -As an example, given the following platform, the invocation `build --platforms=//:repeat_demo --features feature_a --features feature_b` will end up with the value of the +As an example, given the following platform, the invocation `build --platforms=//:repeat_demo +--features feature_a --features feature_b` will end up with the value of the `--feature` flag being `["feature_c", "feature_d"]`, removing the features set on the command line. @@ -240,7 +241,7 @@ platform( In this example, the child platforms have the following properties: -* `child_a` inherits the "exec_properties" of the parent and does not set its own. +* `child_a` inherits the "exec\_properties" of the parent and does not set its own. * `child_b` inherits the parent's `exec_properties` and overrides the value of `k1`. Its `exec_properties` will be: `{ "k1": "child", "k2": "v2" }`. @@ -257,15 +258,15 @@ In this example, the child platforms have the following properties: | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | | `constraint_values` | List of [labels](/concepts/labels); [nonconfigurable](common-definitions#configurable-attributes); default is `[]` The combination of constraint choices that this platform comprises. In order for a platform to apply to a given environment, the environment must have at least the values in this list. Each `constraint_value` in this list must be for a different `constraint_setting`. For example, you cannot define a platform that requires the cpu architecture to be both `@platforms//cpu:x86_64` and `@platforms//cpu:arm`. | -| `exec_properties` | Dictionary: String -> String; [nonconfigurable](common-definitions#configurable-attributes); default is `{}` A map of strings that affect the way actions are executed remotely. Bazel makes no attempt to interpret this, it is treated as opaque data that's forwarded via the Platform field of the [remote execution protocol](https://github.com/bazelbuild/remote-apis). This includes any data from the parent platform's `exec_properties` attributes. If the child and parent platform define the same keys, the child's values are kept. Any keys associated with a value that is an empty string are removed from the dictionary. | +| `exec_properties` | Dictionary: String -> String; [nonconfigurable](common-definitions#configurable-attributes); default is `{}` A map of strings that affect the way actions are executed remotely. Bazel makes no attempt to interpret this, it is treated as opaque data that's forwarded via the Platform field of the [remote execution protocol](https://github.com/bazelbuild/remote-apis). This includes any data from the parent platform's `exec_properties` attributes. If the child and parent platform define the same keys, the child's values are kept. Any keys associated with a value that is an empty string are removed from the dictionary. | | `flags` | List of strings; [nonconfigurable](common-definitions#configurable-attributes); default is `[]` A list of flags that will be enabled when this platform is used as the target platform in a configuration. Only flags that are part of the configuration can be set, such as those that can be used in transitions, or the `--define` flag. | | `missing_toolchain_error` | String; [nonconfigurable](common-definitions#configurable-attributes); default is `"For more information on platforms or toolchains see https://bazel.build/concepts/platforms-intro."` A custom error message that is displayed when a mandatory toolchain requirement cannot be satisfied for this target platform. Intended to point to relevant documentation users can read to understand why their toolchains are misconfigured. Not inherited from parent platforms. | -| `parents` | List of [labels](/concepts/labels); [nonconfigurable](common-definitions#configurable-attributes); default is `[]` The label of a `platform` target that this platform should inherit from. Although the attribute takes a list, there should be no more than one platform present. Any constraint_settings not set directly on this platform will be found in the parent platform. See the section on [Platform Inheritance](#platform_inheritance) for details. | +| `parents` | List of [labels](/concepts/labels); [nonconfigurable](common-definitions#configurable-attributes); default is `[]` The label of a `platform` target that this platform should inherit from. Although the attribute takes a list, there should be no more than one platform present. Any constraint\_settings not set directly on this platform will be found in the parent platform. See the section on [Platform Inheritance](#platform_inheritance) for details. | | `required_settings` | List of [labels](/concepts/labels); default is `[]` A list of `config_setting`s that must be satisfied by the target configuration in order for this platform to be used as an execution platform during toolchain resolution. Required settings are not inherited from parent platforms. | ## toolchain -[View rule sourceopen_in_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/platform/ToolchainRule.java) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/platform/ToolchainRule.java) ``` toolchain(name, aspect_hints, deprecation, exec_compatible_with, features, licenses, package_metadata, tags, target_compatible_with, target_settings, testonly, toolchain, toolchain_type, use_target_platform_constraints, visibility) @@ -288,9 +289,9 @@ details. | `toolchain_type` | [Label](/concepts/labels); [nonconfigurable](common-definitions#configurable-attributes); required The label of a `toolchain_type` target that represents the role that this toolchain serves. | | `use_target_platform_constraints` | Boolean; [nonconfigurable](common-definitions#configurable-attributes); default is `False` If `True`, this toolchain behaves as if its `exec_compatible_with` and `target_compatible_with` constraints are set to those of the current target platform. `exec_compatible_with` and `target_compatible_with` must not be set in that case. | -## toolchain_type +## toolchain\_type -[View rule sourceopen_in_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/ToolchainType.java) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/ToolchainType.java) ``` toolchain_type(name, aspect_hints, compatible_with, deprecation, features, no_match_error, package_metadata, restricted_to, tags, target_compatible_with, testonly, visibility) diff --git a/reference/be/protocol-buffer.mdx b/reference/be/protocol-buffer.mdx index 65bf8114..c5ab4f17 100644 --- a/reference/be/protocol-buffer.mdx +++ b/reference/be/protocol-buffer.mdx @@ -4,17 +4,17 @@ title: 'Protocol Buffer Rules' ## Rules -* [cc_proto_library](#cc_proto_library) -* [java_lite_proto_library](#java_lite_proto_library) -* [java_proto_library](#java_proto_library) -* [proto_library](#proto_library) -* [py_proto_library](#py_proto_library) -* [proto_lang_toolchain](#proto_lang_toolchain) -* [proto_toolchain](#proto_toolchain) +* [cc\_proto\_library](#cc_proto_library) +* [java\_lite\_proto\_library](#java_lite_proto_library) +* [java\_proto\_library](#java_proto_library) +* [proto\_library](#proto_library) +* [py\_proto\_library](#py_proto_library) +* [proto\_lang\_toolchain](#proto_lang_toolchain) +* [proto\_toolchain](#proto_toolchain) -## cc_proto_library +## cc\_proto\_library -[View rule sourceopen_in_new](https://github.com/protocolbuffers/protobuf/tree/v29.0-rc2/bazel/private/bazel_cc_proto_library.bzl) +[View rule sourceopen\_in\_new](https://github.com/protocolbuffers/protobuf/tree/v29.0-rc2/bazel/private/bazel_cc_proto_library.bzl) ``` cc_proto_library(name, deps, aspect_hints, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, package_metadata, restricted_to, tags, target_compatible_with, testonly, toolchains, visibility) @@ -49,9 +49,9 @@ proto_library( | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | | `deps` | List of [labels](/concepts/labels); default is `[]` The list of [`proto_library`](protocol-buffer#proto_library) rules to generate C++ code for. | -## java_lite_proto_library +## java\_lite\_proto\_library -[View rule sourceopen_in_new](https://github.com/protocolbuffers/protobuf/tree/v29.0-rc2/bazel/private/java_lite_proto_library.bzl) +[View rule sourceopen\_in\_new](https://github.com/protocolbuffers/protobuf/tree/v29.0-rc2/bazel/private/java_lite_proto_library.bzl) ``` java_lite_proto_library(name, deps, aspect_hints, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, package_metadata, restricted_to, tags, target_compatible_with, testonly, toolchains, visibility) @@ -86,9 +86,9 @@ proto_library( | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | | `deps` | List of [labels](/concepts/labels); default is `[]` The list of [`proto_library`](protocol-buffer#proto_library) rules to generate Java code for. | -## java_proto_library +## java\_proto\_library -[View rule sourceopen_in_new](https://github.com/protocolbuffers/protobuf/tree/v29.0-rc2/bazel/private/bazel_java_proto_library_rule.bzl) +[View rule sourceopen\_in\_new](https://github.com/protocolbuffers/protobuf/tree/v29.0-rc2/bazel/private/bazel_java_proto_library_rule.bzl) ``` java_proto_library(name, deps, aspect_hints, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, licenses, package_metadata, restricted_to, tags, target_compatible_with, testonly, toolchains, visibility) @@ -123,9 +123,9 @@ proto_library( | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | | `deps` | List of [labels](/concepts/labels); default is `[]` The list of [`proto_library`](protocol-buffer#proto_library) rules to generate Java code for. | -## proto_library +## proto\_library -[View rule sourceopen_in_new](https://github.com/protocolbuffers/protobuf/tree/v29.0-rc2/bazel/private/proto_library_rule.bzl) +[View rule sourceopen\_in\_new](https://github.com/protocolbuffers/protobuf/tree/v29.0-rc2/bazel/private/proto_library_rule.bzl) ``` proto_library(name, deps, srcs, data, allow_exports, aspect_hints, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, exports, extension_declarations, features, import_prefix, licenses, option_deps, package_metadata, restricted_to, strip_import_prefix, tags, target_compatible_with, testonly, toolchains, visibility) @@ -140,7 +140,7 @@ When compiled on the command-line, a `proto_library` creates a file named `foo-descriptor-set.proto.bin`, which is the descriptor set for the messages the rule srcs. The file is a serialized `FileDescriptorSet`, which is described in -https://developers.google.com/protocol-buffers/docs/techniques#self-description. +. It only contains information about the `.proto` files directly mentioned by a `proto_library` rule; the collection of transitive @@ -161,38 +161,38 @@ Recommended code organization: | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | | `deps` | List of [labels](/concepts/labels); default is `[]` The list of other `proto_library` rules that the target depends upon. A `proto_library` may only depend on other `proto_library` targets. It may not depend on language-specific libraries. | -| `srcs` | List of [labels](/concepts/labels); default is `[]` The list of `.proto` and `.protodevel` files that are processed to create the target. This is usually a non empty list. One usecase where `srcs` can be empty is an *alias-library*. This is a proto_library rule having one or more other proto_library in `deps`. This pattern can be used to e.g. export a public api under a persistent name. | -| `allow_exports` | [Label](/concepts/labels); default is `None` An optional allowlist that prevents proto library to be reexported or used in lang_proto_library that is not in one of the listed packages. | -| `exports` | List of [labels](/concepts/labels); default is `[]` List of proto_library targets that can be referenced via "import public" in the proto source. It's an error if you use "import public" but do not list the corresponding library in the exports attribute. Note that you have list the library both in deps and exports since not all lang_proto_library implementations have been changed yet. | +| `srcs` | List of [labels](/concepts/labels); default is `[]` The list of `.proto` and `.protodevel` files that are processed to create the target. This is usually a non empty list. One usecase where `srcs` can be empty is an *alias-library*. This is a proto\_library rule having one or more other proto\_library in `deps`. This pattern can be used to e.g. export a public api under a persistent name. | +| `allow_exports` | [Label](/concepts/labels); default is `None` An optional allowlist that prevents proto library to be reexported or used in lang\_proto\_library that is not in one of the listed packages. | +| `exports` | List of [labels](/concepts/labels); default is `[]` List of proto\_library targets that can be referenced via "import public" in the proto source. It's an error if you use "import public" but do not list the corresponding library in the exports attribute. Note that you have list the library both in deps and exports since not all lang\_proto\_library implementations have been changed yet. | | `extension_declarations` | List of [labels](/concepts/labels); default is `[]` List of files containing extension declarations. This attribute is only allowed for use with MessageSet. | | `import_prefix` | String; default is `""` The prefix to add to the paths of the .proto files in this rule. When set, the .proto source files in the `srcs` attribute of this rule are accessible at is the value of this attribute prepended to their repository-relative path. The prefix in the `strip_import_prefix` attribute is removed before this prefix is added. | | `option_deps` | List of [labels](/concepts/labels); default is `[]` The list of other `proto_library` rules that the target depends upon for options only. A `proto_library` may only depend on other `proto_library` targets. It may not depend on language-specific libraries. | | `strip_import_prefix` | String; default is `"/"` The prefix to strip from the paths of the .proto files in this rule. When set, .proto source files in the `srcs` attribute of this rule are accessible at their path with this prefix cut off. If it's a relative path (not starting with a slash), it's taken as a package-relative one. If it's an absolute one, it's understood as a repository-relative path. The prefix in the `import_prefix` attribute is added after this prefix is stripped. | -## py_proto_library +## py\_proto\_library -[View rule sourceopen_in_new](https://github.com/protocolbuffers/protobuf/tree/v29.0-rc2/bazel/py_proto_library.bzl) +[View rule sourceopen\_in\_new](https://github.com/protocolbuffers/protobuf/tree/v29.0-rc2/bazel/py_proto_library.bzl) ``` py_proto_library(name, deps, aspect_hints, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, package_metadata, restricted_to, tags, target_compatible_with, testonly, toolchains, visibility) ``` -Use `py_proto_library` to generate Python libraries from `.proto` files. -The convention is to name the `py_proto_library` rule `foo_py_pb2`, -when it is wrapping `proto_library` rule `foo_proto`. -`deps` must point to a `proto_library` rule. +Use `py\_proto\_library` to generate Python libraries from `.proto` files. +The convention is to name the `py\_proto\_library` rule `foo\_py\_pb2`, +when it is wrapping `proto\_library` rule `foo\_proto`. +`deps` must point to a `proto\_library` rule. Example: ```starlark -py_library( +py\_library( name = "lib", -deps = [":foo_py_pb2"], +deps = [":foo\_py\_pb2"], ) -py_proto_library( -name = "foo_py_pb2", -deps = [":foo_proto"], +py\_proto\_library( +name = "foo\_py\_pb2", +deps = [":foo\_proto"], ) -proto_library( -name = "foo_proto", +proto\_library( +name = "foo\_proto", srcs = ["foo.proto"], ) ``` @@ -202,30 +202,30 @@ srcs = ["foo.proto"], | Attributes | | | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | -| `deps` | List of [labels](/concepts/labels); default is `[]` The list of `proto_library` rules to generate Python libraries for. Usually this is just the one target: the proto library of interest. It can be any target providing `ProtoInfo`. | +| `deps` | List of [labels](/concepts/labels); default is `[]` The list of `proto\_library` rules to generate Python libraries for. Usually this is just the one target: the proto library of interest. It can be any target providing `ProtoInfo`. | -## proto_lang_toolchain +## proto\_lang\_toolchain -[View rule sourceopen_in_new](https://github.com/protocolbuffers/protobuf/tree/v29.0-rc2/bazel/private/proto_lang_toolchain_rule.bzl) +[View rule sourceopen\_in\_new](https://github.com/protocolbuffers/protobuf/tree/v29.0-rc2/bazel/private/proto_lang_toolchain_rule.bzl) ``` proto_lang_toolchain(name, allowlist_different_package, aspect_hints, blacklisted_protos, command_line, compatible_with, denylisted_protos, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, mnemonic, output_files, package_metadata, plugin, plugin_format_flag, progress_message, protoc_minimal_do_not_use, restricted_to, runtime, tags, target_compatible_with, testonly, toolchain_type, toolchains, visibility) ``` -If using Bazel, please load the rule from https://github.com/bazelbuild/rules_proto. +If using Bazel, please load the rule from . -Specifies how a LANG_proto_library rule (e.g., `java_proto_library`) should invoke the +Specifies how a LANG\_proto\_library rule (e.g., `java_proto_library`) should invoke the proto-compiler. -Some LANG_proto_library rules allow specifying which toolchain to use using command-line flags; +Some LANG\_proto\_library rules allow specifying which toolchain to use using command-line flags; consult their documentation. Normally you should not write those kind of rules unless you want to tune your Java compiler. -There's no compiler. The proto-compiler is taken from the proto_library rule we attach to. It is +There's no compiler. The proto-compiler is taken from the proto\_library rule we attach to. It is passed as a command-line flag to Blaze. -Several features require a proto-compiler to be invoked on the proto_library rule itself. -It's beneficial to enforce the compiler that LANG_proto_library uses is the same as the one +Several features require a proto-compiler to be invoked on the proto\_library rule itself. +It's beneficial to enforce the compiler that LANG\_proto\_library uses is the same as the one `proto_library` does. #### Examples @@ -248,7 +248,7 @@ proto_lang_toolchain( | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | | `allowlist_different_package` | [Label](/concepts/labels); default is `None` | | `blacklisted_protos` | List of [labels](/concepts/labels); default is `[]` Deprecated. Alias for `denylisted_protos`. Will be removed in a future release. | -| `command_line` | String; required This value will be passed to proto-compiler to generate the code. Only include the parts specific to this code-generator/plugin (e.g., do not include -I parameters) * `$(OUT)` is LANG_proto_library-specific. The rules are expected to define how they interpret this variable. For Java, for example, $(OUT) will be replaced with the src-jar filename to create. | +| `command_line` | String; required This value will be passed to proto-compiler to generate the code. Only include the parts specific to this code-generator/plugin (e.g., do not include -I parameters) * `$(OUT)` is LANG\_proto\_library-specific. The rules are expected to define how they interpret this variable. For Java, for example, $(OUT) will be replaced with the src-jar filename to create. | | `denylisted_protos` | List of [labels](/concepts/labels); default is `[]` No code will be generated for files in the `srcs` attribute of `denylisted_protos`. This is used for .proto files that are already linked into proto runtimes, such as `any.proto`. | | `mnemonic` | String; default is `"GenProto"` This value will be set as the mnemonic on protoc action. | | `output_files` | String; default is `"legacy"` Controls how `$(OUT)` in `command_line` is formatted, either by a path to a single file or output directory in case of multiple files. Possible values are: "single", "multiple". | @@ -256,12 +256,12 @@ proto_lang_toolchain( | `plugin_format_flag` | String; default is `""` If provided, this value will be passed to proto-compiler to use the plugin. The value must contain a single %s which is replaced with plugin executable. `--plugin=protoc-gen-PLUGIN=.` | | `progress_message` | String; default is `"Generating proto_library %{label}"` This value will be set as the progress message on protoc action. | | `protoc_minimal_do_not_use` | [Label](/concepts/labels); default is `None` | -| `runtime` | [Label](/concepts/labels); default is `None` A language-specific library that the generated code is compiled against. The exact behavior is LANG_proto_library-specific. Java, for example, should compile against the runtime. | +| `runtime` | [Label](/concepts/labels); default is `None` A language-specific library that the generated code is compiled against. The exact behavior is LANG\_proto\_library-specific. Java, for example, should compile against the runtime. | | `toolchain_type` | [Label](/concepts/labels); default is `None` | -## proto_toolchain +## proto\_toolchain -[View rule sourceopen_in_new](https://github.com/protocolbuffers/protobuf/tree/v29.0-rc2/bazel/private/proto_toolchain_rule.bzl) +[View rule sourceopen\_in\_new](https://github.com/protocolbuffers/protobuf/tree/v29.0-rc2/bazel/private/proto_toolchain_rule.bzl) ``` proto_toolchain(name, aspect_hints, command_line, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, mnemonic, output_files, package_metadata, progress_message, proto_compiler, restricted_to, tags, target_compatible_with, testonly, toolchains, visibility) diff --git a/reference/be/python.mdx b/reference/be/python.mdx index e734693a..a85fd9cf 100644 --- a/reference/be/python.mdx +++ b/reference/be/python.mdx @@ -4,14 +4,14 @@ title: 'Python Rules' ## Rules -* [py_binary](#py_binary) -* [py_library](#py_library) -* [py_test](#py_test) -* [py_runtime](#py_runtime) +* [py\_binary](#py_binary) +* [py\_library](#py_library) +* [py\_test](#py_test) +* [py\_runtime](#py_runtime) -## py_binary +## py\_binary -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_python/tree/0.40.0/python/private/py_binary_rule.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_python/tree/0.40.0/python/private/py_binary_rule.bzl) ``` py_binary(name, deps, srcs, data, args, aspect_hints, compatible_with, config_settings, deprecation, distribs, env, exec_compatible_with, exec_group_compatible_with, exec_properties, features, imports, interpreter_args, legacy_create_init, licenses, main, main_module, output_licenses, package_metadata, precompile, precompile_invalidation_mode, precompile_optimize_level, precompile_source_retention, pyc_collection, pyi_deps, pyi_srcs, python_version, restricted_to, srcs_version, stamp, tags, target_compatible_with, testonly, toolchains, visibility) @@ -22,30 +22,30 @@ py_binary(name, deps, srcs, data, args, aspect_hints, compatible_with, config_se | Attributes | | | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | -| `deps` | List of [labels](/concepts/labels); default is `[]` List of additional libraries to be linked in to the target. See comments about the [`deps` attribute typically defined by rules](https://bazel.build/reference/be/common-definitions#typical-attributes). These are typically `py_library` rules. Targets that only provide data files used at runtime belong in the `data` attribute. :::{note} The order of this list can matter because it affects the order that information from dependencies is merged in, which can be relevant depending on the ordering mode of depsets that are merged. \* {obj}`PyInfo.venv_symlinks` uses default ordering. See {obj}`PyInfo` for more information about the ordering of its depsets and how its fields are merged. ::: | +| `deps` | List of [labels](/concepts/labels); default is `[]` List of additional libraries to be linked in to the target. See comments about the [`deps` attribute typically defined by rules](https://bazel.build/reference/be/common-definitions#typical-attributes). These are typically `py\_library` rules. Targets that only provide data files used at runtime belong in the `data` attribute. :::{note} The order of this list can matter because it affects the order that information from dependencies is merged in, which can be relevant depending on the ordering mode of depsets that are merged. \* {obj}`PyInfo.venv\_symlinks` uses default ordering. See {obj}`PyInfo` for more information about the ordering of its depsets and how its fields are merged. ::: | | `srcs` | List of [labels](/concepts/labels); default is `[]` The list of Python source files that are processed to create the target. This includes all your checked-in code and may include generated source files. The `.py` files belong in `srcs` and library targets belong in `deps`. Other binary files that may be needed at run time belong in `data`. | -| `data` | List of [labels](/concepts/labels); default is `[]` The list of files need by this library at runtime. See comments about the [`data` attribute typically defined by rules](https://bazel.build/reference/be/common-definitions#typical-attributes). There is no `py_embed_data` like there is `cc_embed_data` and `go_embed_data`. This is because Python has a concept of runtime resources. | -| `config_settings` | Dictionary: [label](/concepts/labels) -> String; default is `{}` Config settings to change for this target. The keys are labels for settings, and the values are strings for the new value to use. Pass `Label` objects or canonical label strings for the keys to ensure they resolve as expected (canonical labels start with `@@` and can be obtained by calling `str(Label(...))`). Most `@rules_python//python/config_setting` settings can be used here, which allows, for example, making only a certain `py_binary` use {obj}`--boostrap_impl=script`. Additional or custom config settings can be registered using the {obj}`add_transition_setting` API. This allows, for example, forcing a particular CPU, or defining a custom setting that `select()` uses elsewhere to pick between `pip.parse` hubs. See the [How to guide on multiple versions of a library] for a more concrete example. :::{note} These values are transitioned on, so will affect the analysis graph and the associated memory overhead. The more unique configurations in your overall build, the more memory and (often unnecessary) re-analysis and re-building can occur. See https://bazel.build/extending/config#memory-performance-considerations for more information about risks and considerations. ::: :::{versionadded} 1.7.0 ::: | +| `data` | List of [labels](/concepts/labels); default is `[]` The list of files need by this library at runtime. See comments about the [`data` attribute typically defined by rules](https://bazel.build/reference/be/common-definitions#typical-attributes). There is no `py\_embed\_data` like there is `cc\_embed\_data` and `go\_embed\_data`. This is because Python has a concept of runtime resources. | +| `config_settings` | Dictionary: [label](/concepts/labels) -> String; default is `{}` Config settings to change for this target. The keys are labels for settings, and the values are strings for the new value to use. Pass `Label` objects or canonical label strings for the keys to ensure they resolve as expected (canonical labels start with `@@` and can be obtained by calling `str(Label(...))`). Most `@rules\_python//python/config\_setting` settings can be used here, which allows, for example, making only a certain `py\_binary` use {obj}`--boostrap\_impl=script`. Additional or custom config settings can be registered using the {obj}`add\_transition\_setting` API. This allows, for example, forcing a particular CPU, or defining a custom setting that `select()` uses elsewhere to pick between `pip.parse` hubs. See the [How to guide on multiple versions of a library] for a more concrete example. :::{note} These values are transitioned on, so will affect the analysis graph and the associated memory overhead. The more unique configurations in your overall build, the more memory and (often unnecessary) re-analysis and re-building can occur. See https://bazel.build/extending/config#memory-performance-considerations for more information about risks and considerations. ::: :::{versionadded} 1.7.0 ::: | | `distribs` | List of strings; default is `[]` | -| `imports` | List of strings; default is `[]` List of import directories to be added to the PYTHONPATH. Subject to "Make variable" substitution. These import directories will be added for this rule and all rules that depend on it (note: not the rules this rule depends on. Each directory will be added to `PYTHONPATH` by `py_binary` rules that depend on this rule. The strings are repo-runfiles-root relative, Absolute paths (paths that start with `/`) and paths that references a path above the execution root are not allowed and will result in an error. | -| `interpreter_args` | List of strings; default is `[]` Arguments that are only applicable to the interpreter. The args an interpreter supports are specific to the interpreter. For CPython, see https://docs.python.org/3/using/cmdline.html. :::{note} Only supported for {obj}`--bootstrap_impl=script`. Ignored otherwise. ::: :::{seealso} The {any}`RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS` environment variable ::: :::{versionadded} 1.3.0 ::: | -| `legacy_create_init` | Integer; default is `-1` Whether to implicitly create empty `\__init\_\_.py` files in the runfiles tree. These are created in every directory containing Python source code or shared libraries, and every parent directory of those directories, excluding the repo root directory. The default, `-1` (auto), means true unless `--incompatible_default_to_explicit_init_py` is used. If false, the user is responsible for creating (possibly empty) `\__init\_\_.py` files and adding them to the `srcs` of Python targets as required. | -| `main` | [Label](/concepts/labels); default is `None` Optional; the name of the source file that is the main entry point of the application. This file must also be listed in `srcs`. If left unspecified, `name`, with `.py` appended, is used instead. If `name` does not match any filename in `srcs`, `main` must be specified. This is mutually exclusive with {obj}`main_module`. | -| `main_module` | String; default is `""` Module name to execute as the main program. When set, `srcs` is not required, and it is assumed the module is provided by a dependency. See https://docs.python.org/3/using/cmdline.html#cmdoption-m for more information about running modules as the main program. This is mutually exclusive with {obj}`main`. :::{versionadded} 1.3.0 ::: :::{versionchanged} 1.7.0 Support added for {obj}`--bootstrap_impl=system_python`. ::: | -| `precompile` | String; default is `"inherit"` Whether py source files \*\*for this target\*\* should be precompiled. Values: \* `inherit`: Allow the downstream binary decide if precompiled files are used. \* `enabled`: Compile Python source files at build time. \* `disabled`: Don't compile Python source files at build time. :::{seealso} \* The {flag}`--precompile` flag, which can override this attribute in some cases and will affect all targets when building. \* The {obj}`pyc_collection` attribute for transitively enabling precompiling on a per-target basis. \* The [Precompiling](precompiling) docs for a guide about using precompiling. ::: | -| `precompile_invalidation_mode` | String; default is `"auto"` How precompiled files should be verified to be up-to-date with their associated source files. Possible values are: \* `auto`: The effective value will be automatically determined by other build settings. \* `checked_hash`: Use the pyc file if the hash of the source file matches the hash recorded in the pyc file. This is most useful when working with code that you may modify. \* `unchecked_hash`: Always use the pyc file; don't check the pyc's hash against the source file. This is most useful when the code won't be modified. For more information on pyc invalidation modes, see https://docs.python.org/3/library/py_compile.html#py_compile.PycInvalidationMode | +| `imports` | List of strings; default is `[]` List of import directories to be added to the PYTHONPATH. Subject to "Make variable" substitution. These import directories will be added for this rule and all rules that depend on it (note: not the rules this rule depends on. Each directory will be added to `PYTHONPATH` by `py\_binary` rules that depend on this rule. The strings are repo-runfiles-root relative, Absolute paths (paths that start with `/`) and paths that references a path above the execution root are not allowed and will result in an error. | +| `interpreter_args` | List of strings; default is `[]` Arguments that are only applicable to the interpreter. The args an interpreter supports are specific to the interpreter. For CPython, see https://docs.python.org/3/using/cmdline.html. :::{note} Only supported for {obj}`--bootstrap\_impl=script`. Ignored otherwise. ::: :::{seealso} The {any}`RULES\_PYTHON\_ADDITIONAL\_INTERPRETER\_ARGS` environment variable ::: :::{versionadded} 1.3.0 ::: | +| `legacy_create_init` | Integer; default is `-1` Whether to implicitly create empty `\_\_init\_\_.py` files in the runfiles tree. These are created in every directory containing Python source code or shared libraries, and every parent directory of those directories, excluding the repo root directory. The default, `-1` (auto), means true unless `--incompatible\_default\_to\_explicit\_init\_py` is used. If false, the user is responsible for creating (possibly empty) `\_\_init\_\_.py` files and adding them to the `srcs` of Python targets as required. | +| `main` | [Label](/concepts/labels); default is `None` Optional; the name of the source file that is the main entry point of the application. This file must also be listed in `srcs`. If left unspecified, `name`, with `.py` appended, is used instead. If `name` does not match any filename in `srcs`, `main` must be specified. This is mutually exclusive with {obj}`main\_module`. | +| `main_module` | String; default is `""` Module name to execute as the main program. When set, `srcs` is not required, and it is assumed the module is provided by a dependency. See https://docs.python.org/3/using/cmdline.html#cmdoption-m for more information about running modules as the main program. This is mutually exclusive with {obj}`main`. :::{versionadded} 1.3.0 ::: :::{versionchanged} 1.7.0 Support added for {obj}`--bootstrap\_impl=system\_python`. ::: | +| `precompile` | String; default is `"inherit"` Whether py source files \*\*for this target\*\* should be precompiled. Values: \* `inherit`: Allow the downstream binary decide if precompiled files are used. \* `enabled`: Compile Python source files at build time. \* `disabled`: Don't compile Python source files at build time. :::{seealso} \* The {flag}`--precompile` flag, which can override this attribute in some cases and will affect all targets when building. \* The {obj}`pyc\_collection` attribute for transitively enabling precompiling on a per-target basis. \* The [Precompiling](precompiling) docs for a guide about using precompiling. ::: | +| `precompile_invalidation_mode` | String; default is `"auto"` How precompiled files should be verified to be up-to-date with their associated source files. Possible values are: \* `auto`: The effective value will be automatically determined by other build settings. \* `checked\_hash`: Use the pyc file if the hash of the source file matches the hash recorded in the pyc file. This is most useful when working with code that you may modify. \* `unchecked\_hash`: Always use the pyc file; don't check the pyc's hash against the source file. This is most useful when the code won't be modified. For more information on pyc invalidation modes, see https://docs.python.org/3/library/py\_compile.html#py\_compile.PycInvalidationMode | | `precompile_optimize_level` | Integer; default is `0` The optimization level for precompiled files. For more information about optimization levels, see the `compile()` function's `optimize` arg docs at https://docs.python.org/3/library/functions.html#compile NOTE: The value `-1` means "current interpreter", which will be the interpreter used \_at build time when pycs are generated\_, not the interpreter used at runtime when the code actually runs. | -| `precompile_source_retention` | String; default is `"inherit"` Determines, when a source file is compiled, if the source file is kept in the resulting output or not. Valid values are: \* `inherit`: Inherit the value from the {flag}`--precompile_source_retention` flag. \* `keep_source`: Include the original Python source. \* `omit_source`: Don't include the original py source. | -| `pyc_collection` | String; default is `"inherit"` Determines whether pyc files from dependencies should be manually included. Valid values are: \* `inherit`: Inherit the value from {flag}`--precompile`. \* `include_pyc`: Add implicitly generated pyc files from dependencies. i.e. pyc files for targets that specify {attr}`precompile="inherit"`. \* `disabled`: Don't add implicitly generated pyc files. Note that pyc files may still come from dependencies that enable precompiling at the target level. | -| `pyi_deps` | List of [labels](/concepts/labels); default is `[]` Dependencies providing type definitions the library needs. These are dependencies that satisfy imports guarded by `typing.TYPE_CHECKING`. These are build-time only dependencies and not included as part of a runnable program (packaging rules may include them, however). :::{versionadded} 1.1.0 ::: | -| `pyi_srcs` | List of [labels](/concepts/labels); default is `[]` Type definition files for the library. These are typically `.pyi` files, but other file types for type-checker specific formats are allowed. These files are build-time only dependencies and not included as part of a runnable program (packaging rules may include them, however). :::{versionadded} 1.1.0 ::: | -| `python_version` | String; default is `""` The Python version this target should use. The value should be in `X.Y` or `X.Y.Z` (or compatible) format. If empty or unspecified, the incoming configuration's {obj}`--python_version` flag is inherited. For backwards compatibility, the values `PY2` and `PY3` are accepted, but treated as an empty/unspecified value. :::{note} In order for the requested version to be used, there must be a toolchain configured to match the Python version. If there isn't, then it may be silently ignored, or an error may occur, depending on the toolchain configuration. ::: :::{versionchanged} 1.1.0 This attribute was changed from only accepting `PY2` and `PY3` values to accepting arbitrary Python versions. ::: | +| `precompile_source_retention` | String; default is `"inherit"` Determines, when a source file is compiled, if the source file is kept in the resulting output or not. Valid values are: \* `inherit`: Inherit the value from the {flag}`--precompile\_source\_retention` flag. \* `keep\_source`: Include the original Python source. \* `omit\_source`: Don't include the original py source. | +| `pyc_collection` | String; default is `"inherit"` Determines whether pyc files from dependencies should be manually included. Valid values are: \* `inherit`: Inherit the value from {flag}`--precompile`. \* `include\_pyc`: Add implicitly generated pyc files from dependencies. i.e. pyc files for targets that specify {attr}`precompile="inherit"`. \* `disabled`: Don't add implicitly generated pyc files. Note that pyc files may still come from dependencies that enable precompiling at the target level. | +| `pyi_deps` | List of [labels](/concepts/labels); default is `[]` Dependencies providing type definitions the library needs. These are dependencies that satisfy imports guarded by `typing.TYPE\_CHECKING`. These are build-time only dependencies and not included as part of a runnable program (packaging rules may include them, however). :::{versionadded} 1.1.0 ::: | +| `pyi_srcs` | List of [labels](/concepts/labels); default is `[]` Type definition files for the library. These are typically `.pyi` files, but other file types for type-checker specific formats are allowed. These files are build-time only dependencies and not included as part of a runnable program (packaging rules may include them, however). :::{versionadded} 1.1.0 ::: | +| `python_version` | String; default is `""` The Python version this target should use. The value should be in `X.Y` or `X.Y.Z` (or compatible) format. If empty or unspecified, the incoming configuration's {obj}`--python\_version` flag is inherited. For backwards compatibility, the values `PY2` and `PY3` are accepted, but treated as an empty/unspecified value. :::{note} In order for the requested version to be used, there must be a toolchain configured to match the Python version. If there isn't, then it may be silently ignored, or an error may occur, depending on the toolchain configuration. ::: :::{versionchanged} 1.1.0 This attribute was changed from only accepting `PY2` and `PY3` values to accepting arbitrary Python versions. ::: | | `srcs_version` | String; default is `""` Defunct, unused, does nothing. | | `stamp` | Integer; default is `-1` Whether to encode build information into the binary. Possible values: \* `stamp = 1`: Always stamp the build information into the binary, even in `--nostamp` builds. \*\*This setting should be avoided\*\*, since it potentially kills remote caching for the binary and any downstream actions that depend on it. \* `stamp = 0`: Always replace build information by constant values. This gives good build result caching. \* `stamp = -1`: Embedding of build information is controlled by the `--[no]stamp` flag. Stamped binaries are not rebuilt unless their dependencies change. WARNING: Stamping can harm build performance by reducing cache hits and should be avoided if possible. | -## py_library +## py\_library -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_python/tree/0.40.0/python/private/py_library_rule.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_python/tree/0.40.0/python/private/py_library_rule.bzl) ``` py_library(name, deps, srcs, data, aspect_hints, compatible_with, deprecation, distribs, exec_compatible_with, exec_group_compatible_with, exec_properties, experimental_venvs_site_packages, features, imports, licenses, package_metadata, precompile, precompile_invalidation_mode, precompile_optimize_level, precompile_source_retention, pyi_deps, pyi_srcs, restricted_to, srcs_version, tags, target_compatible_with, testonly, toolchains, visibility) @@ -58,7 +58,7 @@ Default outputs: NOTE: Precompilation affects which of the default outputs are included in the resulting runfiles. See the precompile-related attributes and flags for more information. -:::{versionchanged} 0.37.0 +:::{versionchanged} 0.37.0 Source files are no longer added to the runfiles directly. ::: @@ -67,23 +67,23 @@ Source files are no longer added to the runfiles directly. | Attributes | | | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | -| `deps` | List of [labels](/concepts/labels); default is `[]` List of additional libraries to be linked in to the target. See comments about the [`deps` attribute typically defined by rules](https://bazel.build/reference/be/common-definitions#typical-attributes). These are typically `py_library` rules. Targets that only provide data files used at runtime belong in the `data` attribute. :::{note} The order of this list can matter because it affects the order that information from dependencies is merged in, which can be relevant depending on the ordering mode of depsets that are merged. \* {obj}`PyInfo.venv_symlinks` uses default ordering. See {obj}`PyInfo` for more information about the ordering of its depsets and how its fields are merged. ::: | +| `deps` | List of [labels](/concepts/labels); default is `[]` List of additional libraries to be linked in to the target. See comments about the [`deps` attribute typically defined by rules](https://bazel.build/reference/be/common-definitions#typical-attributes). These are typically `py\_library` rules. Targets that only provide data files used at runtime belong in the `data` attribute. :::{note} The order of this list can matter because it affects the order that information from dependencies is merged in, which can be relevant depending on the ordering mode of depsets that are merged. \* {obj}`PyInfo.venv\_symlinks` uses default ordering. See {obj}`PyInfo` for more information about the ordering of its depsets and how its fields are merged. ::: | | `srcs` | List of [labels](/concepts/labels); default is `[]` The list of Python source files that are processed to create the target. This includes all your checked-in code and may include generated source files. The `.py` files belong in `srcs` and library targets belong in `deps`. Other binary files that may be needed at run time belong in `data`. | -| `data` | List of [labels](/concepts/labels); default is `[]` The list of files need by this library at runtime. See comments about the [`data` attribute typically defined by rules](https://bazel.build/reference/be/common-definitions#typical-attributes). There is no `py_embed_data` like there is `cc_embed_data` and `go_embed_data`. This is because Python has a concept of runtime resources. | +| `data` | List of [labels](/concepts/labels); default is `[]` The list of files need by this library at runtime. See comments about the [`data` attribute typically defined by rules](https://bazel.build/reference/be/common-definitions#typical-attributes). There is no `py\_embed\_data` like there is `cc\_embed\_data` and `go\_embed\_data`. This is because Python has a concept of runtime resources. | | `distribs` | List of strings; default is `[]` | -| `experimental_venvs_site_packages` | [Label](/concepts/labels); default is `None` \*\*INTERNAL ATTRIBUTE. SHOULD ONLY BE SET BY rules_python-INTERNAL CODE.\*\* :::{include} /\_includes/experimental_api.md ::: A flag that decides whether the library should treat its sources as a site-packages layout. When the flag is `yes`, then the `srcs` files are treated as a site-packages layout that is relative to the `imports` attribute. The `imports` attribute can have only a single element. It is a repo-relative runfiles path. For example, in the `my/pkg/BUILD.bazel` file, given `srcs=["site-packages/foo/bar.py"]`, specifying `imports=["my/pkg/site-packages"]` means `foo/bar.py` is the file path under the binary's venv site-packages directory that should be made available (i.e. `import foo.bar` will work). `\__init\_\_.py` files are treated specially to provide basic support for [implicit namespace packages]( https://packaging.python.org/en/latest/guides/packaging-namespace-packages/#native-namespace-packages). However, the \*content\* of the files cannot be taken into account, merely their presence or absence. Stated another way: [pkgutil-style namespace packages]( https://packaging.python.org/en/latest/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages) won't be understood as namespace packages; they'll be seen as regular packages. This will likely lead to conflicts with other targets that contribute to the namespace. :::{seealso} This attributes populates {obj}`PyInfo.venv_symlinks`. ::: :::{versionadded} 1.4.0 ::: :::{versionchanged} 1.5.0 The topological order has been removed and if 2 different versions of the same PyPI package are observed, the behaviour has no guarantees except that it is deterministic and that only one package version will be included. ::: | -| `imports` | List of strings; default is `[]` List of import directories to be added to the PYTHONPATH. Subject to "Make variable" substitution. These import directories will be added for this rule and all rules that depend on it (note: not the rules this rule depends on. Each directory will be added to `PYTHONPATH` by `py_binary` rules that depend on this rule. The strings are repo-runfiles-root relative, Absolute paths (paths that start with `/`) and paths that references a path above the execution root are not allowed and will result in an error. | -| `precompile` | String; default is `"inherit"` Whether py source files \*\*for this target\*\* should be precompiled. Values: \* `inherit`: Allow the downstream binary decide if precompiled files are used. \* `enabled`: Compile Python source files at build time. \* `disabled`: Don't compile Python source files at build time. :::{seealso} \* The {flag}`--precompile` flag, which can override this attribute in some cases and will affect all targets when building. \* The {obj}`pyc_collection` attribute for transitively enabling precompiling on a per-target basis. \* The [Precompiling](precompiling) docs for a guide about using precompiling. ::: | -| `precompile_invalidation_mode` | String; default is `"auto"` How precompiled files should be verified to be up-to-date with their associated source files. Possible values are: \* `auto`: The effective value will be automatically determined by other build settings. \* `checked_hash`: Use the pyc file if the hash of the source file matches the hash recorded in the pyc file. This is most useful when working with code that you may modify. \* `unchecked_hash`: Always use the pyc file; don't check the pyc's hash against the source file. This is most useful when the code won't be modified. For more information on pyc invalidation modes, see https://docs.python.org/3/library/py_compile.html#py_compile.PycInvalidationMode | +| `experimental_venvs_site_packages` | [Label](/concepts/labels); default is `None` \*\*INTERNAL ATTRIBUTE. SHOULD ONLY BE SET BY rules\_python-INTERNAL CODE.\*\* :::{include} /\_includes/experimental\_api.md ::: A flag that decides whether the library should treat its sources as a site-packages layout. When the flag is `yes`, then the `srcs` files are treated as a site-packages layout that is relative to the `imports` attribute. The `imports` attribute can have only a single element. It is a repo-relative runfiles path. For example, in the `my/pkg/BUILD.bazel` file, given `srcs=["site-packages/foo/bar.py"]`, specifying `imports=["my/pkg/site-packages"]` means `foo/bar.py` is the file path under the binary's venv site-packages directory that should be made available (i.e. `import foo.bar` will work). `\_\_init\_\_.py` files are treated specially to provide basic support for [implicit namespace packages]( https://packaging.python.org/en/latest/guides/packaging-namespace-packages/#native-namespace-packages). However, the \*content\* of the files cannot be taken into account, merely their presence or absence. Stated another way: [pkgutil-style namespace packages]( https://packaging.python.org/en/latest/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages) won't be understood as namespace packages; they'll be seen as regular packages. This will likely lead to conflicts with other targets that contribute to the namespace. :::{seealso} This attributes populates {obj}`PyInfo.venv\_symlinks`. ::: :::{versionadded} 1.4.0 ::: :::{versionchanged} 1.5.0 The topological order has been removed and if 2 different versions of the same PyPI package are observed, the behaviour has no guarantees except that it is deterministic and that only one package version will be included. ::: | +| `imports` | List of strings; default is `[]` List of import directories to be added to the PYTHONPATH. Subject to "Make variable" substitution. These import directories will be added for this rule and all rules that depend on it (note: not the rules this rule depends on. Each directory will be added to `PYTHONPATH` by `py\_binary` rules that depend on this rule. The strings are repo-runfiles-root relative, Absolute paths (paths that start with `/`) and paths that references a path above the execution root are not allowed and will result in an error. | +| `precompile` | String; default is `"inherit"` Whether py source files \*\*for this target\*\* should be precompiled. Values: \* `inherit`: Allow the downstream binary decide if precompiled files are used. \* `enabled`: Compile Python source files at build time. \* `disabled`: Don't compile Python source files at build time. :::{seealso} \* The {flag}`--precompile` flag, which can override this attribute in some cases and will affect all targets when building. \* The {obj}`pyc\_collection` attribute for transitively enabling precompiling on a per-target basis. \* The [Precompiling](precompiling) docs for a guide about using precompiling. ::: | +| `precompile_invalidation_mode` | String; default is `"auto"` How precompiled files should be verified to be up-to-date with their associated source files. Possible values are: \* `auto`: The effective value will be automatically determined by other build settings. \* `checked\_hash`: Use the pyc file if the hash of the source file matches the hash recorded in the pyc file. This is most useful when working with code that you may modify. \* `unchecked\_hash`: Always use the pyc file; don't check the pyc's hash against the source file. This is most useful when the code won't be modified. For more information on pyc invalidation modes, see https://docs.python.org/3/library/py\_compile.html#py\_compile.PycInvalidationMode | | `precompile_optimize_level` | Integer; default is `0` The optimization level for precompiled files. For more information about optimization levels, see the `compile()` function's `optimize` arg docs at https://docs.python.org/3/library/functions.html#compile NOTE: The value `-1` means "current interpreter", which will be the interpreter used \_at build time when pycs are generated\_, not the interpreter used at runtime when the code actually runs. | -| `precompile_source_retention` | String; default is `"inherit"` Determines, when a source file is compiled, if the source file is kept in the resulting output or not. Valid values are: \* `inherit`: Inherit the value from the {flag}`--precompile_source_retention` flag. \* `keep_source`: Include the original Python source. \* `omit_source`: Don't include the original py source. | -| `pyi_deps` | List of [labels](/concepts/labels); default is `[]` Dependencies providing type definitions the library needs. These are dependencies that satisfy imports guarded by `typing.TYPE_CHECKING`. These are build-time only dependencies and not included as part of a runnable program (packaging rules may include them, however). :::{versionadded} 1.1.0 ::: | -| `pyi_srcs` | List of [labels](/concepts/labels); default is `[]` Type definition files for the library. These are typically `.pyi` files, but other file types for type-checker specific formats are allowed. These files are build-time only dependencies and not included as part of a runnable program (packaging rules may include them, however). :::{versionadded} 1.1.0 ::: | +| `precompile_source_retention` | String; default is `"inherit"` Determines, when a source file is compiled, if the source file is kept in the resulting output or not. Valid values are: \* `inherit`: Inherit the value from the {flag}`--precompile\_source\_retention` flag. \* `keep\_source`: Include the original Python source. \* `omit\_source`: Don't include the original py source. | +| `pyi_deps` | List of [labels](/concepts/labels); default is `[]` Dependencies providing type definitions the library needs. These are dependencies that satisfy imports guarded by `typing.TYPE\_CHECKING`. These are build-time only dependencies and not included as part of a runnable program (packaging rules may include them, however). :::{versionadded} 1.1.0 ::: | +| `pyi_srcs` | List of [labels](/concepts/labels); default is `[]` Type definition files for the library. These are typically `.pyi` files, but other file types for type-checker specific formats are allowed. These files are build-time only dependencies and not included as part of a runnable program (packaging rules may include them, however). :::{versionadded} 1.1.0 ::: | | `srcs_version` | String; default is `""` Defunct, unused, does nothing. | -## py_test +## py\_test -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_python/tree/0.40.0/python/private/py_test_rule.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_python/tree/0.40.0/python/private/py_test_rule.bzl) ``` py_test(name, deps, srcs, data, args, aspect_hints, compatible_with, config_settings, deprecation, distribs, env, env_inherit, exec_compatible_with, exec_group_compatible_with, exec_properties, features, flaky, imports, interpreter_args, legacy_create_init, licenses, local, main, main_module, package_metadata, precompile, precompile_invalidation_mode, precompile_optimize_level, precompile_source_retention, pyc_collection, pyi_deps, pyi_srcs, python_version, restricted_to, shard_count, size, srcs_version, stamp, tags, target_compatible_with, testonly, timeout, toolchains, visibility) @@ -94,37 +94,37 @@ py_test(name, deps, srcs, data, args, aspect_hints, compatible_with, config_sett | Attributes | | | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | -| `deps` | List of [labels](/concepts/labels); default is `[]` List of additional libraries to be linked in to the target. See comments about the [`deps` attribute typically defined by rules](https://bazel.build/reference/be/common-definitions#typical-attributes). These are typically `py_library` rules. Targets that only provide data files used at runtime belong in the `data` attribute. :::{note} The order of this list can matter because it affects the order that information from dependencies is merged in, which can be relevant depending on the ordering mode of depsets that are merged. \* {obj}`PyInfo.venv_symlinks` uses default ordering. See {obj}`PyInfo` for more information about the ordering of its depsets and how its fields are merged. ::: | +| `deps` | List of [labels](/concepts/labels); default is `[]` List of additional libraries to be linked in to the target. See comments about the [`deps` attribute typically defined by rules](https://bazel.build/reference/be/common-definitions#typical-attributes). These are typically `py\_library` rules. Targets that only provide data files used at runtime belong in the `data` attribute. :::{note} The order of this list can matter because it affects the order that information from dependencies is merged in, which can be relevant depending on the ordering mode of depsets that are merged. \* {obj}`PyInfo.venv\_symlinks` uses default ordering. See {obj}`PyInfo` for more information about the ordering of its depsets and how its fields are merged. ::: | | `srcs` | List of [labels](/concepts/labels); default is `[]` The list of Python source files that are processed to create the target. This includes all your checked-in code and may include generated source files. The `.py` files belong in `srcs` and library targets belong in `deps`. Other binary files that may be needed at run time belong in `data`. | -| `data` | List of [labels](/concepts/labels); default is `[]` The list of files need by this library at runtime. See comments about the [`data` attribute typically defined by rules](https://bazel.build/reference/be/common-definitions#typical-attributes). There is no `py_embed_data` like there is `cc_embed_data` and `go_embed_data`. This is because Python has a concept of runtime resources. | -| `config_settings` | Dictionary: [label](/concepts/labels) -> String; default is `{}` Config settings to change for this target. The keys are labels for settings, and the values are strings for the new value to use. Pass `Label` objects or canonical label strings for the keys to ensure they resolve as expected (canonical labels start with `@@` and can be obtained by calling `str(Label(...))`). Most `@rules_python//python/config_setting` settings can be used here, which allows, for example, making only a certain `py_binary` use {obj}`--boostrap_impl=script`. Additional or custom config settings can be registered using the {obj}`add_transition_setting` API. This allows, for example, forcing a particular CPU, or defining a custom setting that `select()` uses elsewhere to pick between `pip.parse` hubs. See the [How to guide on multiple versions of a library] for a more concrete example. :::{note} These values are transitioned on, so will affect the analysis graph and the associated memory overhead. The more unique configurations in your overall build, the more memory and (often unnecessary) re-analysis and re-building can occur. See https://bazel.build/extending/config#memory-performance-considerations for more information about risks and considerations. ::: :::{versionadded} 1.7.0 ::: | +| `data` | List of [labels](/concepts/labels); default is `[]` The list of files need by this library at runtime. See comments about the [`data` attribute typically defined by rules](https://bazel.build/reference/be/common-definitions#typical-attributes). There is no `py\_embed\_data` like there is `cc\_embed\_data` and `go\_embed\_data`. This is because Python has a concept of runtime resources. | +| `config_settings` | Dictionary: [label](/concepts/labels) -> String; default is `{}` Config settings to change for this target. The keys are labels for settings, and the values are strings for the new value to use. Pass `Label` objects or canonical label strings for the keys to ensure they resolve as expected (canonical labels start with `@@` and can be obtained by calling `str(Label(...))`). Most `@rules\_python//python/config\_setting` settings can be used here, which allows, for example, making only a certain `py\_binary` use {obj}`--boostrap\_impl=script`. Additional or custom config settings can be registered using the {obj}`add\_transition\_setting` API. This allows, for example, forcing a particular CPU, or defining a custom setting that `select()` uses elsewhere to pick between `pip.parse` hubs. See the [How to guide on multiple versions of a library] for a more concrete example. :::{note} These values are transitioned on, so will affect the analysis graph and the associated memory overhead. The more unique configurations in your overall build, the more memory and (often unnecessary) re-analysis and re-building can occur. See https://bazel.build/extending/config#memory-performance-considerations for more information about risks and considerations. ::: :::{versionadded} 1.7.0 ::: | | `distribs` | List of strings; default is `[]` | -| `imports` | List of strings; default is `[]` List of import directories to be added to the PYTHONPATH. Subject to "Make variable" substitution. These import directories will be added for this rule and all rules that depend on it (note: not the rules this rule depends on. Each directory will be added to `PYTHONPATH` by `py_binary` rules that depend on this rule. The strings are repo-runfiles-root relative, Absolute paths (paths that start with `/`) and paths that references a path above the execution root are not allowed and will result in an error. | -| `interpreter_args` | List of strings; default is `[]` Arguments that are only applicable to the interpreter. The args an interpreter supports are specific to the interpreter. For CPython, see https://docs.python.org/3/using/cmdline.html. :::{note} Only supported for {obj}`--bootstrap_impl=script`. Ignored otherwise. ::: :::{seealso} The {any}`RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS` environment variable ::: :::{versionadded} 1.3.0 ::: | -| `legacy_create_init` | Integer; default is `-1` Whether to implicitly create empty `\__init\_\_.py` files in the runfiles tree. These are created in every directory containing Python source code or shared libraries, and every parent directory of those directories, excluding the repo root directory. The default, `-1` (auto), means true unless `--incompatible_default_to_explicit_init_py` is used. If false, the user is responsible for creating (possibly empty) `\__init\_\_.py` files and adding them to the `srcs` of Python targets as required. | -| `main` | [Label](/concepts/labels); default is `None` Optional; the name of the source file that is the main entry point of the application. This file must also be listed in `srcs`. If left unspecified, `name`, with `.py` appended, is used instead. If `name` does not match any filename in `srcs`, `main` must be specified. This is mutually exclusive with {obj}`main_module`. | -| `main_module` | String; default is `""` Module name to execute as the main program. When set, `srcs` is not required, and it is assumed the module is provided by a dependency. See https://docs.python.org/3/using/cmdline.html#cmdoption-m for more information about running modules as the main program. This is mutually exclusive with {obj}`main`. :::{versionadded} 1.3.0 ::: :::{versionchanged} 1.7.0 Support added for {obj}`--bootstrap_impl=system_python`. ::: | -| `precompile` | String; default is `"inherit"` Whether py source files \*\*for this target\*\* should be precompiled. Values: \* `inherit`: Allow the downstream binary decide if precompiled files are used. \* `enabled`: Compile Python source files at build time. \* `disabled`: Don't compile Python source files at build time. :::{seealso} \* The {flag}`--precompile` flag, which can override this attribute in some cases and will affect all targets when building. \* The {obj}`pyc_collection` attribute for transitively enabling precompiling on a per-target basis. \* The [Precompiling](precompiling) docs for a guide about using precompiling. ::: | -| `precompile_invalidation_mode` | String; default is `"auto"` How precompiled files should be verified to be up-to-date with their associated source files. Possible values are: \* `auto`: The effective value will be automatically determined by other build settings. \* `checked_hash`: Use the pyc file if the hash of the source file matches the hash recorded in the pyc file. This is most useful when working with code that you may modify. \* `unchecked_hash`: Always use the pyc file; don't check the pyc's hash against the source file. This is most useful when the code won't be modified. For more information on pyc invalidation modes, see https://docs.python.org/3/library/py_compile.html#py_compile.PycInvalidationMode | +| `imports` | List of strings; default is `[]` List of import directories to be added to the PYTHONPATH. Subject to "Make variable" substitution. These import directories will be added for this rule and all rules that depend on it (note: not the rules this rule depends on. Each directory will be added to `PYTHONPATH` by `py\_binary` rules that depend on this rule. The strings are repo-runfiles-root relative, Absolute paths (paths that start with `/`) and paths that references a path above the execution root are not allowed and will result in an error. | +| `interpreter_args` | List of strings; default is `[]` Arguments that are only applicable to the interpreter. The args an interpreter supports are specific to the interpreter. For CPython, see https://docs.python.org/3/using/cmdline.html. :::{note} Only supported for {obj}`--bootstrap\_impl=script`. Ignored otherwise. ::: :::{seealso} The {any}`RULES\_PYTHON\_ADDITIONAL\_INTERPRETER\_ARGS` environment variable ::: :::{versionadded} 1.3.0 ::: | +| `legacy_create_init` | Integer; default is `-1` Whether to implicitly create empty `\_\_init\_\_.py` files in the runfiles tree. These are created in every directory containing Python source code or shared libraries, and every parent directory of those directories, excluding the repo root directory. The default, `-1` (auto), means true unless `--incompatible\_default\_to\_explicit\_init\_py` is used. If false, the user is responsible for creating (possibly empty) `\_\_init\_\_.py` files and adding them to the `srcs` of Python targets as required. | +| `main` | [Label](/concepts/labels); default is `None` Optional; the name of the source file that is the main entry point of the application. This file must also be listed in `srcs`. If left unspecified, `name`, with `.py` appended, is used instead. If `name` does not match any filename in `srcs`, `main` must be specified. This is mutually exclusive with {obj}`main\_module`. | +| `main_module` | String; default is `""` Module name to execute as the main program. When set, `srcs` is not required, and it is assumed the module is provided by a dependency. See https://docs.python.org/3/using/cmdline.html#cmdoption-m for more information about running modules as the main program. This is mutually exclusive with {obj}`main`. :::{versionadded} 1.3.0 ::: :::{versionchanged} 1.7.0 Support added for {obj}`--bootstrap\_impl=system\_python`. ::: | +| `precompile` | String; default is `"inherit"` Whether py source files \*\*for this target\*\* should be precompiled. Values: \* `inherit`: Allow the downstream binary decide if precompiled files are used. \* `enabled`: Compile Python source files at build time. \* `disabled`: Don't compile Python source files at build time. :::{seealso} \* The {flag}`--precompile` flag, which can override this attribute in some cases and will affect all targets when building. \* The {obj}`pyc\_collection` attribute for transitively enabling precompiling on a per-target basis. \* The [Precompiling](precompiling) docs for a guide about using precompiling. ::: | +| `precompile_invalidation_mode` | String; default is `"auto"` How precompiled files should be verified to be up-to-date with their associated source files. Possible values are: \* `auto`: The effective value will be automatically determined by other build settings. \* `checked\_hash`: Use the pyc file if the hash of the source file matches the hash recorded in the pyc file. This is most useful when working with code that you may modify. \* `unchecked\_hash`: Always use the pyc file; don't check the pyc's hash against the source file. This is most useful when the code won't be modified. For more information on pyc invalidation modes, see https://docs.python.org/3/library/py\_compile.html#py\_compile.PycInvalidationMode | | `precompile_optimize_level` | Integer; default is `0` The optimization level for precompiled files. For more information about optimization levels, see the `compile()` function's `optimize` arg docs at https://docs.python.org/3/library/functions.html#compile NOTE: The value `-1` means "current interpreter", which will be the interpreter used \_at build time when pycs are generated\_, not the interpreter used at runtime when the code actually runs. | -| `precompile_source_retention` | String; default is `"inherit"` Determines, when a source file is compiled, if the source file is kept in the resulting output or not. Valid values are: \* `inherit`: Inherit the value from the {flag}`--precompile_source_retention` flag. \* `keep_source`: Include the original Python source. \* `omit_source`: Don't include the original py source. | -| `pyc_collection` | String; default is `"inherit"` Determines whether pyc files from dependencies should be manually included. Valid values are: \* `inherit`: Inherit the value from {flag}`--precompile`. \* `include_pyc`: Add implicitly generated pyc files from dependencies. i.e. pyc files for targets that specify {attr}`precompile="inherit"`. \* `disabled`: Don't add implicitly generated pyc files. Note that pyc files may still come from dependencies that enable precompiling at the target level. | -| `pyi_deps` | List of [labels](/concepts/labels); default is `[]` Dependencies providing type definitions the library needs. These are dependencies that satisfy imports guarded by `typing.TYPE_CHECKING`. These are build-time only dependencies and not included as part of a runnable program (packaging rules may include them, however). :::{versionadded} 1.1.0 ::: | -| `pyi_srcs` | List of [labels](/concepts/labels); default is `[]` Type definition files for the library. These are typically `.pyi` files, but other file types for type-checker specific formats are allowed. These files are build-time only dependencies and not included as part of a runnable program (packaging rules may include them, however). :::{versionadded} 1.1.0 ::: | -| `python_version` | String; default is `""` The Python version this target should use. The value should be in `X.Y` or `X.Y.Z` (or compatible) format. If empty or unspecified, the incoming configuration's {obj}`--python_version` flag is inherited. For backwards compatibility, the values `PY2` and `PY3` are accepted, but treated as an empty/unspecified value. :::{note} In order for the requested version to be used, there must be a toolchain configured to match the Python version. If there isn't, then it may be silently ignored, or an error may occur, depending on the toolchain configuration. ::: :::{versionchanged} 1.1.0 This attribute was changed from only accepting `PY2` and `PY3` values to accepting arbitrary Python versions. ::: | +| `precompile_source_retention` | String; default is `"inherit"` Determines, when a source file is compiled, if the source file is kept in the resulting output or not. Valid values are: \* `inherit`: Inherit the value from the {flag}`--precompile\_source\_retention` flag. \* `keep\_source`: Include the original Python source. \* `omit\_source`: Don't include the original py source. | +| `pyc_collection` | String; default is `"inherit"` Determines whether pyc files from dependencies should be manually included. Valid values are: \* `inherit`: Inherit the value from {flag}`--precompile`. \* `include\_pyc`: Add implicitly generated pyc files from dependencies. i.e. pyc files for targets that specify {attr}`precompile="inherit"`. \* `disabled`: Don't add implicitly generated pyc files. Note that pyc files may still come from dependencies that enable precompiling at the target level. | +| `pyi_deps` | List of [labels](/concepts/labels); default is `[]` Dependencies providing type definitions the library needs. These are dependencies that satisfy imports guarded by `typing.TYPE\_CHECKING`. These are build-time only dependencies and not included as part of a runnable program (packaging rules may include them, however). :::{versionadded} 1.1.0 ::: | +| `pyi_srcs` | List of [labels](/concepts/labels); default is `[]` Type definition files for the library. These are typically `.pyi` files, but other file types for type-checker specific formats are allowed. These files are build-time only dependencies and not included as part of a runnable program (packaging rules may include them, however). :::{versionadded} 1.1.0 ::: | +| `python_version` | String; default is `""` The Python version this target should use. The value should be in `X.Y` or `X.Y.Z` (or compatible) format. If empty or unspecified, the incoming configuration's {obj}`--python\_version` flag is inherited. For backwards compatibility, the values `PY2` and `PY3` are accepted, but treated as an empty/unspecified value. :::{note} In order for the requested version to be used, there must be a toolchain configured to match the Python version. If there isn't, then it may be silently ignored, or an error may occur, depending on the toolchain configuration. ::: :::{versionchanged} 1.1.0 This attribute was changed from only accepting `PY2` and `PY3` values to accepting arbitrary Python versions. ::: | | `srcs_version` | String; default is `""` Defunct, unused, does nothing. | | `stamp` | Integer; default is `0` Whether to encode build information into the binary. Possible values: \* `stamp = 1`: Always stamp the build information into the binary, even in `--nostamp` builds. \*\*This setting should be avoided\*\*, since it potentially kills remote caching for the binary and any downstream actions that depend on it. \* `stamp = 0`: Always replace build information by constant values. This gives good build result caching. \* `stamp = -1`: Embedding of build information is controlled by the `--[no]stamp` flag. Stamped binaries are not rebuilt unless their dependencies change. WARNING: Stamping can harm build performance by reducing cache hits and should be avoided if possible. | -## py_runtime +## py\_runtime -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_python/tree/0.40.0/python/private/py_runtime_rule.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_python/tree/0.40.0/python/private/py_runtime_rule.bzl) ``` py_runtime(name, abi_flags, aspect_hints, bootstrap_template, compatible_with, coverage_tool, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, files, implementation_name, interpreter, interpreter_path, interpreter_version_info, package_metadata, pyc_tag, python_version, restricted_to, site_init_template, stage2_bootstrap_template, stub_shebang, supports_build_time_venv, tags, target_compatible_with, testonly, toolchains, visibility, zip_main_template) ``` Represents a Python runtime used to execute Python code. -A `py_runtime` target can represent either a \*platform runtime\* or an \*in-build +A `py\_runtime` target can represent either a \*platform runtime\* or an \*in-build runtime\*. A platform runtime accesses a system-installed interpreter at a known path, whereas an in-build runtime points to an executable target that acts as the interpreter. In both cases, an "interpreter" means any executable binary or @@ -137,15 +137,15 @@ a checked-in interpreter or a wrapper script that accesses the system interpreter. Example ``` -load("@rules_python//python:py_runtime.bzl", "py_runtime") -py_runtime( +load("@rules\_python//python:py\_runtime.bzl", "py\_runtime") +py\_runtime( name = "python-2.7.12", files = glob(["python-2.7.12/\*\*"]), interpreter = "python-2.7.12/bin/python", ) -py_runtime( +py\_runtime( name = "python-3.6.0", -interpreter_path = "/opt/pyenv/versions/3.6.0/bin/python", +interpreter\_path = "/opt/pyenv/versions/3.6.0/bin/python", ) ``` @@ -155,17 +155,17 @@ interpreter_path = "/opt/pyenv/versions/3.6.0/bin/python", | --- | --- | | `name` | [Name](/concepts/labels#target-names); required A unique name for this target. | | `abi_flags` | String; default is `""` The runtime's ABI flags, i.e. `sys.abiflags`. If not set, then it will be set based on flags. | -| `bootstrap_template` | [Label](/concepts/labels); default is `"@rules_python//python/private:bootstrap_template"` The bootstrap script template file to use. Should have %python_binary%, %workspace_name%, %main%, and %imports%. This template, after expansion, becomes the executable file used to start the process, so it is responsible for initial bootstrapping actions such as finding the Python interpreter, runfiles, and constructing an environment to run the intended Python application. While this attribute is currently optional, it will become required when the Python rules are moved out of Bazel itself. The exact variable names expanded is an unstable API and is subject to change. The API will become more stable when the Python rules are moved out of Bazel itself. See @bazel_tools//tools/python:python_bootstrap_template.txt for more variables. | -| `coverage_tool` | [Label](/concepts/labels); default is `None` This is a target to use for collecting code coverage information from {rule}`py_binary` and {rule}`py_test` targets. If set, the target must either produce a single file or be an executable target. The path to the single file, or the executable if the target is executable, determines the entry point for the python coverage tool. The target and its runfiles will be added to the runfiles when coverage is enabled. The entry point for the tool must be loadable by a Python interpreter (e.g. a `.py` or `.pyc` file). It must accept the command line arguments of [`coverage.py`](https://coverage.readthedocs.io), at least including the `run` and `lcov` subcommands. | +| `bootstrap_template` | [Label](/concepts/labels); default is `"@rules_python//python/private:bootstrap_template"` The bootstrap script template file to use. Should have %python\_binary%, %workspace\_name%, %main%, and %imports%. This template, after expansion, becomes the executable file used to start the process, so it is responsible for initial bootstrapping actions such as finding the Python interpreter, runfiles, and constructing an environment to run the intended Python application. While this attribute is currently optional, it will become required when the Python rules are moved out of Bazel itself. The exact variable names expanded is an unstable API and is subject to change. The API will become more stable when the Python rules are moved out of Bazel itself. See @bazel\_tools//tools/python:python\_bootstrap\_template.txt for more variables. | +| `coverage_tool` | [Label](/concepts/labels); default is `None` This is a target to use for collecting code coverage information from {rule}`py\_binary` and {rule}`py\_test` targets. If set, the target must either produce a single file or be an executable target. The path to the single file, or the executable if the target is executable, determines the entry point for the python coverage tool. The target and its runfiles will be added to the runfiles when coverage is enabled. The entry point for the tool must be loadable by a Python interpreter (e.g. a `.py` or `.pyc` file). It must accept the command line arguments of [`coverage.py`](https://coverage.readthedocs.io), at least including the `run` and `lcov` subcommands. | | `files` | List of [labels](/concepts/labels); default is `[]` For an in-build runtime, this is the set of files comprising this runtime. These files will be added to the runfiles of Python binaries that use this runtime. For a platform runtime this attribute must not be set. | | `implementation_name` | String; default is `"cpython"` The Python implementation name (`sys.implementation.name`) | -| `interpreter` | [Label](/concepts/labels); default is `None` For an in-build runtime, this is the target to invoke as the interpreter. It can be either of: \* A single file, which will be the interpreter binary. It's assumed such interpreters are either self-contained single-file executables or any supporting files are specified in `files`. \* An executable target. The target's executable will be the interpreter binary. Any other default outputs (`target.files`) and plain files runfiles (`runfiles.files`) will be automatically included as if specified in the `files` attribute. NOTE: the runfiles of the target may not yet be properly respected/propagated to consumers of the toolchain/interpreter, see bazel-contrib/rules_python/issues/1612 For a platform runtime (i.e. `interpreter_path` being set) this attribute must not be set. | +| `interpreter` | [Label](/concepts/labels); default is `None` For an in-build runtime, this is the target to invoke as the interpreter. It can be either of: \* A single file, which will be the interpreter binary. It's assumed such interpreters are either self-contained single-file executables or any supporting files are specified in `files`. \* An executable target. The target's executable will be the interpreter binary. Any other default outputs (`target.files`) and plain files runfiles (`runfiles.files`) will be automatically included as if specified in the `files` attribute. NOTE: the runfiles of the target may not yet be properly respected/propagated to consumers of the toolchain/interpreter, see bazel-contrib/rules\_python/issues/1612 For a platform runtime (i.e. `interpreter\_path` being set) this attribute must not be set. | | `interpreter_path` | String; default is `""` For a platform runtime, this is the absolute path of a Python interpreter on the target platform. For an in-build runtime this attribute must not be set. | -| `interpreter_version_info` | Dictionary: String -> String; default is `{}` Version information about the interpreter this runtime provides. If not specified, uses {obj}`--python_version` The supported keys match the names for `sys.version_info`. While the input values are strings, most are converted to ints. The supported keys are: \* major: int, the major version number \* minor: int, the minor version number \* micro: optional int, the micro version number \* releaselevel: optional str, the release level \* serial: optional int, the serial number of the release :::{versionchanged} 0.36.0 {obj}`--python_version` determines the default value. ::: | -| `pyc_tag` | String; default is `""` Optional string; the tag portion of a pyc filename, e.g. the `cpython-39` infix of `foo.cpython-39.pyc`. See PEP 3147. If not specified, it will be computed from `implementation_name` and `interpreter_version_info`. If no pyc_tag is available, then only source-less pyc generation will function correctly. | -| `python_version` | String; default is `"PY3"` Whether this runtime is for Python major version 2 or 3. Valid values are `"PY2"` and `"PY3"`. The default value is controlled by the `--incompatible_py3_is_default` flag. However, in the future this attribute will be mandatory and have no default value. | -| `site_init_template` | [Label](/concepts/labels); default is `"@rules_python//python/private:site_init_template"` The template to use for the binary-specific site-init hook run by the interpreter at startup. :::{versionadded} 0.41.0 ::: | -| `stage2_bootstrap_template` | [Label](/concepts/labels); default is `"@rules_python//python/private:stage2_bootstrap_template"` The template to use when two stage bootstrapping is enabled :::{seealso} {obj}`PyRuntimeInfo.stage2_bootstrap_template` and {obj}`--bootstrap_impl` ::: | -| `stub_shebang` | String; default is `"#!/usr/bin/env python3"` "Shebang" expression prepended to the bootstrapping Python stub script used when executing {rule}`py_binary` targets. See https://github.com/bazelbuild/bazel/issues/8685 for motivation. Does not apply to Windows. | -| `supports_build_time_venv` | Boolean; default is `True` Whether this runtime supports virtualenvs created at build time. See {obj}`PyRuntimeInfo.supports_build_time_venv` for docs. :::{versionadded} 1.5.0 ::: | -| `zip_main_template` | [Label](/concepts/labels); default is `"@rules_python//python/private:zip_main_template"` The template to use for a zip's top-level `\__main\_\_.py` file. This becomes the entry point executed when `python foo.zip` is run. :::{seealso} The {obj}`PyRuntimeInfo.zip_main_template` field. ::: | \ No newline at end of file +| `interpreter_version_info` | Dictionary: String -> String; default is `{}` Version information about the interpreter this runtime provides. If not specified, uses {obj}`--python\_version` The supported keys match the names for `sys.version\_info`. While the input values are strings, most are converted to ints. The supported keys are: \* major: int, the major version number \* minor: int, the minor version number \* micro: optional int, the micro version number \* releaselevel: optional str, the release level \* serial: optional int, the serial number of the release :::{versionchanged} 0.36.0 {obj}`--python\_version` determines the default value. ::: | +| `pyc_tag` | String; default is `""` Optional string; the tag portion of a pyc filename, e.g. the `cpython-39` infix of `foo.cpython-39.pyc`. See PEP 3147. If not specified, it will be computed from `implementation\_name` and `interpreter\_version\_info`. If no pyc\_tag is available, then only source-less pyc generation will function correctly. | +| `python_version` | String; default is `"PY3"` Whether this runtime is for Python major version 2 or 3. Valid values are `"PY2"` and `"PY3"`. The default value is controlled by the `--incompatible\_py3\_is\_default` flag. However, in the future this attribute will be mandatory and have no default value. | +| `site_init_template` | [Label](/concepts/labels); default is `"@rules_python//python/private:site_init_template"` The template to use for the binary-specific site-init hook run by the interpreter at startup. :::{versionadded} 0.41.0 ::: | +| `stage2_bootstrap_template` | [Label](/concepts/labels); default is `"@rules_python//python/private:stage2_bootstrap_template"` The template to use when two stage bootstrapping is enabled :::{seealso} {obj}`PyRuntimeInfo.stage2\_bootstrap\_template` and {obj}`--bootstrap\_impl` ::: | +| `stub_shebang` | String; default is `"#!/usr/bin/env python3"` "Shebang" expression prepended to the bootstrapping Python stub script used when executing {rule}`py\_binary` targets. See https://github.com/bazelbuild/bazel/issues/8685 for motivation. Does not apply to Windows. | +| `supports_build_time_venv` | Boolean; default is `True` Whether this runtime supports virtualenvs created at build time. See {obj}`PyRuntimeInfo.supports\_build\_time\_venv` for docs. :::{versionadded} 1.5.0 ::: | +| `zip_main_template` | [Label](/concepts/labels); default is `"@rules_python//python/private:zip_main_template"` The template to use for a zip's top-level `\_\_main\_\_.py` file. This becomes the entry point executed when `python foo.zip` is run. :::{seealso} The {obj}`PyRuntimeInfo.zip\_main\_template` field. ::: | \ No newline at end of file diff --git a/reference/be/shell.mdx b/reference/be/shell.mdx index 4545d8fc..177f78de 100644 --- a/reference/be/shell.mdx +++ b/reference/be/shell.mdx @@ -4,13 +4,13 @@ title: 'Shell Rules' ## Rules -* [sh_binary](#sh_binary) -* [sh_library](#sh_library) -* [sh_test](#sh_test) +* [sh\_binary](#sh_binary) +* [sh\_library](#sh_library) +* [sh\_test](#sh_test) -## sh_binary +## sh\_binary -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_shell/tree/v0.2.0/shell/private/sh_binary.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_shell/tree/v0.2.0/shell/private/sh_binary.bzl) ``` sh_binary(name, deps, srcs, data, args, aspect_hints, compatible_with, deprecation, env, env_inherit, exec_compatible_with, exec_group_compatible_with, exec_properties, features, output_licenses, package_metadata, restricted_to, tags, target_compatible_with, testonly, toolchains, use_bash_launcher, visibility) @@ -46,9 +46,9 @@ sh_binary( | `env_inherit` | List of strings; default is `[]` | | `use_bash_launcher` | Boolean; default is `False` Use a bash launcher initializing the runfiles library | -## sh_library +## sh\_library -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_shell/tree/v0.2.0/shell/private/sh_library.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_shell/tree/v0.2.0/shell/private/sh_library.bzl) ``` sh_library(name, deps, srcs, data, aspect_hints, compatible_with, deprecation, exec_compatible_with, exec_group_compatible_with, exec_properties, features, package_metadata, restricted_to, tags, target_compatible_with, testonly, toolchains, visibility) @@ -94,9 +94,9 @@ sh_library( | `deps` | List of [labels](/concepts/labels); default is `[]` The list of "library" targets to be aggregated into this target. See general comments about `deps` at [Typical attributes defined by most build rules](/reference/be/common-definitions#typical.deps). This attribute should be used to list other `sh_library` rules that provide interpreted program source code depended on by the code in `srcs`. The files provided by these rules will be present among the `runfiles` of this target. | | `srcs` | List of [labels](/concepts/labels); default is `[]` The list of input files. This attribute should be used to list shell script source files that belong to this library. Scripts can load other scripts using the shell's `source` or `.` command. | -## sh_test +## sh\_test -[View rule sourceopen_in_new](https://github.com/bazelbuild/rules_shell/tree/v0.2.0/shell/private/sh_test.bzl) +[View rule sourceopen\_in\_new](https://github.com/bazelbuild/rules_shell/tree/v0.2.0/shell/private/sh_test.bzl) ``` sh_test(name, deps, srcs, data, args, aspect_hints, compatible_with, deprecation, env, env_inherit, exec_compatible_with, exec_group_compatible_with, exec_properties, features, flaky, local, package_metadata, restricted_to, shard_count, size, tags, target_compatible_with, testonly, timeout, toolchains, use_bash_launcher, visibility) diff --git a/reference/command-line-reference.mdx b/reference/command-line-reference.mdx index 0f00cb9d..fcfaba0d 100644 --- a/reference/command-line-reference.mdx +++ b/reference/command-line-reference.mdx @@ -82,7 +82,7 @@ or force-disabled as follows: | [`run`](#run) | Runs the specified target. | | [`shutdown`](#shutdown) | Stops the bazel server. | | [`test`](#test) | Builds and runs the specified test targets. | -| [`vendor`](#vendor) | Fetches external repositories into a folder specified by the flag --vendor_dir. | +| [`vendor`](#vendor) | Fetches external repositories into a folder specified by the flag --vendor\_dir. | | [`version`](#version) | Prints version information for bazel. | ## Startup Options @@ -90,7 +90,7 @@ or force-disabled as follows: Options that appear before the command and are parsed by the client: `--[no]autodetect_server_javabase` default: "true" -: When --noautodetect_server_javabase is passed, Bazel does not fall back to the local JDK for running the bazel server and instead exits. +: When --noautodetect\_server\_javabase is passed, Bazel does not fall back to the local JDK for running the bazel server and instead exits. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -102,7 +102,7 @@ Options that appear before the command and are parsed by the client: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`bazel_internal_configuration`](#effect_tag_BAZEL_INTERNAL_CONFIGURATION), [`deprecated`](#metadata_tag_DEPRECATED) `--[no]batch_cpu_scheduling` default: "false" -: Only on Linux; use 'batch' CPU scheduling for Blaze. This policy is useful for workloads that are non-interactive, but do not want to lower their nice value. See 'man 2 sched_setscheduler'. If false, then Bazel does not perform a system call. +: Only on Linux; use 'batch' CPU scheduling for Blaze. This policy is useful for workloads that are non-interactive, but do not want to lower their nice value. See 'man 2 sched\_setscheduler'. If false, then Bazel does not perform a system call. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) @@ -127,7 +127,7 @@ Options that appear before the command and are parsed by the client: [`changes_inputs`](#effect_tag_CHANGES_INPUTS) `--[no]block_for_lock` default: "true" -: When --noblock_for_lock is passed, Bazel does not wait for a running command to complete, but instead exits immediately. +: When --noblock\_for\_lock is passed, Bazel does not wait for a running command to complete, but instead exits immediately. Tags: [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT) @@ -169,7 +169,7 @@ Options that appear before the command and are parsed by the client: [`bazel_internal_configuration`](#effect_tag_BAZEL_INTERNAL_CONFIGURATION) `--failure_detail_out=` default: see description -: If set, specifies a location to write a failure_detail protobuf message if the server experiences a failure and cannot report it via gRPC, as normal. Otherwise, the location will be ${OUTPUT_BASE}/failure_detail.rawproto. +: If set, specifies a location to write a failure\_detail protobuf message if the server experiences a failure and cannot report it via gRPC, as normal. Otherwise, the location will be ${OUTPUT\_BASE}/failure\_detail.rawproto. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -193,7 +193,7 @@ Options that appear before the command and are parsed by the client: [`changes_inputs`](#effect_tag_CHANGES_INPUTS) `--io_nice_level={-1,0,1,2,3,4,5,6,7}` default: "-1" -: Only on Linux; set a level from 0-7 for best-effort IO scheduling using the sys_ioprio_set system call. 0 is highest priority, 7 is lowest. The anticipatory scheduler may only honor up to priority 4. If set to a negative value, then Bazel does not perform a system call. +: Only on Linux; set a level from 0-7 for best-effort IO scheduling using the sys\_ioprio\_set system call. 0 is highest priority, 7 is lowest. The anticipatory scheduler may only honor up to priority 4. If set to a negative value, then Bazel does not perform a system call. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) @@ -217,7 +217,7 @@ Options that appear before the command and are parsed by the client: [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--output_base=` default: see description -: If set, specifies the output location to which all build output will be written. Otherwise, the location will be ${OUTPUT_ROOT}/*blaze*${USER}/${MD5_OF_WORKSPACE_ROOT}. Note: If you specify a different option from one to the next Bazel invocation for this value, you'll likely start up a new, additional Bazel server. Bazel starts exactly one server per specified output base. Typically there is one output base per workspace - however, with this option you may have multiple output bases per workspace and thereby run multiple builds for the same client on the same machine concurrently. See 'bazel help shutdown' on how to shutdown a Bazel server. +: If set, specifies the output location to which all build output will be written. Otherwise, the location will be ${OUTPUT\_ROOT}/*blaze*${USER}/${MD5\_OF\_WORKSPACE\_ROOT}. Note: If you specify a different option from one to the next Bazel invocation for this value, you'll likely start up a new, additional Bazel server. Bazel starts exactly one server per specified output base. Typically there is one output base per workspace - however, with this option you may have multiple output bases per workspace and thereby run multiple builds for the same client on the same machine concurrently. See 'bazel help shutdown' on how to shutdown a Bazel server. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -241,13 +241,13 @@ Options that appear before the command and are parsed by the client: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`bazel_monitoring`](#effect_tag_BAZEL_MONITORING) `--server_jvm_out=` default: see description -: The location to write the server's JVM's output. If unset then defaults to a location in output_base. +: The location to write the server's JVM's output. If unset then defaults to a location in output\_base. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--[no]shutdown_on_low_sys_mem` default: "false" -: If max_idle_secs is set and the build server has been idle for a while, shut down the server when the system is low on free RAM. Linux and MacOS only. +: If max\_idle\_secs is set and the build server has been idle for a while, shut down the server when the system is low on free RAM. Linux and MacOS only. Tags: [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -410,13 +410,13 @@ Options that control build execution: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--gc_churning_threshold_if_multiple_top_level_targets=` default: "-1" -: If set to a value in [0, 100] and this is a command that takes top-level targets (e.g. build but not query) and there are multiple such top-level targets, overrides --gc_churning_threshold. Useful to configure more aggressive OOMing behavior (i.e. a lower value than --gc_churning_threshold) when they are multiple top-level targets so that the invoker of Bazel can split and retry while still having less aggressive behavior when there is a single top-level target. +: If set to a value in [0, 100] and this is a command that takes top-level targets (e.g. build but not query) and there are multiple such top-level targets, overrides --gc\_churning\_threshold. Useful to configure more aggressive OOMing behavior (i.e. a lower value than --gc\_churning\_threshold) when they are multiple top-level targets so that the invoker of Bazel can split and retry while still having less aggressive behavior when there is a single top-level target. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--gc_thrashing_threshold=` default: "100" -: The percent of tenured space occupied (0-100) above which GcThrashingDetector considers memory pressure events against its limits (--gc_thrashing_limits). If set to 100, GcThrashingDetector is disabled. +: The percent of tenured space occupied (0-100) above which GcThrashingDetector considers memory pressure events against its limits (--gc\_thrashing\_limits). If set to 100, GcThrashingDetector is disabled. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) @@ -448,13 +448,13 @@ Options that let the user configure the intended output, affecting its value, as [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--[no]incompatible_repo_env_ignores_action_env` default: "true" -: If true, `--action_env=NAME=VALUE` will no longer affect repository rule and module extension environments. +: If true, --action\_env=NAME=VALUE will no longer affect repository rule and module extension environments. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--remote_download_all` -: Downloads all remote outputs to the local machine. This flag is an alias for --remote_download_outputs=all. +: Downloads all remote outputs to the local machine. This flag is an alias for --remote\_download\_outputs=all. Expands to: @@ -464,7 +464,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--remote_download_minimal` -: Does not download any remote build outputs to the local machine. This flag is an alias for --remote_download_outputs=minimal. +: Does not download any remote build outputs to the local machine. This flag is an alias for --remote\_download\_outputs=minimal. Expands to: @@ -480,13 +480,13 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--remote_download_symlink_template=` default: "" -: Instead of downloading remote build outputs to the local machine, create symbolic links. The target of the symbolic links can be specified in the form of a template string. This template string may contain {hash} and {size_bytes} that expand to the hash of the object and the size in bytes, respectively. These symbolic links may, for example, point to a FUSE file system that loads objects from the CAS on demand. +: Instead of downloading remote build outputs to the local machine, create symbolic links. The target of the symbolic links can be specified in the form of a template string. This template string may contain {hash} and {size\_bytes} that expand to the hash of the object and the size in bytes, respectively. These symbolic links may, for example, point to a FUSE file system that loads objects from the CAS on demand. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--remote_download_toplevel` -: Only downloads remote outputs of top level targets to the local machine. This flag is an alias for --remote_download_outputs=toplevel. +: Only downloads remote outputs of top level targets to the local machine. This flag is an alias for --remote\_download\_outputs=toplevel. Expands to: @@ -496,7 +496,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--repo_env=` multiple uses are accumulated -: Specifies additional environment variables to be available only for repository rules. Note that repository rules see the full environment anyway, but in this way variables can be set via command-line flags and `.bazelrc` entries. The special syntax `=NAME` can be used to explicitly unset a variable. The string `%bazel_workspace%` in a value will be replaced with the absolute path of the workspace as printed by `bazel info workspace`. +: Specifies additional environment variables to be available only for repository rules. Note that repository rules see the full environment anyway, but in this way variables can be set via command-line flags and .bazelrc entries. The special syntax =NAME can be used to explicitly unset a variable. The string %bazel\_workspace% in a value will be replaced with the absolute path of the workspace as printed by bazel info workspace. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES) @@ -530,7 +530,7 @@ This option affects semantics of the Starlark language or the build API accessib [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--[no]experimental_cc_shared_library` default: "false" -: If set to true, rule attributes and Starlark API methods needed for the rule cc_shared_library will be available +: If set to true, rule attributes and Starlark API methods needed for the rule cc\_shared\_library will be available Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -542,7 +542,7 @@ This option affects semantics of the Starlark language or the build API accessib [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) `--[no]experimental_dormant_deps` default: "false" -: If set to true, attr.label(materializer=), attr(for_dependency_resolution=), attr.dormant_label(), attr.dormant_label_list() and rule(for_dependency_resolution=) are allowed. +: If set to true, attr.label(materializer=), attr(for\_dependency\_resolution=), attr.dormant\_label(), attr.dormant\_label\_list() and rule(for\_dependency\_resolution=) are allowed. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -578,7 +578,7 @@ This option affects semantics of the Starlark language or the build API accessib [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--[no]experimental_isolated_extension_usages` default: "false" -: If true, enables the `isolate` parameter in the [`use_extension`](https://bazel.build/rules/lib/globals/module#use_extension) function. +: If true, enables the isolate parameter in the use\_extension function. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -590,25 +590,25 @@ This option affects semantics of the Starlark language or the build API accessib [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--[no]experimental_repo_remote_exec` default: "false" -: If set to true, repository_rule gains some remote execution capabilities. +: If set to true, repository\_rule gains some remote execution capabilities. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--[no]experimental_repository_ctx_execute_wasm` default: "false" -: If true enables the repository_ctx `load_wasm` and `execute_wasm` methods. +: If true enables the repository\_ctx `load_wasm` and `execute_wasm` methods. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--[no]experimental_sibling_repository_layout` default: "false" -: If set to true, non-main repositories are planted as symlinks to the main repository in the execution root. That is, all repositories are direct children of the $output_base/execution_root directory. This has the side effect of freeing up $output_base/execution_root/**main**/external for the real top-level 'external' directory. +: If set to true, non-main repositories are planted as symlinks to the main repository in the execution root. That is, all repositories are direct children of the $output\_base/execution\_root directory. This has the side effect of freeing up $output\_base/execution\_root/**main**/external for the real top-level 'external' directory. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`bazel_internal_configuration`](#effect_tag_BAZEL_INTERNAL_CONFIGURATION), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) `--[no]experimental_single_package_toolchain_binding` default: "false" -: If enabled, the register_toolchain function may not include target patterns which may refer to more than one package. +: If enabled, the register\_toolchain function may not include target patterns which may refer to more than one package. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -626,7 +626,7 @@ This option affects semantics of the Starlark language or the build API accessib [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--experimental_starlark_type_checking` -: Enables both static and dynamic type checking in files and functions that contain type annotations or related syntax. This is an expansion flag for --experimental_starlark_static_type_checking and --experimental_starlark_dynamic_type_checking. (When both flags are disabled, Bazel is more forgiving of invalid types in type annotations.) +: Enables both static and dynamic type checking in files and functions that contain type annotations or related syntax. This is an expansion flag for --experimental\_starlark\_static\_type\_checking and --experimental\_starlark\_dynamic\_type\_checking. (When both flags are disabled, Bazel is more forgiving of invalid types in type annotations.) Expands to: @@ -651,7 +651,7 @@ This option affects semantics of the Starlark language or the build API accessib [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--[no]force_starlark_stack_trace` default: "false" -: If --force_starlark_stack_trace=true, Starlark stace traces will always be printed from calls to fail(), including those normally supressed with fail(..., stack_trace = False) +: If --force\_starlark\_stack\_trace=true, Starlark stace traces will always be printed from calls to fail(), including those normally supressed with fail(..., stack\_trace = False) Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -669,7 +669,7 @@ This option affects semantics of the Starlark language or the build API accessib [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_disable_objc_library_transition` default: "true" -: Disable objc_library's custom transition and inherit from the top level target instead (No-op in Bazel) +: Disable objc\_library's custom transition and inherit from the top level target instead (No-op in Bazel) Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -693,7 +693,7 @@ This option affects semantics of the Starlark language or the build API accessib [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE), [`non_configurable`](#metadata_tag_NON_CONFIGURABLE) `--[no]incompatible_disallow_ctx_resolve_tools` default: "true" -: If set to true, calling the deprecated ctx.resolve_tools API always fails. Uses of this API should be replaced by an executable or tools argument to ctx.actions.run or ctx.actions.run_shell. +: If set to true, calling the deprecated ctx.resolve\_tools API always fails. Uses of this API should be replaced by an executable or tools argument to ctx.actions.run or ctx.actions.run\_shell. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -705,7 +705,7 @@ This option affects semantics of the Starlark language or the build API accessib [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_enable_deprecated_label_apis` default: "true" -: If enabled, certain deprecated APIs (native.repository_name, Label.workspace_name, Label.relative) can be used. +: If enabled, certain deprecated APIs (native.repository\_name, Label.workspace\_name, Label.relative) can be used. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -717,13 +717,13 @@ This option affects semantics of the Starlark language or the build API accessib [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_fix_package_group_reporoot_syntax` default: "true" -: In package_group's `packages` attribute, changes the meaning of the value "//..." to refer to all packages in the current repository instead of all packages in any repository. You can use the special value "public" in place of "//..." to obtain the old behavior. This flag requires that --incompatible_package_group_has_public_syntax also be enabled. +: In package\_group's `packages` attribute, changes the meaning of the value "//..." to refer to all packages in the current repository instead of all packages in any repository. You can use the special value "public" in place of "//..." to obtain the old behavior. This flag requires that --incompatible\_package\_group\_has\_public\_syntax also be enabled. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_locations_prefers_executable` default: "true" -: Whether a target that provides an executable expands to the executable rather than the files in `DefaultInfo.files` under $(locations ...) expansion if the number of files is not 1. +: Whether a target that provides an executable expands to the executable rather than the files in DefaultInfo.files under $(locations ...) expansion if the number of files is not 1. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -741,7 +741,7 @@ This option affects semantics of the Starlark language or the build API accessib [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_no_implicit_watch_label` default: "true" -: If true, then methods on `repository_ctx` that are passed a Label will no longer automatically watch the file under that label for changes even if `watch = "no"`, and `repository_ctx.path` no longer causes the returned path to be watched. Use `repository_ctx.watch` instead. +: If true, then methods on repository\_ctx that are passed a Label will no longer automatically watch the file under that label for changes even if watch = "no", and repository\_ctx.path no longer causes the returned path to be watched. Use repository\_ctx.watch instead. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -753,13 +753,13 @@ This option affects semantics of the Starlark language or the build API accessib [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_package_group_has_public_syntax` default: "true" -: In package_group's `packages` attribute, allows writing "public" or "private" to refer to all packages or no packages respectively. +: In package\_group's `packages` attribute, allows writing "public" or "private" to refer to all packages or no packages respectively. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_require_mnemonic_for_run_actions` default: "false" -: If set to true, ctx.actions.run and ctx.actions.run_shell will require an explicit mnemonic +: If set to true, ctx.actions.run and ctx.actions.run\_shell will require an explicit mnemonic Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -771,7 +771,7 @@ This option affects semantics of the Starlark language or the build API accessib [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_run_shell_command_string` default: "true" -: If set to true, the command parameter of actions.run_shell will only accept string +: If set to true, the command parameter of actions.run\_shell will only accept string Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -783,7 +783,7 @@ This option affects semantics of the Starlark language or the build API accessib [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_stop_exporting_build_file_path` default: "false" -: If set to true, deprecated ctx.build_file_path will not be available. ctx.label.package + '/BUILD' can be used instead. +: If set to true, deprecated ctx.build\_file\_path will not be available. ctx.label.package + '/BUILD' can be used instead. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -800,6 +800,12 @@ This option affects semantics of the Starlark language or the build API accessib Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) +`--[no]incompatible_use_cc_configure_from_rules_cc` default: "false" +: When true, Bazel will no longer allow using cc\_configure from @bazel\_tools. Please see https://github.com/bazelbuild/bazel/issues/10134 for details and migration instructions. + + Tags: + [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) + `--max_computation_steps=` default: "0" : The maximum number of Starlark computation steps that may be executed by a BUILD file (zero means no limit). @@ -892,7 +898,7 @@ Options relating to Bzlmod output and semantics: Options that trigger optimizations of the build time: `--gc_thrashing_limits=:>` default: "1s:2,20s:3,1m:5" -: Limits which, if reached, cause GcThrashingDetector to crash Bazel with an OOM. Each limit is specified as <period>:<count> where period is a duration and count is a positive integer. If more than --gc_thrashing_threshold percent of tenured space (old gen heap) remains occupied after <count> consecutive full GCs within <period>, an OOM is triggered. Multiple limits can be specified separated by commas. +: Limits which, if reached, cause GcThrashingDetector to crash Bazel with an OOM. Each limit is specified as : where period is a duration and count is a positive integer. If more than --gc\_thrashing\_threshold percent of tenured space (old gen heap) remains occupied after consecutive full GCs within , an OOM is triggered. Multiple limits can be specified separated by commas. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) @@ -916,13 +922,13 @@ Options that trigger optimizations of the build time: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--skyframe_high_water_mark_full_gc_drops_per_invocation== 0>` default: "10" -: Flag for advanced configuration of Bazel's internal Skyframe engine. If Bazel detects its retained heap percentage usage exceeds the threshold set by --skyframe_high_water_mark_threshold, when a full GC event occurs, it will drop unnecessary temporary Skyframe state, up to this many times per invocation. Defaults to 10. Zero means that full GC events will never trigger drops. If the limit is reached, Skyframe state will no longer be dropped when a full GC event occurs and that retained heap percentage threshold is exceeded. +: Flag for advanced configuration of Bazel's internal Skyframe engine. If Bazel detects its retained heap percentage usage exceeds the threshold set by --skyframe\_high\_water\_mark\_threshold, when a full GC event occurs, it will drop unnecessary temporary Skyframe state, up to this many times per invocation. Defaults to 10. Zero means that full GC events will never trigger drops. If the limit is reached, Skyframe state will no longer be dropped when a full GC event occurs and that retained heap percentage threshold is exceeded. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--skyframe_high_water_mark_minor_gc_drops_per_invocation== 0>` default: "10" -: Flag for advanced configuration of Bazel's internal Skyframe engine. If Bazel detects its retained heap percentage usage exceeds the threshold set by --skyframe_high_water_mark_threshold, when a minor GC event occurs, it will drop unnecessary temporary Skyframe state, up to this many times per invocation. Defaults to 10. Zero means that minor GC events will never trigger drops. If the limit is reached, Skyframe state will no longer be dropped when a minor GC event occurs and that retained heap percentage threshold is exceeded. +: Flag for advanced configuration of Bazel's internal Skyframe engine. If Bazel detects its retained heap percentage usage exceeds the threshold set by --skyframe\_high\_water\_mark\_threshold, when a minor GC event occurs, it will drop unnecessary temporary Skyframe state, up to this many times per invocation. Defaults to 10. Zero means that minor GC events will never trigger drops. If the limit is reached, Skyframe state will no longer be dropped when a minor GC event occurs and that retained heap percentage threshold is exceeded. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) @@ -948,7 +954,7 @@ Options that affect the verbosity, format or location of logging: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]attempt_to_print_relative_paths` default: "false" -: When printing the location part of messages, attempt to use a path relative to the workspace directory or one of the directories specified by --package_path. +: When printing the location part of messages, attempt to use a path relative to the workspace directory or one of the directories specified by --package\_path. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -1048,7 +1054,7 @@ Options that affect the verbosity, format or location of logging: Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) -`--bes_upload_mode=` default: "wait_for_upload_complete" +`--bes_upload_mode=` default: "wait\_for\_upload\_complete" : Specifies whether the Build Event Service upload should block the build completion or should end the invocation immediately and finish the upload in the background. @@ -1084,7 +1090,7 @@ Options that affect the verbosity, format or location of logging: Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) -`--build_event_binary_file_upload_mode=` default: "wait_for_upload_complete" +`--build_event_binary_file_upload_mode=` default: "wait\_for\_upload\_complete" : Specifies whether the Build Event Service upload for `--build_event_binary_file` should block the build completion or should end the invocation immediately and finish the upload in the background. Either `wait_for_upload_complete` (default), @@ -1108,7 +1114,7 @@ Options that affect the verbosity, format or location of logging: Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) -`--build_event_json_file_upload_mode=` default: "wait_for_upload_complete" +`--build_event_json_file_upload_mode=` default: "wait\_for\_upload\_complete" : Specifies whether the Build Event Service upload for `--build_event_json_file` should block the build completion or should end the invocation immediately and finish the upload in the background. Either `wait_for_upload_complete` (default), @@ -1148,7 +1154,7 @@ Options that affect the verbosity, format or location of logging: Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) -`--build_event_text_file_upload_mode=` default: "wait_for_upload_complete" +`--build_event_text_file_upload_mode=` default: "wait\_for\_upload\_complete" : Specifies whether the Build Event Service upload for `--build_event_text_file` should block the build completion or should end the invocation immediately and finish the upload in the background. Either `wait_for_upload_complete` (default), @@ -1263,7 +1269,7 @@ Options that affect the verbosity, format or location of logging: : Controls the output of BEP ActionSummary and BuildGraphMetrics, limiting the number of mnemonics in ActionData and number of entries reported in BuildGraphMetrics.AspectCount/RuleClassCount. By default the number of types is limited to the top 20, by number of executed actions for ActionData, and instances for RuleClass and Asepcts. Setting this option will write statistics for all mnemonics, rule classes and aspects. `--[no]experimental_record_skyframe_metrics` default: "false" -: Controls the output of BEP BuildGraphMetrics, including expensive to compute skyframe metrics about Skykeys, RuleClasses and Aspects. With this flag set to false BuildGraphMetrics.rule_count and aspect fields will not be populated in the BEP. +: Controls the output of BEP BuildGraphMetrics, including expensiveto compute skyframe metrics about Skykeys, RuleClasses and Aspects.With this flag set to false BuildGraphMetrics.rule\_count and aspectfields will not be populated in the BEP. `--[no]experimental_run_bep_event_include_residue` default: "false" : Whether to include the command-line residue in run build events which could contain the residue. By default, the residue is not included in run command build events that could contain the residue. @@ -1287,7 +1293,7 @@ Options that affect the verbosity, format or location of logging: [`bazel_monitoring`](#effect_tag_BAZEL_MONITORING) `--[no]heap_dump_on_oom` default: "false" -: Whether to manually output a heap dump if an OOM is thrown (including manual OOMs due to reaching --gc_thrashing_limits). The dump will be written to <output_base>/<invocation_id>.heapdump.hprof. This option effectively replaces -XX:+HeapDumpOnOutOfMemoryError, which has no effect for manual OOMs. +: Whether to manually output a heap dump if an OOM is thrown (including manual OOMs due to reaching --gc\_thrashing\_limits). The dump will be written to /.heapdump.hprof. This option effectively replaces -XX:+HeapDumpOnOutOfMemoryError, which has no effect for manual OOMs. Tags: [`bazel_monitoring`](#effect_tag_BAZEL_MONITORING) @@ -1384,61 +1390,7 @@ Options that affect the verbosity, format or location of logging: Remote caching and execution options: `--downloader_config=` multiple uses are accumulated -: Specify a file to configure the remote downloader with. - - This file consists of directives, one per line, that adjust how the - Bazel downloader acts. The directives are: `allow`, `block`, `rewrite`, - and `all_blocked_message`. The directives are applied in the order - `rewrite, allow, block'. - - Comments are allowed and must be on their own line (no trailing comments) - and preceded by a `#`. Example: `# evil.com is known to host malicious code` - - The `allow` and `block` directives take a host name as an argument. For - example: `block mvnrepository.com.example` or `allow github.com.example`. The given host - and all subdomains will be allowed or blocked. Do not include the URL - scheme (`http://` or `https://`). You can block all hosts with the `*` - wildcard: `block *`. - - The `rewrite` directive takes two regex patterns: the first to match a URL - and the second to substitute matched URLs with. For example, `rewrite github.com.example/bazel-contrib/rules_python/releases/download/(.*)/(.*) mycorp.example/rules_python_mirror/$1/$2` will cause the downloader - to access `mycorp.example/rules_python_mirror` whenever attempting - to download rules_python from example.com. The substitute URL supports - back-references starting from `$1`. It is possible for multiple - `rewrite` directives for the same matched URL to be provided, and in - this case multiple URLs will be returned and tried sequentially. Do not - include the URL scheme (`http://` or `https://`) in the patterns. - - The `all_blocked_message` directive allows you to customize the message - that is shown when the rewriter is configured to block all URLs for - a particular resource. This directive can only be given once, and the - message must exist on a single line. Example: `all_blocked_message Hey, I think the downloader config is wrong. Bummer!`. - - Note that it is not possible to directly block a particular path for - a given host while still allowing other paths on the host. This can be - worked around by rewrite the path to a blocked host: - - ``` - block dummy_host.invalid - rewrite example.com/bar/.* dummy_host.invalid - ``` - - An example config may look like: - - ``` - all_blocked_message See example.com/blocked-bazel-fetches for more information. - block mvnrepository.com.example - block maven-central.storage.googleapis.com.example - - # See internal doc id1234 for why gitblit is blocked - block gitblit.github.com.example - rewrite repo.maven.apache.org.example/maven2/(.*) artifacts.mycorp.example/libs-release/$1 - - # Use our GCS bucket for rules_python - rewrite github.com.example/bazel-contrib/rules_python/releases/download/(.*)/(.*) mycorp.example/rules_python_mirror/$1/$2 - ``` - - See also: [Insulating Builds from the Internet](https://bazel.build/external/faq#how-do-i-insulate-my-builds-from-the-internet) +: Specify a file to configure the remote downloader with. This file consists of lines, each of which starts with a directive (`allow`, `block` or `rewrite`) followed by either a host name (for `allow` and `block`) or two patterns, one to match against, and one to use as a substitute URL, with back-references starting from `$1`. It is possible for multiple `rewrite` directives for the same URL to be given, and in this case multiple URLs will be returned. `--experimental_circuit_breaker_strategy=` default: see description : Specifies the strategy for the circuit breaker to use. Available strategies are "failure". On invalid value for the option the behavior same as the option is not set. @@ -1453,7 +1405,7 @@ Remote caching and execution options: [`experimental`](#metadata_tag_EXPERIMENTAL) `--experimental_remote_cache_compression_threshold=` default: "100" -: The minimum blob size required to compress/decompress with zstd. Ineffectual unless --remote_cache_compression is set. +: The minimum blob size required to compress/decompress with zstd. Ineffectual unless --remote\_cache\_compression is set. `--[no]experimental_remote_cache_lease_extension` default: "false" : If set to true, Bazel will extend the lease for outputs of remote actions during the build by sending `FindMissingBlobs` calls periodically to remote cache. The frequency is based on the value of `--experimental_remote_cache_ttl`. @@ -1471,7 +1423,7 @@ Remote caching and execution options: : If set to true, discard in-memory copies of the input root's Merkle tree and associated input mappings during calls to GetActionResult() and Execute(). This reduces memory usage significantly, but does require Bazel to recompute them upon remote cache misses and retries. `--experimental_remote_downloader=` default: see description -: A Remote Asset API endpoint URI, to be used as a remote download proxy. The supported schemes are grpc, grpcs (grpc with TLS enabled) and unix (local UNIX sockets). If no scheme is provided Bazel will default to grpcs. See: https://github.com/bazelbuild/remote-apis/blob/master/build/bazel/remote/asset/v1/remote_asset.proto +: A Remote Asset API endpoint URI, to be used as a remote download proxy. The supported schemes are grpc, grpcs (grpc with TLS enabled) and unix (local UNIX sockets). If no scheme is provided Bazel will default to grpcs. See: https://github.com/bazelbuild/remote-apis/blob/master/build/bazel/remote/asset/v1/remote\_asset.proto `--[no]experimental_remote_downloader_local_fallback` default: "false" : Whether to fall back to the local downloader if remote downloader fails. @@ -1498,13 +1450,13 @@ Remote caching and execution options: : HOST or HOST:PORT of a remote output service endpoint. The supported schemes are grpc, grpcs (grpc with TLS enabled) and unix (local UNIX sockets). If no scheme is provided Bazel will default to grpcs. Specify grpc:// or unix: scheme to disable TLS. `--experimental_remote_output_service_output_path_prefix=` default: "" -: The path under which the contents of output directories managed by the --experimental_remote_output_service are placed. The actual output directory used by a build will be a descendant of this path and determined by the output service. +: The path under which the contents of output directories managed by the --experimental\_remote\_output\_service are placed. The actual output directory used by a build will be a descendant of this path and determined by the output service. `--[no]experimental_remote_require_cached` default: "false" : If set to true, enforce that all actions that can run remotely are cached, or else fail the build. This is useful to troubleshoot non-determinism issues as it allows checking whether actions that should be cached are actually cached without spuriously injecting new results into the cache. `--experimental_remote_scrubbing_config=` default: see description -: Enables remote cache key scrubbing with the supplied configuration file, which must be a protocol buffer in text format (see src/main/protobuf/remote_scrubbing.proto). +: Enables remote cache key scrubbing with the supplied configuration file, which must be a protocol buffer in text format (see src/main/protobuf/remote\_scrubbing.proto). This feature is intended to facilitate sharing a remote/disk cache between actions executing on different platforms but targeting the same platform. It should be used with extreme care, as improper settings may cause accidental sharing of cache entries and result in incorrect builds. @@ -1512,7 +1464,7 @@ Remote caching and execution options: Modifying the scrubbing configuration does not invalidate outputs present in the local filesystem or internal caches; a clean build is required to reexecute affected actions. - In order to successfully use this feature, you likely want to set a custom --host_platform together with --experimental_platform_in_output_dir (to normalize output prefixes). + In order to successfully use this feature, you likely want to set a custom --host\_platform together with --experimental\_platform\_in\_output\_dir (to normalize output prefixes). `--[no]guard_against_concurrent_changes` default: "lite" : Set this to 'full' to enable checking the ctime of all input files of an action before uploading it to a remote cache. There may be cases where the Linux kernel delays writing of files, which could cause false positives. The default is 'lite', which only checks source files in the main repository. Setting this to 'off' disables all checks. This is not recommended, as the cache may be polluted when a source file is changed while an action that takes it as an input is executing. @@ -1521,7 +1473,7 @@ Remote caching and execution options: [`execution`](#effect_tag_EXECUTION) `--[no]incompatible_remote_local_fallback_for_remote_cache` default: "false" -: Whether --remote_local_fallback applies to --remote_cache. +: Whether --remote\_local\_fallback applies to --remote\_cache. `--[no]remote_accept_cached` default: "true" : Whether to accept remotely cached action results. @@ -1532,7 +1484,7 @@ Remote caching and execution options: Default to 'minimal'. `--remote_bytestream_uri_prefix=` default: see description -: The hostname and instance name to be used in bytestream:// URIs that are written into build event streams. This option can be set when builds are performed using a proxy, which causes the values of --remote_executor and --remote_instance_name to no longer correspond to the canonical name of the remote execution service. When not set, it will default to "${hostname}/${instance_name}". +: The hostname and instance name to be used in bytestream:// URIs that are written into build event streams. This option can be set when builds are performed using a proxy, which causes the values of --remote\_executor and --remote\_instance\_name to no longer correspond to the canonical name of the remote execution service. When not set, it will default to "${hostname}/${instance\_name}". `--remote_cache=` default: see description : A URI of a caching endpoint. The supported schemes are http, https, grpc, grpcs (grpc with TLS enabled) and unix (local UNIX sockets). If no scheme is provided Bazel will default to grpcs. Specify grpc://, http:// or unix: scheme to disable TLS. See https://bazel.build/remote/caching @@ -1541,28 +1493,28 @@ Remote caching and execution options: : If true, uploading of action results to a disk or remote cache will happen in the background instead of blocking the completion of an action. Some actions are incompatible with background uploads, and may still block even when this flag is set. `--[no]remote_cache_compression` default: "false" -: If enabled, compress/decompress cache blobs with zstd when their size is at least --experimental_remote_cache_compression_threshold. +: If enabled, compress/decompress cache blobs with zstd when their size is at least --experimental\_remote\_cache\_compression\_threshold. `--remote_cache_header=` multiple uses are accumulated -: Specify a header that will be included in cache requests: --remote_cache_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. +: Specify a header that will be included in cache requests: --remote\_cache\_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. `--remote_default_exec_properties=` multiple uses are accumulated -: Set the default exec properties to be used as the remote execution platform if an execution platform does not already set exec_properties. +: Set the default exec properties to be used as the remote execution platform if an execution platform does not already set exec\_properties. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--remote_download_regex=` multiple uses are accumulated -: Force remote build outputs whose path matches this pattern to be downloaded, irrespective of --remote_download_outputs. Multiple patterns may be specified by repeating this flag. +: Force remote build outputs whose path matches this pattern to be downloaded, irrespective of --remote\_download\_outputs. Multiple patterns may be specified by repeating this flag. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--remote_downloader_header=` multiple uses are accumulated -: Specify a header that will be included in remote downloader requests: --remote_downloader_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. +: Specify a header that will be included in remote downloader requests: --remote\_downloader\_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. `--remote_exec_header=` multiple uses are accumulated -: Specify a header that will be included in execution requests: --remote_exec_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. +: Specify a header that will be included in execution requests: --remote\_exec\_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. `--remote_execution_priority=` default: "0" : The relative priority of actions to be executed remotely. The semantics of the particular priority values are server-dependent. @@ -1574,10 +1526,10 @@ Remote caching and execution options: : If specified, a path to a file to log gRPC call related details. This log consists of a sequence of serialized com.google.devtools.build.lib.remote.logging.RemoteExecutionLog.LogEntry protobufs with each message prefixed by a varint denoting the size of the following serialized protobuf message, as performed by the method LogEntry.writeDelimitedTo(OutputStream). `--remote_header=` multiple uses are accumulated -: Specify a header that will be included in requests: --remote_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. +: Specify a header that will be included in requests: --remote\_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. `--remote_instance_name=` default: "" -: Value to pass as instance_name in the remote execution API. +: Value to pass as instance\_name in the remote execution API. `--[no]remote_local_fallback` default: "false" : Whether to fall back to standalone local execution strategy if remote execution fails. @@ -1585,9 +1537,6 @@ Remote caching and execution options: `--remote_local_fallback_strategy=` default: "local" : Deprecated. See https://github.com/bazelbuild/bazel/issues/7480 for details. - Tags: - [`deprecated`](#metadata_tag_DEPRECATED) - `--remote_max_concurrency_per_connection=` default: "100" : Limit the max number of concurrent requests per gRPC connection. By default the value is 100. @@ -1596,8 +1545,8 @@ Remote caching and execution options: `--remote_max_connections=` default: "100" : Limit the max number of concurrent connections to remote cache/executor. By default the value is 100. Setting this to 0 means no limitation. - For HTTP remote cache, one TCP connection could handle one request at one time, so Bazel could make up to --remote_max_connections concurrent requests. - For gRPC remote cache/executor, one gRPC channel could usually handle 100+ concurrent requests (controlled by --remote_max_concurrency_per_connection), so Bazel could make around `--remote_max_connections * 100` concurrent requests. + For HTTP remote cache, one TCP connection could handle one request at one time, so Bazel could make up to --remote\_max\_connections concurrent requests. + For gRPC remote cache/executor, one gRPC channel could usually handle 100+ concurrent requests (controlled by --remote\_max\_concurrency\_per\_connection), so Bazel could make around `--remote_max_connections * 100` concurrent requests. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) @@ -1635,7 +1584,7 @@ Miscellaneous options, not otherwise categorized.: : Use terminal controls to colorize output. `--config=` multiple uses are accumulated -: Selects additional config sections from the rc files; for every <command>, it also pulls in the options from <command>:<config> if such a section exists; if this section doesn't exist in any .rc file, Blaze fails with an error. The config sections and flag combinations they are equivalent to are located in the tools/\*.blazerc config files. +: Selects additional config sections from the rc files; for every , it also pulls in the options from : if such a section exists; if this section doesn't exist in any .rc file, Blaze fails with an error. The config sections and flag combinations they are equivalent to are located in the tools/\*.blazerc config files. `--credential_helper=` multiple uses are accumulated : Configures a credential helper conforming to the [Credential Helper Specification](https://github.com/EngFlow/credential-helper-spec) @@ -1668,41 +1617,41 @@ Miscellaneous options, not otherwise categorized.: `--curses=` default: "auto" : Use terminal cursor controls to minimize scrolling output. -`--[no]disk_cache` default: see description -: A path to a directory where Bazel can read and write actions and action outputs. If the directory does not exist, it will be created. Use --disk_cache with no value (or --disk_cache=true) to use a default location under the output user root (<outputUserRoot>/cache/disk). Use --nodisk_cache or --disk_cache=false to disable. +`--disk_cache=` default: see description +: A path to a directory where Bazel can read and write actions and action outputs. If the directory does not exist, it will be created. `--[no]enable_platform_specific_config` default: "false" : If true, Bazel picks up host-OS-specific config lines from bazelrc files. For example, if the host OS is Linux and you run bazel build, Bazel picks up lines starting with build:linux. Supported OS identifiers are linux, macos, windows, freebsd, and openbsd. Enabling this flag is equivalent to using --config=linux on Linux, --config=windows on Windows, etc. `--experimental_action_cache_gc_idle_delay=` default: "5m" -: How long the server must remain idle before a garbage collection of the action cache is attempted. Ineffectual unless --experimental_action_cache_gc_max_age is nonzero. +: How long the server must remain idle before a garbage collection of the action cache is attempted. Ineffectual unless --experimental\_action\_cache\_gc\_max\_age is nonzero. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--experimental_action_cache_gc_max_age=` default: "0" -: If set to a nonzero value, the action cache will be periodically garbage collected to remove entries older than this age. Garbage collection occurs in the background once the server has become idle, as determined by the --experimental_action_cache_gc_idle_delay and --experimental_action_cache_gc_threshold flags. +: If set to a nonzero value, the action cache will be periodically garbage collected to remove entries older than this age. Garbage collection occurs in the background once the server has become idle, as determined by the --experimental\_action\_cache\_gc\_idle\_delay and --experimental\_action\_cache\_gc\_threshold flags. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--experimental_action_cache_gc_threshold=` default: "10" -: The percentage of stale action cache entries required for garbage collection to be triggered. Ineffectual unless --experimental_action_cache_gc_max_age is nonzero. +: The percentage of stale action cache entries required for garbage collection to be triggered. Ineffectual unless --experimental\_action\_cache\_gc\_max\_age is nonzero. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--experimental_disk_cache_gc_idle_delay=` default: "5m" -: How long the server must remain idle before a garbage collection of the disk cache occurs. To specify the garbage collection policy, set --experimental_disk_cache_gc_max_size and/or --experimental_disk_cache_gc_max_age. +: How long the server must remain idle before a garbage collection of the disk cache occurs. To specify the garbage collection policy, set --experimental\_disk\_cache\_gc\_max\_size and/or --experimental\_disk\_cache\_gc\_max\_age. `--experimental_disk_cache_gc_max_age=` default: "0" -: If set to a positive value, the disk cache will be periodically garbage collected to remove entries older than this age. If set in conjunction with --experimental_disk_cache_gc_max_size, both criteria are applied. Garbage collection occurrs in the background once the server has become idle, as determined by the --experimental_disk_cache_gc_idle_delay flag. +: If set to a positive value, the disk cache will be periodically garbage collected to remove entries older than this age. If set in conjunction with --experimental\_disk\_cache\_gc\_max\_size, both criteria are applied. Garbage collection occurrs in the background once the server has become idle, as determined by the --experimental\_disk\_cache\_gc\_idle\_delay flag. `--experimental_disk_cache_gc_max_size=` default: "0" -: If set to a positive value, the disk cache will be periodically garbage collected to stay under this size. If set in conjunction with --experimental_disk_cache_gc_max_age, both criteria are applied. Garbage collection occurrs in the background once the server has become idle, as determined by the --experimental_disk_cache_gc_idle_delay flag. +: If set to a positive value, the disk cache will be periodically garbage collected to stay under this size. If set in conjunction with --experimental\_disk\_cache\_gc\_max\_age, both criteria are applied. Garbage collection occurrs in the background once the server has become idle, as determined by the --experimental\_disk\_cache\_gc\_idle\_delay flag. `--[no]experimental_enable_thread_dump` default: "false" -: Whether to enable thread dumps. If true, Bazel will dump the state of all threads (including virtual threads) to a file every --experimental_thread_dump_interval, or after action execution being inactive for --experimental_thread_dump_action_execution_inactivity_duration. The dumps will be written to the <output_base>/server/thread_dumps/ directory. +: Whether to enable thread dumps. If true, Bazel will dump the state of all threads (including virtual threads) to a file every --experimental\_thread\_dump\_interval, or after action execution being inactive for --experimental\_thread\_dump\_action\_execution\_inactivity\_duration. The dumps will be written to the /server/thread\_dumps/ directory. Tags: [`bazel_monitoring`](#effect_tag_BAZEL_MONITORING) @@ -1758,7 +1707,7 @@ Miscellaneous options, not otherwise categorized.: pings are disabled, then this setting is ignored. `--[no]incompatible_disable_non_executable_java_binary` default: "false" -: If true, java_binary is always executable. create_executable attribute is removed. +: If true, java\_binary is always executable. create\_executable attribute is removed. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -1820,7 +1769,7 @@ Miscellaneous options, not otherwise categorized.: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]watchfs` default: "false" -: On Linux/macOS: If true, bazel tries to use the operating system's file watch service for local changes instead of scanning every file for a change. On Windows: this flag currently is a non-op but can be enabled in conjunction with --experimental_windows_watchfs. On any OS: The behavior is undefined if your workspace is on a network file system, and files are edited on a remote machine. +: On Linux/macOS: If true, bazel tries to use the operating system's file watch service for local changes instead of scanning every file for a change. On Windows: this flag currently is a non-op but can be enabled in conjunction with --experimental\_windows\_watchfs. On any OS: The behavior is undefined if your workspace is on a network file system, and files are edited on a remote machine. ## Aquery Options @@ -1829,13 +1778,13 @@ Inherits all options from [build](#build). Options relating to query output and semantics: `--aspect_deps=` default: "conservative" -: How to resolve aspect dependencies when the output format is one of {xml,proto,record}. 'off' means no aspect dependencies are resolved, 'conservative' (the default) means all declared aspect dependencies are added regardless of whether they are given the rule class of direct dependencies, 'precise' means that only those aspects are added that are possibly active given the rule class of the direct dependencies. Note that precise mode requires loading other packages to evaluate a single target thus making it slower than the other modes. Also note that even precise mode is not completely precise: the decision whether to compute an aspect is decided in the analysis phase, which is not run during 'bazel query'. +: How to resolve aspect dependencies when the output format is one of {xml,proto,record}. 'off' means no aspect dependencies are resolved, 'conservative' (the default) means all declared aspect dependencies are added regardless of whether they are given the rule class of direct dependencies, 'precise' means that only those aspects are added that are possibly active given the rule class of the direct dependencies. Note that precise mode requires loading other packages to evaluate a single target thus making it slower than the other modes. Also note that even precise mode is not completely precise: the decision whether to compute an aspect is decided in the analysis phase, which is not run during 'bazel query'. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) `--[no]consistent_labels` default: "false" -: If enabled, every query command emits labels as if by the Starlark `str` function applied to a `Label` instance. This is useful for tools that need to match the output of different query commands and/or labels emitted by rules. If not enabled, output formatters are free to emit apparent repository names (relative to the main repository) instead to make the output more readable. +: If enabled, every query command emits labels as if by the Starlark str function applied to a Label instance. This is useful for tools that need to match the output of different query commands and/or labels emitted by rules. If not enabled, output formatters are free to emit apparent repository names (relative to the main repository) instead to make the output more readable. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -1889,31 +1838,25 @@ Options relating to query output and semantics: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]include_param_files` default: "false" -: Include the content of the param files used in the command (potentially large). Note: Enabling this flag will automatically enable the --include_commandline flag. +: Include the content of the param files used in the command (potentially large). Note: Enabling this flag will automatically enable the --include\_commandline flag. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]include_pruned_inputs` default: "true" -: Includes action inputs that were pruned during action execution. Only affects actions that discover inputs and have been executed in a previous invocation. Only takes effect if --include_artifacts is also set. +: Includes action inputs that were pruned during action execution. Only affects actions that discover inputs and have been executed in a previous invocation. Only takes effect if --include\_artifacts is also set. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) -`--[no]incompatible_package_group_build_output` default: "false" -: If enabled, `blaze query --output=build` will output `package_group` targets. - - Tags: - [`terminal_output`](#effect_tag_TERMINAL_OUTPUT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) - `--[no]incompatible_package_group_includes_double_slash` default: "true" -: If enabled, when outputting package_group's `packages` attribute, the leading `//` will not be omitted. +: If enabled, when outputting package\_group's `packages` attribute, the leading `//` will not be omitted. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]infer_universe_scope` default: "false" -: If set and --universe_scope is unset, then a value of --universe_scope will be inferred as the list of unique target patterns in the query expression. Note that the --universe_scope value inferred for a query expression that uses universe-scoped functions (e.g.`allrdeps`) may not be what you want, so you should use this option only if you know what you are doing. See https://bazel.build/reference/query#sky-query for details and examples. If --universe_scope is set, then this option's value is ignored. Note: this option applies only to `query` (i.e. not `cquery`). +: If set and --universe\_scope is unset, then a value of --universe\_scope will be inferred as the list of unique target patterns in the query expression. Note that the --universe\_scope value inferred for a query expression that uses universe-scoped functions (e.g.`allrdeps`) may not be what you want, so you should use this option only if you know what you are doing. See https://bazel.build/reference/query#sky-query for details and examples. If --universe\_scope is set, then this option's value is ignored. Note: this option applies only to `query` (i.e. not `cquery`). Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -1931,13 +1874,13 @@ Options relating to query output and semantics: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) `--output=` default: "text" -: The format in which the aquery results should be printed. Allowed values for aquery are: text, textproto, proto, streamed_proto, jsonproto. +: The format in which the aquery results should be printed. Allowed values for aquery are: text, textproto, proto, streamed\_proto, jsonproto. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--output_file=` default: "" -: When specified, query results will be written directly to this file, and nothing will be printed to Bazel's standard output stream (stdout). In benchmarks, this is generally faster than `bazel query > file`. +: When specified, query results will be written directly to this file, and nothing will be printed to Bazel's standard output stream (stdout). In benchmarks, this is generally faster than bazel query > file. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -1949,7 +1892,7 @@ Options relating to query output and semantics: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]proto:definition_stack` default: "false" -: Populate the definition_stack proto field, which records for each rule instance the Starlark call stack at the moment the rule's class was defined. +: Populate the definition\_stack proto field, which records for each rule instance the Starlark call stack at the moment the rule's class was defined. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -1961,19 +1904,19 @@ Options relating to query output and semantics: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) `--[no]proto:include_attribute_source_aspects` default: "false" -: Populate the source_aspect_name proto field of each Attribute with the source aspect that the attribute came from (empty string if it did not). +: Populate the source\_aspect\_name proto field of each Attribute with the source aspect that the attribute came from (empty string if it did not). Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]proto:include_starlark_rule_env` default: "true" -: Use the starlark environment in the value of the generated $internal_attr_hash attribute. This ensures that the starlark rule definition (and its transitive imports) are part of this identifier. +: Use the starlark environment in the value of the generated $internal\_attr\_hash attribute. This ensures that the starlark rule definition (and its transitive imports) are part of this identifier. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]proto:include_synthetic_attribute_hash` default: "false" -: Whether or not to calculate and populate the $internal_attr_hash attribute. +: Whether or not to calculate and populate the $internal\_attr\_hash attribute. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -1997,13 +1940,13 @@ Options relating to query output and semantics: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]proto:rule_classes` default: "false" -: Populate the rule_class_key field of each rule; and for the first rule with a given rule_class_key, also populate its rule_class_info proto field. The rule_class_key field uniquely identifies a rule class, and the rule_class_info field is a Stardoc-format rule class API definition. +: Populate the rule\_class\_key field of each rule; and for the first rule with a given rule\_class\_key, also populate its rule\_class\_info proto field. The rule\_class\_key field uniquely identifies a rule class, and the rule\_class\_info field is a Stardoc-format rule class API definition. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]proto:rule_inputs_and_outputs` default: "true" -: Whether or not to populate the rule_input and rule_output fields. +: Whether or not to populate the rule\_input and rule\_output fields. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -2021,13 +1964,13 @@ Options relating to query output and semantics: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]skyframe_state` default: "false" -: Without performing extra analysis, dump the current Action Graph from Skyframe. Note: Specifying a target with --skyframe_state is currently not supported. This flag is only available with --output=proto or --output=textproto. +: Without performing extra analysis, dump the current Action Graph from Skyframe. Note: Specifying a target with --skyframe\_state is currently not supported. This flag is only available with --output=proto or --output=textproto. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]tool_deps` default: "true" -: Query: If disabled, dependencies on 'exec configuration' will not be included in the dependency graph over which the query operates. An 'exec configuration' dependency edge, such as the one from any 'proto_library' rule to the Protocol Compiler, usually points to a tool executed during the build rather than a part of the same 'target' program. +: Query: If disabled, dependencies on 'exec configuration' will not be included in the dependency graph over which the query operates. An 'exec configuration' dependency edge, such as the one from any 'proto\_library' rule to the Protocol Compiler, usually points to a tool executed during the build rather than a part of the same 'target' program. Cquery: If disabled, filters out all configured targets which cross an execution transition from the top-level target that discovered this configured target. That means if the top-level target is in the target configuration, only configured targets also in the target configuration will be returned. If the top-level target is in the exec configuration, only exec configured targets will be returned. This option will NOT exclude resolved toolchains. Tags: @@ -2220,13 +2163,13 @@ Options that configure the toolchain used for action execution: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--android_manifest_merger=` default: "android" -: Selects the manifest merger to use for android_binary rules. Flag to help the transition to the Android manifest merger from the legacy merger. +: Selects the manifest merger to use for android\_binary rules. Flag to help the transition to the Android manifest merger from the legacy merger. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--android_platforms=` default: "" -: Sets the platforms that android_binary targets use. If multiple platforms are specified, then the binary is a fat APKs, which contains native binaries for each specified target platform. +: Sets the platforms that android\_binary targets use. If multiple platforms are specified, then the binary is a fat APKs, which contains native binaries for each specified target platform. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -2243,21 +2186,21 @@ Options that configure the toolchain used for action execution: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION) -`--coverage_output_generator=` default: "@bazel_tools//tools/test:lcov_merger" +`--coverage_output_generator=` default: "@bazel\_tools//tools/test:lcov\_merger" : Location of the binary that is used to postprocess raw coverage reports. This must be a binary target. Defaults to `@bazel_tools//tools/test:lcov_merger`. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--coverage_report_generator=` default: "@bazel_tools//tools/test:coverage_report_generator" +`--coverage_report_generator=` default: "@bazel\_tools//tools/test:coverage\_report\_generator" : Location of the binary that is used to generate coverage reports. This must be a binary target. Defaults to `@bazel_tools//tools/test:coverage_report_generator`. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--coverage_support=` default: "@bazel_tools//tools/test:coverage_support" +`--coverage_support=` default: "@bazel\_tools//tools/test:coverage\_support" : Location of support files that are required on the inputs of every test action that collects code coverage. Defaults to `//tools/test:coverage_support`. @@ -2271,7 +2214,7 @@ Options that configure the toolchain used for action execution: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]experimental_include_xcode_execution_requirements` default: "false" -: If set, add a "requires-xcode:{version}" execution requirement to every Xcode action. If the Xcode version has a hyphenated label, also add a "requires-xcode-label:{version_label}" execution requirement. +: If set, add a "requires-xcode:{version}" execution requirement to every Xcode action. If the Xcode version has a hyphenated label, also add a "requires-xcode-label:{version\_label}" execution requirement. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -2314,12 +2257,12 @@ Options that configure the toolchain used for action execution: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION) `--host_grte_top=` default: see description -: If specified, this setting overrides the libc top-level directory (--grte_top) for the exec configuration. +: If specified, this setting overrides the libc top-level directory (--grte\_top) for the exec configuration. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) -`--host_platform=` default: "@bazel_tools//tools:host_platform" +`--host_platform=` default: "@bazel\_tools//tools:host\_platform" : The label of a platform rule that describes the host system. Tags: @@ -2341,6 +2284,12 @@ Options that configure the toolchain used for action execution: Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) +`--[no]incompatible_cuda_compile_action` default: "false" +: Compile cuda files using the cuda-compile action in the toolchain. + + Tags: + [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) + `--[no]incompatible_dont_enable_host_nonhost_crosstool_features` default: "true" : If true, Bazel will not enable 'host' and 'nonhost' features in the c++ toolchain (see https://github.com/bazelbuild/bazel/issues/7407 for more information). @@ -2366,13 +2315,13 @@ Options that configure the toolchain used for action execution: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ios_sdk_version=` default: see description -: Specifies the version of the iOS SDK to use to build iOS applications. If unspecified, uses the default iOS SDK version from 'xcode_version'. +: Specifies the version of the iOS SDK to use to build iOS applications. If unspecified, uses the default iOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--macos_sdk_version=` default: see description -: Specifies the version of the macOS SDK to use to build macOS applications. If unspecified, uses the default macOS SDK version from 'xcode_version'. +: Specifies the version of the macOS SDK to use to build macOS applications. If unspecified, uses the default macOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -2399,19 +2348,19 @@ Options that configure the toolchain used for action execution: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--tvos_sdk_version=` default: see description -: Specifies the version of the tvOS SDK to use to build tvOS applications. If unspecified, uses the default tvOS SDK version from 'xcode_version'. +: Specifies the version of the tvOS SDK to use to build tvOS applications. If unspecified, uses the default tvOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--[no]use_platforms_in_apple_crosstool_transition` default: "false" -: Makes apple_crosstool_transition fall back to using the value of `--platforms` flag instead of legacy `--cpu` when needed. +: Makes apple\_crosstool\_transition fall back to using the value of `--platforms` flag instead of legacy `--cpu` when needed. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--watchos_sdk_version=` default: see description -: Specifies the version of the watchOS SDK to use to build watchOS applications. If unspecified, uses the default watchOS SDK version from 'xcode_version'. +: Specifies the version of the watchOS SDK to use to build watchOS applications. If unspecified, uses the default watchOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -2422,8 +2371,8 @@ Options that configure the toolchain used for action execution: Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) -`--xcode_version_config=` default: "@bazel_tools//tools/cpp:host_xcodes" -: The label of the xcode_config rule to be used for selecting the Xcode version in the build configuration. +`--xcode_version_config=` default: "@bazel\_tools//tools/cpp:host\_xcodes" +: The label of the xcode\_config rule to be used for selecting the Xcode version in the build configuration. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -2455,19 +2404,19 @@ Options that control the output of the command: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--cc_proto_library_header_suffixes=` default: ".pb.h" -: Sets the suffixes of header files that a cc_proto_library creates. +: Sets the suffixes of header files that a cc\_proto\_library creates. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--cc_proto_library_source_suffixes=` default: ".pb.cc" -: Sets the suffixes of source files that a cc_proto_library creates. +: Sets the suffixes of source files that a cc\_proto\_library creates. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--[no]experimental_proto_descriptor_sets_include_source_info` default: "false" -: Run extra actions for alternative Java api versions in a proto_library. +: Run extra actions for alternative Java api versions in a proto\_library. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -2479,7 +2428,7 @@ Options that control the output of the command: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--fission=` default: "no" -: Specifies which compilation modes use fission for C++ compilations and links. May be any combination of {'fastbuild', 'dbg', 'opt'} or the special values 'yes' to enable all modes and 'no' to disable all modes. +: Specifies which compilation modes use fission for C++ compilations and links. May be any combination of {'fastbuild', 'dbg', 'opt'} or the special values 'yes' to enable all modes and 'no' to disable all modes. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -2546,20 +2495,32 @@ Options that let the user configure the intended output, affecting its value, as Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) +`--[no]android_databinding_use_androidx` default: "true" +: Generate AndroidX-compatible data-binding files. This is only used with databinding v2. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + +`--[no]android_databinding_use_v3_4_args` default: "true" +: Use android databinding v2 with 3.4.0 argument. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--android_dynamic_mode=` default: "off" -: Determines whether C++ deps of Android rules will be linked dynamically when a cc_binary does not explicitly create a shared library. 'default' means bazel will choose whether to link dynamically. 'fully' means all libraries will be linked dynamically. 'off' means that all libraries will be linked in mostly static mode. +: Determines whether C++ deps of Android rules will be linked dynamically when a cc\_binary does not explicitly create a shared library. 'default' means bazel will choose whether to link dynamically. 'fully' means all libraries will be linked dynamically. 'off' means that all libraries will be linked in mostly static mode. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--android_manifest_merger_order=` default: "alphabetical" -: Sets the order of manifests passed to the manifest merger for Android binaries. ALPHABETICAL means manifests are sorted by path relative to the execroot. ALPHABETICAL_BY_CONFIGURATION means manifests are sorted by paths relative to the configuration directory within the output directory. DEPENDENCY means manifests are ordered with each library's manifest coming before the manifests of its dependencies. +: Sets the order of manifests passed to the manifest merger for Android binaries. ALPHABETICAL means manifests are sorted by path relative to the execroot. ALPHABETICAL\_BY\_CONFIGURATION means manifests are sorted by paths relative to the configuration directory within the output directory. DEPENDENCY means manifests are ordered with each library's manifest coming before the manifests of its dependencies. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`execution`](#effect_tag_EXECUTION) `--[no]android_resource_shrinking` default: "false" -: Enables resource shrinking for android_binary APKs that use ProGuard. +: Enables resource shrinking for android\_binary APKs that use ProGuard. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -2612,7 +2573,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--cs_fdo_profile=` default: see description -: The cs_fdo_profile representing the context sensitive profile to be used for optimization. +: The cs\_fdo\_profile representing the context sensitive profile to be used for optimization. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -2673,8 +2634,14 @@ Options that let the user configure the intended output, affecting its value, as Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]experimental_android_databinding_v2` default: "true" +: Use android databinding v2. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_android_resource_shrinking` default: "false" -: Enables resource shrinking for android_binary APKs that use ProGuard. +: Enables resource shrinking for android\_binary APKs that use ProGuard. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -2726,7 +2693,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--[no]experimental_use_llvm_covmap` default: "false" -: If specified, Bazel will generate llvm-cov coverage map information rather than gcov when collect_code_coverage is enabled. +: If specified, Bazel will generate llvm-cov coverage map information rather than gcov when collect\_code\_coverage is enabled. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -2758,7 +2725,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--fdo_profile=` default: see description -: The fdo_profile representing the profile to be used for optimization. +: The fdo\_profile representing the profile to be used for optimization. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -2834,13 +2801,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--host_macos_minimum_os=` default: see description -: Minimum compatible macOS version for host targets. If unspecified, uses 'macos_sdk_version'. +: Minimum compatible macOS version for host targets. If unspecified, uses 'macos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--host_per_file_copt=` multiple uses are accumulated -: Additional options to selectively pass to the C/C++ compiler when compiling certain files in the exec configurations. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation_filter). option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --host_per_file_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. +: Additional options to selectively pass to the C/C++ compiler when compiling certain files in the exec configurations. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation\_filter). option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --host\_per\_file\_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -2884,17 +2851,23 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ios_minimum_os=` default: see description -: Minimum compatible iOS version for target simulators and devices. If unspecified, uses 'ios_sdk_version'. +: Minimum compatible iOS version for target simulators and devices. If unspecified, uses 'ios\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--ios_multi_cpus=` multiple uses are accumulated -: Comma-separated list of architectures to build an ios_application with. The result is a universal binary containing all specified architectures. +: Comma-separated list of architectures to build an ios\_application with. The result is a universal binary containing all specified architectures. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) +`--[no]legacy_whole_archive` default: "true" +: Deprecated, superseded by --incompatible\_remove\_legacy\_whole\_archive (see https://github.com/bazelbuild/bazel/issues/7362 for details). When on, use --whole-archive for cc\_binary rules that have linkshared=True and either linkstatic=True or '-static' in linkopts. This is for backwards compatibility only. A better alternative is to use alwayslink=1 where required. + + Tags: + [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`deprecated`](#metadata_tag_DEPRECATED) + `--linkopt=` multiple uses are accumulated : Additional option to pass to gcc when linking. @@ -2902,13 +2875,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ltobackendopt=` multiple uses are accumulated -: Additional option to pass to the LTO backend step (under --features=thin_lto). +: Additional option to pass to the LTO backend step (under --features=thin\_lto). Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ltoindexopt=` multiple uses are accumulated -: Additional option to pass to the LTO indexing step (under --features=thin_lto). +: Additional option to pass to the LTO indexing step (under --features=thin\_lto). Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -2920,7 +2893,7 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--macos_minimum_os=` default: see description -: Minimum compatible macOS version for targets. If unspecified, uses 'macos_sdk_version'. +: Minimum compatible macOS version for targets. If unspecified, uses 'macos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -2932,7 +2905,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]objc_enable_binary_stripping` default: "false" -: Whether to perform symbol and dead-code strippings on linked binaries. Binary strippings will be performed if both this flag and --compilation_mode=opt are specified. +: Whether to perform symbol and dead-code strippings on linked binaries. Binary strippings will be performed if both this flag and --compilation\_mode=opt are specified. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES) @@ -2944,13 +2917,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES) `--per_file_copt=` multiple uses are accumulated -: Additional options to selectively pass to gcc when compiling certain files. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation_filter). option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per_file_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. +: Additional options to selectively pass to gcc when compiling certain files. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation\_filter). option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per\_file\_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--per_file_ltobackendopt=` multiple uses are accumulated -: Additional options to selectively pass to LTO backend (under --features=thin_lto) when compiling certain backend objects. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns. option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per_file_ltobackendopt=//foo/.\*.o,-//foo/bar.o@-O0 adds the -O0 command line option to the LTO backend command line of all o files in //foo/ except bar.o. +: Additional options to selectively pass to LTO backend (under --features=thin\_lto) when compiling certain backend objects. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns. option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per\_file\_ltobackendopt=//foo/.\*.o,-//foo/bar.o@-O0 adds the -O0 command line option to the LTO backend command line of all o files in //foo/ except bar.o. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -2962,19 +2935,19 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--propeller_optimize=` default: see description -: Use Propeller profile information to optimize the build target.A propeller profile must consist of at least one of two files, a cc profile and a ld profile. This flag accepts a build label which must refer to the propeller profile input files. For example, the BUILD file that defines the label, in a/b/BUILD:propeller_optimize( name = "propeller_profile", cc_profile = "propeller_cc_profile.txt", ld_profile = "propeller_ld_profile.txt",)An exports_files directive may have to be added to the corresponding package to make these files visible to Bazel. The option must be used as: --propeller_optimize=//a/b:propeller_profile +: Use Propeller profile information to optimize the build target.A propeller profile must consist of at least one of two files, a cc profile and a ld profile. This flag accepts a build label which must refer to the propeller profile input files. For example, the BUILD file that defines the label, in a/b/BUILD:propeller\_optimize( name = "propeller\_profile", cc\_profile = "propeller\_cc\_profile.txt", ld\_profile = "propeller\_ld\_profile.txt",)An exports\_files directive may have to be added to the corresponding package to make these files visible to Bazel. The option must be used as: --propeller\_optimize=//a/b:propeller\_profile Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--propeller_optimize_absolute_cc_profile=` default: see description -: Absolute path name of cc_profile file for Propeller Optimized builds. +: Absolute path name of cc\_profile file for Propeller Optimized builds. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--propeller_optimize_absolute_ld_profile=` default: see description -: Absolute path name of ld_profile file for Propeller Optimized builds. +: Absolute path name of ld\_profile file for Propeller Optimized builds. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -3008,13 +2981,13 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--strip=` default: "sometimes" -: Specifies whether to strip binaries and shared libraries (using "-Wl,--strip-debug"). The default value of 'sometimes' means strip iff --compilation_mode=fastbuild. +: Specifies whether to strip binaries and shared libraries (using "-Wl,--strip-debug"). The default value of 'sometimes' means strip iff --compilation\_mode=fastbuild. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--stripopt=` multiple uses are accumulated -: Additional options to pass to strip when generating a '<name>.stripped' binary. +: Additional options to pass to strip when generating a '.stripped' binary. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -3026,7 +2999,7 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--tvos_minimum_os=` default: see description -: Minimum compatible tvOS version for target simulators and devices. If unspecified, uses 'tvos_sdk_version'. +: Minimum compatible tvOS version for target simulators and devices. If unspecified, uses 'tvos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -3044,13 +3017,13 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--watchos_minimum_os=` default: see description -: Minimum compatible watchOS version for target simulators and devices. If unspecified, uses 'watchos_sdk_version'. +: Minimum compatible watchOS version for target simulators and devices. If unspecified, uses 'watchos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--xbinary_fdo=` default: see description -: Use XbinaryFDO profile information to optimize compilation. Specify the name of default cross binary profile. When the option is used together with --fdo_instrument/--fdo_optimize/--fdo_profile, those options will always prevail as if xbinary_fdo is never specified. +: Use XbinaryFDO profile information to optimize compilation. Specify the name of default cross binary profile. When the option is used together with --fdo\_instrument/--fdo\_optimize/--fdo\_profile, those options will always prevail as if xbinary\_fdo is never specified. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -3081,14 +3054,20 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) +`--[no]experimental_check_desugar_deps` default: "true" +: Whether to double-check correct desugaring at Android binary level. + + Tags: + [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_enforce_transitive_visibility` default: "false" -: If true, enable package()s to set the transitive_visibility attribute to restrict which packages may depend on them. +: If true, enable package()s to set the transitive\_visibility attribute to restrict which packages may depend on them. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--experimental_one_version_enforcement=` default: "OFF" -: When enabled, enforce that a java_binary rule can't contain more than one version of the same class file on the classpath. This enforcement can break the build, or can just result in warnings. +: When enabled, enforce that a java\_binary rule can't contain more than one version of the same class file on the classpath. This enforcement can break the build, or can just result in warnings. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -3105,26 +3084,26 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) -`--[no]incompatible_disable_native_apple_binary_rule` default: "false" -: No-op. Kept here for backwards compatibility. +`--[no]incompatible_disable_native_android_rules` default: "false" +: If enabled, direct usage of the native Android rules is disabled. Please use the Starlark Android rules from https://github.com/bazelbuild/rules\_android Tags: - [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE), [`deprecated`](#metadata_tag_DEPRECATED) + [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]one_version_enforcement_on_java_tests` default: "true" -: When enabled, and with experimental_one_version_enforcement set to a non-NONE value, enforce one version on java_test targets. This flag can be disabled to improve incremental test performance at the expense of missing potential one version violations. +: When enabled, and with experimental\_one\_version\_enforcement set to a non-NONE value, enforce one version on java\_test targets. This flag can be disabled to improve incremental test performance at the expense of missing potential one version violations. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--strict_proto_deps=` default: "error" -: Unless OFF, checks that a proto_library target explicitly declares all directly used targets as dependencies. +: Unless OFF, checks that a proto\_library target explicitly declares all directly used targets as dependencies. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--strict_public_imports=` default: "off" -: Unless OFF, checks that a proto_library target explicitly declares all targets used in 'import public' as exported. +: Unless OFF, checks that a proto\_library target explicitly declares all targets used in 'import public' as exported. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -3147,7 +3126,7 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Options that affect the signing outputs of a build: -`--apk_signing_method=` default: "v1_v2" +`--apk_signing_method=` default: "v1\_v2" : Implementation to use to sign APKs Tags: @@ -3162,13 +3141,13 @@ Options that affect the signing outputs of a build: This option affects semantics of the Starlark language or the build API accessible to BUILD files, .bzl files, or WORKSPACE files.: `--[no]incompatible_disallow_sdk_frameworks_attributes` default: "false" -: If true, disallow sdk_frameworks and weak_sdk_frameworks attributes in objc_library and objc_import. +: If true, disallow sdk\_frameworks and weak\_sdk\_frameworks attributes in objc\_library and objc\_import. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_objc_alwayslink_by_default` default: "false" -: If true, make the default value true for alwayslink attributes in objc_library and objc_import. +: If true, make the default value true for alwayslink attributes in objc\_library and objc\_import. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -3202,6 +3181,24 @@ Options that govern the behavior of the test environment or test runner: The default test resources specified by this flag are overridden by explicit resources specified in tags. +`--[no]experimental_android_use_parallel_dex2oat` default: "false" +: Use dex2oat in parallel to possibly speed up android\_test. + + Tags: + [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS), [`experimental`](#metadata_tag_EXPERIMENTAL) + +`--ios_simulator_device=` default: see description +: The device to simulate when running an iOS application in the simulator, e.g. 'iPhone 6'. You can get a list of devices by running 'xcrun simctl list devicetypes' on the machine the simulator will be run on. + + Tags: + [`test_runner`](#effect_tag_TEST_RUNNER) + +`--ios_simulator_version=` default: see description +: The version of iOS to run on the simulator when running or testing. This is ignored for ios\_test rules if a target device is specified in the rule. + + Tags: + [`test_runner`](#effect_tag_TEST_RUNNER) + `--runs_per_test=` multiple uses are accumulated : Specifies number of times to run each test. If any of those attempts fail for any reason, the whole test is considered failed. Normally the value specified is @@ -3211,7 +3208,7 @@ Options that govern the behavior of the test environment or test runner: Alternate syntax: `regex_filter@runs_per_test`. Where `runs_per_test` stands for an integer value and `regex_filter` stands for a list of include and exclude - regular expression patterns (Also see --instrumentation_filter). + regular expression patterns (Also see --instrumentation\_filter). Example: `--runs_per_test=//foo/.*,-//foo/bar/.*@3` runs all tests in `//foo/` except those under `//foo/bar` three times. This option can be passed multiple times. The most @@ -3257,6 +3254,12 @@ Options that trigger optimizations of the build time: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]experimental_filter_library_jar_with_program_jar` default: "false" +: Filter the ProGuard ProgramJar to remove any classes also present in the LibraryJar. + + Tags: + [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_inmemory_dotd_files` default: "true" : If enabled, C++ .d files will be passed through in memory directly from the remote build nodes instead of being written to disk. @@ -3284,6 +3287,12 @@ Options that trigger optimizations of the build time: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]incremental_dexing` default: "true" +: Does most of the work for dexing separately for each Jar file. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) + `--[no]objc_use_dotd_pruning` default: "true" : If set, .d files emitted by clang will be used to prune the set of inputs passed into objc compiles. @@ -3366,11 +3375,8 @@ Miscellaneous options, not otherwise categorized.: Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) -`--experimental_turbine_cpu_reservation=` default: "1" -: The number of CPUs to reserve for Turbine. - `--[no]explicit_java_test_deps` default: "false" -: Explicitly specify a dependency to JUnit or Hamcrest in a java_test instead of accidentally obtaining from the TestRunner's deps. Only works for bazel right now. +: Explicitly specify a dependency to JUnit or Hamcrest in a java\_test instead of accidentally obtaining from the TestRunner's deps. Only works for bazel right now. `--host_java_launcher=` default: see description : The Java launcher used by tools that are executed during a build. @@ -3379,7 +3385,7 @@ Miscellaneous options, not otherwise categorized.: : Additional options to pass to javac when building tools that are executed during a build. `--host_jvmopt=` multiple uses are accumulated -: Additional options to pass to the Java VM when building tools that are executed during the build. These options will get added to the VM startup options of each java_binary target. +: Additional options to pass to the Java VM when building tools that are executed during the build. These options will get added to the VM startup options of each java\_binary target. `--[no]incompatible_exclusive_test_sandboxed` default: "true" : If true, exclusive tests will run with sandboxed strategy. Add `local` tag to force @@ -3401,7 +3407,7 @@ Miscellaneous options, not otherwise categorized.: : Additional options to pass to the J2ObjC tool. `--java_debug` -: Causes the Java virtual machine of a java test to wait for a connection from a JDWP-compliant debugger (such as jdb) before starting the test. Implies -test_output=streamed. +: Causes the Java virtual machine of a java test to wait for a connection from a JDWP-compliant debugger (such as jdb) before starting the test. Implies -test\_output=streamed. Expands to: @@ -3427,14 +3433,14 @@ Miscellaneous options, not otherwise categorized.: `--java_launcher=` default: see description : The Java launcher to use when building Java binaries. If this flag is set to the empty string, the JDK launcher is used. The "launcher" attribute overrides this flag. -`--java_runtime_version=` default: "local_jdk" +`--java_runtime_version=` default: "local\_jdk" : The Java runtime version `--javacopt=` multiple uses are accumulated : Additional options to pass to javac. `--jvmopt=` multiple uses are accumulated -: Additional options to pass to the Java VM. These options will get added to the VM startup options of each java_binary target. +: Additional options to pass to the Java VM. These options will get added to the VM startup options of each java\_binary target. `--legacy_main_dex_list_generator=` default: see description : Specifies a binary to use to generate the list of classes that must be in the main dex when compiling legacy multidex. @@ -3443,43 +3449,43 @@ Miscellaneous options, not otherwise categorized.: : Specifies a binary to use to do dexing without sharding. `--plugin=` multiple uses are accumulated -: Plugins to use in the build. Currently works with java_plugin. +: Plugins to use in the build. Currently works with java\_plugin. `--proguard_top=` default: see description : Specifies which version of ProGuard to use for code removal when building a Java binary. -`--proto_compiler=` default: "@bazel_tools//tools/proto:protoc" +`--proto_compiler=` default: "@bazel\_tools//tools/proto:protoc" : The label of the proto-compiler. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--[no]proto_profile` default: "true" -: Whether to pass profile_path to the proto compiler. +: Whether to pass profile\_path to the proto compiler. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--proto_profile_path=` default: see description -: The profile to pass to the proto compiler as profile_path. If unset, but --proto_profile is true (the default), infers the path from --fdo_optimize. +: The profile to pass to the proto compiler as profile\_path. If unset, but --proto\_profile is true (the default), infers the path from --fdo\_optimize. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_cc=` default: "@bazel_tools//tools/proto:cc_toolchain" -: Label of proto_lang_toolchain() which describes how to compile C++ protos +`--proto_toolchain_for_cc=` default: "@bazel\_tools//tools/proto:cc\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile C++ protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_java=` default: "@bazel_tools//tools/proto:java_toolchain" -: Label of proto_lang_toolchain() which describes how to compile Java protos +`--proto_toolchain_for_java=` default: "@bazel\_tools//tools/proto:java\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile Java protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_javalite=` default: "@bazel_tools//tools/proto:javalite_toolchain" -: Label of proto_lang_toolchain() which describes how to compile JavaLite protos +`--proto_toolchain_for_javalite=` default: "@bazel\_tools//tools/proto:javalite\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile JavaLite protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -3521,9 +3527,6 @@ Miscellaneous options, not otherwise categorized.: `--test_result_expiration=` default: "-1" : This option is deprecated and has no effect. - Tags: - [`deprecated`](#metadata_tag_DEPRECATED) - `--[no]test_runner_fail_fast` default: "false" : Forwards fail fast option to the test runner. The test runner should stop execution upon first failure. @@ -3539,7 +3542,7 @@ Miscellaneous options, not otherwise categorized.: `--tool_java_language_version=` default: "" : The Java language version used to execute the tools that are needed during a build -`--tool_java_runtime_version=` default: "remotejdk_11" +`--tool_java_runtime_version=` default: "remotejdk\_11" : The Java runtime version used to execute tools during the build `--[no]use_ijars` default: "true" @@ -3589,13 +3592,13 @@ Options that control build execution: [`execution`](#effect_tag_EXECUTION), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--dynamic_local_strategy=` multiple uses are accumulated -: The local strategies, in order, to use for the given mnemonic - the first applicable strategy is used. For example, `worker,sandboxed` runs actions that support persistent workers using the worker strategy, and all others using the sandboxed strategy. If no mnemonic is given, the list of strategies is used as the fallback for all mnemonics. The default fallback list is `worker,sandboxed`, or`worker,sandboxed,standalone` if `experimental_local_lockfree_output` is set. Takes [mnemonic=]local_strategy[,local_strategy,...] +: The local strategies, in order, to use for the given mnemonic - the first applicable strategy is used. For example, `worker,sandboxed` runs actions that support persistent workers using the worker strategy, and all others using the sandboxed strategy. If no mnemonic is given, the list of strategies is used as the fallback for all mnemonics. The default fallback list is `worker,sandboxed`, or`worker,sandboxed,standalone` if `experimental_local_lockfree_output` is set. Takes [mnemonic=]local\_strategy[,local\_strategy,...] Tags: [`execution`](#effect_tag_EXECUTION), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--dynamic_remote_strategy=` multiple uses are accumulated -: The remote strategies, in order, to use for the given mnemonic - the first applicable strategy is used. If no mnemonic is given, the list of strategies is used as the fallback for all mnemonics. The default fallback list is `remote`, so this flag usually does not need to be set explicitly. Takes [mnemonic=]remote_strategy[,remote_strategy,...] +: The remote strategies, in order, to use for the given mnemonic - the first applicable strategy is used. If no mnemonic is given, the list of strategies is used as the fallback for all mnemonics. The default fallback list is `remote`, so this flag usually does not need to be set explicitly. Takes [mnemonic=]remote\_strategy[,remote\_strategy,...] Tags: [`execution`](#effect_tag_EXECUTION), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) @@ -3615,7 +3618,7 @@ Options that control build execution: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS), [`execution`](#effect_tag_EXECUTION) `--experimental_docker_image=` default: "" -: Specify a Docker image name (e.g. "ubuntu:latest") that should be used to execute a sandboxed action when using the docker strategy and the action itself doesn't already have a container-image attribute in its exec_properties in the platform description. The value of this flag is passed verbatim to 'docker run', so it supports the same syntax and mechanisms as Docker itself. +: Specify a Docker image name (e.g. "ubuntu:latest") that should be used to execute a sandboxed action when using the docker strategy and the action itself doesn't already have a container-image attribute in its exec\_properties in the platform description. The value of this flag is passed verbatim to 'docker run', so it supports the same syntax and mechanisms as Docker itself. Tags: [`execution`](#effect_tag_EXECUTION) @@ -3633,14 +3636,14 @@ Options that control build execution: [`execution`](#effect_tag_EXECUTION), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--experimental_dynamic_local_load_factor=` default: "0" -: Controls how much load from dynamic execution to put on the local machine. This flag adjusts how many actions in dynamic execution we will schedule concurrently. It is based on the number of CPUs Blaze thinks is available, which can be controlled with the --local_resources=cpu= flag. - If this flag is 0, all actions are scheduled locally immediately. If > 0, the amount of actions scheduled locally is limited by the number of CPUs available. If < 1, the load factor is used to reduce the number of locally scheduled actions when the number of actions waiting to schedule is high. This lessens the load on the local machine in the clean build case, where the local machine does not contribute much. +: Controls how much load from dynamic execution to put on the local machine. This flag adjusts how many actions in dynamic execution we will schedule concurrently. It is based on the number of CPUs Blaze thinks is available, which can be controlled with the --local\_resources=cpu= flag. + If this flag is 0, all actions are scheduled locally immediately. If > 0, the amount of actions scheduled locally is limited by the number of CPUs available. If < 1, the load factor is used to reduce the number of locally scheduled actions when the number of actions waiting to schedule is high. This lessens the load on the local machine in the clean build case, where the local machine does not contribute much. Tags: [`execution`](#effect_tag_EXECUTION), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--experimental_dynamic_slow_remote_time=` default: "0" -: If >0, the time a dynamically run action must run remote-only before we prioritize its local execution to avoid remote timeouts. This may hide some problems on the remote execution system. Do not turn this on without monitoring of remote execution issues. +: If >0, the time a dynamically run action must run remote-only before we prioritize its local execution to avoid remote timeouts. This may hide some problems on the remote execution system. Do not turn this on without monitoring of remote execution issues. Tags: [`execution`](#effect_tag_EXECUTION), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) @@ -3652,7 +3655,7 @@ Options that control build execution: [`execution`](#effect_tag_EXECUTION) `--[no]experimental_inmemory_sandbox_stashes` default: "false" -: If set to true, the contents of stashed sandboxes for reuse_sandbox_directories will be tracked in memory. This reduces the amount of I/O needed during reuse. Depending on the build this flag may improve wall time. Depending on the build as well this flag may use a significant amount of additional memory. +: If set to true, the contents of stashed sandboxes for reuse\_sandbox\_directories will be tracked in memory. This reduces the amount of I/O needed during reuse. Depending on the build this flag may improve wall time. Depending on the build as well this flag may use a significant amount of additional memory. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS), [`execution`](#effect_tag_EXECUTION) @@ -3664,25 +3667,25 @@ Options that control build execution: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS), [`execution`](#effect_tag_EXECUTION) `--experimental_sandbox_enforce_resources_regexp=` default: "" -: If true, actions whose mnemonic matches the input regex will have their resources request enforced as limits, overriding the value of --experimental_sandbox_limits, if the resource type supports it. For example a test that declares cpu:3 and resources:memory:10, will run with at most 3 cpus and 10 megabytes of memory. +: If true, actions whose mnemonic matches the input regex will have their resources request enforced as limits, overriding the value of --experimental\_sandbox\_limits, if the resource type supports it. For example a test that declares cpu:3 and resources:memory:10, will run with at most 3 cpus and 10 megabytes of memory. Tags: [`execution`](#effect_tag_EXECUTION) `--experimental_sandbox_limits=) eg. "HOST_CPUS", "HOST_CPUS*.5">` multiple uses are accumulated -: If > 0, each Linux sandbox will be limited to the given amount for the specified resource. Requires --incompatible_use_new_cgroup_implementation and overrides --experimental_sandbox_memory_limit_mb. Requires cgroups v1 or v2 and permissions for the users to the cgroups dir. +: If > 0, each Linux sandbox will be limited to the given amount for the specified resource. Requires --incompatible\_use\_new\_cgroup\_implementation and overrides --experimental\_sandbox\_memory\_limit\_mb. Requires cgroups v1 or v2 and permissions for the users to the cgroups dir. Tags: [`execution`](#effect_tag_EXECUTION) `--experimental_sandbox_memory_limit_mb=.>` default: "0" -: If > 0, each Linux sandbox will be limited to the given amount of memory (in MB). Requires cgroups v1 or v2 and permissions for the users to the cgroups dir. +: If > 0, each Linux sandbox will be limited to the given amount of memory (in MB). Requires cgroups v1 or v2 and permissions for the users to the cgroups dir. Tags: [`execution`](#effect_tag_EXECUTION) `--[no]experimental_shrink_worker_pool` default: "false" -: If enabled, could shrink worker pool if worker memory pressure is high. This flag works only when flag experimental_total_worker_memory_limit_mb is enabled. +: If enabled, could shrink worker pool if worker memory pressure is high. This flag works only when flag experimental\_total\_worker\_memory\_limit\_mb is enabled. Tags: [`execution`](#effect_tag_EXECUTION), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) @@ -3694,19 +3697,19 @@ Options that control build execution: [`execution`](#effect_tag_EXECUTION), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--[no]experimental_use_hermetic_linux_sandbox` default: "false" -: If set to true, do not mount root, only mount whats provided with sandbox_add_mount_pair. Input files will be hardlinked to the sandbox instead of symlinked to from the sandbox. If action input files are located on a filesystem different from the sandbox, then the input files will be copied instead. +: If set to true, do not mount root, only mount whats provided with sandbox\_add\_mount\_pair. Input files will be hardlinked to the sandbox instead of symlinked to from the sandbox. If action input files are located on a filesystem different from the sandbox, then the input files will be copied instead. Tags: [`execution`](#effect_tag_EXECUTION) `--[no]experimental_use_windows_sandbox` default: "false" -: Use Windows sandbox to run actions. If "yes", the binary provided by --experimental_windows_sandbox_path must be valid and correspond to a supported version of sandboxfs. If "auto", the binary may be missing or not compatible. +: Use Windows sandbox to run actions. If "yes", the binary provided by --experimental\_windows\_sandbox\_path must be valid and correspond to a supported version of sandboxfs. If "auto", the binary may be missing or not compatible. Tags: [`execution`](#effect_tag_EXECUTION) `--experimental_windows_sandbox_path=` default: "BazelSandbox.exe" -: Path to the Windows sandbox binary to use when --experimental_use_windows_sandbox is true. If a bare name, use the first binary of that name found in the PATH. +: Path to the Windows sandbox binary to use when --experimental\_use\_windows\_sandbox is true. If a bare name, use the first binary of that name found in the PATH. Tags: [`execution`](#effect_tag_EXECUTION) @@ -3760,13 +3763,13 @@ Options that control build execution: [`execution`](#effect_tag_EXECUTION) `--genrule_strategy=` default: "" -: Specify how to execute genrules. This flag will be phased out. Instead, use --spawn_strategy=<value> to control all actions or --strategy=Genrule=<value> to control genrules only. +: Specify how to execute genrules. This flag will be phased out. Instead, use --spawn\_strategy= to control all actions or --strategy=Genrule= to control genrules only. Tags: [`execution`](#effect_tag_EXECUTION) `--[no]incompatible_use_new_cgroup_implementation` default: "true" -: If true, use the new implementation for cgroups. The old implementation only supports the memory controller and ignores the value of --experimental_sandbox_limits. +: If true, use the new implementation for cgroups. The old implementation only supports the memory controller and ignores the value of --experimental\_sandbox\_limits. Tags: [`execution`](#effect_tag_EXECUTION) @@ -3778,7 +3781,7 @@ Options that control build execution: [`execution`](#effect_tag_EXECUTION), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--jobs=) eg. "auto", "HOST_CPUS*.5">` [`-j`] default: "auto" -: The number of concurrent jobs to run. Takes an integer, or a keyword ("auto", "HOST_CPUS", "HOST_RAM"), optionally followed by an operation ([-|*]<float>) eg. "auto", "HOST_CPUS*.5". Values must be between 1 and 5000. Values above 2500 may cause memory issues. "auto" calculates a reasonable default based on host resources. +: The number of concurrent jobs to run. Takes an integer, or a keyword ("auto", "HOST\_CPUS", "HOST\_RAM"), optionally followed by an operation ([-|*]) eg. "auto", "HOST\_CPUS*.5". Values must be between 1 and 5000. Values above 2500 may cause memory issues. "auto" calculates a reasonable default based on host resources. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS), [`execution`](#effect_tag_EXECUTION) @@ -3790,7 +3793,7 @@ Options that control build execution: [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT) `--loading_phase_threads=) eg. "auto", "HOST_CPUS*.5">` default: "auto" -: Number of parallel threads to use for the loading/analysis phase.Takes an integer, or a keyword ("auto", "HOST_CPUS", "HOST_RAM"), optionally followed by an operation ([-|*]<float>) eg. "auto", "HOST_CPUS*.5". "auto" sets a reasonable default based on host resources. Must be at least 1. +: Number of parallel threads to use for the loading/analysis phase.Takes an integer, or a keyword ("auto", "HOST\_CPUS", "HOST\_RAM"), optionally followed by an operation ([-|*]) eg. "auto", "HOST\_CPUS*.5". "auto" sets a reasonable default based on host resources. Must be at least 1. Tags: [`bazel_internal_configuration`](#effect_tag_BAZEL_INTERNAL_CONFIGURATION) @@ -3840,31 +3843,31 @@ Options that control build execution: [`execution`](#effect_tag_EXECUTION) `--strategy=` multiple uses are accumulated -: Specify how to distribute compilation of other spawn actions. Accepts a comma-separated list of strategies from highest to lowest priority. For each action Bazel picks the strategy with the highest priority that can execute the action. The default value is "remote,worker,sandboxed,local". This flag overrides the values set by --spawn_strategy (and --genrule_strategy if used with mnemonic Genrule). See https://blog.bazel.build/2019/06/19/list-strategy.html for details. +: Specify how to distribute compilation of other spawn actions. Accepts a comma-separated list of strategies from highest to lowest priority. For each action Bazel picks the strategy with the highest priority that can execute the action. The default value is "remote,worker,sandboxed,local". This flag overrides the values set by --spawn\_strategy (and --genrule\_strategy if used with mnemonic Genrule). See https://blog.bazel.build/2019/06/19/list-strategy.html for details. Tags: [`execution`](#effect_tag_EXECUTION) `--strategy_regexp==value[,value]' assignment>` multiple uses are accumulated -: Override which spawn strategy should be used to execute spawn actions that have descriptions matching a certain regex_filter. See --per_file_copt for details on regex_filter matching. The last regex_filter that matches the description is used. This option overrides other flags for specifying strategy. Example: --strategy_regexp=//foo.*.cc,-//foo/bar=local means to run actions using local strategy if their descriptions match //foo.*.cc but not //foo/bar. Example: --strategy_regexp='Compiling.\*/bar=local --strategy_regexp=Compiling=sandboxed will run 'Compiling //foo/bar/baz' with the 'local' strategy, but reversing the order would run it with 'sandboxed'. +: Override which spawn strategy should be used to execute spawn actions that have descriptions matching a certain regex\_filter. See --per\_file\_copt for details onregex\_filter matching. The last regex\_filter that matches the description is used. This option overrides other flags for specifying strategy. Example: --strategy\_regexp=//foo.*.cc,-//foo/bar=local means to run actions using local strategy if their descriptions match //foo.*.cc but not //foo/bar. Example: --strategy\_regexp='Compiling.\*/bar=local --strategy\_regexp=Compiling=sandboxed will run 'Compiling //foo/bar/baz' with the 'local' strategy, but reversing the order would run it with 'sandboxed'. Tags: [`execution`](#effect_tag_EXECUTION) `--worker_extra_flag=` multiple uses are accumulated -: Extra command-flags that will be passed to worker processes in addition to --persistent_worker, keyed by mnemonic (e.g. --worker_extra_flag=Javac=--debug. +: Extra command-flags that will be passed to worker processes in addition to --persistent\_worker, keyed by mnemonic (e.g. --worker\_extra\_flag=Javac=--debug. Tags: [`execution`](#effect_tag_EXECUTION), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--worker_max_instances=<[name=]value, where value is an integer, or a keyword ("auto", "HOST_CPUS", "HOST_RAM"), optionally followed by an operation ([-|*]) eg. "auto", "HOST_CPUS*.5">` multiple uses are accumulated -: How many instances of each kind of persistent worker may be launched if you use the 'worker' strategy. May be specified as [name=value] to give a different value per mnemonic. The limit is based on worker keys, which are differentiated based on mnemonic, but also on startup flags and environment, so there can in some cases be more workers per mnemonic than this flag specifies. Takes an integer, or a keyword ("auto", "HOST_CPUS", "HOST_RAM"), optionally followed by an operation ([-|*]<float>) eg. "auto", "HOST_CPUS*.5". 'auto' calculates a reasonable default based on machine capacity. "=value" sets a default for unspecified mnemonics. +: How many instances of each kind of persistent worker may be launched if you use the 'worker' strategy. May be specified as [name=value] to give a different value per mnemonic. The limit is based on worker keys, which are differentiated based on mnemonic, but also on startup flags and environment, so there can in some cases be more workers per mnemonic than this flag specifies. Takes an integer, or a keyword ("auto", "HOST\_CPUS", "HOST\_RAM"), optionally followed by an operation ([-|*]) eg. "auto", "HOST\_CPUS*.5". 'auto' calculates a reasonable default based on machine capacity. "=value" sets a default for unspecified mnemonics. Tags: [`execution`](#effect_tag_EXECUTION), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--worker_max_multiplex_instances=<[name=]value, where value is an integer, or a keyword ("auto", "HOST_CPUS", "HOST_RAM"), optionally followed by an operation ([-|*]) eg. "auto", "HOST_CPUS*.5">` multiple uses are accumulated -: How many WorkRequests a multiplex worker process may receive in parallel if you use the 'worker' strategy with --worker_multiplex. May be specified as [name=value] to give a different value per mnemonic. The limit is based on worker keys, which are differentiated based on mnemonic, but also on startup flags and environment, so there can in some cases be more workers per mnemonic than this flag specifies. Takes an integer, or a keyword ("auto", "HOST_CPUS", "HOST_RAM"), optionally followed by an operation ([-|*]<float>) eg. "auto", "HOST_CPUS*.5". 'auto' calculates a reasonable default based on machine capacity. "=value" sets a default for unspecified mnemonics. +: How many WorkRequests a multiplex worker process may receive in parallel if you use the 'worker' strategy with --worker\_multiplex. May be specified as [name=value] to give a different value per mnemonic. The limit is based on worker keys, which are differentiated based on mnemonic, but also on startup flags and environment, so there can in some cases be more workers per mnemonic than this flag specifies. Takes an integer, or a keyword ("auto", "HOST\_CPUS", "HOST\_RAM"), optionally followed by an operation ([-|*]) eg. "auto", "HOST\_CPUS*.5". 'auto' calculates a reasonable default based on machine capacity. "=value" sets a default for unspecified mnemonics. Tags: [`execution`](#effect_tag_EXECUTION), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) @@ -3981,7 +3984,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--remote_download_all` -: Downloads all remote outputs to the local machine. This flag is an alias for --remote_download_outputs=all. +: Downloads all remote outputs to the local machine. This flag is an alias for --remote\_download\_outputs=all. Expands to: @@ -3991,7 +3994,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--remote_download_minimal` -: Does not download any remote build outputs to the local machine. This flag is an alias for --remote_download_outputs=minimal. +: Does not download any remote build outputs to the local machine. This flag is an alias for --remote\_download\_outputs=minimal. Expands to: @@ -4007,13 +4010,13 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--remote_download_symlink_template=` default: "" -: Instead of downloading remote build outputs to the local machine, create symbolic links. The target of the symbolic links can be specified in the form of a template string. This template string may contain {hash} and {size_bytes} that expand to the hash of the object and the size in bytes, respectively. These symbolic links may, for example, point to a FUSE file system that loads objects from the CAS on demand. +: Instead of downloading remote build outputs to the local machine, create symbolic links. The target of the symbolic links can be specified in the form of a template string. This template string may contain {hash} and {size\_bytes} that expand to the hash of the object and the size in bytes, respectively. These symbolic links may, for example, point to a FUSE file system that loads objects from the CAS on demand. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--remote_download_toplevel` -: Only downloads remote outputs of top level targets to the local machine. This flag is an alias for --remote_download_outputs=toplevel. +: Only downloads remote outputs of top level targets to the local machine. This flag is an alias for --remote\_download\_outputs=toplevel. Expands to: @@ -4085,13 +4088,13 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit This option affects semantics of the Starlark language or the build API accessible to BUILD files, .bzl files, or WORKSPACE files.: `--[no]incompatible_config_setting_private_default_visibility` default: "false" -: If incompatible_enforce_config_setting_visibility=false, this is a noop. Else, if this flag is false, any config_setting without an explicit visibility attribute is //visibility:public. If this flag is true, config_setting follows the same visibility logic as all other rules. See https://github.com/bazelbuild/bazel/issues/12933. +: If incompatible\_enforce\_config\_setting\_visibility=false, this is a noop. Else, if this flag is false, any config\_setting without an explicit visibility attribute is //visibility:public. If this flag is true, config\_setting follows the same visibility logic as all other rules. See https://github.com/bazelbuild/bazel/issues/12933. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_enforce_config_setting_visibility` default: "true" -: If true, enforce config_setting visibility restrictions. If false, every config_setting is visible to every target. See https://github.com/bazelbuild/bazel/issues/12932. +: If true, enforce config\_setting visibility restrictions. If false, every config\_setting is visible to every target. See https://github.com/bazelbuild/bazel/issues/12932. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -4099,19 +4102,19 @@ This option affects semantics of the Starlark language or the build API accessib Options that govern the behavior of the test environment or test runner: `--[no]check_tests_up_to_date` default: "false" -: Don't run tests, just check if they are up-to-date. If all tests results are up-to-date, the testing completes successfully. If any test needs to be built or executed, an error is reported and the testing fails. This option implies --check_up_to_date behavior. +: Don't run tests, just check if they are up-to-date. If all tests results are up-to-date, the testing completes successfully. If any test needs to be built or executed, an error is reported and the testing fails. This option implies --check\_up\_to\_date behavior. Tags: [`execution`](#effect_tag_EXECUTION) `--flaky_test_attempts=` multiple uses are accumulated -: Each test will be retried up to the specified number of times in case of any test failure. Tests that required more than one attempt to pass are marked as 'FLAKY' in the test summary. Normally the value specified is just an integer or the string 'default'. If an integer, then all tests will be run up to N times. If 'default', then only a single test attempt will be made for regular tests and three for tests marked explicitly as flaky by their rule (flaky=1 attribute). Alternate syntax: regex_filter@flaky_test_attempts. Where flaky_test_attempts is as above and regex_filter stands for a list of include and exclude regular expression patterns (Also see --runs_per_test). Example: --flaky_test_attempts=//foo/.*,-//foo/bar/.*@3 deflakes all tests in //foo/ except those under foo/bar three times. This option can be passed multiple times. The most recently passed argument that matches takes precedence. If nothing matches, behavior is as if 'default' above. +: Each test will be retried up to the specified number of times in case of any test failure. Tests that required more than one attempt to pass are marked as 'FLAKY' in the test summary. Normally the value specified is just an integer or the string 'default'. If an integer, then all tests will be run up to N times. If 'default', then only a single test attempt will be made for regular tests and three for tests marked explicitly as flaky by their rule (flaky=1 attribute). Alternate syntax: regex\_filter@flaky\_test\_attempts. Where flaky\_test\_attempts is as above and regex\_filter stands for a list of include and exclude regular expression patterns (Also see --runs\_per\_test). Example: --flaky\_test\_attempts=//foo/.*,-//foo/bar/.*@3 deflakes all tests in //foo/ except those under foo/bar three times. This option can be passed multiple times. The most recently passed argument that matches takes precedence. If nothing matches, behavior is as if 'default' above. Tags: [`execution`](#effect_tag_EXECUTION) `--local_test_jobs=) eg. "auto", "HOST_CPUS*.5">` default: "auto" -: The max number of local test jobs to run concurrently. Takes an integer, or a keyword ("auto", "HOST_CPUS", "HOST_RAM"), optionally followed by an operation ([-|*]<float>) eg. "auto", "HOST_CPUS*.5". 0 means local resources will limit the number of local test jobs to run concurrently instead. Setting this greater than the value for --jobs is ineffectual. +: The max number of local test jobs to run concurrently. Takes an integer, or a keyword ("auto", "HOST\_CPUS", "HOST\_RAM"), optionally followed by an operation ([-|*]) eg. "auto", "HOST\_CPUS*.5". 0 means local resources will limit the number of local test jobs to run concurrently instead. Setting this greater than the value for --jobs is ineffectual. Tags: [`execution`](#effect_tag_EXECUTION) @@ -4143,7 +4146,7 @@ Options that trigger optimizations of the build time: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--[no]experimental_cpu_load_scheduling` default: "false" -: Enables the experimental local execution scheduling based on CPU load, not estimation of actions one by one. Experimental scheduling have showed the large benefit on a large local builds on a powerful machines with the large number of cores. Recommended to use with --local_resources=cpu=HOST_CPUS +: Enables the experimental local execution scheduling based on CPU load, not estimation of actions one by one. Experimental scheduling have showed the large benefit on a large local builds on a powerful machines with the large number of cores. Reccommended to use with --local\_resources=cpu=HOST\_CPUS Tags: [`execution`](#effect_tag_EXECUTION) @@ -4155,13 +4158,13 @@ Options that trigger optimizations of the build time: [`execution`](#effect_tag_EXECUTION) `--[no]experimental_enable_skyfocus` default: "false" -: If true, enable the use of --experimental_active_directories to reduce Bazel's memory footprint for incremental builds. This feature is known as Skyfocus. +: If true, enable the use of --experimental\_active\_directories to reduce Bazel's memory footprint for incremental builds. This feature is known as Skyfocus. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) `--local_resources=) eg. "HOST_CPUS", "HOST_CPUS*.5">` multiple uses are accumulated -: Set the number of resources available to Bazel. Takes in an assignment to a float or HOST_RAM/HOST_CPUS, optionally followed by [-|*]<float> (eg. memory=HOST_RAM*.5 to use half the available RAM). Can be used multiple times to specify multiple types of resources. Bazel will limit concurrently running actions based on the available resources and the resources required. Tests can declare the amount of resources they need by using a tag of the "resources:<resource name>:<amount>" format. +: Set the number of resources available to Bazel. Takes in an assignment to a float or HOST\_RAM/HOST\_CPUS, optionally followed by [-|*] (eg. memory=HOST\_RAM*.5 to use half the available RAM). Can be used multiple times to specify multiple types of resources. Bazel will limit concurrently running actions based on the available resources and the resources required. Tests can declare the amount of resources they need by using a tag of the "resources::" format. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) @@ -4272,7 +4275,7 @@ Options that affect the verbosity, format or location of logging: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]materialize_param_files` default: "false" -: Writes intermediate parameter files to output tree even when using remote action execution or caching. Useful when debugging actions. This is implied by --subcommands and --verbose_failures. +: Writes intermediate parameter files to output tree even when using remote action execution or caching. Useful when debugging actions. This is implied by --subcommands and --verbose\_failures. Tags: [`execution`](#effect_tag_EXECUTION) @@ -4284,7 +4287,7 @@ Options that affect the verbosity, format or location of logging: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--max_test_output_bytes=` default: "-1" -: Specifies maximum per-test-log size that can be emitted when --test_output is 'errors' or 'all'. Useful for avoiding overwhelming the output with excessively noisy test output. The test header is included in the log size. Negative values imply no limit. Output is all or nothing. +: Specifies maximum per-test-log size that can be emitted when --test\_output is 'errors' or 'all'. Useful for avoiding overwhelming the output with excessively noisy test output. The test header is included in the log size. Negative values imply no limit. Output is all or nothing. Tags: [`test_runner`](#effect_tag_TEST_RUNNER), [`terminal_output`](#effect_tag_TERMINAL_OUTPUT), [`execution`](#effect_tag_EXECUTION) @@ -4339,7 +4342,7 @@ Options that affect the verbosity, format or location of logging: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]subcommands` [`-s`] default: "false" -: Display the subcommands executed during a build. Related flags: --execution_log_json_file, --execution_log_binary_file (for logging subcommands to a file in a tool-friendly format). +: Display the subcommands executed during a build. Related flags: --execution\_log\_json\_file, --execution\_log\_binary\_file (for logging subcommands to a file in a tool-friendly format). Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -4414,7 +4417,7 @@ Remote caching and execution options: [`experimental`](#metadata_tag_EXPERIMENTAL) `--experimental_remote_cache_compression_threshold=` default: "100" -: The minimum blob size required to compress/decompress with zstd. Ineffectual unless --remote_cache_compression is set. +: The minimum blob size required to compress/decompress with zstd. Ineffectual unless --remote\_cache\_compression is set. `--experimental_remote_cache_eviction_retries=` default: "5" : The maximum number of attempts to retry if the build encountered a transient remote cache error that would otherwise fail the build. Applies for example when artifacts are evicted from the remote cache, or in certain cache failure conditions. A new invocation id will be generated for each attempt. @@ -4438,7 +4441,7 @@ Remote caching and execution options: : If set to true, discard in-memory copies of the input root's Merkle tree and associated input mappings during calls to GetActionResult() and Execute(). This reduces memory usage significantly, but does require Bazel to recompute them upon remote cache misses and retries. `--experimental_remote_downloader=` default: see description -: A Remote Asset API endpoint URI, to be used as a remote download proxy. The supported schemes are grpc, grpcs (grpc with TLS enabled) and unix (local UNIX sockets). If no scheme is provided Bazel will default to grpcs. See: https://github.com/bazelbuild/remote-apis/blob/master/build/bazel/remote/asset/v1/remote_asset.proto +: A Remote Asset API endpoint URI, to be used as a remote download proxy. The supported schemes are grpc, grpcs (grpc with TLS enabled) and unix (local UNIX sockets). If no scheme is provided Bazel will default to grpcs. See: https://github.com/bazelbuild/remote-apis/blob/master/build/bazel/remote/asset/v1/remote\_asset.proto `--[no]experimental_remote_downloader_local_fallback` default: "false" : Whether to fall back to the local downloader if remote downloader fails. @@ -4465,13 +4468,13 @@ Remote caching and execution options: : HOST or HOST:PORT of a remote output service endpoint. The supported schemes are grpc, grpcs (grpc with TLS enabled) and unix (local UNIX sockets). If no scheme is provided Bazel will default to grpcs. Specify grpc:// or unix: scheme to disable TLS. `--experimental_remote_output_service_output_path_prefix=` default: "" -: The path under which the contents of output directories managed by the --experimental_remote_output_service are placed. The actual output directory used by a build will be a descendant of this path and determined by the output service. +: The path under which the contents of output directories managed by the --experimental\_remote\_output\_service are placed. The actual output directory used by a build will be a descendant of this path and determined by the output service. `--[no]experimental_remote_require_cached` default: "false" : If set to true, enforce that all actions that can run remotely are cached, or else fail the build. This is useful to troubleshoot non-determinism issues as it allows checking whether actions that should be cached are actually cached without spuriously injecting new results into the cache. `--experimental_remote_scrubbing_config=` default: see description -: Enables remote cache key scrubbing with the supplied configuration file, which must be a protocol buffer in text format (see src/main/protobuf/remote_scrubbing.proto). +: Enables remote cache key scrubbing with the supplied configuration file, which must be a protocol buffer in text format (see src/main/protobuf/remote\_scrubbing.proto). This feature is intended to facilitate sharing a remote/disk cache between actions executing on different platforms but targeting the same platform. It should be used with extreme care, as improper settings may cause accidental sharing of cache entries and result in incorrect builds. @@ -4479,7 +4482,7 @@ Remote caching and execution options: Modifying the scrubbing configuration does not invalidate outputs present in the local filesystem or internal caches; a clean build is required to reexecute affected actions. - In order to successfully use this feature, you likely want to set a custom --host_platform together with --experimental_platform_in_output_dir (to normalize output prefixes). + In order to successfully use this feature, you likely want to set a custom --host\_platform together with --experimental\_platform\_in\_output\_dir (to normalize output prefixes). `--[no]guard_against_concurrent_changes` default: "lite" : Set this to 'full' to enable checking the ctime of all input files of an action before uploading it to a remote cache. There may be cases where the Linux kernel delays writing of files, which could cause false positives. The default is 'lite', which only checks source files in the main repository. Setting this to 'off' disables all checks. This is not recommended, as the cache may be polluted when a source file is changed while an action that takes it as an input is executing. @@ -4488,7 +4491,7 @@ Remote caching and execution options: [`execution`](#effect_tag_EXECUTION) `--[no]incompatible_remote_local_fallback_for_remote_cache` default: "false" -: Whether --remote_local_fallback applies to --remote_cache. +: Whether --remote\_local\_fallback applies to --remote\_cache. `--[no]remote_accept_cached` default: "true" : Whether to accept remotely cached action results. @@ -4499,7 +4502,7 @@ Remote caching and execution options: Default to 'minimal'. `--remote_bytestream_uri_prefix=` default: see description -: The hostname and instance name to be used in bytestream:// URIs that are written into build event streams. This option can be set when builds are performed using a proxy, which causes the values of --remote_executor and --remote_instance_name to no longer correspond to the canonical name of the remote execution service. When not set, it will default to "${hostname}/${instance_name}". +: The hostname and instance name to be used in bytestream:// URIs that are written into build event streams. This option can be set when builds are performed using a proxy, which causes the values of --remote\_executor and --remote\_instance\_name to no longer correspond to the canonical name of the remote execution service. When not set, it will default to "${hostname}/${instance\_name}". `--remote_cache=` default: see description : A URI of a caching endpoint. The supported schemes are http, https, grpc, grpcs (grpc with TLS enabled) and unix (local UNIX sockets). If no scheme is provided Bazel will default to grpcs. Specify grpc://, http:// or unix: scheme to disable TLS. See https://bazel.build/remote/caching @@ -4508,28 +4511,28 @@ Remote caching and execution options: : If true, uploading of action results to a disk or remote cache will happen in the background instead of blocking the completion of an action. Some actions are incompatible with background uploads, and may still block even when this flag is set. `--[no]remote_cache_compression` default: "false" -: If enabled, compress/decompress cache blobs with zstd when their size is at least --experimental_remote_cache_compression_threshold. +: If enabled, compress/decompress cache blobs with zstd when their size is at least --experimental\_remote\_cache\_compression\_threshold. `--remote_cache_header=` multiple uses are accumulated -: Specify a header that will be included in cache requests: --remote_cache_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. +: Specify a header that will be included in cache requests: --remote\_cache\_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. `--remote_default_exec_properties=` multiple uses are accumulated -: Set the default exec properties to be used as the remote execution platform if an execution platform does not already set exec_properties. +: Set the default exec properties to be used as the remote execution platform if an execution platform does not already set exec\_properties. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--remote_download_regex=` multiple uses are accumulated -: Force remote build outputs whose path matches this pattern to be downloaded, irrespective of --remote_download_outputs. Multiple patterns may be specified by repeating this flag. +: Force remote build outputs whose path matches this pattern to be downloaded, irrespective of --remote\_download\_outputs. Multiple patterns may be specified by repeating this flag. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--remote_downloader_header=` multiple uses are accumulated -: Specify a header that will be included in remote downloader requests: --remote_downloader_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. +: Specify a header that will be included in remote downloader requests: --remote\_downloader\_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. `--remote_exec_header=` multiple uses are accumulated -: Specify a header that will be included in execution requests: --remote_exec_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. +: Specify a header that will be included in execution requests: --remote\_exec\_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. `--remote_execution_priority=` default: "0" : The relative priority of actions to be executed remotely. The semantics of the particular priority values are server-dependent. @@ -4541,10 +4544,10 @@ Remote caching and execution options: : If specified, a path to a file to log gRPC call related details. This log consists of a sequence of serialized com.google.devtools.build.lib.remote.logging.RemoteExecutionLog.LogEntry protobufs with each message prefixed by a varint denoting the size of the following serialized protobuf message, as performed by the method LogEntry.writeDelimitedTo(OutputStream). `--remote_header=` multiple uses are accumulated -: Specify a header that will be included in requests: --remote_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. +: Specify a header that will be included in requests: --remote\_header=Name=Value. Multiple headers can be passed by specifying the flag multiple times. Multiple values for the same name will be converted to a comma-separated list. `--remote_instance_name=` default: "" -: Value to pass as instance_name in the remote execution API. +: Value to pass as instance\_name in the remote execution API. `--[no]remote_local_fallback` default: "false" : Whether to fall back to standalone local execution strategy if remote execution fails. @@ -4552,9 +4555,6 @@ Remote caching and execution options: `--remote_local_fallback_strategy=` default: "local" : Deprecated. See https://github.com/bazelbuild/bazel/issues/7480 for details. - Tags: - [`deprecated`](#metadata_tag_DEPRECATED) - `--remote_max_concurrency_per_connection=` default: "100" : Limit the max number of concurrent requests per gRPC connection. By default the value is 100. @@ -4563,8 +4563,8 @@ Remote caching and execution options: `--remote_max_connections=` default: "100" : Limit the max number of concurrent connections to remote cache/executor. By default the value is 100. Setting this to 0 means no limitation. - For HTTP remote cache, one TCP connection could handle one request at one time, so Bazel could make up to --remote_max_connections concurrent requests. - For gRPC remote cache/executor, one gRPC channel could usually handle 100+ concurrent requests (controlled by --remote_max_concurrency_per_connection), so Bazel could make around `--remote_max_connections * 100` concurrent requests. + For HTTP remote cache, one TCP connection could handle one request at one time, so Bazel could make up to --remote\_max\_connections concurrent requests. + For gRPC remote cache/executor, one gRPC channel could usually handle 100+ concurrent requests (controlled by --remote\_max\_concurrency\_per\_connection), so Bazel could make around `--remote_max_connections * 100` concurrent requests. Tags: [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS) @@ -4601,16 +4601,16 @@ Miscellaneous options, not otherwise categorized.: [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT) `--auto_output_filter=` default: "none" -: If --output_filter is not specified, then the value for this option is used create a filter automatically. Allowed values are 'none' (filter nothing / show everything), 'all' (filter everything / show nothing), 'packages' (include output from rules in packages mentioned on the Blaze command line), and 'subpackages' (like 'packages', but also include subpackages). For the 'packages' and 'subpackages' values //java/foo and //javatests/foo are treated as one package)'. +: If --output\_filter is not specified, then the value for this option is used create a filter automatically. Allowed values are 'none' (filter nothing / show everything), 'all' (filter everything / show nothing), 'packages' (include output from rules in packages mentioned on the Blaze command line), and 'subpackages' (like 'packages', but also include subpackages). For the 'packages' and 'subpackages' values //java/foo and //javatests/foo are treated as one package)'. `--[no]build_manual_tests` default: "false" : Forces test targets tagged 'manual' to be built. 'manual' tests are excluded from processing. This option forces them to be built (but not executed). `--build_tag_filters=` default: "" -: Specifies a comma-separated list of tags. Each tag can be optionally preceded with '-' to specify excluded tags. Only those targets will be built that contain at least one included tag and do not contain any excluded tags. This option does not affect the set of tests executed with the 'test' command; those are be governed by the test filtering options, for example '--test_tag_filters' +: Specifies a comma-separated list of tags. Each tag can be optionally preceded with '-' to specify excluded tags. Only those targets will be built that contain at least one included tag and do not contain any excluded tags. This option does not affect the set of tests executed with the 'test' command; those are be governed by the test filtering options, for example '--test\_tag\_filters' `--[no]build_tests_only` default: "false" -: If specified, only \*\_test and test_suite rules will be built and other targets specified on the command line will be ignored. By default everything that was requested will be built. +: If specified, only \*\_test and test\_suite rules will be built and other targets specified on the command line will be ignored. By default everything that was requested will be built. `--combined_report=` default: "lcov" : Specifies desired cumulative coverage report type. At this point only LCOV is supported. @@ -4620,52 +4620,49 @@ Miscellaneous options, not otherwise categorized.: `--deleted_packages=` multiple uses are accumulated : A comma-separated list of names of packages which the build system will consider non-existent, even if they are visible somewhere on the package path. - Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package_path entry. Specifying --deleted_packages x/y avoids this problem. + Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package\_path entry. Specifying --deleted\_packages x/y avoids this problem. `--[no]discard_analysis_cache` default: "false" : Discard the analysis cache immediately after the analysis phase completes. Reduces memory usage by ~10%, but makes further incremental builds slower. -`--[no]disk_cache` default: see description -: A path to a directory where Bazel can read and write actions and action outputs. If the directory does not exist, it will be created. Use --disk_cache with no value (or --disk_cache=true) to use a default location under the output user root (<outputUserRoot>/cache/disk). Use --nodisk_cache or --disk_cache=false to disable. +`--disk_cache=` default: see description +: A path to a directory where Bazel can read and write actions and action outputs. If the directory does not exist, it will be created. `--embed_label=` default: "" : Embed source control revision or release label in binary -`--[no]execution_log_binary_file` default: see description -: Log the executed spawns into this file as length-delimited SpawnExec protos, according to src/main/protobuf/spawn.proto. Prefer --execution_log_compact_file, which is significantly smaller and cheaper to produce. The flag accepts boolean and string values. If string, it represents a local path. If true, then --experimental_stream_log_file_uploads must be set, whereby it will stream the execution log to remote storage. If false, then logging to the execution log is disabled. Related flags: --execution_log_compact_file (compact format; mutually exclusive), --execution_log_json_file (text JSON format; mutually exclusive), --execution_log_sort (whether to sort the execution log), --subcommands (for displaying subcommands in terminal output). +`--execution_log_binary_file=` default: see description +: Log the executed spawns into this file as length-delimited SpawnExec protos, according to src/main/protobuf/spawn.proto. Prefer --execution\_log\_compact\_file, which is significantly smaller and cheaper to produce. Related flags: --execution\_log\_compact\_file (compact format; mutually exclusive), --execution\_log\_json\_file (text JSON format; mutually exclusive), --execution\_log\_sort (whether to sort the execution log), --subcommands (for displaying subcommands in terminal output). -`--[no]execution_log_compact_file` default: see description -: Log the executed spawns into this file as length-delimited ExecLogEntry protos, according to src/main/protobuf/spawn.proto. The entire file is zstd compressed. The flag accepts boolean and string values. If string, it represents a local path. If true, then --experimental_stream_log_file_uploads must be set, whereby it will stream the execution log to remote storage. If false, then logging to the execution log is disabled. Related flags: --execution_log_binary_file (binary protobuf format; mutually exclusive), --execution_log_json_file (text JSON format; mutually exclusive), --subcommands (for displaying subcommands in terminal output). +`--execution_log_compact_file=` default: see description +: Log the executed spawns into this file as length-delimited ExecLogEntry protos, according to src/main/protobuf/spawn.proto. The entire file is zstd compressed. Related flags: --execution\_log\_binary\_file (binary protobuf format; mutually exclusive), --execution\_log\_json\_file (text JSON format; mutually exclusive), --subcommands (for displaying subcommands in terminal output). -`--[no]execution_log_json_file` default: see description -: Log the executed spawns into this file as newline-delimited JSON representations of SpawnExec protos, according to src/main/protobuf/spawn.proto. Prefer --execution_log_compact_file, which is significantly smaller and cheaper to produce. The flag accepts boolean and string values. If string, it represents a local path. If true, then --experimental_stream_log_file_uploads must be set, whereby it will stream the execution log to remote storage. If false, then logging to the execution log is disabled. Related flags: --execution_log_compact_file (compact format; mutually exclusive), --execution_log_binary_file (binary protobuf format; mutually exclusive), --execution_log_sort (whether to sort the execution log), --subcommands (for displaying subcommands in terminal output). - -`--execution_log_mnemonic_filter=` default: ".\*" -: Filter the execution log by mnemonic. Only spawns with a matching mnemonic will be logged. Supports a comma-separated list of regexes, with optional '-' prefix for exclusions. The default is to log every spawn. +`--execution_log_json_file=` default: see description +: Log the executed spawns into this file as newline-delimited JSON representations of SpawnExec protos, according to src/main/protobuf/spawn.proto. Prefer --execution\_log\_compact\_file, which is significantly smaller and cheaper to produce. Related flags: --execution\_log\_compact\_file (compact format; mutually exclusive), --execution\_log\_binary\_file (binary protobuf format; mutually exclusive), --execution\_log\_sort (whether to sort the execution log), --subcommands (for displaying subcommands in terminal output). `--[no]execution_log_sort` default: "true" : Whether to sort the execution log, making it easier to compare logs across invocations. Set to false to avoid potentially significant CPU and memory usage at the end of the invocation, at the cost of producing the log in nondeterministic execution order. Only applies to the binary and JSON formats; the compact format is never sorted. `--[no]expand_test_suites` default: "true" -: Expand test_suite targets into their constituent tests before analysis. When this flag is turned on (the default), negative target patterns will apply to the tests belonging to the test suite, otherwise they will not. Turning off this flag is useful when top-level aspects are applied at command line: then they can analyze test_suite targets. +: Expand test\_suite targets into their constituent tests before analysis. When this flag is turned on (the default), negative target patterns will apply to the tests belonging to the test suite, otherwise they will not. Turning off this flag is useful when top-level aspects are applied at command line: then they can analyze test\_suite targets. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--experimental_disk_cache_gc_idle_delay=` default: "5m" -: How long the server must remain idle before a garbage collection of the disk cache occurs. To specify the garbage collection policy, set --experimental_disk_cache_gc_max_size and/or --experimental_disk_cache_gc_max_age. +: How long the server must remain idle before a garbage collection of the disk cache occurs. To specify the garbage collection policy, set --experimental\_disk\_cache\_gc\_max\_size and/or --experimental\_disk\_cache\_gc\_max\_age. `--experimental_disk_cache_gc_max_age=` default: "0" -: If set to a positive value, the disk cache will be periodically garbage collected to remove entries older than this age. If set in conjunction with --experimental_disk_cache_gc_max_size, both criteria are applied. Garbage collection occurrs in the background once the server has become idle, as determined by the --experimental_disk_cache_gc_idle_delay flag. +: If set to a positive value, the disk cache will be periodically garbage collected to remove entries older than this age. If set in conjunction with --experimental\_disk\_cache\_gc\_max\_size, both criteria are applied. Garbage collection occurrs in the background once the server has become idle, as determined by the --experimental\_disk\_cache\_gc\_idle\_delay flag. `--experimental_disk_cache_gc_max_size=` default: "0" -: If set to a positive value, the disk cache will be periodically garbage collected to stay under this size. If set in conjunction with --experimental_disk_cache_gc_max_age, both criteria are applied. Garbage collection occurrs in the background once the server has become idle, as determined by the --experimental_disk_cache_gc_idle_delay flag. +: If set to a positive value, the disk cache will be periodically garbage collected to stay under this size. If set in conjunction with --experimental\_disk\_cache\_gc\_max\_age, both criteria are applied. Garbage collection occurrs in the background once the server has become idle, as determined by the --experimental\_disk\_cache\_gc\_idle\_delay flag. `--experimental_extra_action_filter=` default: "" -: Deprecated in favor of aspects. Filters set of targets to schedule extra_actions for. +: Deprecated in favor of aspects. Filters set of targets to schedule extra\_actions for. `--[no]experimental_extra_action_top_level_only` default: "false" -: Deprecated in favor of aspects. Only schedules extra_actions for top level targets. +: Deprecated in favor of aspects. Only schedules extra\_actions for top level targets. `--experimental_spawn_scheduler` : Enable dynamic execution by running actions locally and remotely in parallel. Bazel spawns each action locally and remotely and picks the one that completes first. If an action supports workers, the local action will be run in the persistent worker mode. To enable dynamic execution for an individual action mnemonic, use the `--internal_spawn_scheduler` and `--strategy==dynamic` flags instead. @@ -4676,9 +4673,6 @@ Miscellaneous options, not otherwise categorized.:   `--spawn_strategy=dynamic` - Tags: - [`deprecated`](#metadata_tag_DEPRECATED) - `--[no]fetch` default: "true" : Allows the command to fetch external dependencies. If set to false, the command will utilize any cached version of the dependency, and if none exists, the command will result in failure. @@ -4692,16 +4686,16 @@ Miscellaneous options, not otherwise categorized.: : If enabled, causes Bazel to print "Loading package:" messages. `--test_lang_filters=` default: "" -: Specifies a comma-separated list of test languages. Each language can be optionally preceded with '-' to specify excluded languages. Only those test targets will be found that are written in the specified languages. The name used for each language should be the same as the language prefix in the \*\_test rule, e.g. one of 'cc', 'java', 'py', etc. This option affects --build_tests_only behavior and the test command. +: Specifies a comma-separated list of test languages. Each language can be optionally preceded with '-' to specify excluded languages. Only those test targets will be found that are written in the specified languages. The name used for each language should be the same as the language prefix in the \*\_test rule, e.g. one of 'cc', 'java', 'py', etc. This option affects --build\_tests\_only behavior and the test command. `--test_size_filters=` default: "" -: Specifies a comma-separated list of test sizes. Each size can be optionally preceded with '-' to specify excluded sizes. Only those test targets will be found that contain at least one included size and do not contain any excluded sizes. This option affects --build_tests_only behavior and the test command. +: Specifies a comma-separated list of test sizes. Each size can be optionally preceded with '-' to specify excluded sizes. Only those test targets will be found that contain at least one included size and do not contain any excluded sizes. This option affects --build\_tests\_only behavior and the test command. `--test_tag_filters=` default: "" -: Specifies a comma-separated list of test tags. Each tag can be optionally preceded with '-' to specify excluded tags. Only those test targets will be found that contain at least one included tag and do not contain any excluded tags. This option affects --build_tests_only behavior and the test command. +: Specifies a comma-separated list of test tags. Each tag can be optionally preceded with '-' to specify excluded tags. Only those test targets will be found that contain at least one included tag and do not contain any excluded tags. This option affects --build\_tests\_only behavior and the test command. `--test_timeout_filters=` default: "" -: Specifies a comma-separated list of test timeouts. Each timeout can be optionally preceded with '-' to specify excluded timeouts. Only those test targets will be found that contain at least one included timeout and do not contain any excluded timeouts. This option affects --build_tests_only behavior and the test command. +: Specifies a comma-separated list of test timeouts. Each timeout can be optionally preceded with '-' to specify excluded timeouts. Only those test targets will be found that contain at least one included timeout and do not contain any excluded timeouts. This option affects --build\_tests\_only behavior and the test command. `--workspace_status_command=` default: "" : A command invoked at the beginning of the build to provide status @@ -4889,13 +4883,13 @@ Options that configure the toolchain used for action execution: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--android_manifest_merger=` default: "android" -: Selects the manifest merger to use for android_binary rules. Flag to help the transition to the Android manifest merger from the legacy merger. +: Selects the manifest merger to use for android\_binary rules. Flag to help the transition to the Android manifest merger from the legacy merger. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--android_platforms=` default: "" -: Sets the platforms that android_binary targets use. If multiple platforms are specified, then the binary is a fat APKs, which contains native binaries for each specified target platform. +: Sets the platforms that android\_binary targets use. If multiple platforms are specified, then the binary is a fat APKs, which contains native binaries for each specified target platform. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -4912,21 +4906,21 @@ Options that configure the toolchain used for action execution: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION) -`--coverage_output_generator=` default: "@bazel_tools//tools/test:lcov_merger" +`--coverage_output_generator=` default: "@bazel\_tools//tools/test:lcov\_merger" : Location of the binary that is used to postprocess raw coverage reports. This must be a binary target. Defaults to `@bazel_tools//tools/test:lcov_merger`. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--coverage_report_generator=` default: "@bazel_tools//tools/test:coverage_report_generator" +`--coverage_report_generator=` default: "@bazel\_tools//tools/test:coverage\_report\_generator" : Location of the binary that is used to generate coverage reports. This must be a binary target. Defaults to `@bazel_tools//tools/test:coverage_report_generator`. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--coverage_support=` default: "@bazel_tools//tools/test:coverage_support" +`--coverage_support=` default: "@bazel\_tools//tools/test:coverage\_support" : Location of support files that are required on the inputs of every test action that collects code coverage. Defaults to `//tools/test:coverage_support`. @@ -4940,7 +4934,7 @@ Options that configure the toolchain used for action execution: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]experimental_include_xcode_execution_requirements` default: "false" -: If set, add a "requires-xcode:{version}" execution requirement to every Xcode action. If the Xcode version has a hyphenated label, also add a "requires-xcode-label:{version_label}" execution requirement. +: If set, add a "requires-xcode:{version}" execution requirement to every Xcode action. If the Xcode version has a hyphenated label, also add a "requires-xcode-label:{version\_label}" execution requirement. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -4983,12 +4977,12 @@ Options that configure the toolchain used for action execution: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION) `--host_grte_top=` default: see description -: If specified, this setting overrides the libc top-level directory (--grte_top) for the exec configuration. +: If specified, this setting overrides the libc top-level directory (--grte\_top) for the exec configuration. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) -`--host_platform=` default: "@bazel_tools//tools:host_platform" +`--host_platform=` default: "@bazel\_tools//tools:host\_platform" : The label of a platform rule that describes the host system. Tags: @@ -5010,6 +5004,12 @@ Options that configure the toolchain used for action execution: Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) +`--[no]incompatible_cuda_compile_action` default: "false" +: Compile cuda files using the cuda-compile action in the toolchain. + + Tags: + [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) + `--[no]incompatible_dont_enable_host_nonhost_crosstool_features` default: "true" : If true, Bazel will not enable 'host' and 'nonhost' features in the c++ toolchain (see https://github.com/bazelbuild/bazel/issues/7407 for more information). @@ -5035,13 +5035,13 @@ Options that configure the toolchain used for action execution: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ios_sdk_version=` default: see description -: Specifies the version of the iOS SDK to use to build iOS applications. If unspecified, uses the default iOS SDK version from 'xcode_version'. +: Specifies the version of the iOS SDK to use to build iOS applications. If unspecified, uses the default iOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--macos_sdk_version=` default: see description -: Specifies the version of the macOS SDK to use to build macOS applications. If unspecified, uses the default macOS SDK version from 'xcode_version'. +: Specifies the version of the macOS SDK to use to build macOS applications. If unspecified, uses the default macOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -5068,19 +5068,19 @@ Options that configure the toolchain used for action execution: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--tvos_sdk_version=` default: see description -: Specifies the version of the tvOS SDK to use to build tvOS applications. If unspecified, uses the default tvOS SDK version from 'xcode_version'. +: Specifies the version of the tvOS SDK to use to build tvOS applications. If unspecified, uses the default tvOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--[no]use_platforms_in_apple_crosstool_transition` default: "false" -: Makes apple_crosstool_transition fall back to using the value of `--platforms` flag instead of legacy `--cpu` when needed. +: Makes apple\_crosstool\_transition fall back to using the value of `--platforms` flag instead of legacy `--cpu` when needed. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--watchos_sdk_version=` default: see description -: Specifies the version of the watchOS SDK to use to build watchOS applications. If unspecified, uses the default watchOS SDK version from 'xcode_version'. +: Specifies the version of the watchOS SDK to use to build watchOS applications. If unspecified, uses the default watchOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -5091,8 +5091,8 @@ Options that configure the toolchain used for action execution: Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) -`--xcode_version_config=` default: "@bazel_tools//tools/cpp:host_xcodes" -: The label of the xcode_config rule to be used for selecting the Xcode version in the build configuration. +`--xcode_version_config=` default: "@bazel\_tools//tools/cpp:host\_xcodes" +: The label of the xcode\_config rule to be used for selecting the Xcode version in the build configuration. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -5124,19 +5124,19 @@ Options that control the output of the command: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--cc_proto_library_header_suffixes=` default: ".pb.h" -: Sets the suffixes of header files that a cc_proto_library creates. +: Sets the suffixes of header files that a cc\_proto\_library creates. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--cc_proto_library_source_suffixes=` default: ".pb.cc" -: Sets the suffixes of source files that a cc_proto_library creates. +: Sets the suffixes of source files that a cc\_proto\_library creates. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--[no]experimental_proto_descriptor_sets_include_source_info` default: "false" -: Run extra actions for alternative Java api versions in a proto_library. +: Run extra actions for alternative Java api versions in a proto\_library. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -5148,7 +5148,7 @@ Options that control the output of the command: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--fission=` default: "no" -: Specifies which compilation modes use fission for C++ compilations and links. May be any combination of {'fastbuild', 'dbg', 'opt'} or the special values 'yes' to enable all modes and 'no' to disable all modes. +: Specifies which compilation modes use fission for C++ compilations and links. May be any combination of {'fastbuild', 'dbg', 'opt'} or the special values 'yes' to enable all modes and 'no' to disable all modes. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -5215,20 +5215,32 @@ Options that let the user configure the intended output, affecting its value, as Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) +`--[no]android_databinding_use_androidx` default: "true" +: Generate AndroidX-compatible data-binding files. This is only used with databinding v2. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + +`--[no]android_databinding_use_v3_4_args` default: "true" +: Use android databinding v2 with 3.4.0 argument. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--android_dynamic_mode=` default: "off" -: Determines whether C++ deps of Android rules will be linked dynamically when a cc_binary does not explicitly create a shared library. 'default' means bazel will choose whether to link dynamically. 'fully' means all libraries will be linked dynamically. 'off' means that all libraries will be linked in mostly static mode. +: Determines whether C++ deps of Android rules will be linked dynamically when a cc\_binary does not explicitly create a shared library. 'default' means bazel will choose whether to link dynamically. 'fully' means all libraries will be linked dynamically. 'off' means that all libraries will be linked in mostly static mode. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--android_manifest_merger_order=` default: "alphabetical" -: Sets the order of manifests passed to the manifest merger for Android binaries. ALPHABETICAL means manifests are sorted by path relative to the execroot. ALPHABETICAL_BY_CONFIGURATION means manifests are sorted by paths relative to the configuration directory within the output directory. DEPENDENCY means manifests are ordered with each library's manifest coming before the manifests of its dependencies. +: Sets the order of manifests passed to the manifest merger for Android binaries. ALPHABETICAL means manifests are sorted by path relative to the execroot. ALPHABETICAL\_BY\_CONFIGURATION means manifests are sorted by paths relative to the configuration directory within the output directory. DEPENDENCY means manifests are ordered with each library's manifest coming before the manifests of its dependencies. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`execution`](#effect_tag_EXECUTION) `--[no]android_resource_shrinking` default: "false" -: Enables resource shrinking for android_binary APKs that use ProGuard. +: Enables resource shrinking for android\_binary APKs that use ProGuard. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -5281,7 +5293,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--cs_fdo_profile=` default: see description -: The cs_fdo_profile representing the context sensitive profile to be used for optimization. +: The cs\_fdo\_profile representing the context sensitive profile to be used for optimization. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -5342,8 +5354,14 @@ Options that let the user configure the intended output, affecting its value, as Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]experimental_android_databinding_v2` default: "true" +: Use android databinding v2. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_android_resource_shrinking` default: "false" -: Enables resource shrinking for android_binary APKs that use ProGuard. +: Enables resource shrinking for android\_binary APKs that use ProGuard. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -5395,7 +5413,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--[no]experimental_use_llvm_covmap` default: "false" -: If specified, Bazel will generate llvm-cov coverage map information rather than gcov when collect_code_coverage is enabled. +: If specified, Bazel will generate llvm-cov coverage map information rather than gcov when collect\_code\_coverage is enabled. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -5427,7 +5445,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--fdo_profile=` default: see description -: The fdo_profile representing the profile to be used for optimization. +: The fdo\_profile representing the profile to be used for optimization. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -5503,13 +5521,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--host_macos_minimum_os=` default: see description -: Minimum compatible macOS version for host targets. If unspecified, uses 'macos_sdk_version'. +: Minimum compatible macOS version for host targets. If unspecified, uses 'macos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--host_per_file_copt=` multiple uses are accumulated -: Additional options to selectively pass to the C/C++ compiler when compiling certain files in the exec configurations. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation_filter). option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --host_per_file_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. +: Additional options to selectively pass to the C/C++ compiler when compiling certain files in the exec configurations. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation\_filter). option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --host\_per\_file\_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -5553,17 +5571,23 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ios_minimum_os=` default: see description -: Minimum compatible iOS version for target simulators and devices. If unspecified, uses 'ios_sdk_version'. +: Minimum compatible iOS version for target simulators and devices. If unspecified, uses 'ios\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--ios_multi_cpus=` multiple uses are accumulated -: Comma-separated list of architectures to build an ios_application with. The result is a universal binary containing all specified architectures. +: Comma-separated list of architectures to build an ios\_application with. The result is a universal binary containing all specified architectures. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) +`--[no]legacy_whole_archive` default: "true" +: Deprecated, superseded by --incompatible\_remove\_legacy\_whole\_archive (see https://github.com/bazelbuild/bazel/issues/7362 for details). When on, use --whole-archive for cc\_binary rules that have linkshared=True and either linkstatic=True or '-static' in linkopts. This is for backwards compatibility only. A better alternative is to use alwayslink=1 where required. + + Tags: + [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`deprecated`](#metadata_tag_DEPRECATED) + `--linkopt=` multiple uses are accumulated : Additional option to pass to gcc when linking. @@ -5571,13 +5595,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ltobackendopt=` multiple uses are accumulated -: Additional option to pass to the LTO backend step (under --features=thin_lto). +: Additional option to pass to the LTO backend step (under --features=thin\_lto). Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ltoindexopt=` multiple uses are accumulated -: Additional option to pass to the LTO indexing step (under --features=thin_lto). +: Additional option to pass to the LTO indexing step (under --features=thin\_lto). Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -5589,7 +5613,7 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--macos_minimum_os=` default: see description -: Minimum compatible macOS version for targets. If unspecified, uses 'macos_sdk_version'. +: Minimum compatible macOS version for targets. If unspecified, uses 'macos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -5601,7 +5625,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]objc_enable_binary_stripping` default: "false" -: Whether to perform symbol and dead-code strippings on linked binaries. Binary strippings will be performed if both this flag and --compilation_mode=opt are specified. +: Whether to perform symbol and dead-code strippings on linked binaries. Binary strippings will be performed if both this flag and --compilation\_mode=opt are specified. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES) @@ -5613,13 +5637,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES) `--per_file_copt=` multiple uses are accumulated -: Additional options to selectively pass to gcc when compiling certain files. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation_filter). option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per_file_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. +: Additional options to selectively pass to gcc when compiling certain files. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation\_filter). option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per\_file\_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--per_file_ltobackendopt=` multiple uses are accumulated -: Additional options to selectively pass to LTO backend (under --features=thin_lto) when compiling certain backend objects. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns. option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per_file_ltobackendopt=//foo/.\*.o,-//foo/bar.o@-O0 adds the -O0 command line option to the LTO backend command line of all o files in //foo/ except bar.o. +: Additional options to selectively pass to LTO backend (under --features=thin\_lto) when compiling certain backend objects. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns. option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per\_file\_ltobackendopt=//foo/.\*.o,-//foo/bar.o@-O0 adds the -O0 command line option to the LTO backend command line of all o files in //foo/ except bar.o. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -5631,19 +5655,19 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--propeller_optimize=` default: see description -: Use Propeller profile information to optimize the build target.A propeller profile must consist of at least one of two files, a cc profile and a ld profile. This flag accepts a build label which must refer to the propeller profile input files. For example, the BUILD file that defines the label, in a/b/BUILD:propeller_optimize( name = "propeller_profile", cc_profile = "propeller_cc_profile.txt", ld_profile = "propeller_ld_profile.txt",)An exports_files directive may have to be added to the corresponding package to make these files visible to Bazel. The option must be used as: --propeller_optimize=//a/b:propeller_profile +: Use Propeller profile information to optimize the build target.A propeller profile must consist of at least one of two files, a cc profile and a ld profile. This flag accepts a build label which must refer to the propeller profile input files. For example, the BUILD file that defines the label, in a/b/BUILD:propeller\_optimize( name = "propeller\_profile", cc\_profile = "propeller\_cc\_profile.txt", ld\_profile = "propeller\_ld\_profile.txt",)An exports\_files directive may have to be added to the corresponding package to make these files visible to Bazel. The option must be used as: --propeller\_optimize=//a/b:propeller\_profile Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--propeller_optimize_absolute_cc_profile=` default: see description -: Absolute path name of cc_profile file for Propeller Optimized builds. +: Absolute path name of cc\_profile file for Propeller Optimized builds. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--propeller_optimize_absolute_ld_profile=` default: see description -: Absolute path name of ld_profile file for Propeller Optimized builds. +: Absolute path name of ld\_profile file for Propeller Optimized builds. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -5677,13 +5701,13 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--strip=` default: "sometimes" -: Specifies whether to strip binaries and shared libraries (using "-Wl,--strip-debug"). The default value of 'sometimes' means strip iff --compilation_mode=fastbuild. +: Specifies whether to strip binaries and shared libraries (using "-Wl,--strip-debug"). The default value of 'sometimes' means strip iff --compilation\_mode=fastbuild. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--stripopt=` multiple uses are accumulated -: Additional options to pass to strip when generating a '<name>.stripped' binary. +: Additional options to pass to strip when generating a '.stripped' binary. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -5695,7 +5719,7 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--tvos_minimum_os=` default: see description -: Minimum compatible tvOS version for target simulators and devices. If unspecified, uses 'tvos_sdk_version'. +: Minimum compatible tvOS version for target simulators and devices. If unspecified, uses 'tvos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -5713,13 +5737,13 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--watchos_minimum_os=` default: see description -: Minimum compatible watchOS version for target simulators and devices. If unspecified, uses 'watchos_sdk_version'. +: Minimum compatible watchOS version for target simulators and devices. If unspecified, uses 'watchos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--xbinary_fdo=` default: see description -: Use XbinaryFDO profile information to optimize compilation. Specify the name of default cross binary profile. When the option is used together with --fdo_instrument/--fdo_optimize/--fdo_profile, those options will always prevail as if xbinary_fdo is never specified. +: Use XbinaryFDO profile information to optimize compilation. Specify the name of default cross binary profile. When the option is used together with --fdo\_instrument/--fdo\_optimize/--fdo\_profile, those options will always prevail as if xbinary\_fdo is never specified. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -5750,14 +5774,20 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) +`--[no]experimental_check_desugar_deps` default: "true" +: Whether to double-check correct desugaring at Android binary level. + + Tags: + [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_enforce_transitive_visibility` default: "false" -: If true, enable package()s to set the transitive_visibility attribute to restrict which packages may depend on them. +: If true, enable package()s to set the transitive\_visibility attribute to restrict which packages may depend on them. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--experimental_one_version_enforcement=` default: "OFF" -: When enabled, enforce that a java_binary rule can't contain more than one version of the same class file on the classpath. This enforcement can break the build, or can just result in warnings. +: When enabled, enforce that a java\_binary rule can't contain more than one version of the same class file on the classpath. This enforcement can break the build, or can just result in warnings. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -5774,26 +5804,26 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) -`--[no]incompatible_disable_native_apple_binary_rule` default: "false" -: No-op. Kept here for backwards compatibility. +`--[no]incompatible_disable_native_android_rules` default: "false" +: If enabled, direct usage of the native Android rules is disabled. Please use the Starlark Android rules from https://github.com/bazelbuild/rules\_android Tags: - [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE), [`deprecated`](#metadata_tag_DEPRECATED) + [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]one_version_enforcement_on_java_tests` default: "true" -: When enabled, and with experimental_one_version_enforcement set to a non-NONE value, enforce one version on java_test targets. This flag can be disabled to improve incremental test performance at the expense of missing potential one version violations. +: When enabled, and with experimental\_one\_version\_enforcement set to a non-NONE value, enforce one version on java\_test targets. This flag can be disabled to improve incremental test performance at the expense of missing potential one version violations. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--strict_proto_deps=` default: "error" -: Unless OFF, checks that a proto_library target explicitly declares all directly used targets as dependencies. +: Unless OFF, checks that a proto\_library target explicitly declares all directly used targets as dependencies. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--strict_public_imports=` default: "off" -: Unless OFF, checks that a proto_library target explicitly declares all targets used in 'import public' as exported. +: Unless OFF, checks that a proto\_library target explicitly declares all targets used in 'import public' as exported. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -5816,7 +5846,7 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Options that affect the signing outputs of a build: -`--apk_signing_method=` default: "v1_v2" +`--apk_signing_method=` default: "v1\_v2" : Implementation to use to sign APKs Tags: @@ -5831,13 +5861,13 @@ Options that affect the signing outputs of a build: This option affects semantics of the Starlark language or the build API accessible to BUILD files, .bzl files, or WORKSPACE files.: `--[no]incompatible_disallow_sdk_frameworks_attributes` default: "false" -: If true, disallow sdk_frameworks and weak_sdk_frameworks attributes in objc_library and objc_import. +: If true, disallow sdk\_frameworks and weak\_sdk\_frameworks attributes in objc\_library and objc\_import. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_objc_alwayslink_by_default` default: "false" -: If true, make the default value true for alwayslink attributes in objc_library and objc_import. +: If true, make the default value true for alwayslink attributes in objc\_library and objc\_import. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -5871,6 +5901,24 @@ Options that govern the behavior of the test environment or test runner: The default test resources specified by this flag are overridden by explicit resources specified in tags. +`--[no]experimental_android_use_parallel_dex2oat` default: "false" +: Use dex2oat in parallel to possibly speed up android\_test. + + Tags: + [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS), [`experimental`](#metadata_tag_EXPERIMENTAL) + +`--ios_simulator_device=` default: see description +: The device to simulate when running an iOS application in the simulator, e.g. 'iPhone 6'. You can get a list of devices by running 'xcrun simctl list devicetypes' on the machine the simulator will be run on. + + Tags: + [`test_runner`](#effect_tag_TEST_RUNNER) + +`--ios_simulator_version=` default: see description +: The version of iOS to run on the simulator when running or testing. This is ignored for ios\_test rules if a target device is specified in the rule. + + Tags: + [`test_runner`](#effect_tag_TEST_RUNNER) + `--runs_per_test=` multiple uses are accumulated : Specifies number of times to run each test. If any of those attempts fail for any reason, the whole test is considered failed. Normally the value specified is @@ -5880,7 +5928,7 @@ Options that govern the behavior of the test environment or test runner: Alternate syntax: `regex_filter@runs_per_test`. Where `runs_per_test` stands for an integer value and `regex_filter` stands for a list of include and exclude - regular expression patterns (Also see --instrumentation_filter). + regular expression patterns (Also see --instrumentation\_filter). Example: `--runs_per_test=//foo/.*,-//foo/bar/.*@3` runs all tests in `//foo/` except those under `//foo/bar` three times. This option can be passed multiple times. The most @@ -5926,6 +5974,12 @@ Options that trigger optimizations of the build time: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]experimental_filter_library_jar_with_program_jar` default: "false" +: Filter the ProGuard ProgramJar to remove any classes also present in the LibraryJar. + + Tags: + [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_inmemory_dotd_files` default: "true" : If enabled, C++ .d files will be passed through in memory directly from the remote build nodes instead of being written to disk. @@ -5953,6 +6007,12 @@ Options that trigger optimizations of the build time: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]incremental_dexing` default: "true" +: Does most of the work for dexing separately for each Jar file. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) + `--[no]objc_use_dotd_pruning` default: "true" : If set, .d files emitted by clang will be used to prune the set of inputs passed into objc compiles. @@ -6035,11 +6095,8 @@ Miscellaneous options, not otherwise categorized.: Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) -`--experimental_turbine_cpu_reservation=` default: "1" -: The number of CPUs to reserve for Turbine. - `--[no]explicit_java_test_deps` default: "false" -: Explicitly specify a dependency to JUnit or Hamcrest in a java_test instead of accidentally obtaining from the TestRunner's deps. Only works for bazel right now. +: Explicitly specify a dependency to JUnit or Hamcrest in a java\_test instead of accidentally obtaining from the TestRunner's deps. Only works for bazel right now. `--host_java_launcher=` default: see description : The Java launcher used by tools that are executed during a build. @@ -6048,7 +6105,7 @@ Miscellaneous options, not otherwise categorized.: : Additional options to pass to javac when building tools that are executed during a build. `--host_jvmopt=` multiple uses are accumulated -: Additional options to pass to the Java VM when building tools that are executed during the build. These options will get added to the VM startup options of each java_binary target. +: Additional options to pass to the Java VM when building tools that are executed during the build. These options will get added to the VM startup options of each java\_binary target. `--[no]incompatible_exclusive_test_sandboxed` default: "true" : If true, exclusive tests will run with sandboxed strategy. Add `local` tag to force @@ -6070,7 +6127,7 @@ Miscellaneous options, not otherwise categorized.: : Additional options to pass to the J2ObjC tool. `--java_debug` -: Causes the Java virtual machine of a java test to wait for a connection from a JDWP-compliant debugger (such as jdb) before starting the test. Implies -test_output=streamed. +: Causes the Java virtual machine of a java test to wait for a connection from a JDWP-compliant debugger (such as jdb) before starting the test. Implies -test\_output=streamed. Expands to: @@ -6096,14 +6153,14 @@ Miscellaneous options, not otherwise categorized.: `--java_launcher=` default: see description : The Java launcher to use when building Java binaries. If this flag is set to the empty string, the JDK launcher is used. The "launcher" attribute overrides this flag. -`--java_runtime_version=` default: "local_jdk" +`--java_runtime_version=` default: "local\_jdk" : The Java runtime version `--javacopt=` multiple uses are accumulated : Additional options to pass to javac. `--jvmopt=` multiple uses are accumulated -: Additional options to pass to the Java VM. These options will get added to the VM startup options of each java_binary target. +: Additional options to pass to the Java VM. These options will get added to the VM startup options of each java\_binary target. `--legacy_main_dex_list_generator=` default: see description : Specifies a binary to use to generate the list of classes that must be in the main dex when compiling legacy multidex. @@ -6112,43 +6169,43 @@ Miscellaneous options, not otherwise categorized.: : Specifies a binary to use to do dexing without sharding. `--plugin=` multiple uses are accumulated -: Plugins to use in the build. Currently works with java_plugin. +: Plugins to use in the build. Currently works with java\_plugin. `--proguard_top=` default: see description : Specifies which version of ProGuard to use for code removal when building a Java binary. -`--proto_compiler=` default: "@bazel_tools//tools/proto:protoc" +`--proto_compiler=` default: "@bazel\_tools//tools/proto:protoc" : The label of the proto-compiler. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--[no]proto_profile` default: "true" -: Whether to pass profile_path to the proto compiler. +: Whether to pass profile\_path to the proto compiler. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--proto_profile_path=` default: see description -: The profile to pass to the proto compiler as profile_path. If unset, but --proto_profile is true (the default), infers the path from --fdo_optimize. +: The profile to pass to the proto compiler as profile\_path. If unset, but --proto\_profile is true (the default), infers the path from --fdo\_optimize. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_cc=` default: "@bazel_tools//tools/proto:cc_toolchain" -: Label of proto_lang_toolchain() which describes how to compile C++ protos +`--proto_toolchain_for_cc=` default: "@bazel\_tools//tools/proto:cc\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile C++ protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_java=` default: "@bazel_tools//tools/proto:java_toolchain" -: Label of proto_lang_toolchain() which describes how to compile Java protos +`--proto_toolchain_for_java=` default: "@bazel\_tools//tools/proto:java\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile Java protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_javalite=` default: "@bazel_tools//tools/proto:javalite_toolchain" -: Label of proto_lang_toolchain() which describes how to compile JavaLite protos +`--proto_toolchain_for_javalite=` default: "@bazel\_tools//tools/proto:javalite\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile JavaLite protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -6190,9 +6247,6 @@ Miscellaneous options, not otherwise categorized.: `--test_result_expiration=` default: "-1" : This option is deprecated and has no effect. - Tags: - [`deprecated`](#metadata_tag_DEPRECATED) - `--[no]test_runner_fail_fast` default: "false" : Forwards fail fast option to the test runner. The test runner should stop execution upon first failure. @@ -6208,7 +6262,7 @@ Miscellaneous options, not otherwise categorized.: `--tool_java_language_version=` default: "" : The Java language version used to execute the tools that are needed during a build -`--tool_java_runtime_version=` default: "remotejdk_11" +`--tool_java_runtime_version=` default: "remotejdk\_11" : The Java runtime version used to execute tools during the build `--[no]use_ijars` default: "true" @@ -6221,7 +6275,7 @@ Inherits all options from [build](#build). Options that control the output of the command: `--[no]canonicalize_policy` default: "false" -: Output the canonical policy, after expansion and filtering. To keep the output clean, the canonicalized command arguments will NOT be shown when this option is set to true. Note that the command specified by --for_command affects the filtered policy, and if none is specified, the default command is 'build'. +: Output the canonical policy, after expansion and filtering. To keep the output clean, the canonicalized command arguments will NOT be shown when this option is set to true. Note that the command specified by --for\_command affects the filtered policy, and if none is specified, the default command is 'build'. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -6235,13 +6289,13 @@ Options that control the output of the command: This option affects semantics of the Starlark language or the build API accessible to BUILD files, .bzl files, or WORKSPACE files.: `--[no]incompatible_config_setting_private_default_visibility` default: "false" -: If incompatible_enforce_config_setting_visibility=false, this is a noop. Else, if this flag is false, any config_setting without an explicit visibility attribute is //visibility:public. If this flag is true, config_setting follows the same visibility logic as all other rules. See https://github.com/bazelbuild/bazel/issues/12933. +: If incompatible\_enforce\_config\_setting\_visibility=false, this is a noop. Else, if this flag is false, any config\_setting without an explicit visibility attribute is //visibility:public. If this flag is true, config\_setting follows the same visibility logic as all other rules. See https://github.com/bazelbuild/bazel/issues/12933. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_enforce_config_setting_visibility` default: "true" -: If true, enforce config_setting visibility restrictions. If false, every config_setting is visible to every target. See https://github.com/bazelbuild/bazel/issues/12932. +: If true, enforce config\_setting visibility restrictions. If false, every config\_setting is visible to every target. See https://github.com/bazelbuild/bazel/issues/12932. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -6264,7 +6318,7 @@ Miscellaneous options, not otherwise categorized.: `--deleted_packages=` multiple uses are accumulated : A comma-separated list of names of packages which the build system will consider non-existent, even if they are visible somewhere on the package path. - Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package_path entry. Specifying --deleted_packages x/y avoids this problem. + Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package\_path entry. Specifying --deleted\_packages x/y avoids this problem. `--[no]fetch` default: "true" : Allows the command to fetch external dependencies. If set to false, the command will utilize any cached version of the dependency, and if none exists, the command will result in failure. @@ -6318,13 +6372,13 @@ Inherits all options from [test](#test). Options relating to query output and semantics: `--aspect_deps=` default: "conservative" -: How to resolve aspect dependencies when the output format is one of {xml,proto,record}. 'off' means no aspect dependencies are resolved, 'conservative' (the default) means all declared aspect dependencies are added regardless of whether they are given the rule class of direct dependencies, 'precise' means that only those aspects are added that are possibly active given the rule class of the direct dependencies. Note that precise mode requires loading other packages to evaluate a single target thus making it slower than the other modes. Also note that even precise mode is not completely precise: the decision whether to compute an aspect is decided in the analysis phase, which is not run during 'bazel query'. +: How to resolve aspect dependencies when the output format is one of {xml,proto,record}. 'off' means no aspect dependencies are resolved, 'conservative' (the default) means all declared aspect dependencies are added regardless of whether they are given the rule class of direct dependencies, 'precise' means that only those aspects are added that are possibly active given the rule class of the direct dependencies. Note that precise mode requires loading other packages to evaluate a single target thus making it slower than the other modes. Also note that even precise mode is not completely precise: the decision whether to compute an aspect is decided in the analysis phase, which is not run during 'bazel query'. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) `--[no]consistent_labels` default: "false" -: If enabled, every query command emits labels as if by the Starlark `str` function applied to a `Label` instance. This is useful for tools that need to match the output of different query commands and/or labels emitted by rules. If not enabled, output formatters are free to emit apparent repository names (relative to the main repository) instead to make the output more readable. +: If enabled, every query command emits labels as if by the Starlark str function applied to a Label instance. This is useful for tools that need to match the output of different query commands and/or labels emitted by rules. If not enabled, output formatters are free to emit apparent repository names (relative to the main repository) instead to make the output more readable. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -6359,20 +6413,14 @@ Options relating to query output and semantics: Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) -`--[no]incompatible_package_group_build_output` default: "false" -: If enabled, `blaze query --output=build` will output `package_group` targets. - - Tags: - [`terminal_output`](#effect_tag_TERMINAL_OUTPUT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) - `--[no]incompatible_package_group_includes_double_slash` default: "true" -: If enabled, when outputting package_group's `packages` attribute, the leading `//` will not be omitted. +: If enabled, when outputting package\_group's `packages` attribute, the leading `//` will not be omitted. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]infer_universe_scope` default: "false" -: If set and --universe_scope is unset, then a value of --universe_scope will be inferred as the list of unique target patterns in the query expression. Note that the --universe_scope value inferred for a query expression that uses universe-scoped functions (e.g.`allrdeps`) may not be what you want, so you should use this option only if you know what you are doing. See https://bazel.build/reference/query#sky-query for details and examples. If --universe_scope is set, then this option's value is ignored. Note: this option applies only to `query` (i.e. not `cquery`). +: If set and --universe\_scope is unset, then a value of --universe\_scope will be inferred as the list of unique target patterns in the query expression. Note that the --universe\_scope value inferred for a query expression that uses universe-scoped functions (e.g.`allrdeps`) may not be what you want, so you should use this option only if you know what you are doing. See https://bazel.build/reference/query#sky-query for details and examples. If --universe\_scope is set, then this option's value is ignored. Note: this option applies only to `query` (i.e. not `cquery`). Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -6390,13 +6438,13 @@ Options relating to query output and semantics: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) `--output=` default: "label" -: The format in which the cquery results should be printed. Allowed values for cquery are: label, label_kind, textproto, transitions, proto, streamed_proto, jsonproto. If you select 'transitions', you also have to specify the --transitions=(lite|full) option. +: The format in which the cquery results should be printed. Allowed values for cquery are: label, label\_kind, textproto, transitions, proto, streamed\_proto, jsonproto. If you select 'transitions', you also have to specify the --transitions=(lite|full) option. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--output_file=` default: "" -: When specified, query results will be written directly to this file, and nothing will be printed to Bazel's standard output stream (stdout). In benchmarks, this is generally faster than `bazel query > file`. +: When specified, query results will be written directly to this file, and nothing will be printed to Bazel's standard output stream (stdout). In benchmarks, this is generally faster than bazel query > file. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -6408,7 +6456,7 @@ Options relating to query output and semantics: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]proto:definition_stack` default: "false" -: Populate the definition_stack proto field, which records for each rule instance the Starlark call stack at the moment the rule's class was defined. +: Populate the definition\_stack proto field, which records for each rule instance the Starlark call stack at the moment the rule's class was defined. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -6420,7 +6468,7 @@ Options relating to query output and semantics: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) `--[no]proto:include_attribute_source_aspects` default: "false" -: Populate the source_aspect_name proto field of each Attribute with the source aspect that the attribute came from (empty string if it did not). +: Populate the source\_aspect\_name proto field of each Attribute with the source aspect that the attribute came from (empty string if it did not). Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -6432,13 +6480,13 @@ Options relating to query output and semantics: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]proto:include_starlark_rule_env` default: "true" -: Use the starlark environment in the value of the generated $internal_attr_hash attribute. This ensures that the starlark rule definition (and its transitive imports) are part of this identifier. +: Use the starlark environment in the value of the generated $internal\_attr\_hash attribute. This ensures that the starlark rule definition (and its transitive imports) are part of this identifier. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]proto:include_synthetic_attribute_hash` default: "false" -: Whether or not to calculate and populate the $internal_attr_hash attribute. +: Whether or not to calculate and populate the $internal\_attr\_hash attribute. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -6462,13 +6510,13 @@ Options relating to query output and semantics: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]proto:rule_classes` default: "false" -: Populate the rule_class_key field of each rule; and for the first rule with a given rule_class_key, also populate its rule_class_info proto field. The rule_class_key field uniquely identifies a rule class, and the rule_class_info field is a Stardoc-format rule class API definition. +: Populate the rule\_class\_key field of each rule; and for the first rule with a given rule\_class\_key, also populate its rule\_class\_info proto field. The rule\_class\_key field uniquely identifies a rule class, and the rule\_class\_info field is a Stardoc-format rule class API definition. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]proto:rule_inputs_and_outputs` default: "true" -: Whether or not to populate the rule_input and rule_output fields. +: Whether or not to populate the rule\_input and rule\_output fields. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -6504,7 +6552,7 @@ Options relating to query output and semantics: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]tool_deps` default: "true" -: Query: If disabled, dependencies on 'exec configuration' will not be included in the dependency graph over which the query operates. An 'exec configuration' dependency edge, such as the one from any 'proto_library' rule to the Protocol Compiler, usually points to a tool executed during the build rather than a part of the same 'target' program. +: Query: If disabled, dependencies on 'exec configuration' will not be included in the dependency graph over which the query operates. An 'exec configuration' dependency edge, such as the one from any 'proto\_library' rule to the Protocol Compiler, usually points to a tool executed during the build rather than a part of the same 'target' program. Cquery: If disabled, filters out all configured targets which cross an execution transition from the top-level target that discovered this configured target. That means if the top-level target is in the target configuration, only configured targets also in the target configuration will be returned. If the top-level target is in the exec configuration, only exec configured targets will be returned. This option will NOT exclude resolved toolchains. Tags: @@ -6703,13 +6751,13 @@ Options that configure the toolchain used for action execution: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--android_manifest_merger=` default: "android" -: Selects the manifest merger to use for android_binary rules. Flag to help the transition to the Android manifest merger from the legacy merger. +: Selects the manifest merger to use for android\_binary rules. Flag to help the transition to the Android manifest merger from the legacy merger. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--android_platforms=` default: "" -: Sets the platforms that android_binary targets use. If multiple platforms are specified, then the binary is a fat APKs, which contains native binaries for each specified target platform. +: Sets the platforms that android\_binary targets use. If multiple platforms are specified, then the binary is a fat APKs, which contains native binaries for each specified target platform. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -6726,21 +6774,21 @@ Options that configure the toolchain used for action execution: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION) -`--coverage_output_generator=` default: "@bazel_tools//tools/test:lcov_merger" +`--coverage_output_generator=` default: "@bazel\_tools//tools/test:lcov\_merger" : Location of the binary that is used to postprocess raw coverage reports. This must be a binary target. Defaults to `@bazel_tools//tools/test:lcov_merger`. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--coverage_report_generator=` default: "@bazel_tools//tools/test:coverage_report_generator" +`--coverage_report_generator=` default: "@bazel\_tools//tools/test:coverage\_report\_generator" : Location of the binary that is used to generate coverage reports. This must be a binary target. Defaults to `@bazel_tools//tools/test:coverage_report_generator`. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--coverage_support=` default: "@bazel_tools//tools/test:coverage_support" +`--coverage_support=` default: "@bazel\_tools//tools/test:coverage\_support" : Location of support files that are required on the inputs of every test action that collects code coverage. Defaults to `//tools/test:coverage_support`. @@ -6754,7 +6802,7 @@ Options that configure the toolchain used for action execution: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]experimental_include_xcode_execution_requirements` default: "false" -: If set, add a "requires-xcode:{version}" execution requirement to every Xcode action. If the Xcode version has a hyphenated label, also add a "requires-xcode-label:{version_label}" execution requirement. +: If set, add a "requires-xcode:{version}" execution requirement to every Xcode action. If the Xcode version has a hyphenated label, also add a "requires-xcode-label:{version\_label}" execution requirement. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -6797,12 +6845,12 @@ Options that configure the toolchain used for action execution: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION) `--host_grte_top=` default: see description -: If specified, this setting overrides the libc top-level directory (--grte_top) for the exec configuration. +: If specified, this setting overrides the libc top-level directory (--grte\_top) for the exec configuration. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) -`--host_platform=` default: "@bazel_tools//tools:host_platform" +`--host_platform=` default: "@bazel\_tools//tools:host\_platform" : The label of a platform rule that describes the host system. Tags: @@ -6824,6 +6872,12 @@ Options that configure the toolchain used for action execution: Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) +`--[no]incompatible_cuda_compile_action` default: "false" +: Compile cuda files using the cuda-compile action in the toolchain. + + Tags: + [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) + `--[no]incompatible_dont_enable_host_nonhost_crosstool_features` default: "true" : If true, Bazel will not enable 'host' and 'nonhost' features in the c++ toolchain (see https://github.com/bazelbuild/bazel/issues/7407 for more information). @@ -6849,13 +6903,13 @@ Options that configure the toolchain used for action execution: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ios_sdk_version=` default: see description -: Specifies the version of the iOS SDK to use to build iOS applications. If unspecified, uses the default iOS SDK version from 'xcode_version'. +: Specifies the version of the iOS SDK to use to build iOS applications. If unspecified, uses the default iOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--macos_sdk_version=` default: see description -: Specifies the version of the macOS SDK to use to build macOS applications. If unspecified, uses the default macOS SDK version from 'xcode_version'. +: Specifies the version of the macOS SDK to use to build macOS applications. If unspecified, uses the default macOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -6882,19 +6936,19 @@ Options that configure the toolchain used for action execution: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--tvos_sdk_version=` default: see description -: Specifies the version of the tvOS SDK to use to build tvOS applications. If unspecified, uses the default tvOS SDK version from 'xcode_version'. +: Specifies the version of the tvOS SDK to use to build tvOS applications. If unspecified, uses the default tvOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--[no]use_platforms_in_apple_crosstool_transition` default: "false" -: Makes apple_crosstool_transition fall back to using the value of `--platforms` flag instead of legacy `--cpu` when needed. +: Makes apple\_crosstool\_transition fall back to using the value of `--platforms` flag instead of legacy `--cpu` when needed. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--watchos_sdk_version=` default: see description -: Specifies the version of the watchOS SDK to use to build watchOS applications. If unspecified, uses the default watchOS SDK version from 'xcode_version'. +: Specifies the version of the watchOS SDK to use to build watchOS applications. If unspecified, uses the default watchOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -6905,8 +6959,8 @@ Options that configure the toolchain used for action execution: Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) -`--xcode_version_config=` default: "@bazel_tools//tools/cpp:host_xcodes" -: The label of the xcode_config rule to be used for selecting the Xcode version in the build configuration. +`--xcode_version_config=` default: "@bazel\_tools//tools/cpp:host\_xcodes" +: The label of the xcode\_config rule to be used for selecting the Xcode version in the build configuration. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -6938,19 +6992,19 @@ Options that control the output of the command: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--cc_proto_library_header_suffixes=` default: ".pb.h" -: Sets the suffixes of header files that a cc_proto_library creates. +: Sets the suffixes of header files that a cc\_proto\_library creates. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--cc_proto_library_source_suffixes=` default: ".pb.cc" -: Sets the suffixes of source files that a cc_proto_library creates. +: Sets the suffixes of source files that a cc\_proto\_library creates. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--[no]experimental_proto_descriptor_sets_include_source_info` default: "false" -: Run extra actions for alternative Java api versions in a proto_library. +: Run extra actions for alternative Java api versions in a proto\_library. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -6962,7 +7016,7 @@ Options that control the output of the command: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--fission=` default: "no" -: Specifies which compilation modes use fission for C++ compilations and links. May be any combination of {'fastbuild', 'dbg', 'opt'} or the special values 'yes' to enable all modes and 'no' to disable all modes. +: Specifies which compilation modes use fission for C++ compilations and links. May be any combination of {'fastbuild', 'dbg', 'opt'} or the special values 'yes' to enable all modes and 'no' to disable all modes. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -7029,20 +7083,32 @@ Options that let the user configure the intended output, affecting its value, as Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) +`--[no]android_databinding_use_androidx` default: "true" +: Generate AndroidX-compatible data-binding files. This is only used with databinding v2. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + +`--[no]android_databinding_use_v3_4_args` default: "true" +: Use android databinding v2 with 3.4.0 argument. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--android_dynamic_mode=` default: "off" -: Determines whether C++ deps of Android rules will be linked dynamically when a cc_binary does not explicitly create a shared library. 'default' means bazel will choose whether to link dynamically. 'fully' means all libraries will be linked dynamically. 'off' means that all libraries will be linked in mostly static mode. +: Determines whether C++ deps of Android rules will be linked dynamically when a cc\_binary does not explicitly create a shared library. 'default' means bazel will choose whether to link dynamically. 'fully' means all libraries will be linked dynamically. 'off' means that all libraries will be linked in mostly static mode. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--android_manifest_merger_order=` default: "alphabetical" -: Sets the order of manifests passed to the manifest merger for Android binaries. ALPHABETICAL means manifests are sorted by path relative to the execroot. ALPHABETICAL_BY_CONFIGURATION means manifests are sorted by paths relative to the configuration directory within the output directory. DEPENDENCY means manifests are ordered with each library's manifest coming before the manifests of its dependencies. +: Sets the order of manifests passed to the manifest merger for Android binaries. ALPHABETICAL means manifests are sorted by path relative to the execroot. ALPHABETICAL\_BY\_CONFIGURATION means manifests are sorted by paths relative to the configuration directory within the output directory. DEPENDENCY means manifests are ordered with each library's manifest coming before the manifests of its dependencies. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`execution`](#effect_tag_EXECUTION) `--[no]android_resource_shrinking` default: "false" -: Enables resource shrinking for android_binary APKs that use ProGuard. +: Enables resource shrinking for android\_binary APKs that use ProGuard. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -7095,7 +7161,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--cs_fdo_profile=` default: see description -: The cs_fdo_profile representing the context sensitive profile to be used for optimization. +: The cs\_fdo\_profile representing the context sensitive profile to be used for optimization. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -7156,8 +7222,14 @@ Options that let the user configure the intended output, affecting its value, as Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]experimental_android_databinding_v2` default: "true" +: Use android databinding v2. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_android_resource_shrinking` default: "false" -: Enables resource shrinking for android_binary APKs that use ProGuard. +: Enables resource shrinking for android\_binary APKs that use ProGuard. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -7209,7 +7281,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--[no]experimental_use_llvm_covmap` default: "false" -: If specified, Bazel will generate llvm-cov coverage map information rather than gcov when collect_code_coverage is enabled. +: If specified, Bazel will generate llvm-cov coverage map information rather than gcov when collect\_code\_coverage is enabled. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -7241,7 +7313,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--fdo_profile=` default: see description -: The fdo_profile representing the profile to be used for optimization. +: The fdo\_profile representing the profile to be used for optimization. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -7317,13 +7389,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--host_macos_minimum_os=` default: see description -: Minimum compatible macOS version for host targets. If unspecified, uses 'macos_sdk_version'. +: Minimum compatible macOS version for host targets. If unspecified, uses 'macos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--host_per_file_copt=` multiple uses are accumulated -: Additional options to selectively pass to the C/C++ compiler when compiling certain files in the exec configurations. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation_filter). option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --host_per_file_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. +: Additional options to selectively pass to the C/C++ compiler when compiling certain files in the exec configurations. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation\_filter). option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --host\_per\_file\_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -7367,17 +7439,23 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ios_minimum_os=` default: see description -: Minimum compatible iOS version for target simulators and devices. If unspecified, uses 'ios_sdk_version'. +: Minimum compatible iOS version for target simulators and devices. If unspecified, uses 'ios\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--ios_multi_cpus=` multiple uses are accumulated -: Comma-separated list of architectures to build an ios_application with. The result is a universal binary containing all specified architectures. +: Comma-separated list of architectures to build an ios\_application with. The result is a universal binary containing all specified architectures. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) +`--[no]legacy_whole_archive` default: "true" +: Deprecated, superseded by --incompatible\_remove\_legacy\_whole\_archive (see https://github.com/bazelbuild/bazel/issues/7362 for details). When on, use --whole-archive for cc\_binary rules that have linkshared=True and either linkstatic=True or '-static' in linkopts. This is for backwards compatibility only. A better alternative is to use alwayslink=1 where required. + + Tags: + [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`deprecated`](#metadata_tag_DEPRECATED) + `--linkopt=` multiple uses are accumulated : Additional option to pass to gcc when linking. @@ -7385,13 +7463,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ltobackendopt=` multiple uses are accumulated -: Additional option to pass to the LTO backend step (under --features=thin_lto). +: Additional option to pass to the LTO backend step (under --features=thin\_lto). Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ltoindexopt=` multiple uses are accumulated -: Additional option to pass to the LTO indexing step (under --features=thin_lto). +: Additional option to pass to the LTO indexing step (under --features=thin\_lto). Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -7403,7 +7481,7 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--macos_minimum_os=` default: see description -: Minimum compatible macOS version for targets. If unspecified, uses 'macos_sdk_version'. +: Minimum compatible macOS version for targets. If unspecified, uses 'macos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -7415,7 +7493,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]objc_enable_binary_stripping` default: "false" -: Whether to perform symbol and dead-code strippings on linked binaries. Binary strippings will be performed if both this flag and --compilation_mode=opt are specified. +: Whether to perform symbol and dead-code strippings on linked binaries. Binary strippings will be performed if both this flag and --compilation\_mode=opt are specified. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES) @@ -7427,13 +7505,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES) `--per_file_copt=` multiple uses are accumulated -: Additional options to selectively pass to gcc when compiling certain files. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation_filter). option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per_file_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. +: Additional options to selectively pass to gcc when compiling certain files. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation\_filter). option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per\_file\_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--per_file_ltobackendopt=` multiple uses are accumulated -: Additional options to selectively pass to LTO backend (under --features=thin_lto) when compiling certain backend objects. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns. option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per_file_ltobackendopt=//foo/.\*.o,-//foo/bar.o@-O0 adds the -O0 command line option to the LTO backend command line of all o files in //foo/ except bar.o. +: Additional options to selectively pass to LTO backend (under --features=thin\_lto) when compiling certain backend objects. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns. option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per\_file\_ltobackendopt=//foo/.\*.o,-//foo/bar.o@-O0 adds the -O0 command line option to the LTO backend command line of all o files in //foo/ except bar.o. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -7445,19 +7523,19 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--propeller_optimize=` default: see description -: Use Propeller profile information to optimize the build target.A propeller profile must consist of at least one of two files, a cc profile and a ld profile. This flag accepts a build label which must refer to the propeller profile input files. For example, the BUILD file that defines the label, in a/b/BUILD:propeller_optimize( name = "propeller_profile", cc_profile = "propeller_cc_profile.txt", ld_profile = "propeller_ld_profile.txt",)An exports_files directive may have to be added to the corresponding package to make these files visible to Bazel. The option must be used as: --propeller_optimize=//a/b:propeller_profile +: Use Propeller profile information to optimize the build target.A propeller profile must consist of at least one of two files, a cc profile and a ld profile. This flag accepts a build label which must refer to the propeller profile input files. For example, the BUILD file that defines the label, in a/b/BUILD:propeller\_optimize( name = "propeller\_profile", cc\_profile = "propeller\_cc\_profile.txt", ld\_profile = "propeller\_ld\_profile.txt",)An exports\_files directive may have to be added to the corresponding package to make these files visible to Bazel. The option must be used as: --propeller\_optimize=//a/b:propeller\_profile Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--propeller_optimize_absolute_cc_profile=` default: see description -: Absolute path name of cc_profile file for Propeller Optimized builds. +: Absolute path name of cc\_profile file for Propeller Optimized builds. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--propeller_optimize_absolute_ld_profile=` default: see description -: Absolute path name of ld_profile file for Propeller Optimized builds. +: Absolute path name of ld\_profile file for Propeller Optimized builds. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -7491,13 +7569,13 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--strip=` default: "sometimes" -: Specifies whether to strip binaries and shared libraries (using "-Wl,--strip-debug"). The default value of 'sometimes' means strip iff --compilation_mode=fastbuild. +: Specifies whether to strip binaries and shared libraries (using "-Wl,--strip-debug"). The default value of 'sometimes' means strip iff --compilation\_mode=fastbuild. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--stripopt=` multiple uses are accumulated -: Additional options to pass to strip when generating a '<name>.stripped' binary. +: Additional options to pass to strip when generating a '.stripped' binary. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -7509,7 +7587,7 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--tvos_minimum_os=` default: see description -: Minimum compatible tvOS version for target simulators and devices. If unspecified, uses 'tvos_sdk_version'. +: Minimum compatible tvOS version for target simulators and devices. If unspecified, uses 'tvos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -7527,13 +7605,13 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--watchos_minimum_os=` default: see description -: Minimum compatible watchOS version for target simulators and devices. If unspecified, uses 'watchos_sdk_version'. +: Minimum compatible watchOS version for target simulators and devices. If unspecified, uses 'watchos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--xbinary_fdo=` default: see description -: Use XbinaryFDO profile information to optimize compilation. Specify the name of default cross binary profile. When the option is used together with --fdo_instrument/--fdo_optimize/--fdo_profile, those options will always prevail as if xbinary_fdo is never specified. +: Use XbinaryFDO profile information to optimize compilation. Specify the name of default cross binary profile. When the option is used together with --fdo\_instrument/--fdo\_optimize/--fdo\_profile, those options will always prevail as if xbinary\_fdo is never specified. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -7564,14 +7642,20 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) +`--[no]experimental_check_desugar_deps` default: "true" +: Whether to double-check correct desugaring at Android binary level. + + Tags: + [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_enforce_transitive_visibility` default: "false" -: If true, enable package()s to set the transitive_visibility attribute to restrict which packages may depend on them. +: If true, enable package()s to set the transitive\_visibility attribute to restrict which packages may depend on them. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--experimental_one_version_enforcement=` default: "OFF" -: When enabled, enforce that a java_binary rule can't contain more than one version of the same class file on the classpath. This enforcement can break the build, or can just result in warnings. +: When enabled, enforce that a java\_binary rule can't contain more than one version of the same class file on the classpath. This enforcement can break the build, or can just result in warnings. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -7588,26 +7672,26 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) -`--[no]incompatible_disable_native_apple_binary_rule` default: "false" -: No-op. Kept here for backwards compatibility. +`--[no]incompatible_disable_native_android_rules` default: "false" +: If enabled, direct usage of the native Android rules is disabled. Please use the Starlark Android rules from https://github.com/bazelbuild/rules\_android Tags: - [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE), [`deprecated`](#metadata_tag_DEPRECATED) + [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]one_version_enforcement_on_java_tests` default: "true" -: When enabled, and with experimental_one_version_enforcement set to a non-NONE value, enforce one version on java_test targets. This flag can be disabled to improve incremental test performance at the expense of missing potential one version violations. +: When enabled, and with experimental\_one\_version\_enforcement set to a non-NONE value, enforce one version on java\_test targets. This flag can be disabled to improve incremental test performance at the expense of missing potential one version violations. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--strict_proto_deps=` default: "error" -: Unless OFF, checks that a proto_library target explicitly declares all directly used targets as dependencies. +: Unless OFF, checks that a proto\_library target explicitly declares all directly used targets as dependencies. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--strict_public_imports=` default: "off" -: Unless OFF, checks that a proto_library target explicitly declares all targets used in 'import public' as exported. +: Unless OFF, checks that a proto\_library target explicitly declares all targets used in 'import public' as exported. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -7630,7 +7714,7 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Options that affect the signing outputs of a build: -`--apk_signing_method=` default: "v1_v2" +`--apk_signing_method=` default: "v1\_v2" : Implementation to use to sign APKs Tags: @@ -7645,13 +7729,13 @@ Options that affect the signing outputs of a build: This option affects semantics of the Starlark language or the build API accessible to BUILD files, .bzl files, or WORKSPACE files.: `--[no]incompatible_disallow_sdk_frameworks_attributes` default: "false" -: If true, disallow sdk_frameworks and weak_sdk_frameworks attributes in objc_library and objc_import. +: If true, disallow sdk\_frameworks and weak\_sdk\_frameworks attributes in objc\_library and objc\_import. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_objc_alwayslink_by_default` default: "false" -: If true, make the default value true for alwayslink attributes in objc_library and objc_import. +: If true, make the default value true for alwayslink attributes in objc\_library and objc\_import. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -7685,6 +7769,24 @@ Options that govern the behavior of the test environment or test runner: The default test resources specified by this flag are overridden by explicit resources specified in tags. +`--[no]experimental_android_use_parallel_dex2oat` default: "false" +: Use dex2oat in parallel to possibly speed up android\_test. + + Tags: + [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS), [`experimental`](#metadata_tag_EXPERIMENTAL) + +`--ios_simulator_device=` default: see description +: The device to simulate when running an iOS application in the simulator, e.g. 'iPhone 6'. You can get a list of devices by running 'xcrun simctl list devicetypes' on the machine the simulator will be run on. + + Tags: + [`test_runner`](#effect_tag_TEST_RUNNER) + +`--ios_simulator_version=` default: see description +: The version of iOS to run on the simulator when running or testing. This is ignored for ios\_test rules if a target device is specified in the rule. + + Tags: + [`test_runner`](#effect_tag_TEST_RUNNER) + `--runs_per_test=` multiple uses are accumulated : Specifies number of times to run each test. If any of those attempts fail for any reason, the whole test is considered failed. Normally the value specified is @@ -7694,7 +7796,7 @@ Options that govern the behavior of the test environment or test runner: Alternate syntax: `regex_filter@runs_per_test`. Where `runs_per_test` stands for an integer value and `regex_filter` stands for a list of include and exclude - regular expression patterns (Also see --instrumentation_filter). + regular expression patterns (Also see --instrumentation\_filter). Example: `--runs_per_test=//foo/.*,-//foo/bar/.*@3` runs all tests in `//foo/` except those under `//foo/bar` three times. This option can be passed multiple times. The most @@ -7740,6 +7842,12 @@ Options that trigger optimizations of the build time: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]experimental_filter_library_jar_with_program_jar` default: "false" +: Filter the ProGuard ProgramJar to remove any classes also present in the LibraryJar. + + Tags: + [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_inmemory_dotd_files` default: "true" : If enabled, C++ .d files will be passed through in memory directly from the remote build nodes instead of being written to disk. @@ -7767,6 +7875,12 @@ Options that trigger optimizations of the build time: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]incremental_dexing` default: "true" +: Does most of the work for dexing separately for each Jar file. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) + `--[no]objc_use_dotd_pruning` default: "true" : If set, .d files emitted by clang will be used to prune the set of inputs passed into objc compiles. @@ -7849,11 +7963,8 @@ Miscellaneous options, not otherwise categorized.: Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) -`--experimental_turbine_cpu_reservation=` default: "1" -: The number of CPUs to reserve for Turbine. - `--[no]explicit_java_test_deps` default: "false" -: Explicitly specify a dependency to JUnit or Hamcrest in a java_test instead of accidentally obtaining from the TestRunner's deps. Only works for bazel right now. +: Explicitly specify a dependency to JUnit or Hamcrest in a java\_test instead of accidentally obtaining from the TestRunner's deps. Only works for bazel right now. `--host_java_launcher=` default: see description : The Java launcher used by tools that are executed during a build. @@ -7862,7 +7973,7 @@ Miscellaneous options, not otherwise categorized.: : Additional options to pass to javac when building tools that are executed during a build. `--host_jvmopt=` multiple uses are accumulated -: Additional options to pass to the Java VM when building tools that are executed during the build. These options will get added to the VM startup options of each java_binary target. +: Additional options to pass to the Java VM when building tools that are executed during the build. These options will get added to the VM startup options of each java\_binary target. `--[no]incompatible_exclusive_test_sandboxed` default: "true" : If true, exclusive tests will run with sandboxed strategy. Add `local` tag to force @@ -7884,7 +7995,7 @@ Miscellaneous options, not otherwise categorized.: : Additional options to pass to the J2ObjC tool. `--java_debug` -: Causes the Java virtual machine of a java test to wait for a connection from a JDWP-compliant debugger (such as jdb) before starting the test. Implies -test_output=streamed. +: Causes the Java virtual machine of a java test to wait for a connection from a JDWP-compliant debugger (such as jdb) before starting the test. Implies -test\_output=streamed. Expands to: @@ -7910,14 +8021,14 @@ Miscellaneous options, not otherwise categorized.: `--java_launcher=` default: see description : The Java launcher to use when building Java binaries. If this flag is set to the empty string, the JDK launcher is used. The "launcher" attribute overrides this flag. -`--java_runtime_version=` default: "local_jdk" +`--java_runtime_version=` default: "local\_jdk" : The Java runtime version `--javacopt=` multiple uses are accumulated : Additional options to pass to javac. `--jvmopt=` multiple uses are accumulated -: Additional options to pass to the Java VM. These options will get added to the VM startup options of each java_binary target. +: Additional options to pass to the Java VM. These options will get added to the VM startup options of each java\_binary target. `--legacy_main_dex_list_generator=` default: see description : Specifies a binary to use to generate the list of classes that must be in the main dex when compiling legacy multidex. @@ -7926,43 +8037,43 @@ Miscellaneous options, not otherwise categorized.: : Specifies a binary to use to do dexing without sharding. `--plugin=` multiple uses are accumulated -: Plugins to use in the build. Currently works with java_plugin. +: Plugins to use in the build. Currently works with java\_plugin. `--proguard_top=` default: see description : Specifies which version of ProGuard to use for code removal when building a Java binary. -`--proto_compiler=` default: "@bazel_tools//tools/proto:protoc" +`--proto_compiler=` default: "@bazel\_tools//tools/proto:protoc" : The label of the proto-compiler. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--[no]proto_profile` default: "true" -: Whether to pass profile_path to the proto compiler. +: Whether to pass profile\_path to the proto compiler. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--proto_profile_path=` default: see description -: The profile to pass to the proto compiler as profile_path. If unset, but --proto_profile is true (the default), infers the path from --fdo_optimize. +: The profile to pass to the proto compiler as profile\_path. If unset, but --proto\_profile is true (the default), infers the path from --fdo\_optimize. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_cc=` default: "@bazel_tools//tools/proto:cc_toolchain" -: Label of proto_lang_toolchain() which describes how to compile C++ protos +`--proto_toolchain_for_cc=` default: "@bazel\_tools//tools/proto:cc\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile C++ protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_java=` default: "@bazel_tools//tools/proto:java_toolchain" -: Label of proto_lang_toolchain() which describes how to compile Java protos +`--proto_toolchain_for_java=` default: "@bazel\_tools//tools/proto:java\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile Java protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_javalite=` default: "@bazel_tools//tools/proto:javalite_toolchain" -: Label of proto_lang_toolchain() which describes how to compile JavaLite protos +`--proto_toolchain_for_javalite=` default: "@bazel\_tools//tools/proto:javalite\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile JavaLite protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -8004,9 +8115,6 @@ Miscellaneous options, not otherwise categorized.: `--test_result_expiration=` default: "-1" : This option is deprecated and has no effect. - Tags: - [`deprecated`](#metadata_tag_DEPRECATED) - `--[no]test_runner_fail_fast` default: "false" : Forwards fail fast option to the test runner. The test runner should stop execution upon first failure. @@ -8022,7 +8130,7 @@ Miscellaneous options, not otherwise categorized.: `--tool_java_language_version=` default: "" : The Java language version used to execute the tools that are needed during a build -`--tool_java_runtime_version=` default: "remotejdk_11" +`--tool_java_runtime_version=` default: "remotejdk\_11" : The Java runtime version used to execute tools during the build `--[no]use_ijars` default: "true" @@ -8069,7 +8177,7 @@ Options that control the output of the command: [`bazel_monitoring`](#effect_tag_BAZEL_MONITORING) `--skykey_filter=` default: ".\*" -: Regex filter of SkyKey names to output. Only used with --skyframe=deps, rdeps, function_graph. +: Regex filter of SkyKey names to output. Only used with --skyframe=deps, rdeps, function\_graph. Tags: [`bazel_monitoring`](#effect_tag_BAZEL_MONITORING) @@ -8101,7 +8209,7 @@ Options that control build execution: [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT) `--loading_phase_threads=) eg. "auto", "HOST_CPUS*.5">` default: "auto" -: Number of parallel threads to use for the loading/analysis phase.Takes an integer, or a keyword ("auto", "HOST_CPUS", "HOST_RAM"), optionally followed by an operation ([-|*]<float>) eg. "auto", "HOST_CPUS*.5". "auto" sets a reasonable default based on host resources. Must be at least 1. +: Number of parallel threads to use for the loading/analysis phase.Takes an integer, or a keyword ("auto", "HOST\_CPUS", "HOST\_RAM"), optionally followed by an operation ([-|*]) eg. "auto", "HOST\_CPUS*.5". "auto" sets a reasonable default based on host resources. Must be at least 1. Tags: [`bazel_internal_configuration`](#effect_tag_BAZEL_INTERNAL_CONFIGURATION) @@ -8109,13 +8217,13 @@ Options that control build execution: This option affects semantics of the Starlark language or the build API accessible to BUILD files, .bzl files, or WORKSPACE files.: `--[no]incompatible_config_setting_private_default_visibility` default: "false" -: If incompatible_enforce_config_setting_visibility=false, this is a noop. Else, if this flag is false, any config_setting without an explicit visibility attribute is //visibility:public. If this flag is true, config_setting follows the same visibility logic as all other rules. See https://github.com/bazelbuild/bazel/issues/12933. +: If incompatible\_enforce\_config\_setting\_visibility=false, this is a noop. Else, if this flag is false, any config\_setting without an explicit visibility attribute is //visibility:public. If this flag is true, config\_setting follows the same visibility logic as all other rules. See https://github.com/bazelbuild/bazel/issues/12933. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_enforce_config_setting_visibility` default: "true" -: If true, enforce config_setting visibility restrictions. If false, every config_setting is visible to every target. See https://github.com/bazelbuild/bazel/issues/12932. +: If true, enforce config\_setting visibility restrictions. If false, every config\_setting is visible to every target. See https://github.com/bazelbuild/bazel/issues/12932. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -8147,7 +8255,7 @@ Miscellaneous options, not otherwise categorized.: `--deleted_packages=` multiple uses are accumulated : A comma-separated list of names of packages which the build system will consider non-existent, even if they are visible somewhere on the package path. - Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package_path entry. Specifying --deleted_packages x/y avoids this problem. + Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package\_path entry. Specifying --deleted\_packages x/y avoids this problem. `--[no]fetch` default: "true" : Allows the command to fetch external dependencies. If set to false, the command will utilize any cached version of the dependency, and if none exists, the command will result in failure. @@ -8338,13 +8446,13 @@ Options that configure the toolchain used for action execution: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--android_manifest_merger=` default: "android" -: Selects the manifest merger to use for android_binary rules. Flag to help the transition to the Android manifest merger from the legacy merger. +: Selects the manifest merger to use for android\_binary rules. Flag to help the transition to the Android manifest merger from the legacy merger. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--android_platforms=` default: "" -: Sets the platforms that android_binary targets use. If multiple platforms are specified, then the binary is a fat APKs, which contains native binaries for each specified target platform. +: Sets the platforms that android\_binary targets use. If multiple platforms are specified, then the binary is a fat APKs, which contains native binaries for each specified target platform. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -8361,21 +8469,21 @@ Options that configure the toolchain used for action execution: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION) -`--coverage_output_generator=` default: "@bazel_tools//tools/test:lcov_merger" +`--coverage_output_generator=` default: "@bazel\_tools//tools/test:lcov\_merger" : Location of the binary that is used to postprocess raw coverage reports. This must be a binary target. Defaults to `@bazel_tools//tools/test:lcov_merger`. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--coverage_report_generator=` default: "@bazel_tools//tools/test:coverage_report_generator" +`--coverage_report_generator=` default: "@bazel\_tools//tools/test:coverage\_report\_generator" : Location of the binary that is used to generate coverage reports. This must be a binary target. Defaults to `@bazel_tools//tools/test:coverage_report_generator`. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--coverage_support=` default: "@bazel_tools//tools/test:coverage_support" +`--coverage_support=` default: "@bazel\_tools//tools/test:coverage\_support" : Location of support files that are required on the inputs of every test action that collects code coverage. Defaults to `//tools/test:coverage_support`. @@ -8389,7 +8497,7 @@ Options that configure the toolchain used for action execution: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]experimental_include_xcode_execution_requirements` default: "false" -: If set, add a "requires-xcode:{version}" execution requirement to every Xcode action. If the Xcode version has a hyphenated label, also add a "requires-xcode-label:{version_label}" execution requirement. +: If set, add a "requires-xcode:{version}" execution requirement to every Xcode action. If the Xcode version has a hyphenated label, also add a "requires-xcode-label:{version\_label}" execution requirement. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -8432,12 +8540,12 @@ Options that configure the toolchain used for action execution: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION) `--host_grte_top=` default: see description -: If specified, this setting overrides the libc top-level directory (--grte_top) for the exec configuration. +: If specified, this setting overrides the libc top-level directory (--grte\_top) for the exec configuration. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) -`--host_platform=` default: "@bazel_tools//tools:host_platform" +`--host_platform=` default: "@bazel\_tools//tools:host\_platform" : The label of a platform rule that describes the host system. Tags: @@ -8459,6 +8567,12 @@ Options that configure the toolchain used for action execution: Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) +`--[no]incompatible_cuda_compile_action` default: "false" +: Compile cuda files using the cuda-compile action in the toolchain. + + Tags: + [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) + `--[no]incompatible_dont_enable_host_nonhost_crosstool_features` default: "true" : If true, Bazel will not enable 'host' and 'nonhost' features in the c++ toolchain (see https://github.com/bazelbuild/bazel/issues/7407 for more information). @@ -8484,13 +8598,13 @@ Options that configure the toolchain used for action execution: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ios_sdk_version=` default: see description -: Specifies the version of the iOS SDK to use to build iOS applications. If unspecified, uses the default iOS SDK version from 'xcode_version'. +: Specifies the version of the iOS SDK to use to build iOS applications. If unspecified, uses the default iOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--macos_sdk_version=` default: see description -: Specifies the version of the macOS SDK to use to build macOS applications. If unspecified, uses the default macOS SDK version from 'xcode_version'. +: Specifies the version of the macOS SDK to use to build macOS applications. If unspecified, uses the default macOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -8517,19 +8631,19 @@ Options that configure the toolchain used for action execution: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--tvos_sdk_version=` default: see description -: Specifies the version of the tvOS SDK to use to build tvOS applications. If unspecified, uses the default tvOS SDK version from 'xcode_version'. +: Specifies the version of the tvOS SDK to use to build tvOS applications. If unspecified, uses the default tvOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--[no]use_platforms_in_apple_crosstool_transition` default: "false" -: Makes apple_crosstool_transition fall back to using the value of `--platforms` flag instead of legacy `--cpu` when needed. +: Makes apple\_crosstool\_transition fall back to using the value of `--platforms` flag instead of legacy `--cpu` when needed. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--watchos_sdk_version=` default: see description -: Specifies the version of the watchOS SDK to use to build watchOS applications. If unspecified, uses the default watchOS SDK version from 'xcode_version'. +: Specifies the version of the watchOS SDK to use to build watchOS applications. If unspecified, uses the default watchOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -8540,8 +8654,8 @@ Options that configure the toolchain used for action execution: Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) -`--xcode_version_config=` default: "@bazel_tools//tools/cpp:host_xcodes" -: The label of the xcode_config rule to be used for selecting the Xcode version in the build configuration. +`--xcode_version_config=` default: "@bazel\_tools//tools/cpp:host\_xcodes" +: The label of the xcode\_config rule to be used for selecting the Xcode version in the build configuration. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -8573,19 +8687,19 @@ Options that control the output of the command: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--cc_proto_library_header_suffixes=` default: ".pb.h" -: Sets the suffixes of header files that a cc_proto_library creates. +: Sets the suffixes of header files that a cc\_proto\_library creates. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--cc_proto_library_source_suffixes=` default: ".pb.cc" -: Sets the suffixes of source files that a cc_proto_library creates. +: Sets the suffixes of source files that a cc\_proto\_library creates. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--[no]experimental_proto_descriptor_sets_include_source_info` default: "false" -: Run extra actions for alternative Java api versions in a proto_library. +: Run extra actions for alternative Java api versions in a proto\_library. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -8597,7 +8711,7 @@ Options that control the output of the command: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--fission=` default: "no" -: Specifies which compilation modes use fission for C++ compilations and links. May be any combination of {'fastbuild', 'dbg', 'opt'} or the special values 'yes' to enable all modes and 'no' to disable all modes. +: Specifies which compilation modes use fission for C++ compilations and links. May be any combination of {'fastbuild', 'dbg', 'opt'} or the special values 'yes' to enable all modes and 'no' to disable all modes. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -8664,20 +8778,32 @@ Options that let the user configure the intended output, affecting its value, as Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) +`--[no]android_databinding_use_androidx` default: "true" +: Generate AndroidX-compatible data-binding files. This is only used with databinding v2. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + +`--[no]android_databinding_use_v3_4_args` default: "true" +: Use android databinding v2 with 3.4.0 argument. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--android_dynamic_mode=` default: "off" -: Determines whether C++ deps of Android rules will be linked dynamically when a cc_binary does not explicitly create a shared library. 'default' means bazel will choose whether to link dynamically. 'fully' means all libraries will be linked dynamically. 'off' means that all libraries will be linked in mostly static mode. +: Determines whether C++ deps of Android rules will be linked dynamically when a cc\_binary does not explicitly create a shared library. 'default' means bazel will choose whether to link dynamically. 'fully' means all libraries will be linked dynamically. 'off' means that all libraries will be linked in mostly static mode. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--android_manifest_merger_order=` default: "alphabetical" -: Sets the order of manifests passed to the manifest merger for Android binaries. ALPHABETICAL means manifests are sorted by path relative to the execroot. ALPHABETICAL_BY_CONFIGURATION means manifests are sorted by paths relative to the configuration directory within the output directory. DEPENDENCY means manifests are ordered with each library's manifest coming before the manifests of its dependencies. +: Sets the order of manifests passed to the manifest merger for Android binaries. ALPHABETICAL means manifests are sorted by path relative to the execroot. ALPHABETICAL\_BY\_CONFIGURATION means manifests are sorted by paths relative to the configuration directory within the output directory. DEPENDENCY means manifests are ordered with each library's manifest coming before the manifests of its dependencies. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`execution`](#effect_tag_EXECUTION) `--[no]android_resource_shrinking` default: "false" -: Enables resource shrinking for android_binary APKs that use ProGuard. +: Enables resource shrinking for android\_binary APKs that use ProGuard. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -8730,7 +8856,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--cs_fdo_profile=` default: see description -: The cs_fdo_profile representing the context sensitive profile to be used for optimization. +: The cs\_fdo\_profile representing the context sensitive profile to be used for optimization. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -8791,8 +8917,14 @@ Options that let the user configure the intended output, affecting its value, as Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]experimental_android_databinding_v2` default: "true" +: Use android databinding v2. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_android_resource_shrinking` default: "false" -: Enables resource shrinking for android_binary APKs that use ProGuard. +: Enables resource shrinking for android\_binary APKs that use ProGuard. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -8844,7 +8976,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--[no]experimental_use_llvm_covmap` default: "false" -: If specified, Bazel will generate llvm-cov coverage map information rather than gcov when collect_code_coverage is enabled. +: If specified, Bazel will generate llvm-cov coverage map information rather than gcov when collect\_code\_coverage is enabled. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -8876,7 +9008,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--fdo_profile=` default: see description -: The fdo_profile representing the profile to be used for optimization. +: The fdo\_profile representing the profile to be used for optimization. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -8952,13 +9084,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--host_macos_minimum_os=` default: see description -: Minimum compatible macOS version for host targets. If unspecified, uses 'macos_sdk_version'. +: Minimum compatible macOS version for host targets. If unspecified, uses 'macos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--host_per_file_copt=` multiple uses are accumulated -: Additional options to selectively pass to the C/C++ compiler when compiling certain files in the exec configurations. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation_filter). option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --host_per_file_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. +: Additional options to selectively pass to the C/C++ compiler when compiling certain files in the exec configurations. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation\_filter). option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --host\_per\_file\_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -9002,17 +9134,23 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ios_minimum_os=` default: see description -: Minimum compatible iOS version for target simulators and devices. If unspecified, uses 'ios_sdk_version'. +: Minimum compatible iOS version for target simulators and devices. If unspecified, uses 'ios\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--ios_multi_cpus=` multiple uses are accumulated -: Comma-separated list of architectures to build an ios_application with. The result is a universal binary containing all specified architectures. +: Comma-separated list of architectures to build an ios\_application with. The result is a universal binary containing all specified architectures. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) +`--[no]legacy_whole_archive` default: "true" +: Deprecated, superseded by --incompatible\_remove\_legacy\_whole\_archive (see https://github.com/bazelbuild/bazel/issues/7362 for details). When on, use --whole-archive for cc\_binary rules that have linkshared=True and either linkstatic=True or '-static' in linkopts. This is for backwards compatibility only. A better alternative is to use alwayslink=1 where required. + + Tags: + [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`deprecated`](#metadata_tag_DEPRECATED) + `--linkopt=` multiple uses are accumulated : Additional option to pass to gcc when linking. @@ -9020,13 +9158,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ltobackendopt=` multiple uses are accumulated -: Additional option to pass to the LTO backend step (under --features=thin_lto). +: Additional option to pass to the LTO backend step (under --features=thin\_lto). Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ltoindexopt=` multiple uses are accumulated -: Additional option to pass to the LTO indexing step (under --features=thin_lto). +: Additional option to pass to the LTO indexing step (under --features=thin\_lto). Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -9038,7 +9176,7 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--macos_minimum_os=` default: see description -: Minimum compatible macOS version for targets. If unspecified, uses 'macos_sdk_version'. +: Minimum compatible macOS version for targets. If unspecified, uses 'macos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -9050,7 +9188,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]objc_enable_binary_stripping` default: "false" -: Whether to perform symbol and dead-code strippings on linked binaries. Binary strippings will be performed if both this flag and --compilation_mode=opt are specified. +: Whether to perform symbol and dead-code strippings on linked binaries. Binary strippings will be performed if both this flag and --compilation\_mode=opt are specified. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES) @@ -9062,13 +9200,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES) `--per_file_copt=` multiple uses are accumulated -: Additional options to selectively pass to gcc when compiling certain files. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation_filter). option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per_file_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. +: Additional options to selectively pass to gcc when compiling certain files. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation\_filter). option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per\_file\_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--per_file_ltobackendopt=` multiple uses are accumulated -: Additional options to selectively pass to LTO backend (under --features=thin_lto) when compiling certain backend objects. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns. option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per_file_ltobackendopt=//foo/.\*.o,-//foo/bar.o@-O0 adds the -O0 command line option to the LTO backend command line of all o files in //foo/ except bar.o. +: Additional options to selectively pass to LTO backend (under --features=thin\_lto) when compiling certain backend objects. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns. option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per\_file\_ltobackendopt=//foo/.\*.o,-//foo/bar.o@-O0 adds the -O0 command line option to the LTO backend command line of all o files in //foo/ except bar.o. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -9080,19 +9218,19 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--propeller_optimize=` default: see description -: Use Propeller profile information to optimize the build target.A propeller profile must consist of at least one of two files, a cc profile and a ld profile. This flag accepts a build label which must refer to the propeller profile input files. For example, the BUILD file that defines the label, in a/b/BUILD:propeller_optimize( name = "propeller_profile", cc_profile = "propeller_cc_profile.txt", ld_profile = "propeller_ld_profile.txt",)An exports_files directive may have to be added to the corresponding package to make these files visible to Bazel. The option must be used as: --propeller_optimize=//a/b:propeller_profile +: Use Propeller profile information to optimize the build target.A propeller profile must consist of at least one of two files, a cc profile and a ld profile. This flag accepts a build label which must refer to the propeller profile input files. For example, the BUILD file that defines the label, in a/b/BUILD:propeller\_optimize( name = "propeller\_profile", cc\_profile = "propeller\_cc\_profile.txt", ld\_profile = "propeller\_ld\_profile.txt",)An exports\_files directive may have to be added to the corresponding package to make these files visible to Bazel. The option must be used as: --propeller\_optimize=//a/b:propeller\_profile Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--propeller_optimize_absolute_cc_profile=` default: see description -: Absolute path name of cc_profile file for Propeller Optimized builds. +: Absolute path name of cc\_profile file for Propeller Optimized builds. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--propeller_optimize_absolute_ld_profile=` default: see description -: Absolute path name of ld_profile file for Propeller Optimized builds. +: Absolute path name of ld\_profile file for Propeller Optimized builds. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -9126,13 +9264,13 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--strip=` default: "sometimes" -: Specifies whether to strip binaries and shared libraries (using "-Wl,--strip-debug"). The default value of 'sometimes' means strip iff --compilation_mode=fastbuild. +: Specifies whether to strip binaries and shared libraries (using "-Wl,--strip-debug"). The default value of 'sometimes' means strip iff --compilation\_mode=fastbuild. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--stripopt=` multiple uses are accumulated -: Additional options to pass to strip when generating a '<name>.stripped' binary. +: Additional options to pass to strip when generating a '.stripped' binary. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -9144,7 +9282,7 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--tvos_minimum_os=` default: see description -: Minimum compatible tvOS version for target simulators and devices. If unspecified, uses 'tvos_sdk_version'. +: Minimum compatible tvOS version for target simulators and devices. If unspecified, uses 'tvos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -9162,13 +9300,13 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--watchos_minimum_os=` default: see description -: Minimum compatible watchOS version for target simulators and devices. If unspecified, uses 'watchos_sdk_version'. +: Minimum compatible watchOS version for target simulators and devices. If unspecified, uses 'watchos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--xbinary_fdo=` default: see description -: Use XbinaryFDO profile information to optimize compilation. Specify the name of default cross binary profile. When the option is used together with --fdo_instrument/--fdo_optimize/--fdo_profile, those options will always prevail as if xbinary_fdo is never specified. +: Use XbinaryFDO profile information to optimize compilation. Specify the name of default cross binary profile. When the option is used together with --fdo\_instrument/--fdo\_optimize/--fdo\_profile, those options will always prevail as if xbinary\_fdo is never specified. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -9199,14 +9337,20 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) +`--[no]experimental_check_desugar_deps` default: "true" +: Whether to double-check correct desugaring at Android binary level. + + Tags: + [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_enforce_transitive_visibility` default: "false" -: If true, enable package()s to set the transitive_visibility attribute to restrict which packages may depend on them. +: If true, enable package()s to set the transitive\_visibility attribute to restrict which packages may depend on them. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--experimental_one_version_enforcement=` default: "OFF" -: When enabled, enforce that a java_binary rule can't contain more than one version of the same class file on the classpath. This enforcement can break the build, or can just result in warnings. +: When enabled, enforce that a java\_binary rule can't contain more than one version of the same class file on the classpath. This enforcement can break the build, or can just result in warnings. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -9223,26 +9367,26 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) -`--[no]incompatible_disable_native_apple_binary_rule` default: "false" -: No-op. Kept here for backwards compatibility. +`--[no]incompatible_disable_native_android_rules` default: "false" +: If enabled, direct usage of the native Android rules is disabled. Please use the Starlark Android rules from https://github.com/bazelbuild/rules\_android Tags: - [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE), [`deprecated`](#metadata_tag_DEPRECATED) + [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]one_version_enforcement_on_java_tests` default: "true" -: When enabled, and with experimental_one_version_enforcement set to a non-NONE value, enforce one version on java_test targets. This flag can be disabled to improve incremental test performance at the expense of missing potential one version violations. +: When enabled, and with experimental\_one\_version\_enforcement set to a non-NONE value, enforce one version on java\_test targets. This flag can be disabled to improve incremental test performance at the expense of missing potential one version violations. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--strict_proto_deps=` default: "error" -: Unless OFF, checks that a proto_library target explicitly declares all directly used targets as dependencies. +: Unless OFF, checks that a proto\_library target explicitly declares all directly used targets as dependencies. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--strict_public_imports=` default: "off" -: Unless OFF, checks that a proto_library target explicitly declares all targets used in 'import public' as exported. +: Unless OFF, checks that a proto\_library target explicitly declares all targets used in 'import public' as exported. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -9265,7 +9409,7 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Options that affect the signing outputs of a build: -`--apk_signing_method=` default: "v1_v2" +`--apk_signing_method=` default: "v1\_v2" : Implementation to use to sign APKs Tags: @@ -9280,13 +9424,13 @@ Options that affect the signing outputs of a build: This option affects semantics of the Starlark language or the build API accessible to BUILD files, .bzl files, or WORKSPACE files.: `--[no]incompatible_disallow_sdk_frameworks_attributes` default: "false" -: If true, disallow sdk_frameworks and weak_sdk_frameworks attributes in objc_library and objc_import. +: If true, disallow sdk\_frameworks and weak\_sdk\_frameworks attributes in objc\_library and objc\_import. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_objc_alwayslink_by_default` default: "false" -: If true, make the default value true for alwayslink attributes in objc_library and objc_import. +: If true, make the default value true for alwayslink attributes in objc\_library and objc\_import. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -9320,6 +9464,24 @@ Options that govern the behavior of the test environment or test runner: The default test resources specified by this flag are overridden by explicit resources specified in tags. +`--[no]experimental_android_use_parallel_dex2oat` default: "false" +: Use dex2oat in parallel to possibly speed up android\_test. + + Tags: + [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS), [`experimental`](#metadata_tag_EXPERIMENTAL) + +`--ios_simulator_device=` default: see description +: The device to simulate when running an iOS application in the simulator, e.g. 'iPhone 6'. You can get a list of devices by running 'xcrun simctl list devicetypes' on the machine the simulator will be run on. + + Tags: + [`test_runner`](#effect_tag_TEST_RUNNER) + +`--ios_simulator_version=` default: see description +: The version of iOS to run on the simulator when running or testing. This is ignored for ios\_test rules if a target device is specified in the rule. + + Tags: + [`test_runner`](#effect_tag_TEST_RUNNER) + `--runs_per_test=` multiple uses are accumulated : Specifies number of times to run each test. If any of those attempts fail for any reason, the whole test is considered failed. Normally the value specified is @@ -9329,7 +9491,7 @@ Options that govern the behavior of the test environment or test runner: Alternate syntax: `regex_filter@runs_per_test`. Where `runs_per_test` stands for an integer value and `regex_filter` stands for a list of include and exclude - regular expression patterns (Also see --instrumentation_filter). + regular expression patterns (Also see --instrumentation\_filter). Example: `--runs_per_test=//foo/.*,-//foo/bar/.*@3` runs all tests in `//foo/` except those under `//foo/bar` three times. This option can be passed multiple times. The most @@ -9375,6 +9537,12 @@ Options that trigger optimizations of the build time: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]experimental_filter_library_jar_with_program_jar` default: "false" +: Filter the ProGuard ProgramJar to remove any classes also present in the LibraryJar. + + Tags: + [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_inmemory_dotd_files` default: "true" : If enabled, C++ .d files will be passed through in memory directly from the remote build nodes instead of being written to disk. @@ -9402,6 +9570,12 @@ Options that trigger optimizations of the build time: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]incremental_dexing` default: "true" +: Does most of the work for dexing separately for each Jar file. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) + `--[no]objc_use_dotd_pruning` default: "true" : If set, .d files emitted by clang will be used to prune the set of inputs passed into objc compiles. @@ -9484,11 +9658,8 @@ Miscellaneous options, not otherwise categorized.: Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) -`--experimental_turbine_cpu_reservation=` default: "1" -: The number of CPUs to reserve for Turbine. - `--[no]explicit_java_test_deps` default: "false" -: Explicitly specify a dependency to JUnit or Hamcrest in a java_test instead of accidentally obtaining from the TestRunner's deps. Only works for bazel right now. +: Explicitly specify a dependency to JUnit or Hamcrest in a java\_test instead of accidentally obtaining from the TestRunner's deps. Only works for bazel right now. `--host_java_launcher=` default: see description : The Java launcher used by tools that are executed during a build. @@ -9497,7 +9668,7 @@ Miscellaneous options, not otherwise categorized.: : Additional options to pass to javac when building tools that are executed during a build. `--host_jvmopt=` multiple uses are accumulated -: Additional options to pass to the Java VM when building tools that are executed during the build. These options will get added to the VM startup options of each java_binary target. +: Additional options to pass to the Java VM when building tools that are executed during the build. These options will get added to the VM startup options of each java\_binary target. `--[no]incompatible_exclusive_test_sandboxed` default: "true" : If true, exclusive tests will run with sandboxed strategy. Add `local` tag to force @@ -9519,7 +9690,7 @@ Miscellaneous options, not otherwise categorized.: : Additional options to pass to the J2ObjC tool. `--java_debug` -: Causes the Java virtual machine of a java test to wait for a connection from a JDWP-compliant debugger (such as jdb) before starting the test. Implies -test_output=streamed. +: Causes the Java virtual machine of a java test to wait for a connection from a JDWP-compliant debugger (such as jdb) before starting the test. Implies -test\_output=streamed. Expands to: @@ -9545,14 +9716,14 @@ Miscellaneous options, not otherwise categorized.: `--java_launcher=` default: see description : The Java launcher to use when building Java binaries. If this flag is set to the empty string, the JDK launcher is used. The "launcher" attribute overrides this flag. -`--java_runtime_version=` default: "local_jdk" +`--java_runtime_version=` default: "local\_jdk" : The Java runtime version `--javacopt=` multiple uses are accumulated : Additional options to pass to javac. `--jvmopt=` multiple uses are accumulated -: Additional options to pass to the Java VM. These options will get added to the VM startup options of each java_binary target. +: Additional options to pass to the Java VM. These options will get added to the VM startup options of each java\_binary target. `--legacy_main_dex_list_generator=` default: see description : Specifies a binary to use to generate the list of classes that must be in the main dex when compiling legacy multidex. @@ -9561,43 +9732,43 @@ Miscellaneous options, not otherwise categorized.: : Specifies a binary to use to do dexing without sharding. `--plugin=` multiple uses are accumulated -: Plugins to use in the build. Currently works with java_plugin. +: Plugins to use in the build. Currently works with java\_plugin. `--proguard_top=` default: see description : Specifies which version of ProGuard to use for code removal when building a Java binary. -`--proto_compiler=` default: "@bazel_tools//tools/proto:protoc" +`--proto_compiler=` default: "@bazel\_tools//tools/proto:protoc" : The label of the proto-compiler. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--[no]proto_profile` default: "true" -: Whether to pass profile_path to the proto compiler. +: Whether to pass profile\_path to the proto compiler. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--proto_profile_path=` default: see description -: The profile to pass to the proto compiler as profile_path. If unset, but --proto_profile is true (the default), infers the path from --fdo_optimize. +: The profile to pass to the proto compiler as profile\_path. If unset, but --proto\_profile is true (the default), infers the path from --fdo\_optimize. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_cc=` default: "@bazel_tools//tools/proto:cc_toolchain" -: Label of proto_lang_toolchain() which describes how to compile C++ protos +`--proto_toolchain_for_cc=` default: "@bazel\_tools//tools/proto:cc\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile C++ protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_java=` default: "@bazel_tools//tools/proto:java_toolchain" -: Label of proto_lang_toolchain() which describes how to compile Java protos +`--proto_toolchain_for_java=` default: "@bazel\_tools//tools/proto:java\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile Java protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_javalite=` default: "@bazel_tools//tools/proto:javalite_toolchain" -: Label of proto_lang_toolchain() which describes how to compile JavaLite protos +`--proto_toolchain_for_javalite=` default: "@bazel\_tools//tools/proto:javalite\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile JavaLite protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -9639,9 +9810,6 @@ Miscellaneous options, not otherwise categorized.: `--test_result_expiration=` default: "-1" : This option is deprecated and has no effect. - Tags: - [`deprecated`](#metadata_tag_DEPRECATED) - `--[no]test_runner_fail_fast` default: "false" : Forwards fail fast option to the test runner. The test runner should stop execution upon first failure. @@ -9657,7 +9825,7 @@ Miscellaneous options, not otherwise categorized.: `--tool_java_language_version=` default: "" : The Java language version used to execute the tools that are needed during a build -`--tool_java_runtime_version=` default: "remotejdk_11" +`--tool_java_runtime_version=` default: "remotejdk\_11" : The Java runtime version used to execute tools during the build `--[no]use_ijars` default: "true" @@ -9700,7 +9868,7 @@ Inherits all options from [build](#build). Options that let the user configure the intended output, affecting its value, as opposed to its existence: `--info_output_type=` default: "stdout" -: If stdout, results are directly printed to the console. If response_proto, the info command results are packed in response extensions. +: If stdout, results are directly printed to the console. If response\_proto, the info command results are packed in response extensions. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -9725,12 +9893,12 @@ Options that control build execution: : Deprecated no-effect flag. Only skylark mode is still supported. Tags: - [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE), [`deprecated`](#metadata_tag_DEPRECATED) + [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) Options that configure the toolchain used for action execution: `--adb=` default: "" -: adb binary to use for the 'mobile-install' command. If unspecified, the one in the Android SDK specified by the --android_sdk_channel command line option (or the default SDK if --android_sdk_channel is not specified) is used. +: adb binary to use for the 'mobile-install' command. If unspecified, the one in the Android SDK specified by the --android\_sdk\_channel command line option (or the default SDK if --android\_sdk\_channel is not specified) is used. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS) @@ -9815,7 +9983,7 @@ Options that control build execution: [`execution`](#effect_tag_EXECUTION), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--loading_phase_threads=) eg. "auto", "HOST_CPUS*.5">` default: "auto" -: Number of parallel threads to use for the loading/analysis phase.Takes an integer, or a keyword ("auto", "HOST_CPUS", "HOST_RAM"), optionally followed by an operation ([-|*]<float>) eg. "auto", "HOST_CPUS*.5". "auto" sets a reasonable default based on host resources. Must be at least 1. +: Number of parallel threads to use for the loading/analysis phase.Takes an integer, or a keyword ("auto", "HOST\_CPUS", "HOST\_RAM"), optionally followed by an operation ([-|*]) eg. "auto", "HOST\_CPUS*.5". "auto" sets a reasonable default based on host resources. Must be at least 1. Tags: [`bazel_internal_configuration`](#effect_tag_BAZEL_INTERNAL_CONFIGURATION) @@ -10138,7 +10306,7 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) `--[no]experimental_enforce_transitive_visibility` default: "false" -: If true, enable package()s to set the transitive_visibility attribute to restrict which packages may depend on them. +: If true, enable package()s to set the transitive\_visibility attribute to restrict which packages may depend on them. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -10162,13 +10330,13 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit This option affects semantics of the Starlark language or the build API accessible to BUILD files, .bzl files, or WORKSPACE files.: `--[no]incompatible_config_setting_private_default_visibility` default: "false" -: If incompatible_enforce_config_setting_visibility=false, this is a noop. Else, if this flag is false, any config_setting without an explicit visibility attribute is //visibility:public. If this flag is true, config_setting follows the same visibility logic as all other rules. See https://github.com/bazelbuild/bazel/issues/12933. +: If incompatible\_enforce\_config\_setting\_visibility=false, this is a noop. Else, if this flag is false, any config\_setting without an explicit visibility attribute is //visibility:public. If this flag is true, config\_setting follows the same visibility logic as all other rules. See https://github.com/bazelbuild/bazel/issues/12933. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_enforce_config_setting_visibility` default: "true" -: If true, enforce config_setting visibility restrictions. If false, every config_setting is visible to every target. See https://github.com/bazelbuild/bazel/issues/12932. +: If true, enforce config\_setting visibility restrictions. If false, every config\_setting is visible to every target. See https://github.com/bazelbuild/bazel/issues/12932. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -10205,7 +10373,7 @@ Options relating to the output and semantics of the `mod` subcommand: Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) -`--base_module=<"" for the root module; @ for a specific version of a module; for all versions of a module; @ for a repo with the given apparent name; or @@ for a repo with the given canonical name>` default: "<root>" +`--base_module=<"" for the root module; @ for a specific version of a module; for all versions of a module; @ for a repo with the given apparent name; or @@ for a repo with the given canonical name>` default: "" : Specify a module relative to which the specified target repos will be interpreted. Tags: @@ -10251,12 +10419,12 @@ Options relating to the output and semantics of the `mod` subcommand: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--extension_usages=s>` default: "" -: Specify modules whose extension usages will be displayed in the show_extension query. +: Specify modules whose extension usages will be displayed in the show\_extension query. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) -`--from=s>` default: "<root>" +`--from=s>` default: "" : The module(s) starting from which the dependency graph query will be displayed. Check each query’s description for the exact semantics. Defaults to ``. @@ -10313,7 +10481,7 @@ Miscellaneous options, not otherwise categorized.: `--deleted_packages=` multiple uses are accumulated : A comma-separated list of names of packages which the build system will consider non-existent, even if they are visible somewhere on the package path. - Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package_path entry. Specifying --deleted_packages x/y avoids this problem. + Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package\_path entry. Specifying --deleted\_packages x/y avoids this problem. `--[no]fetch` default: "true" : Allows the command to fetch external dependencies. If set to false, the command will utilize any cached version of the dependency, and if none exists, the command will result in failure. @@ -10324,14 +10492,14 @@ Miscellaneous options, not otherwise categorized.: `--[no]show_loading_progress` default: "true" : If enabled, causes Bazel to print "Loading package:" messages. -## Print_action Options +## Print\_action Options Inherits all options from [build](#build). Miscellaneous options, not otherwise categorized.: `--print_action_mnemonics=` multiple uses are accumulated -: Lists which mnemonics to filter print_action data by, no filtering takes place when left empty. +: Lists which mnemonics to filter print\_action data by, no filtering takes place when left empty. ## Query Options @@ -10357,7 +10525,7 @@ Options that control build execution: [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT) `--loading_phase_threads=) eg. "auto", "HOST_CPUS*.5">` default: "auto" -: Number of parallel threads to use for the loading/analysis phase.Takes an integer, or a keyword ("auto", "HOST_CPUS", "HOST_RAM"), optionally followed by an operation ([-|*]<float>) eg. "auto", "HOST_CPUS*.5". "auto" sets a reasonable default based on host resources. Must be at least 1. +: Number of parallel threads to use for the loading/analysis phase.Takes an integer, or a keyword ("auto", "HOST\_CPUS", "HOST\_RAM"), optionally followed by an operation ([-|*]) eg. "auto", "HOST\_CPUS*.5". "auto" sets a reasonable default based on host resources. Must be at least 1. Tags: [`bazel_internal_configuration`](#effect_tag_BAZEL_INTERNAL_CONFIGURATION) @@ -10680,7 +10848,7 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) `--[no]experimental_enforce_transitive_visibility` default: "false" -: If true, enable package()s to set the transitive_visibility attribute to restrict which packages may depend on them. +: If true, enable package()s to set the transitive\_visibility attribute to restrict which packages may depend on them. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -10704,13 +10872,13 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit This option affects semantics of the Starlark language or the build API accessible to BUILD files, .bzl files, or WORKSPACE files.: `--[no]incompatible_config_setting_private_default_visibility` default: "false" -: If incompatible_enforce_config_setting_visibility=false, this is a noop. Else, if this flag is false, any config_setting without an explicit visibility attribute is //visibility:public. If this flag is true, config_setting follows the same visibility logic as all other rules. See https://github.com/bazelbuild/bazel/issues/12933. +: If incompatible\_enforce\_config\_setting\_visibility=false, this is a noop. Else, if this flag is false, any config\_setting without an explicit visibility attribute is //visibility:public. If this flag is true, config\_setting follows the same visibility logic as all other rules. See https://github.com/bazelbuild/bazel/issues/12933. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_enforce_config_setting_visibility` default: "true" -: If true, enforce config_setting visibility restrictions. If false, every config_setting is visible to every target. See https://github.com/bazelbuild/bazel/issues/12932. +: If true, enforce config\_setting visibility restrictions. If false, every config\_setting is visible to every target. See https://github.com/bazelbuild/bazel/issues/12932. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -10736,13 +10904,13 @@ Options that govern the behavior of the test environment or test runner: Options relating to query output and semantics: `--aspect_deps=` default: "conservative" -: How to resolve aspect dependencies when the output format is one of {xml,proto,record}. 'off' means no aspect dependencies are resolved, 'conservative' (the default) means all declared aspect dependencies are added regardless of whether they are given the rule class of direct dependencies, 'precise' means that only those aspects are added that are possibly active given the rule class of the direct dependencies. Note that precise mode requires loading other packages to evaluate a single target thus making it slower than the other modes. Also note that even precise mode is not completely precise: the decision whether to compute an aspect is decided in the analysis phase, which is not run during 'bazel query'. +: How to resolve aspect dependencies when the output format is one of {xml,proto,record}. 'off' means no aspect dependencies are resolved, 'conservative' (the default) means all declared aspect dependencies are added regardless of whether they are given the rule class of direct dependencies, 'precise' means that only those aspects are added that are possibly active given the rule class of the direct dependencies. Note that precise mode requires loading other packages to evaluate a single target thus making it slower than the other modes. Also note that even precise mode is not completely precise: the decision whether to compute an aspect is decided in the analysis phase, which is not run during 'bazel query'. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) `--[no]consistent_labels` default: "false" -: If enabled, every query command emits labels as if by the Starlark `str` function applied to a `Label` instance. This is useful for tools that need to match the output of different query commands and/or labels emitted by rules. If not enabled, output formatters are free to emit apparent repository names (relative to the main repository) instead to make the output more readable. +: If enabled, every query command emits labels as if by the Starlark str function applied to a Label instance. This is useful for tools that need to match the output of different query commands and/or labels emitted by rules. If not enabled, output formatters are free to emit apparent repository names (relative to the main repository) instead to make the output more readable. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -10754,7 +10922,7 @@ Options relating to query output and semantics: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]experimental_graphless_query` default: "auto" -: If true, uses a Query implementation that does not make a copy of the graph. The new implementation only supports --order_output=no, as well as only a subset of output formatters. +: If true, uses a Query implementation that does not make a copy of the graph. The new implementation only supports --order\_output=no, as well as only a subset of output formatters. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT) @@ -10789,20 +10957,14 @@ Options relating to query output and semantics: Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) -`--[no]incompatible_package_group_build_output` default: "false" -: If enabled, `blaze query --output=build` will output `package_group` targets. - - Tags: - [`terminal_output`](#effect_tag_TERMINAL_OUTPUT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) - `--[no]incompatible_package_group_includes_double_slash` default: "true" -: If enabled, when outputting package_group's `packages` attribute, the leading `//` will not be omitted. +: If enabled, when outputting package\_group's `packages` attribute, the leading `//` will not be omitted. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]infer_universe_scope` default: "false" -: If set and --universe_scope is unset, then a value of --universe_scope will be inferred as the list of unique target patterns in the query expression. Note that the --universe_scope value inferred for a query expression that uses universe-scoped functions (e.g.`allrdeps`) may not be what you want, so you should use this option only if you know what you are doing. See https://bazel.build/reference/query#sky-query for details and examples. If --universe_scope is set, then this option's value is ignored. Note: this option applies only to `query` (i.e. not `cquery`). +: If set and --universe\_scope is unset, then a value of --universe\_scope will be inferred as the list of unique target patterns in the query expression. Note that the --universe\_scope value inferred for a query expression that uses universe-scoped functions (e.g.`allrdeps`) may not be what you want, so you should use this option only if you know what you are doing. See https://bazel.build/reference/query#sky-query for details and examples. If --universe\_scope is set, then this option's value is ignored. Note: this option applies only to `query` (i.e. not `cquery`). Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -10856,19 +11018,13 @@ Options relating to query output and semantics: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--output=` default: "label" -: The format in which the query results should be printed. Allowed values for query are: build, graph, streamed_jsonproto, label, label_kind, location, maxrank, minrank, package, proto, streamed_proto, xml. - - Tags: - [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) - -`--[no]output:display_full_kind` default: "False" -: When displaying rule kind, whether to display the short rule name, or the full name for Starlark rules. +: The format in which the query results should be printed. Allowed values for query are: build, graph, streamed\_jsonproto, label, label\_kind, location, maxrank, minrank, package, proto, streamed\_proto, xml. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--output_file=` default: "" -: When specified, query results will be written directly to this file, and nothing will be printed to Bazel's standard output stream (stdout). In benchmarks, this is generally faster than `bazel query > file`. +: When specified, query results will be written directly to this file, and nothing will be printed to Bazel's standard output stream (stdout). In benchmarks, this is generally faster than bazel query > file. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -10880,7 +11036,7 @@ Options relating to query output and semantics: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]proto:definition_stack` default: "false" -: Populate the definition_stack proto field, which records for each rule instance the Starlark call stack at the moment the rule's class was defined. +: Populate the definition\_stack proto field, which records for each rule instance the Starlark call stack at the moment the rule's class was defined. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -10892,19 +11048,19 @@ Options relating to query output and semantics: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) `--[no]proto:include_attribute_source_aspects` default: "false" -: Populate the source_aspect_name proto field of each Attribute with the source aspect that the attribute came from (empty string if it did not). +: Populate the source\_aspect\_name proto field of each Attribute with the source aspect that the attribute came from (empty string if it did not). Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]proto:include_starlark_rule_env` default: "true" -: Use the starlark environment in the value of the generated $internal_attr_hash attribute. This ensures that the starlark rule definition (and its transitive imports) are part of this identifier. +: Use the starlark environment in the value of the generated $internal\_attr\_hash attribute. This ensures that the starlark rule definition (and its transitive imports) are part of this identifier. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]proto:include_synthetic_attribute_hash` default: "false" -: Whether or not to calculate and populate the $internal_attr_hash attribute. +: Whether or not to calculate and populate the $internal\_attr\_hash attribute. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -10928,13 +11084,13 @@ Options relating to query output and semantics: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]proto:rule_classes` default: "false" -: Populate the rule_class_key field of each rule; and for the first rule with a given rule_class_key, also populate its rule_class_info proto field. The rule_class_key field uniquely identifies a rule class, and the rule_class_info field is a Stardoc-format rule class API definition. +: Populate the rule\_class\_key field of each rule; and for the first rule with a given rule\_class\_key, also populate its rule\_class\_info proto field. The rule\_class\_key field uniquely identifies a rule class, and the rule\_class\_info field is a Stardoc-format rule class API definition. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]proto:rule_inputs_and_outputs` default: "true" -: Whether or not to populate the rule_input and rule_output fields. +: Whether or not to populate the rule\_input and rule\_output fields. Tags: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) @@ -10952,13 +11108,13 @@ Options relating to query output and semantics: [`terminal_output`](#effect_tag_TERMINAL_OUTPUT) `--[no]strict_test_suite` default: "false" -: If true, the tests() expression gives an error if it encounters a test_suite containing non-test targets. +: If true, the tests() expression gives an error if it encounters a test\_suite containing non-test targets. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT) `--[no]tool_deps` default: "true" -: Query: If disabled, dependencies on 'exec configuration' will not be included in the dependency graph over which the query operates. An 'exec configuration' dependency edge, such as the one from any 'proto_library' rule to the Protocol Compiler, usually points to a tool executed during the build rather than a part of the same 'target' program. +: Query: If disabled, dependencies on 'exec configuration' will not be included in the dependency graph over which the query operates. An 'exec configuration' dependency edge, such as the one from any 'proto\_library' rule to the Protocol Compiler, usually points to a tool executed during the build rather than a part of the same 'target' program. Cquery: If disabled, filters out all configured targets which cross an execution transition from the top-level target that discovered this configured target. That means if the top-level target is in the target configuration, only configured targets also in the target configuration will be returned. If the top-level target is in the exec configuration, only exec configured targets will be returned. This option will NOT exclude resolved toolchains. Tags: @@ -11004,7 +11160,7 @@ Miscellaneous options, not otherwise categorized.: `--deleted_packages=` multiple uses are accumulated : A comma-separated list of names of packages which the build system will consider non-existent, even if they are visible somewhere on the package path. - Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package_path entry. Specifying --deleted_packages x/y avoids this problem. + Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package\_path entry. Specifying --deleted\_packages x/y avoids this problem. `--[no]fetch` default: "true" : Allows the command to fetch external dependencies. If set to false, the command will utilize any cached version of the dependency, and if none exists, the command will result in failure. @@ -11028,13 +11184,13 @@ Options that appear before the command and are parsed by the client: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]run` default: "true" -: If false, skip running the command line constructed for the built target. Note that this flag is ignored for all --script_path builds. +: If false, skip running the command line constructed for the built target. Note that this flag is ignored for all --script\_path builds. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--run_env=` multiple uses are accumulated -: Specifies the set of environment variables available to the target to run. Variables can be either specified by name, in which case the value will be taken from the invocation environment, by the <code>name=value</code> pair which sets the value independent of the invocation environment, or by <code>=name</code>, which unsets the variable of that name. This option can be used multiple times; for options given for the same variable, the latest wins, options for different variables accumulate. Note that the executed target will generally see the full environment of the host except for those variables that have been explicitly unset. +: Specifies the set of environment variables available to the target to run. Variables can be either specified by name, in which case the value will be taken from the invocation environment, by the name=value pair which sets the value independent of the invocation environment, or by =name, which unsets the variable of that name. This option can be used multiple times; for options given for the same variable, the latest wins, options for different variables accumulate. Note that the executed target will generally see the full environment of the host except for those variables that have been explicitly unset. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -11048,7 +11204,7 @@ Options that appear before the command and are parsed by the client: Options that let the user configure the intended output, affecting its value, as opposed to its existence: `--script_path=` default: see description -: If set, write a shell script to the given file which invokes the target. If this option is set, the target is not run from bazel. Use 'bazel run --script_path=foo //foo && ./foo' to invoke target '//foo' This differs from 'bazel run //foo' in that the bazel lock is released and the executable is connected to the terminal's stdin. +: If set, write a shell script to the given file which invokes the target. If this option is set, the target is not run from bazel. Use 'bazel run --script\_path=foo //foo && ./foo' to invoke target '//foo' This differs from 'bazel run //foo' in that the bazel lock is released and the executable is connected to the terminal's stdin. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`execution`](#effect_tag_EXECUTION) @@ -11108,7 +11264,7 @@ Options that control build execution: [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT) `--loading_phase_threads=) eg. "auto", "HOST_CPUS*.5">` default: "auto" -: Number of parallel threads to use for the loading/analysis phase.Takes an integer, or a keyword ("auto", "HOST_CPUS", "HOST_RAM"), optionally followed by an operation ([-|*]<float>) eg. "auto", "HOST_CPUS*.5". "auto" sets a reasonable default based on host resources. Must be at least 1. +: Number of parallel threads to use for the loading/analysis phase.Takes an integer, or a keyword ("auto", "HOST\_CPUS", "HOST\_RAM"), optionally followed by an operation ([-|*]) eg. "auto", "HOST\_CPUS*.5". "auto" sets a reasonable default based on host resources. Must be at least 1. Tags: [`bazel_internal_configuration`](#effect_tag_BAZEL_INTERNAL_CONFIGURATION) @@ -11116,13 +11272,13 @@ Options that control build execution: This option affects semantics of the Starlark language or the build API accessible to BUILD files, .bzl files, or WORKSPACE files.: `--[no]incompatible_config_setting_private_default_visibility` default: "false" -: If incompatible_enforce_config_setting_visibility=false, this is a noop. Else, if this flag is false, any config_setting without an explicit visibility attribute is //visibility:public. If this flag is true, config_setting follows the same visibility logic as all other rules. See https://github.com/bazelbuild/bazel/issues/12933. +: If incompatible\_enforce\_config\_setting\_visibility=false, this is a noop. Else, if this flag is false, any config\_setting without an explicit visibility attribute is //visibility:public. If this flag is true, config\_setting follows the same visibility logic as all other rules. See https://github.com/bazelbuild/bazel/issues/12933. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_enforce_config_setting_visibility` default: "true" -: If true, enforce config_setting visibility restrictions. If false, every config_setting is visible to every target. See https://github.com/bazelbuild/bazel/issues/12932. +: If true, enforce config\_setting visibility restrictions. If false, every config\_setting is visible to every target. See https://github.com/bazelbuild/bazel/issues/12932. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -11140,7 +11296,7 @@ Miscellaneous options, not otherwise categorized.: `--deleted_packages=` multiple uses are accumulated : A comma-separated list of names of packages which the build system will consider non-existent, even if they are visible somewhere on the package path. - Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package_path entry. Specifying --deleted_packages x/y avoids this problem. + Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package\_path entry. Specifying --deleted\_packages x/y avoids this problem. `--[no]fetch` default: "true" : Allows the command to fetch external dependencies. If set to false, the command will utilize any cached version of the dependency, and if none exists, the command will result in failure. @@ -11331,13 +11487,13 @@ Options that configure the toolchain used for action execution: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--android_manifest_merger=` default: "android" -: Selects the manifest merger to use for android_binary rules. Flag to help the transition to the Android manifest merger from the legacy merger. +: Selects the manifest merger to use for android\_binary rules. Flag to help the transition to the Android manifest merger from the legacy merger. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--android_platforms=` default: "" -: Sets the platforms that android_binary targets use. If multiple platforms are specified, then the binary is a fat APKs, which contains native binaries for each specified target platform. +: Sets the platforms that android\_binary targets use. If multiple platforms are specified, then the binary is a fat APKs, which contains native binaries for each specified target platform. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -11354,21 +11510,21 @@ Options that configure the toolchain used for action execution: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION) -`--coverage_output_generator=` default: "@bazel_tools//tools/test:lcov_merger" +`--coverage_output_generator=` default: "@bazel\_tools//tools/test:lcov\_merger" : Location of the binary that is used to postprocess raw coverage reports. This must be a binary target. Defaults to `@bazel_tools//tools/test:lcov_merger`. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--coverage_report_generator=` default: "@bazel_tools//tools/test:coverage_report_generator" +`--coverage_report_generator=` default: "@bazel\_tools//tools/test:coverage\_report\_generator" : Location of the binary that is used to generate coverage reports. This must be a binary target. Defaults to `@bazel_tools//tools/test:coverage_report_generator`. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--coverage_support=` default: "@bazel_tools//tools/test:coverage_support" +`--coverage_support=` default: "@bazel\_tools//tools/test:coverage\_support" : Location of support files that are required on the inputs of every test action that collects code coverage. Defaults to `//tools/test:coverage_support`. @@ -11382,7 +11538,7 @@ Options that configure the toolchain used for action execution: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]experimental_include_xcode_execution_requirements` default: "false" -: If set, add a "requires-xcode:{version}" execution requirement to every Xcode action. If the Xcode version has a hyphenated label, also add a "requires-xcode-label:{version_label}" execution requirement. +: If set, add a "requires-xcode:{version}" execution requirement to every Xcode action. If the Xcode version has a hyphenated label, also add a "requires-xcode-label:{version\_label}" execution requirement. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -11425,12 +11581,12 @@ Options that configure the toolchain used for action execution: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION) `--host_grte_top=` default: see description -: If specified, this setting overrides the libc top-level directory (--grte_top) for the exec configuration. +: If specified, this setting overrides the libc top-level directory (--grte\_top) for the exec configuration. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) -`--host_platform=` default: "@bazel_tools//tools:host_platform" +`--host_platform=` default: "@bazel\_tools//tools:host\_platform" : The label of a platform rule that describes the host system. Tags: @@ -11452,6 +11608,12 @@ Options that configure the toolchain used for action execution: Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) +`--[no]incompatible_cuda_compile_action` default: "false" +: Compile cuda files using the cuda-compile action in the toolchain. + + Tags: + [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) + `--[no]incompatible_dont_enable_host_nonhost_crosstool_features` default: "true" : If true, Bazel will not enable 'host' and 'nonhost' features in the c++ toolchain (see https://github.com/bazelbuild/bazel/issues/7407 for more information). @@ -11477,13 +11639,13 @@ Options that configure the toolchain used for action execution: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ios_sdk_version=` default: see description -: Specifies the version of the iOS SDK to use to build iOS applications. If unspecified, uses the default iOS SDK version from 'xcode_version'. +: Specifies the version of the iOS SDK to use to build iOS applications. If unspecified, uses the default iOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--macos_sdk_version=` default: see description -: Specifies the version of the macOS SDK to use to build macOS applications. If unspecified, uses the default macOS SDK version from 'xcode_version'. +: Specifies the version of the macOS SDK to use to build macOS applications. If unspecified, uses the default macOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -11510,19 +11672,19 @@ Options that configure the toolchain used for action execution: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--tvos_sdk_version=` default: see description -: Specifies the version of the tvOS SDK to use to build tvOS applications. If unspecified, uses the default tvOS SDK version from 'xcode_version'. +: Specifies the version of the tvOS SDK to use to build tvOS applications. If unspecified, uses the default tvOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--[no]use_platforms_in_apple_crosstool_transition` default: "false" -: Makes apple_crosstool_transition fall back to using the value of `--platforms` flag instead of legacy `--cpu` when needed. +: Makes apple\_crosstool\_transition fall back to using the value of `--platforms` flag instead of legacy `--cpu` when needed. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--watchos_sdk_version=` default: see description -: Specifies the version of the watchOS SDK to use to build watchOS applications. If unspecified, uses the default watchOS SDK version from 'xcode_version'. +: Specifies the version of the watchOS SDK to use to build watchOS applications. If unspecified, uses the default watchOS SDK version from 'xcode\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -11533,8 +11695,8 @@ Options that configure the toolchain used for action execution: Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) -`--xcode_version_config=` default: "@bazel_tools//tools/cpp:host_xcodes" -: The label of the xcode_config rule to be used for selecting the Xcode version in the build configuration. +`--xcode_version_config=` default: "@bazel\_tools//tools/cpp:host\_xcodes" +: The label of the xcode\_config rule to be used for selecting the Xcode version in the build configuration. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -11566,19 +11728,19 @@ Options that control the output of the command: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--cc_proto_library_header_suffixes=` default: ".pb.h" -: Sets the suffixes of header files that a cc_proto_library creates. +: Sets the suffixes of header files that a cc\_proto\_library creates. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--cc_proto_library_source_suffixes=` default: ".pb.cc" -: Sets the suffixes of source files that a cc_proto_library creates. +: Sets the suffixes of source files that a cc\_proto\_library creates. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--[no]experimental_proto_descriptor_sets_include_source_info` default: "false" -: Run extra actions for alternative Java api versions in a proto_library. +: Run extra actions for alternative Java api versions in a proto\_library. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -11590,7 +11752,7 @@ Options that control the output of the command: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--fission=` default: "no" -: Specifies which compilation modes use fission for C++ compilations and links. May be any combination of {'fastbuild', 'dbg', 'opt'} or the special values 'yes' to enable all modes and 'no' to disable all modes. +: Specifies which compilation modes use fission for C++ compilations and links. May be any combination of {'fastbuild', 'dbg', 'opt'} or the special values 'yes' to enable all modes and 'no' to disable all modes. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -11657,20 +11819,32 @@ Options that let the user configure the intended output, affecting its value, as Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) +`--[no]android_databinding_use_androidx` default: "true" +: Generate AndroidX-compatible data-binding files. This is only used with databinding v2. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + +`--[no]android_databinding_use_v3_4_args` default: "true" +: Use android databinding v2 with 3.4.0 argument. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--android_dynamic_mode=` default: "off" -: Determines whether C++ deps of Android rules will be linked dynamically when a cc_binary does not explicitly create a shared library. 'default' means bazel will choose whether to link dynamically. 'fully' means all libraries will be linked dynamically. 'off' means that all libraries will be linked in mostly static mode. +: Determines whether C++ deps of Android rules will be linked dynamically when a cc\_binary does not explicitly create a shared library. 'default' means bazel will choose whether to link dynamically. 'fully' means all libraries will be linked dynamically. 'off' means that all libraries will be linked in mostly static mode. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--android_manifest_merger_order=` default: "alphabetical" -: Sets the order of manifests passed to the manifest merger for Android binaries. ALPHABETICAL means manifests are sorted by path relative to the execroot. ALPHABETICAL_BY_CONFIGURATION means manifests are sorted by paths relative to the configuration directory within the output directory. DEPENDENCY means manifests are ordered with each library's manifest coming before the manifests of its dependencies. +: Sets the order of manifests passed to the manifest merger for Android binaries. ALPHABETICAL means manifests are sorted by path relative to the execroot. ALPHABETICAL\_BY\_CONFIGURATION means manifests are sorted by paths relative to the configuration directory within the output directory. DEPENDENCY means manifests are ordered with each library's manifest coming before the manifests of its dependencies. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`execution`](#effect_tag_EXECUTION) `--[no]android_resource_shrinking` default: "false" -: Enables resource shrinking for android_binary APKs that use ProGuard. +: Enables resource shrinking for android\_binary APKs that use ProGuard. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -11723,7 +11897,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--cs_fdo_profile=` default: see description -: The cs_fdo_profile representing the context sensitive profile to be used for optimization. +: The cs\_fdo\_profile representing the context sensitive profile to be used for optimization. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -11784,8 +11958,14 @@ Options that let the user configure the intended output, affecting its value, as Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]experimental_android_databinding_v2` default: "true" +: Use android databinding v2. This flag is a no-op. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_android_resource_shrinking` default: "false" -: Enables resource shrinking for android_binary APKs that use ProGuard. +: Enables resource shrinking for android\_binary APKs that use ProGuard. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -11837,7 +12017,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--[no]experimental_use_llvm_covmap` default: "false" -: If specified, Bazel will generate llvm-cov coverage map information rather than gcov when collect_code_coverage is enabled. +: If specified, Bazel will generate llvm-cov coverage map information rather than gcov when collect\_code\_coverage is enabled. Tags: [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) @@ -11869,7 +12049,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--fdo_profile=` default: see description -: The fdo_profile representing the profile to be used for optimization. +: The fdo\_profile representing the profile to be used for optimization. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -11945,13 +12125,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--host_macos_minimum_os=` default: see description -: Minimum compatible macOS version for host targets. If unspecified, uses 'macos_sdk_version'. +: Minimum compatible macOS version for host targets. If unspecified, uses 'macos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--host_per_file_copt=` multiple uses are accumulated -: Additional options to selectively pass to the C/C++ compiler when compiling certain files in the exec configurations. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation_filter). option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --host_per_file_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. +: Additional options to selectively pass to the C/C++ compiler when compiling certain files in the exec configurations. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation\_filter). option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --host\_per\_file\_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -11995,17 +12175,23 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ios_minimum_os=` default: see description -: Minimum compatible iOS version for target simulators and devices. If unspecified, uses 'ios_sdk_version'. +: Minimum compatible iOS version for target simulators and devices. If unspecified, uses 'ios\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--ios_multi_cpus=` multiple uses are accumulated -: Comma-separated list of architectures to build an ios_application with. The result is a universal binary containing all specified architectures. +: Comma-separated list of architectures to build an ios\_application with. The result is a universal binary containing all specified architectures. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) +`--[no]legacy_whole_archive` default: "true" +: Deprecated, superseded by --incompatible\_remove\_legacy\_whole\_archive (see https://github.com/bazelbuild/bazel/issues/7362 for details). When on, use --whole-archive for cc\_binary rules that have linkshared=True and either linkstatic=True or '-static' in linkopts. This is for backwards compatibility only. A better alternative is to use alwayslink=1 where required. + + Tags: + [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`deprecated`](#metadata_tag_DEPRECATED) + `--linkopt=` multiple uses are accumulated : Additional option to pass to gcc when linking. @@ -12013,13 +12199,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ltobackendopt=` multiple uses are accumulated -: Additional option to pass to the LTO backend step (under --features=thin_lto). +: Additional option to pass to the LTO backend step (under --features=thin\_lto). Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--ltoindexopt=` multiple uses are accumulated -: Additional option to pass to the LTO indexing step (under --features=thin_lto). +: Additional option to pass to the LTO indexing step (under --features=thin\_lto). Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -12031,7 +12217,7 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--macos_minimum_os=` default: see description -: Minimum compatible macOS version for targets. If unspecified, uses 'macos_sdk_version'. +: Minimum compatible macOS version for targets. If unspecified, uses 'macos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -12043,7 +12229,7 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--[no]objc_enable_binary_stripping` default: "false" -: Whether to perform symbol and dead-code strippings on linked binaries. Binary strippings will be performed if both this flag and --compilation_mode=opt are specified. +: Whether to perform symbol and dead-code strippings on linked binaries. Binary strippings will be performed if both this flag and --compilation\_mode=opt are specified. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES) @@ -12055,13 +12241,13 @@ Options that let the user configure the intended output, affecting its value, as [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES) `--per_file_copt=` multiple uses are accumulated -: Additional options to selectively pass to gcc when compiling certain files. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation_filter). option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per_file_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. +: Additional options to selectively pass to gcc when compiling certain files. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation\_filter). option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per\_file\_copt=//foo/.\*.cc,-//foo/bar.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--per_file_ltobackendopt=` multiple uses are accumulated -: Additional options to selectively pass to LTO backend (under --features=thin_lto) when compiling certain backend objects. This option can be passed multiple times. Syntax: regex_filter@option_1,option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns. option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per_file_ltobackendopt=//foo/.\*.o,-//foo/bar.o@-O0 adds the -O0 command line option to the LTO backend command line of all o files in //foo/ except bar.o. +: Additional options to selectively pass to LTO backend (under --features=thin\_lto) when compiling certain backend objects. This option can be passed multiple times. Syntax: regex\_filter@option\_1,option\_2,...,option\_n. Where regex\_filter stands for a list of include and exclude regular expression patterns. option\_1 to option\_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per\_file\_ltobackendopt=//foo/.\*.o,-//foo/bar.o@-O0 adds the -O0 command line option to the LTO backend command line of all o files in //foo/ except bar.o. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -12073,19 +12259,19 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--propeller_optimize=` default: see description -: Use Propeller profile information to optimize the build target.A propeller profile must consist of at least one of two files, a cc profile and a ld profile. This flag accepts a build label which must refer to the propeller profile input files. For example, the BUILD file that defines the label, in a/b/BUILD:propeller_optimize( name = "propeller_profile", cc_profile = "propeller_cc_profile.txt", ld_profile = "propeller_ld_profile.txt",)An exports_files directive may have to be added to the corresponding package to make these files visible to Bazel. The option must be used as: --propeller_optimize=//a/b:propeller_profile +: Use Propeller profile information to optimize the build target.A propeller profile must consist of at least one of two files, a cc profile and a ld profile. This flag accepts a build label which must refer to the propeller profile input files. For example, the BUILD file that defines the label, in a/b/BUILD:propeller\_optimize( name = "propeller\_profile", cc\_profile = "propeller\_cc\_profile.txt", ld\_profile = "propeller\_ld\_profile.txt",)An exports\_files directive may have to be added to the corresponding package to make these files visible to Bazel. The option must be used as: --propeller\_optimize=//a/b:propeller\_profile Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--propeller_optimize_absolute_cc_profile=` default: see description -: Absolute path name of cc_profile file for Propeller Optimized builds. +: Absolute path name of cc\_profile file for Propeller Optimized builds. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--propeller_optimize_absolute_ld_profile=` default: see description -: Absolute path name of ld_profile file for Propeller Optimized builds. +: Absolute path name of ld\_profile file for Propeller Optimized builds. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -12119,13 +12305,13 @@ Options that let the user configure the intended output, affecting its value, as [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--strip=` default: "sometimes" -: Specifies whether to strip binaries and shared libraries (using "-Wl,--strip-debug"). The default value of 'sometimes' means strip iff --compilation_mode=fastbuild. +: Specifies whether to strip binaries and shared libraries (using "-Wl,--strip-debug"). The default value of 'sometimes' means strip iff --compilation\_mode=fastbuild. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) `--stripopt=` multiple uses are accumulated -: Additional options to pass to strip when generating a '<name>.stripped' binary. +: Additional options to pass to strip when generating a '.stripped' binary. Tags: [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -12137,7 +12323,7 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--tvos_minimum_os=` default: see description -: Minimum compatible tvOS version for target simulators and devices. If unspecified, uses 'tvos_sdk_version'. +: Minimum compatible tvOS version for target simulators and devices. If unspecified, uses 'tvos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) @@ -12155,13 +12341,13 @@ Options that let the user configure the intended output, affecting its value, as [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--watchos_minimum_os=` default: see description -: Minimum compatible watchOS version for target simulators and devices. If unspecified, uses 'watchos_sdk_version'. +: Minimum compatible watchOS version for target simulators and devices. If unspecified, uses 'watchos\_sdk\_version'. Tags: [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) `--xbinary_fdo=` default: see description -: Use XbinaryFDO profile information to optimize compilation. Specify the name of default cross binary profile. When the option is used together with --fdo_instrument/--fdo_optimize/--fdo_profile, those options will always prevail as if xbinary_fdo is never specified. +: Use XbinaryFDO profile information to optimize compilation. Specify the name of default cross binary profile. When the option is used together with --fdo\_instrument/--fdo\_optimize/--fdo\_profile, those options will always prevail as if xbinary\_fdo is never specified. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS) @@ -12192,14 +12378,20 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS) +`--[no]experimental_check_desugar_deps` default: "true" +: Whether to double-check correct desugaring at Android binary level. + + Tags: + [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_enforce_transitive_visibility` default: "false" -: If true, enable package()s to set the transitive_visibility attribute to restrict which packages may depend on them. +: If true, enable package()s to set the transitive\_visibility attribute to restrict which packages may depend on them. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`experimental`](#metadata_tag_EXPERIMENTAL) `--experimental_one_version_enforcement=` default: "OFF" -: When enabled, enforce that a java_binary rule can't contain more than one version of the same class file on the classpath. This enforcement can break the build, or can just result in warnings. +: When enabled, enforce that a java\_binary rule can't contain more than one version of the same class file on the classpath. This enforcement can break the build, or can just result in warnings. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -12216,26 +12408,26 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) -`--[no]incompatible_disable_native_apple_binary_rule` default: "false" -: No-op. Kept here for backwards compatibility. +`--[no]incompatible_disable_native_android_rules` default: "false" +: If enabled, direct usage of the native Android rules is disabled. Please use the Starlark Android rules from https://github.com/bazelbuild/rules\_android Tags: - [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE), [`deprecated`](#metadata_tag_DEPRECATED) + [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]one_version_enforcement_on_java_tests` default: "true" -: When enabled, and with experimental_one_version_enforcement set to a non-NONE value, enforce one version on java_test targets. This flag can be disabled to improve incremental test performance at the expense of missing potential one version violations. +: When enabled, and with experimental\_one\_version\_enforcement set to a non-NONE value, enforce one version on java\_test targets. This flag can be disabled to improve incremental test performance at the expense of missing potential one version violations. Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--strict_proto_deps=` default: "error" -: Unless OFF, checks that a proto_library target explicitly declares all directly used targets as dependencies. +: Unless OFF, checks that a proto\_library target explicitly declares all directly used targets as dependencies. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--strict_public_imports=` default: "off" -: Unless OFF, checks that a proto_library target explicitly declares all targets used in 'import public' as exported. +: Unless OFF, checks that a proto\_library target explicitly declares all targets used in 'import public' as exported. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`eagerness_to_exit`](#effect_tag_EAGERNESS_TO_EXIT), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -12258,7 +12450,7 @@ Options that affect how strictly Bazel enforces valid build inputs (rule definit Options that affect the signing outputs of a build: -`--apk_signing_method=` default: "v1_v2" +`--apk_signing_method=` default: "v1\_v2" : Implementation to use to sign APKs Tags: @@ -12273,13 +12465,13 @@ Options that affect the signing outputs of a build: This option affects semantics of the Starlark language or the build API accessible to BUILD files, .bzl files, or WORKSPACE files.: `--[no]incompatible_disallow_sdk_frameworks_attributes` default: "false" -: If true, disallow sdk_frameworks and weak_sdk_frameworks attributes in objc_library and objc_import. +: If true, disallow sdk\_frameworks and weak\_sdk\_frameworks attributes in objc\_library and objc\_import. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) `--[no]incompatible_objc_alwayslink_by_default` default: "false" -: If true, make the default value true for alwayslink attributes in objc_library and objc_import. +: If true, make the default value true for alwayslink attributes in objc\_library and objc\_import. Tags: [`build_file_semantics`](#effect_tag_BUILD_FILE_SEMANTICS), [`incompatible_change`](#metadata_tag_INCOMPATIBLE_CHANGE) @@ -12313,6 +12505,24 @@ Options that govern the behavior of the test environment or test runner: The default test resources specified by this flag are overridden by explicit resources specified in tags. +`--[no]experimental_android_use_parallel_dex2oat` default: "false" +: Use dex2oat in parallel to possibly speed up android\_test. + + Tags: + [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`host_machine_resource_optimizations`](#effect_tag_HOST_MACHINE_RESOURCE_OPTIMIZATIONS), [`experimental`](#metadata_tag_EXPERIMENTAL) + +`--ios_simulator_device=` default: see description +: The device to simulate when running an iOS application in the simulator, e.g. 'iPhone 6'. You can get a list of devices by running 'xcrun simctl list devicetypes' on the machine the simulator will be run on. + + Tags: + [`test_runner`](#effect_tag_TEST_RUNNER) + +`--ios_simulator_version=` default: see description +: The version of iOS to run on the simulator when running or testing. This is ignored for ios\_test rules if a target device is specified in the rule. + + Tags: + [`test_runner`](#effect_tag_TEST_RUNNER) + `--runs_per_test=` multiple uses are accumulated : Specifies number of times to run each test. If any of those attempts fail for any reason, the whole test is considered failed. Normally the value specified is @@ -12322,7 +12532,7 @@ Options that govern the behavior of the test environment or test runner: Alternate syntax: `regex_filter@runs_per_test`. Where `runs_per_test` stands for an integer value and `regex_filter` stands for a list of include and exclude - regular expression patterns (Also see --instrumentation_filter). + regular expression patterns (Also see --instrumentation\_filter). Example: `--runs_per_test=//foo/.*,-//foo/bar/.*@3` runs all tests in `//foo/` except those under `//foo/bar` three times. This option can be passed multiple times. The most @@ -12368,6 +12578,12 @@ Options that trigger optimizations of the build time: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]experimental_filter_library_jar_with_program_jar` default: "false" +: Filter the ProGuard ProgramJar to remove any classes also present in the LibraryJar. + + Tags: + [`action_command_lines`](#effect_tag_ACTION_COMMAND_LINES), [`experimental`](#metadata_tag_EXPERIMENTAL) + `--[no]experimental_inmemory_dotd_files` default: "true" : If enabled, C++ .d files will be passed through in memory directly from the remote build nodes instead of being written to disk. @@ -12395,6 +12611,12 @@ Options that trigger optimizations of the build time: Tags: [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`execution`](#effect_tag_EXECUTION), [`changes_inputs`](#effect_tag_CHANGES_INPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) +`--[no]incremental_dexing` default: "true" +: Does most of the work for dexing separately for each Jar file. + + Tags: + [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS), [`loses_incremental_state`](#effect_tag_LOSES_INCREMENTAL_STATE) + `--[no]objc_use_dotd_pruning` default: "true" : If set, .d files emitted by clang will be used to prune the set of inputs passed into objc compiles. @@ -12477,11 +12699,8 @@ Miscellaneous options, not otherwise categorized.: Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`experimental`](#metadata_tag_EXPERIMENTAL) -`--experimental_turbine_cpu_reservation=` default: "1" -: The number of CPUs to reserve for Turbine. - `--[no]explicit_java_test_deps` default: "false" -: Explicitly specify a dependency to JUnit or Hamcrest in a java_test instead of accidentally obtaining from the TestRunner's deps. Only works for bazel right now. +: Explicitly specify a dependency to JUnit or Hamcrest in a java\_test instead of accidentally obtaining from the TestRunner's deps. Only works for bazel right now. `--host_java_launcher=` default: see description : The Java launcher used by tools that are executed during a build. @@ -12490,7 +12709,7 @@ Miscellaneous options, not otherwise categorized.: : Additional options to pass to javac when building tools that are executed during a build. `--host_jvmopt=` multiple uses are accumulated -: Additional options to pass to the Java VM when building tools that are executed during the build. These options will get added to the VM startup options of each java_binary target. +: Additional options to pass to the Java VM when building tools that are executed during the build. These options will get added to the VM startup options of each java\_binary target. `--[no]incompatible_exclusive_test_sandboxed` default: "true" : If true, exclusive tests will run with sandboxed strategy. Add `local` tag to force @@ -12512,7 +12731,7 @@ Miscellaneous options, not otherwise categorized.: : Additional options to pass to the J2ObjC tool. `--java_debug` -: Causes the Java virtual machine of a java test to wait for a connection from a JDWP-compliant debugger (such as jdb) before starting the test. Implies -test_output=streamed. +: Causes the Java virtual machine of a java test to wait for a connection from a JDWP-compliant debugger (such as jdb) before starting the test. Implies -test\_output=streamed. Expands to: @@ -12538,14 +12757,14 @@ Miscellaneous options, not otherwise categorized.: `--java_launcher=` default: see description : The Java launcher to use when building Java binaries. If this flag is set to the empty string, the JDK launcher is used. The "launcher" attribute overrides this flag. -`--java_runtime_version=` default: "local_jdk" +`--java_runtime_version=` default: "local\_jdk" : The Java runtime version `--javacopt=` multiple uses are accumulated : Additional options to pass to javac. `--jvmopt=` multiple uses are accumulated -: Additional options to pass to the Java VM. These options will get added to the VM startup options of each java_binary target. +: Additional options to pass to the Java VM. These options will get added to the VM startup options of each java\_binary target. `--legacy_main_dex_list_generator=` default: see description : Specifies a binary to use to generate the list of classes that must be in the main dex when compiling legacy multidex. @@ -12554,43 +12773,43 @@ Miscellaneous options, not otherwise categorized.: : Specifies a binary to use to do dexing without sharding. `--plugin=` multiple uses are accumulated -: Plugins to use in the build. Currently works with java_plugin. +: Plugins to use in the build. Currently works with java\_plugin. `--proguard_top=` default: see description : Specifies which version of ProGuard to use for code removal when building a Java binary. -`--proto_compiler=` default: "@bazel_tools//tools/proto:protoc" +`--proto_compiler=` default: "@bazel\_tools//tools/proto:protoc" : The label of the proto-compiler. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--[no]proto_profile` default: "true" -: Whether to pass profile_path to the proto compiler. +: Whether to pass profile\_path to the proto compiler. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) `--proto_profile_path=` default: see description -: The profile to pass to the proto compiler as profile_path. If unset, but --proto_profile is true (the default), infers the path from --fdo_optimize. +: The profile to pass to the proto compiler as profile\_path. If unset, but --proto\_profile is true (the default), infers the path from --fdo\_optimize. Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_cc=` default: "@bazel_tools//tools/proto:cc_toolchain" -: Label of proto_lang_toolchain() which describes how to compile C++ protos +`--proto_toolchain_for_cc=` default: "@bazel\_tools//tools/proto:cc\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile C++ protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_java=` default: "@bazel_tools//tools/proto:java_toolchain" -: Label of proto_lang_toolchain() which describes how to compile Java protos +`--proto_toolchain_for_java=` default: "@bazel\_tools//tools/proto:java\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile Java protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) -`--proto_toolchain_for_javalite=` default: "@bazel_tools//tools/proto:javalite_toolchain" -: Label of proto_lang_toolchain() which describes how to compile JavaLite protos +`--proto_toolchain_for_javalite=` default: "@bazel\_tools//tools/proto:javalite\_toolchain" +: Label of proto\_lang\_toolchain() which describes how to compile JavaLite protos Tags: [`affects_outputs`](#effect_tag_AFFECTS_OUTPUTS), [`loading_and_analysis`](#effect_tag_LOADING_AND_ANALYSIS) @@ -12632,9 +12851,6 @@ Miscellaneous options, not otherwise categorized.: `--test_result_expiration=` default: "-1" : This option is deprecated and has no effect. - Tags: - [`deprecated`](#metadata_tag_DEPRECATED) - `--[no]test_runner_fail_fast` default: "false" : Forwards fail fast option to the test runner. The test runner should stop execution upon first failure. @@ -12650,7 +12866,7 @@ Miscellaneous options, not otherwise categorized.: `--tool_java_language_version=` default: "" : The Java language version used to execute the tools that are needed during a build -`--tool_java_runtime_version=` default: "remotejdk_11" +`--tool_java_runtime_version=` default: "remotejdk\_11" : The Java runtime version used to execute tools during the build `--[no]use_ijars` default: "true" diff --git a/reference/flag-cheatsheet.mdx b/reference/flag-cheatsheet.mdx index ce9583ce..275dee97 100644 --- a/reference/flag-cheatsheet.mdx +++ b/reference/flag-cheatsheet.mdx @@ -12,7 +12,7 @@ This page focuses on the most crucial flags you'll need to know. command line reference. -## Useful general options {#useful-command} +## Useful general options The following flags are meant to be set explicitly on the command line. @@ -24,7 +24,7 @@ The following flags are meant to be set explicitly on the command line. -

`--config`

+

--config

@@ -38,7 +38,7 @@ be selected with --config=<group>. -

`--keep_going`

+

--keep_going

@@ -50,7 +50,7 @@ By default, Bazel fails eagerly. -

`--remote_download_outputs`

+

--remote_download_outputs

@@ -71,7 +71,7 @@ and intermediate artifacts that are necessary for local actions. -

`--stamp`

+

--stamp

@@ -86,7 +86,7 @@ Adds build info (user, timestamp) to binaries. -## Uncover Build & Test Issues {#uncover-build} +## Uncover Build & Test Issues The following flags can help you better understand Bazel build or test errors. @@ -98,7 +98,7 @@ The following flags can help you better understand Bazel build or test errors. -

`--announce_rc`

+

--announce_rc

@@ -111,7 +111,7 @@ machine-defined, or project-defined .bazelrc files. -

`--auto_output_filter`

+

--auto_output_filter

@@ -126,7 +126,7 @@ command line. To disable all filtering, set -

`--sandbox_debug`

+

--sandbox_debug

@@ -149,7 +149,7 @@ builds by default and what gets sandboxed, see our -

`--subcommands (-s)`

+

--subcommands (-s)

@@ -160,7 +160,7 @@ regardless of whether it succeeds or fails -## Startup {#startup} +## Startup Caution: Startup flags need to be passed before the command and cause a server restart. Toggle these flags with caution. @@ -173,7 +173,7 @@ a server restart. Toggle these flags with caution. -

`--bazelrc`

+

--bazelrc

@@ -196,7 +196,7 @@ the .bazelrc file>
. -

`--host_jvm_args`

+

--host_jvm_args

@@ -229,7 +229,7 @@ For example, the following limits the Bazel heap size to 3GB: -

`--output_base`

+

--output_base

@@ -249,7 +249,7 @@ see Choosing the ou -## Bazel tests {#bazel-tests} +## Bazel tests The following flags are related to Bazel test @@ -261,7 +261,7 @@ The following flags are related to Bazel test -

`--java_debug`

+

--java_debug

@@ -273,7 +273,7 @@ Causes Java tests to wait for a debugger connection before being executed. -

`--runs_per_test`

+

--runs_per_test

@@ -287,7 +287,7 @@ flaky tests and see whether a fix causes a test to pass consistently. -

`--test_filter`

+

--test_filter

@@ -304,7 +304,7 @@ debugging. This flag is often used in conjunction with -

`--test_output`

+

--test_output

@@ -318,7 +318,7 @@ real time. -## Bazel run {#bazel-run} +## Bazel run The following flags are related to Bazel run. @@ -330,7 +330,7 @@ The following flags are related to Bazel run. -

`--run_under`

+

--run_under

@@ -343,7 +343,7 @@ commonly used for debugging. -## User-specific bazelrc options {#user-specific-bazelrc} +## User-specific bazelrc options The following flags are related to user-specific **.bazelrc** options. @@ -356,7 +356,7 @@ options. -

`--disk_cache`

+

--disk_cache

@@ -373,7 +373,7 @@ up Bazel builds by adding -

`--jobs`

+

--jobs

@@ -388,7 +388,7 @@ cluster executes more jobs than you have cores locally. -

`--local_resources`

+

--local_resources

@@ -405,7 +405,7 @@ Limits how much CPU or RAM is consumed by locally running actions. -

`--sandbox_base`

+

--sandbox_base

@@ -423,7 +423,7 @@ build. -## Project-specific bazelrc options {#project-specific-bazelrc} +## Project-specific bazelrc options The following flags are related to project-specific .bazelrc options. @@ -436,7 +436,7 @@ options. -

`--flaky_test_attempts`

+

--flaky_test_attempts

@@ -451,7 +451,7 @@ the test summary. -

`--remote_cache`

+

--remote_cache

@@ -464,7 +464,7 @@ speed up Bazel builds. It can be combined with a local disk cache. -

`--remote_download_regex`

+

--remote_download_regex

@@ -478,7 +478,7 @@ patterns may be specified by repeating this flag. -

`--remote_executor`

+

--remote_executor

@@ -492,7 +492,7 @@ a remote execution service. You'll often need to Add -

`--remote_instance_name`

+

--remote_instance_name

@@ -504,7 +504,7 @@ The value to pass as instance_name in the remote execution API. -

`--show_timestamps`

+

--show_timestamps

@@ -518,7 +518,7 @@ quickly understand what step took how long. -

`--spawn_strategy`

+

--spawn_strategy

diff --git a/reference/glossary.mdx b/reference/glossary.mdx index 7d1e7dd9..4959f6ba 100644 --- a/reference/glossary.mdx +++ b/reference/glossary.mdx @@ -2,7 +2,7 @@ title: 'Bazel Glossary' --- -### Action {#action} +### Action A command to run during the build, for example, a call to a compiler that takes [artifacts](#artifact) as inputs and produces other artifacts as outputs. @@ -11,42 +11,44 @@ variables, and declared input/output artifacts. **See also:** [Rules documentation](/extending/rules#actions) -### Action cache {#action-cache} +### Action cache An on-disk cache that stores a mapping of executed [actions](#action) to the outputs they created. The cache key is known as the [action key](#action-key). A core component for Bazel's incrementality model. The cache is stored in the output base directory and thus survives Bazel server restarts. -### Action graph {#action-graph} +### Action graph An in-memory graph of [actions](#action) and the [artifacts](#artifact) that these actions read and generate. The graph might include artifacts that exist as source files (for example, in the file system) as well as generated intermediate/final artifacts that are not mentioned in `BUILD` files. Produced -during the [analysis phase](#analysis-phase) and used during the [execution phase](#execution-phase). +during the [analysis phase](#analysis-phase) and used during the [execution +phase](#execution-phase). -### Action graph query (aquery) {#action-graph-query} +### Action graph query (aquery) A [query](#query-concept) tool that can query over build [actions](#action). This provides the ability to analyze how [build rules](#rule) translate into the actual work builds do. -### Action key {#action-key} +### Action key The cache key of an [action](#action). Computed based on action metadata, which might include the command to be executed in the action, compiler flags, library locations, or system headers, depending on the action. Enables Bazel to cache or invalidate individual actions deterministically. -### Analysis phase {#analysis-phase} +### Analysis phase The second phase of a build. Processes the [target graph](#target-graph) -specified in [`BUILD` files](#build-file) to produce an in-memory [action graph](#action-graph) that determines the order of actions to run during the +specified in [`BUILD` files](#build-file) to produce an in-memory [action +graph](#action-graph) that determines the order of actions to run during the [execution phase](#execution-phase). This is the phase in which rule implementations are evaluated. -### Artifact {#artifact} +### Artifact A source file or a generated file. Can also be a directory of files, known as [tree artifacts](#tree-artifact). @@ -57,7 +59,7 @@ at most one action. An artifact that corresponds to a [file target](#target) can be addressed by a label. -### Aspect {#aspect} +### Aspect A mechanism for rules to create additional [actions](#action) in their dependencies. For example, if target A depends on B, one can apply an aspect on @@ -69,7 +71,7 @@ metadata for IDEs, and create actions for linting. **See also:** [Aspects documentation](/extending/aspects) -### Aspect-on-aspect {#aspect-on-aspect} +### Aspect-on-aspect A composition mechanism whereby aspects can be applied to the results of other aspects. For example, an aspect that generates information for use by @@ -81,27 +83,28 @@ For an aspect `A` to apply on top of aspect `B`, the [providers](#provider) that must match what `A` declares it wants in its [`required_aspect_providers`](/rules/lib/globals#aspect.required_aspect_providers) attribute. -### Attribute {#attribute} +### Attribute A parameter to a [rule](#rule), used to express per-target build information. Examples include `srcs`, `deps`, and `copts`, which respectively declare a target's source files, dependencies, and custom compiler options. The particular attributes available for a given target depend on its rule type. -### .bazelrc {#bazelrc} +### .bazelrc -Bazel’s configuration file used to change the default values for [startup flags](#startup-flags) and [command flags](#command-flags), and to define common +Bazel’s configuration file used to change the default values for [startup +flags](#startup-flags) and [command flags](#command-flags), and to define common groups of options that can then be set together on the Bazel command line using a `--config` flag. Bazel can combine settings from multiple bazelrc files (systemwide, per-workspace, per-user, or from a custom location), and a `bazelrc` file may also import settings from other `bazelrc` files. -### Blaze {#blaze} +### Blaze The Google-internal version of Bazel. Google’s main build system for its mono-repository. -### BUILD File {#build-file} +### BUILD File A `BUILD` file is the main configuration file that tells Bazel what software outputs to build, what their dependencies are, and how to build them. Bazel @@ -112,55 +115,44 @@ containing a `BUILD` file as a [package](#package), and can contain [targets](#target) created by [rules](#rule). The file can also be named `BUILD.bazel`. -### BUILD.bazel File {#build-bazel-file} +### BUILD.bazel File See [`BUILD` File](#build-file). Takes precedence over a `BUILD` file in the same directory. -### .bzl File {#bzl-file} +### .bzl File A file that defines rules, [macros](#macro), and constants written in -[Starlark](#starlark). These can then be imported into [`BUILD` files](#build-file) using the `load()` function. +[Starlark](#starlark). These can then be imported into [`BUILD` +files](#build-file) using the `load()` function. -### Build Event Protocol {#build-event-protocol} +{/* TODO: ### Build event protocol */} -The set of protocol buffer messages used to communicate information about build -and test results, build progress, build configuration, and much more. +{/* TODO: ### Build flag */} -**See also:** [Build Event Protocol](/remote/bep) - -### Build flag {#build-flag} - -A flag passed to Bazel to control Bazel itself and build actions. Flags are -either [startup flags](#startup-flags) or [command flags](#command-flags). - -Usage is always `bazel command -- `. A typical example would be `bazel --host_jvm_args=-Xmx512M test ---compilation_mode=dbg --test_output=errors -- //test:target1 //test:target2 -//test/local/...`. - -### Build graph {#build-graph} +### Build graph The dependency graph that Bazel constructs and traverses to perform a build. -Includes nodes like [targets](#target), [configured targets](#configured-target), [actions](#action), and [artifacts](#artifact). A +Includes nodes like [targets](#target), [configured +targets](#configured-target), [actions](#action), and [artifacts](#artifact). A build is considered complete when all [artifacts](#artifact) on which a set of requested targets depend are verified as up-to-date. -### Build setting {#build-setting} +### Build setting A Starlark-defined piece of [configuration](#configuration). [Transitions](#transition) can set build settings to change a subgraph's configuration. If exposed to the user as a [command-line flag](#command-flags), also known as a build flag. -### Clean build {#clean-build} +### Clean build A build that doesn't use the results of earlier builds. This is generally slower than an [incremental build](#incremental-build) but commonly considered to be more [correct](#correctness). Bazel guarantees both clean and incremental builds are always correct. -### Client-server model {#client-server-model} +### Client-server model The `bazel` command-line client automatically starts a background server on the local machine to execute Bazel [commands](#command). The server persists across @@ -169,12 +161,12 @@ bazel shutdown). Splitting Bazel into a server and client helps amortize JVM startup time and supports faster [incremental builds](#incremental-build) because the [action graph](#action-graph) remains in memory across commands. -### Command {#command} +### Command Used on the command line to invoke different Bazel functions, like `bazel build`, `bazel test`, `bazel run`, and `bazel query`. -### Command flags {#command-flags} +### Command flags A set of flags specific to a [command](#command). Command flags are specified *after* the command (`bazel build `). Flags can be applicable to @@ -184,29 +176,19 @@ one or more commands. For example, `--configure` is a flag exclusively for the purposes, so changes in flag values can cause Bazel to invalidate in-memory graphs and restart the [analysis phase](#analysis-phase). -### Configuration {#configuration} +### Configuration Information outside of [rule](#rule) definitions that impacts how rules generate [actions](#action). Every build has at least one configuration specifying the -target platform, action environment variables, and command-line [build flags](#command-flags). [Transitions](#transition) may create additional +target platform, action environment variables, and command-line [build +flags](#command-flags). [Transitions](#transition) may create additional configurations, such as for host tools or cross-compilation. -A configuration is composed of one of more [configuration fragments](#configuration-fragment), and separately contains all set [Starlark flags](#starlark-flags). - **See also:** [Configurations](/extending/rules#configurations) -### Configuration fragment {#configuration-fragment} +{/* TODO: ### Configuration fragment */} -Fragments are parts of the built-in [configuration](#configuration). Configuration -fragments give rules access to language-specific parts of -[configuration](#configuration). Built-in flags are groups into related fragments, -such as test flags, platform flags, remote execution flags, etc. Some fragments -are [exposed to Starlark rules](/rules/lib/overview#configuration-fragments). - -[Starlark flags](#starlark-flags) are not part of any configuration fragment, -and are accessed directly using providers. - -### Configuration trimming {#config-trimming} +### Configuration trimming The process of only including the pieces of [configuration](#configuration) a target actually needs. For example, if you build Java binary `//:j` with C++ @@ -214,15 +196,16 @@ dependency `//:c`, it's wasteful to include the value of `--javacopt` in the configuration of `//:c` because changing `--javacopt` unnecessarily breaks C++ build cacheability. -### Configured query (cquery) {#configured-query} +### Configured query (cquery) -A [query](#query-concept) tool that queries over [configured targets](#configured-target) (after the [analysis phase](#analysis-phase) +A [query](#query-concept) tool that queries over [configured +targets](#configured-target) (after the [analysis phase](#analysis-phase) completes). This means `select()` and [build flags](#command-flags) (such as `--platforms`) are accurately reflected in the results. **See also:** [cquery documentation](/query/cquery) -### Configured target {#configured-target} +### Configured target The result of evaluating a [target](#target) with a [configuration](#configuration). The [analysis phase](#analysis-phase) produces @@ -230,14 +213,15 @@ this by combining the build's options with the targets that need to be built. For example, if `//:foo` builds for two different architectures in the same build, it has two configured targets: `` and ``. -### Correctness {#correctness} +### Correctness A build is correct when its output faithfully reflects the state of its transitive inputs. To achieve correct builds, Bazel strives to be -[hermetic](#hermeticity), reproducible, and making [build analysis](#analysis-phase) and [action execution](#execution-phase) +[hermetic](#hermeticity), reproducible, and making [build +analysis](#analysis-phase) and [action execution](#execution-phase) deterministic. -### Dependency {#dependency} +### Dependency A directed edge between two [targets](#target). A target `//:foo` has a *target dependency* on target `//:bar` if `//:foo`'s attribute values contain a @@ -248,7 +232,7 @@ action in `//:bar`. In certain contexts, it could also refer to an _external dependency_; see [modules](#module). -### Depset {#depset} +### Depset A data structure for collecting data on transitive dependencies. Optimized so that merging depsets is time and space efficient, because it’s common to have @@ -261,17 +245,17 @@ implementation. **See also:** [Depset documentation](/extending/depsets) -### Disk cache {#disk-cache} +### Disk cache A local on-disk blob store for the remote caching feature. Can be used in conjunction with an actual remote blob store. -### Distdir {#distdir} +### Distdir A read-only directory containing files that Bazel would otherwise fetch from the internet using repository rules. Enables builds to run fully offline. -### Dynamic execution {#dynamic-execution} +### Dynamic execution An execution strategy that selects between local and remote execution based on various heuristics, and uses the execution results of the faster successful @@ -280,14 +264,15 @@ linking) and others are faster remotely (for example, highly parallelizable compilation). A dynamic execution strategy can provide the best possible incremental and clean build times. -### Execution phase {#execution-phase} +### Execution phase -The third phase of a build. Executes the [actions](#action) in the [action graph](#action-graph) created during the [analysis phase](#analysis-phase). +The third phase of a build. Executes the [actions](#action) in the [action +graph](#action-graph) created during the [analysis phase](#analysis-phase). These actions invoke executables (compilers, scripts) to read and write [artifacts](#artifact). *Spawn strategies* control how these actions are executed: locally, remotely, dynamically, sandboxed, docker, and so on. -### Execution root {#execution-root} +### Execution root A directory in the [workspace](#workspace)’s [output base](#output-base) directory where local [actions](#action) are executed in @@ -299,11 +284,11 @@ by creating a *symlink forest* of the directories that represent the transitive closure of packages on which a build depends. Accessible with `bazel info execution_root` on the command line. -### File {#file} +### File See [Artifact](#artifact). -### Hermeticity {#hermeticity} +### Hermeticity A build is hermetic if there are no external influences on its build and test operations, which helps to make sure that results are deterministic and @@ -312,21 +297,16 @@ access to actions, restrict access to declared inputs, use fixed timestamps and timezones, restrict access to environment variables, and use fixed seeds for random number generators -### Incremental build {#incremental-build} +### Incremental build An incremental build reuses the results of earlier builds to reduce build time and resource usage. Dependency checking and caching aim to produce correct results for this type of build. An incremental build is the opposite of a clean build. -### Install base {#install-base} - -The location where Bazel unpacks required tools that are delivered as part of -the binary. - -You can find the install base using `bazel info install_base`. +{/* TODO: ### Install base */} -### Label {#label} +### Label An identifier for a [target](#target). Generally has the form `@repo//path/to/package:target`, where `repo` is the (apparent) name of the @@ -338,14 +318,15 @@ syntax may be omitted. **See also**: [Labels](/concepts/labels) -### Loading phase {#loading-phase} +### Loading phase The first phase of a build where Bazel executes [`BUILD` files](#build-file) to create [packages](#package). [Macros](#macro) and certain functions like `glob()` are evaluated in this phase. Interleaved with the second phase of the -build, the [analysis phase](#analysis-phase), to build up a [target graph](#target-graph). +build, the [analysis phase](#analysis-phase), to build up a [target +graph](#target-graph). -### Legacy macro {#legacy-macro} +### Legacy macro A flavor of [macro](#macro) which is declared as an ordinary [Starlark](#starlark) function, and which runs as a side effect of executing a @@ -360,7 +341,7 @@ Contrast with [symbolic macros](#symbolic-macro). **See also:** [Legacy macro documentation](/extending/legacy-macros) -### Macro {#macro} +### Macro A mechanism to compose multiple [rule](#rule) target declarations together under a single [Starlark](#starlark) callable. Enables reusing common rule declaration @@ -370,7 +351,7 @@ declarations during the [loading phase](#loading-phase). Comes in two flavors: [symbolic macros](#symbolic-macro) (since Bazel 8) and [legacy macros](#legacy-macro). -### Mnemonic {#mnemonic} +### Mnemonic A short, human-readable string selected by a rule author to quickly understand what an [action](#action) in the rule is doing. Mnemonics can be used as @@ -378,7 +359,7 @@ identifiers for *spawn strategy* selections. Some examples of action mnemonics are `Javac` from Java rules, `CppCompile` from C++ rules, and `AndroidManifestMerger` from Android rules. -### Module {#module} +### Module A Bazel project that can have multiple versions, each of which can have dependencies on other modules. This is analogous to familiar concepts in other @@ -395,27 +376,29 @@ Module metadata is hosted in Bazel registries. **See also:** [Bazel modules](/external/module) -### Module Extension {#module-extension} +### Module Extension A piece of logic that can be run to generate [repos](#repository) by reading -inputs from across the [module](#module) dependency graph and invoking [repo rules](#repository-rule). Module extensions have capabilities similar to repo +inputs from across the [module](#module) dependency graph and invoking [repo +rules](#repository-rule). Module extensions have capabilities similar to repo rules, allowing them to access the internet, perform file I/O, and so on. **See also:** [Module extensions](/external/extension) -### Native rules {#native-rules} +### Native rules [Rules](#rule) that are built into Bazel and implemented in Java. Such rules appear in [`.bzl` files](#bzl-file) as functions in the native module (for example, `native.cc_library` or `native.java_library`). User-defined rules (non-native) are created using [Starlark](#starlark). -### Output base {#output-base} +### Output base A [workspace](#workspace)-specific directory to store Bazel output files. Used -to separate outputs from the *workspace*'s source tree (the [main repo](#repository)). Located in the [output user root](#output-user-root). +to separate outputs from the *workspace*'s source tree (the [main +repo](#repository)). Located in the [output user root](#output-user-root). -### Output groups {#output-groups} +### Output groups A group of files that is expected to be built when Bazel finishes building a target. [Rules](#rule) put their usual outputs in the "default output group" @@ -426,7 +409,7 @@ Rules can define more named output groups that can be explicitly specified in [`BUILD` files](#build-file) (`filegroup` rule) or the command line (`--output_groups` flag). -### Output user root {#output-user-root} +### Output user root A user-specific directory to store Bazel's outputs. The directory name is derived from the user's system username. Prevents output file collisions if @@ -434,25 +417,25 @@ multiple users are building the same project on the system at the same time. Contains subdirectories corresponding to build outputs of individual workspaces, also known as [output bases](#output-base). -### Package {#package} +### Package The set of [targets](#target) defined by a [`BUILD` file](#build-file). A package's name is the `BUILD` file's path relative to the [repo](#repository) root. A package can contain subpackages, or subdirectories containing `BUILD` files, thus forming a package hierarchy. -### Package group {#package-group} +### Package group A [target](#target) representing a set of packages. Often used in `visibility` attribute values. -### Platform {#platform} +### Platform A "machine type" involved in a build. This includes the machine Bazel runs on (the "host" platform), the machines build tools execute on ("exec" platforms), and the machines targets are built for ("target platforms"). -### Provider {#provider} +### Provider A schema describing a unit of information to pass between [rule targets](#rule-target) along dependency relationships. Typically this @@ -467,22 +450,23 @@ referred to as a "provider instance", although sometimes this is conflated with **See also:** [Provider documentation](/extending/rules#providers) -### Query (concept) {#query-concept} +### Query (concept) The process of analyzing a [build graph](#build-graph) to understand [target](#target) properties and dependency structures. Bazel supports three query variants: [query](#query-command), [cquery](#configured-query), and [aquery](#action-graph-query). -### query (command) {#query-command} +### query (command) -A [query](#query-concept) tool that operates over the build's post-[loading phase](#loading-phase) [target graph](#target-graph). This is relatively fast, +A [query](#query-concept) tool that operates over the build's post-[loading +phase](#loading-phase) [target graph](#target-graph). This is relatively fast, but can't analyze the effects of `select()`, [build flags](#command-flags), [artifacts](#artifact), or build [actions](#action). **See also:** [Query how-to](/query/guide), [Query reference](/query/language) -### Repository {#repository} +### Repository A directory tree with a boundary marker file at its root, containing source files that can be used in a Bazel build. Often shortened to just **repo**. @@ -495,7 +479,8 @@ repo; multiple such files can coexist in a directory. The *main repo* is the repo in which the current Bazel command is being run. *External repos* are defined by specifying [modules](#module) in `MODULE.bazel` -files, or invoking [repo rules](#repository-rule) in [module extensions](#module-extension). They can be fetched on demand to a predetermined +files, or invoking [repo rules](#repository-rule) in [module +extensions](#module-extension). They can be fetched on demand to a predetermined "magical" location on disk. Each repo has a unique, constant *canonical* name, and potentially different @@ -503,15 +488,16 @@ Each repo has a unique, constant *canonical* name, and potentially different **See also**: [External dependencies overview](/external/overview) -### Repository cache {#repo-cache} +### Repository cache A shared content-addressable cache of files downloaded by Bazel for builds, shareable across [workspaces](#workspace). Enables offline builds after the -initial download. Commonly used to cache files downloaded through [repository rules](#repository-rule) like `http_archive` and repository rule APIs like +initial download. Commonly used to cache files downloaded through [repository +rules](#repository-rule) like `http_archive` and repository rule APIs like `repository_ctx.download`. Files are cached only if their SHA-256 checksums are specified for the download. -### Repository rule {#repository-rule} +### Repository rule A schema for repository definitions that tells Bazel how to materialize (or "fetch") a [repository](#repository). Often shortened to just **repo rule**. @@ -523,14 +509,14 @@ internet. **See also:** [Repo rule documentation](/external/repo) -### Reproducibility {#reproducibility} +### Reproducibility The property of a build or test that a set of inputs to the build or test will always produce the same set of outputs every time, regardless of time, method, or environment. Note that this does not necessarily imply that the outputs are [correct](#correctness) or the desired outputs. -### Rule {#rule} +### Rule A schema for defining [rule targets](#rule-target) in a `BUILD` file, such as `cc_library`. From the perspective of a `BUILD` file author, a rule consists of @@ -544,7 +530,8 @@ Rules are instantiated to produce rule targets in the [loading phase](#loading-phase). In the [analysis phase](#analysis-phase) rule targets communicate information to their downstream dependencies in the form of [providers](#provider), and register [actions](#action) describing how to -generate their output artifacts. These actions are run in the [execution phase](#execution-phase). +generate their output artifacts. These actions are run in the [execution +phase](#execution-phase). Note: Historically the term "rule" has been used to refer to a rule target. This usage was inherited from tools like Make, but causes confusion and should @@ -552,12 +539,12 @@ be avoided for Bazel. **See also:** [Rules documentation](/extending/rules) -### Rule target {#rule-target} +### Rule target A [target](#target) that is an instance of a rule. Contrasts with file targets and package groups. Not to be confused with [rule](#rule). -### Runfiles {#runfiles} +### Runfiles The runtime dependencies of an executable [target](#target). Most commonly, the executable is the executable output of a test rule, and the runfiles are runtime @@ -567,7 +554,7 @@ according to their source directory structure. **See also:** [Runfiles documentation](/extending/rules#runfiles) -### Sandboxing {#sandboxing} +### Sandboxing A technique to isolate a running [action](#action) inside a restricted and temporary [execution root](#execution-root), helping to ensure that it doesn’t @@ -576,31 +563,13 @@ read undeclared inputs or write undeclared outputs. Sandboxing greatly improves support from the operating system. The performance cost depends on the platform. On Linux, it's not significant, but on macOS it can make sandboxing unusable. -### Skyframe {#skyframe} +### Skyframe [Skyframe](/reference/skyframe) is the core parallel, functional, and incremental evaluation framework of Bazel. -### Spawn strategy {#spawn-strategy} +{/* TODO: ### Spawn strategy */} -Also known as the [execution strategy](/docs/user-manual#execution-strategy), this -denotes the way Bazel attempts to execute build actions. The chosen strategy -impacts build hermeticity and speed. Build outputs remain the same for all -strategies. - -**Usage**: Specify the execution strategy using a flag. Commonly used flags to specify execution strategy are: -* `--spawn_strategy`: Set as the global default for all actions. -* `--strategy `: Override the global default strategy for a specific action mnemonic. - -See [Execution strategy](/docs/user-manual#execution-strategy) for the full list of flags. - -Strategies include: -* `local` causes commands to be executed as local subprocesses. -* `sandboxed` causes commands to be executed inside a sandbox on the local machine. See [Sandboxing](/docs/sandboxing). -* `worker` causes commands to be executed using a [persistent worker](/remote/persistent). -* `docker` causes commands to be executed inside a Docker sandbox on the local machine. -* `remote` causes commands to be [executed remotely](/remote/rbe). - -### Stamping {#stamping} +### Stamping A feature to embed additional information into Bazel-built [artifacts](#artifact). For example, this can be used for source control, build @@ -608,32 +577,22 @@ time and other workspace or environment-related information for release builds. Enable through the `--workspace_status_command` flag and [rules](/extending/rules) that support the stamp attribute. -### Starlark {#starlark} +### Starlark The extension language for writing [rules](/extending/rules) and [macros](#macro). A restricted subset of Python (syntactically and grammatically) aimed for the -purpose of configuration, and for better performance. Uses the [`.bzl` file](#bzl-file) extension. [`BUILD` files](#build-file) use an even more +purpose of configuration, and for better performance. Uses the [`.bzl` +file](#bzl-file) extension. [`BUILD` files](#build-file) use an even more restricted version of Starlark (such as no `def` function definitions), formerly known as Skylark. **See also:** [Starlark language documentation](/rules/language) -### Starlark flags {#starlark-flags} - -Rules can define [custom flags](/extending/config#user-defined-build-settings), -known as Starlark flags because they are implemented using [Starlark rules](#starlark-rules). These flags control how the rule behaves at a higher -level than individual BUILD files. - -**See also**: [Configurations](/extending/config) - -### Starlark rules {#starlark-rules} - -Custom rules written in [Starlark](#starlark) that extend Bazel with new build -capabilities. +{/* TODO: ### Starlark rules */} -**See also:** [Rules](/extending/rules) +{/* TODO: ### Starlark rule sandwich */} -### Startup flags {#startup-flags} +### Startup flags The set of flags specified between `bazel` and the [command](#query-command), for example, bazel `--host_jvm_debug` build. These flags modify the @@ -641,7 +600,7 @@ for example, bazel `--host_jvm_debug` build. These flags modify the startup flags causes a server restart. Startup flags are not specific to any command. -### Symbolic macro {#symbolic-macro} +### Symbolic macro A flavor of [macro](#macro) which is declared with a [rule](#rule)-like [attribute](#attribute) schema, allows hiding internal declared @@ -651,13 +610,14 @@ problems seen in large [legacy macro](#legacy-macro) codebases. **See also:** [Symbolic macro documentation](/extending/macros) -### Target {#target} +### Target An object that is defined in a [`BUILD` file](#build-file) and identified by a [label](#label). Targets represent the buildable units of a workspace from the perspective of the end user. -A target that is declared by instantiating a [rule](#rule) is called a [rule target](#rule-target). Depending on the rule, these may be runnable (like +A target that is declared by instantiating a [rule](#rule) is called a [rule +target](#rule-target). Depending on the rule, these may be runnable (like `cc_binary`) or testable (like `cc_test`). Rule targets typically depend on other targets via their [attributes](#attribute) (such as `deps`); these dependencies form the basis of the [target graph](#target-graph). @@ -668,14 +628,17 @@ within a `BUILD` file. As a special case, the `BUILD` file of any package is always considered a source file target in that package. Targets are discovered during the [loading phase](#loading-phase). During the -[analysis phase](#analysis-phase), targets are associated with [build configurations](#configuration) to form [configured targets](#configured-target). +[analysis phase](#analysis-phase), targets are associated with [build +configurations](#configuration) to form [configured +targets](#configured-target). -### Target graph {#target-graph} +### Target graph An in-memory graph of [targets](#target) and their dependencies. Produced during -the [loading phase](#loading-phase) and used as an input to the [analysis phase](#analysis-phase). +the [loading phase](#loading-phase) and used as an input to the [analysis +phase](#analysis-phase). -### Target pattern {#target-pattern} +### Target pattern A way to specify a group of [targets](#target) on the command line. Commonly used patterns are `:all` (all rule targets), `:*` (all rule + file targets), @@ -683,14 +646,15 @@ used patterns are `:all` (all rule targets), `:*` (all rule + file targets), in combination, for example, `//...:*` means all rule and file targets in all packages recursively from the root of the [workspace](#workspace). -### Tests {#tests} +### Tests Rule [targets](#target) instantiated from test rules, and therefore contains a test executable. A return code of zero from the completion of the executable indicates test success. The exact contract between Bazel and tests (such as test -environment variables, test result collection methods) is specified in the [Test Encyclopedia](/reference/test-encyclopedia). +environment variables, test result collection methods) is specified in the [Test +Encyclopedia](/reference/test-encyclopedia). -### Toolchain {#toolchain} +### Toolchain A set of tools to build outputs for a language. Typically, a toolchain includes compilers, linkers, interpreters or/and linters. A toolchain can also vary by @@ -698,18 +662,19 @@ platform, that is, a Unix compiler toolchain's components may differ for the Windows variant, even though the toolchain is for the same language. Selecting the right toolchain for the platform is known as toolchain resolution. -### Top-level target {#top-level-target} +### Top-level target A build [target](#target) is top-level if it’s requested on the Bazel command line. For example, if `//:foo` depends on `//:bar`, and `bazel build //:foo` is called, then for this build, `//:foo` is top-level, and `//:bar` isn’t top-level, although both targets will need to be built. An important difference -between top-level and non-top-level targets is that [command flags](#command-flags) set on the Bazel command line (or via +between top-level and non-top-level targets is that [command +flags](#command-flags) set on the Bazel command line (or via [.bazelrc](#bazelrc)) will set the [configuration](#configuration) for top-level targets, but might be modified by a [transition](#transition) for non-top-level targets. -### Transition {#transition} +### Transition A mapping of [configuration](#configuration) state from one value to another. Enables [targets](#target) in the [build graph](#build-graph) to have different @@ -721,13 +686,13 @@ compiled for ARM and x86 using split transitions in a single build. **See also:** [User-defined transitions](/extending/config#user-defined-transitions) -### Tree artifact {#tree-artifact} +### Tree artifact An [artifact](#artifact) that represents a collection of files. Since these files are not themselves artifacts, an [action](#action) operating on them must instead register the tree artifact as its input or output. -### Visibility {#visibility} +### Visibility One of two mechanisms for preventing unwanted dependencies in the build system: *target visibility* for controlling whether a [target](#target) can be depended @@ -737,9 +702,10 @@ or `.bzl` file may load a given `.bzl` file. Without context, usually **See also:** [Visibility documentation](/concepts/visibility) -### Workspace {#workspace} +### Workspace -The environment shared by all Bazel commands run from the same [main repository](#repository). +The environment shared by all Bazel commands run from the same [main +repository](#repository). Note that historically the concepts of "repository" and "workspace" have been conflated; the term "workspace" has often been used to refer to the main diff --git a/reference/test-encyclopedia.mdx b/reference/test-encyclopedia.mdx index eade94bc..c2311ea3 100644 --- a/reference/test-encyclopedia.mdx +++ b/reference/test-encyclopedia.mdx @@ -4,7 +4,7 @@ title: 'Test encyclopedia' An exhaustive specification of the test execution environment. -## Background {#background} +## Background The Bazel BUILD language includes rules which can be used to define automated test programs in many languages. @@ -22,7 +22,7 @@ release engineering auditability, and resource isolation of tests (automated testing frameworks ought not DDOS a server because some tests happen to talk to it). -## Objective {#objective} +## Objective The goal of this page is to formally establish the runtime environment for and expected behavior of Bazel tests. It will also impose requirements on the test @@ -38,13 +38,13 @@ This page is intended to be both normative and authoritative. If this specification and the implemented behavior of test runner disagree, the specification takes precedence. -## Proposed Specification {#proposed-specification} +## Proposed Specification The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" are to be interpreted as described in IETF RFC 2119. -## Purpose of tests {#purpose-of-tests} +## Purpose of tests The purpose of Bazel tests is to confirm some property of the source files checked into the repository. (On this page, "source files" includes test data, @@ -64,7 +64,7 @@ Therefore the outcome of a test must depend only on: Currently, such behavior is not enforced. However, test runners reserve the right to add such enforcement in the future. -## Role of the build system {#role-build-system} +## Role of the build system Test rules are analogous to binary rules in that each must yield an executable program. For some languages, this is a stub program which combines a @@ -81,7 +81,7 @@ should ensure that the generated executable loads these files via the runfiles image provided by the test runner, rather than hardcoded references to absolute locations in the source or output tree. -## Role of the test runner {#role-test-runner} +## Role of the test runner From the point of view of the test runner, each test is a program which can be invoked with `execve()`. There may be other ways to execute tests; for example, @@ -210,7 +210,7 @@ the test runner should consider the run complete and count it as a success or failure based on the exit code observed from the main process. The test runner may kill any stray processes. Tests should not leak processes in this fashion. -## Test sharding {#test-sharding} +## Test sharding Tests can be parallelized via test sharding. See [`--test_sharding_strategy`](/reference/command-line-reference#flag--test_sharding_strategy) @@ -225,7 +225,7 @@ modified date of the file specified by [`TEST_SHARD_STATUS_FILE`](#initial-conditions), otherwise Bazel will fail the test if it is sharded. -## Initial conditions {#initial-conditions} +## Initial conditions When executing a test, the test runner must establish certain initial conditions. @@ -454,8 +454,7 @@ The initial environment block shall be composed as follows: Otherwise, Bazel generates a default XML output file wrapping the test log as part of the test action. The XML schema is based on the JUnit test result schema. - + class="external">JUnit test result schema. optional @@ -565,13 +564,13 @@ The initial process times (as returned by `times()`) and resource utilization The initial scheduling policy and priority are unspecified. -## Role of the host system {#role-host-system} +## Role of the host system In addition to the aspects of user context under direct control of the test runner, the operating system on which tests execute must satisfy certain properties for a test run to be valid. -#### Filesystem {#filesystem} +#### Filesystem The root directory observed by a test may or may not be the real root directory. @@ -590,7 +589,7 @@ use. Tests must not assume that atimes are enabled for any mounted filesystem. -#### Users and groups {#users-groups} +#### Users and groups The users root, nobody, and unittest must exist. The groups root, nobody, and eng must exist. @@ -607,13 +606,13 @@ supplementary group ids. The current user must have a home directory. It may not be writable. Tests must not attempt to write to it. -#### Networking {#networking} +#### Networking The hostname is unspecified. It may or may not contain a dot. Resolving the hostname must give an IP address of the current host. Resolving the hostname cut after the first dot must also work. The hostname localhost must resolve. -#### Other resources {#other-resources} +#### Other resources Tests are granted at least one CPU core. Others may be available but this is not guaranteed. Other performance aspects of this core are not specified. You can @@ -628,14 +627,14 @@ Tests may create subprocesses, but not process groups or sessions. There is a limit on the number of input files a test may consume. This limit is subject to change, but is currently in the range of tens of thousands of inputs. -#### Time and date {#time-and-date} +#### Time and date The current time and date are unspecified. The system timezone is unspecified. X Windows may or may not be available. Tests that need an X server should start Xvfb. -## Test interaction with the filesystem {#test-interaction-filesystem} +## Test interaction with the filesystem All file paths specified in test environment variables point to somewhere on the local filesystem, unless otherwise specified. @@ -696,11 +695,12 @@ In order to catch early exit, a test may create a file at the path specified by file when the test finishes, it will assume that the test exited prematurely and mark it as having failed. -## Execution platform {#execution-platform} +## Execution platform The [execution platform](/extending/platforms) for a test action is determined via [toolchain resolution](/extending/toolchains#toolchain-resolution), just -like for any other action. Each test rule has an implicitly defined [`test` exec group](/extending/exec-groups#exec-groups-for-native-rules) that, +like for any other action. Each test rule has an implicitly defined [ +`test` exec group](/extending/exec-groups#exec-groups-for-native-rules) that, unless overridden, has a mandatory toolchain requirement on `@bazel_tools//tools/test:default_test_toolchain_type`. @@ -737,11 +737,12 @@ behavior and their toolchains will take precedence over the default ones. Test rule authors can define their own test toolchain type and also register a default toolchain for it. -## Tag conventions {#tag-conventions} +## Tag conventions Some tags in the test rules have a special meaning. See also the -[Bazel Build Encyclopedia on the `tags` attribute](/reference/be/common-definitions#common.tags). +[Bazel Build Encyclopedia on the `tags` attribute] +(/reference/be/common-definitions#common.tags). @@ -761,7 +762,7 @@ See also the - + @@ -782,19 +783,19 @@ See also the Note: bazel `query` does not respect the manual tag. -## Runfiles {#runfiles} +## Runfiles In the following, assume there is a *_binary() rule labeled `//foo/bar:unittest`, with a run-time dependency on the rule labeled `//deps/server:server`. -#### Location {#runfiles-location} +#### Location The runfiles directory for a target `//foo/bar:unittest` is the directory `$(WORKSPACE)/$(BINDIR)/foo/bar/unittest.runfiles`. This path is referred to as the `runfiles_dir`. -#### Dependencies {#runfiles-dependencies} +#### Dependencies The runfiles directory is declared as a compile-time dependency of the `*_binary()` rule. The runfiles directory itself depends on the set of BUILD @@ -802,7 +803,7 @@ files that affect the `*_binary()` rule or any of its compile-time or run-time dependencies. Modifying source files does not affect the structure of the runfiles directory, and thus does not trigger any rebuilding. -#### Contents {#runfiles-contents} +#### Contents The runfiles directory contains the following: diff --git a/release/backward-compatibility.mdx b/release/backward-compatibility.mdx index b838e511..af653ccd 100644 --- a/release/backward-compatibility.mdx +++ b/release/backward-compatibility.mdx @@ -8,11 +8,13 @@ This page provides information about how to handle backward compatibility, including migrating from one release to another and how to communicate incompatible changes. -Bazel is evolving. Minor versions released as part of an [LTS major version](/release#bazel-versioning) are fully backward-compatible. New major LTS +Bazel is evolving. Minor versions released as part of an [LTS major +version](/release#bazel-versioning) are fully backward-compatible. New major LTS releases may contain incompatible changes that require some migration effort. -For more information about Bazel's release model, please check out the [Release Model](/release) page. +For more information about Bazel's release model, please check out the [Release +Model](/release) page. -## Summary {#summary} +## Summary 1. It is recommended to use `--incompatible_*` flags for breaking changes. 1. For every `--incompatible_*` flag, a GitHub issue explains the change in @@ -24,13 +26,13 @@ For more information about Bazel's release model, please check out the [Release 1. Never run production builds with `--experimental_*` or `--incompatible_*` flags. -## How to follow this policy {#policy} +## How to follow this policy * [For Bazel users - how to update Bazel](/install/bazelisk) * [For contributors - best practices for incompatible changes](/contribute/breaking-changes) * [For release managers - how to update issue labels and release](https://github.com/bazelbuild/continuous-integration/tree/master/docs/release-playbook.%6D%64) -## What is stable functionality? {#stable-functionality} +## What is stable functionality? In general, APIs or behaviors without `--experimental_...` flags are considered stable, supported features in Bazel. @@ -42,7 +44,7 @@ This includes: * Bazel APIs such as Remote Execution APIs or Build Event Protocol * Flags and their semantics -## Incompatible changes and migration recipes {#incompatible-changes} +## Incompatible changes and migration recipes For every incompatible change in a new release, the Bazel team aims to provide a _migration recipe_ that helps you update your code (`BUILD` and `.bzl` files, as @@ -56,10 +58,11 @@ the latest LTS release without enabling the flag by default. This allows users to migrate for the incompatible changes before the next LTS release is available. -## Communicating incompatible changes {#communicating-incompatible-changes} +## Communicating incompatible changes The primary source of information about incompatible changes are GitHub issues -marked with an ["incompatible-change" label](https://github.com/bazelbuild/bazel/issues?q=label%3Aincompatible-change). +marked with an ["incompatible-change" +label](https://github.com/bazelbuild/bazel/issues?q=label%3Aincompatible-change). For every incompatible change, the issue specifies the following: diff --git a/release/index.mdx b/release/index.mdx index 822c08f5..84e6e4d7 100644 --- a/release/index.mdx +++ b/release/index.mdx @@ -4,28 +4,31 @@ title: 'Release Model' -As announced in [the original blog post](https://blog.bazel.build/2020/11/10/long-term-support-release.html), Bazel +As announced in [the original blog +post](https://blog.bazel.build/2020/11/10/long-term-support-release.html), Bazel 4.0 and higher versions provides support for two release tracks: rolling releases and long term support (LTS) releases. This page covers the latest information about Bazel's release model. -## Support matrix {#support-matrix} +## Support matrix | LTS release | Support stage | Latest version | End of support | | ----------- | ------------- | -------------- | -------------- | | Bazel 10 | Rolling| [Check rolling release page](/release/rolling) | N/A | -| Bazel 9 | Active| [9.1.0](https://github.com/bazelbuild/bazel/releases/tag/9.1.0) | Dec 2028 | +| Bazel 9 | Active| [9.0.1](https://github.com/bazelbuild/bazel/releases/tag/9.0.1) | Dec 2028 | | Bazel 8 | Maintenance| [8.6.0](https://github.com/bazelbuild/bazel/releases/tag/8.6.0) | Dec 2027 | | Bazel 7 | Maintenance| [7.7.1](https://github.com/bazelbuild/bazel/releases/tag/7.7.1) | Dec 2026 | | Bazel 6 | Deprecated | [6.6.0](https://github.com/bazelbuild/bazel/releases/tag/6.6.0) | Dec 2025 | | Bazel 5 | Deprecated | [5.4.1](https://github.com/bazelbuild/bazel/releases/tag/5.4.1) | Jan 2025 | | Bazel 4 | Deprecated | [4.2.4](https://github.com/bazelbuild/bazel/releases/tag/4.2.4) | Jan 2024 | -All Bazel LTS releases can be found on the [release page](https://github.com/bazelbuild/bazel/releases) on GitHub. +All Bazel LTS releases can be found on the [release +page](https://github.com/bazelbuild/bazel/releases) on GitHub. -## Release versioning {#bazel-versioning} +## Release versioning -Bazel uses a _major.minor.patch_ [Semantic Versioning](https://semver.org/) scheme. +Bazel uses a _major.minor.patch_ [Semantic +Versioning](https://semver.org/) scheme. * A _major release_ contains features that are not backward compatible with the previous release. Each major Bazel version is an LTS release. @@ -43,7 +46,7 @@ For example, a new release of each type would result in these version numbers: * Patch: 6.1.2 * Pre-release: 7.0.0-pre.20230502.1 -## Support stages {#support-stages} +## Support stages For each major Bazel version, there are four support stages: @@ -57,20 +60,21 @@ For each major Bazel version, there are four support stages: * **Deprecated**: The Bazel team no longer provides support for this major version, all users should migrate to newer Bazel LTS releases. -## Release cadence {#release-cadence} +## Release cadence Bazel regularly publish releases for two release tracks. -### Rolling releases {#rolling-releases} +### Rolling releases * Rolling releases are coordinated with Google Blaze release and are released from HEAD around every two weeks. It is a preview of the next Bazel LTS release. * Rolling releases can ship incompatible changes. Incompatible flags are recommended for major breaking changes, rolling out incompatible changes - should follow our [backward compatibility policy](/release/backward-compatibility). + should follow our [backward compatibility + policy](/release/backward-compatibility). -### LTS releases {#lts-releases} +### LTS releases * _Major release_: A new LTS release is expected to be cut from HEAD roughly every @@ -84,10 +88,11 @@ Bazel regularly publish releases for two release tracks. * A Bazel LTS release enters the Deprecated stage after being in ​​the Maintenance stage for 2 years. -For planned releases, please check our [release issues](https://github.com/bazelbuild/bazel/issues?q=is%3Aopen+is%3Aissue+label%3Arelease) +For planned releases, please check our [release +issues](https://github.com/bazelbuild/bazel/issues?q=is%3Aopen+is%3Aissue+label%3Arelease) on Github. -## Release procedure & policies {#release-procedure-policies} +## Release procedure & policies For rolling releases, the process is straightforward: about every two weeks, a new release is created, aligning with the same baseline as the Google internal @@ -147,7 +152,8 @@ For LTS releases, the procedure and policies below are followed: 1. Identify release blockers and fix issues found on the release branch. * The release branch is tested with the same test suite in [postsubmit](https://buildkite.com/bazel/bazel-bazel) and - [downstream test pipeline](https://buildkite.com/bazel/bazel-at-head-plus-downstream) + [downstream test pipeline] + (https://buildkite.com/bazel/bazel-at-head-plus-downstream) on Bazel CI. The Bazel team monitors testing results of the release branch and fixes any regressions found. 1. Create a new release candidate from the release branch when all known @@ -177,7 +183,7 @@ For LTS releases, the procedure and policies below are followed: the Bazel team monitors and addresses community bug reports for the new release. -## Report regressions {#report-regressions} +## Report regressions If a user finds a regression in a new Bazel release, release candidate or even Bazel at HEAD, please file a bug on @@ -200,7 +206,8 @@ reproduce the issue. For more details, check out documentation about Bazelisk Remember to upgrade Bazelisk to the latest version to use the bisect feature. -## Rule compatibility {#rule-compatibility} +## Rule compatibility If you are a rule authors and want to maintain compatibility with different -Bazel versions, please check out the [Rule Compatibility](/release/rule-compatibility) page. +Bazel versions, please check out the [Rule +Compatibility](/release/rule-compatibility) page. diff --git a/release/rolling.mdx b/release/rolling.mdx index e4a87b3f..ba7ba918 100644 --- a/release/rolling.mdx +++ b/release/rolling.mdx @@ -9,6 +9,6 @@ This page contains an overview of all rolling releases, as per our [Bazelisk](https://github.com/bazelbuild/bazelisk) is the best way to use these releases. -## Index {#index} +## Index diff --git a/release/rule-compatibility.mdx b/release/rule-compatibility.mdx index 78d79dc1..05a8a95e 100644 --- a/release/rule-compatibility.mdx +++ b/release/rule-compatibility.mdx @@ -18,7 +18,7 @@ and Bazel version can often be a source of frustration for Bazel users. This page covers how rules authors should maintain rule compatibility with Bazel to make it easier for users to upgrade Bazel and rules. -## Manageable migration process {#manageable-migration-process} +## Manageable migration process While it's obviously not feasible to guarantee compatibility between every version of Bazel and every version of the rule, our aim is to ensure that the @@ -50,20 +50,23 @@ release. ✅: At least one version of the rule is compatible with the latest version of the Bazel LTS release. -## Best practices {#best-practices} +## Best practices As Bazel rules authors, you can ensure a manageable migration process for users by following these best practices: -1. The rule should follow [Semantic Versioning](https://semver.org/): minor versions of the same +1. The rule should follow [Semantic + Versioning](https://semver.org/): minor versions of the same major version are backward compatible. 1. The rule at HEAD should be compatible with the latest Bazel LTS release. 1. The rule at HEAD should be compatible with Bazel at HEAD. To achieve this, you can * Set up your own CI testing with Bazel at HEAD - * Add your project to [Bazel downstream testing](https://github.com/bazelbuild/continuous-integration/blob/master/docs/downstream-testing.md); + * Add your project to [Bazel downstream + testing](https://github.com/bazelbuild/continuous-integration/blob/master/docs/downstream-testing.md); the Bazel team files issues to your project if breaking changes in Bazel - affect your project, and you must follow our [downstream project policies](https://github.com/bazelbuild/continuous-integration/blob/master/docs/downstream-testing.md#downstream-project-policies) + affect your project, and you must follow our [downstream project + policies](https://github.com/bazelbuild/continuous-integration/blob/master/docs/downstream-testing.md#downstream-project-policies) to address issues timely. 1. The latest major version of the rule must be compatible with the latest Bazel LTS release. diff --git a/remote/bep-examples.mdx b/remote/bep-examples.mdx index 7b3f406a..faf11bf9 100644 --- a/remote/bep-examples.mdx +++ b/remote/bep-examples.mdx @@ -100,7 +100,7 @@ built. } ``` -## Aspect Results in BEP {#aspect-results} +## Aspect Results in BEP Ordinary builds evaluate actions associated with `(target, configuration)` pairs. When building with [aspects](/extending/aspects) enabled, Bazel @@ -142,7 +142,7 @@ Note: The only difference between the IDs is the presence of the `aspect` field. A tool that does not check the `aspect` ID field and accumulates output files by target may conflate target outputs with aspect outputs. -## Consuming `NamedSetOfFiles` {#consuming-namedsetoffiles} +## Consuming `NamedSetOfFiles` Determining the artifacts produced by a given target (or aspect) is a common BEP use-case that can be done efficiently with some preparation. This section diff --git a/remote/bep-glossary.mdx b/remote/bep-glossary.mdx index 80739e51..3bd11eea 100644 --- a/remote/bep-glossary.mdx +++ b/remote/bep-glossary.mdx @@ -8,7 +8,7 @@ Each BEP event type has its own semantics, minimally documented in [build\_event\_stream.proto](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto). The following glossary describes each event type. -## Aborted {#aborted} +## Aborted Unlike other events, `Aborted` does not have a corresponding ID type, because the `Aborted` event *replaces* events of other types. This event indicates that @@ -35,27 +35,27 @@ BEP contains an event like the following: } ``` -## ActionExecuted {#actionexecuted} +## ActionExecuted Provides details about the execution of a specific -[Action](/rules/lib/builtins/actions) in a build. By default, this event is +[Action](/rules/lib/actions) in a build. By default, this event is included in the BEP only for failed actions, to support identifying the root cause of build failures. Users may set the `--build_event_publish_all_actions` flag to include all `ActionExecuted` events. -## BuildFinished {#buildfinished} +## BuildFinished A single `BuildFinished` event is sent after the command is complete and includes the exit code for the command. This event provides authoritative success/failure information. -## BuildMetadata {#buildmetadata} +## BuildMetadata Contains the parsed contents of the `--build_metadata` flag. This event exists to support Bazel integration with other tooling by plumbing external data (such as identifiers). -## BuildMetrics {#buildmetrics} +## BuildMetrics A single `BuildMetrics` event is sent at the end of every command and includes counters/gauges useful for quantifying the build tool's behavior during the @@ -92,12 +92,12 @@ collector to run at the end of the command to populate `memory_metrics`. } ``` -## BuildStarted {#buildstarted} +## BuildStarted The first event in a BEP stream, `BuildStarted` includes metadata describing the command before any meaningful work begins. -## BuildToolLogs {#buildtoollogs} +## BuildToolLogs A single `BuildToolLogs` event is sent at the end of a command, including URIs of files generated by the build tool that may aid in understanding or debugging @@ -128,7 +128,7 @@ build tool behavior. Some information may be included inline. } ``` -## CommandLine {#commandline} +## CommandLine The BEP contains multiple `CommandLine` events containing representations of all command-line arguments (including options and uninterpreted arguments). @@ -145,7 +145,7 @@ indicates which representation it conveys; three such events appear in the BEP: which is used directly, or a string which is parsed but not interpreted (as the tool's options may differ from Bazel's). -## Configuration {#configuration} +## Configuration A `Configuration` event is sent for every [`configuration`](/extending/config) used in the top-level targets in a build. At least one configuration event is @@ -174,7 +174,7 @@ multi-configuration builds. } ``` -## ConvenienceSymlinksIdentified {#conveniencesymlinksidentified} +## ConvenienceSymlinksIdentified **Experimental.** If the `--experimental_convenience_symlinks_bep_event` option is set, a single `ConvenienceSymlinksIdentified` event is produced by @@ -209,13 +209,13 @@ workspace as if Bazel had been run locally. } ``` -## Fetch {#fetch} +## Fetch Indicates that a Fetch operation occurred as a part of the command execution. Unlike other events, if a cached fetch result is re-used, this event does not appear in the BEP stream. -## NamedSetOfFiles {#namedsetoffiles} +## NamedSetOfFiles `NamedSetOfFiles` events report a structure matching a [`depset`](/extending/depsets) of files produced during command evaluation. @@ -224,7 +224,7 @@ Transitively included depsets are identified by `NamedSetOfFilesId`. For more information on interpreting a stream's `NamedSetOfFiles` events, see the [BEP examples page](/remote/bep-examples#consuming-namedsetoffiles). -## OptionsParsed {#optionsparsed} +## OptionsParsed A single `OptionsParsed` event lists all options applied to the command, separating startup options from command options. It also includes the @@ -262,7 +262,7 @@ separating startup options from command options. It also includes the } ``` -## PatternExpanded {#patternexpanded} +## PatternExpanded `PatternExpanded` events indicate the set of all targets that match the patterns supplied on the commandline. For successful commands, a single event is present @@ -292,14 +292,14 @@ event with a `PatternExpandedId` identifying the pattern. } ``` -## Progress {#progress} +## Progress Progress events contain the standard output and standard error produced by Bazel during command execution. These events are also auto-generated as needed to announce events that have not been announced by a logical "parent" event (in particular, [NamedSetOfFiles](#namedsetoffiles).) -## TargetComplete {#targetcomplete} +## TargetComplete For each `(target, configuration, aspect)` combination that completes the execution phase, a `TargetComplete` event is included in BEP. The event contains @@ -331,7 +331,7 @@ the target's success/failure and the target's requested output groups. } ``` -## TargetConfigured {#targetconfigured} +## TargetConfigured For each Target that completes the analysis phase, a `TargetConfigured` event is included in BEP. This is the authoritative source for a target's "rule kind" @@ -373,20 +373,20 @@ configurations: } ``` -## TargetSummary {#targetsummary} +## TargetSummary For each `(target, configuration)` pair that is executed, a `TargetSummary` event is included with an aggregate success result encompassing the configured target's execution and all aspects applied to that configured target. -## TestResult {#testresult} +## TestResult If testing is requested, a `TestResult` event is sent for each test attempt, shard, and run per test. This allows BEP consumers to identify precisely which test actions failed their tests and identify the test outputs (such as logs, test.xml files) for each test action. -## TestSummary {#testsummary} +## TestSummary If testing is requested, a `TestSummary` event is sent for each test `(target, configuration)`, containing information necessary to interpret the test's @@ -395,7 +395,7 @@ BEP consumers to differentiate artifacts across these dimensions. The attempts and runs per test are considered while producing the aggregate `TestStatus` to differentiate `FLAKY` tests from `FAILED` tests. -## UnstructuredCommandLine {#unstructuredcommandline} +## UnstructuredCommandLine Unlike [CommandLine](#commandline), this event carries the unparsed commandline flags in string form as encountered by the build tool after expanding all @@ -405,11 +405,12 @@ considering the `--config` flag. The `UnstructuredCommandLine` event may be relied upon to precisely reproduce a given command execution. -## WorkspaceConfig {#workspaceconfig} +## WorkspaceConfig A single `WorkspaceConfig` event contains configuration information regarding the workspace, such as the execution root. -## WorkspaceStatus {#workspacestatus} +## WorkspaceStatus -A single `WorkspaceStatus` event contains the result of the [workspace status command](/docs/user-manual#workspace-status). +A single `WorkspaceStatus` event contains the result of the [workspace status +command](/docs/user-manual#workspace-status). diff --git a/remote/bep.mdx b/remote/bep.mdx index 08ac72d2..bafdaa9e 100644 --- a/remote/bep.mdx +++ b/remote/bep.mdx @@ -4,12 +4,14 @@ title: 'Build Event Protocol' -The [Build Event Protocol](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto) +The [Build Event +Protocol](https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto) (BEP) allows third-party programs to gain insight into a Bazel invocation. For example, you could use the BEP to gather information for an IDE plugin or a dashboard that displays build results. -The protocol is a set of [protocol buffer](https://developers.google.com/protocol-buffers/) messages with some +The protocol is a set of [protocol +buffer](https://developers.google.com/protocol-buffers/) messages with some semantics defined on top of it. It includes information about build and test results, build progress, the build configuration and much more. The BEP is intended to be consumed programmatically and makes parsing Bazel’s @@ -20,13 +22,16 @@ build event is a protocol buffer message consisting of a build event identifier, a set of child event identifiers, and a payload. * __Build Event Identifier:__ Depending on the kind of build event, it might be -an [opaque string](https://github.com/bazelbuild/bazel/blob/7.1.0/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto#L131-L140) -or [structured information](https://github.com/bazelbuild/bazel/blob/7.1.0/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto#L194-L205) +an [opaque +string](https://github.com/bazelbuild/bazel/blob/7.1.0/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto#L131-L140) +or [structured +information](https://github.com/bazelbuild/bazel/blob/7.1.0/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto#L194-L205) revealing more about the build event. A build event identifier is unique within a build. * __Children:__ A build event may announce other build events, by including -their build event identifiers in its [children field](https://github.com/bazelbuild/bazel/blob/7.1.0/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto#L1276). +their build event identifiers in its [children +field](https://github.com/bazelbuild/bazel/blob/7.1.0/src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto#L1276). For example, the `PatternExpanded` build event announces the targets it expands to as children. The protocol guarantees that all events, except for the first event, are announced by a previous event. @@ -36,7 +41,7 @@ encoded as a protocol buffer message specific to that event. Note that the payload might not be the expected type, but could be an `Aborted` message if the build aborted prematurely. -### Build event graph {#build-event-graph} +### Build event graph All build events form a directed acyclic graph through their parent and child relationship. Every build event except for the initial build event has one or @@ -59,9 +64,9 @@ graph has the following characteristic shape: by events containing summary information about the build (for example, metric or profiling data). -## Consuming Build Event Protocol {#consuming-bep} +## Consuming Build Event Protocol -### Consume in binary format {#consuming-bep-binary} +### Consume in binary format To consume the BEP in a binary format: @@ -76,7 +81,7 @@ To consume the BEP in a binary format: 2. Then, write a program that extracts the relevant information from the serialized protocol buffer message. -### Consume in text or JSON formats {#consuming-bep-text-json} +### Consume in text or JSON formats The following Bazel command line flags will output the BEP in human-readable formats, such as text and JSON: @@ -86,9 +91,10 @@ human-readable formats, such as text and JSON: --build_event_json_file ``` -## Build Event Service {#build-event-service} +## Build Event Service -The [Build Event Service](https://github.com/googleapis/googleapis/blob/master/google/devtools/build/v1/publish_build_event.proto) +The [Build Event +Service](https://github.com/googleapis/googleapis/blob/master/google/devtools/build/v1/publish_build_event.proto) Protocol is a generic [gRPC](https://www.grpc.io) service for publishing build events. The Build Event Service protocol is independent of the BEP and treats BEP events as opaque bytes. Bazel ships with a gRPC client implementation of the Build Event Service protocol that @@ -97,7 +103,7 @@ events to using the `--bes_backend=HOST:PORT` flag. If your backend uses gRPC, you must prefix the address with the appropriate scheme: `grpc://` for plaintext gRPC and `grpcs://` for gRPC with TLS enabled. -### Build Event Service flags {#bes-flags} +### Build Event Service flags Bazel has several flags related to the Build Event Service protocol, including: @@ -110,7 +116,7 @@ Bazel has several flags related to the Build Event Service protocol, including: For a description of each of these flags, see the [Command-Line Reference](/reference/command-line-reference). -### Authentication and security {#authentication-security} +### Authentication and security Bazel’s Build Event Service implementation also supports authentication and TLS. These settings can be controlled using the below flags. Please note that these @@ -127,12 +133,13 @@ authentication and TLS infrastructure. For a description of each of these flags, see the [Command-Line Reference](/reference/command-line-reference). -### Build Event Service and remote caching {#bes-remote-caching} +### Build Event Service and remote caching The BEP typically contains many references to log files (test.log, test.xml, etc. ) stored on the machine where Bazel is running. A remote BES server typically can't access these files as they are on different machines. A way to -work around this issue is to use Bazel with [remote caching](/remote/caching). +work around this issue is to use Bazel with [remote +caching](/remote/caching). Bazel will upload all output files to the remote cache (including files referenced in the BEP) and the BES server can then fetch the referenced files from the cache. diff --git a/remote/cache-local.mdx b/remote/cache-local.mdx index ac81188e..2d5fa81d 100644 --- a/remote/cache-local.mdx +++ b/remote/cache-local.mdx @@ -17,10 +17,11 @@ logs between two Bazel invocations, see Everything presented in that guide also applies to remote caching with local execution. However, local execution presents some additional challenges. -## Checking your cache hit rate {#cache-hits} +## Checking your cache hit rate Successful remote cache hits will show up in the status line, similar to -[Cache Hits rate with Remote Execution](/remote/cache-remote#check-cache-hits). +[Cache Hits rate with Remote +Execution](/remote/cache-remote#check-cache-hits). In the standard output of your Bazel run, you will see something like the following: @@ -35,11 +36,11 @@ strategy. Local cache hits are not included in this summary. If you are getting 0 processes (or a number lower than expected), run `bazel clean` followed by your build/test command. -## Troubleshooting cache hits {#troubleshooting-cache-hits} +## Troubleshooting cache hits If you are not getting the cache hit rate you are expecting, do the following: -### Ensure successful communication with the remote endpoint {#remote-endpoint-success} +### Ensure successful communication with the remote endpoint To ensure your build is successfully communicating with the remote cache, follow the steps in this section. @@ -69,7 +70,8 @@ the steps in this section. message you see does not give you enough information, try adding `--verbose_failures`. -2. Follow the steps from [Troubleshooting cache hits for remote execution](/remote/cache-remote#troubleshooting_cache_hits) to +2. Follow the steps from [Troubleshooting cache hits for remote + execution](/remote/cache-remote#troubleshooting_cache_hits) to ensure that your cache-writing Bazel invocations are able to get cache hits on the same machine and across machines. @@ -83,6 +85,7 @@ the steps in this section. b. Ensure your cache-reading Bazel invocations build the same targets as the cache-writing Bazel invocations. - c. Follow the same steps as to [ensure caching across machines](/remote/cache-remote#caching-across-machines), + c. Follow the same steps as to [ensure caching across + machines](/remote/cache-remote#caching-across-machines), to ensure caching from your cache-writing Bazel invocation to your cache-reading Bazel invocation. diff --git a/remote/cache-remote.mdx b/remote/cache-remote.mdx index 21eb25fb..1480c03f 100644 --- a/remote/cache-remote.mdx +++ b/remote/cache-remote.mdx @@ -11,7 +11,7 @@ This page assumes that you have a build and/or test that successfully utilizes remote execution, and you want to ensure that you are effectively utilizing remote cache. -## Checking your cache hit rate {#check-cache-hits} +## Checking your cache hit rate In the standard output of your Bazel run, look at the `INFO` line that lists processes, which roughly correspond to Bazel actions. That line details @@ -33,11 +33,11 @@ cache hits are not included in this summary. If you are getting 0 processes (or a number lower than expected), run `bazel clean` followed by your build/test command. -## Troubleshooting cache hits {#troubleshooting-cache-hits} +## Troubleshooting cache hits If you are not getting the cache hit rate you are expecting, do the following: -### Ensure re-running the same build/test command produces cache hits {#rerun-cache-hits} +### Ensure re-running the same build/test command produces cache hits 1. Run the build(s) and/or test(s) that you expect to populate the cache. The first time a new build is run on a particular stack, you can expect no remote @@ -108,7 +108,7 @@ If you are not getting the cache hit rate you are expecting, do the following: set to `false`: either at the command line or in a [bazelrc](/run/bazelrc#bazelrc-file-locations) file. -### Ensure caching across machines {#caching-across-machines} +### Ensure caching across machines After cache hits are happening as expected on the same machine, run the same build(s)/test(s) on a different machine. If you suspect that caching is @@ -138,7 +138,7 @@ not happening across machines, do the following: for discrepancies as well as properties from the host environment leaking into either of the builds. -## Comparing the execution logs {#compare-logs} +## Comparing the execution logs The execution log contains records of actions executed during the build. Each record describes both the inputs (not only files, but also command line diff --git a/remote/caching.mdx b/remote/caching.mdx index 97a1ba88..415925d2 100644 --- a/remote/caching.mdx +++ b/remote/caching.mdx @@ -12,7 +12,7 @@ A remote cache is used by a team of developers and/or a continuous integration outputs from one machine can be safely reused on another machine, which can make builds significantly faster. -## Overview {#overview} +## Overview Bazel breaks a build into discrete steps, which are called actions. Each action has inputs, output names, a command line, and environment variables. Required @@ -38,7 +38,7 @@ Note that the remote cache additionally stores the stdout and stderr for every action. Inspecting the stdout/stderr of Bazel thus is not a good signal for [estimating cache hits](/remote/cache-local). -### How a build uses remote caching {#remote-caching} +### How a build uses remote caching Once a server is set up as the remote cache, you use the cache in multiple ways: @@ -62,7 +62,7 @@ Bazel retrieves the output. This is a cache hit. actions locally and creates the required build outputs. 5. New build outputs are uploaded to the remote cache. -## Setting up a server as the cache's backend {#cache-backend} +## Setting up a server as the cache's backend You need to set up a server to act as the cache's backend. A HTTP/1.1 server can treat Bazel's data as opaque bytes and so many existing servers @@ -85,7 +85,7 @@ include: * [bazel-remote](#bazel-remote) * [Google Cloud Storage](#cloud-storage) -### nginx {#nginx} +### nginx nginx is an open source web server. With its [WebDAV module], it can be used as a remote cache for Bazel. On Debian and Ubuntu you can install the @@ -120,7 +120,7 @@ location /cache/ { } ``` -### bazel-remote {#bazel-remote} +### bazel-remote bazel-remote is an open source remote build cache that you can use on your infrastructure. It has been successfully used in production at @@ -129,14 +129,14 @@ not provide technical support for bazel-remote. This cache stores contents on disk and also provides garbage collection to enforce an upper storage limit and clean unused artifacts. The cache is -available as a [docker image](https://hub.docker.com/r/buchgr/bazel-remote-cache/) and its code is available on +available as a [docker image] and its code is available on [GitHub](https://github.com/buchgr/bazel-remote/). Both the REST and gRPC remote cache APIs are supported. Refer to the [GitHub](https://github.com/buchgr/bazel-remote/) page for instructions on how to use it. -### Google Cloud Storage {#cloud-storage} +### Google Cloud Storage [Google Cloud Storage] is a fully managed object store which provides an HTTP API that is compatible with Bazel's remote caching protocol. It requires @@ -164,13 +164,13 @@ to/from your GCS bucket. 5. You can configure Cloud Storage to automatically delete old files. To do so, see [Managing Object Lifecycles](https://cloud.google.com/storage/docs/managing-lifecycles). -### Other servers {#other-servers} +### Other servers You can set up any HTTP/1.1 server that supports PUT and GET as the cache's backend. Users have reported success with caching backends such as [Hazelcast](https://hazelcast.com), [Apache httpd](http://httpd.apache.org), and [AWS S3](https://aws.amazon.com/s3). -## Authentication {#authentication} +## Authentication As of version 0.11.0 support for HTTP Basic Authentication was added to Bazel. You can pass a username and password to Bazel via the remote cache URL. The @@ -178,7 +178,7 @@ syntax is `https://username:password@hostname.com:port/path`. Note that HTTP Basic Authentication transmits username and password in plaintext over the network and it's thus critical to always use it with HTTPS. -## HTTP caching protocol {#http-caching} +## HTTP caching protocol Bazel supports remote caching via HTTP/1.1. The protocol is conceptually simple: Binary data (BLOB) is uploaded via PUT requests and downloaded via GET requests. @@ -209,7 +209,7 @@ Connection: Keep-Alive 0x310x320x330x340x350x360x370x380x39 ``` -## Run Bazel using the remote cache {#run-remote-cache} +## Run Bazel using the remote cache Once a server is set up as the remote cache, to use the remote cache you need to add flags to your Bazel command. See list of configurations and @@ -226,7 +226,7 @@ team dynamics, you can add flags to a `.bazelrc` file that is: * In your project's workspace, shared with the team * On the CI system -### Read from and write to the remote cache {#read-write-remote-cache} +### Read from and write to the remote cache Take care in who has the ability to write to the remote cache. You may want only your CI system to be able to write to the remote cache. @@ -246,7 +246,7 @@ remote cache: build --remote_upload_local_results=false ``` -### Exclude specific targets from using the remote cache {#targets-remote-cache} +### Exclude specific targets from using the remote cache To exclude specific targets from using the remote cache, tag the target with `no-remote-cache`. For example: @@ -258,7 +258,7 @@ java_library( ) ``` -### Delete content from the remote cache {#delete-remote-cache} +### Delete content from the remote cache Deleting content from the remote cache is part of managing your server. How you delete content from the remote cache depends on the server you have @@ -274,7 +274,7 @@ You may want to delete content from the cache to: * Create a clean cache after a cache was poisoned * Reduce the amount of storage used by deleting old outputs -### Unix sockets {#unix-sockets} +### Unix sockets The remote HTTP cache supports connecting over unix domain sockets. The behavior is similar to curl's `--unix-socket` flag. Use the following to configure unix @@ -287,7 +287,7 @@ domain socket: This feature is unsupported on Windows. -## Disk cache {#disk-cache} +## Disk cache Bazel can use a directory on the file system as a remote cache. This is useful for sharing build artifacts when switching branches and/or working @@ -298,17 +298,12 @@ Enable the disk cache as follows: build --disk_cache=path/to/build/cache ``` -You can also run `build --disk_cache` with no value to use a default location -under your [output user root](/reference/user-manual#output-user-root) -(`/cache/disk`), alongside the repository cache. Use -`build --nodisk_cache` to disable the disk cache explicitly. - You can pass a user-specific path to the `--disk_cache` flag using the `~` alias (Bazel will substitute the current user's home directory). This comes in handy when enabling the disk cache for all developers of a project via the project's checked in `.bazelrc` file. -### Garbage collection {#disk-cache-gc} +### Garbage collection Starting with Bazel 7.4, you can use `--experimental_disk_cache_gc_max_size` and `--experimental_disk_cache_gc_max_age` to set a maximum size for the disk cache @@ -316,10 +311,11 @@ or for the age of individual cache entries. Bazel will automatically garbage collect the disk cache while idling between builds; the idle timer can be set with `--experimental_disk_cache_gc_idle_delay` (defaulting to 5 minutes). -As an alternative to automatic garbage collection, we also provide a [tool](https://github.com/bazelbuild/bazel/tree/master/src/tools/diskcache) to run a +As an alternative to automatic garbage collection, we also provide a [tool]( +https://github.com/bazelbuild/bazel/tree/master/src/tools/diskcache) to run a garbage collection on demand. -## Known issues {#known-issues} +## Known issues **Input file modification during a build** @@ -355,7 +351,7 @@ On the server side, Bazel maintains an in-memory state which speeds up builds. When running builds inside docker containers such as in CI, the in-memory state is lost and Bazel must rebuild it before using the remote cache. -## External links {#external-links} +## External links * **Your Build in a Datacenter:** The Bazel team gave a [talk](https://fosdem.org/2018/schedule/event/datacenter_build/) about remote caching and execution at FOSDEM 2018. diff --git a/remote/ci.mdx b/remote/ci.mdx index d5de9c5b..325393d8 100644 --- a/remote/ci.mdx +++ b/remote/ci.mdx @@ -10,7 +10,7 @@ your repository to test your rules for compatibility against a remote execution scenario. The instructions on this page apply to projects stored in GitHub repositories. -## Prerequisites {#prerequisites} +## Prerequisites Before completing the steps on this page, ensure the following: @@ -19,7 +19,7 @@ Before completing the steps on this page, ensure the following: * You have configured Buildkite for your repository as described in [Bazel Continuous Integration](https://github.com/bazelbuild/continuous-integration/tree/master/buildkite). -## Setting up the Bazel CI for testing {#bazel-ci-testing} +## Setting up the Bazel CI for testing 1. In your `.bazelci/presubmit.yml` file, do the following: @@ -58,7 +58,7 @@ rbe_autoconfig(name = "buildkite_config") ![Branch protection rules settings](/docs/images/rbe-ci-2.png "Branch protection rules") -## Troubleshooting failed builds and tests {#troubleshooting-failed-builds} +## Troubleshooting failed builds and tests If your build or tests fail, it's likely due to the following: @@ -76,7 +76,7 @@ If your build or tests fail, it's likely due to the following: [Adapting Bazel Rules for Remote Execution](/remote/rules) for details about compatibility with remote execution. -## Using a custom container in the rbe_ubuntu1604 CI config {#custom-container} +## Using a custom container in the rbe_ubuntu1604 CI config The `rbe-ubuntu16-04` container is publicly available at the following URL: @@ -91,7 +91,7 @@ Before you begin, make sure you have installed `gcloud`, `docker`, and `git`. If you are building the container from source, you must also install the latest version of Bazel. -### Pulling the rbe-ubuntu16-04 from Container Registry {#container-registry} +### Pulling the rbe-ubuntu16-04 from Container Registry To pull the `rbe-ubuntu16-04` container from Container Registry, run the following command: @@ -103,7 +103,7 @@ gcloud docker -- pull gcr.io/cloud-marketplace/google/rbe-ubuntu16-04@sha256:sha256-checksum with the SHA256 checksum value for [the latest container](https://console.cloud.google.com/gcr/images/cloud-marketplace/GLOBAL/google/rbe-ubuntu16-04). -### Building the rbe-ubuntu16-04 container from source {#container-source} +### Building the rbe-ubuntu16-04 container from source To build the `rbe-ubuntu16-04` container from source, do the following: @@ -122,7 +122,7 @@ To build the `rbe-ubuntu16-04` container from source, do the following: gcloud docker -- pull gcr.io/project-id/custom-container-namesha256-checksum ``` -### Running the custom container {#run-custom-container} +### Running the custom container To run the custom container, do one of the following: @@ -142,7 +142,7 @@ To run the custom container, do one of the following: docker run -it gcr.io/project-id/custom-container-name@sha256:sha256sum /bin/bash ``` -### Adding resources to the custom container {#add-resources-container} +### Adding resources to the custom container Use a [`Dockerfile`](https://docs.docker.com/engine/reference/builder/) or [`rules_docker`](https://github.com/bazelbuild/rules_docker) to add resources or @@ -159,7 +159,7 @@ FROM gcr.io/cloud-marketplace/google/rbe-ubuntu16-04@sha256:sha256-checksum RUN apt-get update && yes | apt-get install -y my_tool_package ``` -### Pushing the custom container to Container Registry {#push-container-registry} +### Pushing the custom container to Container Registry Once you have customized the container, build the container image and push it to Container Registry as follows: @@ -193,7 +193,7 @@ Container Registry as follows: [Pushing and Pulling Images](https://cloud.google.com/container-registry/docs/pushing-and-pulling). -### Specifying the build platform definition {#platform-definition} +### Specifying the build platform definition You must include a [Bazel platform](/extending/platforms) configuration in your custom toolchain configuration, which allows Bazel to select a toolchain diff --git a/remote/creating.mdx b/remote/creating.mdx index b2ea83f7..0e46a07a 100644 --- a/remote/creating.mdx +++ b/remote/creating.mdx @@ -17,7 +17,7 @@ The worker implementation has two parts: * The [worker](#making-worker). * The [rule that uses the worker](#rule-uses-worker). -## Making the worker {#making-worker} +## Making the worker A persistent worker upholds a few requirements: @@ -34,7 +34,7 @@ A persistent worker upholds a few requirements: If your program upholds these requirements, it can be used as a persistent worker! -### Work requests {#work-requests} +### Work requests A `WorkRequest` contains a list of arguments to the worker, a list of path-digest pairs representing the inputs the worker can access (this isn’t @@ -66,7 +66,7 @@ manually for different amounts of output. The optional `sandbox_dir` field is used only by workers that support [multiplex sandboxing](/remote/multiplex). -### Work responses {#work-responses} +### Work responses A `WorkResponse` contains a request id, a zero or nonzero exit code, and an output message describing any errors encountered in processing or executing @@ -116,7 +116,7 @@ response (except for cancel requests, see below). * Bazel stores requests as protobufs and converts them to JSON using [protobuf's JSON format](https://cs.opensource.google/protobuf/protobuf/+/master:java/util/src/main/java/com/google/protobuf/util/JsonFormat.java) -### Cancellation {#cancellation} +### Cancellation Workers can optionally allow work requests to be cancelled before they finish. This is particularly useful in connection with dynamic execution, where local @@ -144,7 +144,7 @@ Once a response has been sent for a `WorkRequest`, the worker must not touch the files in its working directory. The server is free to clean up the files, including temporary files. -## Making the rule that uses the worker {#rule-uses-worker} +## Making the rule that uses the worker You'll also need to create a rule that generates actions to be performed by the worker. Making a Starlark rule that uses a worker is just like @@ -186,7 +186,7 @@ level of the build, this might be the attribute definition: execution platform rather than on the target platform (i.e., the worker is used as tool during the build). -### Work action requirements {#work-action-requirements} +### Work action requirements The rule that uses the worker creates actions for the worker to perform. These actions have a couple of requirements. @@ -239,7 +239,7 @@ ctx.actions.run( For another example, see [Implementing persistent workers](/remote/persistent#implementation). -## Examples {#examples} +## Examples The Bazel code base uses [Java compiler workers](https://github.com/bazelbuild/bazel/blob/a4251eab6988d6cf4f5e35681fbe2c1b0abe48ef/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/BazelJavaBuilder.java), diff --git a/remote/dynamic.mdx b/remote/dynamic.mdx index c30afa0b..d2392166 100644 --- a/remote/dynamic.mdx +++ b/remote/dynamic.mdx @@ -12,9 +12,10 @@ alike. This page describes how to enable, tune, and debug dynamic execution. If you have both local and remote execution set up and are trying to adjust Bazel settings for better performance, this page is for you. If you don't already have -remote execution set up, go to the Bazel [Remote Execution Overview](/remote/rbe) first. +remote execution set up, go to the Bazel [Remote Execution +Overview](/remote/rbe) first. -## Enabling dynamic execution? {#enabling-dynamic-execution} +## Enabling dynamic execution? The dynamic execution module is part of Bazel, but to make use of dynamic execution, you must already be able to compile both locally and remotely from @@ -43,12 +44,14 @@ are likely. The default value is 1000ms, but should be tuned to being just a bit longer than cache hits usually take. The actual time depends both on the remote system and on how long a round-trip takes. Usually, the value will be the same for all users of a given remote system, unless some of them are far enough away -to add roundtrip latency. You can use the [Bazel profiling features](/rules/performance#performance-profiling) to look at how long typical +to add roundtrip latency. You can use the [Bazel profiling +features](/rules/performance#performance-profiling) to look at how long typical cache hits take. Dynamic execution can be used with local sandboxed strategy as well as with [persistent workers](/remote/persistent). Persistent workers will automatically -run with sandboxing when used with dynamic execution, and cannot use [multiplex workers](/remote/multiplex). On Darwin and Windows systems, the sandboxed +run with sandboxing when used with dynamic execution, and cannot use [multiplex +workers](/remote/multiplex). On Darwin and Windows systems, the sandboxed strategy can be slow; you can pass `--reuse_sandbox_directories` to reduce overhead of creating sandboxes on these systems. @@ -64,9 +67,10 @@ entire action fails. This is an intentional choice to prevent differences between local and remote execution from going unnoticed. For more background on how dynamic execution and its locking works, see Julio -Merino's excellent [blog posts](https://jmmv.dev/series/bazel-dynamic-execution/) +Merino's excellent [blog +posts](https://jmmv.dev/series/bazel-dynamic-execution/) -## When should I use dynamic execution? {#when-to-use} +## When should I use dynamic execution? Dynamic execution requires some form of [remote execution system](/remote/rbe). It is not currently possible to use a cache-only remote system, as a cache miss @@ -91,7 +95,7 @@ threads.

Profiling data with poor dynamic execution performance + src="/docs/images/dyn-trace-alldynamic.png">

In the profile above, which uses 8 Javac workers, we see many Javac workers @@ -101,7 +105,7 @@ delay the workers.

Profiling data with better dynamic execution performance + src="/docs/images/dyn-trace-javaconly.png">

When only Javac is run with dynamic execution, only about half of the started @@ -111,7 +115,7 @@ The previously recommended `--experimental_spawn_scheduler` flag is deprecated. It turns on dynamic execution and sets `dynamic` as the default strategy for all mnemonics, which would often lead to these kinds of problems. -## Performance {#performance} +## Performance The dynamic execution approach assumes there are enough resources available locally and remotely that it's worth spending some extra resources to improve @@ -159,7 +163,7 @@ The [JSON trace profile](/advanced/performance/json-trace-profile) contains a number of performance-related graphs that can help identify ways to improve the trade-off of performance and resource usage. -## Troubleshooting {#troubleshooting} +## Troubleshooting Problems with dynamic execution can be subtle and hard to debug, as they can manifest only under some specific combinations of local and remote execution. diff --git a/remote/multiplex.mdx b/remote/multiplex.mdx index fd5b472d..b4b0a0d4 100644 --- a/remote/multiplex.mdx +++ b/remote/multiplex.mdx @@ -18,7 +18,7 @@ languages like Java and Scala, this saves JVM warm-up time and JIT compilation time, and in general it allows using one shared cache between all workers of the same type. -## Overview {#overview} +## Overview There are two layers between the Bazel server and the worker process. For certain mnemonics that can run processes in parallel, Bazel gets a `WorkerProxy` from @@ -39,7 +39,7 @@ invocation, each unique mnemonic can only have one `WorkerMultiplexer` and one worker process. The total number of workers, including regular workers and `WorkerProxy`s, is still limited by `--worker_max_instances`. -## Writing multiplex-compatible rules {#multiplex-rules} +## Writing multiplex-compatible rules The rule's worker process should be multi-threaded to take advantage of multiplex workers. Protobuf allows a ruleset to parse a single request even @@ -50,7 +50,7 @@ the same time, the worker process needs to make sure the responses are written atomically (messages don't overlap). Responses must contain the `request_id` of the request they're handling. -### Handling multiplex output {#output} +### Handling multiplex output Multiplex workers need to be more careful about handling their output than singleplex workers. Anything sent to `stderr` will go into a single log file @@ -61,7 +61,7 @@ field of `WorkResponse`, as that could show the user mangled pieces of output. If your tool only sends user-oriented output to `stdout` or `stderr`, you will need to change that behaviour before you can enable multiplex workers. -## Enabling multiplex workers {#multiplex-workers} +## Enabling multiplex workers Multiplex workers are not enabled by default. A ruleset can turn on multiplex workers by using the `supports-multiplex-workers` tag in the diff --git a/remote/output-directories.mdx b/remote/output-directories.mdx index 36710825..f3af3a72 100644 --- a/remote/output-directories.mdx +++ b/remote/output-directories.mdx @@ -6,7 +6,7 @@ title: 'Output Directory Layout' This page covers requirements and layout for output directories. -## Requirements {#requirements} +## Requirements Requirements for an output directory layout: @@ -21,13 +21,13 @@ Requirements for an output directory layout: * All the build state per user should be underneath one directory ("I'd like to clean all the .o files from all my clients.") -## Current layout {#layout} +## Current layout The solution that's currently implemented: -* Bazel must be invoked from a directory containing a repository boundary file, - or a subdirectory thereof. In other words, Bazel must be invoked from inside a - [repository](/external/overview#repository). Otherwise, an error is +* Bazel must be invoked from a directory containing a repo boundary file, or a + subdirectory thereof. In other words, Bazel must be invoked from inside a + [repository](../external/overview#repository). Otherwise, an error is reported. * The _outputRoot_ directory defaults to ~/.cache/bazel on Linux, `~/Library/Caches/bazel` on macOS (when using Bazel 9 and newer), @@ -45,7 +45,7 @@ The solution that's currently implemented: it is an `installBase` directory whose name is the MD5 hash of the Bazel installation manifest. * Beneath the `outputUserRoot` directory, an `outputBase` directory - is also created whose name is the MD5 hash of the path of the workspace + is also created whose name is the MD5 hash of the path name of the workspace root. So, for example, if Bazel is running in the workspace root `/home/user/src/my-project` (or in a directory symlinked to that one), then an output base directory is created called: @@ -64,7 +64,7 @@ directories inside a target-specific directory inside the output directory. These symlinks are only for the user's convenience, as Bazel itself does not use them. Also, this is done only if the workspace root is writable. -## Layout diagram {#layout-diagram} +## Layout diagram The directories are laid out as follows: @@ -80,12 +80,9 @@ The directories are laid out as follows: outputUserRoot install/ fba9a2c87ee9589d72889caf082f1029/ <== Hash of the Bazel install manifest: installBase - A-server.jar <== The main Bazel server Java application, unpacked - from the data section of the bazel executable on first run. - linux-sandbox <== Sandboxing helper binary (platform-specific). - process-wrapper <== Process wrapper binary for action execution. - embedded_tools/ <== Contains the bundled JDK, build tool sources, - and other resources needed by the server. + _embedded_binaries/ <== Contains binaries and scripts unpacked from the data section of + the bazel executable on first run (such as helper scripts and the + main Java file BazelServer_deploy.jar) 7ffd56a6e4cb724ea575aba15733d113/ <== Hash of the client's workspace root (such as /home/user/src/my-project): outputBase action_cache/ <== Action cache directory hierarchy @@ -96,9 +93,8 @@ The directories are laid out as follows: recent bazel command. external/ <== The directory that remote repositories are downloaded/symlinked into. - server/ <== The Bazel server puts all server-related files here - (such as the server PID, the TCP command port, - request/response cookies, and JVM logs). + server/ <== The Bazel server puts all server-related files (such + as socket file, logs, etc) here. jvm.out <== The debugging output for the server. execroot/ <== The working directory for all actions. For special cases such as sandboxing and remote execution, the @@ -114,11 +110,8 @@ The directories are laid out as follows: _tmp/actions/ <== Action output directory. This contains a file with the stdout/stderr for every action from the most recent bazel run that produced output. - k8-fastbuild/ <== One subdirectory per unique target BuildConfiguration instance; - named by a mnemonic encoding the CPU and compilation mode - (such as k8-fastbuild, k8-opt, or k8-dbg). Configurations - with Starlark transitions append an ST-hash suffix - (such as k8-fastbuild-ST-abc123). + local_linux-fastbuild/ <== one subdirectory per unique target BuildConfiguration instance; + this is currently encoded bin/ <== Bazel outputs binaries for target configuration here: $(BINDIR) foo/bar/_objs/baz/ <== Object files for a cc_* rule named //foo/bar:baz foo/bar/baz1.o <== Object files from source //foo/bar:baz1.cc @@ -129,13 +122,16 @@ The directories are laid out as follows: MANIFEST _main/ ... + genfiles/ <== Bazel puts generated source for the target configuration here: + $(GENDIR) + foo/bar.h such as foo/bar.h might be a headerfile generated by //foo:bargen testlogs/ <== Bazel internal test runner puts test log files here foo/bartest.log such as foo/bar.log might be an output of the //foo:bartest test with foo/bartest.status foo/bartest.status containing exit status of the test (such as PASSED or FAILED (Exit 1), etc) - k8-opt-exec/ <== BuildConfiguration for the exec platform, used for - building prerequisite tools (such as the Protocol Compiler) - that will be used in later stages of the build. + host/ <== BuildConfiguration for build host (user's workstation), for + building prerequisite tools, that will be used in later stages + of the build (ex: Protocol Compiler) <packages>/ <== Packages referenced in the build appear as if under a regular workspace ``` @@ -143,7 +139,6 @@ The layout of the \*.runfiles directories is documented in more detail in the pl ## `bazel clean` -`bazel clean` clears the on-disk action cache and then removes the entire -`execroot` directory (which contains the symlink forest and all build -outputs). It also removes the convenience symlinks from the workspace -directory. The `--expunge` option will clean the entire outputBase. +`bazel clean` does an `rm -rf` on the `outputPath` and the `action_cache` +directory. It also removes the workspace symlinks. The `--expunge` option +will clean the entire outputBase. diff --git a/remote/persistent.mdx b/remote/persistent.mdx index c0e7f1da..8820950b 100644 --- a/remote/persistent.mdx +++ b/remote/persistent.mdx @@ -33,7 +33,7 @@ Programs using a NodeJS runtime can use the [@bazel/worker](https://www.npmjs.com/package/@bazel/worker) helper library to implement the worker protocol. -## Using persistent workers {#usage} +## Using persistent workers [Bazel 0.27 and higher](https://blog.bazel.build/2019/06/19/list-strategy.html) uses persistent workers by default when executing builds, though remote @@ -64,7 +64,7 @@ flag. This strategy automatically enables workers, so there is no need to specify the `worker` strategy, but you can still use `local` or `sandboxed` as fallbacks. -## Choosing number of workers {#number-of-workers} +## Choosing number of workers The default number of worker instances per mnemonic is 4, but can be adjusted with the @@ -112,7 +112,7 @@ discarded): The speed-up depends on the change being made. A speed-up of a factor 6 is measured in the above situation when a commonly used constant is changed. -## Modifying persistent workers {#options} +## Modifying persistent workers You can pass the [`--worker_extra_flag`](/reference/command-line-reference#flag--worker_extra_flag) @@ -150,7 +150,7 @@ log files for a given mnemonic. For Android builds, see details at the [Android Build Performance page](/docs/android-build-performance). -## Implementing persistent workers {#implementation} +## Implementing persistent workers See the [creating persistent workers](/remote/creating) page for more information on how to make a worker. @@ -232,7 +232,7 @@ and [nodejs worker example](https://github.com/bazelbuild/rules_nodejs/tree/stable/examples/worker) might be helpful. -## How do workers affect sandboxing? {#sandboxing} +## How do workers affect sandboxing? Using the `worker` strategy by default does not run the action in a [sandbox](/docs/sandboxing), similar to the `local` strategy. You can set the @@ -255,13 +255,14 @@ and this sandboxing must be separately enabled with the `--experimental_worker_multiplex_sandboxing` flag. See more details in [the design doc](https://docs.google.com/document/d/1ncLW0hz6uDhNvci1dpzfEoifwTiNTqiBEm1vi-bIIRM/edit)). -## Further reading {#further-reading} +## Further reading For more information on persistent workers, see: * [Original persistent workers blog post](https://blog.bazel.build/2015/12/10/java-workers.html) * [Haskell implementation description](https://www.tweag.io/blog/2019-09-25-bazel-ghc-persistent-worker-internship/) * [Blog post by Mike Morearty](https://medium.com/@mmorearty/how-to-create-a-persistent-worker-for-bazel-7738bba2cabb) -* [Front End Development with Bazel: Angular/TypeScript and Persistent Workers w/ Asana](https://www.youtube.com/watch?v=0pgERydGyqo) +* [Front End Development with Bazel: Angular/TypeScript and Persistent Workers + w/ Asana](https://www.youtube.com/watch?v=0pgERydGyqo) * [Bazel strategies explained](https://jmmv.dev/2019/12/bazel-strategies.html) * [Informative worker strategy discussion on the bazel-discuss mailing list](https://groups.google.com/forum/#!msg/bazel-discuss/oAEnuhYOPm8/ol7hf4KWJgAJ) diff --git a/remote/rbe.mdx b/remote/rbe.mdx index 8daffa5c..75d4a155 100644 --- a/remote/rbe.mdx +++ b/remote/rbe.mdx @@ -26,7 +26,7 @@ For a list of commercially supported remote execution services as well as self-service tools, see [Remote Execution Services](https://www.bazel.build/remote-execution-services.html) -## Requirements {#requirements} +## Requirements Remote execution of Bazel builds imposes a set of mandatory configuration constraints on the build. For more information, see diff --git a/remote/rules.mdx b/remote/rules.mdx index e5da6a8f..340ab02c 100644 --- a/remote/rules.mdx +++ b/remote/rules.mdx @@ -23,7 +23,7 @@ environment types or *platforms*: * **Execution platform** - where Bazel actions run. * **Target platform** - where the build outputs (and some actions) run. -## Overview {#overview} +## Overview When configuring a Bazel build for remote execution, you must follow the guidelines described in this page to ensure the build executes remotely @@ -44,7 +44,7 @@ following topics: * [Managing platform-dependent binaries](#manage-binaries) * [Managing configure-style WORKSPACE rules](#manage-workspace-rules) -## Invoking build tools through toolchain rules {#toolchain-rules} +## Invoking build tools through toolchain rules A Bazel toolchain rule is a configuration provider that tells a build rule what build tools, such as compilers and linkers, to use and how to configure them @@ -56,7 +56,8 @@ variables that may not be set to equivalent values (or at all) in the remote execution environment. Toolchain rules currently exist for Bazel build and test rules for -[Scala](https://github.com/bazelbuild/rules_scala/blob/master/scala/scala_toolch ain.bzl), +[Scala](https://github.com/bazelbuild/rules_scala/blob/master/scala/scala_toolch +ain.bzl), [Rust](https://github.com/bazelbuild/rules_rust/blob/main/rust/toolchain.bzl), and [Go](https://github.com/bazelbuild/rules_go/blob/master/go/toolchains.rst), and new toolchain rules are under way for other languages and tools such as @@ -64,7 +65,7 @@ and new toolchain rules are under way for other languages and tools such as If a toolchain rule does not exist for the tool your rule uses, consider [creating a toolchain rule](/extending/toolchains#creating-a-toolchain-rule). -## Managing implicit dependencies {#manage-dependencies} +## Managing implicit dependencies If a build tool can access dependencies across build actions, those actions will fail when remotely executed because each remote build action is executed @@ -88,7 +89,7 @@ execution. Use the sandbox to prepare your build for remote execution by identifying and resolving dependency-related build errors. See [Troubleshooting Bazel Remote Execution with Docker Sandbox](/remote/sandbox) for more information. -## Managing platform-dependent binaries {#manage-binaries} +## Managing platform-dependent binaries Typically, a binary built on the host platform cannot safely execute on an arbitrary remote execution platform due to potentially mismatched dependencies. @@ -108,7 +109,7 @@ one of the following: toolchain container) if it's stable enough and use toolchain rules to run it in your build. -## Managing configure-style WORKSPACE rules {#manage-workspace-rules} +## Managing configure-style WORKSPACE rules Bazel's `WORKSPACE` rules can be used for probing the host platform for tools and libraries required by the build, which, for local builds, is also Bazel's diff --git a/remote/sandbox.mdx b/remote/sandbox.mdx index de66ba6c..d230d691 100644 --- a/remote/sandbox.mdx +++ b/remote/sandbox.mdx @@ -46,7 +46,7 @@ You can troubleshoot these issues using one of the following methods: build even if portions of the build are failing. This method is experimental and not officially supported. -## Prerequisites {#prerequisites} +## Prerequisites Before you begin troubleshooting, do the following if you have not already done so: @@ -88,7 +88,7 @@ If your rules require additional tools, do the following: name of your custom container image. -## Troubleshooting natively {#troubleshooting-natively} +## Troubleshooting natively This method executes Bazel and all of its build actions directly on the local machine and is a reliable way to confirm whether your build will succeed when @@ -99,7 +99,7 @@ into into your build, especially if it uses [configure-style WORKSPACE rules](/r Such leaks will cause problems with remote execution; to detect them, [troubleshoot in a Docker container](#troubleshooting-docker-container) in addition to troubleshooting natively. -### Step 1: Run the build {#run-build} +### Step 1: Run the build 1. Add the `--config=docker-sandbox` flag to the Bazel command that executes your build. For example: @@ -123,7 +123,7 @@ faulty Docker installation or lack of permissions to execute it under the current user account. See the [Docker documentation](https://docs.docker.com/install/linux/linux-postinstall/) for more information. If problems persist, skip ahead to [Troubleshooting in a Docker container](#troubleshooting-docker-container). -### Step 2: Resolve detected issues {#resolve-common-issues} +### Step 2: Resolve detected issues The following are the most commonly encountered issues and their workarounds. @@ -153,7 +153,7 @@ The following are the most commonly encountered issues and their workarounds. * **Other errors.** Contact [bazel-discuss@google.com](mailto:bazel-discuss@google.com) for help. -## Troubleshooting in a Docker container {#troubleshooting-docker-container} +## Troubleshooting in a Docker container With this method, Bazel runs inside a host Docker container, and Bazel's build actions execute inside individual toolchain containers spawned by the Docker @@ -165,7 +165,7 @@ environment. By separating the execution of the build from the execution of its build actions and keeping the installed tooling to a minimum, you can verify whether your build has any dependencies on the local execution environment. -### Step 1: Build the container {#build-container} +### Step 1: Build the container Note: The commands below are tailored specifically for a `debian:stretch` base. For other bases, modify them as necessary. @@ -195,7 +195,7 @@ For other bases, modify them as necessary. docker build -t bazel_container - < Dockerfile ``` -### Step 2: Start the container {#start-container} +### Step 2: Start the container Start the Docker container using the command shown below. In the command, substitute the path to the source code on your host that you want to build. @@ -220,7 +220,7 @@ includes binaries incompatible with the `rbe-ubuntu16-04` container used as a toolchain container. If binaries from the local environment are leaking into the toolchain container, they will cause build errors. -### Step 3: Test the container {#test-container} +### Step 3: Test the container Run the following commands from inside the Docker container to test it: @@ -230,7 +230,7 @@ docker ps bazel version ``` -### Step 4: Run the build {#run-build-step} +### Step 4: Run the build Run the build as shown below. The output user is root so that it corresponds to a directory that is accessible with the same absolute path from inside the host @@ -242,7 +242,7 @@ machine on which the host and action containers run. bazel --output_user_root=/tmp/bazel_docker_root --bazelrc=.bazelrc \ build --config=docker-sandbox target ``` -### Step 5: Resolve detected issues {#resolve-build-failures} +### Step 5: Resolve detected issues You can resolve build failures as follows: diff --git a/remote/workspace.mdx b/remote/workspace.mdx index 4cba551c..3793fcc8 100644 --- a/remote/workspace.mdx +++ b/remote/workspace.mdx @@ -13,12 +13,13 @@ on the host machine. If your workspace rules access information about the host machine for use during execution, your build is likely to break due to incompatibilities between the environments. -As part of [adapting Bazel rules for remote execution](/remote/rules), you need to find such workspace rules +As part of [adapting Bazel rules for remote +execution](/remote/rules), you need to find such workspace rules and fix them. This page describes how to find potentially problematic workspace rules using the workspace log. -## Finding non-hermetic rules {#nonhermetic-rules} +## Finding non-hermetic rules [Repository rules](/external/repo) allow the developer to add dependencies to external workspaces, but they are rich enough to allow arbitrary processing to diff --git a/rules/bzl-style.mdx b/rules/bzl-style.mdx index 240c9f2e..65f589f4 100644 --- a/rules/bzl-style.mdx +++ b/rules/bzl-style.mdx @@ -39,15 +39,15 @@ developers and tools. The [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) principle doesn't really apply here. -## General advice {#general-advice} +## General advice * Use [Buildifier](https://github.com/bazelbuild/buildtools/tree/master/buildifier#linter) as a formatter and linter. * Follow [testing guidelines](/rules/testing). -## Style {#style} +## Style -### Python style {#python-style} +### Python style When in doubt, follow the [PEP 8 style guide](https://www.python.org/dev/peps/pep-0008/) where possible. @@ -61,18 +61,18 @@ comparisons to singletons be done with `is`, which is not an operator in Starlark. -### Docstring {#docstring} +### Docstring Document files and functions using [docstrings](https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#function-docstring). Use a docstring at the top of each `.bzl` file, and a docstring for each public function. -### Document rules and aspects {#doc-rules-aspects} +### Document rules and aspects Rules and aspects, along with their attributes, as well as providers and their fields, should be documented using the `doc` argument. -### Naming convention {#naming-convention} +### Naming convention * Variables and function names use lowercase with words separated by underscores (`[a-z][a-z0-9_]*`), such as `cc_library`. @@ -80,7 +80,7 @@ fields, should be documented using the `doc` argument. private values cannot be used from other files. Local variables should not use the underscore prefix. -### Line length {#line-length} +### Line length As in `BUILD` files, there is no strict line length limit as labels can be long. When possible, try to use at most 79 characters per line (following Python's @@ -89,7 +89,7 @@ should not be enforced strictly: editors should display more than 80 columns, automated changes will frequently introduce longer lines, and humans shouldn't spend time splitting lines that are already readable. -### Keyword arguments {#keyword-arguments} +### Keyword arguments In keyword arguments, spaces around the equal sign are preferred: @@ -103,12 +103,12 @@ def fct(name, srcs): ) ``` -### Boolean values {#boolean-values} +### Boolean values Prefer values `True` and `False` (rather than of `1` and `0`) for boolean values (such as when using a boolean attribute in a rule). -### Use print only for debugging {#print-for-debugging} +### Use print only for debugging Do not use the `print()` function in production code; it is only intended for debugging, and will spam all direct and indirect users of your `.bzl` file. The @@ -118,7 +118,7 @@ uses of `print()` are guarded by `if DEBUG:` where `DEBUG` is hardcoded to `False`. Be mindful of whether these statements are useful enough to justify their impact on readability. -## Macros {#macros} +## Macros A macro is a function which instantiates one or more rules during the loading phase. In general, use rules whenever possible instead of macros. The build @@ -171,7 +171,7 @@ As a rule of thumb, the more macros resemble the rules, the better. See also [macros](/extending/macros#conventions). -## Rules {#rules} +## Rules * Rules, aspects, and their attributes should use lower_case names ("snake case"). diff --git a/rules/challenges.mdx b/rules/challenges.mdx index 7169fbc9..10ff7371 100644 --- a/rules/challenges.mdx +++ b/rules/challenges.mdx @@ -7,7 +7,7 @@ title: 'Challenges of Writing Rules' This page gives a high-level overview of the specific issues and challenges of writing efficient Bazel rules. -## Summary Requirements {#summary-requirements} +## Summary Requirements * Assumption: Aim for Correctness, Throughput, Ease of Use & Latency * Assumption: Large Scale Repositories @@ -19,14 +19,14 @@ of writing efficient Bazel rules. requires Unusual Coding Patterns * Intrinsic: Avoiding Quadratic Time and Memory Consumption is Hard -## Assumptions {#assumptions} +## Assumptions Here are some assumptions made about the build system, such as need for correctness, ease of use, throughput, and large scale repositories. The following sections address these assumptions and offer guidelines to ensure rules are written in an effective manner. -### Aim for correctness, throughput, ease of use & latency {#aim} +### Aim for correctness, throughput, ease of use & latency We assume that the build system needs to be first and foremost correct with respect to incremental builds. For a given source tree, the output of the @@ -57,7 +57,7 @@ message that a `BUILD` file has a typo. Note that these goals often overlap; latency is as much a function of throughput of the remote execution service as is correctness relevant for ease of use. -### Large scale repositories {#large-repos} +### Large scale repositories The build system needs to operate at the scale of large repositories where large scale means that it does not fit on a single hard drive, so it is impossible to @@ -68,7 +68,7 @@ hundreds of thousands of globs. While it is theoretically possible to read all reasonable amount of time and memory. As such, it is critical that `BUILD` files can be loaded and parsed independently. -### BUILD-like description language {#language} +### BUILD-like description language In this context, we assume a configuration language that is roughly similar to `BUILD` files in declaration of library and binary rules @@ -76,12 +76,12 @@ and their interdependencies. `BUILD` files can be read and parsed independently, and we avoid even looking at source files whenever we can (except for existence). -## Historic {#historic} +## Historic There are differences between Bazel versions that cause challenges and some of these are outlined in the following sections. -### Hard separation between loading, analysis, and execution is outdated but still affects the API {#loading-outdated} +### Hard separation between loading, analysis, and execution is outdated but still affects the API Technically, it is sufficient for a rule to know the input and output files of an action just before the action is sent to remote execution. However, the @@ -102,12 +102,12 @@ output of an action; instead, it needs to generate a partial directed bipartite graph of build steps and output file names that is only determined from the rule itself and its dependencies. -## Intrinsic {#intrinsic} +## Intrinsic There are some intrinsic properties that make writing rules challenging and some of the most common ones are described in the following sections. -### Remote execution and caching are hard {#remote-execution} +### Remote execution and caching are hard Remote execution and caching improve build times in large repositories by roughly two orders of magnitude compared to running the build on a single @@ -123,7 +123,7 @@ the scheduler replies with the digests of the output files; the files itself are addressed by digest later on. However, this imposes restrictions on the Bazel rules, which need to declare all input files ahead of time. -### Using change information for correct and fast incremental builds requires unusual coding patterns {#coding-patterns} +### Using change information for correct and fast incremental builds requires unusual coding patterns Above, we argued that in order to be correct, Bazel needs to know all the input files that go into a build step in order to detect whether that build step is @@ -176,7 +176,7 @@ in the first place. The danger of accidental use of such APIs is just too big - several Bazel bugs in the past were caused by rules using unsafe APIs, even though the rules were written by the Bazel team or other domain experts. -### Avoiding quadratic time and memory consumption is hard {#avoid} +### Avoiding quadratic time and memory consumption is hard To make matters worse, apart from the requirements imposed by Skyframe, the historical constraints of using Java, and the outdatedness of the rules API, @@ -204,13 +204,13 @@ the Java runtime classpath, or the C++ linker command line. For example, it could expand the command line string representation of the C++ link action. N/2 copies of N/2 elements is O(N^2) memory. -#### Custom collections classes to avoid quadratic complexity {#custom-classes} +#### Custom collections classes to avoid quadratic complexity Bazel is heavily affected by both of these scenarios, so we introduced a set of custom collection classes that effectively compress the information in memory by avoiding the copy at each step. Almost all of these data structures have set semantics, so we called it -[depset](/rules/lib/builtins/depset) +[depset](/rules/lib/depset) (also known as `NestedSet` in the internal implementation). The majority of changes to reduce Bazel's memory consumption over the past several years were changes to use depsets instead of whatever was previously used. diff --git a/rules/faq.mdx b/rules/faq.mdx index d36139e9..5321f0b7 100644 --- a/rules/faq.mdx +++ b/rules/faq.mdx @@ -19,7 +19,7 @@ Bazel only executes the actions needed to produce the *requested* output files. * If you want the file to be built automatically whenever your target is mentioned on the command line, add it to your rule's default outputs by - returning a [`DefaultInfo`](/rules/lib/globals#DefaultInfo) provider. + returning a [`DefaultInfo`](lib/globals#DefaultInfo) provider. See the [Rules page](/extending/rules#requesting-output-files) for more information. @@ -37,24 +37,24 @@ correct path. For actions, you declare inputs by passing them to the `ctx.actions.*` function that creates the action. The proper path for the file can be obtained using -[`File.path`](/rules/lib/builtins/File#path). +[`File.path`](lib/File#path). For binaries (the executable outputs run by a `bazel run` or `bazel test` command), you declare inputs by including them in the [runfiles](/extending/rules#runfiles). Instead of using the `path` field, use -[`File.short_path`](/rules/lib/builtins/File#short_path), which is file's path relative to +[`File.short_path`](lib/File#short_path), which is file's path relative to the runfiles directory in which the binary executes. ## How can I control which files are built by `bazel build //pkg:mytarget`? -Use the [`DefaultInfo`](/rules/lib/globals#DefaultInfo) provider to +Use the [`DefaultInfo`](lib/globals#DefaultInfo) provider to [set the default outputs](/extending/rules#requesting-output-files). ## How can I run a program or do file I/O as part of my build? A tool can be declared as a target, just like any other part of your build, and run during the execution phase to help build other targets. To create an action -that runs a tool, use [`ctx.actions.run`](/rules/lib/builtins/actions#run) and pass in the +that runs a tool, use [`ctx.actions.run`](lib/actions#run) and pass in the tool as the `executable` parameter. During the loading and analysis phases, a tool *cannot* run, nor can you perform diff --git a/rules/index.mdx b/rules/index.mdx index a8d32eec..2a6c3eb7 100644 --- a/rules/index.mdx +++ b/rules/index.mdx @@ -10,7 +10,7 @@ languages and packages. Much of Bazel's strength comes from the ability to This page describes the recommended, native, and non-native Bazel rules. -## Recommended rules {#recommended-rules} +## Recommended rules Here is a selection of recommended rules: @@ -72,7 +72,7 @@ BUILD files without a `load` statement. - [`xcode_config`](/reference/be/objective-c#xcode_config) - [`xcode_version`](/reference/be/objective-c#xcode_version) -## Embedded non-native rules {#embedded-rules} +## Embedded non-native rules Bazel also embeds additional rules written in [Starlark](/rules/language). Those can be loaded from the `@bazel_tools` built-in external repository. diff --git a/rules/language.mdx b/rules/language.mdx index a29111d8..e6066cfa 100644 --- a/rules/language.mdx +++ b/rules/language.mdx @@ -36,16 +36,16 @@ Starlark's semantics can differ from Python, but behavioral differences are rare, except for cases where Starlark raises an error. The following Python types are supported: -* [None](/rules/lib/globals#None) -* [bool](/rules/lib/core/bool) -* [dict](/rules/lib/core/dict) -* [tuple](/rules/lib/core/tuple) -* [function](/rules/lib/core/function) -* [int](/rules/lib/core/int) -* [list](/rules/lib/core/list) -* [string](/rules/lib/core/string) +* [None](lib/globals#None) +* [bool](lib/bool) +* [dict](lib/dict) +* [tuple](lib/tuple) +* [function](lib/function) +* [int](lib/int) +* [list](lib/list) +* [string](lib/string) -## Type annotations {#StarlarkTypes} +## Type annotations **Experimental**. Type annotations are an experimental feature and may change at any time. Don't depend on it. It may be enabled in Bazel at HEAD @@ -62,7 +62,7 @@ with a syntax inspired by [PEP 484](https://peps.python.org/pep-0484/). ## Mutability Starlark favors immutability. Two mutable data structures are available: -[lists](/rules/lib/core/list) and [dicts](/rules/lib/core/dict). Changes to mutable +[lists](lib/list) and [dicts](lib/dict). Changes to mutable data-structures, such as appending a value to a list or deleting an entry in a dictionary are valid only for objects created in the current context. After a context finishes, its values become immutable. @@ -104,13 +104,15 @@ Global variables defined in `bzl` files cannot be changed outside of the `bzl` file that defined them. Just like the above example using `bzl` files, values returned by rules are immutable. -## Differences between BUILD and .bzl files {#differences-between-build-and-bzl-files} +## Differences between BUILD and .bzl files `BUILD` files register targets via making calls to rules. `.bzl` files provide definitions for constants, rules, macros, and functions. -[Native functions](/reference/be/functions) and [native rules](/reference/be/overview#language-specific-native-rules) are global symbols in -`BUILD` files. `bzl` files need to load them using the [`native` module](/rules/lib/toplevel/native). +[Native functions](/reference/be/functions) and [native rules]( +/reference/be/overview#language-specific-native-rules) are global symbols in +`BUILD` files. `bzl` files need to load them using the [`native` module]( +/rules/lib/toplevel/native). There are two syntactic restrictions in `BUILD` files: 1) declaring functions is illegal, and 2) `*args` and `**kwargs` arguments are not allowed. @@ -144,7 +146,7 @@ not defined across value types. In short: `5 < 'foo'` will throw an error and error: `{"a": 4, "b": 7, "a": 1}`. * Strings are represented with double-quotes (such as when you call - [repr](/rules/lib/globals#repr)). + [repr](lib/globals#repr)). * Strings aren't iterable. @@ -152,12 +154,12 @@ The following Python features are not supported: * implicit string concatenation (use explicit `+` operator). * Chained comparisons (such as `1 < x < 5`). -* `class` (see [`struct`](/rules/lib/builtins/struct#struct) function). +* `class` (see [`struct`](lib/struct#struct) function). * `import` (see [`load`](/extending/concepts#loading-an-extension) statement). * `while`, `yield`. * float and set types. * generators and generator expressions. * `is` (use `==` instead). -* `try`, `raise`, `except`, `finally` (see [`fail`](/rules/lib/globals#fail) for fatal errors). +* `try`, `raise`, `except`, `finally` (see [`fail`](lib/globals#fail) for fatal errors). * `global`, `nonlocal`. * most builtin functions, most methods. diff --git a/rules/legacy-macro-tutorial.mdx b/rules/legacy-macro-tutorial.mdx index 991c7809..28b0fca8 100644 --- a/rules/legacy-macro-tutorial.mdx +++ b/rules/legacy-macro-tutorial.mdx @@ -5,7 +5,9 @@ title: 'Creating a Legacy Macro' IMPORTANT: This tutorial is for [*legacy macros*](/extending/legacy-macros). If -you only need to support Bazel 8 or newer, we recommend using [symbolic macros](/extending/macros) instead; take a look at [Creating a Symbolic Macro](/rules/macro-tutorial). +you only need to support Bazel 8 or newer, we recommend using [symbolic +macros](/extending/macros) instead; take a look at [Creating a Symbolic +Macro](macro-tutorial). Imagine that you need to run a tool as part of your build. For example, you may want to generate or preprocess a source file, or compress a binary. In this diff --git a/rules/lib/builtins.mdx b/rules/lib/builtins.mdx index fb85bde3..fd86936c 100644 --- a/rules/lib/builtins.mdx +++ b/rules/lib/builtins.mdx @@ -6,12 +6,12 @@ This section lists types of Starlark objects. With some exceptions, these type n * [Action](/rules/lib/builtins/Action) * [actions](/rules/lib/builtins/actions) -* [apple_platform](/rules/lib/builtins/apple_platform) +* [apple\_platform](/rules/lib/builtins/apple_platform) * [Args](/rules/lib/builtins/Args) * [Aspect](/rules/lib/builtins/Aspect) * [Attribute](/rules/lib/builtins/Attribute) -* [bazel_module](/rules/lib/builtins/bazel_module) -* [bazel_module_tags](/rules/lib/builtins/bazel_module_tags) +* [bazel\_module](/rules/lib/builtins/bazel_module) +* [bazel\_module\_tags](/rules/lib/builtins/bazel_module_tags) * [BuildSetting](/rules/lib/builtins/BuildSetting) * [CcCompilationOutputs](/rules/lib/builtins/CcCompilationOutputs) * [CcLinkingOutputs](/rules/lib/builtins/CcLinkingOutputs) @@ -21,18 +21,17 @@ This section lists types of Starlark objects. With some exceptions, these type n * [depset](/rules/lib/builtins/depset) * [DirectoryExpander](/rules/lib/builtins/DirectoryExpander) * [DottedVersion](/rules/lib/builtins/DottedVersion) -* [exec_result](/rules/lib/builtins/exec_result) +* [exec\_result](/rules/lib/builtins/exec_result) * [ExecGroupCollection](/rules/lib/builtins/ExecGroupCollection) * [ExecGroupContext](/rules/lib/builtins/ExecGroupContext) * [ExecTransitionFactory](/rules/lib/builtins/ExecTransitionFactory) * [ExpandedDirectory](/rules/lib/builtins/ExpandedDirectory) -* [extension_metadata](/rules/lib/builtins/extension_metadata) +* [extension\_metadata](/rules/lib/builtins/extension_metadata) * [Facts](/rules/lib/builtins/Facts) * [FeatureConfiguration](/rules/lib/builtins/FeatureConfiguration) * [File](/rules/lib/builtins/File) * [fragments](/rules/lib/builtins/fragments) -* [java_annotation_processing](/rules/lib/builtins/java_annotation_processing) -* [java_output](/rules/lib/builtins/java_output) +* [java\_annotation\_processing](/rules/lib/builtins/java_annotation_processing) * [Label](/rules/lib/builtins/Label) * [LateBoundDefault](/rules/lib/builtins/LateBoundDefault) * [LibraryToLink](/rules/lib/builtins/LibraryToLink) @@ -40,29 +39,29 @@ This section lists types of Starlark objects. With some exceptions, these type n * [LinkerInput](/rules/lib/builtins/LinkerInput) * [LinkingContext](/rules/lib/builtins/LinkingContext) * [macro](/rules/lib/builtins/macro) -* [mapped_root](/rules/lib/builtins/mapped_root) -* [module_ctx](/rules/lib/builtins/module_ctx) +* [mapped\_root](/rules/lib/builtins/mapped_root) +* [module\_ctx](/rules/lib/builtins/module_ctx) * [path](/rules/lib/builtins/path) -* [propagation_ctx](/rules/lib/builtins/propagation_ctx) +* [propagation\_ctx](/rules/lib/builtins/propagation_ctx) * [Provider](/rules/lib/builtins/Provider) -* [repo_metadata](/rules/lib/builtins/repo_metadata) -* [repository_ctx](/rules/lib/builtins/repository_ctx) -* [repository_os](/rules/lib/builtins/repository_os) -* [repository_rule](/rules/lib/builtins/repository_rule) +* [repo\_metadata](/rules/lib/builtins/repo_metadata) +* [repository\_ctx](/rules/lib/builtins/repository_ctx) +* [repository\_os](/rules/lib/builtins/repository_os) +* [repository\_rule](/rules/lib/builtins/repository_rule) * [root](/rules/lib/builtins/root) * [rule](/rules/lib/builtins/rule) -* [rule_attributes](/rules/lib/builtins/rule_attributes) +* [rule\_attributes](/rules/lib/builtins/rule_attributes) * [runfiles](/rules/lib/builtins/runfiles) * [struct](/rules/lib/builtins/struct) * [Subrule](/rules/lib/builtins/Subrule) -* [subrule_ctx](/rules/lib/builtins/subrule_ctx) +* [subrule\_ctx](/rules/lib/builtins/subrule_ctx) * [SymlinkEntry](/rules/lib/builtins/SymlinkEntry) -* [tag_class](/rules/lib/builtins/tag_class) +* [tag\_class](/rules/lib/builtins/tag_class) * [Target](/rules/lib/builtins/Target) -* [template_ctx](/rules/lib/builtins/template_ctx) +* [template\_ctx](/rules/lib/builtins/template_ctx) * [TemplateDict](/rules/lib/builtins/TemplateDict) -* [toolchain_type](/rules/lib/builtins/toolchain_type) +* [toolchain\_type](/rules/lib/builtins/toolchain_type) * [ToolchainContext](/rules/lib/builtins/ToolchainContext) * [transition](/rules/lib/builtins/transition) -* [wasm_exec_result](/rules/lib/builtins/wasm_exec_result) -* [wasm_module](/rules/lib/builtins/wasm_module) \ No newline at end of file +* [wasm\_exec\_result](/rules/lib/builtins/wasm_exec_result) +* [wasm\_module](/rules/lib/builtins/wasm_module) \ No newline at end of file diff --git a/rules/lib/builtins/Action.mdx b/rules/lib/builtins/Action.mdx index 9ba2879b..a73471a9 100644 --- a/rules/lib/builtins/Action.mdx +++ b/rules/lib/builtins/Action.mdx @@ -36,7 +36,7 @@ May return `None`. sequence Action.argv ``` -For actions created by [ctx.actions.run()](../builtins/actions#run) or [ctx.actions.run_shell()](../builtins/actions#run_shell) an immutable list of the arguments for the command line to be executed. Note that for shell actions the first two arguments will be the shell path and `"-c"`. +For actions created by [ctx.actions.run()](../builtins/actions#run) or [ctx.actions.run\_shell()](../builtins/actions#run_shell) an immutable list of the arguments for the command line to be executed. Note that for shell actions the first two arguments will be the shell path and `"-c"`. May return `None`. ## content @@ -45,7 +45,7 @@ May return `None`. string Action.content ``` -For actions created by [ctx.actions.write()](../builtins/actions#write) or [ctx.actions.expand_template()](../builtins/actions#expand_template), the contents of the file to be written, if those contents can be computed during the analysis phase. The value is `None` if the contents cannot be determined until the execution phase, such as when a directory in an [Args](../builtins/Args) object needs to be expanded. +For actions created by [ctx.actions.write()](../builtins/actions#write) or [ctx.actions.expand\_template()](../builtins/actions#expand_template), the contents of the file to be written, if those contents can be computed during the analysis phase. The value is `None` if the contents cannot be determined until the execution phase, such as when a directory in an [Args](../builtins/Args) object needs to be expanded. May return `None`. ## env @@ -86,5 +86,5 @@ A set of the output files of this action. dict Action.substitutions ``` -For actions created by [ctx.actions.expand_template()](../builtins/actions#expand_template), an immutable dict holding the substitution mapping. +For actions created by [ctx.actions.expand\_template()](../builtins/actions#expand_template), an immutable dict holding the substitution mapping. May return `None`. \ No newline at end of file diff --git a/rules/lib/builtins/Args.mdx b/rules/lib/builtins/Args.mdx index 9410c3c0..b7011baa 100644 --- a/rules/lib/builtins/Args.mdx +++ b/rules/lib/builtins/Args.mdx @@ -45,10 +45,10 @@ ctx.actions.run( ## Members * [add](#add) -* [add_all](#add_all) -* [add_joined](#add_joined) -* [set_param_file_format](#set_param_file_format) -* [use_param_file](#use_param_file) +* [add\_all](#add_all) +* [add\_joined](#add_joined) +* [set\_param\_file\_format](#set_param_file_format) +* [use\_param\_file](#use_param_file) ## add @@ -66,7 +66,7 @@ Appends an argument to this command line. | `value` | default is `unbound` The object to append. It will be converted to a string using the standard conversion mentioned above. Since there is no `map_each` parameter for this function, `value` should be either a string or a `File`. A list, tuple, depset, or directory `File` must be passed to [`add_all()` or [`add_joined()`](#add_joined) instead of this method.](#add_all) | | `format` | [string](../core/string); or `None`; default is `None` A format string pattern, to be applied to the stringified version of `value`. | -## add_all +## add\_all ``` Args Args.add_all(arg_name_or_values, values=unbound, *, map_each=None, format_each=None, before_each=None, omit_if_empty=True, uniquify=False, expand_directories=True, terminate_with=None, allow_closure=False) @@ -96,7 +96,7 @@ Note that empty strings are valid arguments that are subject to all these proces | `terminate_with` | [string](../core/string); or `None`; default is `None` An optional argument to append after all other arguments. This argument will not be added if `omit_if_empty` is true (the default) and no other items are appended (as happens if `values` is empty or all of its items are filtered). | | `allow_closure` | [bool](../core/bool); default is `False` If true, allows the use of closures in function parameters like `map_each`. Usually this isn't necessary and it risks retaining large analysis-phase data structures into the execution phase. | -## add_joined +## add\_joined ``` Args Args.add_joined(arg_name_or_values, values=unbound, *, join_with, map_each=None, format_each=None, format_joined=None, omit_if_empty=True, uniquify=False, expand_directories=True, allow_closure=False) @@ -123,7 +123,7 @@ If after filtering there are no strings to join into an argument, and if `omit_i | `expand_directories` | [bool](../core/bool); default is `True` Same as for [`add_all`](#add_all.expand_directories). | | `allow_closure` | [bool](../core/bool); default is `False` Same as for [`add_all`](#add_all.allow_closure). | -## set_param_file_format +## set\_param\_file\_format ``` Args Args.set_param_file_format(format) @@ -135,9 +135,9 @@ Sets the format of the param file, if one is used | Parameter | Description | | --- | --- | -| `format` | [string](../core/string); required Must be one of: * "multiline": Each item (argument name or value) is written verbatim to the param file with a newline character following it. * "shell": Same as "multiline", but the items are shell-quoted * "flag_per_line": Same as "multiline", but (1) only flags (beginning with '--') are written to the param file, and (2) the values of the flags, if any, are written on the same line with a '=' separator. This is the format expected by the Abseil flags library. The format defaults to "shell" if not called. | +| `format` | [string](../core/string); required Must be one of: * "multiline": Each item (argument name or value) is written verbatim to the param file with a newline character following it. * "shell": Same as "multiline", but the items are shell-quoted * "flag\_per\_line": Same as "multiline", but (1) only flags (beginning with '--') are written to the param file, and (2) the values of the flags, if any, are written on the same line with a '=' separator. This is the format expected by the Abseil flags library. The format defaults to "shell" if not called. | -## use_param_file +## use\_param\_file ``` Args Args.use_param_file(param_file_arg, *, use_always=False) diff --git a/rules/lib/builtins/BuildSetting.mdx b/rules/lib/builtins/BuildSetting.mdx index 98bddb02..9198c823 100644 --- a/rules/lib/builtins/BuildSetting.mdx +++ b/rules/lib/builtins/BuildSetting.mdx @@ -2,4 +2,4 @@ title: 'BuildSetting' --- -The descriptor for a single piece of configuration information. If configuration is a key-value map of settings like {'cpu': 'ppc', 'copt': '-DFoo'}, this describes a single entry in that map. \ No newline at end of file +The descriptor for a single piece of configuration information. If configuration is a key-value map of settings like {'cpu': 'ppc', 'copt': '-DFoo'}, this describes a single entry in that map. \ No newline at end of file diff --git a/rules/lib/builtins/CcCompilationOutputs.mdx b/rules/lib/builtins/CcCompilationOutputs.mdx index 89a4df08..752e970d 100644 --- a/rules/lib/builtins/CcCompilationOutputs.mdx +++ b/rules/lib/builtins/CcCompilationOutputs.mdx @@ -7,7 +7,7 @@ Helper class containing CC compilation outputs. ## Members * [objects](#objects) -* [pic_objects](#pic_objects) +* [pic\_objects](#pic_objects) ## objects @@ -17,7 +17,7 @@ sequence CcCompilationOutputs.objects Non-PIC object files. -## pic_objects +## pic\_objects ``` sequence CcCompilationOutputs.pic_objects diff --git a/rules/lib/builtins/CcLinkingOutputs.mdx b/rules/lib/builtins/CcLinkingOutputs.mdx index 41fbd16c..3090803f 100644 --- a/rules/lib/builtins/CcLinkingOutputs.mdx +++ b/rules/lib/builtins/CcLinkingOutputs.mdx @@ -7,7 +7,7 @@ Helper class containing CC compilation outputs. ## Members * [executable](#executable) -* [library_to_link](#library_to_link) +* [library\_to\_link](#library_to_link) ## executable @@ -18,7 +18,7 @@ File CcLinkingOutputs.executable Represents the linked executable. May return `None`. -## library_to_link +## library\_to\_link ``` LibraryToLink CcLinkingOutputs.library_to_link diff --git a/rules/lib/builtins/CompilationContext.mdx b/rules/lib/builtins/CompilationContext.mdx index 4f7627f6..eb9b0323 100644 --- a/rules/lib/builtins/CompilationContext.mdx +++ b/rules/lib/builtins/CompilationContext.mdx @@ -7,18 +7,18 @@ Immutable store of information needed for C++ compilation that is aggregated acr ## Members * [defines](#defines) -* [direct_headers](#direct_headers) -* [direct_private_headers](#direct_private_headers) -* [direct_public_headers](#direct_public_headers) -* [direct_textual_headers](#direct_textual_headers) -* [external_includes](#external_includes) -* [framework_includes](#framework_includes) +* [direct\_headers](#direct_headers) +* [direct\_private\_headers](#direct_private_headers) +* [direct\_public\_headers](#direct_public_headers) +* [direct\_textual\_headers](#direct_textual_headers) +* [external\_includes](#external_includes) +* [framework\_includes](#framework_includes) * [headers](#headers) * [includes](#includes) -* [local_defines](#local_defines) -* [quote_includes](#quote_includes) -* [system_includes](#system_includes) -* [validation_artifacts](#validation_artifacts) +* [local\_defines](#local_defines) +* [quote\_includes](#quote_includes) +* [system\_includes](#system_includes) +* [validation\_artifacts](#validation_artifacts) ## defines @@ -28,7 +28,7 @@ depset CompilationContext.defines Returns the set of defines needed to compile this target. Each define is a string. These values are propagated to the target's transitive dependents, that is, any rules that depend on this target. -## direct_headers +## direct\_headers ``` list CompilationContext.direct_headers @@ -36,7 +36,7 @@ list CompilationContext.direct_headers Returns the list of modular headers that are declared by this target. This includes both public headers (such as those listed in "hdrs") and private headers (such as those listed in "srcs"). -## direct_private_headers +## direct\_private\_headers ``` list CompilationContext.direct_private_headers @@ -44,7 +44,7 @@ list CompilationContext.direct_private_headers Returns the list of modular private headers (those listed in "srcs") that are declared by this target. -## direct_public_headers +## direct\_public\_headers ``` list CompilationContext.direct_public_headers @@ -52,7 +52,7 @@ list CompilationContext.direct_public_headers Returns the list of modular public headers (those listed in "hdrs") that are declared by this target. -## direct_textual_headers +## direct\_textual\_headers ``` list CompilationContext.direct_textual_headers @@ -60,7 +60,7 @@ list CompilationContext.direct_textual_headers Returns the list of textual headers that are declared by this target. -## external_includes +## external\_includes ``` depset CompilationContext.external_includes @@ -68,7 +68,7 @@ depset CompilationContext.external_includes Returns the set of search paths (as strings) for external header files referenced by angle bracket. Usually passed with -isystem. -## framework_includes +## framework\_includes ``` depset CompilationContext.framework_includes @@ -92,7 +92,7 @@ depset CompilationContext.includes Returns the set of search paths (as strings) for header files referenced both by angle bracket and quotes. Usually passed with -I. -## local_defines +## local\_defines ``` depset CompilationContext.local_defines @@ -100,7 +100,7 @@ depset CompilationContext.local_defines Returns the set of defines needed to compile this target. Each define is a string. These values are not propagated to the target's transitive dependents. -## quote_includes +## quote\_includes ``` depset CompilationContext.quote_includes @@ -108,15 +108,15 @@ depset CompilationContext.quote_includes Returns the set of search paths (as strings) for header files referenced by quotes, e.g. #include "foo/bar/header.h". They can be either relative to the exec root or absolute. Usually passed with -iquote. -## system_includes +## system\_includes ``` depset CompilationContext.system_includes ``` -Returns the set of search paths (as strings) for header files referenced by angle brackets, e.g. #include <foo/bar/header.h>. They can be either relative to the exec root or absolute. Usually passed with -isystem. +Returns the set of search paths (as strings) for header files referenced by angle brackets, e.g. #include . They can be either relative to the exec root or absolute. Usually passed with -isystem. -## validation_artifacts +## validation\_artifacts ``` depset CompilationContext.validation_artifacts diff --git a/rules/lib/builtins/DottedVersion.mdx b/rules/lib/builtins/DottedVersion.mdx index bf0133ff..f17cea85 100644 --- a/rules/lib/builtins/DottedVersion.mdx +++ b/rules/lib/builtins/DottedVersion.mdx @@ -6,15 +6,15 @@ A value representing a version with multiple components, separated by periods, s ## Members -* [compare_to](#compare_to) +* [compare\_to](#compare_to) -## compare_to +## compare\_to ``` int DottedVersion.compare_to(other) ``` -Compares based on most significant (first) not-matching version component. So, for example, 1.2.3 < 1.2.4 +Compares based on most significant (first) not-matching version component. So, for example, 1.2.3 < 1.2.4 ### Parameters diff --git a/rules/lib/builtins/File.mdx b/rules/lib/builtins/File.mdx index b5821c92..5a46a3f2 100644 --- a/rules/lib/builtins/File.mdx +++ b/rules/lib/builtins/File.mdx @@ -11,14 +11,14 @@ When a `File` is passed to an [`Args`](../builtins/Args) object without using a * [basename](#basename) * [dirname](#dirname) * [extension](#extension) -* [is_directory](#is_directory) -* [is_source](#is_source) -* [is_symlink](#is_symlink) +* [is\_directory](#is_directory) +* [is\_source](#is_source) +* [is\_symlink](#is_symlink) * [owner](#owner) * [path](#path) * [root](#root) -* [short_path](#short_path) -* [tree_relative_path](#tree_relative_path) +* [short\_path](#short_path) +* [tree\_relative\_path](#tree_relative_path) ## basename @@ -44,15 +44,15 @@ string File.extension The file extension of this file, following (not including) the rightmost period. Empty string if the file's basename includes no periods. -## is_directory +## is\_directory ``` bool File.is_directory ``` -Returns true if this is a directory. This reflects the type the file was declared as (i.e. ctx.actions.declare_directory), not its type on the filesystem, which might differ. +Returns true if this is a directory. This reflects the type the file was declared as (i.e. ctx.actions.declare\_directory), not its type on the filesystem, which might differ. -## is_source +## is\_source ``` bool File.is_source @@ -60,13 +60,13 @@ bool File.is_source Returns true if this is a source file, i.e. it is not generated. -## is_symlink +## is\_symlink ``` bool File.is_symlink ``` -Returns true if this was declared as a symlink. This reflects the type the file was declared as (i.e. ctx.actions.declare_symlink), not its type on the filesystem, which might differ. +Returns true if this was declared as a symlink. This reflects the type the file was declared as (i.e. ctx.actions.declare\_symlink), not its type on the filesystem, which might differ. ## owner @@ -93,7 +93,7 @@ root File.root The root beneath which this file resides. -## short_path +## short\_path ``` string File.short_path @@ -101,10 +101,10 @@ string File.short_path The path of this file relative to its root. This excludes the aforementioned *root*, i.e. configuration-specific fragments of the path. This is also the path under which the file is mapped if it's in the runfiles of a binary. -## tree_relative_path +## tree\_relative\_path ``` string File.tree_relative_path ``` -The path of this file relative to the root of the ancestor's tree, if the ancestor's [is_directory](#is_directory) field is true. `tree_relative_path` is only available for expanded files of a directory in an action command, i.e. [Args.add_all()](../builtins/Args#add_all). For other types of files, it is an error to access this field. \ No newline at end of file +The path of this file relative to the root of the ancestor's tree, if the ancestor's [is\_directory](#is_directory) field is true. `tree_relative_path` is only available for expanded files of a directory in an action command, i.e. [Args.add\_all()](../builtins/Args#add_all). For other types of files, it is an error to access this field. \ No newline at end of file diff --git a/rules/lib/builtins/Label.mdx b/rules/lib/builtins/Label.mdx index d4dd4021..8e30c7cd 100644 --- a/rules/lib/builtins/Label.mdx +++ b/rules/lib/builtins/Label.mdx @@ -14,10 +14,10 @@ When passed as positional arguments to `print()` or `fail()`, `Label` use a stri * [name](#name) * [package](#package) * [relative](#relative) -* [repo_name](#repo_name) -* [same_package_label](#same_package_label) -* [workspace_name](#workspace_name) -* [workspace_root](#workspace_root) +* [repo\_name](#repo_name) +* [same\_package\_label](#same_package_label) +* [workspace\_name](#workspace_name) +* [workspace\_root](#workspace_root) ## Label @@ -91,7 +91,7 @@ Label("@repo//foo/bar:baz").relative("@other//wiz:quux") == Label("@remapped//wi | --- | --- | | `relName` | [string](../core/string); required | -## repo_name +## repo\_name ``` string Label.repo_name @@ -103,7 +103,7 @@ The canonical name of the repository containing the target referred to by this l Label("@@foo//bar:baz").repo_name == "foo" ``` -## same_package_label +## same\_package\_label ``` Label Label.same_package_label(target_name) @@ -117,7 +117,7 @@ Creates a label in the same package as this label with the given target name. | --- | --- | | `target_name` | [string](../core/string); required | -## workspace_name +## workspace\_name ``` string Label.workspace_name @@ -132,7 +132,7 @@ The canonical name of the repository containing the target referred to by this l Label("@@foo//bar:baz").workspace_name == "foo" ``` -## workspace_root +## workspace\_root ``` string Label.workspace_root diff --git a/rules/lib/builtins/LateBoundDefault.mdx b/rules/lib/builtins/LateBoundDefault.mdx index c418408b..edd0010c 100644 --- a/rules/lib/builtins/LateBoundDefault.mdx +++ b/rules/lib/builtins/LateBoundDefault.mdx @@ -4,4 +4,4 @@ title: 'LateBoundDefault' Represents a late-bound default attribute value of type 'Label'. The value of a LateBoundDefault is only resolvable in the context of a rule implementation function, and depends on the current build configuration. For example, a LateBoundDefault might represent the Label of the java toolchain in the current build configuration. -See [configuration_field](../globals/bzl#configuration_field) for example usage. \ No newline at end of file +See [configuration\_field](../globals/bzl#configuration_field) for example usage. \ No newline at end of file diff --git a/rules/lib/builtins/LibraryToLink.mdx b/rules/lib/builtins/LibraryToLink.mdx index 2037eacd..319d2745 100644 --- a/rules/lib/builtins/LibraryToLink.mdx +++ b/rules/lib/builtins/LibraryToLink.mdx @@ -7,16 +7,16 @@ A library the user can link against. ## Members * [alwayslink](#alwayslink) -* [dynamic_library](#dynamic_library) -* [interface_library](#interface_library) -* [lto_bitcode_files](#lto_bitcode_files) +* [dynamic\_library](#dynamic_library) +* [interface\_library](#interface_library) +* [lto\_bitcode\_files](#lto_bitcode_files) * [objects](#objects) -* [pic_lto_bitcode_files](#pic_lto_bitcode_files) -* [pic_objects](#pic_objects) -* [pic_static_library](#pic_static_library) -* [resolved_symlink_dynamic_library](#resolved_symlink_dynamic_library) -* [resolved_symlink_interface_library](#resolved_symlink_interface_library) -* [static_library](#static_library) +* [pic\_lto\_bitcode\_files](#pic_lto_bitcode_files) +* [pic\_objects](#pic_objects) +* [pic\_static\_library](#pic_static_library) +* [resolved\_symlink\_dynamic\_library](#resolved_symlink_dynamic_library) +* [resolved\_symlink\_interface\_library](#resolved_symlink_interface_library) +* [static\_library](#static_library) ## alwayslink @@ -24,9 +24,9 @@ A library the user can link against. bool LibraryToLink.alwayslink ``` -Whether to link the static library/objects in the --whole_archive block. +Whether to link the static library/objects in the --whole\_archive block. -## dynamic_library +## dynamic\_library ``` File LibraryToLink.dynamic_library @@ -35,7 +35,7 @@ File LibraryToLink.dynamic_library `Artifact` of dynamic library to be linked. Always used for runtime and used for linking if `interface_library` is not passed. May return `None`. -## interface_library +## interface\_library ``` File LibraryToLink.interface_library @@ -44,7 +44,7 @@ File LibraryToLink.interface_library `Artifact` of interface library to be linked. May return `None`. -## lto_bitcode_files +## lto\_bitcode\_files ``` sequence LibraryToLink.lto_bitcode_files @@ -62,7 +62,7 @@ sequence LibraryToLink.objects `List` of object files in the library. May return `None`. -## pic_lto_bitcode_files +## pic\_lto\_bitcode\_files ``` sequence LibraryToLink.pic_lto_bitcode_files @@ -71,7 +71,7 @@ sequence LibraryToLink.pic_lto_bitcode_files `List` of pic LTO bitcode files in the library. May return `None`. -## pic_objects +## pic\_objects ``` sequence LibraryToLink.pic_objects @@ -80,7 +80,7 @@ sequence LibraryToLink.pic_objects `List` of pic object files in the library. May return `None`. -## pic_static_library +## pic\_static\_library ``` File LibraryToLink.pic_static_library @@ -89,7 +89,7 @@ File LibraryToLink.pic_static_library `Artifact` of pic static library to be linked. May return `None`. -## resolved_symlink_dynamic_library +## resolved\_symlink\_dynamic\_library ``` File LibraryToLink.resolved_symlink_dynamic_library @@ -98,7 +98,7 @@ File LibraryToLink.resolved_symlink_dynamic_library The resolved `Artifact` of the dynamic library to be linked if `dynamic_library` is a symlink, otherwise this is None. May return `None`. -## resolved_symlink_interface_library +## resolved\_symlink\_interface\_library ``` File LibraryToLink.resolved_symlink_interface_library @@ -107,7 +107,7 @@ File LibraryToLink.resolved_symlink_interface_library The resolved `Artifact` of the interface library to be linked if `interface_library` is a symlink, otherwise this is None. May return `None`. -## static_library +## static\_library ``` File LibraryToLink.static_library diff --git a/rules/lib/builtins/LinkerInput.mdx b/rules/lib/builtins/LinkerInput.mdx index 8b3c59c5..41aa63a2 100644 --- a/rules/lib/builtins/LinkerInput.mdx +++ b/rules/lib/builtins/LinkerInput.mdx @@ -6,12 +6,12 @@ Either libraries, flags or other files that may be passed to the linker as input ## Members -* [additional_inputs](#additional_inputs) +* [additional\_inputs](#additional_inputs) * [libraries](#libraries) * [owner](#owner) -* [user_link_flags](#user_link_flags) +* [user\_link\_flags](#user_link_flags) -## additional_inputs +## additional\_inputs ``` sequence LinkerInput.additional_inputs @@ -35,7 +35,7 @@ Label LinkerInput.owner Returns the owner of this LinkerInput. -## user_link_flags +## user\_link\_flags ``` sequence LinkerInput.user_link_flags diff --git a/rules/lib/builtins/LinkingContext.mdx b/rules/lib/builtins/LinkingContext.mdx index 6db2286b..0ae74054 100644 --- a/rules/lib/builtins/LinkingContext.mdx +++ b/rules/lib/builtins/LinkingContext.mdx @@ -6,9 +6,9 @@ Immutable store of information needed for C++ linking that is aggregated across ## Members -* [linker_inputs](#linker_inputs) +* [linker\_inputs](#linker_inputs) -## linker_inputs +## linker\_inputs ``` depset LinkingContext.linker_inputs diff --git a/rules/lib/builtins/SymlinkEntry.mdx b/rules/lib/builtins/SymlinkEntry.mdx index ebfcda68..00e5464e 100644 --- a/rules/lib/builtins/SymlinkEntry.mdx +++ b/rules/lib/builtins/SymlinkEntry.mdx @@ -7,7 +7,7 @@ A single runfiles symlink represented by a link name and target. ## Members * [path](#path) -* [target_file](#target_file) +* [target\_file](#target_file) ## path @@ -17,7 +17,7 @@ string SymlinkEntry.path The path of the symlink in the runfiles tree -## target_file +## target\_file ``` File SymlinkEntry.target_file diff --git a/rules/lib/builtins/TemplateDict.mdx b/rules/lib/builtins/TemplateDict.mdx index 453f2e9d..5f18fd44 100644 --- a/rules/lib/builtins/TemplateDict.mdx +++ b/rules/lib/builtins/TemplateDict.mdx @@ -2,12 +2,12 @@ title: 'TemplateDict' --- -An Args-like structure for use in ctx.actions.expand_template(), which allows for deferring evaluation of values till the execution phase. +An Args-like structure for use in ctx.actions.expand\_template(), which allows for deferring evaluation of values till the execution phase. ## Members * [add](#add) -* [add_joined](#add_joined) +* [add\_joined](#add_joined) ## add @@ -24,7 +24,7 @@ Add a String value | `key` | [string](../core/string); required A String key | | `value` | [string](../core/string); required A String value | -## add_joined +## add\_joined ``` TemplateDict TemplateDict.add_joined(key, values, *, join_with, map_each, uniquify=False, format_joined=None, allow_closure=False) diff --git a/rules/lib/builtins/actions.mdx b/rules/lib/builtins/actions.mdx index 7a6910e6..374a9b1c 100644 --- a/rules/lib/builtins/actions.mdx +++ b/rules/lib/builtins/actions.mdx @@ -7,16 +7,16 @@ Module providing functions to create actions. Access this module using [`ctx.act ## Members * [args](#args) -* [declare_directory](#declare_directory) -* [declare_file](#declare_file) -* [declare_symlink](#declare_symlink) -* [do_nothing](#do_nothing) -* [expand_template](#expand_template) -* [map_directory](#map_directory) +* [declare\_directory](#declare_directory) +* [declare\_file](#declare_file) +* [declare\_symlink](#declare_symlink) +* [do\_nothing](#do_nothing) +* [expand\_template](#expand_template) +* [map\_directory](#map_directory) * [run](#run) -* [run_shell](#run_shell) +* [run\_shell](#run_shell) * [symlink](#symlink) -* [template_dict](#template_dict) +* [template\_dict](#template_dict) * [write](#write) ## args @@ -27,13 +27,13 @@ Args actions.args() Returns an Args object that can be used to build memory-efficient command lines. -## declare_directory +## declare\_directory ``` File actions.declare_directory(filename, *, sibling=None) ``` -Declares that the rule or aspect creates a directory with the given name, in the current package. You must create an action that generates the directory. The contents of the directory are not directly accessible from Starlark, but can be expanded in an action command with [`Args.add_all()`](../builtins/Args#add_all). Only regular files and directories can be in the expanded contents of a declare_directory. +Declares that the rule or aspect creates a directory with the given name, in the current package. You must create an action that generates the directory. The contents of the directory are not directly accessible from Starlark, but can be expanded in an action command with [`Args.add_all()`](../builtins/Args#add_all). Only regular files and directories can be in the expanded contents of a declare\_directory. ### Parameters @@ -42,7 +42,7 @@ Declares that the rule or aspect creates a directory with the given name, in the | `filename` | [string](../core/string); required If no 'sibling' provided, path of the new directory, relative to the current package. Otherwise a base name for a file ('sibling' defines a directory). | | `sibling` | [File](../builtins/File); or `None`; default is `None` A file that lives in the same directory as the newly declared directory. The file must be in the current package. | -## declare_file +## declare\_file ``` File actions.declare_file(filename, *, sibling=None) @@ -61,7 +61,7 @@ Note that [predeclared output files](https://bazel.build/extending/rules#files) | `filename` | [string](../core/string); required If no 'sibling' provided, path of the new file, relative to the current package. Otherwise a base name for a file ('sibling' determines a directory). | | `sibling` | [File](../builtins/File); or `None`; default is `None` A file that lives in the same directory as the newly created file. The file must be in the current package. | -## declare_symlink +## declare\_symlink ``` File actions.declare_symlink(filename, *, sibling=None) @@ -76,7 +76,7 @@ Declares that the rule or aspect creates a symlink with the given name in the cu | `filename` | [string](../core/string); required If no 'sibling' provided, path of the new symlink, relative to the current package. Otherwise a base name for a file ('sibling' defines a directory). | | `sibling` | [File](../builtins/File); or `None`; default is `None` A file that lives in the same directory as the newly declared symlink. | -## do_nothing +## do\_nothing ``` None actions.do_nothing(*, mnemonic, inputs=[]) @@ -91,7 +91,7 @@ Creates an empty action that neither executes a command nor produces any output, | `mnemonic` | [string](../core/string); required A one-word description of the action, for example, CppCompile or GoLink. | | `inputs` | [sequence](../core/list) of [File](../builtins/File)s; or [depset](../builtins/depset); default is `[]` List of the input files of the action. | -## expand_template +## expand\_template ``` None actions.expand_template(*, template, output, substitutions={}, is_executable=False, computed_substitutions=unbound) @@ -109,7 +109,7 @@ Creates a template expansion action. When the action is executed, it will genera | `is_executable` | [bool](../core/bool); default is `False` Whether the output file should be executable. | | `computed_substitutions` | [TemplateDict](../builtins/TemplateDict); default is `unbound` Substitutions to make when expanding the template. | -## map_directory +## map\_directory ``` None actions.map_directory(*, input_directories, additional_inputs={}, output_directories, tools, additional_params={}, execution_requirements=None, exec_group=None, toolchain=None, use_default_shell_env=False, env=None, mnemonic=None, implementation) @@ -160,10 +160,10 @@ Creates an action that runs an executable. [See example of use](https://github.c | `input_manifests` | [sequence](../core/list); or `None`; default is `None` Legacy argument. Ignored. | | `exec_group` | [string](../core/string); or `None`; default is `None` Runs the action on the given exec group's execution platform. If none, uses the target's default execution platform. | | `shadowed_action` | [Action](../builtins/Action); default is `None` Runs the action using the given shadowed action's inputs and environment added to the action's inputs list and environment. The action environment can overwrite any of the shadowed action's environment variables. If none, uses only the action's inputs and given environment. | -| `resource_set` | callable; or `None`; default is `None` A callback function that returns a resource set dictionary, used to estimate resource usage at execution time if this action is run locally. The function accepts two positional arguments: a string representing an OS name (e.g. "osx"), and an integer representing the number of inputs to the action. The returned dictionary may contain the following entries, each of which may be a float or an int: * "cpu": number of CPUs; default 1* "memory": in MB; default 250* "local_test": number of local tests; default 1 If this parameter is set to `None` , the default values are used. The callback must be top-level (lambda and nested functions aren't allowed). | -| `toolchain` | [Label](../builtins/Label); or [string](../core/string); or `None`; default is `unbound` Toolchain type of the executable or tools used in this action. If executable and tools are not coming from a toolchain, set this parameter to `None`. If executable and tools are coming from a toolchain, toolchain type must be set so that the action executes on the correct execution platform. Note that the rule which creates this action needs to define this toolchain inside its 'rule()' function. When `toolchain` and `exec_group` parameters are both set, `exec_group` will be used. An error is raised in case the `exec_group` doesn't specify the same toolchain. | +| `resource_set` | callable; or `None`; default is `None` A callback function that returns a resource set dictionary, used to estimate resource usage at execution time if this action is run locally. The function accepts two positional arguments: a string representing an OS name (e.g. "osx"), and an integer representing the number of inputs to the action. The returned dictionary may contain the following entries, each of which may be a float or an int: * "cpu": number of CPUs; default 1* "memory": in MB; default 250* "local\_test": number of local tests; default 1 If this parameter is set to `None` , the default values are used. The callback must be top-level (lambda and nested functions aren't allowed). | +| `toolchain` | [Label](../builtins/Label); or [string](../core/string); or `None`; default is `unbound` Toolchain type of the executable or tools used in this action. If executable and tools are not coming from a toolchain, set this parameter to `None`. If executable and tools are coming from a toolchain, toolchain type must be set so that the action executes on the correct execution platform. Note that the rule which creates this action needs to define this toolchain inside its 'rule()' function. When `toolchain` and `exec\_group` parameters are both set, `exec\_group` will be used. An error is raised in case the `exec\_group` doesn't specify the same toolchain. | -## run_shell +## run\_shell ``` None actions.run_shell(*, outputs, inputs=[], tools=unbound, arguments=[], mnemonic=None, command, progress_message=None, use_default_shell_env=False, env=None, execution_requirements=None, input_manifests=None, exec_group=None, shadowed_action=None, resource_set=None, toolchain=unbound) @@ -180,7 +180,7 @@ Creates an action that runs a shell command. [See example of use](https://github | `tools` | [sequence](../core/list) of [File](../builtins/File)s; or [depset](../builtins/depset); default is `unbound` List or [`depset`](../builtins/depset) of any tools needed by the action. Tools are executable inputs that may have their own runfiles which are automatically made available to the action. When a list is provided, it can be a heterogenous collection of: * `File`s * `FilesToRunProvider` instances * `depset`s of `File`s `File`s from [`ctx.executable`](../builtins/ctx#executable) and `FilesToRunProvider`s which are directly in the list will have their runfiles automatically added. All tools are implicitly added as inputs. | | `arguments` | [sequence](../core/list); default is `[]` Command line arguments of the action. Must be a list of strings or [`actions.args()`](#args) objects. Bazel passes the elements in this attribute as arguments to the command.The command can access these arguments using shell variable substitutions such as `$1`, `$2`, etc. Note that since Args objects are flattened before indexing, if there is an Args object of unknown size then all subsequent strings will be at unpredictable indices. It may be useful to use `$@` (to retrieve all arguments) in conjunction with Args objects of indeterminate size. In the case where `command` is a list of strings, this parameter may not be used. | | `mnemonic` | [string](../core/string); or `None`; default is `None` A one-word description of the action, for example, CppCompile or GoLink. | -| `command` | [string](../core/string); or [sequence](../core/list) of [string](../core/string)s; required Shell command to execute. This may either be a string (preferred) or a sequence of strings **(deprecated)**. If `command` is a string, then it is executed as if by `sh -c "" ` -- that is, the elements in `arguments` are made available to the command as `$1`, `$2` (or `%1`, `%2` if using Windows batch), etc. If `arguments` contains any [`actions.args()`](#args) objects, their contents are appended one by one to the command line, so `$`*i* can refer to individual strings within an Args object. Note that if an Args object of unknown size is passed as part of `arguments`, then the strings will be at unknown indices; in this case the `$@` shell substitution (retrieve all arguments) may be useful. **(Deprecated)** If `command` is a sequence of strings, the first item is the executable to run and the remaining items are its arguments. If this form is used, the `arguments` parameter must not be supplied. *Note that this form is deprecated and will soon be removed. It is disabled with `--incompatible_run_shell_command_string`. Use this flag to verify your code is compatible.* Bazel uses the same shell to execute the command as it does for genrules. | +| `command` | [string](../core/string); or [sequence](../core/list) of [string](../core/string)s; required Shell command to execute. This may either be a string (preferred) or a sequence of strings **(deprecated)**. If `command` is a string, then it is executed as if by `sh -c "" ` -- that is, the elements in `arguments` are made available to the command as `$1`, `$2` (or `%1`, `%2` if using Windows batch), etc. If `arguments` contains any [`actions.args()`](#args) objects, their contents are appended one by one to the command line, so `$`*i* can refer to individual strings within an Args object. Note that if an Args object of unknown size is passed as part of `arguments`, then the strings will be at unknown indices; in this case the `$@` shell substitution (retrieve all arguments) may be useful. **(Deprecated)** If `command` is a sequence of strings, the first item is the executable to run and the remaining items are its arguments. If this form is used, the `arguments` parameter must not be supplied. *Note that this form is deprecated and will soon be removed. It is disabled with `--incompatible\_run\_shell\_command\_string`. Use this flag to verify your code is compatible.* Bazel uses the same shell to execute the command as it does for genrules. | | `progress_message` | [string](../core/string); or `None`; default is `None` Progress message to show to the user during the build, for example, "Compiling foo.cc to create foo.o". The message may contain `%{label}`, `%{input}`, or `%{output}` patterns, which are substituted with label string, first input, or output's path, respectively. Prefer to use patterns instead of static strings, because the former are more efficient. | | `use_default_shell_env` | [bool](../core/bool); default is `False` Whether the action should use the default shell environment, which consists of a few OS-dependent variables as well as variables set via [`--action_env`](/reference/command-line-reference#flag--action_env). If both `use_default_shell_env` and `env` are set to `True`, values set in `env` will overwrite the default shell environment. | | `env` | [dict](../core/dict); or `None`; default is `None` Sets the dictionary of environment variables. If both `use_default_shell_env` and `env` are set to `True`, values set in `env` will overwrite the default shell environment. | @@ -189,7 +189,7 @@ Creates an action that runs a shell command. [See example of use](https://github | `exec_group` | [string](../core/string); or `None`; default is `None` Runs the action on the given exec group's execution platform. If none, uses the target's default execution platform. | | `shadowed_action` | [Action](../builtins/Action); default is `None` Runs the action using the given shadowed action's discovered inputs added to the action's inputs list. If none, uses only the action's inputs. | | `resource_set` | callable; or `None`; default is `None` A callback function for estimating resource usage if run locally. See[`ctx.actions.run()`](#run.resource_set). | -| `toolchain` | [Label](../builtins/Label); or [string](../core/string); or `None`; default is `unbound` Toolchain type of the executable or tools used in this action. If executable and tools are not coming from a toolchain, set this parameter to `None`. If executable and tools are coming from a toolchain, toolchain type must be set so that the action executes on the correct execution platform. Note that the rule which creates this action needs to define this toolchain inside its 'rule()' function. When `toolchain` and `exec_group` parameters are both set, `exec_group` will be used. An error is raised in case the `exec_group` doesn't specify the same toolchain. | +| `toolchain` | [Label](../builtins/Label); or [string](../core/string); or `None`; default is `unbound` Toolchain type of the executable or tools used in this action. If executable and tools are not coming from a toolchain, set this parameter to `None`. If executable and tools are coming from a toolchain, toolchain type must be set so that the action executes on the correct execution platform. Note that the rule which creates this action needs to define this toolchain inside its 'rule()' function. When `toolchain` and `exec\_group` parameters are both set, `exec\_group` will be used. An error is raised in case the `exec\_group` doesn't specify the same toolchain. | ## symlink @@ -216,7 +216,7 @@ Otherwise, when you use `target_path`, declare `output` with [`declare_symlink() | `is_executable` | [bool](../core/bool); default is `False` May only be used with `target_file`, not `target_path`. If true, when the action is executed, the `target_file`'s path is checked to confirm that it is executable, and an error is reported if it is not. Setting `is_executable` to False does not mean the target is not executable, just that no verification is done. This feature does not make sense for `target_path` because dangling symlinks might not exist at build time. | | `progress_message` | [string](../core/string); or `None`; default is `None` Progress message to show to the user during the build. | -## template_dict +## template\_dict ``` TemplateDict actions.template_dict() diff --git a/rules/lib/builtins/apple_platform.mdx b/rules/lib/builtins/apple_platform.mdx index 59225ef9..ba2fc42e 100644 --- a/rules/lib/builtins/apple_platform.mdx +++ b/rules/lib/builtins/apple_platform.mdx @@ -1,10 +1,10 @@ --- -title: 'apple_platform' +title: 'apple\_platform' --- Corresponds to Xcode's notion of a platform as would be found in `Xcode.app/Contents/Developer/Platforms`. Each platform represents an Apple platform type (such as iOS or tvOS) combined with one or more related CPU architectures. For example, the iOS simulator platform supports `x86_64` and `i386` architectures. -Specific instances of this type can be retrieved from the fields of the [apple_common.platform](../toplevel/apple_common#platform) struct: +Specific instances of this type can be retrieved from the fields of the [apple\_common.platform](../toplevel/apple_common#platform) struct: * `apple_common.platform.ios_device` * `apple_common.platform.ios_simulator` @@ -25,12 +25,12 @@ print(p.name_in_plist) # 'iPhoneOS' ## Members -* [is_device](#is_device) +* [is\_device](#is_device) * [name](#name) -* [name_in_plist](#name_in_plist) -* [platform_type](#platform_type) +* [name\_in\_plist](#name_in_plist) +* [platform\_type](#platform_type) -## is_device +## is\_device ``` bool apple_platform.is_device @@ -46,7 +46,7 @@ string apple_platform.name Returns the name aka starlarkKey of this platform. -## name_in_plist +## name\_in\_plist ``` string apple_platform.name_in_plist @@ -55,7 +55,7 @@ string apple_platform.name_in_plist The name of the platform as it appears in the `CFBundleSupportedPlatforms` entry of an Info.plist file and in Xcode's platforms directory, without the extension (for example, `iPhoneOS` or `iPhoneSimulator`). This name, when converted to lowercase (e.g., `iphoneos`, `iphonesimulator`), can be passed to Xcode's command-line tools like `ibtool` and `actool` when they expect a platform name. -## platform_type +## platform\_type ``` string apple_platform.platform_type diff --git a/rules/lib/builtins/bazel_module.mdx b/rules/lib/builtins/bazel_module.mdx index 42214092..9e1db64d 100644 --- a/rules/lib/builtins/bazel_module.mdx +++ b/rules/lib/builtins/bazel_module.mdx @@ -1,17 +1,17 @@ --- -title: 'bazel_module' +title: 'bazel\_module' --- Represents a Bazel module in the external dependency graph. ## Members -* [is_root](#is_root) +* [is\_root](#is_root) * [name](#name) * [tags](#tags) * [version](#version) -## is_root +## is\_root ``` bool bazel_module.is_root diff --git a/rules/lib/builtins/bazel_module_tags.mdx b/rules/lib/builtins/bazel_module_tags.mdx index 4d62639c..dcb92a6f 100644 --- a/rules/lib/builtins/bazel_module_tags.mdx +++ b/rules/lib/builtins/bazel_module_tags.mdx @@ -1,7 +1,6 @@ --- -title: 'bazel_module_tags' +title: 'bazel\_module\_tags' --- Contains the tags in a module for the module extension currently being processed. This object has a field for each tag class of the extension, and the value of the field is a list containing an object for each tag instance. This "tag instance" object in turn has a field for each attribute of the tag class. - When passed as positional arguments to `print()` or `fail()`, tag instance objects turn into a meaningful string representation of the form "'install' tag at /home/user/workspace/MODULE.bazel:3:4". This can be used to construct error messages that point to the location of the tag in the module file, e.g. `fail("Conflict between", tag1, "and", tag2)`. \ No newline at end of file diff --git a/rules/lib/builtins/configuration.mdx b/rules/lib/builtins/configuration.mdx index 2730ca70..4cfae100 100644 --- a/rules/lib/builtins/configuration.mdx +++ b/rules/lib/builtins/configuration.mdx @@ -6,14 +6,13 @@ This object holds information about the environment in which the build is runnin ## Members -* [coverage_enabled](#coverage_enabled) -* [default_shell_env](#default_shell_env) -* [host_path_separator](#host_path_separator) -* [is_tool_configuration](#is_tool_configuration) -* [short_id](#short_id) -* [test_env](#test_env) +* [coverage\_enabled](#coverage_enabled) +* [default\_shell\_env](#default_shell_env) +* [host\_path\_separator](#host_path_separator) +* [short\_id](#short_id) +* [test\_env](#test_env) -## coverage_enabled +## coverage\_enabled ``` bool configuration.coverage_enabled @@ -21,7 +20,7 @@ bool configuration.coverage_enabled A boolean that tells whether code coverage is enabled for this run. Note that this does not compute whether a specific rule should be instrumented for code coverage data collection. For that, see the [`ctx.coverage_instrumented`](../builtins/ctx#coverage_instrumented) function. -## default_shell_env +## default\_shell\_env ``` dict configuration.default_shell_env @@ -29,7 +28,7 @@ dict configuration.default_shell_env A dictionary representing the static local shell environment. It maps variables to their values (strings). -## host_path_separator +## host\_path\_separator ``` string configuration.host_path_separator @@ -37,15 +36,7 @@ string configuration.host_path_separator Returns the separator for PATH environment variable, which is ':' on Unix. -## is_tool_configuration - -``` -bool configuration.is_tool_configuration() -``` - -Returns true when building in the tool (exec) configuration. - -## short_id +## short\_id ``` string configuration.short_id @@ -57,7 +48,7 @@ Use this to distinguish different configurations for the same target in a way th * The value may differ across Bazel versions, including patch releases.* The value encodes the value of **every** flag, including those that aren't otherwise relevant for the current target and may thus invalidate caches more frequently. -## test_env +## test\_env ``` dict configuration.test_env diff --git a/rules/lib/builtins/ctx.mdx b/rules/lib/builtins/ctx.mdx index b8751f4a..192d89c9 100644 --- a/rules/lib/builtins/ctx.mdx +++ b/rules/lib/builtins/ctx.mdx @@ -11,39 +11,39 @@ Context objects essentially live for the duration of the call to the implementat ## Members * [actions](#actions) -* [aspect_ids](#aspect_ids) +* [aspect\_ids](#aspect_ids) * [attr](#attr) -* [bin_dir](#bin_dir) -* [build_file_path](#build_file_path) -* [build_setting_value](#build_setting_value) +* [bin\_dir](#bin_dir) +* [build\_file\_path](#build_file_path) +* [build\_setting\_value](#build_setting_value) * [configuration](#configuration) -* [coverage_instrumented](#coverage_instrumented) -* [created_actions](#created_actions) -* [disabled_features](#disabled_features) -* [exec_groups](#exec_groups) +* [coverage\_instrumented](#coverage_instrumented) +* [created\_actions](#created_actions) +* [disabled\_features](#disabled_features) +* [exec\_groups](#exec_groups) * [executable](#executable) -* [expand_location](#expand_location) -* [expand_make_variables](#expand_make_variables) +* [expand\_location](#expand_location) +* [expand\_make\_variables](#expand_make_variables) * [features](#features) * [file](#file) * [files](#files) * [fragments](#fragments) -* [genfiles_dir](#genfiles_dir) -* [info_file](#info_file) +* [genfiles\_dir](#genfiles_dir) +* [info\_file](#info_file) * [label](#label) * [outputs](#outputs) -* [package_relative_label](#package_relative_label) -* [resolve_command](#resolve_command) -* [resolve_tools](#resolve_tools) +* [package\_relative\_label](#package_relative_label) +* [resolve\_command](#resolve_command) +* [resolve\_tools](#resolve_tools) * [rule](#rule) * [runfiles](#runfiles) -* [split_attr](#split_attr) +* [split\_attr](#split_attr) * [super](#super) -* [target_platform_has_constraint](#target_platform_has_constraint) +* [target\_platform\_has\_constraint](#target_platform_has_constraint) * [toolchains](#toolchains) * [var](#var) -* [version_file](#version_file) -* [workspace_name](#workspace_name) +* [version\_file](#version_file) +* [workspace\_name](#workspace_name) ## actions @@ -53,7 +53,7 @@ actions ctx.actions Contains methods for declaring output files and the actions that produce them. -## aspect_ids +## aspect\_ids ``` list ctx.aspect_ids @@ -69,7 +69,7 @@ struct ctx.attr A struct to access the values of the [attributes](https://bazel.build/extending/rules#attributes). The values are provided by the user (if not, a default value is used). The attributes of the struct and the types of their values correspond to the keys and values of the [`attrs` dict](../globals/bzl#rule.attrs) provided to the [`rule` function](../globals/bzl#rule). [See example of use](https://github.com/bazelbuild/examples/blob/main/rules/attributes/printer.bzl). -## bin_dir +## bin\_dir ``` root ctx.bin_dir @@ -77,7 +77,7 @@ root ctx.bin_dir The root corresponding to bin directory. -## build_file_path +## build\_file\_path ``` string ctx.build_file_path @@ -85,7 +85,7 @@ string ctx.build_file_path Deprecated: Use `ctx.label.package + '/BUILD'`. The path to the BUILD file for this rule, relative to the source root. -## build_setting_value +## build\_setting\_value ``` unknown ctx.build_setting_value @@ -101,13 +101,13 @@ configuration ctx.configuration The current target's build configuration. See the [Starlark configuration type](../builtins/configuration) and [configuration documentation](/extending/rules#configurations) for more details. -## coverage_instrumented +## coverage\_instrumented ``` bool ctx.coverage_instrumented(target=None) ``` -Returns whether code coverage instrumentation should be generated when performing compilation actions for this rule or, if `target` is provided, the rule specified by that Target. (If a non-rule or a Starlark rule Target is provided, this returns False.) Checks if the sources of the current rule (if no Target is provided) or the sources of Target should be instrumented based on the --instrumentation_filter and --instrument_test_targets config settings. This differs from `coverage_enabled` in the [configuration](../builtins/configuration), which notes whether coverage data collection is enabled for the entire run, but not whether a specific target should be instrumented. +Returns whether code coverage instrumentation should be generated when performing compilation actions for this rule or, if `target` is provided, the rule specified by that Target. (If a non-rule or a Starlark rule Target is provided, this returns False.) Checks if the sources of the current rule (if no Target is provided) or the sources of Target should be instrumented based on the --instrumentation\_filter and --instrument\_test\_targets config settings. This differs from `coverage_enabled` in the [configuration](../builtins/configuration), which notes whether coverage data collection is enabled for the entire run, but not whether a specific target should be instrumented. ### Parameters @@ -115,17 +115,17 @@ Returns whether code coverage instrumentation should be generated when performin | --- | --- | | `target` | [Target](../builtins/Target); or `None`; default is `None` A Target specifying a rule. If not provided, defaults to the current rule. | -## created_actions +## created\_actions ``` StarlarkValue ctx.created_actions() ``` -For rules with [\_skylark_testable](../globals/bzl#rule._skylark_testable) set to `True`, this returns an `Actions` provider representing all actions created so far for the current rule. For all other rules, returns `None`. Note that the provider is not updated when subsequent actions are created, so you will have to call this function again if you wish to inspect them. +For rules with [\_skylark\_testable](../globals/bzl#rule._skylark_testable) set to `True`, this returns an `Actions` provider representing all actions created so far for the current rule. For all other rules, returns `None`. Note that the provider is not updated when subsequent actions are created, so you will have to call this function again if you wish to inspect them. This is intended to help write tests for rule-implementation helper functions, which may take in a `ctx` object and create actions on it. -## disabled_features +## disabled\_features ``` list ctx.disabled_features @@ -133,7 +133,7 @@ list ctx.disabled_features The set of features that are explicitly disabled by the user for this rule. -## exec_groups +## exec\_groups ``` ExecGroupCollection ctx.exec_groups @@ -149,7 +149,7 @@ struct ctx.executable A `struct` containing executable files defined in [label type attributes](../toplevel/attr#label) marked as [`executable=True`](../toplevel/attr#label.executable). The struct fields correspond to the attribute names. Each value in the struct is either a [`File`](../builtins/File) or `None`. If an optional attribute is not specified in the rule then the corresponding struct value is `None`. If a label type is not marked as `executable=True`, no corresponding struct field is generated. [See example of use](https://github.com/bazelbuild/examples/blob/main/rules/actions_run/execute.bzl). -## expand_location +## expand\_location ``` string ctx.expand_location(input, targets=[]) @@ -170,7 +170,7 @@ This function is useful to let the user specify a command in a BUILD file (like May return `None`. -## expand_make_variables +## expand\_make\_variables ``` string ctx.expand_make_variables(attribute_name, command, additional_substitutions) @@ -238,7 +238,7 @@ fragments ctx.fragments Allows access to configuration fragments in target configuration. -## genfiles_dir +## genfiles\_dir ``` root ctx.genfiles_dir @@ -246,13 +246,13 @@ root ctx.genfiles_dir The root corresponding to genfiles directory. -## info_file +## info\_file ``` File ctx.info_file ``` -The file that is used to hold the non-volatile workspace status for the current build request. See documentation for --workspace_status_command for more information. +The file that is used to hold the non-volatile workspace status for the current build request. See documentation for --workspace\_status\_command for more information. ## label @@ -276,7 +276,7 @@ The fields of this object are defined as follows. It is an error if two outputs * If the rule declares an [`outputs`](../globals/bzl#rule.outputs) dict, then for every entry in the dict, there is a field whose name is the key and whose value is the corresponding `File`.* For every attribute of type [`attr.output`](../toplevel/attr#output) that the rule declares, there is a field whose name is the attribute's name. If the target specified a label for that attribute, then the field value is the corresponding `File`; otherwise the field value is `None`.* For every attribute of type [`attr.output_list`](../toplevel/attr#output_list) that the rule declares, there is a field whose name is the attribute's name. The field value is a list of `File` objects corresponding to the labels given for that attribute in the target, or an empty list if the attribute was not specified in the target.* **(Deprecated)** If the rule is marked [`executable`](../globals/bzl#rule.executable) or [`test`](../globals/bzl#rule.test), there is a field named `"executable"`, which is the default executable. It is recommended that instead of using this, you pass another file (either predeclared or not) to the `executable` arg of [`DefaultInfo`](../providers/DefaultInfo). -## package_relative_label +## package\_relative\_label ``` Label ctx.package_relative_label(input) @@ -284,9 +284,8 @@ Label ctx.package_relative_label(input) Converts the input string into a [Label](../builtins/Label) object, in the context of the package of the target currently being analyzed. If the input is already a `Label`, it is returned unchanged. -The result of this function is the same `Label` value as would be produced by passing the given string to a label-valued attribute of the rule and accessing the corresponding [`label`](../builtins/Target#label) field. - -*Usage note:* The difference between this function and [Label()](../builtins/Label#Label) is that `Label()` uses the context of the package of the `.bzl` file that called it, not the package of the target currently being analyzed. This function has the same behavior as [`native.package_relative_label()`](../toplevel/native#package_relative_label), which cannot be used in a rule or +The result of this function is the same `Label` value as would be produced by passing the given string to a label-valued attribute of the rule and accessing the corresponding [Label()](../builtins/Target#label>label field. +

Usage note: The difference between this function and /_main/`, **not** the directory corresponding to the current target's repository. See [Runfiles symlinks](https://bazel.build/extending/rules#runfiles_symlinks) in the rules guide. | | `root_symlinks` | [dict](../core/dict); or [depset](../builtins/depset) of [SymlinkEntry](../builtins/SymlinkEntry)s; default is `{}` Either a SymlinkEntry depset or a map of symlinks to be added to the runfiles. See [Runfiles symlinks](https://bazel.build/extending/rules#runfiles_symlinks) in the rules guide. | -## split_attr +## split\_attr ``` struct ctx.split_attr ``` -A struct to access the values of attributes with split configurations. If the attribute is a label list, the value of split_attr is a dict of the keys of the split (as strings) to lists of the ConfiguredTargets in that branch of the split. If the attribute is a label, then the value of split_attr is a dict of the keys of the split (as strings) to single ConfiguredTargets. Attributes with split configurations still appear in the attr struct, but their values will be single lists with all the branches of the split merged together. +A struct to access the values of attributes with split configurations. If the attribute is a label list, the value of split\_attr is a dict of the keys of the split (as strings) to lists of the ConfiguredTargets in that branch of the split. If the attribute is a label, then the value of split\_attr is a dict of the keys of the split (as strings) to single ConfiguredTargets. Attributes with split configurations still appear in the attr struct, but their values will be single lists with all the branches of the split merged together. ## super @@ -375,7 +374,7 @@ unknown ctx.super() Experimental: Calls parent's implementation function and returns its providers -## target_platform_has_constraint +## target\_platform\_has\_constraint ``` bool ctx.target_platform_has_constraint(constraintValue) @@ -405,15 +404,15 @@ dict ctx.var Dictionary (String to String) of configuration variables. -## version_file +## version\_file ``` File ctx.version_file ``` -The file that is used to hold the volatile workspace status for the current build request. See documentation for --workspace_status_command for more information. +The file that is used to hold the volatile workspace status for the current build request. See documentation for --workspace\_status\_command for more information. -## workspace_name +## workspace\_name ``` string ctx.workspace_name diff --git a/rules/lib/builtins/depset.mdx b/rules/lib/builtins/depset.mdx index a9b2adeb..7baf77d3 100644 --- a/rules/lib/builtins/depset.mdx +++ b/rules/lib/builtins/depset.mdx @@ -45,9 +45,9 @@ semantics. ## Members -* [to_list](#to_list) +* [to\_list](#to_list) -## to_list +## to\_list ``` list depset.to_list() diff --git a/rules/lib/builtins/exec_result.mdx b/rules/lib/builtins/exec_result.mdx index df2542f0..afff773a 100644 --- a/rules/lib/builtins/exec_result.mdx +++ b/rules/lib/builtins/exec_result.mdx @@ -1,16 +1,16 @@ --- -title: 'exec_result' +title: 'exec\_result' --- -A structure storing result of repository_ctx.execute() method. It contains the standard output stream content, the standard error stream content and the execution return code. +A structure storing result of repository\_ctx.execute() method. It contains the standard output stream content, the standard error stream content and the execution return code. ## Members -* [return_code](#return_code) +* [return\_code](#return_code) * [stderr](#stderr) * [stdout](#stdout) -## return_code +## return\_code ``` int exec_result.return_code diff --git a/rules/lib/builtins/extension_metadata.mdx b/rules/lib/builtins/extension_metadata.mdx index 853805f1..f530ba8d 100644 --- a/rules/lib/builtins/extension_metadata.mdx +++ b/rules/lib/builtins/extension_metadata.mdx @@ -1,5 +1,5 @@ --- -title: 'extension_metadata' +title: 'extension\_metadata' --- Return values of this type from a module extension's implementation function to provide metadata about the repositories generated by the extension to Bazel. \ No newline at end of file diff --git a/rules/lib/builtins/java_annotation_processing.mdx b/rules/lib/builtins/java_annotation_processing.mdx index ad97ae45..8ae7aaed 100644 --- a/rules/lib/builtins/java_annotation_processing.mdx +++ b/rules/lib/builtins/java_annotation_processing.mdx @@ -1,20 +1,20 @@ --- -title: 'java_annotation_processing' +title: 'java\_annotation\_processing' --- Information about jars that are a result of annotation processing for a Java rule. ## Members -* [class_jar](#class_jar) +* [class\_jar](#class_jar) * [enabled](#enabled) -* [processor_classnames](#processor_classnames) -* [processor_classpath](#processor_classpath) -* [source_jar](#source_jar) -* [transitive_class_jars](#transitive_class_jars) -* [transitive_source_jars](#transitive_source_jars) +* [processor\_classnames](#processor_classnames) +* [processor\_classpath](#processor_classpath) +* [source\_jar](#source_jar) +* [transitive\_class\_jars](#transitive_class_jars) +* [transitive\_source\_jars](#transitive_source_jars) -## class_jar +## class\_jar ``` File java_annotation_processing.class_jar @@ -31,7 +31,7 @@ bool java_annotation_processing.enabled Deprecated. Returns true if annotation processing was applied on this target. -## processor_classnames +## processor\_classnames ``` list java_annotation_processing.processor_classnames @@ -39,7 +39,7 @@ list java_annotation_processing.processor_classnames Deprecated: Please use `JavaInfo.plugins` instead. Returns class names of annotation processors applied to this rule. -## processor_classpath +## processor\_classpath ``` depset java_annotation_processing.processor_classpath @@ -47,7 +47,7 @@ depset java_annotation_processing.processor_classpath Deprecated: Please use `JavaInfo.plugins` instead. Returns a classpath of annotation processors applied to this rule. -## source_jar +## source\_jar ``` File java_annotation_processing.source_jar @@ -56,7 +56,7 @@ File java_annotation_processing.source_jar Deprecated: Please use `JavaInfo.java_outputs.generated_source_jar` instead. May return `None`. -## transitive_class_jars +## transitive\_class\_jars ``` depset java_annotation_processing.transitive_class_jars @@ -64,7 +64,7 @@ depset java_annotation_processing.transitive_class_jars Deprecated. Returns a transitive set of class file jars resulting from annotation processing of this rule and its dependencies. -## transitive_source_jars +## transitive\_source\_jars ``` depset java_annotation_processing.transitive_source_jars diff --git a/rules/lib/builtins/mapped_root.mdx b/rules/lib/builtins/mapped_root.mdx index 31522c6e..528d8ea2 100644 --- a/rules/lib/builtins/mapped_root.mdx +++ b/rules/lib/builtins/mapped_root.mdx @@ -1,5 +1,5 @@ --- -title: 'mapped_root' +title: 'mapped\_root' --- A root for files that have been subject to path mapping diff --git a/rules/lib/builtins/module_ctx.mdx b/rules/lib/builtins/module_ctx.mdx index 40a4bb62..4b0b8b03 100644 --- a/rules/lib/builtins/module_ctx.mdx +++ b/rules/lib/builtins/module_ctx.mdx @@ -1,27 +1,26 @@ --- -title: 'module_ctx' +title: 'module\_ctx' --- -The context of the module extension containing helper functions and information about pertinent tags across the dependency graph. You get a module_ctx object as an argument to the `implementation` function when you create a module extension. +The context of the module extension containing helper functions and information about pertinent tags across the dependency graph. You get a module\_ctx object as an argument to the `implementation` function when you create a module extension. ## Members * [download](#download) -* [download_and_extract](#download_and_extract) +* [download\_and\_extract](#download_and_extract) * [execute](#execute) -* [extension_metadata](#extension_metadata) +* [extension\_metadata](#extension_metadata) * [extract](#extract) * [facts](#facts) * [file](#file) * [getenv](#getenv) -* [is_dev_dependency](#is_dev_dependency) +* [is\_dev\_dependency](#is_dev_dependency) * [modules](#modules) * [os](#os) * [path](#path) * [read](#read) -* [report_progress](#report_progress) -* [root_module_has_non_dev_dependency](#root_module_has_non_dev_dependency) -* [tag_sort_key](#tag_sort_key) +* [report\_progress](#report_progress) +* [root\_module\_has\_non\_dev\_dependency](#root_module_has_non_dev_dependency) * [watch](#watch) * [which](#which) @@ -31,7 +30,7 @@ The context of the module extension containing helper functions and information unknown module_ctx.download(url, output='', sha256='', executable=False, allow_fail=False, canonical_id='', auth={}, headers={}, *, integrity='', block=True) ``` -Downloads a file to the output path for the provided url and returns a struct containing `success`, a flag which is `true` if the download completed successfully, and if successful, a hash of the file with the fields `sha256` and `integrity`. If the value of the `success` field is false, the `error` field will be set with a message indicating why the download failed. The message in the `error` field is for debugging purposes only and should not be relied upon as a stable API (the format of the string can change between patch versions of Bazel). When `sha256` or `integrity` is user specified, setting an explicit `canonical_id` is highly recommended. e.g. [`get_default_canonical_id`](/rules/lib/repo/cache#get_default_canonical_id) +Downloads a file to the output path for the provided url and returns a struct containing `success`, a flag which is `true` if the download completed successfully, and if successful, a hash of the file with the fields `sha256` and `integrity`. When `sha256` or `integrity` is user specified, setting an explicit `canonical_id` is highly recommended. e.g. [`get_default_canonical_id`](/rules/lib/repo/cache#get_default_canonical_id) ### Parameters @@ -48,13 +47,13 @@ Downloads a file to the output path for the provided url and returns a struct co | `integrity` | [string](../core/string); default is `''` Expected checksum of the file downloaded, in Subresource Integrity format. This must match the checksum of the file downloaded. It is a security risk to omit the checksum as remote files can change. At best omitting this field will make your build non-hermetic. It is optional to make development easier but should be set before shipping. If provided, the repository cache will first be checked for a file with the given checksum; a download will only be attempted if the file was not found in the cache. After a successful download, the file will be added to the cache. | | `block` | [bool](../core/bool); default is `True` If set to false, the call returns immediately and instead of the regular return value, it returns a token with one single method, wait(), which blocks until the download is finished and returns the usual return value or throws as usual. | -## download_and_extract +## download\_and\_extract ``` -struct module_ctx.download_and_extract(url, output='', sha256='', type='', strip_prefix='', allow_fail=False, canonical_id='', auth={}, headers={}, *, integrity='', rename_files={}, strip_components=0) +struct module_ctx.download_and_extract(url, output='', sha256='', type='', strip_prefix='', allow_fail=False, canonical_id='', auth={}, headers={}, *, integrity='', rename_files={}) ``` -Downloads a file to the output path for the provided url, extracts it, and returns a struct containing `success`, a flag which is `true` if the download completed successfully, and if successful, a hash of the file with the fields `sha256` and `integrity`. If the value of the `success` field is false, the `error` field will be set with a message indicating why the download failed. The message in the `error` field is for debugging purposes only and should not be relied upon as a stable API (the format of the string can change between patch versions of Bazel). When `sha256` or `integrity` is user specified, setting an explicit `canonical_id` is highly recommended. e.g. [`get_default_canonical_id`](/rules/lib/repo/cache#get_default_canonical_id) +Downloads a file to the output path for the provided url, extracts it, and returns a struct containing `success`, a flag which is `true` if the download completed successfully, and if successful, a hash of the file with the fields `sha256` and `integrity`. When `sha256` or `integrity` is user specified, setting an explicit `canonical_id` is highly recommended. e.g. [`get_default_canonical_id`](/rules/lib/repo/cache#get_default_canonical_id) ### Parameters @@ -63,15 +62,14 @@ Downloads a file to the output path for the provided url, extracts it, and retur | `url` | [string](../core/string); or Iterable of [string](../core/string)s; required List of mirror URLs referencing the same file. | | `output` | [string](../core/string); or [Label](../builtins/Label); or [path](../builtins/path); default is `''` Path to the directory where the archive will be unpacked, relative to the repository directory. | | `sha256` | [string](../core/string); default is `''` The expected SHA-256 hash of the file downloaded. This must match the SHA-256 hash of the file downloaded. It is a security risk to omit the SHA-256 as remote files can change. At best omitting this field will make your build non-hermetic. It is optional to make development easier but should be set before shipping. If provided, the repository cache will first be checked for a file with the given hash; a download will only be attempted if the file was not found in the cache. After a successful download, the file will be added to the cache. | -| `type` | [string](../core/string); default is `''` The archive type of the downloaded file. By default, the archive type is determined from the file extension of the URL. If the file has no extension, you can explicitly specify either "zip", "jar", "war", "aar", "nupkg", "whl", "tar", "tar.gz", "tgz", "gz", "tar.xz", "txz", "xz", "tar.zst", "tzst", "zst", "tar.bz2", "tbz", "bz2", "ar", "deb", "7z", "tar.br" or "br" here. | -| `strip_prefix` | [string](../core/string); default is `''` A directory prefix to strip from the extracted files. Many archives contain a top-level directory that contains all files in the archive. Instead of needing to specify this prefix over and over in the `build_file`, this field can be used to strip it from extracted files. For compatibility, this parameter may also be used under the deprecated name `stripPrefix`. Only one of `strip_prefix` or `strip_components` can be used. | +| `type` | [string](../core/string); default is `''` The archive type of the downloaded file. By default, the archive type is determined from the file extension of the URL. If the file has no extension, you can explicitly specify either "zip", "jar", "war", "aar", "nupkg", "whl", "tar", "tar.gz", "tgz", "gz", "tar.xz", "txz", "xz", "tar.zst", "tzst", "zst", "tar.bz2", "tbz", "bz2", "ar", "deb" or "7z" here. | +| `strip_prefix` | [string](../core/string); default is `''` A directory prefix to strip from the extracted files. Many archives contain a top-level directory that contains all files in the archive. Instead of needing to specify this prefix over and over in the `build_file`, this field can be used to strip it from extracted files. For compatibility, this parameter may also be used under the deprecated name `stripPrefix`. | | `allow_fail` | [bool](../core/bool); default is `False` If set, indicate the error in the return value instead of raising an error for failed downloads. | | `canonical_id` | [string](../core/string); default is `''` If set, restrict cache hits to those cases where the file was added to the cache with the same canonical id. By default caching uses the checksum (`sha256` or `integrity`). | | `auth` | [dict](../core/dict); default is `{}` An optional dict specifying authentication information for some of the URLs. | | `headers` | [dict](../core/dict); default is `{}` An optional dict specifying http headers for all URLs. | | `integrity` | [string](../core/string); default is `''` Expected checksum of the file downloaded, in Subresource Integrity format. This must match the checksum of the file downloaded. It is a security risk to omit the checksum as remote files can change. At best omitting this field will make your build non-hermetic. It is optional to make development easier but should be set before shipping. If provided, the repository cache will first be checked for a file with the given checksum; a download will only be attempted if the file was not found in the cache. After a successful download, the file will be added to the cache. | | `rename_files` | [dict](../core/dict); default is `{}` An optional dict specifying files to rename during the extraction. Archive entries with names exactly matching a key will be renamed to the value, prior to any directory prefix adjustment. This can be used to extract archives that contain non-Unicode filenames, or which have files that would extract to the same path on case-insensitive filesystems. | -| `strip_components` | [int](../core/int); default is `0` Strip the given number of leading components from file paths on extraction. Only one of `strip_components` or `strip_prefix` can be used. | ## execute @@ -91,7 +89,7 @@ Executes the command given by the list of arguments. The execution time of the c | `quiet` | [bool](../core/bool); default is `True` If stdout and stderr should be printed to the terminal. | | `working_directory` | [string](../core/string); default is `""` Working directory for command execution. Can be relative to the repository root or absolute. The default is the repository root. | -## extension_metadata +## extension\_metadata ``` extension_metadata module_ctx.extension_metadata(*, root_module_direct_deps=None, root_module_direct_dev_deps=None, reproducible=False, facts={}) @@ -106,12 +104,12 @@ Constructs an opaque object that can be returned from the module extension's imp | `root_module_direct_deps` | [sequence](../core/list) of [string](../core/string)s; or [string](../core/string); or `None`; default is `None` The names of the repositories that the extension considers to be direct dependencies of the root module. If the root module imports additional repositories or does not import all of these repositories via [`use_repo`](../globals/module#use_repo), Bazel will print a warning when the extension is evaluated, instructing the user to run `bazel mod tidy` to fix the `use_repo` calls automatically. If one of `root_module_direct_deps` and will print a warning and a fixup command when the extension is evaluated. If one of `root_module_direct_deps` and `root_module_direct_dev_deps` is specified, the other has to be as well. The lists specified by these two parameters must be disjoint. Exactly one of `root_module_direct_deps` and `root_module_direct_dev_deps` can be set to the special value `"all"`, which is treated as if a list with the names of all repositories generated by the extension was specified as the value. | | `root_module_direct_dev_deps` | [sequence](../core/list) of [string](../core/string)s; or [string](../core/string); or `None`; default is `None` The names of the repositories that the extension considers to be direct dev dependencies of the root module. If the root module imports additional repositories or does not import all of these repositories via [`use_repo`](../globals/module#use_repo) on an extension proxy created with `use_extension(..., dev_dependency = True)`, Bazel will print a warning when the extension is evaluated, instructing the user to run `bazel mod tidy` to fix the `use_repo` calls automatically. If one of `root_module_direct_deps` and `root_module_direct_dev_deps` is specified, the other has to be as well. The lists specified by these two parameters must be disjoint. Exactly one of `root_module_direct_deps` and `root_module_direct_dev_deps` can be set to the special value `"all"`, which is treated as if a list with the names of all repositories generated by the extension was specified as the value. | | `reproducible` | [bool](../core/bool); default is `False` States that this module extension ensures complete reproducibility, thereby it should not be stored in the lockfile. | -| `facts` | [dict](../core/dict) of [string](../core/string)s; default is `{}` A JSON-like dict that is made available to future executions of this extension via the `module_ctx.facts` property. This is useful for extensions that want to preserve universally true facts such as the hashes of artifacts in an immutable repository. Bazel may shallowly merge multiple facts dicts returned by different versions of the extension in order to resolve merge conflicts on the MODULE.bazel.lock file, as if by applying the `dict.update()` method or the `|` operator in Starlark. Extensions should use facts for key-value storage only and ensure that the key uniquely determines the value, although perhaps only via additional information and network access. An extension can opt out of this merging by providing a dict with a single, fixed top-level key and an arbitrary value. Note that the value provided here may be read back by a different version of the extension, so either include a version number or use a schema that is unlikely to result in ambiguities. | +| `facts` | [dict](../core/dict) of [string](../core/string)s; default is `{}` A JSON-like dict that is made available to future executions of this extension via the `module\_ctx.facts` property. This is useful for extensions that want to preserve universally true facts such as the hashes of artifacts in an immutable repository. Bazel may shallowly merge multiple facts dicts returned by different versions of the extension in order to resolve merge conflicts on the MODULE.bazel.lock file, as if by applying the `dict.update()` method or the `|` operator in Starlark. Extensions should use facts for key-value storage only and ensure that the key uniquely determines the value, although perhaps only via additional information and network access. An extension can opt out of this merging by providing a dict with a single, fixed top-level key and an arbitrary value. Note that the value provided here may be read back by a different version of the extension, so either include a version number or use a schema that is unlikely to result in ambiguities. | ## extract ``` -None module_ctx.extract(archive, output='', strip_prefix='', *, rename_files={}, watch_archive='auto', strip_components=0, type='') +None module_ctx.extract(archive, output='', strip_prefix='', *, rename_files={}, watch_archive='auto', type='') ``` Extract an archive to the repository directory. @@ -122,11 +120,10 @@ Extract an archive to the repository directory. | --- | --- | | `archive` | [string](../core/string); or [Label](../builtins/Label); or [path](../builtins/path); required path to the archive that will be unpacked, relative to the repository directory. | | `output` | [string](../core/string); or [Label](../builtins/Label); or [path](../builtins/path); default is `''` path to the directory where the archive will be unpacked, relative to the repository directory. | -| `strip_prefix` | [string](../core/string); default is `''` a directory prefix to strip from the extracted files. Many archives contain a top-level directory that contains all files in the archive. Instead of needing to specify this prefix over and over in the `build_file`, this field can be used to strip it from extracted files. For compatibility, this parameter may also be used under the deprecated name `stripPrefix`. Only one of `strip_prefix` or `strip_components` can be set. | +| `strip_prefix` | [string](../core/string); default is `''` a directory prefix to strip from the extracted files. Many archives contain a top-level directory that contains all files in the archive. Instead of needing to specify this prefix over and over in the `build_file`, this field can be used to strip it from extracted files. For compatibility, this parameter may also be used under the deprecated name `stripPrefix`. | | `rename_files` | [dict](../core/dict); default is `{}` An optional dict specifying files to rename during the extraction. Archive entries with names exactly matching a key will be renamed to the value, prior to any directory prefix adjustment. This can be used to extract archives that contain non-Unicode filenames, or which have files that would extract to the same path on case-insensitive filesystems. | | `watch_archive` | [string](../core/string); default is `'auto'` whether to [watch](#watch) the archive file. Can be the string 'yes', 'no', or 'auto'. Passing 'yes' is equivalent to immediately invoking the [`watch()`](#watch) method; passing 'no' does not attempt to watch the file; passing 'auto' will only attempt to watch the file when it is legal to do so (see `watch()` docs for more information. | -| `strip_components` | [int](../core/int); default is `0` Strip the given number of leading components from file paths on extraction. Only one of `strip_components` or `strip_prefix` can be set. | -| `type` | [string](../core/string); default is `''` The archive type of the downloaded file. By default, the archive type is determined from the file extension of the URL. If the file has no extension, you can explicitly specify either "zip", "jar", "war", "aar", "nupkg", "whl", "tar", "tar.gz", "tgz", "gz", "tar.xz", "txz", "xz", "tar.zst", "tzst", "zst", "tar.bz2", "tbz", "bz2", "ar", "deb", "7z", "tar.br" or "br" here. | +| `type` | [string](../core/string); default is `''` The archive type of the downloaded file. By default, the archive type is determined from the file extension of the URL. If the file has no extension, you can explicitly specify either "zip", "jar", "war", "aar", "nupkg", "whl", "tar", "tar.gz", "tgz", "gz", "tar.xz", "txz", "xz", "tar.zst", "tzst", "zst", "tar.bz2", "tbz", "bz2", "ar", "deb" or "7z" here. | ## facts @@ -135,8 +132,8 @@ Facts module_ctx.facts ``` The JSON-like dict returned by a previous execution of this extension in the `facts` -parameter of [`extension_metadata`](../builtins/module_ctx#extension_metadata) or else -`{}`. +parameter of [`extension\_metadata`](../builtins/module\_ctx#extension\_metadata) or else +`{}`. This is useful for extensions that want to preserve universally true facts such as the hashes of artifacts in an immutable repository. Note that the returned value may have been created by a different version of the @@ -178,19 +175,19 @@ When building incrementally, any change to the value of the variable named by `n May return `None`. -## is_dev_dependency +## is\_dev\_dependency ``` bool module_ctx.is_dev_dependency(tag) ``` -Returns whether the given tag was specified on the result of a [use_extension](../globals/module#use_extension) call with `devDependency = True`. +Returns whether the given tag was specified on the result of a [use\_extension](../globals/module#use_extension) call with `devDependency = True`. ### Parameters | Parameter | Description | | --- | --- | -| `tag` | bazel_module_tag; required A tag obtained from [bazel_module.tags](../builtins/bazel_module#tags). | +| `tag` | bazel\_module\_tag; required A tag obtained from [bazel\_module.tags](../builtins/bazel_module#tags). | ## modules @@ -198,7 +195,7 @@ Returns whether the given tag was specified on the result of a [use_extension](. list module_ctx.modules ``` -A list of all the Bazel modules in the external dependency graph that use this module extension, each of which is a [bazel_module](../builtins/bazel_module) object that exposes all the tags it specified for this extension. The iteration order of this dictionary is guaranteed to be the same as breadth-first search starting from the root module. +A list of all the Bazel modules in the external dependency graph that use this module extension, each of which is a [bazel\_module](../builtins/bazel_module) object that exposes all the tags it specified for this extension. The iteration order of this dictionary is guaranteed to be the same as breadth-first search starting from the root module. ## os @@ -237,7 +234,7 @@ Reads the content of a file on the filesystem. | `path` | [string](../core/string); or [Label](../builtins/Label); or [path](../builtins/path); required Path of the file to read from. | | `watch` | [string](../core/string); default is `'auto'` Whether to [watch](#watch) the file. Can be the string 'yes', 'no', or 'auto'. Passing 'yes' is equivalent to immediately invoking the [`watch()`](#watch) method; passing 'no' does not attempt to watch the file; passing 'auto' will only attempt to watch the file when it is legal to do so (see `watch()` docs for more information. | -## report_progress +## report\_progress ``` None module_ctx.report_progress(status='') @@ -251,7 +248,7 @@ Updates the progress status for the fetching of this repository or module extens | --- | --- | | `status` | [string](../core/string); default is `''` `string` describing the current status of the fetch progress. | -## root_module_has_non_dev_dependency +## root\_module\_has\_non\_dev\_dependency ``` bool module_ctx.root_module_has_non_dev_dependency @@ -259,20 +256,6 @@ bool module_ctx.root_module_has_non_dev_dependency Whether the root module uses this extension as a non-dev dependency. -## tag_sort_key - -``` -unknown module_ctx.tag_sort_key(tag) -``` - -Returns an opaque `sort_key` object for the given tag, which can be compared with other `sort_key` objects to determine the relative order of tags, even across tag classes. Tags are ordered by their position within a module file and by the BFS ordering of modules in the dependency graph. This can be used with `sorted()` to recover the original order of tags: `sorted(tags, key=lambda tag: module_ctx.tag_sort_key(tag))` - -### Parameters - -| Parameter | Description | -| --- | --- | -| `tag` | bazel_module_tag; required A tag obtained from [bazel_module.tags](../builtins/bazel_module#tags). | - ## watch ``` diff --git a/rules/lib/builtins/path.mdx b/rules/lib/builtins/path.mdx index 98aaafcf..4fdf07f2 100644 --- a/rules/lib/builtins/path.mdx +++ b/rules/lib/builtins/path.mdx @@ -9,8 +9,8 @@ A structure representing a file to be used inside a repository. * [basename](#basename) * [dirname](#dirname) * [exists](#exists) -* [get_child](#get_child) -* [is_dir](#is_dir) +* [get\_child](#get_child) +* [is\_dir](#is_dir) * [readdir](#readdir) * [realpath](#realpath) @@ -41,7 +41,7 @@ Returns true if the file or directory denoted by this path exists. Note that accessing this field does *not* cause the path to be watched. If you'd like the repo rule or module extension to be sensitive to the path's existence, use the `watch()` method on the context object. -## get_child +## get\_child ``` path path.get_child(*relative_paths) @@ -55,7 +55,7 @@ Returns the path obtained by joining this path with the given relative paths. | --- | --- | | `relative_paths` | required Zero or more relative path strings to append to this path with path separators added as needed. | -## is_dir +## is\_dir ``` bool path.is_dir diff --git a/rules/lib/builtins/propagation_ctx.mdx b/rules/lib/builtins/propagation_ctx.mdx index 8b64269a..3d56db86 100644 --- a/rules/lib/builtins/propagation_ctx.mdx +++ b/rules/lib/builtins/propagation_ctx.mdx @@ -1,5 +1,5 @@ --- -title: 'propagation_ctx' +title: 'propagation\_ctx' --- A context object that is passed to the `propagation_predicate`, `attr_aspects` and `toolchains_aspects` functions of aspects. It provides access to the information needed to determine whether the aspect should be propagated to the target and what attributes or toolchain types it should be propagated to next. diff --git a/rules/lib/builtins/repo_metadata.mdx b/rules/lib/builtins/repo_metadata.mdx index 6e2cd8ef..0b28cbac 100644 --- a/rules/lib/builtins/repo_metadata.mdx +++ b/rules/lib/builtins/repo_metadata.mdx @@ -1,5 +1,5 @@ --- -title: 'repo_metadata' +title: 'repo\_metadata' --- See [`repository_ctx.repo_metadata`](repository_ctx#repo_metadata). \ No newline at end of file diff --git a/rules/lib/builtins/repository_ctx.mdx b/rules/lib/builtins/repository_ctx.mdx index abb48faf..3b4a3346 100644 --- a/rules/lib/builtins/repository_ctx.mdx +++ b/rules/lib/builtins/repository_ctx.mdx @@ -1,34 +1,34 @@ --- -title: 'repository_ctx' +title: 'repository\_ctx' --- -The context of the repository rule containing helper functions and information about attributes. You get a repository_ctx object as an argument to the `implementation` function when you create a repository rule. +The context of the repository rule containing helper functions and information about attributes. You get a repository\_ctx object as an argument to the `implementation` function when you create a repository rule. ## Members * [attr](#attr) * [delete](#delete) * [download](#download) -* [download_and_extract](#download_and_extract) +* [download\_and\_extract](#download_and_extract) * [execute](#execute) * [extract](#extract) * [file](#file) * [getenv](#getenv) * [name](#name) -* [original_name](#original_name) +* [original\_name](#original_name) * [os](#os) * [patch](#patch) * [path](#path) * [read](#read) * [rename](#rename) -* [repo_metadata](#repo_metadata) -* [report_progress](#report_progress) +* [repo\_metadata](#repo_metadata) +* [report\_progress](#report_progress) * [symlink](#symlink) * [template](#template) * [watch](#watch) -* [watch_tree](#watch_tree) +* [watch\_tree](#watch_tree) * [which](#which) -* [workspace_root](#workspace_root) +* [workspace\_root](#workspace_root) ## attr @@ -58,7 +58,7 @@ Deletes a file or a directory. Returns a bool, indicating whether the file or di unknown repository_ctx.download(url, output='', sha256='', executable=False, allow_fail=False, canonical_id='', auth={}, headers={}, *, integrity='', block=True) ``` -Downloads a file to the output path for the provided url and returns a struct containing `success`, a flag which is `true` if the download completed successfully, and if successful, a hash of the file with the fields `sha256` and `integrity`. If the value of the `success` field is false, the `error` field will be set with a message indicating why the download failed. The message in the `error` field is for debugging purposes only and should not be relied upon as a stable API (the format of the string can change between patch versions of Bazel). When `sha256` or `integrity` is user specified, setting an explicit `canonical_id` is highly recommended. e.g. [`get_default_canonical_id`](/rules/lib/repo/cache#get_default_canonical_id) +Downloads a file to the output path for the provided url and returns a struct containing `success`, a flag which is `true` if the download completed successfully, and if successful, a hash of the file with the fields `sha256` and `integrity`. When `sha256` or `integrity` is user specified, setting an explicit `canonical_id` is highly recommended. e.g. [`get_default_canonical_id`](/rules/lib/repo/cache#get_default_canonical_id) ### Parameters @@ -75,13 +75,13 @@ Downloads a file to the output path for the provided url and returns a struct co | `integrity` | [string](../core/string); default is `''` Expected checksum of the file downloaded, in Subresource Integrity format. This must match the checksum of the file downloaded. It is a security risk to omit the checksum as remote files can change. At best omitting this field will make your build non-hermetic. It is optional to make development easier but should be set before shipping. If provided, the repository cache will first be checked for a file with the given checksum; a download will only be attempted if the file was not found in the cache. After a successful download, the file will be added to the cache. | | `block` | [bool](../core/bool); default is `True` If set to false, the call returns immediately and instead of the regular return value, it returns a token with one single method, wait(), which blocks until the download is finished and returns the usual return value or throws as usual. | -## download_and_extract +## download\_and\_extract ``` -struct repository_ctx.download_and_extract(url, output='', sha256='', type='', strip_prefix='', allow_fail=False, canonical_id='', auth={}, headers={}, *, integrity='', rename_files={}, strip_components=0) +struct repository_ctx.download_and_extract(url, output='', sha256='', type='', strip_prefix='', allow_fail=False, canonical_id='', auth={}, headers={}, *, integrity='', rename_files={}) ``` -Downloads a file to the output path for the provided url, extracts it, and returns a struct containing `success`, a flag which is `true` if the download completed successfully, and if successful, a hash of the file with the fields `sha256` and `integrity`. If the value of the `success` field is false, the `error` field will be set with a message indicating why the download failed. The message in the `error` field is for debugging purposes only and should not be relied upon as a stable API (the format of the string can change between patch versions of Bazel). When `sha256` or `integrity` is user specified, setting an explicit `canonical_id` is highly recommended. e.g. [`get_default_canonical_id`](/rules/lib/repo/cache#get_default_canonical_id) +Downloads a file to the output path for the provided url, extracts it, and returns a struct containing `success`, a flag which is `true` if the download completed successfully, and if successful, a hash of the file with the fields `sha256` and `integrity`. When `sha256` or `integrity` is user specified, setting an explicit `canonical_id` is highly recommended. e.g. [`get_default_canonical_id`](/rules/lib/repo/cache#get_default_canonical_id) ### Parameters @@ -90,15 +90,14 @@ Downloads a file to the output path for the provided url, extracts it, and retur | `url` | [string](../core/string); or Iterable of [string](../core/string)s; required List of mirror URLs referencing the same file. | | `output` | [string](../core/string); or [Label](../builtins/Label); or [path](../builtins/path); default is `''` Path to the directory where the archive will be unpacked, relative to the repository directory. | | `sha256` | [string](../core/string); default is `''` The expected SHA-256 hash of the file downloaded. This must match the SHA-256 hash of the file downloaded. It is a security risk to omit the SHA-256 as remote files can change. At best omitting this field will make your build non-hermetic. It is optional to make development easier but should be set before shipping. If provided, the repository cache will first be checked for a file with the given hash; a download will only be attempted if the file was not found in the cache. After a successful download, the file will be added to the cache. | -| `type` | [string](../core/string); default is `''` The archive type of the downloaded file. By default, the archive type is determined from the file extension of the URL. If the file has no extension, you can explicitly specify either "zip", "jar", "war", "aar", "nupkg", "whl", "tar", "tar.gz", "tgz", "gz", "tar.xz", "txz", "xz", "tar.zst", "tzst", "zst", "tar.bz2", "tbz", "bz2", "ar", "deb", "7z", "tar.br" or "br" here. | -| `strip_prefix` | [string](../core/string); default is `''` A directory prefix to strip from the extracted files. Many archives contain a top-level directory that contains all files in the archive. Instead of needing to specify this prefix over and over in the `build_file`, this field can be used to strip it from extracted files. For compatibility, this parameter may also be used under the deprecated name `stripPrefix`. Only one of `strip_prefix` or `strip_components` can be used. | +| `type` | [string](../core/string); default is `''` The archive type of the downloaded file. By default, the archive type is determined from the file extension of the URL. If the file has no extension, you can explicitly specify either "zip", "jar", "war", "aar", "nupkg", "whl", "tar", "tar.gz", "tgz", "gz", "tar.xz", "txz", "xz", "tar.zst", "tzst", "zst", "tar.bz2", "tbz", "bz2", "ar", "deb" or "7z" here. | +| `strip_prefix` | [string](../core/string); default is `''` A directory prefix to strip from the extracted files. Many archives contain a top-level directory that contains all files in the archive. Instead of needing to specify this prefix over and over in the `build_file`, this field can be used to strip it from extracted files. For compatibility, this parameter may also be used under the deprecated name `stripPrefix`. | | `allow_fail` | [bool](../core/bool); default is `False` If set, indicate the error in the return value instead of raising an error for failed downloads. | | `canonical_id` | [string](../core/string); default is `''` If set, restrict cache hits to those cases where the file was added to the cache with the same canonical id. By default caching uses the checksum (`sha256` or `integrity`). | | `auth` | [dict](../core/dict); default is `{}` An optional dict specifying authentication information for some of the URLs. | | `headers` | [dict](../core/dict); default is `{}` An optional dict specifying http headers for all URLs. | | `integrity` | [string](../core/string); default is `''` Expected checksum of the file downloaded, in Subresource Integrity format. This must match the checksum of the file downloaded. It is a security risk to omit the checksum as remote files can change. At best omitting this field will make your build non-hermetic. It is optional to make development easier but should be set before shipping. If provided, the repository cache will first be checked for a file with the given checksum; a download will only be attempted if the file was not found in the cache. After a successful download, the file will be added to the cache. | | `rename_files` | [dict](../core/dict); default is `{}` An optional dict specifying files to rename during the extraction. Archive entries with names exactly matching a key will be renamed to the value, prior to any directory prefix adjustment. This can be used to extract archives that contain non-Unicode filenames, or which have files that would extract to the same path on case-insensitive filesystems. | -| `strip_components` | [int](../core/int); default is `0` Strip the given number of leading components from file paths on extraction. Only one of `strip_components` or `strip_prefix` can be used. | ## execute @@ -121,7 +120,7 @@ Executes the command given by the list of arguments. The execution time of the c ## extract ``` -None repository_ctx.extract(archive, output='', strip_prefix='', *, rename_files={}, watch_archive='auto', strip_components=0, type='') +None repository_ctx.extract(archive, output='', strip_prefix='', *, rename_files={}, watch_archive='auto', type='') ``` Extract an archive to the repository directory. @@ -132,11 +131,10 @@ Extract an archive to the repository directory. | --- | --- | | `archive` | [string](../core/string); or [Label](../builtins/Label); or [path](../builtins/path); required path to the archive that will be unpacked, relative to the repository directory. | | `output` | [string](../core/string); or [Label](../builtins/Label); or [path](../builtins/path); default is `''` path to the directory where the archive will be unpacked, relative to the repository directory. | -| `strip_prefix` | [string](../core/string); default is `''` a directory prefix to strip from the extracted files. Many archives contain a top-level directory that contains all files in the archive. Instead of needing to specify this prefix over and over in the `build_file`, this field can be used to strip it from extracted files. For compatibility, this parameter may also be used under the deprecated name `stripPrefix`. Only one of `strip_prefix` or `strip_components` can be set. | +| `strip_prefix` | [string](../core/string); default is `''` a directory prefix to strip from the extracted files. Many archives contain a top-level directory that contains all files in the archive. Instead of needing to specify this prefix over and over in the `build_file`, this field can be used to strip it from extracted files. For compatibility, this parameter may also be used under the deprecated name `stripPrefix`. | | `rename_files` | [dict](../core/dict); default is `{}` An optional dict specifying files to rename during the extraction. Archive entries with names exactly matching a key will be renamed to the value, prior to any directory prefix adjustment. This can be used to extract archives that contain non-Unicode filenames, or which have files that would extract to the same path on case-insensitive filesystems. | | `watch_archive` | [string](../core/string); default is `'auto'` whether to [watch](#watch) the archive file. Can be the string 'yes', 'no', or 'auto'. Passing 'yes' is equivalent to immediately invoking the [`watch()`](#watch) method; passing 'no' does not attempt to watch the file; passing 'auto' will only attempt to watch the file when it is legal to do so (see `watch()` docs for more information. | -| `strip_components` | [int](../core/int); default is `0` Strip the given number of leading components from file paths on extraction. Only one of `strip_components` or `strip_prefix` can be set. | -| `type` | [string](../core/string); default is `''` The archive type of the downloaded file. By default, the archive type is determined from the file extension of the URL. If the file has no extension, you can explicitly specify either "zip", "jar", "war", "aar", "nupkg", "whl", "tar", "tar.gz", "tgz", "gz", "tar.xz", "txz", "xz", "tar.zst", "tzst", "zst", "tar.bz2", "tbz", "bz2", "ar", "deb", "7z", "tar.br" or "br" here. | +| `type` | [string](../core/string); default is `''` The archive type of the downloaded file. By default, the archive type is determined from the file extension of the URL. If the file has no extension, you can explicitly specify either "zip", "jar", "war", "aar", "nupkg", "whl", "tar", "tar.gz", "tgz", "gz", "tar.xz", "txz", "xz", "tar.zst", "tzst", "zst", "tar.bz2", "tbz", "bz2", "ar", "deb" or "7z" here. | ## file @@ -182,7 +180,7 @@ string repository_ctx.name The canonical name of the external repository created by this rule. This name is guaranteed to be unique among all external repositories, but its exact format is not specified. Use [`original_name`](#original_name) instead to get the name that was originally specified as the `name` when this repository rule was instantiated. -## original_name +## original\_name ``` string repository_ctx.original_name @@ -204,7 +202,7 @@ A struct to access information from the system. None repository_ctx.patch(patch_file, strip=0, *, watch_patch='auto') ``` -Apply a patch file to the root directory of external repository. The patch file should be a standard [unified diff format](https://en.wikipedia.org/wiki/Diff#Unified_format) file. The Bazel-native patch implementation doesn't support binary patch like the patch command line tool. +Apply a patch file to the root directory of external repository. The patch file should be a standard [unified diff format](https://en.wikipedia.org/wiki/Diff#Unified_format) file. The Bazel-native patch implementation doesn't support fuzz match and binary patch like the patch command line tool. ### Parameters @@ -259,7 +257,7 @@ already exists. Both paths must be located within the repository. | `src` | [string](../core/string); or [Label](../builtins/Label); or [path](../builtins/path); required The path of the existing file or directory to rename, relative to the repository directory. | | `dst` | [string](../core/string); or [Label](../builtins/Label); or [path](../builtins/path); required The new name to which the file or directory will be renamed to, relative to the repository directory. | -## repo_metadata +## repo\_metadata ``` repo_metadata repository_ctx.repo_metadata(*, reproducible=False, attrs_for_reproducibility={}) @@ -274,7 +272,7 @@ Constructs an opaque object that can be returned from the repo rule's implementa | `reproducible` | [bool](../core/bool); default is `False` States that this repo can be reproducibly refetched; that is, if it were fetched another time with exactly the same input attributes, repo rule definition, watched files and environment variables, etc., then exactly the same output would be produced. This property needs to hold even if other untracked conditions change, such as information from the internet, the path of the workspace root, output from running arbitrary executables, etc. If set to True, this allows the fetched repo contents to be cached across workspaces. Note that setting this to True does not guarantee caching in the repo contents cache; for example, local repo rules are never cached. | | `attrs_for_reproducibility` | [dict](../core/dict); default is `{}` If `reproducible` is False, this can be specified to tell Bazel which attributes of the original repo rule to change to make it reproducible. | -## report_progress +## report\_progress ``` None repository_ctx.report_progress(status='') @@ -339,7 +337,7 @@ Note that attempting to watch paths inside the repo currently being fetched, or | --- | --- | | `path` | [string](../core/string); or [Label](../builtins/Label); or [path](../builtins/path); required Path of the file to watch. | -## watch_tree +## watch\_tree ``` None repository_ctx.watch_tree(path) @@ -371,7 +369,7 @@ Returns the `path` of the corresponding program or `None` if there is no such pr May return `None`. -## workspace_root +## workspace\_root ``` path repository_ctx.workspace_root diff --git a/rules/lib/builtins/repository_os.mdx b/rules/lib/builtins/repository_os.mdx index 628f65ef..e546c63c 100644 --- a/rules/lib/builtins/repository_os.mdx +++ b/rules/lib/builtins/repository_os.mdx @@ -1,5 +1,5 @@ --- -title: 'repository_os' +title: 'repository\_os' --- Various data about the current platform Bazel is running on. diff --git a/rules/lib/builtins/repository_rule.mdx b/rules/lib/builtins/repository_rule.mdx index 617964f2..4fe58461 100644 --- a/rules/lib/builtins/repository_rule.mdx +++ b/rules/lib/builtins/repository_rule.mdx @@ -1,5 +1,5 @@ --- -title: 'repository_rule' +title: 'repository\_rule' --- A callable value that may be invoked within the implementation function of a module extension to instantiate and return a repository rule. Created by [`repository_rule()`](../globals/bzl#repository_rule). \ No newline at end of file diff --git a/rules/lib/builtins/rule_attributes.mdx b/rules/lib/builtins/rule_attributes.mdx index dbedb4eb..37f0b8ab 100644 --- a/rules/lib/builtins/rule_attributes.mdx +++ b/rules/lib/builtins/rule_attributes.mdx @@ -1,5 +1,5 @@ --- -title: 'rule_attributes' +title: 'rule\_attributes' --- Information about attributes of a rule an aspect is applied to. @@ -7,7 +7,7 @@ Information about attributes of a rule an aspect is applied to. ## Members * [attr](#attr) -* [exec_groups](#exec_groups) +* [exec\_groups](#exec_groups) * [executable](#executable) * [file](#file) * [files](#files) @@ -23,7 +23,7 @@ struct rule_attributes.attr A struct to access the values of the [attributes](https://bazel.build/extending/rules#attributes). The values are provided by the user (if not, a default value is used). The attributes of the struct and the types of their values correspond to the keys and values of the [`attrs` dict](../globals/bzl#rule.attrs) provided to the [`rule` function](../globals/bzl#rule). [See example of use](https://github.com/bazelbuild/examples/blob/main/rules/attributes/printer.bzl). -## exec_groups +## exec\_groups ``` ExecGroupCollection rule_attributes.exec_groups @@ -73,7 +73,7 @@ In other words, use `files` to access the [default outputs](https://bazel.build string rule_attributes.kind ``` -The kind of a rule, such as 'cc_library' +The kind of a rule, such as 'cc\_library' ## toolchains diff --git a/rules/lib/builtins/runfiles.mdx b/rules/lib/builtins/runfiles.mdx index 193761c8..1e3acd23 100644 --- a/rules/lib/builtins/runfiles.mdx +++ b/rules/lib/builtins/runfiles.mdx @@ -8,14 +8,14 @@ See [runfiles guide](https://bazel.build/extending/rules#runfiles) for details. ## Members -* [empty_filenames](#empty_filenames) +* [empty\_filenames](#empty_filenames) * [files](#files) * [merge](#merge) -* [merge_all](#merge_all) -* [root_symlinks](#root_symlinks) +* [merge\_all](#merge_all) +* [root\_symlinks](#root_symlinks) * [symlinks](#symlinks) -## empty_filenames +## empty\_filenames ``` depset runfiles.empty_filenames @@ -47,7 +47,7 @@ Returns a new runfiles object that includes all the contents of this one and the | --- | --- | | `other` | [runfiles](../builtins/runfiles); required The runfiles object to merge into this. | -## merge_all +## merge\_all ``` runfiles runfiles.merge_all(other) @@ -61,7 +61,7 @@ Returns a new runfiles object that includes all the contents of this one and of | --- | --- | | `other` | [sequence](../core/list) of [runfiles](../builtins/runfiles)s; required The sequence of runfiles objects to merge into this. | -## root_symlinks +## root\_symlinks ``` depset runfiles.root_symlinks diff --git a/rules/lib/builtins/subrule_ctx.mdx b/rules/lib/builtins/subrule_ctx.mdx index 8f91182f..02d34e79 100644 --- a/rules/lib/builtins/subrule_ctx.mdx +++ b/rules/lib/builtins/subrule_ctx.mdx @@ -1,5 +1,5 @@ --- -title: 'subrule_ctx' +title: 'subrule\_ctx' --- A context object passed to the implementation function of a subrule. diff --git a/rules/lib/builtins/tag_class.mdx b/rules/lib/builtins/tag_class.mdx index f1ed6e2b..7d4349d0 100644 --- a/rules/lib/builtins/tag_class.mdx +++ b/rules/lib/builtins/tag_class.mdx @@ -1,5 +1,5 @@ --- -title: 'tag_class' +title: 'tag\_class' --- Defines a schema of attributes for a tag, created by [`tag_class()`](../globals/bzl#tag_class). \ No newline at end of file diff --git a/rules/lib/builtins/template_ctx.mdx b/rules/lib/builtins/template_ctx.mdx index 6643cccb..ece4b863 100644 --- a/rules/lib/builtins/template_ctx.mdx +++ b/rules/lib/builtins/template_ctx.mdx @@ -1,5 +1,5 @@ --- -title: 'template_ctx' +title: 'template\_ctx' --- A context object that is passed to the action template expansion function. @@ -7,8 +7,8 @@ A context object that is passed to the action template expansion function. ## Members * [args](#args) -* [declare_file](#declare_file) -* [declare_subdirectory](#declare_subdirectory) +* [declare\_file](#declare_file) +* [declare\_subdirectory](#declare_subdirectory) * [run](#run) ## args @@ -19,7 +19,7 @@ Args template_ctx.args() Returns an Args object that can be used to build memory-efficient command lines. -## declare_file +## declare\_file ``` File template_ctx.declare_file(filename, *, directory) @@ -36,7 +36,7 @@ Remember that in addition to declaring a file, you must separately create an act | `filename` | [string](../core/string); required The relative path of the file within the directory. | | `directory` | [File](../builtins/File); required The directory in which the file should be created. | -## declare_subdirectory +## declare\_subdirectory ``` File template_ctx.declare_subdirectory(subdirectory, *, directory) diff --git a/rules/lib/builtins/toolchain_type.mdx b/rules/lib/builtins/toolchain_type.mdx index c6d638da..6d36a0ed 100644 --- a/rules/lib/builtins/toolchain_type.mdx +++ b/rules/lib/builtins/toolchain_type.mdx @@ -1,5 +1,5 @@ --- -title: 'toolchain_type' +title: 'toolchain\_type' --- A data type describing a dependency on a specific toolchain type. @@ -7,7 +7,7 @@ A data type describing a dependency on a specific toolchain type. ## Members * [mandatory](#mandatory) -* [toolchain_type](#toolchain_type) +* [toolchain\_type](#toolchain_type) ## mandatory @@ -17,7 +17,7 @@ bool toolchain_type.mandatory Whether the toolchain type is mandatory or optional. -## toolchain_type +## toolchain\_type ``` Label toolchain_type.toolchain_type diff --git a/rules/lib/builtins/wasm_exec_result.mdx b/rules/lib/builtins/wasm_exec_result.mdx index 30ef5597..3c857ce5 100644 --- a/rules/lib/builtins/wasm_exec_result.mdx +++ b/rules/lib/builtins/wasm_exec_result.mdx @@ -1,5 +1,5 @@ --- -title: 'wasm_exec_result' +title: 'wasm\_exec\_result' --- The result of executing a WebAssembly function with @@ -11,11 +11,11 @@ and the `error_message` field will be set. ## Members -* [error_message](#error_message) +* [error\_message](#error_message) * [output](#output) -* [return_code](#return_code) +* [return\_code](#return_code) -## error_message +## error\_message ``` string wasm_exec_result.error_message @@ -31,7 +31,7 @@ string wasm_exec_result.output The content of the output buffer returned by the WebAssembly function. -## return_code +## return\_code ``` long wasm_exec_result.return_code diff --git a/rules/lib/builtins/wasm_module.mdx b/rules/lib/builtins/wasm_module.mdx index 4590e505..7c91e80d 100644 --- a/rules/lib/builtins/wasm_module.mdx +++ b/rules/lib/builtins/wasm_module.mdx @@ -1,5 +1,5 @@ --- -title: 'wasm_module' +title: 'wasm\_module' --- A WebAssembly module loaded by `repository_ctx.load_wasm()`. diff --git a/rules/lib/core.mdx b/rules/lib/core.mdx index cd4a5839..0d6adc45 100644 --- a/rules/lib/core.mdx +++ b/rules/lib/core.mdx @@ -5,7 +5,7 @@ title: 'Core Starlark data types' This section lists the data types of the [Starlark core language](https://github.com/bazelbuild/starlark/blob/master/spec.md#built-in-constants-and-functions). With some exceptions, these type names are not valid Starlark symbols; instances of them may be acquired through different means. * [bool](/rules/lib/core/bool) -* [builtin_function_or_method](/rules/lib/core/builtin_function_or_method) +* [builtin\_function\_or\_method](/rules/lib/core/builtin_function_or_method) * [dict](/rules/lib/core/dict) * [float](/rules/lib/core/float) * [function](/rules/lib/core/function) diff --git a/rules/lib/core/builtin_function_or_method.mdx b/rules/lib/core/builtin_function_or_method.mdx index e56ec83d..9f0aa8c5 100644 --- a/rules/lib/core/builtin_function_or_method.mdx +++ b/rules/lib/core/builtin_function_or_method.mdx @@ -1,5 +1,5 @@ --- -title: 'builtin_function_or_method' +title: 'builtin\_function\_or\_method' --- The type of a built-in function, defined by Java code. \ No newline at end of file diff --git a/rules/lib/core/json.mdx b/rules/lib/core/json.mdx index 6af95580..54c117b4 100644 --- a/rules/lib/core/json.mdx +++ b/rules/lib/core/json.mdx @@ -8,7 +8,7 @@ Module json is a Starlark module of JSON-related functions. * [decode](#decode) * [encode](#encode) -* [encode_indent](#encode_indent) +* [encode\_indent](#encode_indent) * [indent](#indent) ## decode @@ -51,13 +51,13 @@ Encoding any other value yields an error. | --- | --- | | `x` | required | -## encode_indent +## encode\_indent ``` string json.encode_indent(x, *, prefix='', indent='\t') ``` -The encode_indent function is equivalent to `json.indent(json.encode(x), ...)`. See `indent` for description of formatting parameters. +The encode\_indent function is equivalent to `json.indent(json.encode(x), ...)`. See `indent` for description of formatting parameters. ### Parameters diff --git a/rules/lib/core/set.mdx b/rules/lib/core/set.mdx index 457b4db9..860c4362 100644 --- a/rules/lib/core/set.mdx +++ b/rules/lib/core/set.mdx @@ -115,17 +115,17 @@ operations that attempt to update it will fail. * [add](#add) * [clear](#clear) * [difference](#difference) -* [difference_update](#difference_update) +* [difference\_update](#difference_update) * [discard](#discard) * [intersection](#intersection) -* [intersection_update](#intersection_update) +* [intersection\_update](#intersection_update) * [isdisjoint](#isdisjoint) * [issubset](#issubset) * [issuperset](#issuperset) * [pop](#pop) * [remove](#remove) -* [symmetric_difference](#symmetric_difference) -* [symmetric_difference_update](#symmetric_difference_update) +* [symmetric\_difference](#symmetric_difference) +* [symmetric\_difference\_update](#symmetric_difference_update) * [union](#union) * [update](#update) @@ -185,7 +185,7 @@ set([1, 2, 3]).difference([0, 1], [3, 4]) # set([2]) | --- | --- | | `others` | required Collections of hashable elements. | -## difference_update +## difference\_update ``` None set.difference_update(*others) @@ -270,7 +270,7 @@ set([1, 2, 3]).intersection([0, 1], [1, 2]) # set([1]) | --- | --- | | `others` | required Collections of hashable elements. | -## intersection_update +## intersection\_update ``` None set.intersection_update(*others) @@ -411,7 +411,7 @@ assignment operation. | --- | --- | | `element` | required Element to remove. Must be an element of the set (and hashable). | -## symmetric_difference +## symmetric\_difference ``` set set.symmetric_difference(other) @@ -437,7 +437,7 @@ set([1, 2]).symmetric_difference([2, 3]) # set([1, 3]) | --- | --- | | `other` | required A collection of hashable elements. | -## symmetric_difference_update +## symmetric\_difference\_update ``` None set.symmetric_difference_update(other) @@ -447,7 +447,7 @@ Returns a new mutable set containing the symmetric difference of this set with a hashable elements. If `s` and `t` are sets, `s.symmetric_difference_update(t)` is -equivalent to `s ^= t`; however, note that the`^=` augmented assignment requires both +equivalent to `s ^= t`; however, note that the` ^=` augmented assignment requires both sides to be sets, while the `symmetric_difference_update` method also accepts a sequence or a dict. diff --git a/rules/lib/fragments.mdx b/rules/lib/fragments.mdx index 8b497627..128ba7b0 100644 --- a/rules/lib/fragments.mdx +++ b/rules/lib/fragments.mdx @@ -7,7 +7,7 @@ Configuration fragments give rules access to language-specific parts of [configu Rule implementations can get them using `ctx.fragments.[fragment name]` * [apple](/rules/lib/fragments/apple) -* [bazel_android](/rules/lib/fragments/bazel_android) +* [bazel\_android](/rules/lib/fragments/bazel_android) * [coverage](/rules/lib/fragments/coverage) * [cpp](/rules/lib/fragments/cpp) * [j2objc](/rules/lib/fragments/j2objc) diff --git a/rules/lib/fragments/apple.mdx b/rules/lib/fragments/apple.mdx index c662b220..852f2ab0 100644 --- a/rules/lib/fragments/apple.mdx +++ b/rules/lib/fragments/apple.mdx @@ -6,10 +6,10 @@ A configuration fragment for Apple platforms. ## Members -* [single_arch_cpu](#single_arch_cpu) -* [single_arch_platform](#single_arch_platform) +* [single\_arch\_cpu](#single_arch_cpu) +* [single\_arch\_platform](#single_arch_platform) -## single_arch_cpu +## single\_arch\_cpu ``` string apple.single_arch_cpu @@ -17,10 +17,10 @@ string apple.single_arch_cpu The single "effective" architecture for this configuration (e.g., `i386` or `arm64`) in the context of rule logic that is only concerned with a single architecture (such as `objc_library`, which registers single-architecture compile actions). -## single_arch_platform +## single\_arch\_platform ``` apple_platform apple.single_arch_platform ``` -The platform of the current configuration. This should only be invoked in a context where only a single architecture may be supported; consider [multi_arch_platform](#multi_arch_platform) for other cases. \ No newline at end of file +The platform of the current configuration. This should only be invoked in a context where only a single architecture may be supported; consider [multi\_arch\_platform](#multi_arch_platform) for other cases. \ No newline at end of file diff --git a/rules/lib/fragments/bazel_android.mdx b/rules/lib/fragments/bazel_android.mdx index e3885032..cf269a03 100644 --- a/rules/lib/fragments/bazel_android.mdx +++ b/rules/lib/fragments/bazel_android.mdx @@ -1,15 +1,15 @@ --- -title: 'bazel_android' +title: 'bazel\_android' --- ## Members -* [merge_android_manifest_permissions](#merge_android_manifest_permissions) +* [merge\_android\_manifest\_permissions](#merge_android_manifest_permissions) -## merge_android_manifest_permissions +## merge\_android\_manifest\_permissions ``` bool bazel_android.merge_android_manifest_permissions ``` -The value of --merge_android_manifest_permissions flag. \ No newline at end of file +The value of --merge\_android\_manifest\_permissions flag. \ No newline at end of file diff --git a/rules/lib/fragments/coverage.mdx b/rules/lib/fragments/coverage.mdx index 200a79ba..17f2f3fd 100644 --- a/rules/lib/fragments/coverage.mdx +++ b/rules/lib/fragments/coverage.mdx @@ -6,9 +6,9 @@ A configuration fragment representing the coverage configuration. ## Members -* [output_generator](#output_generator) +* [output\_generator](#output_generator) -## output_generator +## output\_generator ``` Label coverage.output_generator diff --git a/rules/lib/fragments/cpp.mdx b/rules/lib/fragments/cpp.mdx index c2214f33..ea0461ad 100644 --- a/rules/lib/fragments/cpp.mdx +++ b/rules/lib/fragments/cpp.mdx @@ -6,17 +6,17 @@ A configuration fragment for C++. ## Members -* [apple_generate_dsym](#apple_generate_dsym) +* [apple\_generate\_dsym](#apple_generate_dsym) * [conlyopts](#conlyopts) * [copts](#copts) -* [custom_malloc](#custom_malloc) +* [custom\_malloc](#custom_malloc) * [cxxopts](#cxxopts) * [linkopts](#linkopts) -* [objc_generate_linkmap](#objc_generate_linkmap) -* [objc_should_strip_binary](#objc_should_strip_binary) +* [objc\_generate\_linkmap](#objc_generate_linkmap) +* [objc\_should\_strip\_binary](#objc_should_strip_binary) * [objccopts](#objccopts) -## apple_generate_dsym +## apple\_generate\_dsym ``` bool cpp.apple_generate_dsym @@ -40,7 +40,7 @@ list cpp.copts The flags passed to Bazel by [`--copt`](/docs/user-manual#flag--copt) option. -## custom_malloc +## custom\_malloc ``` Label cpp.custom_malloc @@ -75,7 +75,7 @@ list cpp.linkopts The flags passed to Bazel by [`--linkopt`](/docs/user-manual#flag--linkopt) option. -## objc_generate_linkmap +## objc\_generate\_linkmap ``` bool cpp.objc_generate_linkmap @@ -83,7 +83,7 @@ bool cpp.objc_generate_linkmap (Apple-only) Whether to generate linkmap artifacts. -## objc_should_strip_binary +## objc\_should\_strip\_binary ``` bool cpp.objc_should_strip_binary diff --git a/rules/lib/fragments/j2objc.mdx b/rules/lib/fragments/j2objc.mdx index 49b92495..a4abe6cc 100644 --- a/rules/lib/fragments/j2objc.mdx +++ b/rules/lib/fragments/j2objc.mdx @@ -6,9 +6,9 @@ A configuration fragment for j2Objc. ## Members -* [translation_flags](#translation_flags) +* [translation\_flags](#translation_flags) -## translation_flags +## translation\_flags ``` list j2objc.translation_flags diff --git a/rules/lib/fragments/java.mdx b/rules/lib/fragments/java.mdx index 15204c1a..f1573479 100644 --- a/rules/lib/fragments/java.mdx +++ b/rules/lib/fragments/java.mdx @@ -6,30 +6,30 @@ A java compiler configuration. ## Members -* [bytecode_optimization_pass_actions](#bytecode_optimization_pass_actions) -* [bytecode_optimizer_mnemonic](#bytecode_optimizer_mnemonic) -* [default_javac_flags](#default_javac_flags) -* [default_javac_flags_depset](#default_javac_flags_depset) -* [default_jvm_opts](#default_jvm_opts) -* [disallow_java_import_exports](#disallow_java_import_exports) -* [multi_release_deploy_jars](#multi_release_deploy_jars) -* [one_version_enforcement_level](#one_version_enforcement_level) +* [bytecode\_optimization\_pass\_actions](#bytecode_optimization_pass_actions) +* [bytecode\_optimizer\_mnemonic](#bytecode_optimizer_mnemonic) +* [default\_javac\_flags](#default_javac_flags) +* [default\_javac\_flags\_depset](#default_javac_flags_depset) +* [default\_jvm\_opts](#default_jvm_opts) +* [disallow\_java\_import\_exports](#disallow_java_import_exports) +* [multi\_release\_deploy\_jars](#multi_release_deploy_jars) +* [one\_version\_enforcement\_level](#one_version_enforcement_level) * [plugins](#plugins) -* [run_android_lint](#run_android_lint) -* [split_bytecode_optimization_pass](#split_bytecode_optimization_pass) -* [strict_java_deps](#strict_java_deps) -* [use_header_compilation_direct_deps](#use_header_compilation_direct_deps) -* [use_ijars](#use_ijars) +* [run\_android\_lint](#run_android_lint) +* [split\_bytecode\_optimization\_pass](#split_bytecode_optimization_pass) +* [strict\_java\_deps](#strict_java_deps) +* [use\_header\_compilation\_direct\_deps](#use_header_compilation_direct_deps) +* [use\_ijars](#use_ijars) -## bytecode_optimization_pass_actions +## bytecode\_optimization\_pass\_actions ``` int java.bytecode_optimization_pass_actions ``` -This specifies the number of actions to divide the OPTIMIZATION stage of the bytecode optimizer into. Note that if split_bytecode_optimization_pass is set, this will only change behavior if it is > 2. +This specifies the number of actions to divide the OPTIMIZATION stage of the bytecode optimizer into. Note that if split\_bytecode\_optimization\_pass is set, this will only change behavior if it is > 2. -## bytecode_optimizer_mnemonic +## bytecode\_optimizer\_mnemonic ``` string java.bytecode_optimizer_mnemonic @@ -37,7 +37,7 @@ string java.bytecode_optimizer_mnemonic The mnemonic for the bytecode optimizer. -## default_javac_flags +## default\_javac\_flags ``` list java.default_javac_flags @@ -45,7 +45,7 @@ list java.default_javac_flags The default flags for the Java compiler. -## default_javac_flags_depset +## default\_javac\_flags\_depset ``` depset java.default_javac_flags_depset @@ -53,37 +53,37 @@ depset java.default_javac_flags_depset The default flags for the Java compiler. -## default_jvm_opts +## default\_jvm\_opts ``` list java.default_jvm_opts ``` -Additional options to pass to the Java VM for each java_binary target +Additional options to pass to the Java VM for each java\_binary target -## disallow_java_import_exports +## disallow\_java\_import\_exports ``` bool java.disallow_java_import_exports() ``` -Returns true if java_import exports are not allowed. +Returns true if java\_import exports are not allowed. -## multi_release_deploy_jars +## multi\_release\_deploy\_jars ``` bool java.multi_release_deploy_jars ``` -The value of the --incompatible_multi_release_deploy_jars flag. +The value of the --incompatible\_multi\_release\_deploy\_jars flag. -## one_version_enforcement_level +## one\_version\_enforcement\_level ``` string java.one_version_enforcement_level ``` -The value of the --experimental_one_version_enforcement flag. +The value of the --experimental\_one\_version\_enforcement flag. ## plugins @@ -93,15 +93,15 @@ list java.plugins A list containing the labels provided with --plugins, if any. -## run_android_lint +## run\_android\_lint ``` bool java.run_android_lint ``` -The value of the --experimental_run_android_lint_on_java_rules flag. +The value of the --experimental\_run\_android\_lint\_on\_java\_rules flag. -## split_bytecode_optimization_pass +## split\_bytecode\_optimization\_pass ``` bool java.split_bytecode_optimization_pass @@ -109,15 +109,15 @@ bool java.split_bytecode_optimization_pass Returns whether the OPTIMIZATION stage of the bytecode optimizer will be split across two actions. -## strict_java_deps +## strict\_java\_deps ``` string java.strict_java_deps ``` -The value of the strict_java_deps flag. +The value of the strict\_java\_deps flag. -## use_header_compilation_direct_deps +## use\_header\_compilation\_direct\_deps ``` bool java.use_header_compilation_direct_deps() @@ -125,7 +125,7 @@ bool java.use_header_compilation_direct_deps() Returns true if Java header compilation should use separate outputs for direct deps. -## use_ijars +## use\_ijars ``` bool java.use_ijars() diff --git a/rules/lib/fragments/objc.mdx b/rules/lib/fragments/objc.mdx index 1c09b3a7..578ae19f 100644 --- a/rules/lib/fragments/objc.mdx +++ b/rules/lib/fragments/objc.mdx @@ -6,22 +6,24 @@ A configuration fragment for Objective-C. ## Members -* [alwayslink_by_default](#alwayslink_by_default) -* [builtin_objc_strip_action](#builtin_objc_strip_action) -* [copts_for_current_compilation_mode](#copts_for_current_compilation_mode) -* [disallow_sdk_frameworks_attributes](#disallow_sdk_frameworks_attributes) -* [strip_executable_safely](#strip_executable_safely) -* [uses_device_debug_entitlements](#uses_device_debug_entitlements) +* [alwayslink\_by\_default](#alwayslink_by_default) +* [builtin\_objc\_strip\_action](#builtin_objc_strip_action) +* [copts\_for\_current\_compilation\_mode](#copts_for_current_compilation_mode) +* [disallow\_sdk\_frameworks\_attributes](#disallow_sdk_frameworks_attributes) +* [ios\_simulator\_device](#ios_simulator_device) +* [ios\_simulator\_version](#ios_simulator_version) +* [strip\_executable\_safely](#strip_executable_safely) +* [uses\_device\_debug\_entitlements](#uses_device_debug_entitlements) -## alwayslink_by_default +## alwayslink\_by\_default ``` bool objc.alwayslink_by_default ``` -Returns whether objc_library and objc_import should default to alwayslink=True. +Returns whether objc\_library and objc\_import should default to alwayslink=True. -## builtin_objc_strip_action +## builtin\_objc\_strip\_action ``` bool objc.builtin_objc_strip_action @@ -29,7 +31,7 @@ bool objc.builtin_objc_strip_action Returns whether to emit a strip action as part of objc linking. -## copts_for_current_compilation_mode +## copts\_for\_current\_compilation\_mode ``` list objc.copts_for_current_compilation_mode @@ -37,15 +39,33 @@ list objc.copts_for_current_compilation_mode Returns a list of default options to use for compiling Objective-C in the current mode. -## disallow_sdk_frameworks_attributes +## disallow\_sdk\_frameworks\_attributes ``` bool objc.disallow_sdk_frameworks_attributes ``` -Returns whether sdk_frameworks and weak_sdk_frameworks are disallowed attributes. +Returns whether sdk\_frameworks and weak\_sdk\_frameworks are disallowed attributes. -## strip_executable_safely +## ios\_simulator\_device + +``` +string objc.ios_simulator_device +``` + +The type of device (e.g. 'iPhone 6') to use when running on the simulator. +May return `None`. + +## ios\_simulator\_version + +``` +DottedVersion objc.ios_simulator_version +``` + +The SDK version of the iOS simulator to use when running on the simulator. +May return `None`. + +## strip\_executable\_safely ``` bool objc.strip_executable_safely @@ -53,7 +73,7 @@ bool objc.strip_executable_safely Returns whether executable strip action should use flag -x, which does not break dynamic symbol resolution. -## uses_device_debug_entitlements +## uses\_device\_debug\_entitlements ``` bool objc.uses_device_debug_entitlements diff --git a/rules/lib/fragments/platform.mdx b/rules/lib/fragments/platform.mdx index a8057ed5..f5f8651c 100644 --- a/rules/lib/fragments/platform.mdx +++ b/rules/lib/fragments/platform.mdx @@ -6,10 +6,10 @@ The platform configuration. ## Members -* [host_platform](#host_platform) +* [host\_platform](#host_platform) * [platform](#platform) -## host_platform +## host\_platform ``` Label platform.host_platform diff --git a/rules/lib/globals/all.mdx b/rules/lib/globals/all.mdx index 4fa554a3..165ca362 100644 --- a/rules/lib/globals/all.mdx +++ b/rules/lib/globals/all.mdx @@ -465,7 +465,7 @@ set({"k1": "v1", "k2": "v2"}) # set(["k1", "k2"]), a set of two elements list sorted(iterable, key=None, *, reverse=False) ``` -Returns a new sorted list containing all the elements of the supplied iterable sequence. An error may occur if any pair of elements x, y may not be compared using x < y. The elements are sorted into ascending order, unless the reverse argument is True, in which case the order is descending. +Returns a new sorted list containing all the elements of the supplied iterable sequence. An error may occur if any pair of elements x, y may not be compared using x < y. The elements are sorted into ascending order, unless the reverse argument is True, in which case the order is descending. Sorting is stable: elements that compare equal retain their original relative order. ``` diff --git a/rules/lib/globals/build.mdx b/rules/lib/globals/build.mdx index 2f614ff6..b00c047e 100644 --- a/rules/lib/globals/build.mdx +++ b/rules/lib/globals/build.mdx @@ -7,19 +7,19 @@ Methods available in BUILD files. See also the Build Encyclopedia for extra [fun ## Members * [depset](#depset) -* [existing_rule](#existing_rule) -* [existing_rules](#existing_rules) -* [exports_files](#exports_files) +* [existing\_rule](#existing_rule) +* [existing\_rules](#existing_rules) +* [exports\_files](#exports_files) * [glob](#glob) -* [module_name](#module_name) -* [module_version](#module_version) +* [module\_name](#module_name) +* [module\_version](#module_version) * [package](#package) -* [package_default_visibility](#package_default_visibility) -* [package_group](#package_group) -* [package_name](#package_name) -* [package_relative_label](#package_relative_label) -* [repo_name](#repo_name) -* [repository_name](#repository_name) +* [package\_default\_visibility](#package_default_visibility) +* [package\_group](#package_group) +* [package\_name](#package_name) +* [package\_relative\_label](#package_relative_label) +* [repo\_name](#repo_name) +* [repository\_name](#repository_name) * [select](#select) * [subpackages](#subpackages) @@ -33,7 +33,7 @@ Creates a [depset](../builtins/depset). The `direct` parameter is a list of dire All elements (direct and indirect) of a depset must be of the same type, as obtained by the expression [`type(x)`](../globals/all#type). -Because a hash-based set is used to eliminate duplicates during iteration, all elements of a depset should be hashable. However, this invariant is not currently checked consistently in all constructors. Use the --incompatible_always_check_depset_elements flag to enable consistent checking; this will be the default behavior in future releases; see [Issue 10313](https://github.com/bazelbuild/bazel/issues/10313). +Because a hash-based set is used to eliminate duplicates during iteration, all elements of a depset should be hashable. However, this invariant is not currently checked consistently in all constructors. Use the --incompatible\_always\_check\_depset\_elements flag to enable consistent checking; this will be the default behavior in future releases; see [Issue 10313](https://github.com/bazelbuild/bazel/issues/10313). In addition, elements must currently be immutable, though this restriction will be relaxed in future. @@ -47,7 +47,7 @@ The order of the created depset should be *compatible* with the order of its `tr | `order` | [string](../core/string); default is `"default"` The traversal strategy for the new depset. See [here](../builtins/depset) for the possible values. | | `transitive` | [sequence](../core/list) of [depset](../builtins/depset)s; or `None`; default is `None` A list of depsets whose elements will become indirect elements of the depset. | -## existing_rule +## existing\_rule ``` unknown existing_rule(name) @@ -75,7 +75,7 @@ If possible, use this function only in [implementation functions of rule finaliz | --- | --- | | `name` | [string](../core/string); required The name of the target. | -## existing_rules +## existing\_rules ``` unknown existing_rules() @@ -87,7 +87,7 @@ Here, an *immutable dict-like object* means a deeply immutable object `x` suppor If possible, use this function only in [implementation functions of rule finalizer symbolic macros](https://bazel.build/extending/macros#finalizers). Use of this function in other contexts is not recommened, and will be disabled in a future Bazel release; it makes `BUILD` files brittle and order-dependent. -## exports_files +## exports\_files ``` None exports_files(srcs, visibility=None, licenses=None) @@ -123,9 +123,9 @@ If the `exclude_directories` argument is enabled (set to `1`), files of type dir | `include` | [sequence](../core/list) of [string](../core/string)s; default is `[]` The list of glob patterns to include. | | `exclude` | [sequence](../core/list) of [string](../core/string)s; default is `[]` The list of glob patterns to exclude. | | `exclude_directories` | [int](../core/int); default is `1` A flag whether to exclude directories or not. | -| `allow_empty` | default is `unbound` Whether we allow glob patterns to match nothing. If `allow_empty` is False, each individual include pattern must match something and also the final result must be non-empty (after the matches of the `exclude` patterns are excluded). | +| `allow_empty` | default is `unbound` Whether we allow glob patterns to match nothing. If `allow\_empty` is False, each individual include pattern must match something and also the final result must be non-empty (after the matches of the `exclude` patterns are excluded). | -## module_name +## module\_name ``` string module_name() @@ -134,7 +134,7 @@ string module_name() The name of the Bazel module associated with the repo this package is in. If this package is from a repo defined in WORKSPACE instead of MODULE.bazel, this is empty. For repos generated by module extensions, this is the name of the module hosting the extension. It's the same as the `module.name` field seen in `module_ctx.modules`. May return `None`. -## module_version +## module\_version ``` string module_version() @@ -157,7 +157,7 @@ Declares metadata that applies to every rule in the package. It must be called a | --- | --- | | `kwargs` | required See the [`package()`](/reference/be/functions#package) function in the Build Encyclopedia for applicable arguments. | -## package_default_visibility +## package\_default\_visibility ``` List package_default_visibility() @@ -165,7 +165,7 @@ List package_default_visibility() Returns the default visibility of the package being evaluated. This is the value of the `default_visibility` parameter of `package()`, extended to include the package itself. -## package_group +## package\_group ``` None package_group(*, name, packages=[], includes=[]) @@ -181,7 +181,7 @@ This function defines a set of packages and assigns a label to the group. The la | `packages` | [sequence](../core/list) of [string](../core/string)s; default is `[]` A complete enumeration of packages in this group. | | `includes` | [sequence](../core/list) of [string](../core/string)s; default is `[]` Other package groups that are included in this one. | -## package_name +## package\_name ``` string package_name() @@ -189,7 +189,7 @@ string package_name() The name of the package being evaluated, without the repository name. For example, in the BUILD file `some/package/BUILD`, its value will be `some/package`. If the BUILD file calls a function defined in a .bzl file, `package_name()` will match the caller BUILD file package. The value will always be an empty string for the root package. -## package_relative_label +## package\_relative\_label ``` Label package_relative_label(input) @@ -201,7 +201,7 @@ This function may only be called while evaluating a BUILD file and the macros it The result of this function is the same `Label` value as would be produced by passing the given string to a label-valued attribute of a target declared in the BUILD file. -*Usage note:* The difference between this function and [`Label()`](../builtins/Label#Label) is that `Label()` uses the context of the package of the `.bzl` file that called it, not the package of the `BUILD` file. Use `Label()` when you need to refer to a fixed target that is hardcoded into the macro, such as a compiler. Use `package_relative_label()` when you need to normalize a label string supplied by the BUILD file to a `Label` object. (There is no way to convert a string to a `Label` in the context of a package other than the BUILD file or the calling .bzl file. For that reason, outer macros should always prefer to pass Label objects to inner macros rather than label strings.)[`ctx.package_relative_label()`](ctx#package_relative_label) provides the same functionality within a rule or aspect implementation function. +*Usage note:* The difference between this function and [Label()](../builtins/Label#Label) is that `Label()` uses the context of the package of the `.bzl` file that called it, not the package of the `BUILD` file. Use `Label()` when you need to refer to a fixed target that is hardcoded into the macro, such as a compiler. Use `package_relative_label()` when you need to normalize a label string supplied by the BUILD file to a `Label` object. (There is no way to convert a string to a `Label` in the context of a package other than the BUILD file or the calling .bzl file. For that reason, outer macros should always prefer to pass Label objects to inner macros rather than label strings.)[`ctx.package_relative_label()`](ctx#package_relative_label) provides the same functionality within a rule or aspect implementation function. ### Parameters @@ -209,7 +209,7 @@ The result of this function is the same `Label` value as would be produced by pa | --- | --- | | `input` | [string](../core/string); or [Label](../builtins/Label); required The input label string or Label object. If a Label object is passed, it's returned as is. | -## repo_name +## repo\_name ``` string repo_name() @@ -217,7 +217,7 @@ string repo_name() The canonical name of the repository containing the package currently being evaluated, with no leading at-signs. -## repository_name +## repository\_name ``` string repository_name() @@ -249,7 +249,7 @@ unknown select(x, no_match_error='') sequence subpackages(*, include, exclude=[], allow_empty=False) ``` -Returns a new mutable list of every direct subpackage of the current package, regardless of file-system directory depth. List returned is sorted and contains the names of subpackages relative to the current package. It is advised to prefer using the methods in bazel_skylib.subpackages module rather than calling this function directly. +Returns a new mutable list of every direct subpackage of the current package, regardless of file-system directory depth. List returned is sorted and contains the names of subpackages relative to the current package. It is advised to prefer using the methods in bazel\_skylib.subpackages module rather than calling this function directly. ### Parameters diff --git a/rules/lib/globals/bzl.mdx b/rules/lib/globals/bzl.mdx index bde8cf80..748fc2e5 100644 --- a/rules/lib/globals/bzl.mdx +++ b/rules/lib/globals/bzl.mdx @@ -6,24 +6,24 @@ Global methods available in all .bzl files. ## Members -* [analysis_test_transition](#analysis_test_transition) +* [analysis\_test\_transition](#analysis_test_transition) * [aspect](#aspect) -* [configuration_field](#configuration_field) +* [configuration\_field](#configuration_field) * [depset](#depset) -* [exec_group](#exec_group) -* [exec_transition](#exec_transition) +* [exec\_group](#exec_group) +* [exec\_transition](#exec_transition) * [macro](#macro) -* [materializer_rule](#materializer_rule) -* [module_extension](#module_extension) +* [materializer\_rule](#materializer_rule) +* [module\_extension](#module_extension) * [provider](#provider) -* [repository_rule](#repository_rule) +* [repository\_rule](#repository_rule) * [rule](#rule) * [select](#select) * [subrule](#subrule) -* [tag_class](#tag_class) +* [tag\_class](#tag_class) * [visibility](#visibility) -## analysis_test_transition +## analysis\_test\_transition ``` transition analysis_test_transition(*, settings) @@ -64,12 +64,12 @@ Creates a new aspect. The result of this function must be stored in a global val | `host_fragments` | [sequence](../core/list) of [string](../core/string)s; default is `[]` List of names of configuration fragments that the aspect requires in host configuration. | | `toolchains` | [sequence](../core/list); default is `[]` If set, the set of toolchains this aspect requires. The list can contain String, Label, or StarlarkToolchainTypeApi objects, in any combination. Toolchains will be found by checking the current platform, and provided to the aspect implementation via `ctx.toolchain`. | | `doc` | [string](../core/string); or `None`; default is `None` A description of the aspect that can be extracted by documentation generating tools. | -| `apply_to_generating_rules` | [bool](../core/bool); default is `False` If true, the aspect will, when applied to an output file, instead apply to the output file's generating rule. For example, suppose an aspect propagates transitively through attribute `deps` and it is applied to target `alpha`. Suppose `alpha` has `deps = [':beta_output']`, where `beta_output` is a declared output of a target `beta`. Suppose `beta` has a target `charlie` as one of its `deps`. If `apply_to_generating_rules=True` for the aspect, then the aspect will propagate through `alpha`, `beta`, and `charlie`. If False, then the aspect will propagate only to `alpha`. False by default. | +| `apply_to_generating_rules` | [bool](../core/bool); default is `False` If true, the aspect will, when applied to an output file, instead apply to the output file's generating rule. For example, suppose an aspect propagates transitively through attribute `deps` and it is applied to target `alpha`. Suppose `alpha` has `deps = [':beta\_output']`, where `beta\_output` is a declared output of a target `beta`. Suppose `beta` has a target `charlie` as one of its `deps`. If `apply\_to\_generating\_rules=True` for the aspect, then the aspect will propagate through `alpha`, `beta`, and `charlie`. If False, then the aspect will propagate only to `alpha`. False by default. | | `exec_compatible_with` | [sequence](../core/list) of [string](../core/string)s; default is `[]` A list of constraints on the execution platform that apply to all instances of this aspect. | | `exec_groups` | [dict](../core/dict); or `None`; default is `None` Dict of execution group name (string) to [`exec_group`s](../globals/bzl#exec_group). If set, allows aspects to run actions on multiple execution platforms within a single instance. See [execution groups documentation](/reference/exec-groups) for more info. | | `subrules` | [sequence](../core/list) of [Subrule](../builtins/Subrule)s; default is `[]` Experimental: list of subrules used by this aspect. | -## configuration_field +## configuration\_field ``` LateBoundDefault configuration_field(fragment, name) @@ -110,7 +110,7 @@ Creates a [depset](../builtins/depset). The `direct` parameter is a list of dire All elements (direct and indirect) of a depset must be of the same type, as obtained by the expression [`type(x)`](../globals/all#type). -Because a hash-based set is used to eliminate duplicates during iteration, all elements of a depset should be hashable. However, this invariant is not currently checked consistently in all constructors. Use the --incompatible_always_check_depset_elements flag to enable consistent checking; this will be the default behavior in future releases; see [Issue 10313](https://github.com/bazelbuild/bazel/issues/10313). +Because a hash-based set is used to eliminate duplicates during iteration, all elements of a depset should be hashable. However, this invariant is not currently checked consistently in all constructors. Use the --incompatible\_always\_check\_depset\_elements flag to enable consistent checking; this will be the default behavior in future releases; see [Issue 10313](https://github.com/bazelbuild/bazel/issues/10313). In addition, elements must currently be immutable, though this restriction will be relaxed in future. @@ -124,7 +124,7 @@ The order of the created depset should be *compatible* with the order of its `tr | `order` | [string](../core/string); default is `"default"` The traversal strategy for the new depset. See [here](../builtins/depset) for the possible values. | | `transitive` | [sequence](../core/list) of [depset](../builtins/depset)s; or `None`; default is `None` A list of depsets whose elements will become indirect elements of the depset. | -## exec_group +## exec\_group ``` exec_group exec_group(*, toolchains=[], exec_compatible_with=[]) @@ -139,7 +139,7 @@ Creates an [execution group](/reference/exec-groups) which can be used to create | `toolchains` | [sequence](../core/list); default is `[]` The set of toolchains this execution group requires. The list can contain String, Label, or StarlarkToolchainTypeApi objects, in any combination. | | `exec_compatible_with` | [sequence](../core/list) of [string](../core/string)s; default is `[]` A list of constraints on the execution platform. | -## exec_transition +## exec\_transition ``` transition exec_transition(*, implementation, inputs, outputs) @@ -174,13 +174,13 @@ macros. | Parameter | Description | | --- | --- | -| `implementation` | [function](../core/function); required The Starlark function implementing this macro. The values of the macro's attributes are passed to the implementation function as keyword arguments. The implementation function must have at least two named parameters, `name` and `visibility`, and if the macro inherits attributes (see `inherit_attrs` below), it must have a `**kwargs` residual keyword parameter. By convention, the implementation function should have a named parameter for any attribute that the macro needs to examine, modify, or pass to non-"main" targets, while the "bulk" inherited attributes which will be passed to the "main" target unchanged are passed as `**kwargs`. The implementation function must not return a value. Instead, the implementation function *declares targets* by calling rule or macro symbols. The name of any target or inner symbolic macro declared by a symbolic macro (including by any Starlark function that the macro's implementation function transitively calls) must either equal `name` (this is referred to as the "main" target) or start with `name`, followed by a separator chracter (`"_"`, `"-"`, or `"."`) and a string suffix. (Targets violating this naming scheme are allowed to be declared, but cannot be built, configured, or depended upon.) By default, targets declared by a symbolic macro (including by any Starlark function that the macro's implementation function transitively calls) are visible only in the package containing the .bzl file defining the macro. To declare targets visible externally, *including to the caller of the symbolic macro*, the implementation function must set `visibility` appropriately – typically, by passing `visibility = visibility` to the rule or macro symbol being called. The following APIs are unavailable within a macro implementation function and any Starlark function it transitively calls: * [`package()`, `licenses()`](/reference/be/functions#package)* `environment_group()`* [`native.glob()`](../toplevel/native#glob) – instead, you may pass a glob into the macro via a label list attribute* [`native.subpackages()`](../toplevel/native#subpackages)* (allowed in rule finalizers only, see `finalizer` below) [`native.existing_rules()`](../toplevel/native#existing_rules), [`native.existing_rule()`](../toplevel/native#existing_rule)* (for `WORKSPACE` threads) [`workspace()`](../globals/workspace#workspace), [`register_toolchains()`](../globals/workspace#register_toolchains), [`register_execution_platforms()`](../globals/workspace#register_execution_platforms), [`bind()`](../globals/workspace#bind), repository rule instantiation | +| `implementation` | [function](../core/function); required The Starlark function implementing this macro. The values of the macro's attributes are passed to the implementation function as keyword arguments. The implementation function must have at least two named parameters, `name` and `visibility`, and if the macro inherits attributes (see `inherit_attrs` below), it must have a `**kwargs` residual keyword parameter. By convention, the implementation function should have a named parameter for any attribute that the macro needs to examine, modify, or pass to non-"main" targets, while the "bulk" inherited attributes which will be passed to the "main" target unchanged are passed as `**kwargs`. The implementation function must not return a value. Instead, the implementation function *declares targets* by calling rule or macro symbols. The name of any target or inner symbolic macro declared by a symbolic macro (including by any Starlark function that the macro's implementation function transitively calls) must either equal `name` (this is referred to as the "main" target) or start with `name`, followed by a separator chracter (`"_"`, `"-"`, or `"."`) and a string suffix. (Targets violating this naming scheme are allowed to be declared, but cannot be built, configured, or depended upon.) By default, targets declared by a symbolic macro (including by any Starlark function that the macro's implementation function transitively calls) are visible only in the package containing the .bzl file defining the macro. To declare targets visible externally, *including to the caller of the symbolic macro*, the implementation function must set `visibility` appropriately – typically, by passing `visibility = visibility` to the rule or macro symbol being called. The following APIs are unavailable within a macro implementation function and any Starlark function it transitively calls: * [`package()`, `licenses()`* `environment_group()`* [`native.glob()`](../toplevel/native#glob) – instead, you may pass a glob into the macro via a label list attribute* [`native.subpackages()`](../toplevel/native#subpackages)* (allowed in rule finalizers only, see `finalizer` below) [`native.existing_rules()`](../toplevel/native#existing_rules), [`native.existing_rule()`](../toplevel/native#existing_rule)* (for `WORKSPACE` threads) [`workspace()`](../globals/workspace#workspace), [`register_toolchains()`](../globals/workspace#register_toolchains), [`bind()`](../globals/workspace#register_execution_platforms>register_execution_platforms(),

name, workspace_file, workspace_file_content) -Deprecated - use the drop-in replacement 'git_repository' instead +Clone an external git repository. + +Clones a Git repository, checks out the specified branch, tag, or commit, and +makes its targets available for binding. If no branch, tag or commit is +specified, check out the repository's default branch. Also determine the id +and date of the commit that was checked out, and return a dict with +parameters that provide a reproducible version of this rule (which a tag or +branch not necessarily is). + +Bazel will first try to perform a shallow fetch of only the specified commit. +If that fails (usually due to missing server support), it will fall back to a +full fetch of the repository. + +Prefer [`http_archive`](/rules/lib/repo/http#http_archive) to `git_repository`. +The reasons are: + +* Git repository rules depend on system `git(1)` whereas the HTTP downloader is built + into Bazel and has no system dependencies. +* `http_archive` supports a list of `urls` as mirrors, and `git_repository` supports only + a single `remote`. +* `http_archive` works with the [repository cache](/run/build#repository-cache), but not + `git_repository`. See + [#5116](https://github.com/bazelbuild/bazel/issues/5116) for more information. **ATTRIBUTES** @@ -616,7 +639,7 @@ The patch(1) utility to use. If this is specified, Bazel will use the specified

-A list of files that are to be applied as patches after extracting the archive. By default, it uses the Bazel-native patch implementation which doesn't support binary patch, but Bazel will fall back to use patch command line tool if `patch_tool` attribute is specified or there are arguments other than `-p` in `patch_args` attribute. +A list of files that are to be applied as patches after extracting the archive. By default, it uses the Bazel-native patch implementation which doesn't support fuzz match and binary patch, but Bazel will fall back to use patch command line tool if `patch_tool` attribute is specified or there are arguments other than `-p` in `patch_args` attribute.

@@ -801,3 +824,9 @@ No-op attribute; do not use.
test_suite convention; suite of large tests
manual \*manual * don't include test target in wildcard target patterns like :..., :*, or :all
+**ENVIRONMENT VARIABLES** + +This repository rule depends on the following environment variables: + +* `BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID` + diff --git a/rules/lib/repo/http.mdx b/rules/lib/repo/http.mdx index 7f33e91e..e5601205 100644 --- a/rules/lib/repo/http.mdx +++ b/rules/lib/repo/http.mdx @@ -4,6 +4,7 @@ title: 'http repository rules' The following functions can be loaded from `@bazel_tools//tools/build_defs/repo:http.bzl`. + Rules for downloading files and archives over HTTP. @@ -39,14 +40,14 @@ load("@bazel//tools/build_defs/repo:http.bzl", "http_archive") http_archive(name, add_prefix, auth_patterns, build_file, build_file_content, canonical_id, files, integrity, netrc, patch_args, patch_cmds, patch_cmds_win, patch_strip, patch_tool, patches, remote_file_integrity, remote_file_urls, remote_module_file_integrity, - remote_module_file_urls, remote_patch_strip, remote_patches, sha256, strip_components, - strip_prefix, type, url, urls, workspace_file, workspace_file_content) + remote_module_file_urls, remote_patch_strip, remote_patches, sha256, strip_prefix, type, + url, urls, workspace_file, workspace_file_content) Downloads a Bazel repository as a compressed archive file, decompresses it, and makes its targets available for binding. -It supports the following file extensions: `"zip"`, `"jar"`, `"war"`, `"aar"`, `"nupkg"`, `"whl"`, `"tar"`, `"tar.gz"`, `"tgz"`, `"gz"`, `"tar.xz"`, `"txz"`, `"xz"`, `"tar.zst"`, `"tzst"`, `"zst"`, `"tar.bz2"`, `"tbz"`, `"bz2"`, `"ar"`, `"deb"`, `"7z"`, `"tar.br"` or `"br"`. +It supports the following file extensions: `"zip"`, `"jar"`, `"war"`, `"aar"`, `"nupkg"`, `"whl"`, `"tar"`, `"tar.gz"`, `"tgz"`, `"gz"`, `"tar.xz"`, `"txz"`, `"xz"`, `"tar.zst"`, `"tzst"`, `"zst"`, `"tar.bz2"`, `"tbz"`, `"bz2"`, `"ar"`, `"deb"` or `"7z"`. Examples: Suppose the current repository contains the source code for a chat program, @@ -148,24 +149,24 @@ as the value for the Authorization field of the HTTP request. Example attribute and netrc for a http download to an oauth2 enabled API using a bearer token: -``` +
 auth_patterns = {
-    "storage.cloudprovider.com": "Bearer "
+    "storage.cloudprovider.com": "Bearer <password>"
 }
-```
+
netrc: -``` +
 machine storage.cloudprovider.com
         password RANDOM-TOKEN
-```
+
The final HTTP request would have the following header: -``` +
 Authorization: Bearer RANDOM-TOKEN
-```
+

@@ -338,7 +339,7 @@ The patch(1) utility to use. If this is specified, Bazel will use the specified

-A list of files that are to be applied as patches after extracting the archive. By default, it uses the Bazel-native patch implementation which doesn't support binary patch, but Bazel will fall back to use patch command line tool if `patch_tool` attribute is specified or there are arguments other than `-p` in `patch_args` attribute. +A list of files that are to be applied as patches after extracting the archive. By default, it uses the Bazel-native patch implementation which doesn't support fuzz match and binary patch, but Bazel will fall back to use patch command line tool if `patch_tool` attribute is specified or there are arguments other than `-p` in `patch_args` attribute.

@@ -441,22 +442,6 @@ to omit the SHA-256 as remote files can change._ At best omitting this field will make your build non-hermetic. It is optional to make development easier but either this attribute or `integrity` should be set before shipping. -

- - - -strip_components - - -Integer; optional - -

- -Strip the given number of leading components from file paths -on extraction. - -Only one of `strip_components` and `strip_prefix` can be set. -

@@ -487,8 +472,6 @@ files/directories that start with the prefix but are not in the directory (e.g., `foo-lib-1.2.3.release-notes`). If the specified prefix does not match a directory in the archive, Bazel will return an error. -Only one of `strip_prefix` and `strip_components` can be set. -

@@ -504,7 +487,7 @@ The archive type of the downloaded file. By default, the archive type is determined from the file extension of the URL. If the file has no extension, you can explicitly specify one of the -following: `"zip"`, `"jar"`, `"war"`, `"aar"`, `"nupkg"`, `"whl"`, `"tar"`, `"tar.gz"`, `"tgz"`, `"gz"`, `"tar.xz"`, `"txz"`, `"xz"`, `"tar.zst"`, `"tzst"`, `"zst"`, `"tar.bz2"`, `"tbz"`, `"bz2"`, `"ar"`, `"deb"`, `"7z"`, `"tar.br"` or `"br"`. +following: `"zip"`, `"jar"`, `"war"`, `"aar"`, `"nupkg"`, `"whl"`, `"tar"`, `"tar.gz"`, `"tgz"`, `"gz"`, `"tar.xz"`, `"txz"`, `"xz"`, `"tar.zst"`, `"tzst"`, `"zst"`, `"tar.bz2"`, `"tbz"`, `"bz2"`, `"ar"`, `"deb"` or `"7z"`.

@@ -655,24 +638,24 @@ as the value for the Authorization field of the HTTP request. Example attribute and netrc for a http download to an oauth2 enabled API using a bearer token: -``` +
 auth_patterns = {
-    "storage.cloudprovider.com": "Bearer "
+    "storage.cloudprovider.com": "Bearer <password>"
 }
-```
+
netrc: -``` +
 machine storage.cloudprovider.com
         password RANDOM-TOKEN
-```
+
The final HTTP request would have the following header: -``` +
 Authorization: Bearer RANDOM-TOKEN
-```
+

@@ -903,24 +886,24 @@ as the value for the Authorization field of the HTTP request. Example attribute and netrc for a http download to an oauth2 enabled API using a bearer token: -``` +
 auth_patterns = {
-    "storage.cloudprovider.com": "Bearer "
+    "storage.cloudprovider.com": "Bearer <password>"
 }
-```
+
netrc: -``` +
 machine storage.cloudprovider.com
         password RANDOM-TOKEN
-```
+
The final HTTP request would have the following header: -``` +
 Authorization: Bearer RANDOM-TOKEN
-```
+

diff --git a/rules/lib/repo/index.mdx b/rules/lib/repo/index.mdx index 8b364d2d..ab27e81c 100644 --- a/rules/lib/repo/index.mdx +++ b/rules/lib/repo/index.mdx @@ -1,3 +1,4 @@ + --- title: 'Repository Rules' --- diff --git a/rules/lib/repo/local.mdx b/rules/lib/repo/local.mdx index 68bab6cf..21ac0bf4 100644 --- a/rules/lib/repo/local.mdx +++ b/rules/lib/repo/local.mdx @@ -4,6 +4,7 @@ title: 'local repository rules' The following functions can be loaded from `@bazel_tools//tools/build_defs/repo:local.bzl`. + Rules for making directories in the local filesystem available as repos. diff --git a/rules/lib/repo/utils.mdx b/rules/lib/repo/utils.mdx index 943d0a33..536387aa 100644 --- a/rules/lib/repo/utils.mdx +++ b/rules/lib/repo/utils.mdx @@ -4,6 +4,7 @@ title: 'utils repository rules' The following functions can be loaded from `@bazel_tools//tools/build_defs/repo:utils.bzl`. + Utils for manipulating external repositories, once fetched. diff --git a/rules/lib/toplevel.mdx b/rules/lib/toplevel.mdx index ccb9860e..98622e8b 100644 --- a/rules/lib/toplevel.mdx +++ b/rules/lib/toplevel.mdx @@ -4,14 +4,14 @@ title: 'Top-level Modules' This section lists top-level modules. These symbols are available only in .bzl files. -* [apple_common](/rules/lib/toplevel/apple_common) +* [apple\_common](/rules/lib/toplevel/apple_common) * [attr](/rules/lib/toplevel/attr) -* [cc_common](/rules/lib/toplevel/cc_common) +* [cc\_common](/rules/lib/toplevel/cc_common) * [config](/rules/lib/toplevel/config) -* [config_common](/rules/lib/toplevel/config_common) -* [coverage_common](/rules/lib/toplevel/coverage_common) -* [java_common](/rules/lib/toplevel/java_common) +* [config\_common](/rules/lib/toplevel/config_common) +* [coverage\_common](/rules/lib/toplevel/coverage_common) +* [java\_common](/rules/lib/toplevel/java_common) * [native](/rules/lib/toplevel/native) -* [platform_common](/rules/lib/toplevel/platform_common) +* [platform\_common](/rules/lib/toplevel/platform_common) * [proto](/rules/lib/toplevel/proto) * [testing](/rules/lib/toplevel/testing) \ No newline at end of file diff --git a/rules/lib/toplevel/apple_common.mdx b/rules/lib/toplevel/apple_common.mdx index 89daed70..f220a6f1 100644 --- a/rules/lib/toplevel/apple_common.mdx +++ b/rules/lib/toplevel/apple_common.mdx @@ -1,21 +1,21 @@ --- -title: 'apple_common' +title: 'apple\_common' --- Functions for Starlark to access internals of the apple rule implementations. ## Members -* [apple_host_system_env](#apple_host_system_env) -* [apple_toolchain](#apple_toolchain) -* [dotted_version](#dotted_version) +* [apple\_host\_system\_env](#apple_host_system_env) +* [apple\_toolchain](#apple_toolchain) +* [dotted\_version](#dotted_version) * [platform](#platform) -* [platform_type](#platform_type) -* [target_apple_env](#target_apple_env) +* [platform\_type](#platform_type) +* [target\_apple\_env](#target_apple_env) * [XcodeProperties](#XcodeProperties) * [XcodeVersionConfig](#XcodeVersionConfig) -## apple_host_system_env +## apple\_host\_system\_env ``` dict apple_common.apple_host_system_env(xcode_config) @@ -29,7 +29,7 @@ Returns a [dict](../core/dict) of environment variables that should be set for a | --- | --- | | `xcode_config` | required A provider containing information about the Xcode configuration. | -## apple_toolchain +## apple\_toolchain ``` unknown apple_common.apple_toolchain() @@ -37,7 +37,7 @@ unknown apple_common.apple_toolchain() Utilities for resolving items from the apple toolchain. -## dotted_version +## dotted\_version ``` DottedVersion apple_common.dotted_version(version) @@ -69,9 +69,9 @@ An enum-like struct that contains the following fields corresponding to Apple pl * `watchos_device` * `watchos_simulator` -These values can be passed to methods that expect a platform, like [XcodeVersionConfig.sdk_version_for_platform](../providers/XcodeVersionConfig#sdk_version_for_platform). +These values can be passed to methods that expect a platform, like [XcodeVersionConfig.sdk\_version\_for\_platform](../providers/XcodeVersionConfig#sdk_version_for_platform). -## platform_type +## platform\_type ``` struct apple_common.platform_type @@ -87,7 +87,7 @@ An enum-like struct that contains the following fields corresponding to Apple pl These values can be passed to methods that expect a platform type. -## target_apple_env +## target\_apple\_env ``` dict apple_common.target_apple_env(xcode_config, platform) diff --git a/rules/lib/toplevel/attr.mdx b/rules/lib/toplevel/attr.mdx index 677a308f..3ff113c5 100644 --- a/rules/lib/toplevel/attr.mdx +++ b/rules/lib/toplevel/attr.mdx @@ -11,18 +11,18 @@ and [using](https://bazel.build/extending/rules#implementation_function) attribu * [bool](#bool) * [int](#int) -* [int_list](#int_list) +* [int\_list](#int_list) * [label](#label) -* [label_keyed_string_dict](#label_keyed_string_dict) -* [label_list](#label_list) -* [label_list_dict](#label_list_dict) +* [label\_keyed\_string\_dict](#label_keyed_string_dict) +* [label\_list](#label_list) +* [label\_list\_dict](#label_list_dict) * [output](#output) -* [output_list](#output_list) +* [output\_list](#output_list) * [string](#string) -* [string_dict](#string_dict) -* [string_keyed_label_dict](#string_keyed_label_dict) -* [string_list](#string_list) -* [string_list_dict](#string_list_dict) +* [string\_dict](#string_dict) +* [string\_keyed\_label\_dict](#string_keyed_label_dict) +* [string\_list](#string_list) +* [string\_list\_dict](#string_list_dict) ## bool @@ -59,7 +59,7 @@ Creates a schema for an integer attribute. The value must be in the signed 32-bi | `mandatory` | [bool](../core/bool); default is `False` If true, the value must be specified explicitly (even if it has a `default`). | | `values` | [sequence](../core/list) of [int](../core/int)s; default is `[]` The list of allowed values for the attribute. An error is raised if any other value is given. | -## int_list +## int\_list ``` Attribute attr.int_list(mandatory=False, allow_empty=True, *, configurable=unbound, default=[], doc=None) @@ -111,7 +111,7 @@ In addition to ordinary source files, this kind of attribute is often used to re | `aspects` | [sequence](../core/list) of [Aspect](../builtins/Aspect)s; default is `[]` Aspects that should be applied to the dependency or dependencies specified by this attribute. | | `flags` | [sequence](../core/list) of [string](../core/string)s; default is `[]` Deprecated, will be removed. | -## label_keyed_string_dict +## label\_keyed\_string\_dict ``` Attribute attr.label_keyed_string_dict(allow_empty=True, *, configurable=unbound, default={}, doc=None, allow_files=None, allow_rules=None, providers=[], for_dependency_resolution=unbound, flags=[], mandatory=False, skip_validations=False, cfg=None, aspects=[]) @@ -141,7 +141,7 @@ At analysis time (within the rule's implementation function), when retrieving th | `cfg` | default is `None` [Configuration](https://bazel.build/extending/rules#configurations) of the attribute. It can be either `"exec"`, which indicates that the dependency is built for the `execution platform`, or `"target"`, which indicates that the dependency is build for the `target platform`. A typical example of the difference is when building mobile apps, where the `target platform` is `Android` or `iOS` while the `execution platform` is `Linux`, `macOS`, or `Windows`. | | `aspects` | [sequence](../core/list) of [Aspect](../builtins/Aspect)s; default is `[]` Aspects that should be applied to the dependency or dependencies specified by this attribute. | -## label_list +## label\_list ``` Attribute attr.label_list(allow_empty=True, *, configurable=unbound, default=[], materializer=None, doc=None, allow_files=None, allow_rules=None, providers=[], for_dependency_resolution=unbound, flags=[], mandatory=False, skip_validations=False, cfg=None, aspects=[]) @@ -172,7 +172,7 @@ At analysis time (within the rule's implementation function), when retrieving th | `cfg` | default is `None` [Configuration](https://bazel.build/extending/rules#configurations) of the attribute. It can be either `"exec"`, which indicates that the dependency is built for the `execution platform`, or `"target"`, which indicates that the dependency is build for the `target platform`. A typical example of the difference is when building mobile apps, where the `target platform` is `Android` or `iOS` while the `execution platform` is `Linux`, `macOS`, or `Windows`. | | `aspects` | [sequence](../core/list) of [Aspect](../builtins/Aspect)s; default is `[]` Aspects that should be applied to the dependency or dependencies specified by this attribute. | -## label_list_dict +## label\_list\_dict ``` Attribute attr.label_list_dict(allow_empty=True, *, configurable=unbound, default={}, doc=None, allow_files=None, allow_rules=None, providers=[], for_dependency_resolution=unbound, flags=[], mandatory=False, skip_validations=False, cfg=None, aspects=[]) @@ -221,7 +221,7 @@ At analysis time, the corresponding [`File`](../builtins/File) can be retrieved | `doc` | [string](../core/string); or `None`; default is `None` A description of the attribute that can be extracted by documentation generating tools. | | `mandatory` | [bool](../core/bool); default is `False` If true, the value must be specified explicitly (even if it has a `default`). | -## output_list +## output\_list ``` Attribute attr.output_list(allow_empty=True, *, doc=None, mandatory=False) @@ -259,7 +259,7 @@ Creates a schema for a [string](../core/string#attr) attribute. | `mandatory` | [bool](../core/bool); default is `False` If true, the value must be specified explicitly (even if it has a `default`). | | `values` | [sequence](../core/list) of [string](../core/string)s; default is `[]` The list of allowed values for the attribute. An error is raised if any other value is given. | -## string_dict +## string\_dict ``` Attribute attr.string_dict(allow_empty=True, *, configurable=unbound, default={}, doc=None, mandatory=False) @@ -277,7 +277,7 @@ Creates a schema for an attribute holding a dictionary, where the keys and value | `doc` | [string](../core/string); or `None`; default is `None` A description of the attribute that can be extracted by documentation generating tools. | | `mandatory` | [bool](../core/bool); default is `False` If true, the value must be specified explicitly (even if it has a `default`). | -## string_keyed_label_dict +## string\_keyed\_label\_dict ``` Attribute attr.string_keyed_label_dict(allow_empty=True, *, configurable=unbound, default={}, doc=None, allow_files=None, allow_rules=None, providers=[], for_dependency_resolution=unbound, flags=[], mandatory=False, cfg=None, aspects=[]) @@ -306,7 +306,7 @@ At analysis time (within the rule's implementation function), when retrieving th | `cfg` | default is `None` [Configuration](https://bazel.build/extending/rules#configurations) of the attribute. It can be either `"exec"`, which indicates that the dependency is built for the `execution platform`, or `"target"`, which indicates that the dependency is build for the `target platform`. A typical example of the difference is when building mobile apps, where the `target platform` is `Android` or `iOS` while the `execution platform` is `Linux`, `macOS`, or `Windows`. | | `aspects` | [sequence](../core/list) of [Aspect](../builtins/Aspect)s; default is `[]` Aspects that should be applied to the dependency or dependencies specified by this attribute. | -## string_list +## string\_list ``` Attribute attr.string_list(mandatory=False, allow_empty=True, *, configurable=unbound, default=[], doc=None) @@ -324,7 +324,7 @@ Creates a schema for a list-of-strings attribute. | `default` | [sequence](../core/list) of [string](../core/string)s; or NativeComputedDefault; default is `[]` A default value to use if no value for this attribute is given when instantiating the rule. | | `doc` | [string](../core/string); or `None`; default is `None` A description of the attribute that can be extracted by documentation generating tools. | -## string_list_dict +## string\_list\_dict ``` Attribute attr.string_list_dict(allow_empty=True, *, configurable=unbound, default={}, doc=None, mandatory=False) diff --git a/rules/lib/toplevel/cc_common.mdx b/rules/lib/toplevel/cc_common.mdx index 9b48c9a6..070aa2e7 100644 --- a/rules/lib/toplevel/cc_common.mdx +++ b/rules/lib/toplevel/cc_common.mdx @@ -1,50 +1,50 @@ --- -title: 'cc_common' +title: 'cc\_common' --- Utilities for C++ compilation, linking, and command line generation. ## Members -* [action_is_enabled](#action_is_enabled) +* [action\_is\_enabled](#action_is_enabled) * [CcToolchainInfo](#CcToolchainInfo) * [compile](#compile) -* [configure_features](#configure_features) -* [create_cc_toolchain_config_info](#create_cc_toolchain_config_info) -* [create_compilation_context](#create_compilation_context) -* [create_compilation_outputs](#create_compilation_outputs) -* [create_compile_variables](#create_compile_variables) -* [create_library_to_link](#create_library_to_link) -* [create_link_variables](#create_link_variables) -* [create_linker_input](#create_linker_input) -* [create_linking_context](#create_linking_context) -* [create_linking_context_from_compilation_outputs](#create_linking_context_from_compilation_outputs) -* [create_lto_compilation_context](#create_lto_compilation_context) -* [do_not_use_tools_cpp_compiler_present](#do_not_use_tools_cpp_compiler_present) -* [get_environment_variables](#get_environment_variables) -* [get_execution_requirements](#get_execution_requirements) -* [get_memory_inefficient_command_line](#get_memory_inefficient_command_line) -* [get_tool_for_action](#get_tool_for_action) -* [is_enabled](#is_enabled) +* [configure\_features](#configure_features) +* [create\_cc\_toolchain\_config\_info](#create_cc_toolchain_config_info) +* [create\_compilation\_context](#create_compilation_context) +* [create\_compilation\_outputs](#create_compilation_outputs) +* [create\_compile\_variables](#create_compile_variables) +* [create\_library\_to\_link](#create_library_to_link) +* [create\_link\_variables](#create_link_variables) +* [create\_linker\_input](#create_linker_input) +* [create\_linking\_context](#create_linking_context) +* [create\_linking\_context\_from\_compilation\_outputs](#create_linking_context_from_compilation_outputs) +* [create\_lto\_compilation\_context](#create_lto_compilation_context) +* [do\_not\_use\_tools\_cpp\_compiler\_present](#do_not_use_tools_cpp_compiler_present) +* [get\_environment\_variables](#get_environment_variables) +* [get\_execution\_requirements](#get_execution_requirements) +* [get\_memory\_inefficient\_command\_line](#get_memory_inefficient_command_line) +* [get\_tool\_for\_action](#get_tool_for_action) +* [is\_enabled](#is_enabled) * [link](#link) -* [merge_cc_infos](#merge_cc_infos) -* [merge_compilation_contexts](#merge_compilation_contexts) -* [merge_compilation_outputs](#merge_compilation_outputs) +* [merge\_cc\_infos](#merge_cc_infos) +* [merge\_compilation\_contexts](#merge_compilation_contexts) +* [merge\_compilation\_outputs](#merge_compilation_outputs) -## action_is_enabled +## action\_is\_enabled ``` bool cc_common.action_is_enabled(*, feature_configuration, action_name) ``` -Returns True if given action_config is enabled in the feature configuration. +Returns True if given action\_config is enabled in the feature configuration. ### Parameters | Parameter | Description | | --- | --- | | `feature_configuration` | [FeatureConfiguration](../builtins/FeatureConfiguration); required Feature configuration to be queried. | -| `action_name` | [string](../core/string); required Name of the action_config. | +| `action_name` | [string](../core/string); required Name of the action\_config. | ## CcToolchainInfo @@ -74,41 +74,41 @@ Should be used for C++ compilation. Returns tuple of (`CompilationContext`, `CcC | `private_hdrs` | [sequence](../core/list); default is `[]` List of headers needed for compilation of srcs and NOT to be included by dependent rules. | | `includes` | [sequence](../core/list); or [depset](../builtins/depset); default is `[]` Search paths for header files referenced both by angle bracket and quotes. Usually passed with -I. Propagated to dependents transitively. | | `quote_includes` | [sequence](../core/list); default is `[]` Search paths for header files referenced by quotes, e.g. #include "foo/bar/header.h". They can be either relative to the exec root or absolute. Usually passed with -iquote. Propagated to dependents transitively. | -| `system_includes` | [sequence](../core/list); default is `[]` Search paths for header files referenced by angle brackets, e.g. #include <foo/bar/header.h>. They can be either relative to the exec root or absolute. Usually passed with -isystem. Propagated to dependents transitively. | +| `system_includes` | [sequence](../core/list); default is `[]` Search paths for header files referenced by angle brackets, e.g. #include . They can be either relative to the exec root or absolute. Usually passed with -isystem. Propagated to dependents transitively. | | `framework_includes` | [sequence](../core/list); default is `[]` Search paths for header files from Apple frameworks. They can be either relative to the exec root or absolute. Usually passed with -F. Propagated to dependents transitively. | | `defines` | [sequence](../core/list); default is `[]` Set of defines needed to compile this target. Each define is a string. Propagated to dependents transitively. | | `local_defines` | [sequence](../core/list); default is `[]` Set of defines needed to compile this target. Each define is a string. Not propagated to dependents transitively. | -| `include_prefix` | [string](../core/string); default is `''` The prefix to add to the paths of the headers of this rule. When set, the headers in the hdrs attribute of this rule are accessible at is the value of this attribute prepended to their repository-relative path. The prefix in the strip_include_prefix attribute is removed before this prefix is added. | -| `strip_include_prefix` | [string](../core/string); default is `''` The prefix to strip from the paths of the headers of this rule. When set, the headers in the hdrs attribute of this rule are accessible at their path with this prefix cut off. If it's a relative path, it's taken as a package-relative one. If it's an absolute one, it's understood as a repository-relative path. The prefix in the include_prefix attribute is added after this prefix is stripped. | +| `include_prefix` | [string](../core/string); default is `''` The prefix to add to the paths of the headers of this rule. When set, the headers in the hdrs attribute of this rule are accessible at is the value of this attribute prepended to their repository-relative path. The prefix in the strip\_include\_prefix attribute is removed before this prefix is added. | +| `strip_include_prefix` | [string](../core/string); default is `''` The prefix to strip from the paths of the headers of this rule. When set, the headers in the hdrs attribute of this rule are accessible at their path with this prefix cut off. If it's a relative path, it's taken as a package-relative one. If it's an absolute one, it's understood as a repository-relative path. The prefix in the include\_prefix attribute is added after this prefix is stripped. | | `user_compile_flags` | [sequence](../core/list); default is `[]` Additional list of compilation options. | | `conly_flags` | [sequence](../core/list); default is `[]` Additional list of compilation options for C compiles. | | `cxx_flags` | [sequence](../core/list); default is `[]` Additional list of compilation options for C++ compiles. | | `compilation_contexts` | [sequence](../core/list); default is `[]` Headers from dependencies used for compilation. | -| `name` | [string](../core/string); required This is used for naming the output artifacts of actions created by this method. See also the `main_output` arg. | +| `name` | [string](../core/string); required This is used for naming the output artifacts of actions created by this method. See also the `main\_output` arg. | | `disallow_pic_outputs` | [bool](../core/bool); default is `False` Whether PIC outputs should be created. | | `disallow_nopic_outputs` | [bool](../core/bool); default is `False` Whether NOPIC outputs should be created. | | `additional_inputs` | [sequence](../core/list); default is `[]` List of additional files needed for compilation of srcs | -| `module_interfaces` | [sequence](../core/list); default is `unbound` The list of module interfaces source files to be compiled. Note: this is an experimental feature, only enabled with --experimental_cpp_modules | +| `module_interfaces` | [sequence](../core/list); default is `unbound` The list of module interfaces source files to be compiled. Note: this is an experimental feature, only enabled with --experimental\_cpp\_modules | -## configure_features +## configure\_features ``` FeatureConfiguration cc_common.configure_features(*, ctx, cc_toolchain, language=None, requested_features=[], unsupported_features=[]) ``` -Creates a feature_configuration instance. Requires the cpp configuration fragment. +Creates a feature\_configuration instance. Requires the cpp configuration fragment. ### Parameters | Parameter | Description | | --- | --- | | `ctx` | [ctx](../builtins/ctx); required The rule context. | -| `cc_toolchain` | Info; required cc_toolchain for which we configure features. | +| `cc_toolchain` | Info; required cc\_toolchain for which we configure features. | | `language` | [string](../core/string); or `None`; default is `None` The language to configure for: either c++ or objc (default c++) | | `requested_features` | [sequence](../core/list); default is `[]` List of features to be enabled. | | `unsupported_features` | [sequence](../core/list); default is `[]` List of features that are unsupported by the current rule. | -## create_cc_toolchain_config_info +## create\_cc\_toolchain\_config\_info ``` None cc_common.create_cc_toolchain_config_info(*, ctx, features=[], action_configs=[], artifact_name_patterns=[], cxx_builtin_include_directories=[], toolchain_identifier, host_system_name=None, target_system_name=None, target_cpu=None, target_libc=None, compiler, abi_version=None, abi_libc_version=None, tool_paths=[], make_variables=[], builtin_sysroot=None) @@ -123,21 +123,21 @@ Creates a `CcToolchainConfigInfo` provider | `ctx` | [ctx](../builtins/ctx); required The rule context. | | `features` | [sequence](../core/list); default is `[]` Contains all flag specifications for one feature. Arguments: `name`: The feature's name. It is possible to introduce a feature without a change to Bazel by adding a 'feature' section to the toolchain and adding the corresponding string as feature in the `BUILD` file. `enabled`: If 'True', this feature is enabled unless a rule type explicitly marks it as unsupported. `flag_sets`: A FlagSet list. If the given feature is enabled, the flag sets will be applied for the actions are specified for. `env_sets`: an EnvSet list. If the given feature is enabled, the env sets will be applied for the actions they are specified for. `requires`: A list of feature sets defining when this feature is supported by the toolchain. The feature is supported if any of the feature sets fully apply, that is, when all features of a feature set are enabled. If `requires` is omitted, the feature is supported independently of which other features are enabled. Use this for example to filter flags depending on the build mode enabled (opt / fastbuild / dbg). `implies`: A string list of features or action configs that are automatically enabled when this feature is enabled. If any of the implied features or action configs cannot be enabled, this feature will (silently) not be enabled either. `provides`: A list of names this feature conflicts with. A feature cannot be enabled if:- `provides` contains the name of a different feature or action config that we want to enable.- `provides` contains the same value as a 'provides' in a different feature or action config that we want to enable. Use this in order to ensure that incompatible features cannot be accidentally activated at the same time, leading to hard to diagnose compiler errors. | | `action_configs` | [sequence](../core/list); default is `[]` An action config corresponds to a Bazel action, and allows selection of a tool based on activated features. Action config activation occurs by the same semantics as features: a feature can 'require' or 'imply' an action config in the same way that it would another feature. Arguments: `action_name`: The name of the Bazel action that this config applies to, e.g. 'c-compile' or 'c-module-compile'. `enabled`: If 'True', this action is enabled unless a rule type explicitly marks it as unsupported. `tools`: The tool applied to the action will be the first tool with a feature set that matches the feature configuration. An error will be thrown if no tool matches a provided feature configuration - for that reason, it's a good idea to provide a default tool with an empty feature set. `flag_sets`: If the given action config is enabled, the flag sets will be applied to the corresponding action. `implies`: A list of features or action configs that are automatically enabled when this action config is enabled. If any of the implied features or action configs cannot be enabled, this action config will (silently) not be enabled either. | -| `artifact_name_patterns` | [sequence](../core/list); default is `[]` The name for an artifact of a given category of input or output artifacts to an action. Arguments: `category_name`: The category of artifacts that this selection applies to. This field is compared against a list of categories defined in Bazel. Example categories include "linked_output" or the artifact for this selection. Together with the extension it is used to create an artifact name based on the target name. `extension`: The extension for creating the artifact for this selection. Together with the prefix it is used to create an artifact name based on the target name. | +| `artifact_name_patterns` | [sequence](../core/list); default is `[]` The name for an artifact of a given category of input or output artifacts to an action. Arguments: `category_name`: The category of artifacts that this selection applies to. This field is compared against a list of categories defined in Bazel. Example categories include "linked\_output" or the artifact for this selection. Together with the extension it is used to create an artifact name based on the target name. `extension`: The extension for creating the artifact for this selection. Together with the prefix it is used to create an artifact name based on the target name. | | `cxx_builtin_include_directories` | [sequence](../core/list); default is `[]` Built-in include directories for C++ compilation. These should be the exact paths used by the compiler, and are generally relative to the exec root. The paths used by the compiler can be determined by 'gcc -E -xc++ - -v'. We currently use the C++ paths also for C compilation, which is safe as long as there are no name clashes between C++ and C header files. Relative paths are resolved relative to the configuration file directory. If the compiler has --sysroot support, then these paths should use %sysroot% rather than the include path, and specify the sysroot attribute in order to give blaze the information necessary to make the correct replacements. | | `toolchain_identifier` | [string](../core/string); required The unique identifier of the toolchain within the crosstool release. It must be possible to use this as a directory name in a path. It has to match the following regex: [a-zA-Z\_][\.\- \w]\* | | `host_system_name` | [string](../core/string); or `None`; default is `None` Ignored. | -| `target_system_name` | [string](../core/string); or `None`; default is `None` Deprecated. The GNU System Name. The string is exposed to CcToolchainInfo.target_gnu_system_name. | -| `target_cpu` | [string](../core/string); or `None`; default is `None` Deprecated: Use cpu based constraints instead. If the string is "k8", `target_cpu` will be omitted from the filename of raw FDO profile data. | +| `target_system_name` | [string](../core/string); or `None`; default is `None` Deprecated. The GNU System Name. The string is exposed to CcToolchainInfo.target\_gnu\_system\_name. | +| `target_cpu` | [string](../core/string); or `None`; default is `None` Deprecated: Use cpu based constraints instead. If the string is "k8", `target\_cpu` will be omitted from the filename of raw FDO profile data. | | `target_libc` | [string](../core/string); or `None`; default is `None` Deprecated: Use OS based constraints instead. The libc version string (e.g. "glibc-2.2.2"). If the string is "macosx", platform is assumed to be MacOS. Otherwise, Linux. The string is exposed to CcToolchainInfo.libc. | -| `compiler` | [string](../core/string); required The compiler string (e.g. "gcc"). The current toolchain's compiler is exposed to `@bazel_tools//tools/cpp:compiler (compiler_flag)` as a flag value. Targets that require compiler-specific flags can use the config_settings in https://github.com/bazelbuild/rules_cc/blob/main/cc/compiler/BUILD in select() statements or create custom config_setting if the existing settings don't suffice. | +| `compiler` | [string](../core/string); required The compiler string (e.g. "gcc"). The current toolchain's compiler is exposed to `@bazel\_tools//tools/cpp:compiler (compiler\_flag)` as a flag value. Targets that require compiler-specific flags can use the config\_settings in https://github.com/bazelbuild/rules\_cc/blob/main/cc/compiler/BUILD in select() statements or create custom config\_setting if the existing settings don't suffice. | | `abi_version` | [string](../core/string); or `None`; default is `None` The abi in use, which is a gcc version. E.g.: "gcc-3.4". The string is set to C++ toolchain variable ABI. | -| `abi_libc_version` | [string](../core/string); or `None`; default is `None` The glibc version used by the abi we're using. The string is set to C++ toolchain variable ABI_LIBC_VERSION. | -| `tool_paths` | [sequence](../core/list); default is `[]` Tool locations. Arguments: `name`: Name of the tool. `path`: Location of the tool; Can be absolute path (in case of non hermetic toolchain), or path relative to the cc_toolchain's package. | +| `abi_libc_version` | [string](../core/string); or `None`; default is `None` The glibc version used by the abi we're using. The string is set to C++ toolchain variable ABI\_LIBC\_VERSION. | +| `tool_paths` | [sequence](../core/list); default is `[]` Tool locations. Arguments: `name`: Name of the tool. `path`: Location of the tool; Can be absolute path (in case of non hermetic toolchain), or path relative to the cc\_toolchain's package. | | `make_variables` | [sequence](../core/list); default is `[]` A make variable that is made accessible to rules. | -| `builtin_sysroot` | [string](../core/string); or `None`; default is `None` The built-in sysroot. If this attribute is not present, Bazel does not allow using a different sysroot, i.e. through the --grte_top option. | +| `builtin_sysroot` | [string](../core/string); or `None`; default is `None` The built-in sysroot. If this attribute is not present, Bazel does not allow using a different sysroot, i.e. through the --grte\_top option. | -## create_compilation_context +## create\_compilation\_context ``` CompilationContext cc_common.create_compilation_context(*, headers=unbound, system_includes=unbound, includes=unbound, quote_includes=unbound, framework_includes=unbound, defines=unbound, local_defines=unbound) @@ -150,14 +150,14 @@ Creates a `CompilationContext`. | Parameter | Description | | --- | --- | | `headers` | default is `unbound` Set of headers needed to compile this target | -| `system_includes` | default is `unbound` Set of search paths for header files referenced by angle brackets, i.e. #include <foo/bar/header.h>. They can be either relative to the exec root or absolute. Usually passed with -isystem | +| `system_includes` | default is `unbound` Set of search paths for header files referenced by angle brackets, i.e. #include . They can be either relative to the exec root or absolute. Usually passed with -isystem | | `includes` | default is `unbound` Set of search paths for header files referenced both by angle bracket and quotes.Usually passed with -I | | `quote_includes` | default is `unbound` Set of search paths for header files referenced by quotes, i.e. #include "foo/bar/header.h". They can be either relative to the exec root or absolute. Usually passed with -iquote | | `framework_includes` | default is `unbound` Set of framework search paths for header files (Apple platform only) | | `defines` | default is `unbound` Set of defines needed to compile this target. Each define is a string. Propagated transitively to dependents. | | `local_defines` | default is `unbound` Set of defines needed to compile this target. Each define is a string. Not propagated transitively to dependents. | -## create_compilation_outputs +## create\_compilation\_outputs ``` CcCompilationOutputs cc_common.create_compilation_outputs(*, objects=None, pic_objects=None) @@ -172,7 +172,7 @@ Create compilation outputs object. | `objects` | [depset](../builtins/depset); or `None`; default is `None` List of object files. | | `pic_objects` | [depset](../builtins/depset); or `None`; default is `None` List of pic object files. | -## create_compile_variables +## create\_compile\_variables ``` Variables cc_common.create_compile_variables(*, cc_toolchain, feature_configuration, source_file=None, output_file=None, user_compile_flags=None, include_directories=None, quote_include_directories=None, system_include_directories=None, framework_include_directories=None, preprocessor_defines=None, thinlto_index=None, thinlto_input_bitcode_file=None, thinlto_output_object_file=None, use_pic=False, add_legacy_cxx_options=False, variables_extension=unbound) @@ -184,10 +184,10 @@ Returns variables used for compilation actions. | Parameter | Description | | --- | --- | -| `cc_toolchain` | Info; required cc_toolchain for which we are creating build variables. | +| `cc_toolchain` | Info; required cc\_toolchain for which we are creating build variables. | | `feature_configuration` | [FeatureConfiguration](../builtins/FeatureConfiguration); required Feature configuration to be queried. | -| `source_file` | [File](../builtins/File); or [string](../core/string); or `None`; default is `None` Optional source file path for the compilation. Please prefer passing source_file here over appending it to the end of the command line generated from cc_common.get_memory_inefficient_command_line, as then it's in the power of the toolchain author to properly specify and position compiler flags. | -| `output_file` | [File](../builtins/File); or [string](../core/string); or `None`; default is `None` Optional output file path of the compilation. Please prefer passing output_file here over appending it to the end of the command line generated from cc_common.get_memory_inefficient_command_line, as then it's in the power of the toolchain author to properly specify and position compiler flags. | +| `source_file` | [File](../builtins/File); or [string](../core/string); or `None`; default is `None` Optional source file path for the compilation. Please prefer passing source\_file here over appending it to the end of the command line generated from cc\_common.get\_memory\_inefficient\_command\_line, as then it's in the power of the toolchain author to properly specify and position compiler flags. | +| `output_file` | [File](../builtins/File); or [string](../core/string); or `None`; default is `None` Optional output file path of the compilation. Please prefer passing output\_file here over appending it to the end of the command line generated from cc\_common.get\_memory\_inefficient\_command\_line, as then it's in the power of the toolchain author to properly specify and position compiler flags. | | `user_compile_flags` | [sequence](../core/list) of [string](../core/string)s; or `None`; default is `None` List of additional compilation flags (copts). | | `include_directories` | [depset](../builtins/depset); or `None`; default is `None` Depset of include directories. | | `quote_include_directories` | [depset](../builtins/depset); or `None`; default is `None` Depset of quote include directories. | @@ -201,7 +201,7 @@ Returns variables used for compilation actions. | `add_legacy_cxx_options` | [bool](../core/bool); default is `False` Unused. | | `variables_extension` | [dict](../core/dict); default is `unbound` A dictionary of additional variables used by compile actions. | -## create_library_to_link +## create\_library\_to\_link ``` LibraryToLink cc_common.create_library_to_link(*, actions, feature_configuration=None, cc_toolchain=None, static_library=None, pic_static_library=None, dynamic_library=None, interface_library=None, pic_objects=unbound, objects=unbound, alwayslink=False, dynamic_library_symlink_path='', interface_library_symlink_path='') @@ -222,11 +222,11 @@ Creates `LibraryToLink` | `interface_library` | [File](../builtins/File); or `None`; default is `None` `File` of interface library to be linked. | | `pic_objects` | [sequence](../core/list) of [File](../builtins/File)s; default is `unbound` Experimental, do not use | | `objects` | [sequence](../core/list) of [File](../builtins/File)s; default is `unbound` Experimental, do not use | -| `alwayslink` | [bool](../core/bool); default is `False` Whether to link the static library/objects in the --whole_archive block. | +| `alwayslink` | [bool](../core/bool); default is `False` Whether to link the static library/objects in the --whole\_archive block. | | `dynamic_library_symlink_path` | [string](../core/string); default is `''` Override the default path of the dynamic library link in the solib directory. Empty string to use the default. | | `interface_library_symlink_path` | [string](../core/string); default is `''` Override the default path of the interface library link in the solib directory. Empty string to use the default. | -## create_link_variables +## create\_link\_variables ``` Variables cc_common.create_link_variables(*, cc_toolchain, feature_configuration, library_search_directories=[], runtime_library_search_directories=[], user_link_flags=[], output_file=None, param_file=None, is_using_linker=True, is_linking_dynamic_library=False, must_keep_debug=True, use_test_only_flags=False, is_static_linking_mode=True) @@ -238,20 +238,20 @@ Returns link variables used for linking actions. | Parameter | Description | | --- | --- | -| `cc_toolchain` | Info; required cc_toolchain for which we are creating build variables. | +| `cc_toolchain` | Info; required cc\_toolchain for which we are creating build variables. | | `feature_configuration` | [FeatureConfiguration](../builtins/FeatureConfiguration); required Feature configuration to be queried. | | `library_search_directories` | [depset](../builtins/depset); default is `[]` Depset of directories where linker will look for libraries at link time. | | `runtime_library_search_directories` | [depset](../builtins/depset); default is `[]` Depset of directories where loader will look for libraries at runtime. | | `user_link_flags` | [sequence](../core/list); default is `[]` List of additional link flags (linkopts). | | `output_file` | default is `None` Optional output file path. | | `param_file` | default is `None` Optional param file path. | -| `is_using_linker` | [bool](../core/bool); default is `True` True when using linker, False when archiver. Caller is responsible for keeping this in sync with action name used (is_using_linker = True for linking executable or dynamic library, is_using_linker = False for archiving static library). | +| `is_using_linker` | [bool](../core/bool); default is `True` True when using linker, False when archiver. Caller is responsible for keeping this in sync with action name used (is\_using\_linker = True for linking executable or dynamic library, is\_using\_linker = False for archiving static library). | | `is_linking_dynamic_library` | [bool](../core/bool); default is `False` True when creating dynamic library, False when executable or static library. Caller is responsible for keeping this in sync with action name used. This field will be removed once b/65151735 is fixed. | -| `must_keep_debug` | [bool](../core/bool); default is `True` When set to False, bazel will expose 'strip_debug_symbols' variable, which is usually used to use the linker to strip debug symbols from the output file. | -| `use_test_only_flags` | [bool](../core/bool); default is `False` When set to true, 'is_cc_test' variable will be set. | +| `must_keep_debug` | [bool](../core/bool); default is `True` When set to False, bazel will expose 'strip\_debug\_symbols' variable, which is usually used to use the linker to strip debug symbols from the output file. | +| `use_test_only_flags` | [bool](../core/bool); default is `False` When set to true, 'is\_cc\_test' variable will be set. | | `is_static_linking_mode` | [bool](../core/bool); default is `True` Unused. | -## create_linker_input +## create\_linker\_input ``` LinkerInput cc_common.create_linker_input(*, owner, libraries=None, user_link_flags=None, additional_inputs=None) @@ -265,10 +265,10 @@ Creates a `LinkerInput`. | --- | --- | | `owner` | [Label](../builtins/Label); required The label of the target that produced all files used in this input. | | `libraries` | `None`; or [depset](../builtins/depset); default is `None` List of `LibraryToLink`. | -| `user_link_flags` | `None`; or [depset](../builtins/depset) of [string](../core/string)s; or [sequence](../core/list) of [string](../core/string)s; default is `None` User link flags passed as strings. Accepts either [String], [[String]] or depset(String). The latter is discouraged as it's only kept for compatibility purposes, the depset is flattened. If you want to propagate user_link_flags via unflattened depsets() wrap them in a LinkerInput so that they are not flattened till the end. | +| `user_link_flags` | `None`; or [depset](../builtins/depset) of [string](../core/string)s; or [sequence](../core/list) of [string](../core/string)s; default is `None` User link flags passed as strings. Accepts either [String], [[String]] or depset(String). The latter is discouraged as it's only kept for compatibility purposes, the depset is flattened. If you want to propagate user\_link\_flags via unflattened depsets() wrap them in a LinkerInput so that they are not flattened till the end. | | `additional_inputs` | `None`; or [depset](../builtins/depset); default is `None` For additional inputs to the linking action, e.g.: linking scripts. | -## create_linking_context +## create\_linking\_context ``` LinkingContext cc_common.create_linking_context(*, linker_inputs) @@ -282,7 +282,7 @@ Creates a `LinkingContext`. | --- | --- | | `linker_inputs` | [depset](../builtins/depset); required Depset of `LinkerInput`. | -## create_linking_context_from_compilation_outputs +## create\_linking\_context\_from\_compilation\_outputs ``` tuple cc_common.create_linking_context_from_compilation_outputs(*, actions, name, feature_configuration, cc_toolchain, language='c++', disallow_static_libraries=False, disallow_dynamic_library=False, compilation_outputs, linking_contexts=[], user_link_flags=[], alwayslink=False, additional_inputs=[], variables_extension=unbound) @@ -308,7 +308,7 @@ Should be used for creating library rules that can propagate information downstr | `additional_inputs` | [sequence](../core/list); default is `[]` For additional inputs to the linking action, e.g.: linking scripts. | | `variables_extension` | [dict](../core/dict); default is `unbound` Additional variables to pass to the toolchain configuration when creating link command line. | -## create_lto_compilation_context +## create\_lto\_compilation\_context ``` LtoCompilationContext cc_common.create_lto_compilation_context(*, objects={}) @@ -322,15 +322,15 @@ Create LTO compilation context | --- | --- | | `objects` | [dict](../core/dict); default is `{}` map of full object to index object | -## do_not_use_tools_cpp_compiler_present +## do\_not\_use\_tools\_cpp\_compiler\_present ``` None cc_common.do_not_use_tools_cpp_compiler_present ``` -Do not use this field, its only purpose is to help with migration from config_setting.values{'compiler') to config_settings.flag_values{'@bazel_tools//tools/cpp:compiler'} +Do not use this field, its only purpose is to help with migration from config\_setting.values{'compiler') to config\_settings.flag\_values{'@bazel\_tools//tools/cpp:compiler'} -## get_environment_variables +## get\_environment\_variables ``` dict cc_common.get_environment_variables(*, feature_configuration, action_name, variables) @@ -343,10 +343,10 @@ Returns environment variables to be set for given action. | Parameter | Description | | --- | --- | | `feature_configuration` | [FeatureConfiguration](../builtins/FeatureConfiguration); required Feature configuration to be queried. | -| `action_name` | [string](../core/string); required Name of the action. Has to be one of the names in @bazel_tools//tools/build_defs/cc:action_names.bzl (https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/cc/action_names.bzl) | +| `action_name` | [string](../core/string); required Name of the action. Has to be one of the names in @bazel\_tools//tools/build\_defs/cc:action\_names.bzl (https://github.com/bazelbuild/bazel/blob/master/tools/build\_defs/cc/action\_names.bzl) | | `variables` | Variables; required Build variables to be used for template expansion. | -## get_execution_requirements +## get\_execution\_requirements ``` sequence cc_common.get_execution_requirements(*, feature_configuration, action_name) @@ -359,9 +359,9 @@ Returns execution requirements for given action. | Parameter | Description | | --- | --- | | `feature_configuration` | [FeatureConfiguration](../builtins/FeatureConfiguration); required Feature configuration to be queried. | -| `action_name` | [string](../core/string); required Name of the action. Has to be one of the names in @bazel_tools//tools/build_defs/cc:action_names.bzl (https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/cc/action_names.bzl) | +| `action_name` | [string](../core/string); required Name of the action. Has to be one of the names in @bazel\_tools//tools/build\_defs/cc:action\_names.bzl (https://github.com/bazelbuild/bazel/blob/master/tools/build\_defs/cc/action\_names.bzl) | -## get_memory_inefficient_command_line +## get\_memory\_inefficient\_command\_line ``` sequence cc_common.get_memory_inefficient_command_line(*, feature_configuration, action_name, variables) @@ -374,10 +374,10 @@ Returns flattened command line flags for given action, using given variables for | Parameter | Description | | --- | --- | | `feature_configuration` | [FeatureConfiguration](../builtins/FeatureConfiguration); required Feature configuration to be queried. | -| `action_name` | [string](../core/string); required Name of the action. Has to be one of the names in @bazel_tools//tools/build_defs/cc:action_names.bzl (https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/cc/action_names.bzl) | +| `action_name` | [string](../core/string); required Name of the action. Has to be one of the names in @bazel\_tools//tools/build\_defs/cc:action\_names.bzl (https://github.com/bazelbuild/bazel/blob/master/tools/build\_defs/cc/action\_names.bzl) | | `variables` | Variables; required Build variables to be used for template expansions. | -## get_tool_for_action +## get\_tool\_for\_action ``` string cc_common.get_tool_for_action(*, feature_configuration, action_name) @@ -390,9 +390,9 @@ Returns tool path for given action. | Parameter | Description | | --- | --- | | `feature_configuration` | [FeatureConfiguration](../builtins/FeatureConfiguration); required Feature configuration to be queried. | -| `action_name` | [string](../core/string); required Name of the action. Has to be one of the names in @bazel_tools//tools/build_defs/cc:action_names.bzl (https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/cc/action_names.bzl) | +| `action_name` | [string](../core/string); required Name of the action. Has to be one of the names in @bazel\_tools//tools/build\_defs/cc:action\_names.bzl (https://github.com/bazelbuild/bazel/blob/master/tools/build\_defs/cc/action\_names.bzl) | -## is_enabled +## is\_enabled ``` bool cc_common.is_enabled(*, feature_configuration, feature_name) @@ -424,17 +424,17 @@ Should be used for C++ transitive linking. | `feature_configuration` | [FeatureConfiguration](../builtins/FeatureConfiguration); required `feature_configuration` to be queried. | | `cc_toolchain` | Info; required `CcToolchainInfo` provider to be used. | | `language` | [string](../core/string); default is `'c++'` Only C++ supported for now. Do not use this parameter. | -| `output_type` | [string](../core/string); default is `'executable'` Can be either 'executable' or 'dynamic_library'. | +| `output_type` | [string](../core/string); default is `'executable'` Can be either 'executable' or 'dynamic\_library'. | | `link_deps_statically` | [bool](../core/bool); default is `True` True to link dependencies statically, False dynamically. | | `compilation_outputs` | [CcCompilationOutputs](../builtins/CcCompilationOutputs); or `None`; default is `None` Compilation outputs containing object files to link. | | `linking_contexts` | [sequence](../core/list); default is `[]` Linking contexts from dependencies to be linked into the linking context generated by this rule. | | `user_link_flags` | [sequence](../core/list); default is `[]` Additional list of linker options. | -| `stamp` | [int](../core/int); default is `0` Whether to include build information in the linked executable, if output_type is 'executable'. If 1, build information is always included. If 0 (the default build information is always excluded. If -1, uses the default behavior, which may be overridden by the --[no]stamp flag. This should be unset (or set to 0) when generating the executable output for test rules. | +| `stamp` | [int](../core/int); default is `0` Whether to include build information in the linked executable, if output\_type is 'executable'. If 1, build information is always included. If 0 (the default build information is always excluded. If -1, uses the default behavior, which may be overridden by the --[no]stamp flag. This should be unset (or set to 0) when generating the executable output for test rules. | | `additional_inputs` | [sequence](../core/list); or [depset](../builtins/depset); default is `[]` For additional inputs to the linking action, e.g.: linking scripts. | | `additional_outputs` | [sequence](../core/list); default is `[]` For additional outputs to the linking action, e.g.: map files. | | `variables_extension` | [dict](../core/dict); default is `{}` Additional variables to pass to the toolchain configuration when create link command line. | -## merge_cc_infos +## merge\_cc\_infos ``` unknown cc_common.merge_cc_infos(*, direct_cc_infos=[], cc_infos=[]) @@ -449,7 +449,7 @@ Merges multiple `CcInfo`s into one. | `direct_cc_infos` | [sequence](../core/list); default is `[]` List of `CcInfo`s to be merged, whose headers will be exported by the direct fields in the returned provider. | | `cc_infos` | [sequence](../core/list); default is `[]` List of `CcInfo`s to be merged, whose headers will not be exported by the direct fields in the returned provider. | -## merge_compilation_contexts +## merge\_compilation\_contexts ``` CompilationContext cc_common.merge_compilation_contexts(*, compilation_contexts=[]) @@ -463,7 +463,7 @@ Merges multiple `CompilationContexts`s into one. | --- | --- | | `compilation_contexts` | [sequence](../core/list); default is `[]` List of `CompilationContexts`s to be merged. The headers of each context will be exported by the direct fields in the returned provider. | -## merge_compilation_outputs +## merge\_compilation\_outputs ``` CcCompilationOutputs cc_common.merge_compilation_outputs(*, compilation_outputs=[]) diff --git a/rules/lib/toplevel/config.mdx b/rules/lib/toplevel/config.mdx index 77810340..3ecd7c43 100644 --- a/rules/lib/toplevel/config.mdx +++ b/rules/lib/toplevel/config.mdx @@ -21,8 +21,8 @@ ex: the following rule is marked as a build setting by setting the `build_settin * [int](#int) * [none](#none) * [string](#string) -* [string_list](#string_list) -* [string_set](#string_set) +* [string\_list](#string_list) +* [string\_set](#string_set) * [target](#target) ## bool @@ -90,7 +90,7 @@ A string-typed build setting | `flag` | [bool](../core/bool); default is `False` Whether or not this build setting is callable on the command line. | | `allow_multiple` | [bool](../core/bool); default is `False` Deprecated, use a `string_list` setting with `repeatable = True` instead. If set, this flag is allowed to be set multiple times on the command line. The Value of the flag as accessed in transitions and build setting implementation function will be a list of strings. Insertion order and repeated values are both maintained. This list can be post-processed in the build setting implementation function if different behavior is desired. | -## string_list +## string\_list ``` BuildSetting config.string_list(*, flag=False, repeatable=False) @@ -105,7 +105,7 @@ A string list-typed build setting. On the command line pass a list using comma-s | `flag` | [bool](../core/bool); default is `False` Whether or not this build setting is callable on the command line. | | `repeatable` | [bool](../core/bool); default is `False` If set, instead of expecting a comma-separated value, this flag is allowed to be set multiple times on the command line with each individual value treated as a single string to add to the list value. Insertion order and repeated values are both maintained. This list can be post-processed in the build setting implementation function if different behavior is desired. | -## string_set +## string\_set ``` BuildSetting config.string_set(*, flag=False, repeatable=False) diff --git a/rules/lib/toplevel/config_common.mdx b/rules/lib/toplevel/config_common.mdx index ffdab483..9169b17a 100644 --- a/rules/lib/toplevel/config_common.mdx +++ b/rules/lib/toplevel/config_common.mdx @@ -1,5 +1,5 @@ --- -title: 'config_common' +title: 'config\_common' --- Functions for Starlark to interact with Blaze's configurability APIs. @@ -7,7 +7,7 @@ Functions for Starlark to interact with Blaze's configurability APIs. ## Members * [FeatureFlagInfo](#FeatureFlagInfo) -* [toolchain_type](#toolchain_type) +* [toolchain\_type](#toolchain_type) ## FeatureFlagInfo @@ -15,9 +15,9 @@ Functions for Starlark to interact with Blaze's configurability APIs. Provider config_common.FeatureFlagInfo ``` -The key used to retrieve the provider containing config_feature_flag's value. +The key used to retrieve the provider containing config\_feature\_flag's value. -## toolchain_type +## toolchain\_type ``` toolchain_type config_common.toolchain_type(name, *, mandatory=True) diff --git a/rules/lib/toplevel/coverage_common.mdx b/rules/lib/toplevel/coverage_common.mdx index 752f64d4..d29ebc2a 100644 --- a/rules/lib/toplevel/coverage_common.mdx +++ b/rules/lib/toplevel/coverage_common.mdx @@ -1,14 +1,14 @@ --- -title: 'coverage_common' +title: 'coverage\_common' --- Helper functions to access coverage-related infrastructure. ## Members -* [instrumented_files_info](#instrumented_files_info) +* [instrumented\_files\_info](#instrumented_files_info) -## instrumented_files_info +## instrumented\_files\_info ``` InstrumentedFilesInfo coverage_common.instrumented_files_info(ctx, *, source_attributes=[], dependency_attributes=[], extensions=None, metadata_files=[], baseline_coverage_files=None) @@ -23,6 +23,6 @@ Creates a new [InstrumentedFilesInfo](../providers/InstrumentedFilesInfo) instan | `ctx` | [ctx](../builtins/ctx); required The rule context. | | `source_attributes` | [sequence](../core/list); default is `[]` A list of attribute names which contain source files processed by this rule. | | `dependency_attributes` | [sequence](../core/list); default is `[]` A list of attribute names which might provide runtime dependencies (either code dependencies or runfiles). | -| `extensions` | [sequence](../core/list) of [string](../core/string)s; or `None`; default is `None` File extensions used to filter files from source_attributes. For example, 'js'. If not provided (or None), then all files from source_attributes will be added to instrumented files, if an empty list is provided, then no files from source attributes will be added. | +| `extensions` | [sequence](../core/list) of [string](../core/string)s; or `None`; default is `None` File extensions used to filter files from source\_attributes. For example, 'js'. If not provided (or None), then all files from source\_attributes will be added to instrumented files, if an empty list is provided, then no files from source attributes will be added. | | `metadata_files` | [sequence](../core/list) of [File](../builtins/File)s; default is `[]` Additional files required to generate coverage LCOV files after code execution. e.g. .gcno files for C++. | | `baseline_coverage_files` | [sequence](../core/list) of [File](../builtins/File)s; or `None`; default is `None` | \ No newline at end of file diff --git a/rules/lib/toplevel/java_common.mdx b/rules/lib/toplevel/java_common.mdx index 5ca3eb0e..4364854c 100644 --- a/rules/lib/toplevel/java_common.mdx +++ b/rules/lib/toplevel/java_common.mdx @@ -1,5 +1,5 @@ --- -title: 'java_common' +title: 'java\_common' --- Utilities for Java compilation support in Starlark. @@ -11,9 +11,9 @@ Utilities for Java compilation support in Starlark. * [JavaRuntimeInfo](#JavaRuntimeInfo) * [JavaToolchainInfo](#JavaToolchainInfo) * [merge](#merge) -* [pack_sources](#pack_sources) -* [run_ijar](#run_ijar) -* [stamp_jar](#stamp_jar) +* [pack\_sources](#pack_sources) +* [run\_ijar](#run_ijar) +* [stamp\_jar](#stamp_jar) ## BootClassPathInfo @@ -26,7 +26,7 @@ The provider used to supply bootclasspath information ## compile ``` -JavaInfo java_common.compile(ctx, *, source_jars=[], source_files=[], output, output_source_jar=None, javac_opts=[], deps=[], runtime_deps=[], exports=[], plugins=[], exported_plugins=[], native_libraries=[], annotation_processor_additional_inputs=[], annotation_processor_additional_outputs=[], strict_deps='ERROR', java_toolchain, bootclasspath=None, sourcepath=[], resources=[], resource_jars=[], classpath_resources=[], neverlink=False, enable_annotation_processing=True, enable_compile_jar_action=True, add_exports=[], add_opens=[]) +struct java_common.compile(ctx, *, source_jars=[], source_files=[], output, output_source_jar=None, javac_opts=[], deps=[], runtime_deps=[], exports=[], plugins=[], exported_plugins=[], native_libraries=[], annotation_processor_additional_inputs=[], annotation_processor_additional_outputs=[], strict_deps='ERROR', java_toolchain, bootclasspath=None, sourcepath=[], resources=[], resource_jars=[], classpath_resources=[], neverlink=False, enable_annotation_processing=True, enable_compile_jar_action=True, add_exports=[], add_opens=[]) ``` Compiles Java source files/jars from the implementation of a Starlark rule and returns a provider that represents the results of the compilation and can be added to the set of providers emitted by this rule. @@ -36,28 +36,28 @@ Compiles Java source files/jars from the implementation of a Starlark rule and r | Parameter | Description | | --- | --- | | `ctx` | [ctx](../builtins/ctx); required The rule context. | -| `source_jars` | [sequence](../core/list) of [File](../builtins/File)s; default is `[]` A list of the jars to be compiled. At least one of source_jars or source_files should be specified. | -| `source_files` | [sequence](../core/list) of [File](../builtins/File)s; default is `[]` A list of the Java source files to be compiled. At least one of source_jars or source_files should be specified. | +| `source_jars` | [sequence](../core/list) of [File](../builtins/File)s; default is `[]` A list of the jars to be compiled. At least one of source\_jars or source\_files should be specified. | +| `source_files` | [sequence](../core/list) of [File](../builtins/File)s; default is `[]` A list of the Java source files to be compiled. At least one of source\_jars or source\_files should be specified. | | `output` | [File](../builtins/File); required | -| `output_source_jar` | [File](../builtins/File); or `None`; default is `None` The output source jar. Defaults to `{output_jar}-src.jar` if unset. | +| `output_source_jar` | [File](../builtins/File); or `None`; default is `None` The output source jar. Defaults to `{output\_jar}-src.jar` if unset. | | `javac_opts` | [sequence](../core/list) of [string](../core/string)s; default is `[]` A list of the desired javac options. | -| `deps` | [sequence](../core/list) of [JavaInfo](../providers/JavaInfo)s; default is `[]` A list of dependencies. | -| `runtime_deps` | [sequence](../core/list) of [JavaInfo](../providers/JavaInfo)s; default is `[]` A list of runtime dependencies. | -| `exports` | [sequence](../core/list) of [JavaInfo](../providers/JavaInfo)s; default is `[]` A list of exports. | -| `plugins` | [sequence](../core/list) of [JavaPluginInfo](../providers/JavaPluginInfo)s; or [sequence](../core/list) of [JavaInfo](../providers/JavaInfo)s; default is `[]` A list of plugins. | -| `exported_plugins` | [sequence](../core/list) of [JavaPluginInfo](../providers/JavaPluginInfo)s; or [sequence](../core/list) of [JavaInfo](../providers/JavaInfo)s; default is `[]` A list of exported plugins. | +| `deps` | [sequence](../core/list) of [struct](../builtins/struct)s; default is `[]` A list of dependencies. | +| `runtime_deps` | [sequence](../core/list) of [struct](../builtins/struct)s; default is `[]` A list of runtime dependencies. | +| `exports` | [sequence](../core/list) of [struct](../builtins/struct)s; default is `[]` A list of exports. | +| `plugins` | [sequence](../core/list) of [struct](../builtins/struct)s; or [sequence](../core/list) of [struct](../builtins/struct)s; default is `[]` A list of plugins. | +| `exported_plugins` | [sequence](../core/list) of [struct](../builtins/struct)s; or [sequence](../core/list) of [struct](../builtins/struct)s; default is `[]` A list of exported plugins. | | `native_libraries` | [sequence](../core/list) of [CcInfo](../providers/CcInfo)s; default is `[]` CC native library dependencies that are needed for this library. | | `annotation_processor_additional_inputs` | [sequence](../core/list) of [File](../builtins/File)s; default is `[]` A list of inputs that the Java compilation action will take in addition to the Java sources for annotation processing. | | `annotation_processor_additional_outputs` | [sequence](../core/list) of [File](../builtins/File)s; default is `[]` A list of outputs that the Java compilation action will output in addition to the class jar from annotation processing. | -| `strict_deps` | [string](../core/string); default is `'ERROR'` A string that specifies how to handle strict deps. Possible values: 'OFF', 'ERROR', 'WARN' and 'DEFAULT'. For more details see [`--strict_java_depsflag`](/docs/user-manual#flag--strict_java_deps). By default 'ERROR'. | +| `strict_deps` | [string](../core/string); default is `'ERROR'` A string that specifies how to handle strict deps. Possible values: 'OFF', 'ERROR', 'WARN' and 'DEFAULT'. For more details see [`--strict_java_deps flag`](/docs/user-manual#flag--strict_java_deps). By default 'ERROR'. | | `java_toolchain` | Info; required A JavaToolchainInfo to be used for this compilation. Mandatory. | -| `bootclasspath` | default is `None` A BootClassPathInfo to be used for this compilation. If present, overrides the bootclasspath associated with the provided java_toolchain. | +| `bootclasspath` | default is `None` A BootClassPathInfo to be used for this compilation. If present, overrides the bootclasspath associated with the provided java\_toolchain. | | `sourcepath` | [sequence](../core/list) of [File](../builtins/File)s; default is `[]` | | `resources` | [sequence](../core/list) of [File](../builtins/File)s; default is `[]` | | `resource_jars` | [sequence](../core/list) of [File](../builtins/File)s; default is `[]` | | `classpath_resources` | [sequence](../core/list) of [File](../builtins/File)s; default is `[]` | | `neverlink` | [bool](../core/bool); default is `False` | -| `enable_annotation_processing` | [bool](../core/bool); default is `True` Disables annotation processing in this compilation, causing any annotation processors provided in plugins or in exported_plugins of deps to be ignored. | +| `enable_annotation_processing` | [bool](../core/bool); default is `True` Disables annotation processing in this compilation, causing any annotation processors provided in plugins or in exported\_plugins of deps to be ignored. | | `enable_compile_jar_action` | [bool](../core/bool); default is `True` Enables header compilation or ijar creation. If set to False, it forces use of the full class jar in the compilation classpaths of any dependants. Doing so is intended for use by non-library targets such as binaries that do not have dependants. | | `add_exports` | [sequence](../core/list) of [string](../core/string)s; default is `[]` Allow this library to access the given /. | | `add_opens` | [sequence](../core/list) of [string](../core/string)s; default is `[]` Allow this library to reflectively access the given /. | @@ -81,7 +81,7 @@ The key used to retrieve the provider that contains information about the Java t ## merge ``` -JavaInfo java_common.merge(providers) +struct java_common.merge(providers) ``` Merges the given providers into a single JavaInfo. @@ -90,9 +90,9 @@ Merges the given providers into a single JavaInfo. | Parameter | Description | | --- | --- | -| `providers` | [sequence](../core/list) of [JavaInfo](../providers/JavaInfo)s; required The list of providers to merge. | +| `providers` | [sequence](../core/list) of [struct](../builtins/struct)s; required The list of providers to merge. | -## pack_sources +## pack\_sources ``` File java_common.pack_sources(actions, *, output_source_jar=None, sources=[], source_jars=[], java_toolchain) @@ -102,7 +102,7 @@ Packs sources and source jars into a single source jar file. The return value is `JavaInfo#source_jar` -.At least one of parameters output_jar or output_source_jar is required. +.At least one of parameters output\_jar or output\_source\_jar is required. ### Parameters @@ -114,7 +114,7 @@ Packs sources and source jars into a single source jar file. The return value is | `source_jars` | [sequence](../core/list) of [File](../builtins/File)s; default is `[]` A list of source jars to be packed into the source jar. | | `java_toolchain` | Info; required A JavaToolchainInfo to used to find the ijar tool. | -## run_ijar +## run\_ijar ``` File java_common.run_ijar(actions, *, jar, target_label=None, java_toolchain) @@ -131,7 +131,7 @@ Runs ijar on a jar, stripping it of its method bodies. This helps reduce rebuild | `target_label` | [Label](../builtins/Label); or `None`; default is `None` A target label to stamp the jar with. Used for `add_dep` support. Typically, you would pass `ctx.label` to stamp the jar with the current rule's label. | | `java_toolchain` | Info; required A JavaToolchainInfo to used to find the ijar tool. | -## stamp_jar +## stamp\_jar ``` File java_common.stamp_jar(actions, *, jar, target_label, java_toolchain) @@ -144,6 +144,6 @@ Stamps a jar with a target label for `add_dep` support. The return value is typi | Parameter | Description | | --- | --- | | `actions` | [actions](../builtins/actions); required ctx.actions | -| `jar` | [File](../builtins/File); required The jar to run stamp_jar on. | +| `jar` | [File](../builtins/File); required The jar to run stamp\_jar on. | | `target_label` | [Label](../builtins/Label); required A target label to stamp the jar with. Used for `add_dep` support. Typically, you would pass `ctx.label` to stamp the jar with the current rule's label. | -| `java_toolchain` | Info; required A JavaToolchainInfo to used to find the stamp_jar tool. | \ No newline at end of file +| `java_toolchain` | Info; required A JavaToolchainInfo to used to find the stamp\_jar tool. | \ No newline at end of file diff --git a/rules/lib/toplevel/native.mdx b/rules/lib/toplevel/native.mdx index c269d6bf..0e317499 100644 --- a/rules/lib/toplevel/native.mdx +++ b/rules/lib/toplevel/native.mdx @@ -7,21 +7,21 @@ The following functions are also available: ## Members -* [existing_rule](#existing_rule) -* [existing_rules](#existing_rules) -* [exports_files](#exports_files) +* [existing\_rule](#existing_rule) +* [existing\_rules](#existing_rules) +* [exports\_files](#exports_files) * [glob](#glob) -* [module_name](#module_name) -* [module_version](#module_version) -* [package_default_visibility](#package_default_visibility) -* [package_group](#package_group) -* [package_name](#package_name) -* [package_relative_label](#package_relative_label) -* [repo_name](#repo_name) -* [repository_name](#repository_name) +* [module\_name](#module_name) +* [module\_version](#module_version) +* [package\_default\_visibility](#package_default_visibility) +* [package\_group](#package_group) +* [package\_name](#package_name) +* [package\_relative\_label](#package_relative_label) +* [repo\_name](#repo_name) +* [repository\_name](#repository_name) * [subpackages](#subpackages) -## existing_rule +## existing\_rule ``` unknown native.existing_rule(name) @@ -49,7 +49,7 @@ If possible, use this function only in [implementation functions of rule finaliz | --- | --- | | `name` | [string](../core/string); required | -## existing_rules +## existing\_rules ``` unknown native.existing_rules() @@ -61,7 +61,7 @@ Here, an *immutable dict-like object* means a deeply immutable object `x` suppor If possible, use this function only in [implementation functions of rule finalizer symbolic macros](https://bazel.build/extending/macros#finalizers). Use of this function in other contexts is not recommened, and will be disabled in a future Bazel release; it makes `BUILD` files brittle and order-dependent. -## exports_files +## exports\_files ``` None native.exports_files(srcs, visibility=None, licenses=None) @@ -97,9 +97,9 @@ If the `exclude_directories` argument is enabled (set to `1`), files of type dir | `include` | [sequence](../core/list) of [string](../core/string)s; default is `[]` The list of glob patterns to include. | | `exclude` | [sequence](../core/list) of [string](../core/string)s; default is `[]` The list of glob patterns to exclude. | | `exclude_directories` | [int](../core/int); default is `1` A flag whether to exclude directories or not. | -| `allow_empty` | default is `unbound` Whether we allow glob patterns to match nothing. If `allow_empty` is False, each individual include pattern must match something and also the final result must be non-empty (after the matches of the `exclude` patterns are excluded). | +| `allow_empty` | default is `unbound` Whether we allow glob patterns to match nothing. If `allow\_empty` is False, each individual include pattern must match something and also the final result must be non-empty (after the matches of the `exclude` patterns are excluded). | -## module_name +## module\_name ``` string native.module_name() @@ -108,7 +108,7 @@ string native.module_name() The name of the Bazel module associated with the repo this package is in. If this package is from a repo defined in WORKSPACE instead of MODULE.bazel, this is empty. For repos generated by module extensions, this is the name of the module hosting the extension. It's the same as the `module.name` field seen in `module_ctx.modules`. May return `None`. -## module_version +## module\_version ``` string native.module_version() @@ -117,7 +117,7 @@ string native.module_version() The version of the Bazel module associated with the repo this package is in. If this package is from a repo defined in WORKSPACE instead of MODULE.bazel, this is empty. For repos generated by module extensions, this is the version of the module hosting the extension. It's the same as the `module.version` field seen in `module_ctx.modules`. May return `None`. -## package_default_visibility +## package\_default\_visibility ``` List native.package_default_visibility() @@ -125,7 +125,7 @@ List native.package_default_visibility() Returns the default visibility of the package being evaluated. This is the value of the `default_visibility` parameter of `package()`, extended to include the package itself. -## package_group +## package\_group ``` None native.package_group(*, name, packages=[], includes=[]) @@ -141,7 +141,7 @@ This function defines a set of packages and assigns a label to the group. The la | `packages` | [sequence](../core/list) of [string](../core/string)s; default is `[]` A complete enumeration of packages in this group. | | `includes` | [sequence](../core/list) of [string](../core/string)s; default is `[]` Other package groups that are included in this one. | -## package_name +## package\_name ``` string native.package_name() @@ -149,7 +149,7 @@ string native.package_name() The name of the package being evaluated, without the repository name. For example, in the BUILD file `some/package/BUILD`, its value will be `some/package`. If the BUILD file calls a function defined in a .bzl file, `package_name()` will match the caller BUILD file package. The value will always be an empty string for the root package. -## package_relative_label +## package\_relative\_label ``` Label native.package_relative_label(input) @@ -161,7 +161,7 @@ This function may only be called while evaluating a BUILD file and the macros it The result of this function is the same `Label` value as would be produced by passing the given string to a label-valued attribute of a target declared in the BUILD file. -*Usage note:* The difference between this function and [`Label()`](../builtins/Label#Label) is that `Label()` uses the context of the package of the `.bzl` file that called it, not the package of the `BUILD` file. Use `Label()` when you need to refer to a fixed target that is hardcoded into the macro, such as a compiler. Use `package_relative_label()` when you need to normalize a label string supplied by the BUILD file to a `Label` object. (There is no way to convert a string to a `Label` in the context of a package other than the BUILD file or the calling .bzl file. For that reason, outer macros should always prefer to pass Label objects to inner macros rather than label strings.)[`ctx.package_relative_label()`](ctx#package_relative_label) provides the same functionality within a rule or aspect implementation function. +*Usage note:* The difference between this function and [Label()](../builtins/Label#Label) is that `Label()` uses the context of the package of the `.bzl` file that called it, not the package of the `BUILD` file. Use `Label()` when you need to refer to a fixed target that is hardcoded into the macro, such as a compiler. Use `package_relative_label()` when you need to normalize a label string supplied by the BUILD file to a `Label` object. (There is no way to convert a string to a `Label` in the context of a package other than the BUILD file or the calling .bzl file. For that reason, outer macros should always prefer to pass Label objects to inner macros rather than label strings.)[`ctx.package_relative_label()`](ctx#package_relative_label) provides the same functionality within a rule or aspect implementation function. ### Parameters @@ -169,7 +169,7 @@ The result of this function is the same `Label` value as would be produced by pa | --- | --- | | `input` | [string](../core/string); or [Label](../builtins/Label); required The input label string or Label object. If a Label object is passed, it's returned as is. | -## repo_name +## repo\_name ``` string native.repo_name() @@ -177,7 +177,7 @@ string native.repo_name() The canonical name of the repository containing the package currently being evaluated, with no leading at-signs. -## repository_name +## repository\_name ``` string native.repository_name() @@ -194,7 +194,7 @@ The canonical name of the repository containing the package currently being eval sequence native.subpackages(*, include, exclude=[], allow_empty=False) ``` -Returns a new mutable list of every direct subpackage of the current package, regardless of file-system directory depth. List returned is sorted and contains the names of subpackages relative to the current package. It is advised to prefer using the methods in bazel_skylib.subpackages module rather than calling this function directly. +Returns a new mutable list of every direct subpackage of the current package, regardless of file-system directory depth. List returned is sorted and contains the names of subpackages relative to the current package. It is advised to prefer using the methods in bazel\_skylib.subpackages module rather than calling this function directly. ### Parameters diff --git a/rules/lib/toplevel/platform_common.mdx b/rules/lib/toplevel/platform_common.mdx index 098f56fb..17edc7c5 100644 --- a/rules/lib/toplevel/platform_common.mdx +++ b/rules/lib/toplevel/platform_common.mdx @@ -1,5 +1,5 @@ --- -title: 'platform_common' +title: 'platform\_common' --- Functions for Starlark to interact with the platform APIs. diff --git a/rules/lib/toplevel/proto.mdx b/rules/lib/toplevel/proto.mdx index 33aad0c0..9ebc97e5 100644 --- a/rules/lib/toplevel/proto.mdx +++ b/rules/lib/toplevel/proto.mdx @@ -6,9 +6,9 @@ A module for protocol message processing. ## Members -* [encode_text](#encode_text) +* [encode\_text](#encode_text) -## encode_text +## encode\_text ``` string proto.encode_text(x) diff --git a/rules/lib/toplevel/testing.mdx b/rules/lib/toplevel/testing.mdx index a9018884..5489113c 100644 --- a/rules/lib/toplevel/testing.mdx +++ b/rules/lib/toplevel/testing.mdx @@ -6,11 +6,11 @@ Helper methods for Starlark to access testing infrastructure. ## Members -* [analysis_test](#analysis_test) +* [analysis\_test](#analysis_test) * [ExecutionInfo](#ExecutionInfo) * [TestEnvironment](#TestEnvironment) -## analysis_test +## analysis\_test ``` None testing.analysis_test(name, implementation, attrs={}, fragments=[], toolchains=[], attr_values={}) @@ -26,7 +26,7 @@ The number of transitive dependencies of the test are limited. The limit is cont | --- | --- | | `name` | [string](../core/string); required Name of the target. It should be a Starlark identifier, matching pattern '[A-Za-z\_][A-Za-z0-9\_]\*'. | | `implementation` | [function](../core/function); required The Starlark function implementing this analysis test. It must have exactly one parameter: [ctx](../builtins/ctx). The function is called during the analysis phase. It can access the attributes declared by `attrs` and populated via `attr_values`. The implementation function may not register actions. Instead, it must register a pass/fail result via providing [AnalysisTestResultInfo](../providers/AnalysisTestResultInfo). | -| `attrs` | [dict](../core/dict); default is `{}` Dictionary declaring the attributes. See the [rule](../globals/bzl#rule) call. Attributes are allowed to use configuration transitions defined using [analysis_test_transition](../globals/bzl#analysis_test_transition). | +| `attrs` | [dict](../core/dict); default is `{}` Dictionary declaring the attributes. See the [rule](../globals/bzl#rule) call. Attributes are allowed to use configuration transitions defined using [analysis\_test\_transition](../globals/bzl#analysis_test_transition). | | `fragments` | [sequence](../core/list) of [string](../core/string)s; default is `[]` List of configuration fragments that are available to the implementation of the analysis test. | | `toolchains` | [sequence](../core/list); default is `[]` The set of toolchains the test requires. See the [rule](../globals/bzl#rule) call. | | `attr_values` | [dict](../core/dict) of [string](../core/string)s; default is `{}` Dictionary of attribute values to pass to the implementation. | diff --git a/rules/macro-tutorial.mdx b/rules/macro-tutorial.mdx index b74c34bb..2b3d8e4a 100644 --- a/rules/macro-tutorial.mdx +++ b/rules/macro-tutorial.mdx @@ -7,7 +7,7 @@ title: 'Creating a Symbolic Macro' IMPORTANT: This tutorial is for [*symbolic macros*](/extending/macros) – the new macro system introduced in Bazel 8. If you need to support older Bazel versions, you will want to write a [legacy macro](/extending/legacy-macros) instead; take -a look at [Creating a Legacy Macro](/rules/legacy-macro-tutorial). +a look at [Creating a Legacy Macro](legacy-macro-tutorial). Imagine that you need to run a tool as part of your build. For example, you may want to generate or preprocess a source file, or compress a binary. In this diff --git a/rules/performance.mdx b/rules/performance.mdx index 2fc3568f..c415cf14 100644 --- a/rules/performance.mdx +++ b/rules/performance.mdx @@ -14,10 +14,10 @@ assists you in finding spots where you might have made a mistake. Be warned: The cost of writing an inefficient rule may not be evident until it is in widespread use. -## Use depsets {#use-depsets} +## Use depsets Whenever you are rolling up information from rule dependencies you should use -[depsets](/rules/lib/builtins/depset). Only use plain lists or dicts to publish information +[depsets](lib/depset). Only use plain lists or dicts to publish information local to the current rule. A depset represents information as a nested graph which enables sharing. @@ -72,10 +72,10 @@ def _impl(ctx): See the [depset overview](/extending/depsets) page for more information. -### Avoid calling `depset.to_list()` {#avoid-depset-to-list} +### Avoid calling `depset.to_list()` You can coerce a depset to a flat list using -[`to_list()`](/rules/lib/builtins/depset#to_list), but doing so usually results in O(N^2) +[`to_list()`](lib/depset#to_list), but doing so usually results in O(N^2) cost. If at all possible, avoid any flattening of depsets except for debugging purposes. @@ -85,7 +85,7 @@ accumulated over each level of the build graph. But this is *still* O(N^2) when you build a set of targets with overlapping dependencies. This happens when building your tests `//foo/tests/...`, or when importing an IDE project. -### Reduce the number of calls to `depset` {#reduce-calls-depset} +### Reduce the number of calls to `depset` Calling `depset` inside a loop is often a mistake. It can lead to depsets with very deep nesting, which perform poorly. For example: @@ -115,9 +115,9 @@ This can sometimes be reduced using a list comprehension: x = depset(transitive = [i.deps for i in inputs]) ``` -## Use ctx.actions.args() for command lines {#ctx-actions-args} +## Use ctx.actions.args() for command lines -When building command lines you should use [ctx.actions.args()](/rules/lib/builtins/Args). +When building command lines you should use [ctx.actions.args()](lib/Args). This defers expansion of any depsets to the execution phase. Apart from being strictly faster, this will reduce the memory consumption of @@ -128,11 +128,11 @@ Here are some tricks: * Pass depsets and lists directly as arguments, instead of flattening them yourself. They will get expanded by `ctx.actions.args()` for you. If you need any transformations on the depset contents, look at -[ctx.actions.args#add](/rules/lib/builtins/Args#add) to see if anything fits the bill. +[ctx.actions.args#add](lib/Args#add) to see if anything fits the bill. * Are you passing `File#path` as arguments? No need. Any -[File](/rules/lib/builtins/File) is automatically turned into its -[path](/rules/lib/builtins/File#path), deferred to expansion time. +[File](lib/File) is automatically turned into its +[path](lib/File#path), deferred to expansion time. * Avoid constructing strings by concatenating them together. The best string argument is a constant as its memory will be shared between @@ -140,10 +140,10 @@ all instances of your rule. * If the args are too long for the command line an `ctx.actions.args()` object can be conditionally or unconditionally written to a param file using -[`ctx.actions.args#use_param_file`](/rules/lib/builtins/Args#use_param_file). This is +[`ctx.actions.args#use_param_file`](lib/Args#use_param_file). This is done behind the scenes when the action is executed. If you need to explicitly control the params file you can write it manually using -[`ctx.actions.write`](/rules/lib/builtins/actions#write). +[`ctx.actions.write`](lib/actions#write). Example: @@ -176,9 +176,9 @@ def _to_short_path(f): return f.short_path ``` -## Transitive action inputs should be depsets {#transitive-action-inputs} +## Transitive action inputs should be depsets -When building an action using [ctx.actions.run](/rules/lib/builtins/actions#run), do not +When building an action using [ctx.actions.run](lib/actions?#run), do not forget that the `inputs` field accepts a depset. Use this whenever inputs are collected from dependencies transitively. @@ -190,7 +190,7 @@ ctx.actions.run( ) ``` -## Hanging {#hanging} +## Hanging If Bazel appears to be hung, you can hit Ctrl-\ or send Bazel a `SIGQUIT` signal (`kill -3 $(bazel info server_pid)`) to get a thread @@ -200,7 +200,7 @@ Since you may not be able to run `bazel info` if bazel is hung, the `output_base` directory is usually the parent of the `bazel-` symlink in your workspace directory. -## Performance profiling {#performance-profiling} +## Performance profiling The [JSON trace profile](/advanced/performance/json-trace-profile) can be very useful to quickly understand what Bazel spent time on during the invocation. @@ -212,13 +212,13 @@ flag may be used to capture Java Flight Recorder profiles of various kinds The [`--starlark_cpu_profile`](https://bazel.build/reference/command-line-reference#flag--starlark_cpu_profile) flag may be used to write a pprof profile of CPU usage by all Starlark threads. -## Memory profiling {#memory-profiling} +## Memory profiling Bazel comes with a built-in memory profiler that can help you check your rule’s memory use. If there is a problem you can dump the heap to find the exact line of code that is causing the problem. -### Enabling memory tracking {#enabling-memory-tracking} +### Enabling memory tracking You must pass these two startup flags to *every* Bazel invocation: @@ -235,7 +235,7 @@ Repository][allocation-instrumenter-link]. These start the server in memory tracking mode. If you forget these for even one Bazel invocation the server will restart and you will have to start over. -### Using the Memory Tracker {#memory-tracker} +### Using the Memory Tracker As an example, look at the target `foo` and see what it does. To only run the analysis and not run the build execution phase, add the diff --git a/rules/rules-tutorial.mdx b/rules/rules-tutorial.mdx index 8510a81c..56a3ad43 100644 --- a/rules/rules-tutorial.mdx +++ b/rules/rules-tutorial.mdx @@ -33,9 +33,9 @@ foo_binary = rule( ) ``` -When you call the [`rule`](/rules/lib/globals/bzl#rule) function, you +When you call the [`rule`](lib/globals/bzl#rule) function, you must define a callback function. The logic will go there, but you -can leave the function empty for now. The [`ctx`](/rules/lib/builtins/ctx) argument +can leave the function empty for now. The [`ctx`](lib/ctx) argument provides information about the target. You can load the rule and use it from a `BUILD` file. @@ -88,10 +88,10 @@ foo_binary(name = "bin1") foo_binary(name = "bin2") ``` -[`ctx.label`](/rules/lib/builtins/ctx#label) +[`ctx.label`](lib/ctx#label) corresponds to the label of the target being analyzed. The `ctx` object has many useful fields and methods; you can find an exhaustive list in the -[API reference](/rules/lib/builtins/ctx). +[API reference](lib/ctx). Query the code: @@ -147,7 +147,7 @@ bin2 ``` Whenever you declare a file, you have to tell Bazel how to generate it by -creating an action. Use [`ctx.actions.write`](/rules/lib/builtins/actions#write), +creating an action. Use [`ctx.actions.write`](lib/actions#write), to create a file with the given content. ```python @@ -202,7 +202,7 @@ You have successfully generated a file! ## Attributes To make the rule more useful, add new attributes using -[the `attr` module](/rules/lib/toplevel/attr) and update the rule definition. +[the `attr` module](lib/attr) and update the rule definition. Add a string attribute called `username`: @@ -238,22 +238,22 @@ def _foo_binary_impl(ctx): ``` Note that you can make the attribute mandatory or set a default value. Look at -the documentation of [`attr.string`](/rules/lib/toplevel/attr#string). -You may also use other types of attributes, such as [boolean](/rules/lib/toplevel/attr#bool) -or [list of integers](/rules/lib/toplevel/attr#int_list). +the documentation of [`attr.string`](lib/attr#string). +You may also use other types of attributes, such as [boolean](lib/attr#bool) +or [list of integers](lib/attr#int_list). ## Dependencies -Dependency attributes, such as [`attr.label`](/rules/lib/toplevel/attr#label) -and [`attr.label_list`](/rules/lib/toplevel/attr#label_list), +Dependency attributes, such as [`attr.label`](lib/attr#label) +and [`attr.label_list`](lib/attr#label_list), declare a dependency from the target that owns the attribute to the target whose label appears in the attribute's value. This kind of attribute forms the basis of the target graph. In the `BUILD` file, the target label appears as a string object, such as `//pkg:name`. In the implementation function, the target will be accessible as a -[`Target`](/rules/lib/builtins/Target) object. For example, view the files returned -by the target using [`Target.files`](/rules/lib/builtins/Target#modules.Target.files). +[`Target`](lib/Target) object. For example, view the files returned +by the target using [`Target.files`](lib/Target#modules.Target.files). ### Multiple files @@ -296,7 +296,7 @@ implementation function, but this has two problems. First, as the template gets bigger, it becomes more memory efficient to put it in a separate file and avoid constructing large strings during the analysis phase. Second, using a separate file is more convenient for the user. Instead, use -[`ctx.actions.expand_template`](/rules/lib/builtins/actions#expand_template), +[`ctx.actions.expand_template`](lib/actions#expand_template), which performs substitutions on a template file. Create a `template` attribute to declare a dependency on the template diff --git a/rules/testing.mdx b/rules/testing.mdx index 4642c9ea..2996e08c 100644 --- a/rules/testing.mdx +++ b/rules/testing.mdx @@ -7,7 +7,7 @@ title: 'Testing' There are several different approaches to testing Starlark code in Bazel. This page gathers the current best practices and frameworks by use case. -## Testing rules {#testing-rules} +## Testing rules [Skylib](https://github.com/bazelbuild/bazel-skylib) has a test framework called [`unittest.bzl`](https://github.com/bazelbuild/bazel-skylib/blob/main/lib/unittest.bzl) @@ -46,7 +46,7 @@ generated script that fails at test execution time. See below for a minimal toy example, followed by an example that checks actions. -### Minimal example {#testing-rules-example} +### Minimal example `//mypkg/myrules.bzl`: @@ -176,7 +176,7 @@ Then: Note that the labels of all targets can conflict with other labels in the same BUILD package, so it's helpful to use a unique name for the test. -### Failure testing {#failure-testing} +### Failure testing It may be useful to verify that a rule fails given certain inputs or in certain state. This can be done using the analysis test framework: @@ -217,7 +217,7 @@ def _test_failure(): # ":failure_testing_test" to the suite's test targets. ``` -### Verifying registered actions {#verifying-registered-actions} +### Verifying registered actions You may want to write tests which make assertions about the actions that your rule registers, for example, using `ctx.actions.run()`. This can be done in your @@ -237,10 +237,10 @@ def _inspect_actions_test_impl(ctx): ``` Note that `analysistest.target_actions(env)` returns a list of -[`Action`](/rules/lib/builtins/Action) objects which represent actions registered by the +[`Action`](lib/Action) objects which represent actions registered by the target under test. -### Verifying rule behavior under different flags {#verifying-rule-behavior} +### Verifying rule behavior under different flags You may want to verify your real rule behaves a certain way given certain build flags. For example, your rule may behave differently if a user specifies: @@ -289,7 +289,7 @@ prefixed with a special placeholder value `//command_line_option:`, as is shown above. -## Validating artifacts {#validating-artifacts} +## Validating artifacts The main ways to check that your generated files are correct are: @@ -298,7 +298,7 @@ The main ways to check that your generated files are correct are: * You can use a specialized rule for the kind of test you want to perform. -### Using a test target {#using-test-target} +### Using a test target The most straightforward way to validate an artifact is to write a script and add a `*_test` target to your BUILD file. The specific artifacts you want to @@ -339,7 +339,7 @@ sh_test( ) ``` -### Using a custom rule {#using-custom-rule} +### Using a custom rule A more complicated alternative is to write the shell script as a template that gets instantiated by a new rule. This involves more indirection and Starlark @@ -421,7 +421,7 @@ Alternatively, instead of using a template expansion action, you could have inlined the template into the .bzl file as a string and expanded it during the analysis phase using the `str.format` method or `%`-formatting. -## Testing Starlark utilities {#testing-starlark-utilities} +## Testing Starlark utilities [Skylib](https://github.com/bazelbuild/bazel-skylib)'s [`unittest.bzl`](https://github.com/bazelbuild/bazel-skylib/blob/main/lib/unittest.bzl) diff --git a/rules/verbs-tutorial.mdx b/rules/verbs-tutorial.mdx index df2b1fab..db7757e1 100644 --- a/rules/verbs-tutorial.mdx +++ b/rules/verbs-tutorial.mdx @@ -51,7 +51,8 @@ This pattern can also be seen in the Angular project. The produces two targets. The first is a standard `nodejs_test` target which compares some generated output against a "golden" file (that is, a file containing the expected output). This can be built and run with a normal `bazel -test` invocation. In `angular-cli`, you can run [one such target](https://github.com/angular/angular-cli/blob/e1269cb520871ee29b1a4eec6e6c0e4a94f0b5fc/etc/api/BUILD) +test` invocation. In `angular-cli`, you can run [one such +target](https://github.com/angular/angular-cli/blob/e1269cb520871ee29b1a4eec6e6c0e4a94f0b5fc/etc/api/BUILD) with `bazel test //etc/api:angular_devkit_core_api`. Over time, this golden file may need to be updated for legitimate reasons. @@ -160,7 +161,7 @@ an imaginary `bazel publish` command. It's not immediately obvious what the implementation of the `_sphinx_publisher` rule might look like. Often, actions like this write a _launcher_ shell script. This method typically involves using -[`ctx.actions.expand_template`](/rules/lib/builtins/actions#expand_template) +[`ctx.actions.expand_template`](lib/actions#expand_template) to write a very simple shell script, in this case invoking the publisher binary with a path to the output of the primary target. This way, the publisher implementation can remain generic, the `_sphinx_site` rule can just produce diff --git a/run/bazelrc.mdx b/run/bazelrc.mdx index 0a7eff88..f71aabb3 100644 --- a/run/bazelrc.mdx +++ b/run/bazelrc.mdx @@ -10,7 +10,7 @@ Bazel accepts many options. Some options are varied frequently (for example, (and other commands), you can specify options in a configuration file, called `.bazelrc`. -### Where are the `.bazelrc` files? {#bazelrc-file-locations} +### Where are the `.bazelrc` files? Bazel looks for optional configuration files in the following locations, in the order shown below. The options are interpreted in this order, so @@ -77,14 +77,14 @@ In addition to this optional configuration file, Bazel looks for a global rc file. For more details, see the [global bazelrc section](#global-bazelrc). -### `.bazelrc` syntax and semantics {#bazelrc-syntax-semantics} +### `.bazelrc` syntax and semantics Like all UNIX "rc" files, the `.bazelrc` file is a text file with a line-based grammar. Empty lines and lines starting with `#` (comments) are ignored. Each line contains a sequence of words, which are tokenized according to the same rules as the Bourne shell. -#### Imports {#imports} +#### Imports Lines that start with `import`, `try-import` or `try-import-if-bazel-version` are special: use these to load other "rc" files. To specify a path that is @@ -149,7 +149,7 @@ Import precedence: options in the imported file. - Options in files imported later take precedence over files imported earlier. -#### Option defaults {#option-defaults} +#### Option defaults Most lines of a bazelrc define default option values. The first word on each line specifies when these defaults are applied: @@ -234,7 +234,7 @@ options specified in the same files, have lower precedence than their siblings on the command line, and are always prepended to the explicit list of non- option arguments. -#### `--config` {#config} +#### `--config` In addition to setting option defaults, the rc file can be used to group options and provide a shorthand for common groupings. This is done by adding a `:name` @@ -259,7 +259,7 @@ This syntax does not extend to the use of `startup` to set [startup options](#option-defaults). Setting `startup:config-name --some_startup_option` in the .bazelrc will be ignored. -#### `--enable_platform_specific_config` {#enable_platform_specific_config} +#### `--enable_platform_specific_config` Platform specific configs in the `.bazelrc` can be automatically enabled using `--enable_platform_specific_config`. For example, if the host OS is Linux and @@ -270,12 +270,7 @@ automatically enabled. Supported OS identifiers are `linux`, `macos`, `windows`, See [--enable_platform_specific_config](/reference/command-line-reference#flag--enable_platform_specific_config). -Platform specific configurations also apply to `startup` options. For -example `startup:linux --some_startup_option` will be applied when the -host OS is Linux. Supported OS identifiers are `linux`, `macos`, -`windows`, `freebsd`, and `openbsd`. This behavior is always enabled. - -#### Example {#bazelrc-example} +#### Example Here's an example `~/.bazelrc` file: @@ -292,9 +287,9 @@ query --keep_going build:memcheck --strip=never --test_timeout=3600 ``` -### Other files governing Bazel's behavior {#bazel-behavior-files} +### Other files governing Bazel's behavior -#### `.bazelignore` {#bazelignore} +#### `.bazelignore` You can specify directories within the workspace that you want Bazel to ignore, such as related projects @@ -308,12 +303,12 @@ Bazel 8 introduces the `REPO.bazel` file which allows another directive, `ignore It takes a list of directories to ignore just like .bazelignore does, but with glob semantics. See [#24203](https://github.com/bazelbuild/bazel/pull/24203). -### The global bazelrc file {#global-bazelrc} +### The global bazelrc file Bazel reads optional bazelrc files in this order: 1. System rc-file located at `/etc/bazel.bazelrc`. -2. Workspace rc-file located at `$workspace/.bazelrc`. +2. Workspace rc-file located at `$workspace/tools/bazel.rc`. 3. Home rc-file located at `$HOME/.bazelrc` Each bazelrc file listed here has a corresponding flag which can be used to diff --git a/run/build.mdx b/run/build.mdx index 2f3e4825..7fddec40 100644 --- a/run/build.mdx +++ b/run/build.mdx @@ -5,7 +5,7 @@ title: 'Build programs with Bazel' This page covers how to build a program with Bazel, build command syntax, and target pattern syntax. -## Quickstart {#quickstart} +## Quickstart To run Bazel, go to your base [workspace](/concepts/build-ref#workspace) directory or any of its subdirectories and type `bazel`. See [build](#bazel-build) if you @@ -17,7 +17,7 @@ bazel help Usage: bazel command options ... ``` -### Available commands {#available-commands} +### Available commands * [`analyze-profile`](/docs/user-manual#analyze-profile): Analyzes build profile data. * [`aquery`](/docs/user-manual#aquery): Executes a query on the [post-analysis](#analysis) action graph. @@ -36,7 +36,7 @@ Usage: bazel command options ... * [`test`](/docs/user-manual#running-tests): Builds and runs the specified test targets. * [`version`](/docs/user-manual#version): Prints version information for Bazel. -### Getting help {#getting-help} +### Getting help * `bazel help command`: Prints help and options for `command`. @@ -48,7 +48,7 @@ The `bazel` tool performs many functions, called commands. The most commonly used ones are `bazel build` and `bazel test`. You can browse the online help messages using `bazel help`. -### Building one target {#bazel-build} +### Building one target Before you can start a build, you need a _workspace_. A workspace is a directory tree that contains all the source files needed to build your @@ -108,7 +108,7 @@ and no build steps to execute. If something changed in 'foo' or its dependencies, Bazel would re-execute some build actions, or complete an _incremental build_. -### Building multiple targets {#specifying-build-targets} +### Building multiple targets Bazel allows a number of ways to specify the targets to be built. Collectively, these are known as _target patterns_. This syntax is used in commands like @@ -179,8 +179,7 @@ current _working directory_. These examples assume a working directory of `foo`: bar/wiz - - Equivalent to: + Equivalent to: