Skip to content

Commit

Permalink
Use all_crate_deps to upgrade deps in BUILD based on Cargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
nak3 committed Feb 22, 2023
1 parent e8768c7 commit 59472ff
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 118 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ jobs:
chmod +x install.sh
./install.sh --user
echo $HOME/bin >> $GITHUB_PATH
- run: cargo vendor --versioned-dirs --locked
working-directory: third-party
- run: bazel run //third-party:vendor
- name: Check third-party/bazel up to date.
run: git diff --exit-code
- run: bazel run //demo:autocxx-demo --verbose_failures --noshow_progress

sanitizer:
Expand Down
93 changes: 24 additions & 69 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,112 +1,67 @@
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_proc_macro", "rust_binary")
load("//third-party/bazel:defs.bzl", "all_crate_deps")

# export files to referenced by third-party/BUILD.
exports_files([
"Cargo.toml",
"Cargo.lock",
"engine/Cargo.toml",
"gen/build/Cargo.toml",
"gen/cmd/Cargo.toml",
"integration-tests/Cargo.toml",
"macro/Cargo.toml",
"parser/Cargo.toml",
"tools/mdbook-preprocessor/Cargo.toml",
"tools/reduce/Cargo.toml",
])

rust_library(
name = "autocxx",
edition = "2021",
srcs = glob(["src/**/*.rs"]),
data = glob(["README.md"]),
deps = [
"//third-party:cxx",
"//third-party:moveit",
],
compile_data = glob(["README.md"]),
deps = all_crate_deps(normal = True),
visibility = ["//visibility:public"],
proc_macro_deps = [
":autocxx-macro",
"//third-party:aquamarine",
],
proc_macro_deps = all_crate_deps(proc_macro = True) + [":autocxx-macro"],
)

rust_proc_macro(
name = "autocxx-macro",
srcs = glob(["macro/src/**/*.rs"]),
edition = "2021",
visibility = ["//visibility:public"],
deps = [
":autocxx-parser",
"//third-party:proc-macro-error",
"//third-party:proc-macro2",
"//third-party:quote",
"//third-party:syn",
],
deps = all_crate_deps(normal = True, package_name = "macro") + [":autocxx-parser"],
)

rust_library(
name = "autocxx-parser",
srcs = glob(["parser/src/**/*.rs"]),
edition = "2021",
deps = [
"//third-party:log",
"//third-party:proc-macro2",
"//third-party:quote",
"//third-party:serde",
"//third-party:thiserror",
"//third-party:once_cell",
"//third-party:itertools",
"//third-party:indexmap",
"//third-party:serde_json",
"//third-party:syn",
],
deps = all_crate_deps(normal = True, package_name = "parser"),
)

rust_library(
name = "autocxx-engine",
srcs = glob(["engine/src/**/*.rs"]),
compile_data = glob(["**/*.md", "include/cxx.h"]),
edition = "2021",
visibility = ["//visibility:public"],
crate_features = ["build"],
deps = [
"//third-party:log",
"//third-party:proc-macro2",
"//third-party:quote",
"//third-party:autocxx-bindgen",
"//third-party:itertools",
"//third-party:cc",
"//third-party:cxx-gen",
":autocxx-parser",
"//third-party:version_check",
"//third-party:tempfile",
"//third-party:once_cell",
"//third-party:serde_json",
"//third-party:miette",
"//third-party:thiserror",
"//third-party:regex",
"//third-party:indexmap",
"//third-party:prettyplease",
"//third-party:syn",
],
proc_macro_deps = [
"//third-party:indoc",
"//third-party:aquamarine",
"//third-party:strum_macros",
"//third-party:rustversion",
],
deps = all_crate_deps(normal = True, package_name = "engine") + [":autocxx-parser"],
proc_macro_deps = all_crate_deps(proc_macro = True, package_name = "engine"),
)

rust_library(
name = "autocxx-build",
srcs = glob(["gen/build/src/**/*.rs"]),
edition = "2021",
visibility = ["//visibility:public"],
deps = [
":autocxx-engine",
"//third-party:env_logger",
"//third-party:indexmap",
],
deps = all_crate_deps(normal = True, package_name = "gen/build"),
)

rust_binary(
name = "autocxx-gen",
srcs = glob(["gen/cmd/src/**/*.rs"]),
edition = "2021",
visibility = ["//visibility:public"],
deps = [
":autocxx-engine",
"//third-party:clap",
"//third-party:proc-macro2",
"//third-party:env_logger",
"//third-party:pathdiff",
"//third-party:indexmap",
"//third-party:miette",
],
deps = all_crate_deps(normal = True, package_name = "gen/cmd") + [":autocxx-engine"],
)
10 changes: 5 additions & 5 deletions demo/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
load("@rules_rust//rust:defs.bzl", "rust_binary")
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//third-party/bazel:defs.bzl", "all_crate_deps")

# referenced by third-party/BUILD.
exports_files(["Cargo.toml"])

src = "src/main.rs"

Expand All @@ -12,11 +16,7 @@ rust_binary(
":bridge/generated",
],
edition = "2018",
deps = [
":bridge",
"//:autocxx",
"//third-party:cxx",
],
deps = all_crate_deps(normal = True, package_name = "demo") + ["//:autocxx", ":bridge"],
)

filegroup(
Expand Down
56 changes: 14 additions & 42 deletions third-party/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,20 @@ load("@rules_rust//crate_universe:defs.bzl", "crates_vendor")

crates_vendor(
name = "vendor",
cargo_lockfile = "//third-party:Cargo.lock",
generate_build_scripts = True,
manifests = ["//third-party:Cargo.toml"],
cargo_lockfile = "//:Cargo.lock",
manifests = [
"//:Cargo.toml",
"//:engine/Cargo.toml",
"//:gen/build/Cargo.toml",
"//:gen/cmd/Cargo.toml",
"//:integration-tests/Cargo.toml",
"//:macro/Cargo.toml",
"//:parser/Cargo.toml",
"//:tools/mdbook-preprocessor/Cargo.toml",
"//:tools/reduce/Cargo.toml",
# demo is a subpackage hence the file is exported via its BUILD.
"//demo:Cargo.toml",
],
mode = "remote",
tags = ["manual"],
vendor_path = "bazel",
)

[
alias(
name = name,
actual = "//third-party/bazel:{}".format(name),
visibility = ["//visibility:public"],
)
for name in [
"aquamarine",
"autocxx-bindgen",
"cc",
"clap",
"cxx",
"cxx-gen",
"env_logger",
"indexmap",
"indoc",
"itertools",
"log",
"miette",
"moveit",
"once_cell",
"pathdiff",
"prettyplease",
"proc-macro-error",
"proc-macro2",
"quote",
"regex",
"rustversion",
"serde_json",
"serde",
"strum_macros",
"syn",
"tempfile",
"thiserror",
"version_check",
]
]

0 comments on commit 59472ff

Please sign in to comment.