fix Windows build with latest rules_rust
the extra .lib file that is being output for .dll files was tripping up the copy; we need to select only the .dll file
This commit is contained in:
parent
4f64494573
commit
0c7a9be359
@ -2,6 +2,7 @@ load("@rules_python//python:defs.bzl", "py_binary")
|
||||
load("@py_deps//:requirements.bzl", "requirement")
|
||||
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
|
||||
load("@bazel_skylib//lib:selects.bzl", "selects")
|
||||
load(":python_lib.bzl", "copy_python_lib")
|
||||
|
||||
py_binary(
|
||||
name = "genbackend",
|
||||
@ -44,26 +45,9 @@ genrule(
|
||||
],
|
||||
)
|
||||
|
||||
copy_file(
|
||||
name = "rsbridge_unix",
|
||||
src = "//pylib/rsbridge",
|
||||
out = "rsbridge.so",
|
||||
)
|
||||
|
||||
copy_file(
|
||||
name = "rsbridge_win",
|
||||
src = "//pylib/rsbridge",
|
||||
out = "rsbridge.pyd",
|
||||
)
|
||||
|
||||
alias(
|
||||
copy_python_lib(
|
||||
name = "rsbridge",
|
||||
actual = selects.with_or({
|
||||
(
|
||||
"@rules_rust//rust/platform:x86_64-pc-windows-msvc",
|
||||
): ":rsbridge_win",
|
||||
"//conditions:default": ":rsbridge_unix",
|
||||
}),
|
||||
src = "//pylib/rsbridge",
|
||||
)
|
||||
|
||||
_py_srcs = [
|
||||
|
38
pylib/anki/_backend/python_lib.bzl
Normal file
38
pylib/anki/_backend/python_lib.bzl
Normal file
@ -0,0 +1,38 @@
|
||||
load("@bazel_skylib//lib:paths.bzl", "paths")
|
||||
|
||||
def _copy_python_lib_impl(ctx):
|
||||
desired_file = None
|
||||
target_name = ctx.label.name
|
||||
if ctx.attr.is_windows:
|
||||
target_name += ".pyd"
|
||||
for file in ctx.files.src:
|
||||
if file.extension == "dll":
|
||||
desired_file = file
|
||||
break
|
||||
else:
|
||||
target_name += ".so"
|
||||
desired_file = ctx.files.src[0]
|
||||
|
||||
file = ctx.actions.declare_file(target_name)
|
||||
ctx.actions.symlink(output = file, target_file = desired_file)
|
||||
|
||||
return [DefaultInfo(files = depset([file]))]
|
||||
|
||||
_copy_python_lib = rule(
|
||||
implementation = _copy_python_lib_impl,
|
||||
attrs = {
|
||||
"src": attr.label(),
|
||||
"is_windows": attr.bool(mandatory = True),
|
||||
},
|
||||
)
|
||||
|
||||
def copy_python_lib(name, src):
|
||||
"Copy a dynamic library, renaming it to the extension Python expects."
|
||||
_copy_python_lib(
|
||||
name = name,
|
||||
src = src,
|
||||
is_windows = select({
|
||||
"@bazel_tools//src/conditions:host_windows": True,
|
||||
"//conditions:default": False,
|
||||
}),
|
||||
)
|
Loading…
Reference in New Issue
Block a user