Skip to content

Commit 4b5792a

Browse files
sbmuellerarmallen
andauthored
Add standard argument to swift_cc_test_library and swift_c_test (#192)
`swift_cc_test_library` and `swift_c_test` did not support the `standard` attribute, which allows an explicit selection of the language standard. We want to be able to precisely set the C/C++ standard for all targets. All other swift related rules support this already. Reviving @armallen's old commits. --------- Co-authored-by: Arnaud Mallen <[email protected]>
1 parent 5641077 commit 4b5792a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

cc/defs.bzl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,15 @@ def swift_cc_test_library(**kwargs):
592592
be relative to the package this macro is called from.
593593
"""
594594

595-
_ = kwargs.pop("nocopts", []) # To handle API compatibility.
596-
595+
nocopts = kwargs.pop("nocopts", []) # pop because nocopts is a deprecated cc* attr.
597596
local_includes = _construct_local_includes(kwargs.pop("local_includes", []))
598597

599-
kwargs["copts"] = local_includes + kwargs.get("copts", [])
598+
standard = kwargs.pop("standard", None)
599+
600+
copts = _common_cc_opts(nocopts, pedantic = False)
601+
cxxopts = _common_cxx_standard_opts(standard)
602+
603+
kwargs["copts"] = copts + cxxopts + local_includes + kwargs.get("copts", [])
600604

601605
kwargs["tags"] = [TEST_LIBRARY] + kwargs.get("tags", [])
602606

@@ -648,7 +652,10 @@ def swift_c_test(name, type, **kwargs):
648652

649653
local_includes = _construct_local_includes(kwargs.pop("local_includes", []))
650654

651-
kwargs["copts"] = local_includes + kwargs.get("copts", []) + _tests_warn_deprecated_declarations()
655+
extensions = kwargs.pop("extensions", False)
656+
standard = kwargs.pop("standard", 99)
657+
658+
kwargs["copts"] = local_includes + kwargs.get("copts", []) + _tests_warn_deprecated_declarations() + _c_standard(extensions, standard)
652659
kwargs["data"] = kwargs.get("data", []) + _symbolizer_data()
653660
kwargs["env"] = _symbolizer_env(kwargs.get("env", {}))
654661
kwargs["linkstatic"] = kwargs.get("linkstatic", True)

0 commit comments

Comments
 (0)