Skip to content

Commit 7f87a8d

Browse files
authored
Add swift_c_test_library to cc rules (#194)
We have `swift_cc_test_library` and `swift_c_test`, but `swift_c_test_library` was missing.
1 parent ce303b3 commit 7f87a8d

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

cc/defs.bzl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,33 @@ def swift_cc_tool(**kwargs):
579579

580580
native.cc_binary(**kwargs)
581581

582+
def swift_c_test_library(**kwargs):
583+
"""Wraps cc_library to enforce Swift test library conventions.
584+
585+
Args:
586+
**kwargs: See https://bazel.build/reference/be/c-cpp#cc_library
587+
588+
The following additional attributes are supported:
589+
590+
local_includes: List of local (non-public) include paths. Prefer
591+
this to passing local includes using copts. Paths are expected to
592+
be relative to the package this macro is called from.
593+
"""
594+
595+
_ = kwargs.pop("nocopts", []) # To handle API compatibility.
596+
597+
local_includes = _construct_local_includes(kwargs.pop("local_includes", []))
598+
599+
extensions = kwargs.pop("extensions", False)
600+
standard = kwargs.pop("standard", 99)
601+
602+
kwargs["copts"] = local_includes + kwargs.get("copts", []) + _tests_warn_deprecated_declarations() + _c_standard(extensions, standard)
603+
kwargs["linkstatic"] = kwargs.get("linkstatic", True)
604+
kwargs["tags"] = [TEST_LIBRARY] + kwargs.get("tags", [])
605+
kwargs["target_compatible_with"] = kwargs.get("target_compatible_with", []) + _test_compatible_with()
606+
607+
native.cc_library(**kwargs)
608+
582609
def swift_cc_test_library(**kwargs):
583610
"""Wraps cc_library to enforce Swift test library conventions.
584611

0 commit comments

Comments
 (0)