xref: /aosp_15_r20/external/pytorch/third_party/sleef.bzl (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1load("@rules_cc//cc:defs.bzl", "cc_library")
2
3# This macro provides for generating both "sleef<foo>" and
4# "sleefdet<foo>" libraries for a given set of code. The difference is
5# that the "det" libraries get compiled with "-DDETERMINISTIC=1".
6
7def sleef_cc_library(name, copts, **kwargs):
8    cc_library(
9        name = name,
10        copts = copts,
11        **kwargs
12    )
13
14    prefix = "sleef"
15    if not name.startswith(prefix):
16        fail("name {} does not start with {}".format(repr(name), repr(prefix)))
17
18    cc_library(
19        name = name.replace(prefix, prefix + "det", 1),
20        copts = copts + ["-DDETERMINISTIC=1"],
21        **kwargs
22    )
23