diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 069b8ae06..8fd89f2f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/BUILD b/BUILD index fce8c291c..af93f64fc 100644 --- a/BUILD +++ b/BUILD @@ -1,19 +1,28 @@ 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( @@ -21,66 +30,24 @@ rust_proc_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( @@ -88,11 +55,7 @@ rust_library( 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( @@ -100,13 +63,5 @@ rust_binary( 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"], ) diff --git a/demo/BUILD b/demo/BUILD index a07af5bb2..e38048a32 100644 --- a/demo/BUILD +++ b/demo/BUILD @@ -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" @@ -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( diff --git a/third-party/BUILD b/third-party/BUILD index c999488cd..59d73810c 100644 --- a/third-party/BUILD +++ b/third-party/BUILD @@ -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", - ] -]