blob: 4ba9947a792951238a4a036701c790a4cbcece3f [file] [log] [blame] [edit]
# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
load("//bazel/bash:defs.bzl", "custom_args_binary", "custom_args_test", "sh_runfiles_binary")
load(":src.bzl", "ALCHEMIST_BAZEL_SRCS")
exports_files(
["Cargo.toml"],
visibility = ["//bazel/rust:__pkg__"],
)
# Even with --deleted_packages, glob(["src/**"]) won't pick up on any packages
# with build files. However, --deleted_packages does allow you to explicitly
# write ":foo/BUILD.bazel".
filegroup(
name = "srcs",
srcs = ALCHEMIST_BAZEL_SRCS,
)
sh_runfiles_binary(
name = "cargo",
src = "cargo.sh",
data = [
":srcs",
"@rust_host_tools//:cargo",
"@rust_host_tools//:rustc",
"@rust_host_tools//:rustdoc",
],
)
custom_args_binary(
name = "build",
binary = ":cargo",
binary_args = [
"build",
"--package",
"alchemist",
],
)
# Note that running "bazel build :alchemist" won't build alchemist.
# To do that, run "bazel build :build"
custom_args_binary(
name = "alchemist",
binary = ":cargo",
binary_args = [
"run",
"--package",
"alchemist",
],
)
custom_args_test(
name = "alchemist_test",
# If it's not cached, it can be quite slow to download all the dependencies.
size = "medium",
binary = ":cargo",
binary_args = [
"test",
"--package",
"alchemist",
],
# We require network access to download from crates.io, and require
# disabling the sandbox to write them to the local cache of the registry.
tags = [
"no-sandbox",
"requires-network",
],
)