Skip to content

Commit 623f08b

Browse files
author
corentinl
committed
build_def: build cc_binary .pyd directly
1 parent b4eeb57 commit 623f08b

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

build_defs.bzl

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,41 @@ def pybind_extension(
105105
**kwargs
106106
)
107107

108-
copy_file(
109-
name = name + "_copy_dll_to_pyd",
110-
src = name + ".dll",
111-
out = name + ".pyd",
112-
testonly = kwargs.get("testonly"),
113-
visibility = kwargs.get("visibility"),
108+
cc_binary(
109+
name = name + ".pyd",
110+
copts = copts + PYBIND_COPTS + select({
111+
Label("@pybind11//:msvc_compiler"): [],
112+
"//conditions:default": ["-fvisibility=hidden"],
113+
}),
114+
features = features + PYBIND_FEATURES,
115+
linkopts = linkopts + select({
116+
"@platforms//os:osx": ["-undefined", "dynamic_lookup"],
117+
Label("@pybind11//:msvc_compiler"): [],
118+
"//conditions:default": ["-Wl,-Bsymbolic"],
119+
}),
120+
linkshared = 1,
121+
tags = tags,
122+
target_compatible_with = select({
123+
"@platforms//os:windows": [],
124+
"//conditions:default": ["@platforms//:incompatible"],
125+
}),
126+
deps = deps + PYBIND_DEPS,
127+
**kwargs
114128
)
115129

130+
#copy_file(
131+
# name = name + "_copy_dll_to_pyd",
132+
# src = name + ".dll",
133+
# out = name + ".pyd",
134+
# testonly = kwargs.get("testonly"),
135+
# visibility = kwargs.get("visibility"),
136+
#)
137+
116138
native.alias(
117139
name = name,
118140
actual = select({
119-
"@platforms//os:windows": name + "_copy_dll_to_pyd",
141+
"@platforms//os:windows": name + ".pyd",
142+
#"@platforms//os:windows": name + "_copy_dll_to_pyd",
120143
"//conditions:default": name + ".so",
121144
}),
122145
testonly = kwargs.get("testonly"),

0 commit comments

Comments
 (0)