2
0
Fork 0
mirror of https://github.com/bazelbuild/rules_cc synced 2024-11-27 20:43:26 +00:00
rules_cc/cc
Googler e1c7ebb858 Add support for select'ing on cc_args(args=...).
This CL is an alternative to unknown commit. I left the other CL seperately, because I wasn't 100% sure that we'd agree to this, since this is an API change.
I did it this way because I believe it's much less hacky, and it also allows us to format things that aren't variables.

BEGIN_PUBLIC
Add support for select'ing on cc_args(args=...).

This is quite tricky because the one parameter was being split into two in a macro, one of type label and the other of type string.

For example, `args = ["--foo", format_arg("--bar=%s", "//path/to:bar")]` was rewritten by the macro to `args = [json.encode(struct(format_type="raw", format="foo")), json.encode(struct(format_type="format_arg", format="--bar=%s", value=0))], variables = ["//path/to:bar"]`.
To allow it to work with selects, we need to ensure that we don't perform post-processing on the inside of the select. To solve this, we:
* Ensure that args only take strings
* Provide a seperate parameter for substitutions.

This new mechanism also has the useful property that we can now format things that are not variables. For example, I can do the following:

```
directory(name = "sysroot", ...)
cc_args(
    name = "sysroot_arg",
    args = ["--sysroot={sysroot}"],
    format = {
        ":sysroot": "sysroot"
    }
)
```

END_PUBLIC

PiperOrigin-RevId: 656211278
Change-Id: If83f1ea5a99090c18f2a561c51ec6d39ce9fe419
2024-07-25 20:13:42 -07:00
..
common Restructure rules_cc 2024-06-16 22:40:48 -07:00
compiler Fix licensing errors and add default condition for local_defines. 2023-07-18 07:27:57 -07:00
private Restructure rules_cc 2024-06-16 22:40:48 -07:00
proto Create toolchain types for proto_library and lang_proto_library 2023-09-18 12:30:14 -07:00
runfiles The targets in the old package were either not publicly visible or testonly dependencies and had diverged heavily from @bazel_tools. 2023-01-10 02:00:52 -08:00
toolchains Add support for select'ing on cc_args(args=...). 2024-07-25 20:13:42 -07:00
action_names.bzl Implement action types for the configurable cc toolchain. 2024-02-12 18:54:59 -08:00
BUILD No public description 2024-06-25 09:37:32 -07:00
cc_binary.bzl Restructure rules_cc 2024-06-16 22:40:48 -07:00
cc_import.bzl Restructure rules_cc 2024-06-16 22:40:48 -07:00
cc_library.bzl Restructure rules_cc 2024-06-16 22:40:48 -07:00
cc_shared_library.bzl Restructure rules_cc 2024-06-16 22:40:48 -07:00
cc_test.bzl Restructure rules_cc 2024-06-16 22:40:48 -07:00
cc_toolchain_config_lib.bzl Add documentation for rule-based bazel toolchain configuration 2024-02-12 18:22:13 -08:00
defs.bzl Restructure rules_cc 2024-06-16 22:40:48 -07:00
extensions.bzl Automated rollback of commit 48881f1f45. 2023-01-11 02:48:25 -08:00
find_cc_toolchain.bzl Merge pull request #146 from bazelbuild:meteorcloudy-patch-1 2022-09-19 13:51:00 +00:00
objc_import.bzl Restructure rules_cc 2024-06-16 22:40:48 -07:00
objc_library.bzl Restructure rules_cc 2024-06-16 22:40:48 -07:00
repositories.bzl Copybara Merge: https://github.com/bazelbuild/rules_cc/pull/165 2023-01-11 04:33:23 -08:00
system_library.bzl Merge pull request #79 from agluszak:system_library 2020-09-23 06:28:04 -07:00
toolchain_utils.bzl Fix buildifier warnings in @rules_cc 2019-10-24 07:01:25 -07:00