| 1 |
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") |
| 2 |
|
| 3 |
config_setting( |
| 4 |
name = "windows", |
| 5 |
constraint_values = ["@platforms//os:windows"], |
| 6 |
) |
| 7 |
|
| 8 |
# Instrument-hooks library with warning suppressions |
| 9 |
cc_library( |
| 10 |
name = "instrument_hooks", |
| 11 |
srcs = ["instrument-hooks/dist/core.c"], |
| 12 |
hdrs = glob(["instrument-hooks/includes/*.h"]), |
| 13 |
includes = ["instrument-hooks/includes"], |
| 14 |
copts = select({ |
| 15 |
":windows": [ |
| 16 |
"/wd4101", # unreferenced local variable (equivalent to -Wno-unused-variable) |
| 17 |
"/wd4189", # local variable is initialized but not referenced (equivalent to -Wno-unused-but-set-variable) |
| 18 |
"/wd4100", # unreferenced formal parameter (equivalent to -Wno-unused-parameter) |
| 19 |
"/wd4245", # signed/unsigned mismatch |
| 20 |
"/wd4132", # const object should be initialized |
| 21 |
"/wd4146", # unary minus operator applied to unsigned type |
| 22 |
], |
| 23 |
"//conditions:default": [ |
| 24 |
"-Wno-maybe-uninitialized", |
| 25 |
"-Wno-unused-variable", |
| 26 |
"-Wno-unused-parameter", |
| 27 |
"-Wno-unused-but-set-variable", |
| 28 |
"-Wno-type-limits", |
| 29 |
], |
| 30 |
}), |
| 31 |
visibility = ["//visibility:public"], |
| 32 |
) |
| 33 |
|
| 34 |
cc_binary( |
| 35 |
name = "example", |
| 36 |
srcs = ["main.c"], |
| 37 |
deps = [":instrument_hooks"], |
| 38 |
copts = select({ |
| 39 |
":windows": ["/W4", "/WX"], |
| 40 |
"//conditions:default": ["-Wall", "-Wextra", "-Werror"], |
| 41 |
}), |
| 42 |
) |