Allow extra args to cc_sysroot

It's possible for there to be some arguments that are naturally
associated with the sysroot flag, for example on macOS there are
associated framework search paths that should be added with
`-F{sysroot}/Library/Frameworks`. There are also warnings flags you
might want to add such as `-Werror=missing-sysroot`. In this case I
think it's nicer to provide them alongside the sysroot definition,
instead of having to create a custom cc_args for them.
This commit is contained in:
Keith Smiley 2024-09-22 13:56:36 -07:00
parent 91f050e461
commit b4f54fab89
No known key found for this signature in database
GPG Key ID: 33BA60D44C7167F8
1 changed files with 3 additions and 2 deletions

View File

@ -17,13 +17,14 @@ load("//cc/toolchains:args.bzl", "cc_args")
visibility("public") visibility("public")
def cc_sysroot(name, sysroot, **kwargs): def cc_sysroot(name, sysroot, args = [], **kwargs):
"""Creates args for a sysroot. """Creates args for a sysroot.
Args: Args:
name: (str) The name of the target name: (str) The name of the target
sysroot: (bazel_skylib's directory rule) The directory that should be the sysroot: (bazel_skylib's directory rule) The directory that should be the
sysroot. sysroot.
args: (List[str]) Extra command-line args to add.
**kwargs: kwargs to pass to cc_args. **kwargs: kwargs to pass to cc_args.
""" """
cc_args( cc_args(
@ -33,7 +34,7 @@ def cc_sysroot(name, sysroot, **kwargs):
Label("//cc/toolchains/actions:c_compile"), Label("//cc/toolchains/actions:c_compile"),
Label("//cc/toolchains/actions:link_actions"), Label("//cc/toolchains/actions:link_actions"),
], ],
args = ["--sysroot={sysroot}"], args = ["--sysroot={sysroot}"] + args,
format = {"sysroot": sysroot}, format = {"sysroot": sysroot},
**kwargs **kwargs
) )