Skip to content

Commit

Permalink
[features] distinguish between C-only features
Browse files Browse the repository at this point in the history
The `-Wstrict-prototypes` warning is only applicable to C code, not C++
code. See https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstrict-prototypes

Signed-off-by: Tim Trippel <[email protected]>
  • Loading branch information
timothytrippel committed Oct 16, 2024
1 parent 450767a commit 845f62b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions config/features.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def reify_with_features_set(
fail("the argument to with_features must be an array of values created by with_feature_set")
return with_feature_set(
features,
not_features
not_features,
)

def reify_flag_set(
Expand All @@ -89,7 +89,7 @@ def reify_flag_set(
type_name = None):
return __flag_set(
actions,
with_features =[reify_with_features_set(**v) for v in with_features],
with_features = [reify_with_features_set(**v) for v in with_features],
flag_groups = [reify_flag_group(**v) for v in flag_groups],
)

Expand Down Expand Up @@ -183,14 +183,14 @@ feature = rule(
provides = [FeatureInfo],
)

def feature_single_flag_c_cpp(name, flag, enabled = True):
def feature_single_flag_c_cpp(name, flag, c_only = False, enabled = True):
"""This macro produces a C/C++ feature() that enables a single flag."""
feature(
name = name,
enabled = enabled,
flag_sets = [
flag_set(
actions = CPP_ALL_COMPILE_ACTIONS + C_ALL_COMPILE_ACTIONS,
actions = C_ALL_COMPILE_ACTIONS + ([] if c_only else CPP_ALL_COMPILE_ACTIONS),
flag_groups = [
flag_group(
flags = [flag],
Expand Down
3 changes: 2 additions & 1 deletion features/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ feature_single_flag_c_cpp(

feature_single_flag_c_cpp(
name = "strict_prototypes_warnings",
c_only = True,
flag = "-Wstrict-prototypes",
)

Expand Down Expand Up @@ -174,7 +175,7 @@ feature(
flag_groups = [
flag_group(
flags = [
"-flto"
"-flto",
],
),
],
Expand Down

0 comments on commit 845f62b

Please sign in to comment.