Description
Howdy!
I have a cargo manifest like so:
[package]
name = "my-app"
version = "0.1.0"
authors = [<me>]
[dependencies]
libc = "0.2"
log = "0.4"
env_logger = "0.5"
bytes = "0.4"
failure = "0.1"
futures = "0.1"
tokio = "0.1"
tokio-signal = "0.2"
qp-trie = "0.7"
rmp = "0.8"
rmpv = "0.4"
[lib]
crate-type = ["cdylib", "rlib"]
In src I have lib.rs
and main.rs
. Using cargo I get 3 artifacts that are used by other parts of the existing build: libmy_app.so
, libmy_app.rlib
, and the program my-app
.
I can get a working bazel build with something like this:
package(default_visibility = ["//visibility:public"])
load("@io_bazel_rules_rust//rust:rust.bzl", "rust_binary","rust_library")
COMMON_DEPS = [
"//vendor/crates:libc",
"//vendor/crates:log",
"//vendor/crates:env_logger",
"//vendor/crates:bytes",
"//vendor/crates:failure",
"//vendor/crates:futures",
"//vendor/crates:tokio",
"//vendor/crates:tokio_signal",
"//vendor/crates:qp_trie",
"//vendor/crates:rmp",
"//vendor/crates:rmpv",
]
rust_library(
name = "my_app_client",
srcs = ["src/lib.rs"],
deps = COMMON_DEPS,
crate_type = "cdylib",
)
rust_binary(
name = "my_app",
srcs = ["src/main.rs"],
deps = COMMON_DEPS,
)
But this gives me a binary my_app
instead of my-app
which is probably something I can live with; but my shared library is just totally wrong now libmy_app_client--<HASH>.so
.
I'm generating the header for the library using cbindgen and this shared library is used in other parts of our build so the name isn't entirely a problem for that purpose, but it is also part of the package given to clients so this is ultimately not going to work.
I've tried to use -o libmy_app.so
in the rustc flags but the build fails because it can't find libmy_app_client-<HASH>.so
. :D Looks like bazel and I are at another impasse.
Am I missing an obvious solution or configuration here?