Bazel load alias. Aliases function similarly to native flags and also make use of the double-dash option syntax. bzl. In all other respects, it behaves like the Feb 26, 2026 · This page covers the options that are available with various Bazel commands, such as bazel build, bazel run, and bazel test. This code loads the file foo/bar/file. Feb 26, 2026 · Bazel extensions are files ending in . This page is a companion to the list of Bazel's commands in Build with Bazel. Bazel also supports WORKSPACE. If both files exist, WORKSPACE. It might be hard to pull off though. Another way to think about the difference: there are very few things a macro can do which can't be done directly in a BUILD file. I think if we write a bazelrc file to be imported by the main file, in the tools/bazel wrapper, then we can get dynamically generated aliases. When defining environment groups, the aliases to environment rules are not supported. The alias rule has its own visibility declaration. Apr 14, 2020 · Bazel's load builtin supports a syntax for aliasing loaded values, something like this: load ("//:pkg. Extra actions extra_action action_listener General filegroup genquery test_suite alias config_setting genrule Platform constraint_setting constraint_value platform toolchain toolchain_type Workspace bind local_repository new_local . You can define multiple aliases within one load statement. The following example is perfectly legal (please note when to use quotation marks). bazel will take the priority. bazel file as an alias of WORKSPACE file. alias(name, actual, compatible_with, deprecation, features, restricted_to, tags, target_compatible_with, testonly, visibility) The alias rule creates another name a rule can be referred to as. Repositories Code is organized in repositories. This can be used to load new rules, functions, or constants (for example, a string or a list). As the targets are dynamic, we cannot use a static bazelrc with --flag_alias for that. Feb 8, 2022 · Macros can't access the values of a select, only add other selects to it and pass it to rules. Feb 26, 2026 · To define an alias that runs the referenced test, use a test_suite rule with a single target in its tests attribute. Feb 26, 2026 · For the counterpart that declares metadata applying to every rule in the whole repository, use the repo() function in the REPO. bazel file at the root of your repo. Make a Bash alias with alias bazel="bazelisk" and add it to your ~/. The package () function should be called right after all the load () statements at the top of the file, before any The alias rule creates another name a rule can be referred to as. bazelbuild/bazel Participants Feb 26, 2026 · Native rules are shipped with the Bazel binary, they are always available in BUILD files without a load statement. Supported OS identifiers are linux, macos, windows, freebsd, and openbsd. bzl", some_alias = "some_value") Which causes some_alias to refer to some_value in the file in which it is used. The repo() function takes exactly the same arguments as package(). bash_aliases file. Moreover, the argument list can contain both aliases and regular symbol names. Feb 26, 2026 · $ bazel build //my/target --//example:boolean_flag $ bazel build //my/target --no//example:boolean_flag 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. Use the load statement to import a symbol from an extension. Aliasing only works for "regular" targets. Aliasing may be of help in large repositories where renaming a target would require making changes to lots of files. Therefore, Bazel ignores any directory trees in a workspace rooted at a subdirectory containing a WORKSPACE file (as they form another workspace). Feb 15, 2021 · None yet Development Code with agent mode Support contraint_values in select ()s for alias rules bazelbuild/bazel Support contraint_values in select ()s for alias rules bazelbuild/bazel Support select () on constraint_value for aliases. This is necessary for some extensions to work correctly, such as the Bazel plugin for Visual Studio Code. Oct 23, 2019 · Load labels must be resolved before we even parse a BUILD file, so using alias (or anything else in a BUILD file) is not going to work. To define an alias that runs the referenced test, use a test_suite rule with a single target in its tests attribute. bzl and adds the some_library symbol to the environment. actual is a Label. Also, alias. In Bazel, is it possible to use simple functions and variables as input to a load statement? For example: For example, if the host OS is Linux and you run bazel build, Bazel picks up lines starting with build:linux. Dec 11, 2023 · To define an alias that runs the referenced test, use a test_suite rule with a single target in its tests attribute. In particular, package_group and test_suite cannot be aliased. Set the full path to bazel to be the full path to bazelisk in your IDE of choice. yitpcy lzpcnz juktmix lvvkzf ceggtj qnkza uiz psxt azxsb ysnnl