2024-10-08 09:39:00 +00:00
|
|
|
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
|
|
|
|
|
load("@rules_cc//cc:cc_test.bzl", "cc_test")
|
2023-01-02 14:28:25 +00:00
|
|
|
load("@rules_zig//zig:defs.bzl", "BINARY_KIND", "zig_binary")
|
|
|
|
|
|
2023-08-01 11:35:04 +00:00
|
|
|
def zig_cc_binary(
|
|
|
|
|
name,
|
|
|
|
|
copts = [],
|
|
|
|
|
args = None,
|
|
|
|
|
env = None,
|
|
|
|
|
data = [],
|
|
|
|
|
deps = [],
|
2024-05-20 11:28:25 +00:00
|
|
|
tags = [],
|
2023-08-01 11:35:04 +00:00
|
|
|
visibility = None,
|
|
|
|
|
**kwargs):
|
2023-01-02 14:28:25 +00:00
|
|
|
zig_binary(
|
|
|
|
|
name = "{}_lib".format(name),
|
|
|
|
|
kind = BINARY_KIND.static_lib,
|
2024-12-03 13:50:58 +00:00
|
|
|
copts = copts + ["-lc"],
|
2024-10-08 09:39:00 +00:00
|
|
|
deps = deps,
|
|
|
|
|
visibility = visibility,
|
2023-01-02 14:28:25 +00:00
|
|
|
**kwargs
|
|
|
|
|
)
|
2024-10-08 09:39:00 +00:00
|
|
|
cc_binary(
|
2023-01-02 14:28:25 +00:00
|
|
|
name = name,
|
|
|
|
|
args = args,
|
|
|
|
|
env = env,
|
|
|
|
|
data = data,
|
|
|
|
|
deps = [":{}_lib".format(name)],
|
2024-05-20 11:28:25 +00:00
|
|
|
tags = tags,
|
2023-01-02 14:28:25 +00:00
|
|
|
visibility = visibility,
|
|
|
|
|
)
|
|
|
|
|
|
2023-08-01 11:35:04 +00:00
|
|
|
def zig_cc_test(
|
|
|
|
|
name,
|
|
|
|
|
copts = [],
|
|
|
|
|
env = None,
|
|
|
|
|
data = [],
|
|
|
|
|
deps = [],
|
|
|
|
|
test_runner = None,
|
2024-05-20 11:28:25 +00:00
|
|
|
tags = [],
|
2023-08-01 11:35:04 +00:00
|
|
|
visibility = None,
|
|
|
|
|
**kwargs):
|
2023-01-02 14:28:25 +00:00
|
|
|
zig_binary(
|
|
|
|
|
name = "{}_test_lib".format(name),
|
|
|
|
|
kind = BINARY_KIND.test_lib,
|
|
|
|
|
test_runner = test_runner,
|
2024-05-20 11:28:25 +00:00
|
|
|
tags = tags,
|
2024-12-03 13:50:58 +00:00
|
|
|
copts = copts + ["-lc"],
|
2023-01-02 14:28:25 +00:00
|
|
|
deps = deps + [
|
|
|
|
|
"@rules_zig//zig/lib:libc",
|
|
|
|
|
],
|
2024-10-08 09:39:00 +00:00
|
|
|
visibility = visibility,
|
2023-01-02 14:28:25 +00:00
|
|
|
**kwargs
|
|
|
|
|
)
|
2024-10-08 09:39:00 +00:00
|
|
|
cc_test(
|
2023-01-02 14:28:25 +00:00
|
|
|
name = name,
|
|
|
|
|
env = env,
|
|
|
|
|
data = data,
|
|
|
|
|
deps = [":{}_test_lib".format(name)],
|
2024-05-20 11:28:25 +00:00
|
|
|
tags = tags,
|
2023-01-02 14:28:25 +00:00
|
|
|
visibility = visibility,
|
|
|
|
|
linkstatic = True,
|
|
|
|
|
)
|