Allow compiling with Rust code (#3137)

Co-authored-by: Yuri Astrakhan <YuriAstrakhan@gmail.com>
Co-authored-by: Ian Wagner <ianwagner+github@switzerlandmail.ch>
This commit is contained in:
Bart Louwers
2025-01-16 16:01:11 +01:00
committed by GitHub
parent 79d625b03c
commit 527e70b6fa
23 changed files with 649 additions and 25 deletions

46
rustutils/BUILD.bazel Normal file
View File

@@ -0,0 +1,46 @@
load("@rules_rust//rust:defs.bzl", "rust_static_library")
genrule(
name = "cpp_bindings",
srcs = [
"src/color.rs",
],
outs = [
"cpp/include/rustutils/color.hpp",
"cpp/src/color.rs.cpp",
],
cmd = "CXXBRIDGE_CMD=$(location @cxx.rs//:codegen) ./$(location :generate.sh) $(@D) $(SRCS)",
# Using the cxxbridge binary built by Bazel
tools = [
":generate.sh",
"@cxx.rs//:codegen",
],
)
rust_static_library(
name = "rustutils",
srcs = [
"src/color.rs",
"src/lib.rs",
],
crate_name = "rustutils",
visibility = ["//visibility:public"],
deps = [
"@crates//:csscolorparser",
"@crates//:cxx",
],
)
cc_library(
name = "rustutilslib",
srcs = [
":cpp_bindings",
],
includes = [
"cpp/include",
],
visibility = ["//visibility:public"],
deps = [
":rustutils",
],
)