Skip to content
File

Blob: build/wd_cc_library.bzl

1.2 KB
1"""wd_cc_library definition"""
2 
3load("@rules_cc//cc:cc_library.bzl", "cc_library")
4 
5def wd_cc_library(strip_include_prefix = "/src", copts = [], **kwargs):
6 """Wrapper for cc_library that sets common attributes
7 """
8 cc_library(
9 target_compatible_with = select({
10 "@//build/config:no_build": ["@platforms//:incompatible"],
11 "//conditions:default": [],
12 }),
13 # global CPU-specific options are inconvenient to specify with bazel – just set the options we
14 # need for CRC32C used in in this target for now.
15 # TODO(cleanup): Come up with a better approach to specify these options for all C/C++
16 # targets - it appears to be impossible to set arch-specific copts without a custom
17 # toolchain or manually setting a config from the CLI interface (which we can do in CI, but
18 # can't easily do for local builds).
19 copts = copts + select({
20 "@platforms//cpu:aarch64": [
21 "-mcrc",
22 ],
23 "@platforms//cpu:x86_64": [
24 # Note that msse4.2 already includes CRC32C and SSSE3 extensions
25 "-msse4.2",
26 ],
27 }),
28 strip_include_prefix = strip_include_prefix,
29 **kwargs
30 )