blob: afcb4b3e2451f78c2ce98d28db7d8713f9cdb342 [file] [log] [blame]
load(
"@rules_fuchsia//fuchsia:defs.bzl",
"fuchsia_component",
"fuchsia_component_manifest",
"fuchsia_package",
"fuchsia_wrap_rust_binary",
"if_fuchsia",
)
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_doc")
rust_binary(
name = "hello_rust_native",
srcs = ["src/main.rs"],
edition = "2021",
# Unfortunately, there doesn't seem to be a way of configuring these in
# rust_toolchain.
#
# The Rust rules always use the C++ linker (clang++) which knows how to find
# libc and libzircon, so we only have to specify the remaining libstd dep
# here.
#
# We could use the newly-merged experimental_use_cc_common_link and then
# supply stdlib_linkflags (which only works with cc link actions), but
# that's a bit of a hack. It wouldn't solve panic=abort, which is needed by
# our toolchain dist but not the upstream one.
#
# So what we probably need is our own macro to wrap this, or to modify
# rules_rust somehow.
deps = if_fuchsia(["@fuchsia_sdk//pkg/fdio"]),
rustc_flags = [
"-Cpanic=abort",
],
)
fuchsia_wrap_rust_binary(
name = "hello_rust",
native_binary = ":hello_rust_native",
)
fuchsia_component_manifest(
name = "manifest",
src = "meta/hello_rust.cml",
includes = ["@fuchsia_sdk//pkg/syslog:client"],
)
fuchsia_component(
name = "component",
manifest = ":manifest",
deps = [":hello_rust"],
)
fuchsia_package(
name = "pkg",
package_name = "hello_rust",
visibility = ["//visibility:public"],
components = [
":component",
],
)
rust_doc(
name = "hello_rust_doc",
crate = ":hello_rust",
)