diff options
author | Matthew Maurer <mmaurer@google.com> | 2023-03-20 21:47:37 +0000 |
---|---|---|
committer | Matthew Maurer <mmaurer@google.com> | 2023-04-03 17:31:08 +0000 |
commit | e4df9119ca0ce990455630d0f48d36885dad58c3 (patch) | |
tree | 1fd3b9f3ff9a652f86f18a5c841015fea1bfca4a | |
parent | b43e2700ee68420bcd2d5bf717bda8dbac840da5 (diff) | |
parent | e33fac67d2ee1ab9351556944d3ccc61ab6c5b3e (diff) | |
download | cxx-e4df9119ca0ce990455630d0f48d36885dad58c3.tar.gz |
Update to 1.0.93.
Change-Id: I00606f844501a0977ea3f7a59f91ca5b2abc4f63
85 files changed, 2435 insertions, 935 deletions
diff --git a/.buckconfig b/.buckconfig index 045974f7..bb3fda5f 100644 --- a/.buckconfig +++ b/.buckconfig @@ -2,7 +2,7 @@ repo = . prelude = tools/buck/prelude toolchains = tools/buck/toolchains -ovr_config = tools/buck/prelude +config = tools/buck/prelude buck = none fbcode = none fbsource = none @@ -14,4 +14,4 @@ fbsource = none ignore = target [parser] -target_platform_detector_spec = target://...->ovr_config//platforms:default +target_platform_detector_spec = target://...->config//platforms:default diff --git a/.gitattributes b/.gitattributes index f9f0dca7..fc5f7227 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ third-party/BUCK linguist-generated +third-party/bazel/** linguist-generated diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93feb348..9b496ebf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,14 +3,20 @@ name: CI on: push: pull_request: + workflow_dispatch: schedule: [cron: "40 1 * * *"] permissions: contents: read jobs: + pre_ci: + uses: dtolnay/.github/.github/workflows/pre_ci.yml@master + test: name: ${{matrix.name || format('Rust {0}', matrix.rust)}} + needs: pre_ci + if: needs.pre_ci.outputs.continue runs-on: ${{matrix.os || 'ubuntu'}}-latest strategy: fail-fast: false @@ -20,6 +26,7 @@ jobs: - rust: beta - rust: stable - rust: 1.60.0 + - rust: 1.64.0 - name: macOS rust: nightly os: macos @@ -48,7 +55,7 @@ jobs: # builds. run: | echo RUSTFLAGS=$RUSTFLAGS >> $GITHUB_ENV - echo exclude=--exclude cxx-test-suite >> $GITHUB_OUTPUT + echo exclude=--exclude cxx-test-suite ${{matrix.rust == '1.60.0' && '--exclude cxxbridge-cmd' || ''}} >> $GITHUB_OUTPUT env: RUSTFLAGS: ${{env.RUSTFLAGS}} ${{matrix.os && github.event_name != 'schedule' && '--cfg skip_ui_tests' || ''}} id: testsuite @@ -78,13 +85,13 @@ jobs: run: sudo apt-get install lld - run: cargo vendor --versioned-dirs --locked working-directory: third-party - - run: reindeer vendor + - run: reindeer buckify working-directory: third-party - name: Check reindeer-generated BUCK file up to date run: git diff --exit-code - run: buck2 run demo - run: buck2 build ... - - run: buck2 run tests:test + - run: buck2 test ... bazel: name: Bazel @@ -95,7 +102,7 @@ jobs: - uses: actions/checkout@v3 - name: Install Bazel run: | - wget -q -O install.sh https://github.com/bazelbuild/bazel/releases/download/5.1.1/bazel-5.1.1-installer-linux-x86_64.sh + wget -q -O install.sh https://github.com/bazelbuild/bazel/releases/download/6.0.0/bazel-6.0.0-installer-linux-x86_64.sh chmod +x install.sh ./install.sh --user echo $HOME/bin >> $GITHUB_PATH diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index 09382b79..1f9a6955 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -7,6 +7,7 @@ on: paths: - book/** - .github/workflows/site.yml + workflow_dispatch: jobs: deploy: @@ -1,6 +1,9 @@ rust_library( name = "cxx", srcs = glob(["src/**/*.rs"]), + doc_deps = [ + ":cxx-build", + ], edition = "2018", features = [ "alloc", @@ -9,19 +12,23 @@ rust_library( visibility = ["PUBLIC"], deps = [ ":core", - ":macro", + ":cxxbridge-macro", ], ) -rust_binary( +alias( name = "codegen", + actual = ":cxxbridge", + visibility = ["PUBLIC"], +) + +rust_binary( + name = "cxxbridge", srcs = glob(["gen/cmd/src/**/*.rs"]) + [ "gen/cmd/src/gen", "gen/cmd/src/syntax", ], - crate = "cxxbridge", edition = "2018", - visibility = ["PUBLIC"], deps = [ "//third-party:clap", "//third-party:codespan-reporting", @@ -43,9 +50,9 @@ cxx_library( ) rust_library( - name = "macro", + name = "cxxbridge-macro", srcs = glob(["macro/src/**/*.rs"]) + ["macro/src/syntax"], - crate = "cxxbridge_macro", + doctests = False, edition = "2018", proc_macro = True, deps = [ @@ -56,13 +63,13 @@ rust_library( ) rust_library( - name = "build", + name = "cxx-build", srcs = glob(["gen/build/src/**/*.rs"]) + [ "gen/build/src/gen", "gen/build/src/syntax", ], + doctests = False, edition = "2018", - visibility = ["PUBLIC"], deps = [ "//third-party:cc", "//third-party:codespan-reporting", @@ -75,7 +82,7 @@ rust_library( ) rust_library( - name = "lib", + name = "cxx-gen", srcs = glob(["gen/lib/src/**/*.rs"]) + [ "gen/lib/src/gen", "gen/lib/src/syntax", @@ -16,12 +16,17 @@ rust_library( deps = [":core-lib"], ) -rust_binary( +alias( name = "codegen", + actual = ":cxxbridge", + visibility = ["//visibility:public"], +) + +rust_binary( + name = "cxxbridge", srcs = glob(["gen/cmd/src/**/*.rs"]), data = ["gen/cmd/src/gen/include/cxx.h"], edition = "2018", - visibility = ["//visibility:public"], deps = [ "//third-party:clap", "//third-party:codespan-reporting", @@ -57,11 +62,10 @@ rust_proc_macro( ) rust_library( - name = "build", + name = "cxx-build", srcs = glob(["gen/build/src/**/*.rs"]), data = ["gen/build/src/gen/include/cxx.h"], edition = "2018", - visibility = ["//visibility:public"], deps = [ "//third-party:cc", "//third-party:codespan-reporting", @@ -74,7 +78,7 @@ rust_library( ) rust_library( - name = "lib", + name = "cxx-gen", srcs = glob(["gen/lib/src/**/*.rs"]), data = ["gen/lib/src/gen/include/cxx.h"], edition = "2018", @@ -1,18 +1,18 @@ [package] name = "cxx" -version = "1.0.85" # remember to update html_root_url +version = "1.0.93" # remember to update html_root_url authors = ["David Tolnay <dtolnay@gmail.com>"] categories = ["development-tools::ffi", "api-bindings", "no-std"] description = "Safe interop between Rust and C++" documentation = "https://docs.rs/cxx" edition = "2018" -exclude = ["/demo", "/gen", "/syntax", "/third-party"] +exclude = ["/demo", "/gen", "/syntax", "/third-party", "/tools/buck/prelude"] homepage = "https://cxx.rs" keywords = ["ffi", "c++"] license = "MIT OR Apache-2.0" links = "cxxbridge1" repository = "https://github.com/dtolnay/cxx" -rust-version = "1.48" +rust-version = "1.60" [features] default = ["std", "cxxbridge-flags/default"] # c++11 @@ -23,15 +23,15 @@ alloc = [] std = ["alloc"] [dependencies] -cxxbridge-macro = { version = "=1.0.85", path = "macro" } +cxxbridge-macro = { version = "=1.0.93", path = "macro" } link-cplusplus = "1.0" [build-dependencies] cc = "1.0.49" -cxxbridge-flags = { version = "=1.0.85", path = "flags", default-features = false } +cxxbridge-flags = { version = "=1.0.93", path = "flags", default-features = false } [dev-dependencies] -cxx-build = { version = "=1.0.85", path = "gen/build" } +cxx-build = { version = "=1.0.93", path = "gen/build" } cxx-gen = { version = "0.7", path = "gen/lib" } cxx-test-suite = { version = "0", path = "tests/ffi" } rustversion = "1.0" diff --git a/LICENSE-APACHE b/LICENSE-APACHE index 16fe87b0..1b5ec8b7 100644 --- a/LICENSE-APACHE +++ b/LICENSE-APACHE @@ -174,28 +174,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. @@ -24,7 +24,7 @@ cxx = "1.0" cxx-build = "1.0" ``` -*Compiler support: requires rustc 1.48+ and c++11 or newer*<br> +*Compiler support: requires rustc 1.60+ and c++11 or newer*<br> *[Release notes](https://github.com/dtolnay/cxx/releases)* <br> @@ -4,28 +4,22 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "rules_rust", - sha256 = "617082067629939c0a22f587811a3e822a50a203119a90380e21f5aec3373da9", - strip_prefix = "rules_rust-e07881fa22a5f0d16230d8b23bbff2bf358823b8", - urls = [ - # Main branch as of 2022-04-27 - "https://github.com/bazelbuild/rules_rust/archive/e07881fa22a5f0d16230d8b23bbff2bf358823b8.tar.gz", - ], + sha256 = "dc8d79fe9a5beb79d93e482eb807266a0e066e97a7b8c48d43ecf91f32a3a8f3", + urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.19.0/rules_rust-v0.19.0.tar.gz"], ) load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains") -RUST_VERSION = "1.65.0" - rules_rust_dependencies() rust_register_toolchains( - version = RUST_VERSION, + versions = ["1.68.0"], ) -load("//tools/bazel:vendor.bzl", "vendor") +load("@rules_rust//crate_universe:repositories.bzl", "crate_universe_dependencies") -vendor( - name = "third-party", - cargo_version = RUST_VERSION, - lockfile = "//third-party:Cargo.lock", -) +crate_universe_dependencies() + +load("//third-party/bazel:defs.bzl", "crate_repositories") + +crate_repositories() diff --git a/book/src/build/other.md b/book/src/build/other.md index 8933c41b..af835e65 100644 --- a/book/src/build/other.md +++ b/book/src/build/other.md @@ -7,6 +7,12 @@ You will need to achieve at least these three things: - Compile the generated C++ code. - Link the resulting objects together with your other C++ and Rust objects. +*Not all build systems are created equal. If you're hoping to use a build system +from the '90s, especially if you're hoping to overlaying the limitations of 2 or +more build systems (like automake+cargo) and expect to solve them +simultaneously, then be mindful that your expectations are set accordingly and +seek sympathy from those who have imposed the same approach on themselves.* + ### Producing the generated code CXX's Rust code generation automatically happens when the `#[cxx::bridge]` diff --git a/book/src/extern-rust.md b/book/src/extern-rust.md index ab9dcb64..40f22375 100644 --- a/book/src/extern-rust.md +++ b/book/src/extern-rust.md @@ -91,7 +91,7 @@ statement. #[cxx::bridge] mod ffi { extern "Rust" { - struct MyType; + type MyType; fn f() -> Box<MyType>; } } @@ -21,19 +21,13 @@ fn main() { } if let Some(rustc) = rustc_version() { - if rustc.minor < 48 { - println!("cargo:warning=The cxx crate requires a rustc version 1.48.0 or newer."); + if rustc.minor < 60 { + println!("cargo:warning=The cxx crate requires a rustc version 1.60.0 or newer."); println!( "cargo:warning=You appear to be building with: {}", rustc.version, ); } - - if rustc.minor < 52 { - // #![deny(unsafe_op_in_unsafe_fn)]. - // https://github.com/rust-lang/rust/issues/71668 - println!("cargo:rustc-cfg=no_unsafe_op_in_unsafe_fn_lint"); - } } } diff --git a/flags/Cargo.toml b/flags/Cargo.toml index 8958481c..0baafb17 100644 --- a/flags/Cargo.toml +++ b/flags/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "cxxbridge-flags" -version = "1.0.85" +version = "1.0.93" authors = ["David Tolnay <dtolnay@gmail.com>"] categories = ["development-tools::ffi", "compilers"] description = "Compiler configuration of the `cxx` crate (implementation detail)" edition = "2018" license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/cxx" -rust-version = "1.48" +rust-version = "1.60" [features] default = [] # c++11 diff --git a/gen/build/Cargo.toml b/gen/build/Cargo.toml index ea19af89..9b74255b 100644 --- a/gen/build/Cargo.toml +++ b/gen/build/Cargo.toml @@ -1,16 +1,17 @@ [package] name = "cxx-build" -version = "1.0.85" +version = "1.0.93" authors = ["David Tolnay <dtolnay@gmail.com>"] categories = ["development-tools::build-utils", "development-tools::ffi"] description = "C++ code generator for integrating `cxx` crate into a Cargo build." +documentation = "https://docs.rs/cxx-build" edition = "2018" exclude = ["build.rs"] homepage = "https://cxx.rs" keywords = ["ffi", "build-dependencies"] license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/cxx" -rust-version = "1.48" +rust-version = "1.60" [features] parallel = ["cc/parallel"] @@ -24,7 +25,7 @@ once_cell = "1.9" proc-macro2 = { version = "1.0.39", default-features = false, features = ["span-locations"] } quote = { version = "1.0", default-features = false } scratch = "1.0" -syn = { version = "1.0.95", default-features = false, features = ["parsing", "printing", "clone-impls", "full"] } +syn = { version = "2.0.1", default-features = false, features = ["parsing", "printing", "clone-impls", "full"] } [dev-dependencies] cxx = { version = "1.0", path = "../.." } diff --git a/gen/build/src/lib.rs b/gen/build/src/lib.rs index 225042c2..b6b843a6 100644 --- a/gen/build/src/lib.rs +++ b/gen/build/src/lib.rs @@ -45,6 +45,7 @@ //! $ cxxbridge src/main.rs > path/to/mybridge.cc //! ``` +#![doc(html_root_url = "https://docs.rs/cxx-build/1.0.93")] #![allow( clippy::cast_sign_loss, clippy::default_trait_access, @@ -56,7 +57,6 @@ clippy::if_same_then_else, clippy::inherent_to_string, clippy::items_after_statements, - clippy::let_underscore_drop, clippy::match_bool, clippy::match_on_vec_items, clippy::match_same_arms, diff --git a/gen/cmd/Android.bp b/gen/cmd/Android.bp index ffda7dbc..1c402202 100644 --- a/gen/cmd/Android.bp +++ b/gen/cmd/Android.bp @@ -20,23 +20,6 @@ rust_binary_host { rustlibs: [ "libclap", "libcodespan_reporting", - "libcxxbridge_cmd", - "libproc_macro2", - "libquote", - "libsyn", - ], - compile_multilib: "first", -} - -rust_library_host { - name: "libcxxbridge_cmd", - crate_name: "cxxbridge_cmd", - cargo_env_compat: true, - srcs: ["src/lib.rs"], - edition: "2018", - rustlibs: [ - "libclap", - "libcodespan_reporting", "libproc_macro2", "libquote", "libsyn", diff --git a/gen/cmd/Cargo.toml b/gen/cmd/Cargo.toml index 39d9a617..0026a531 100644 --- a/gen/cmd/Cargo.toml +++ b/gen/cmd/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cxxbridge-cmd" -version = "1.0.85" +version = "1.0.93" authors = ["David Tolnay <dtolnay@gmail.com>"] categories = ["development-tools::build-utils", "development-tools::ffi"] description = "C++ code generator for integrating `cxx` crate into a non-Cargo build." @@ -25,7 +25,7 @@ clap = { version = "4", default-features = false, features = ["error-context", " codespan-reporting = "0.11" proc-macro2 = { version = "1.0.39", default-features = false, features = ["span-locations"] } quote = { version = "1.0", default-features = false } -syn = { version = "1.0.95", default-features = false, features = ["parsing", "printing", "clone-impls", "full"] } +syn = { version = "2.0.1", default-features = false, features = ["parsing", "printing", "clone-impls", "full"] } [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/gen/cmd/src/lib.rs b/gen/cmd/src/lib.rs deleted file mode 100644 index 8b1a3937..00000000 --- a/gen/cmd/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ -// empty diff --git a/gen/lib/Android.bp b/gen/lib/Android.bp new file mode 100644 index 00000000..64d2e16d --- /dev/null +++ b/gen/lib/Android.bp @@ -0,0 +1,17 @@ +rust_library_host { + name: "libcxx_gen", + crate_name: "cxx_gen", + cargo_env_compat: true, + cargo_pkg_version: "0.7.93", + srcs: ["src/lib.rs"], + edition: "2018", + rustlibs: [ + "libcodespan_reporting", + "libproc_macro2", + "libquote", + "libsyn", + ], + compile_multilib: "first", + product_available: true, + vendor_available: true, +} diff --git a/gen/lib/Cargo.toml b/gen/lib/Cargo.toml index df8c8558..b4f45b6b 100644 --- a/gen/lib/Cargo.toml +++ b/gen/lib/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cxx-gen" -version = "0.7.85" +version = "0.7.93" authors = ["Adrian Taylor <adetaylor@chromium.org>"] categories = ["development-tools::ffi"] description = "C++ code generator for integrating `cxx` crate into higher level tools." @@ -9,13 +9,13 @@ exclude = ["build.rs"] keywords = ["ffi"] license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/cxx" -rust-version = "1.48" +rust-version = "1.60" [dependencies] codespan-reporting = "0.11" proc-macro2 = { version = "1.0.39", default-features = false, features = ["span-locations"] } quote = { version = "1.0", default-features = false } -syn = { version = "1.0.95", default-features = false, features = ["parsing", "printing", "clone-impls", "full"] } +syn = { version = "2.0.1", default-features = false, features = ["parsing", "printing", "clone-impls", "full"] } [lib] doc-scrape-examples = false diff --git a/gen/lib/src/lib.rs b/gen/lib/src/lib.rs index 47cfa18d..36680b95 100644 --- a/gen/lib/src/lib.rs +++ b/gen/lib/src/lib.rs @@ -7,6 +7,7 @@ //! [dtolnay/cxx#235]: https://github.com/dtolnay/cxx/issues/235 //! [https://github.com/google/autocxx]: https://github.com/google/autocxx +#![doc(html_root_url = "https://docs.rs/cxx-gen/0.7.93")] #![deny(missing_docs)] #![allow(dead_code)] #![allow( diff --git a/gen/src/file.rs b/gen/src/file.rs index 46616fbd..4e4259ef 100644 --- a/gen/src/file.rs +++ b/gen/src/file.rs @@ -2,7 +2,7 @@ use crate::syntax::file::Module; use crate::syntax::namespace::Namespace; use syn::parse::discouraged::Speculative; use syn::parse::{Error, Parse, ParseStream, Result}; -use syn::{braced, Attribute, Ident, Item, Token, Visibility}; +use syn::{braced, Attribute, Ident, Item, Meta, Token, Visibility}; pub struct File { pub modules: Vec<Module>, @@ -23,7 +23,7 @@ fn parse(input: ParseStream, modules: &mut Vec<Module>) -> Result<()> { let mut namespace = Namespace::ROOT; let mut attrs = input.call(Attribute::parse_outer)?; for attr in &attrs { - let path = &attr.path.segments; + let path = &attr.path().segments; if path.len() == 2 && path[0].ident == "cxx" && path[1].ident == "bridge" { cxx_bridge = true; namespace = parse_args(attr)?; @@ -64,7 +64,7 @@ fn parse(input: ParseStream, modules: &mut Vec<Module>) -> Result<()> { } fn parse_args(attr: &Attribute) -> Result<Namespace> { - if attr.tokens.is_empty() { + if let Meta::Path(_) = attr.meta { Ok(Namespace::ROOT) } else { attr.parse_args_with(Namespace::parse_bridge_attr_namespace) diff --git a/macro/Cargo.toml b/macro/Cargo.toml index ed230388..89d97022 100644 --- a/macro/Cargo.toml +++ b/macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cxxbridge-macro" -version = "1.0.85" +version = "1.0.93" authors = ["David Tolnay <dtolnay@gmail.com>"] categories = ["development-tools::ffi"] description = "Implementation detail of the `cxx` crate." @@ -10,7 +10,7 @@ homepage = "https://cxx.rs" keywords = ["ffi"] license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/cxx" -rust-version = "1.48" +rust-version = "1.60" [lib] proc-macro = true @@ -23,7 +23,7 @@ experimental-enum-variants-from-header = ["clang-ast", "flate2", "memmap", "serd [dependencies] proc-macro2 = "1.0.39" quote = "1.0.4" -syn = { version = "1.0.95", features = ["full"] } +syn = { version = "2.0.1", features = ["full"] } # optional dependencies: clang-ast = { version = "0.1", optional = true } diff --git a/macro/src/derive.rs b/macro/src/derive.rs index afe85d1c..e1d8d69e 100644 --- a/macro/src/derive.rs +++ b/macro/src/derive.rs @@ -123,6 +123,7 @@ fn struct_clone(strct: &Struct, span: Span) -> TokenStream { }; quote_spanned! {span=> + #[allow(clippy::expl_impl_clone_on_copy)] impl #generics ::cxx::core::clone::Clone for #ident #generics { fn clone(&self) -> Self { #body @@ -230,6 +231,7 @@ fn enum_clone(enm: &Enum, span: Span) -> TokenStream { let ident = &enm.name.rust; quote_spanned! {span=> + #[allow(clippy::expl_impl_clone_on_copy)] impl ::cxx::core::clone::Clone for #ident { fn clone(&self) -> Self { *self diff --git a/macro/src/expand.rs b/macro/src/expand.rs index 8f5836a6..bd0a2063 100644 --- a/macro/src/expand.rs +++ b/macro/src/expand.rs @@ -139,7 +139,14 @@ fn expand(ffi: Module, doc: Doc, attrs: OtherAttrs, apis: &[Api], types: &Types) #attrs #[deny(improper_ctypes, improper_ctypes_definitions)] #[allow(clippy::unknown_clippy_lints)] - #[allow(non_camel_case_types, non_snake_case, clippy::upper_case_acronyms)] + #[allow( + non_camel_case_types, + non_snake_case, + clippy::extra_unused_type_parameters, + clippy::ptr_as_ptr, + clippy::upper_case_acronyms, + clippy::use_self, + )] #vis #mod_token #ident #expanded } } @@ -321,6 +328,7 @@ fn expand_enum(enm: &Enum) -> TokenStream { Some(quote_spanned! {span=> #doc #attrs + #[allow(dead_code)] pub const #variant_ident: Self = #ident { repr: #discriminant }; }) }); @@ -1256,7 +1264,7 @@ fn expand_rust_box(key: NamedImplKey, types: &Types, explicit_impl: Option<&Impl let (impl_generics, ty_generics) = generics::split_for_impl(key, explicit_impl, resolve); let begin_span = explicit_impl.map_or(key.begin_span, |explicit| explicit.impl_token.span); - let end_span = explicit_impl.map_or(key.end_span, |explicit| explicit.brace_token.span); + let end_span = explicit_impl.map_or(key.end_span, |explicit| explicit.brace_token.span.join()); let unsafe_token = format_ident!("unsafe", span = begin_span); let prevent_unwind_drop_label = format!("::{} as Drop>::drop", ident); @@ -1314,7 +1322,7 @@ fn expand_rust_vec(key: NamedImplKey, types: &Types, explicit_impl: Option<&Impl let (impl_generics, ty_generics) = generics::split_for_impl(key, explicit_impl, resolve); let begin_span = explicit_impl.map_or(key.begin_span, |explicit| explicit.impl_token.span); - let end_span = explicit_impl.map_or(key.end_span, |explicit| explicit.brace_token.span); + let end_span = explicit_impl.map_or(key.end_span, |explicit| explicit.brace_token.span.join()); let unsafe_token = format_ident!("unsafe", span = begin_span); let prevent_unwind_drop_label = format!("::{} as Drop>::drop", elem); @@ -1408,7 +1416,7 @@ fn expand_unique_ptr( }; let begin_span = explicit_impl.map_or(key.begin_span, |explicit| explicit.impl_token.span); - let end_span = explicit_impl.map_or(key.end_span, |explicit| explicit.brace_token.span); + let end_span = explicit_impl.map_or(key.end_span, |explicit| explicit.brace_token.span.join()); let unsafe_token = format_ident!("unsafe", span = begin_span); quote_spanned! {end_span=> @@ -1493,7 +1501,7 @@ fn expand_shared_ptr( }; let begin_span = explicit_impl.map_or(key.begin_span, |explicit| explicit.impl_token.span); - let end_span = explicit_impl.map_or(key.end_span, |explicit| explicit.brace_token.span); + let end_span = explicit_impl.map_or(key.end_span, |explicit| explicit.brace_token.span.join()); let unsafe_token = format_ident!("unsafe", span = begin_span); quote_spanned! {end_span=> @@ -1548,7 +1556,7 @@ fn expand_weak_ptr(key: NamedImplKey, types: &Types, explicit_impl: Option<&Impl let (impl_generics, ty_generics) = generics::split_for_impl(key, explicit_impl, resolve); let begin_span = explicit_impl.map_or(key.begin_span, |explicit| explicit.impl_token.span); - let end_span = explicit_impl.map_or(key.end_span, |explicit| explicit.brace_token.span); + let end_span = explicit_impl.map_or(key.end_span, |explicit| explicit.brace_token.span.join()); let unsafe_token = format_ident!("unsafe", span = begin_span); quote_spanned! {end_span=> @@ -1621,7 +1629,7 @@ fn expand_cxx_vector( let (impl_generics, ty_generics) = generics::split_for_impl(key, explicit_impl, resolve); let begin_span = explicit_impl.map_or(key.begin_span, |explicit| explicit.impl_token.span); - let end_span = explicit_impl.map_or(key.end_span, |explicit| explicit.brace_token.span); + let end_span = explicit_impl.map_or(key.end_span, |explicit| explicit.brace_token.span.join()); let unsafe_token = format_ident!("unsafe", span = begin_span); let can_pass_element_by_value = types.is_maybe_trivial(elem); @@ -1802,7 +1810,7 @@ fn expand_extern_type(ty: &Type, types: &Types, proper: bool) -> TokenStream { } Type::SliceRef(ty) => { let span = ty.ampersand.span; - let rust_slice = Ident::new("RustSlice", ty.bracket.span); + let rust_slice = Ident::new("RustSlice", ty.bracket.span.join()); quote_spanned!(span=> ::cxx::private::#rust_slice) } _ => quote!(#ty), diff --git a/macro/src/lib.rs b/macro/src/lib.rs index 138e3a29..d0205b32 100644 --- a/macro/src/lib.rs +++ b/macro/src/lib.rs @@ -29,8 +29,6 @@ clippy::wrong_self_convention )] -extern crate proc_macro; - mod derive; mod expand; mod generics; @@ -488,6 +488,7 @@ Error &Error::operator=(const Error &other) & { Error &Error::operator=(Error &&other) &noexcept { std::exception::operator=(std::move(other)); + delete[] this->msg; this->msg = other.msg; this->len = other.len; other.msg = nullptr; @@ -18,7 +18,7 @@ //! //! <br> //! -//! *Compiler support: requires rustc 1.48+ and c++11 or newer*<br> +//! *Compiler support: requires rustc 1.60+ and c++11 or newer*<br> //! *[Release notes](https://github.com/dtolnay/cxx/releases)* //! //! <br> @@ -364,10 +364,13 @@ //! </table> #![no_std] -#![doc(html_root_url = "https://docs.rs/cxx/1.0.85")] -#![deny(improper_ctypes, improper_ctypes_definitions, missing_docs)] -#![cfg_attr(not(no_unsafe_op_in_unsafe_fn_lint), deny(unsafe_op_in_unsafe_fn))] -#![cfg_attr(no_unsafe_op_in_unsafe_fn_lint, allow(unused_unsafe))] +#![doc(html_root_url = "https://docs.rs/cxx/1.0.93")] +#![deny( + improper_ctypes, + improper_ctypes_definitions, + missing_docs, + unsafe_op_in_unsafe_fn +)] #![cfg_attr(doc_cfg, feature(doc_cfg))] #![allow(non_camel_case_types)] #![allow( @@ -375,6 +378,7 @@ clippy::declare_interior_mutable_const, clippy::doc_markdown, clippy::empty_enum, + clippy::extra_unused_type_parameters, clippy::inherent_to_string, clippy::items_after_statements, clippy::large_enum_variant, diff --git a/src/lossy.rs b/src/lossy.rs index d68a2e7b..8ccf0f93 100644 --- a/src/lossy.rs +++ b/src/lossy.rs @@ -37,7 +37,7 @@ pub fn debug(mut bytes: &[u8], f: &mut fmt::Formatter) -> fmt::Result { let mut written = 0; for (i, ch) in valid.char_indices() { let esc = ch.escape_debug(); - if esc.len() != 1 { + if esc.len() != 1 && ch != '\'' { f.write_str(&valid[written..i])?; for ch in esc { f.write_char(ch)?; diff --git a/syntax/attrs.rs b/syntax/attrs.rs index 46d010e0..4ff700a8 100644 --- a/syntax/attrs.rs +++ b/syntax/attrs.rs @@ -5,8 +5,8 @@ use crate::syntax::Atom::{self, *}; use crate::syntax::{cfg, Derive, Doc, ForeignName}; use proc_macro2::{Ident, TokenStream}; use quote::ToTokens; -use syn::parse::{Nothing, Parse, ParseStream, Parser as _}; -use syn::{parenthesized, token, Attribute, Error, LitStr, Path, Result, Token}; +use syn::parse::ParseStream; +use syn::{Attribute, Error, Expr, Lit, LitStr, Meta, Path, Result, Token}; // Intended usage: // @@ -47,8 +47,9 @@ pub struct Parser<'a> { pub fn parse(cx: &mut Errors, attrs: Vec<Attribute>, mut parser: Parser) -> OtherAttrs { let mut passthrough_attrs = Vec::new(); for attr in attrs { - if attr.path.is_ident("doc") { - match parse_doc_attribute.parse2(attr.tokens.clone()) { + let attr_path = attr.path(); + if attr_path.is_ident("doc") { + match parse_doc_attribute(&attr.meta) { Ok(attr) => { if let Some(doc) = &mut parser.doc { match attr { @@ -63,7 +64,7 @@ pub fn parse(cx: &mut Errors, attrs: Vec<Attribute>, mut parser: Parser) -> Othe break; } } - } else if attr.path.is_ident("derive") { + } else if attr_path.is_ident("derive") { match attr.parse_args_with(|attr: ParseStream| parse_derive_attribute(cx, attr)) { Ok(attr) => { if let Some(derives) = &mut parser.derives { @@ -76,7 +77,7 @@ pub fn parse(cx: &mut Errors, attrs: Vec<Attribute>, mut parser: Parser) -> Othe break; } } - } else if attr.path.is_ident("repr") { + } else if attr_path.is_ident("repr") { match attr.parse_args_with(parse_repr_attribute) { Ok(attr) => { if let Some(repr) = &mut parser.repr { @@ -89,8 +90,8 @@ pub fn parse(cx: &mut Errors, attrs: Vec<Attribute>, mut parser: Parser) -> Othe break; } } - } else if attr.path.is_ident("namespace") { - match parse_namespace_attribute.parse2(attr.tokens.clone()) { + } else if attr_path.is_ident("namespace") { + match Namespace::parse_meta(&attr.meta) { Ok(attr) => { if let Some(namespace) = &mut parser.namespace { **namespace = attr; @@ -102,8 +103,8 @@ pub fn parse(cx: &mut Errors, attrs: Vec<Attribute>, mut parser: Parser) -> Othe break; } } - } else if attr.path.is_ident("cxx_name") { - match parse_cxx_name_attribute.parse2(attr.tokens.clone()) { + } else if attr_path.is_ident("cxx_name") { + match parse_cxx_name_attribute(&attr.meta) { Ok(attr) => { if let Some(cxx_name) = &mut parser.cxx_name { **cxx_name = Some(attr); @@ -115,8 +116,8 @@ pub fn parse(cx: &mut Errors, attrs: Vec<Attribute>, mut parser: Parser) -> Othe break; } } - } else if attr.path.is_ident("rust_name") { - match parse_rust_name_attribute.parse2(attr.tokens.clone()) { + } else if attr_path.is_ident("rust_name") { + match parse_rust_name_attribute(&attr.meta) { Ok(attr) => { if let Some(rust_name) = &mut parser.rust_name { **rust_name = Some(attr); @@ -128,8 +129,8 @@ pub fn parse(cx: &mut Errors, attrs: Vec<Attribute>, mut parser: Parser) -> Othe break; } } - } else if attr.path.is_ident("cfg") { - match cfg::parse_attribute.parse2(attr.tokens.clone()) { + } else if attr_path.is_ident("cfg") { + match cfg::parse_attribute(&attr) { Ok(cfg_expr) => { if let Some(cfg) = &mut parser.cfg { cfg.merge(cfg_expr); @@ -142,31 +143,31 @@ pub fn parse(cx: &mut Errors, attrs: Vec<Attribute>, mut parser: Parser) -> Othe break; } } - } else if attr.path.is_ident("variants_from_header") + } else if attr_path.is_ident("variants_from_header") && cfg!(feature = "experimental-enum-variants-from-header") { - if let Err(err) = Nothing::parse.parse2(attr.tokens.clone()) { + if let Err(err) = attr.meta.require_path_only() { cx.push(err); } if let Some(variants_from_header) = &mut parser.variants_from_header { **variants_from_header = Some(attr); continue; } - } else if attr.path.is_ident("allow") - || attr.path.is_ident("warn") - || attr.path.is_ident("deny") - || attr.path.is_ident("forbid") - || attr.path.is_ident("deprecated") - || attr.path.is_ident("must_use") + } else if attr_path.is_ident("allow") + || attr_path.is_ident("warn") + || attr_path.is_ident("deny") + || attr_path.is_ident("forbid") + || attr_path.is_ident("deprecated") + || attr_path.is_ident("must_use") { // https://doc.rust-lang.org/reference/attributes/diagnostics.html passthrough_attrs.push(attr); continue; - } else if attr.path.is_ident("serde") { + } else if attr_path.is_ident("serde") { passthrough_attrs.push(attr); continue; - } else if attr.path.segments.len() > 1 { - let tool = &attr.path.segments.first().unwrap().ident; + } else if attr_path.segments.len() > 1 { + let tool = &attr_path.segments.first().unwrap().ident; if tool == "rustfmt" { // Skip, rustfmt only needs to find it in the pre-expansion source file. continue; @@ -192,24 +193,26 @@ mod kw { syn::custom_keyword!(hidden); } -fn parse_doc_attribute(input: ParseStream) -> Result<DocAttribute> { - let lookahead = input.lookahead1(); - if lookahead.peek(Token![=]) { - input.parse::<Token![=]>()?; - let lit: LitStr = input.parse()?; - Ok(DocAttribute::Doc(lit)) - } else if lookahead.peek(token::Paren) { - let content; - parenthesized!(content in input); - content.parse::<kw::hidden>()?; - Ok(DocAttribute::Hidden) - } else { - Err(lookahead.error()) +fn parse_doc_attribute(meta: &Meta) -> Result<DocAttribute> { + match meta { + Meta::NameValue(meta) => { + if let Expr::Lit(expr) = &meta.value { + if let Lit::Str(lit) = &expr.lit { + return Ok(DocAttribute::Doc(lit.clone())); + } + } + } + Meta::List(meta) => { + meta.parse_args::<kw::hidden>()?; + return Ok(DocAttribute::Hidden); + } + Meta::Path(_) => {} } + Err(Error::new_spanned(meta, "unsupported doc attribute")) } fn parse_derive_attribute(cx: &mut Errors, input: ParseStream) -> Result<Vec<Derive>> { - let paths = input.parse_terminated::<Path, Token![,]>(Path::parse_mod_style)?; + let paths = input.parse_terminated(Path::parse_mod_style, Token![,])?; let mut derives = Vec::new(); for path in paths { @@ -241,31 +244,42 @@ fn parse_repr_attribute(input: ParseStream) -> Result<Atom> { )) } -fn parse_namespace_attribute(input: ParseStream) -> Result<Namespace> { - input.parse::<Token![=]>()?; - let namespace = input.parse::<Namespace>()?; - Ok(namespace) -} - -fn parse_cxx_name_attribute(input: ParseStream) -> Result<ForeignName> { - input.parse::<Token![=]>()?; - if input.peek(LitStr) { - let lit: LitStr = input.parse()?; - ForeignName::parse(&lit.value(), lit.span()) - } else { - let ident: Ident = input.parse()?; - ForeignName::parse(&ident.to_string(), ident.span()) +fn parse_cxx_name_attribute(meta: &Meta) -> Result<ForeignName> { + if let Meta::NameValue(meta) = meta { + match &meta.value { + Expr::Lit(expr) => { + if let Lit::Str(lit) = &expr.lit { + return ForeignName::parse(&lit.value(), lit.span()); + } + } + Expr::Path(expr) => { + if let Some(ident) = expr.path.get_ident() { + return ForeignName::parse(&ident.to_string(), ident.span()); + } + } + _ => {} + } } + Err(Error::new_spanned(meta, "unsupported cxx_name attribute")) } -fn parse_rust_name_attribute(input: ParseStream) -> Result<Ident> { - input.parse::<Token![=]>()?; - if input.peek(LitStr) { - let lit: LitStr = input.parse()?; - lit.parse() - } else { - input.parse() +fn parse_rust_name_attribute(meta: &Meta) -> Result<Ident> { + if let Meta::NameValue(meta) = meta { + match &meta.value { + Expr::Lit(expr) => { + if let Lit::Str(lit) = &expr.lit { + return lit.parse(); + } + } + Expr::Path(expr) => { + if let Some(ident) = expr.path.get_ident() { + return Ok(ident.clone()); + } + } + _ => {} + } } + Err(Error::new_spanned(meta, "unsupported rust_name attribute")) } #[derive(Clone)] @@ -288,15 +302,11 @@ impl ToTokens for OtherAttrs { pound_token, style, bracket_token, - path, - tokens: attr_tokens, + meta, } = attr; pound_token.to_tokens(tokens); let _ = style; // ignore; render outer and inner attrs both as outer - bracket_token.surround(tokens, |tokens| { - path.to_tokens(tokens); - attr_tokens.to_tokens(tokens); - }); + bracket_token.surround(tokens, |tokens| meta.to_tokens(tokens)); } } } diff --git a/syntax/cfg.rs b/syntax/cfg.rs index d486b995..ce6f3389 100644 --- a/syntax/cfg.rs +++ b/syntax/cfg.rs @@ -1,7 +1,7 @@ use proc_macro2::Ident; use std::mem; use syn::parse::{Error, ParseStream, Result}; -use syn::{parenthesized, token, LitStr, Token}; +use syn::{parenthesized, token, Attribute, LitStr, Token}; #[derive(Clone)] pub enum CfgExpr { @@ -25,12 +25,12 @@ impl CfgExpr { } } -pub fn parse_attribute(input: ParseStream) -> Result<CfgExpr> { - let content; - parenthesized!(content in input); - let cfg_expr = content.call(parse_single)?; - content.parse::<Option<Token![,]>>()?; - Ok(cfg_expr) +pub fn parse_attribute(attr: &Attribute) -> Result<CfgExpr> { + attr.parse_args_with(|input: ParseStream| { + let cfg_expr = input.call(parse_single)?; + input.parse::<Option<Token![,]>>()?; + Ok(cfg_expr) + }) } fn parse_single(input: ParseStream) -> Result<CfgExpr> { diff --git a/syntax/check.rs b/syntax/check.rs index b203ca1f..0770c847 100644 --- a/syntax/check.rs +++ b/syntax/check.rs @@ -88,7 +88,7 @@ fn check_type_ident(cx: &mut Check, name: &NamedType) { && !cx.types.rust.contains(ident) { let msg = format!("unsupported type: {}", ident); - cx.error(ident, &msg); + cx.error(ident, msg); } } @@ -664,14 +664,14 @@ fn is_opaque_cxx(cx: &mut Check, ty: &Ident) -> bool { fn span_for_struct_error(strct: &Struct) -> TokenStream { let struct_token = strct.struct_token; let mut brace_token = Group::new(Delimiter::Brace, TokenStream::new()); - brace_token.set_span(strct.brace_token.span); + brace_token.set_span(strct.brace_token.span.join()); quote!(#struct_token #brace_token) } fn span_for_enum_error(enm: &Enum) -> TokenStream { let enum_token = enm.enum_token; let mut brace_token = Group::new(Delimiter::Brace, TokenStream::new()); - brace_token.set_span(enm.brace_token.span); + brace_token.set_span(enm.brace_token.span.join()); quote!(#enum_token #brace_token) } diff --git a/syntax/names.rs b/syntax/names.rs index 8b93ac5c..329a1022 100644 --- a/syntax/names.rs +++ b/syntax/names.rs @@ -3,7 +3,8 @@ use crate::syntax::{Lifetimes, NamedType, Pair, Symbol}; use proc_macro2::{Ident, Span}; use std::fmt::{self, Display}; use std::iter; -use syn::parse::{Error, Result}; +use syn::ext::IdentExt; +use syn::parse::{Error, Parser, Result}; use syn::punctuated::Punctuated; #[derive(Clone)] @@ -41,7 +42,7 @@ impl ForeignName { pub fn parse(text: &str, span: Span) -> Result<Self> { // TODO: support C++ names containing whitespace (`unsigned int`) or // non-alphanumeric characters (`operator++`). - match syn::parse_str::<Ident>(text) { + match Ident::parse_any.parse_str(text) { Ok(ident) => { let text = ident.to_string(); Ok(ForeignName { text }) diff --git a/syntax/namespace.rs b/syntax/namespace.rs index 07185e18..aae865cc 100644 --- a/syntax/namespace.rs +++ b/syntax/namespace.rs @@ -3,8 +3,8 @@ use quote::IdentFragment; use std::fmt::{self, Display}; use std::iter::FromIterator; use std::slice::Iter; -use syn::parse::{Parse, ParseStream, Result}; -use syn::{Ident, Token}; +use syn::parse::{Error, Parse, ParseStream, Result}; +use syn::{Expr, Ident, Lit, Meta, Token}; mod kw { syn::custom_keyword!(namespace); @@ -24,7 +24,7 @@ impl Namespace { self.segments.iter() } - pub fn parse_bridge_attr_namespace(input: ParseStream) -> Result<Namespace> { + pub fn parse_bridge_attr_namespace(input: ParseStream) -> Result<Self> { if input.is_empty() { return Ok(Namespace::ROOT); } @@ -35,6 +35,37 @@ impl Namespace { input.parse::<Option<Token![,]>>()?; Ok(namespace) } + + pub fn parse_meta(meta: &Meta) -> Result<Self> { + if let Meta::NameValue(meta) = meta { + match &meta.value { + Expr::Lit(expr) => { + if let Lit::Str(lit) = &expr.lit { + let segments = QualifiedName::parse_quoted(lit)?.segments; + return Ok(Namespace { segments }); + } + } + Expr::Path(expr) + if expr.qself.is_none() + && expr + .path + .segments + .iter() + .all(|segment| segment.arguments.is_none()) => + { + let segments = expr + .path + .segments + .iter() + .map(|segment| segment.ident.clone()) + .collect(); + return Ok(Namespace { segments }); + } + _ => {} + } + } + Err(Error::new_spanned(meta, "unsupported namespace attribute")) + } } impl Default for &Namespace { diff --git a/syntax/parse.rs b/syntax/parse.rs index 1754c600..c6fee5f8 100644 --- a/syntax/parse.rs +++ b/syntax/parse.rs @@ -489,11 +489,7 @@ fn parse_extern_type( let type_token = foreign_type.type_token; let visibility = visibility_pub(&foreign_type.vis, type_token.span); let name = pair(namespace, &foreign_type.ident, cxx_name, rust_name); - let generics = Lifetimes { - lt_token: None, - lifetimes: Punctuated::new(), - gt_token: None, - }; + let generics = extern_type_lifetimes(cx, foreign_type.generics); let colon_token = None; let bounds = Vec::new(); let semi_token = foreign_type.semi_token; @@ -611,7 +607,27 @@ fn parse_extern_fn( }); continue; } - return Err(Error::new_spanned(arg, "unsupported signature")); + if let Some(colon_token) = arg.colon_token { + let ty = parse_type(&arg.ty)?; + if let Type::Ref(reference) = ty { + if let Type::Ident(ident) = reference.inner { + receiver = Some(Receiver { + pinned: reference.pinned, + ampersand: reference.ampersand, + lifetime: reference.lifetime, + mutable: reference.mutable, + var: Token![self](ident.rust.span()), + colon_token, + ty: ident, + shorthand: false, + pin_tokens: reference.pin_tokens, + mutability: reference.mutability, + }); + continue; + } + } + } + return Err(Error::new_spanned(arg, "unsupported method receiver")); } FnArg::Typed(arg) => { let ident = match arg.pat.as_ref() { @@ -622,45 +638,24 @@ fn parse_extern_fn( _ => return Err(Error::new_spanned(arg, "unsupported signature")), }; let ty = parse_type(&arg.ty)?; - if ident != "self" { - let cfg = CfgExpr::Unconditional; - let doc = Doc::new(); - let attrs = OtherAttrs::none(); - let visibility = Token![pub](ident.span()); - let name = pair(Namespace::default(), &ident, None, None); - let colon_token = arg.colon_token; - args.push_value(Var { - cfg, - doc, - attrs, - visibility, - name, - colon_token, - ty, - }); - if let Some(comma) = comma { - args.push_punct(*comma); - } - continue; - } - if let Type::Ref(reference) = ty { - if let Type::Ident(ident) = reference.inner { - receiver = Some(Receiver { - pinned: reference.pinned, - ampersand: reference.ampersand, - lifetime: reference.lifetime, - mutable: reference.mutable, - var: Token![self](ident.rust.span()), - colon_token: arg.colon_token, - ty: ident, - shorthand: false, - pin_tokens: reference.pin_tokens, - mutability: reference.mutability, - }); - continue; - } + let cfg = CfgExpr::Unconditional; + let doc = Doc::new(); + let attrs = OtherAttrs::none(); + let visibility = Token![pub](ident.span()); + let name = pair(Namespace::default(), &ident, None, None); + let colon_token = arg.colon_token; + args.push_value(Var { + cfg, + doc, + attrs, + visibility, + name, + colon_token, + ty, + }); + if let Some(comma) = comma { + args.push_punct(*comma); } - return Err(Error::new_spanned(arg, "unsupported method receiver")); } } } @@ -756,6 +751,45 @@ fn parse_extern_verbatim_type( let type_token: Token![type] = input.parse()?; let ident: Ident = input.parse()?; let generics: Generics = input.parse()?; + let lifetimes = extern_type_lifetimes(cx, generics); + let lookahead = input.lookahead1(); + if lookahead.peek(Token![=]) { + // type Alias = crate::path::to::Type; + parse_type_alias( + cx, + unparsed_attrs, + visibility, + type_token, + ident, + lifetimes, + input, + lang, + extern_block_cfg, + namespace, + attrs, + ) + } else if lookahead.peek(Token![:]) { + // type Opaque: Bound2 + Bound2; + parse_extern_type_bounded( + cx, + unparsed_attrs, + visibility, + type_token, + ident, + lifetimes, + input, + lang, + trusted, + extern_block_cfg, + namespace, + attrs, + ) + } else { + Err(lookahead.error()) + } +} + +fn extern_type_lifetimes(cx: &mut Errors, generics: Generics) -> Lifetimes { let mut lifetimes = Punctuated::new(); let mut has_unsupported_generic_param = false; for pair in generics.params.into_pairs() { @@ -788,45 +822,10 @@ fn parse_extern_verbatim_type( } } } - let lifetimes = Lifetimes { + Lifetimes { lt_token: generics.lt_token, lifetimes, gt_token: generics.gt_token, - }; - let lookahead = input.lookahead1(); - if lookahead.peek(Token![=]) { - // type Alias = crate::path::to::Type; - parse_type_alias( - cx, - unparsed_attrs, - visibility, - type_token, - ident, - lifetimes, - input, - lang, - extern_block_cfg, - namespace, - attrs, - ) - } else if lookahead.peek(Token![:]) || lookahead.peek(Token![;]) { - // type Opaque: Bound2 + Bound2; - parse_extern_type_bounded( - cx, - unparsed_attrs, - visibility, - type_token, - ident, - lifetimes, - input, - lang, - trusted, - extern_block_cfg, - namespace, - attrs, - ) - } else { - Err(lookahead.error()) } } @@ -928,9 +927,7 @@ fn parse_extern_type_bounded( } else { false } => {} - bound @ TypeParamBound::Trait(_) | bound @ TypeParamBound::Lifetime(_) => { - cx.error(bound, "unsupported trait"); - } + bound => cx.error(bound, "unsupported trait"), } let lookahead = input.lookahead1(); @@ -1004,7 +1001,7 @@ fn parse_impl(cx: &mut Errors, imp: ItemImpl) -> Result<Api> { if !imp.items.is_empty() { let mut span = Group::new(Delimiter::Brace, TokenStream::new()); - span.set_span(imp.brace_token.span); + span.set_span(imp.brace_token.span.join()); return Err(Error::new_spanned(span, "expected an empty impl block")); } @@ -1151,7 +1148,7 @@ fn parse_type(ty: &RustType) -> Result<Type> { RustType::Path(ty) => parse_type_path(ty), RustType::Array(ty) => parse_type_array(ty), RustType::BareFn(ty) => parse_type_fn(ty), - RustType::Tuple(ty) if ty.elems.is_empty() => Ok(Type::Void(ty.paren_token.span)), + RustType::Tuple(ty) if ty.elems.is_empty() => Ok(Type::Void(ty.paren_token.span.join())), _ => Err(Error::new_spanned(ty, "unsupported type")), } } @@ -1387,7 +1384,7 @@ fn parse_type_fn(ty: &TypeBareFn) -> Result<Type> { let (ident, colon_token) = match &arg.name { Some((ident, colon_token)) => (ident.clone(), *colon_token), None => { - let fn_span = ty.paren_token.span; + let fn_span = ty.paren_token.span.join(); let ident = format_ident!("arg{}", i, span = fn_span); let colon_token = Token![:](fn_span); (ident, colon_token) @@ -1470,8 +1467,7 @@ fn parse_return_type( fn visibility_pub(vis: &Visibility, inherited: Span) -> Token![pub] { Token![pub](match vis { - Visibility::Public(vis) => vis.pub_token.span, - Visibility::Crate(vis) => vis.crate_token.span, + Visibility::Public(vis) => vis.span, Visibility::Restricted(vis) => vis.pub_token.span, Visibility::Inherited => inherited, }) diff --git a/syntax/qualified.rs b/syntax/qualified.rs index 5f182fa9..e11ffbc1 100644 --- a/syntax/qualified.rs +++ b/syntax/qualified.rs @@ -7,6 +7,18 @@ pub struct QualifiedName { } impl QualifiedName { + pub fn parse_quoted(lit: &LitStr) -> Result<Self> { + if lit.value().is_empty() { + let segments = Vec::new(); + Ok(QualifiedName { segments }) + } else { + lit.parse_with(|input: ParseStream| { + let allow_raw = false; + parse_unquoted(input, allow_raw) + }) + } + } + pub fn parse_unquoted(input: ParseStream) -> Result<Self> { let allow_raw = true; parse_unquoted(input, allow_raw) @@ -15,15 +27,7 @@ impl QualifiedName { pub fn parse_quoted_or_unquoted(input: ParseStream) -> Result<Self> { if input.peek(LitStr) { let lit: LitStr = input.parse()?; - if lit.value().is_empty() { - let segments = Vec::new(); - Ok(QualifiedName { segments }) - } else { - lit.parse_with(|input: ParseStream| { - let allow_raw = false; - parse_unquoted(input, allow_raw) - }) - } + Self::parse_quoted(&lit) } else { Self::parse_unquoted(input) } diff --git a/syntax/tokens.rs b/syntax/tokens.rs index a9f42bd4..05eddc70 100644 --- a/syntax/tokens.rs +++ b/syntax/tokens.rs @@ -270,7 +270,7 @@ impl ToTokens for Signature { args.to_tokens(tokens); }); if let Some(ret) = ret { - Token![->](paren_token.span).to_tokens(tokens); + Token![->](paren_token.span.join()).to_tokens(tokens); if let Some((result, langle, rangle)) = throws_tokens { result.to_tokens(tokens); langle.to_tokens(tokens); @@ -280,7 +280,7 @@ impl ToTokens for Signature { ret.to_tokens(tokens); } } else if let Some((result, langle, rangle)) = throws_tokens { - Token![->](paren_token.span).to_tokens(tokens); + Token![->](paren_token.span.join()).to_tokens(tokens); result.to_tokens(tokens); langle.to_tokens(tokens); token::Paren(langle.span).surround(tokens, |_| ()); diff --git a/tests/cxx_string.rs b/tests/cxx_string.rs index be693cd2..67444fa5 100644 --- a/tests/cxx_string.rs +++ b/tests/cxx_string.rs @@ -13,3 +13,10 @@ fn test_async_cxx_string() { fn assert_send(_: impl Send) {} assert_send(f()); } + +#[test] +fn test_debug() { + let_cxx_string!(s = "x\"y\'z"); + + assert_eq!(format!("{:?}", s), r#""x\"y'z""#); +} diff --git a/tests/ffi/build.rs b/tests/ffi/build.rs index 86f8cd3a..a1a64b7f 100644 --- a/tests/ffi/build.rs +++ b/tests/ffi/build.rs @@ -15,4 +15,7 @@ fn main() { build.define("CXX_TEST_INSTANTIATIONS", None); } build.compile("cxx-test-suite"); + + println!("cargo:rerun-if-changed=tests.cc"); + println!("cargo:rerun-if-changed=tests.h"); } diff --git a/tests/ffi/lib.rs b/tests/ffi/lib.rs index 9286cf7a..d6a5f028 100644 --- a/tests/ffi/lib.rs +++ b/tests/ffi/lib.rs @@ -2,7 +2,6 @@ clippy::boxed_local, clippy::derive_partial_eq_without_eq, clippy::just_underscores_and_digits, - clippy::let_underscore_drop, clippy::missing_safety_doc, clippy::must_use_candidate, clippy::needless_lifetimes, @@ -44,6 +43,7 @@ pub mod ffi { #[namespace = "A"] #[derive(Copy, Clone, Default)] struct AShared { + #[cxx_name = "type"] z: usize, } diff --git a/tests/ffi/tests.cc b/tests/ffi/tests.cc index 984e2220..8cf74beb 100644 --- a/tests/ffi/tests.cc +++ b/tests/ffi/tests.cc @@ -86,7 +86,9 @@ std::unique_ptr<::H::H> c_return_ns_unique_ptr() { const size_t &c_return_ref(const Shared &shared) { return shared.z; } -const size_t &c_return_ns_ref(const ::A::AShared &shared) { return shared.z; } +const size_t &c_return_ns_ref(const ::A::AShared &shared) { + return shared.type; +} const size_t &c_return_nested_ns_ref(const ::A::B::ABShared &shared) { return shared.z; @@ -240,7 +242,7 @@ void c_take_shared(Shared shared) { } void c_take_ns_shared(::A::AShared shared) { - if (shared.z == 2020) { + if (shared.type == 2020) { cxx_test_suite_set_correct(); } } @@ -397,7 +399,7 @@ void c_take_rust_vec_shared(rust::Vec<Shared> v) { void c_take_rust_vec_ns_shared(rust::Vec<::A::AShared> v) { uint32_t sum = 0; for (auto i : v) { - sum += i.z; + sum += i.type; } if (sum == 2021) { cxx_test_suite_set_correct(); @@ -916,7 +918,7 @@ void ns_c_take_trivial(::tests::D d) { } void ns_c_take_ns_shared(::A::AShared shared) { - if (shared.z == 2020) { + if (shared.type == 2020) { cxx_test_suite_set_correct(); } } diff --git a/tests/ui/derive_noncopy.stderr b/tests/ui/derive_noncopy.stderr index 419b0f22..b4f35d3e 100644 --- a/tests/ui/derive_noncopy.stderr +++ b/tests/ui/derive_noncopy.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> tests/ui/derive_noncopy.rs:4:12 | 4 | struct TryCopy { diff --git a/tests/ui/include.stderr b/tests/ui/include.stderr index 45cc5591..b801530e 100644 --- a/tests/ui/include.stderr +++ b/tests/ui/include.stderr @@ -11,10 +11,10 @@ error: unexpected token | ^^^^ error: expected `>` - --> tests/ui/include.rs:6:17 + --> tests/ui/include.rs:6:26 | 6 | include!(<path/to); - | ^^^^^^^^^^ + | ^ error: unexpected token in include path --> tests/ui/include.rs:7:23 diff --git a/tests/ui/opaque_autotraits.stderr b/tests/ui/opaque_autotraits.stderr index 521d9864..c6447c55 100644 --- a/tests/ui/opaque_autotraits.stderr +++ b/tests/ui/opaque_autotraits.stderr @@ -5,9 +5,9 @@ error[E0277]: `*const cxx::void` cannot be sent between threads safely | ^^^^^^^^^^^ `*const cxx::void` cannot be sent between threads safely | = help: within `ffi::Opaque`, the trait `Send` is not implemented for `*const cxx::void` - = note: required because it appears within the type `[*const cxx::void; 0]` - = note: required because it appears within the type `cxx::private::Opaque` -note: required because it appears within the type `ffi::Opaque` + = note: required because it appears within the type `[*const void; 0]` + = note: required because it appears within the type `Opaque` +note: required because it appears within the type `Opaque` --> tests/ui/opaque_autotraits.rs:4:14 | 4 | type Opaque; @@ -25,9 +25,9 @@ error[E0277]: `*const cxx::void` cannot be shared between threads safely | ^^^^^^^^^^^ `*const cxx::void` cannot be shared between threads safely | = help: within `ffi::Opaque`, the trait `Sync` is not implemented for `*const cxx::void` - = note: required because it appears within the type `[*const cxx::void; 0]` - = note: required because it appears within the type `cxx::private::Opaque` -note: required because it appears within the type `ffi::Opaque` + = note: required because it appears within the type `[*const void; 0]` + = note: required because it appears within the type `Opaque` +note: required because it appears within the type `Opaque` --> tests/ui/opaque_autotraits.rs:4:14 | 4 | type Opaque; @@ -46,8 +46,8 @@ error[E0277]: `PhantomPinned` cannot be unpinned | = note: consider using `Box::pin` = note: required because it appears within the type `PhantomData<PhantomPinned>` - = note: required because it appears within the type `cxx::private::Opaque` -note: required because it appears within the type `ffi::Opaque` + = note: required because it appears within the type `Opaque` +note: required because it appears within the type `Opaque` --> tests/ui/opaque_autotraits.rs:4:14 | 4 | type Opaque; diff --git a/tests/ui/unique_ptr_to_opaque.stderr b/tests/ui/unique_ptr_to_opaque.stderr index 6f028f5a..3c121e54 100644 --- a/tests/ui/unique_ptr_to_opaque.stderr +++ b/tests/ui/unique_ptr_to_opaque.stderr @@ -1,8 +1,8 @@ -error[E0271]: type mismatch resolving `<outside::C as ExternType>::Kind == Trivial` +error[E0271]: type mismatch resolving `<C as ExternType>::Kind == Trivial` --> tests/ui/unique_ptr_to_opaque.rs:22:25 | 22 | cxx::UniquePtr::new(outside::C { a: 4 }); - | ------------------- ^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<outside::C as ExternType>::Kind == Trivial` + | ------------------- ^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<C as ExternType>::Kind == Trivial` | | | required by a bound introduced by this call | diff --git a/tests/ui/unpin_impl.stderr b/tests/ui/unpin_impl.stderr index 18099bb6..afe5a806 100644 --- a/tests/ui/unpin_impl.stderr +++ b/tests/ui/unpin_impl.stderr @@ -1,16 +1,14 @@ error[E0282]: type annotations needed - --> tests/ui/unpin_impl.rs:1:1 - | -1 | #[cxx::bridge] - | ^^^^^^^^^^^^^^ cannot infer type of the type parameter `Self` declared on the trait `__AmbiguousIfImpl` + --> tests/ui/unpin_impl.rs:4:14 | - = note: this error originates in the attribute macro `cxx::bridge` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | type Opaque; + | ^^^^^^ cannot infer type error[E0283]: type annotations needed --> tests/ui/unpin_impl.rs:1:1 | 1 | #[cxx::bridge] - | ^^^^^^^^^^^^^^ cannot infer type of the type parameter `Self` declared on the trait `__AmbiguousIfImpl` + | ^^^^^^^^^^^^^^ cannot infer type | note: multiple `impl`s satisfying `ffi::Opaque: __AmbiguousIfImpl<_>` found --> tests/ui/unpin_impl.rs:1:1 diff --git a/tests/ui/unsupported_elided.stderr b/tests/ui/unsupported_elided.stderr index 6926b824..4ccac6fb 100644 --- a/tests/ui/unsupported_elided.stderr +++ b/tests/ui/unsupported_elided.stderr @@ -4,7 +4,6 @@ error[E0726]: implicit elided lifetime not allowed here 6 | type T; | ^ expected lifetime parameter | - = note: assuming a `'static` lifetime... help: indicate the anonymous lifetime | 6 | type T<'_>; diff --git a/tests/ui/vec_opaque.stderr b/tests/ui/vec_opaque.stderr index cd038e66..ae01adfc 100644 --- a/tests/ui/vec_opaque.stderr +++ b/tests/ui/vec_opaque.stderr @@ -10,11 +10,11 @@ error: needs a cxx::ExternType impl in order to be used as a vector element in V 11 | type Job; | ^^^^^^^^ -error[E0271]: type mismatch resolving `<handle::Job as ExternType>::Kind == Trivial` +error[E0271]: type mismatch resolving `<Job as ExternType>::Kind == Trivial` --> tests/ui/vec_opaque.rs:22:14 | 22 | type Job = crate::handle::Job; - | ^^^ expected enum `Trivial`, found enum `Opaque` + | ^^^ expected `Trivial`, found `Opaque` | note: required by a bound in `verify_extern_kind` --> src/extern_type.rs diff --git a/tests/ui/vector_autotraits.stderr b/tests/ui/vector_autotraits.stderr index d8559d00..8851cedc 100644 --- a/tests/ui/vector_autotraits.stderr +++ b/tests/ui/vector_autotraits.stderr @@ -5,8 +5,8 @@ error[E0277]: `*const cxx::void` cannot be sent between threads safely | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*const cxx::void` cannot be sent between threads safely | = help: within `CxxVector<NotThreadSafe>`, the trait `Send` is not implemented for `*const cxx::void` - = note: required because it appears within the type `[*const cxx::void; 0]` - = note: required because it appears within the type `cxx::private::Opaque` + = note: required because it appears within the type `[*const void; 0]` + = note: required because it appears within the type `Opaque` note: required because it appears within the type `NotThreadSafe` --> tests/ui/vector_autotraits.rs:7:14 | diff --git a/tests/ui/wrong_type_id.stderr b/tests/ui/wrong_type_id.stderr index 8cb78980..d3ed3a0c 100644 --- a/tests/ui/wrong_type_id.stderr +++ b/tests/ui/wrong_type_id.stderr @@ -1,4 +1,4 @@ -error[E0271]: type mismatch resolving `<StringPiece as ExternType>::Id == (f, o, l, l, y, (), B, y, t, e, R, a, n, g, e)` +error[E0271]: type mismatch resolving `<StringPiece as ExternType>::Id == (f, o, l, l, y, (), B, y, t, e, ..., ..., ..., ..., ...)` --> tests/ui/wrong_type_id.rs:11:14 | 11 | type ByteRange = crate::here::StringPiece; diff --git a/tests/unique_ptr.rs b/tests/unique_ptr.rs index bbaa3164..e5eb66bc 100644 --- a/tests/unique_ptr.rs +++ b/tests/unique_ptr.rs @@ -1,5 +1,3 @@ -#![allow(clippy::let_underscore_drop)] - use cxx::{CxxString, UniquePtr}; #[test] diff --git a/third-party/BUCK b/third-party/BUCK index 8036117e..cb756ae7 100644 --- a/third-party/BUCK +++ b/third-party/BUCK @@ -1,8 +1,9 @@ # @generated by `reindeer buckify` load("//tools/buck:buildscript.bzl", "buildscript_args") +load("//tools/buck:third_party.bzl", "third_party_rust_library") -rust_library( +third_party_rust_library( name = "bitflags-1.3.2", srcs = [ "vendor/bitflags-1.3.2/src/example_generated.rs", @@ -18,23 +19,23 @@ rust_library( alias( name = "cc", - actual = ":cc-1.0.77", + actual = ":cc-1.0.79", visibility = ["PUBLIC"], ) -rust_library( - name = "cc-1.0.77", +third_party_rust_library( + name = "cc-1.0.79", srcs = [ - "vendor/cc-1.0.77/src/com.rs", - "vendor/cc-1.0.77/src/lib.rs", - "vendor/cc-1.0.77/src/registry.rs", - "vendor/cc-1.0.77/src/setup_config.rs", - "vendor/cc-1.0.77/src/vs_instances.rs", - "vendor/cc-1.0.77/src/winapi.rs", - "vendor/cc-1.0.77/src/windows_registry.rs", + "vendor/cc-1.0.79/src/com.rs", + "vendor/cc-1.0.79/src/lib.rs", + "vendor/cc-1.0.79/src/registry.rs", + "vendor/cc-1.0.79/src/setup_config.rs", + "vendor/cc-1.0.79/src/vs_instances.rs", + "vendor/cc-1.0.79/src/winapi.rs", + "vendor/cc-1.0.79/src/windows_registry.rs", ], crate = "cc", - crate_root = "vendor/cc-1.0.77/src/lib.rs", + crate_root = "vendor/cc-1.0.79/src/lib.rs", edition = "2018", rustc_flags = ["--cap-lints=allow"], visibility = [], @@ -42,90 +43,90 @@ rust_library( alias( name = "clap", - actual = ":clap-4.0.29", + actual = ":clap-4.1.10", visibility = ["PUBLIC"], ) -rust_library( - name = "clap-4.0.29", +third_party_rust_library( + name = "clap-4.1.10", srcs = [ - "vendor/clap-4.0.29/examples/demo.md", - "vendor/clap-4.0.29/examples/demo.rs", - "vendor/clap-4.0.29/src/_cookbook/cargo_example.rs", - "vendor/clap-4.0.29/src/_cookbook/cargo_example_derive.rs", - "vendor/clap-4.0.29/src/_cookbook/escaped_positional.rs", - "vendor/clap-4.0.29/src/_cookbook/escaped_positional_derive.rs", - "vendor/clap-4.0.29/src/_cookbook/find.rs", - "vendor/clap-4.0.29/src/_cookbook/git.rs", - "vendor/clap-4.0.29/src/_cookbook/git_derive.rs", - "vendor/clap-4.0.29/src/_cookbook/mod.rs", - "vendor/clap-4.0.29/src/_cookbook/multicall_busybox.rs", - "vendor/clap-4.0.29/src/_cookbook/multicall_hostname.rs", - "vendor/clap-4.0.29/src/_cookbook/pacman.rs", - "vendor/clap-4.0.29/src/_cookbook/repl.rs", - "vendor/clap-4.0.29/src/_cookbook/typed_derive.rs", - "vendor/clap-4.0.29/src/_derive/_tutorial.rs", - "vendor/clap-4.0.29/src/_derive/mod.rs", - "vendor/clap-4.0.29/src/_faq.rs", - "vendor/clap-4.0.29/src/_features.rs", - "vendor/clap-4.0.29/src/_tutorial.rs", - "vendor/clap-4.0.29/src/builder/action.rs", - "vendor/clap-4.0.29/src/builder/app_settings.rs", - "vendor/clap-4.0.29/src/builder/arg.rs", - "vendor/clap-4.0.29/src/builder/arg_group.rs", - "vendor/clap-4.0.29/src/builder/arg_predicate.rs", - "vendor/clap-4.0.29/src/builder/arg_settings.rs", - "vendor/clap-4.0.29/src/builder/command.rs", - "vendor/clap-4.0.29/src/builder/debug_asserts.rs", - "vendor/clap-4.0.29/src/builder/mod.rs", - "vendor/clap-4.0.29/src/builder/os_str.rs", - "vendor/clap-4.0.29/src/builder/possible_value.rs", - "vendor/clap-4.0.29/src/builder/range.rs", - "vendor/clap-4.0.29/src/builder/resettable.rs", - "vendor/clap-4.0.29/src/builder/str.rs", - "vendor/clap-4.0.29/src/builder/styled_str.rs", - "vendor/clap-4.0.29/src/builder/tests.rs", - "vendor/clap-4.0.29/src/builder/value_hint.rs", - "vendor/clap-4.0.29/src/builder/value_parser.rs", - "vendor/clap-4.0.29/src/derive.rs", - "vendor/clap-4.0.29/src/error/context.rs", - "vendor/clap-4.0.29/src/error/format.rs", - "vendor/clap-4.0.29/src/error/kind.rs", - "vendor/clap-4.0.29/src/error/mod.rs", - "vendor/clap-4.0.29/src/lib.rs", - "vendor/clap-4.0.29/src/macros.rs", - "vendor/clap-4.0.29/src/mkeymap.rs", - "vendor/clap-4.0.29/src/output/fmt.rs", - "vendor/clap-4.0.29/src/output/help.rs", - "vendor/clap-4.0.29/src/output/help_template.rs", - "vendor/clap-4.0.29/src/output/mod.rs", - "vendor/clap-4.0.29/src/output/textwrap/core.rs", - "vendor/clap-4.0.29/src/output/textwrap/mod.rs", - "vendor/clap-4.0.29/src/output/textwrap/word_separators.rs", - "vendor/clap-4.0.29/src/output/textwrap/wrap_algorithms.rs", - "vendor/clap-4.0.29/src/output/usage.rs", - "vendor/clap-4.0.29/src/parser/arg_matcher.rs", - "vendor/clap-4.0.29/src/parser/error.rs", - "vendor/clap-4.0.29/src/parser/features/mod.rs", - "vendor/clap-4.0.29/src/parser/features/suggestions.rs", - "vendor/clap-4.0.29/src/parser/matches/any_value.rs", - "vendor/clap-4.0.29/src/parser/matches/arg_matches.rs", - "vendor/clap-4.0.29/src/parser/matches/matched_arg.rs", - "vendor/clap-4.0.29/src/parser/matches/mod.rs", - "vendor/clap-4.0.29/src/parser/matches/value_source.rs", - "vendor/clap-4.0.29/src/parser/mod.rs", - "vendor/clap-4.0.29/src/parser/parser.rs", - "vendor/clap-4.0.29/src/parser/validator.rs", - "vendor/clap-4.0.29/src/util/color.rs", - "vendor/clap-4.0.29/src/util/flat_map.rs", - "vendor/clap-4.0.29/src/util/flat_set.rs", - "vendor/clap-4.0.29/src/util/graph.rs", - "vendor/clap-4.0.29/src/util/id.rs", - "vendor/clap-4.0.29/src/util/mod.rs", - "vendor/clap-4.0.29/src/util/str_to_bool.rs", + "vendor/clap-4.1.10/examples/demo.md", + "vendor/clap-4.1.10/examples/demo.rs", + "vendor/clap-4.1.10/src/_cookbook/cargo_example.rs", + "vendor/clap-4.1.10/src/_cookbook/cargo_example_derive.rs", + "vendor/clap-4.1.10/src/_cookbook/escaped_positional.rs", + "vendor/clap-4.1.10/src/_cookbook/escaped_positional_derive.rs", + "vendor/clap-4.1.10/src/_cookbook/find.rs", + "vendor/clap-4.1.10/src/_cookbook/git.rs", + "vendor/clap-4.1.10/src/_cookbook/git_derive.rs", + "vendor/clap-4.1.10/src/_cookbook/mod.rs", + "vendor/clap-4.1.10/src/_cookbook/multicall_busybox.rs", + "vendor/clap-4.1.10/src/_cookbook/multicall_hostname.rs", + "vendor/clap-4.1.10/src/_cookbook/pacman.rs", + "vendor/clap-4.1.10/src/_cookbook/repl.rs", + "vendor/clap-4.1.10/src/_cookbook/typed_derive.rs", + "vendor/clap-4.1.10/src/_derive/_tutorial.rs", + "vendor/clap-4.1.10/src/_derive/mod.rs", + "vendor/clap-4.1.10/src/_faq.rs", + "vendor/clap-4.1.10/src/_features.rs", + "vendor/clap-4.1.10/src/_tutorial.rs", + "vendor/clap-4.1.10/src/builder/action.rs", + "vendor/clap-4.1.10/src/builder/app_settings.rs", + "vendor/clap-4.1.10/src/builder/arg.rs", + "vendor/clap-4.1.10/src/builder/arg_group.rs", + "vendor/clap-4.1.10/src/builder/arg_predicate.rs", + "vendor/clap-4.1.10/src/builder/arg_settings.rs", + "vendor/clap-4.1.10/src/builder/command.rs", + "vendor/clap-4.1.10/src/builder/debug_asserts.rs", + "vendor/clap-4.1.10/src/builder/mod.rs", + "vendor/clap-4.1.10/src/builder/os_str.rs", + "vendor/clap-4.1.10/src/builder/possible_value.rs", + "vendor/clap-4.1.10/src/builder/range.rs", + "vendor/clap-4.1.10/src/builder/resettable.rs", + "vendor/clap-4.1.10/src/builder/str.rs", + "vendor/clap-4.1.10/src/builder/styled_str.rs", + "vendor/clap-4.1.10/src/builder/tests.rs", + "vendor/clap-4.1.10/src/builder/value_hint.rs", + "vendor/clap-4.1.10/src/builder/value_parser.rs", + "vendor/clap-4.1.10/src/derive.rs", + "vendor/clap-4.1.10/src/error/context.rs", + "vendor/clap-4.1.10/src/error/format.rs", + "vendor/clap-4.1.10/src/error/kind.rs", + "vendor/clap-4.1.10/src/error/mod.rs", + "vendor/clap-4.1.10/src/lib.rs", + "vendor/clap-4.1.10/src/macros.rs", + "vendor/clap-4.1.10/src/mkeymap.rs", + "vendor/clap-4.1.10/src/output/fmt.rs", + "vendor/clap-4.1.10/src/output/help.rs", + "vendor/clap-4.1.10/src/output/help_template.rs", + "vendor/clap-4.1.10/src/output/mod.rs", + "vendor/clap-4.1.10/src/output/textwrap/core.rs", + "vendor/clap-4.1.10/src/output/textwrap/mod.rs", + "vendor/clap-4.1.10/src/output/textwrap/word_separators.rs", + "vendor/clap-4.1.10/src/output/textwrap/wrap_algorithms.rs", + "vendor/clap-4.1.10/src/output/usage.rs", + "vendor/clap-4.1.10/src/parser/arg_matcher.rs", + "vendor/clap-4.1.10/src/parser/error.rs", + "vendor/clap-4.1.10/src/parser/features/mod.rs", + "vendor/clap-4.1.10/src/parser/features/suggestions.rs", + "vendor/clap-4.1.10/src/parser/matches/any_value.rs", + "vendor/clap-4.1.10/src/parser/matches/arg_matches.rs", + "vendor/clap-4.1.10/src/parser/matches/matched_arg.rs", + "vendor/clap-4.1.10/src/parser/matches/mod.rs", + "vendor/clap-4.1.10/src/parser/matches/value_source.rs", + "vendor/clap-4.1.10/src/parser/mod.rs", + "vendor/clap-4.1.10/src/parser/parser.rs", + "vendor/clap-4.1.10/src/parser/validator.rs", + "vendor/clap-4.1.10/src/util/color.rs", + "vendor/clap-4.1.10/src/util/flat_map.rs", + "vendor/clap-4.1.10/src/util/flat_set.rs", + "vendor/clap-4.1.10/src/util/graph.rs", + "vendor/clap-4.1.10/src/util/id.rs", + "vendor/clap-4.1.10/src/util/mod.rs", + "vendor/clap-4.1.10/src/util/str_to_bool.rs", ], crate = "clap", - crate_root = "vendor/clap-4.0.29/src/lib.rs", + crate_root = "vendor/clap-4.1.10/src/lib.rs", edition = "2021", features = [ "error-context", @@ -137,15 +138,15 @@ rust_library( visibility = [], deps = [ ":bitflags-1.3.2", - ":clap_lex-0.3.0", + ":clap_lex-0.3.3", ], ) -rust_library( - name = "clap_lex-0.3.0", - srcs = ["vendor/clap_lex-0.3.0/src/lib.rs"], +third_party_rust_library( + name = "clap_lex-0.3.3", + srcs = ["vendor/clap_lex-0.3.3/src/lib.rs"], crate = "clap_lex", - crate_root = "vendor/clap_lex-0.3.0/src/lib.rs", + crate_root = "vendor/clap_lex-0.3.3/src/lib.rs", edition = "2021", rustc_flags = ["--cap-lints=allow"], visibility = [], @@ -158,7 +159,7 @@ alias( visibility = ["PUBLIC"], ) -rust_library( +third_party_rust_library( name = "codespan-reporting-0.11.1", srcs = [ "vendor/codespan-reporting-0.11.1/src/diagnostic.rs", @@ -175,28 +176,28 @@ rust_library( rustc_flags = ["--cap-lints=allow"], visibility = [], deps = [ - ":termcolor-1.1.3", + ":termcolor-1.2.0", ":unicode-width-0.1.10", ], ) alias( name = "once_cell", - actual = ":once_cell-1.16.0", + actual = ":once_cell-1.17.1", visibility = ["PUBLIC"], ) -rust_library( - name = "once_cell-1.16.0", +third_party_rust_library( + name = "once_cell-1.17.1", srcs = [ - "vendor/once_cell-1.16.0/src/imp_cs.rs", - "vendor/once_cell-1.16.0/src/imp_pl.rs", - "vendor/once_cell-1.16.0/src/imp_std.rs", - "vendor/once_cell-1.16.0/src/lib.rs", - "vendor/once_cell-1.16.0/src/race.rs", + "vendor/once_cell-1.17.1/src/imp_cs.rs", + "vendor/once_cell-1.17.1/src/imp_pl.rs", + "vendor/once_cell-1.17.1/src/imp_std.rs", + "vendor/once_cell-1.17.1/src/lib.rs", + "vendor/once_cell-1.17.1/src/race.rs", ], crate = "once_cell", - crate_root = "vendor/once_cell-1.16.0/src/lib.rs", + crate_root = "vendor/once_cell-1.17.1/src/lib.rs", edition = "2021", features = [ "alloc", @@ -208,7 +209,7 @@ rust_library( visibility = [], ) -rust_library( +third_party_rust_library( name = "os_str_bytes-6.4.1", srcs = [ "vendor/os_str_bytes-6.4.1/src/common/mod.rs", @@ -237,23 +238,25 @@ rust_library( alias( name = "proc-macro2", - actual = ":proc-macro2-1.0.47", + actual = ":proc-macro2-1.0.52", visibility = ["PUBLIC"], ) -rust_library( - name = "proc-macro2-1.0.47", +third_party_rust_library( + name = "proc-macro2-1.0.52", srcs = [ - "vendor/proc-macro2-1.0.47/src/detection.rs", - "vendor/proc-macro2-1.0.47/src/fallback.rs", - "vendor/proc-macro2-1.0.47/src/lib.rs", - "vendor/proc-macro2-1.0.47/src/marker.rs", - "vendor/proc-macro2-1.0.47/src/parse.rs", - "vendor/proc-macro2-1.0.47/src/rcvec.rs", - "vendor/proc-macro2-1.0.47/src/wrapper.rs", + "vendor/proc-macro2-1.0.52/src/detection.rs", + "vendor/proc-macro2-1.0.52/src/extra.rs", + "vendor/proc-macro2-1.0.52/src/fallback.rs", + "vendor/proc-macro2-1.0.52/src/lib.rs", + "vendor/proc-macro2-1.0.52/src/location.rs", + "vendor/proc-macro2-1.0.52/src/marker.rs", + "vendor/proc-macro2-1.0.52/src/parse.rs", + "vendor/proc-macro2-1.0.52/src/rcvec.rs", + "vendor/proc-macro2-1.0.52/src/wrapper.rs", ], crate = "proc_macro2", - crate_root = "vendor/proc-macro2-1.0.47/src/lib.rs", + crate_root = "vendor/proc-macro2-1.0.52/src/lib.rs", edition = "2018", features = [ "default", @@ -262,17 +265,17 @@ rust_library( ], rustc_flags = [ "--cap-lints=allow", - "@$(location :proc-macro2-1.0.47-build-script-build-args)", + "@$(location :proc-macro2-1.0.52-build-script-build-args)", ], visibility = [], - deps = [":unicode-ident-1.0.5"], + deps = [":unicode-ident-1.0.8"], ) rust_binary( - name = "proc-macro2-1.0.47-build-script-build", - srcs = ["vendor/proc-macro2-1.0.47/build.rs"], + name = "proc-macro2-1.0.52-build-script-build", + srcs = ["vendor/proc-macro2-1.0.52/build.rs"], crate = "build_script_build", - crate_root = "vendor/proc-macro2-1.0.47/build.rs", + crate_root = "vendor/proc-macro2-1.0.52/build.rs", edition = "2018", features = [ "default", @@ -284,38 +287,37 @@ rust_binary( ) buildscript_args( - name = "proc-macro2-1.0.47-build-script-build-args", + name = "proc-macro2-1.0.52-build-script-build-args", package_name = "proc-macro2", - buildscript_rule = ":proc-macro2-1.0.47-build-script-build", - cfgs = [], + buildscript_rule = ":proc-macro2-1.0.52-build-script-build", features = [ "default", "proc-macro", "span-locations", ], outfile = "args.txt", - version = "1.0.47", + version = "1.0.52", ) alias( name = "quote", - actual = ":quote-1.0.21", + actual = ":quote-1.0.26", visibility = ["PUBLIC"], ) -rust_library( - name = "quote-1.0.21", +third_party_rust_library( + name = "quote-1.0.26", srcs = [ - "vendor/quote-1.0.21/src/ext.rs", - "vendor/quote-1.0.21/src/format.rs", - "vendor/quote-1.0.21/src/ident_fragment.rs", - "vendor/quote-1.0.21/src/lib.rs", - "vendor/quote-1.0.21/src/runtime.rs", - "vendor/quote-1.0.21/src/spanned.rs", - "vendor/quote-1.0.21/src/to_tokens.rs", + "vendor/quote-1.0.26/src/ext.rs", + "vendor/quote-1.0.26/src/format.rs", + "vendor/quote-1.0.26/src/ident_fragment.rs", + "vendor/quote-1.0.26/src/lib.rs", + "vendor/quote-1.0.26/src/runtime.rs", + "vendor/quote-1.0.26/src/spanned.rs", + "vendor/quote-1.0.26/src/to_tokens.rs", ], crate = "quote", - crate_root = "vendor/quote-1.0.21/src/lib.rs", + crate_root = "vendor/quote-1.0.26/src/lib.rs", edition = "2018", features = [ "default", @@ -323,17 +325,17 @@ rust_library( ], rustc_flags = [ "--cap-lints=allow", - "@$(location :quote-1.0.21-build-script-build-args)", + "@$(location :quote-1.0.26-build-script-build-args)", ], visibility = [], - deps = [":proc-macro2-1.0.47"], + deps = [":proc-macro2-1.0.52"], ) rust_binary( - name = "quote-1.0.21-build-script-build", - srcs = ["vendor/quote-1.0.21/build.rs"], + name = "quote-1.0.26-build-script-build", + srcs = ["vendor/quote-1.0.26/build.rs"], crate = "build_script_build", - crate_root = "vendor/quote-1.0.21/build.rs", + crate_root = "vendor/quote-1.0.26/build.rs", edition = "2018", features = [ "default", @@ -344,29 +346,28 @@ rust_binary( ) buildscript_args( - name = "quote-1.0.21-build-script-build-args", + name = "quote-1.0.26-build-script-build-args", package_name = "quote", - buildscript_rule = ":quote-1.0.21-build-script-build", - cfgs = [], + buildscript_rule = ":quote-1.0.26-build-script-build", features = [ "default", "proc-macro", ], outfile = "args.txt", - version = "1.0.21", + version = "1.0.26", ) alias( name = "scratch", - actual = ":scratch-1.0.2", + actual = ":scratch-1.0.5", visibility = ["PUBLIC"], ) -rust_library( - name = "scratch-1.0.2", - srcs = ["vendor/scratch-1.0.2/src/lib.rs"], +third_party_rust_library( + name = "scratch-1.0.5", + srcs = ["vendor/scratch-1.0.5/src/lib.rs"], crate = "scratch", - crate_root = "vendor/scratch-1.0.2/src/lib.rs", + crate_root = "vendor/scratch-1.0.5/src/lib.rs", edition = "2015", env = { "OUT_DIR": "generated", @@ -377,97 +378,69 @@ rust_library( alias( name = "syn", - actual = ":syn-1.0.105", + actual = ":syn-2.0.1", visibility = ["PUBLIC"], ) -rust_library( - name = "syn-1.0.105", +third_party_rust_library( + name = "syn-2.0.1", srcs = [ - "vendor/syn-1.0.105/src/attr.rs", - "vendor/syn-1.0.105/src/await.rs", - "vendor/syn-1.0.105/src/bigint.rs", - "vendor/syn-1.0.105/src/buffer.rs", - "vendor/syn-1.0.105/src/custom_keyword.rs", - "vendor/syn-1.0.105/src/custom_punctuation.rs", - "vendor/syn-1.0.105/src/data.rs", - "vendor/syn-1.0.105/src/derive.rs", - "vendor/syn-1.0.105/src/discouraged.rs", - "vendor/syn-1.0.105/src/drops.rs", - "vendor/syn-1.0.105/src/error.rs", - "vendor/syn-1.0.105/src/export.rs", - "vendor/syn-1.0.105/src/expr.rs", - "vendor/syn-1.0.105/src/ext.rs", - "vendor/syn-1.0.105/src/file.rs", - "vendor/syn-1.0.105/src/gen/clone.rs", - "vendor/syn-1.0.105/src/gen/debug.rs", - "vendor/syn-1.0.105/src/gen/eq.rs", - "vendor/syn-1.0.105/src/gen/fold.rs", - "vendor/syn-1.0.105/src/gen/hash.rs", - "vendor/syn-1.0.105/src/gen/visit.rs", - "vendor/syn-1.0.105/src/gen/visit_mut.rs", - "vendor/syn-1.0.105/src/gen_helper.rs", - "vendor/syn-1.0.105/src/generics.rs", - "vendor/syn-1.0.105/src/group.rs", - "vendor/syn-1.0.105/src/ident.rs", - "vendor/syn-1.0.105/src/item.rs", - "vendor/syn-1.0.105/src/lib.rs", - "vendor/syn-1.0.105/src/lifetime.rs", - "vendor/syn-1.0.105/src/lit.rs", - "vendor/syn-1.0.105/src/lookahead.rs", - "vendor/syn-1.0.105/src/mac.rs", - "vendor/syn-1.0.105/src/macros.rs", - "vendor/syn-1.0.105/src/op.rs", - "vendor/syn-1.0.105/src/parse.rs", - "vendor/syn-1.0.105/src/parse_macro_input.rs", - "vendor/syn-1.0.105/src/parse_quote.rs", - "vendor/syn-1.0.105/src/pat.rs", - "vendor/syn-1.0.105/src/path.rs", - "vendor/syn-1.0.105/src/print.rs", - "vendor/syn-1.0.105/src/punctuated.rs", - "vendor/syn-1.0.105/src/reserved.rs", - "vendor/syn-1.0.105/src/sealed.rs", - "vendor/syn-1.0.105/src/span.rs", - "vendor/syn-1.0.105/src/spanned.rs", - "vendor/syn-1.0.105/src/stmt.rs", - "vendor/syn-1.0.105/src/thread.rs", - "vendor/syn-1.0.105/src/token.rs", - "vendor/syn-1.0.105/src/tt.rs", - "vendor/syn-1.0.105/src/ty.rs", - "vendor/syn-1.0.105/src/verbatim.rs", - "vendor/syn-1.0.105/src/whitespace.rs", + "vendor/syn-2.0.1/src/attr.rs", + "vendor/syn-2.0.1/src/bigint.rs", + "vendor/syn-2.0.1/src/buffer.rs", + "vendor/syn-2.0.1/src/custom_keyword.rs", + "vendor/syn-2.0.1/src/custom_punctuation.rs", + "vendor/syn-2.0.1/src/data.rs", + "vendor/syn-2.0.1/src/derive.rs", + "vendor/syn-2.0.1/src/discouraged.rs", + "vendor/syn-2.0.1/src/drops.rs", + "vendor/syn-2.0.1/src/error.rs", + "vendor/syn-2.0.1/src/export.rs", + "vendor/syn-2.0.1/src/expr.rs", + "vendor/syn-2.0.1/src/ext.rs", + "vendor/syn-2.0.1/src/file.rs", + "vendor/syn-2.0.1/src/gen/clone.rs", + "vendor/syn-2.0.1/src/gen/debug.rs", + "vendor/syn-2.0.1/src/gen/eq.rs", + "vendor/syn-2.0.1/src/gen/fold.rs", + "vendor/syn-2.0.1/src/gen/hash.rs", + "vendor/syn-2.0.1/src/gen/visit.rs", + "vendor/syn-2.0.1/src/gen/visit_mut.rs", + "vendor/syn-2.0.1/src/gen_helper.rs", + "vendor/syn-2.0.1/src/generics.rs", + "vendor/syn-2.0.1/src/group.rs", + "vendor/syn-2.0.1/src/ident.rs", + "vendor/syn-2.0.1/src/item.rs", + "vendor/syn-2.0.1/src/lib.rs", + "vendor/syn-2.0.1/src/lifetime.rs", + "vendor/syn-2.0.1/src/lit.rs", + "vendor/syn-2.0.1/src/lookahead.rs", + "vendor/syn-2.0.1/src/mac.rs", + "vendor/syn-2.0.1/src/macros.rs", + "vendor/syn-2.0.1/src/meta.rs", + "vendor/syn-2.0.1/src/op.rs", + "vendor/syn-2.0.1/src/parse.rs", + "vendor/syn-2.0.1/src/parse_macro_input.rs", + "vendor/syn-2.0.1/src/parse_quote.rs", + "vendor/syn-2.0.1/src/pat.rs", + "vendor/syn-2.0.1/src/path.rs", + "vendor/syn-2.0.1/src/print.rs", + "vendor/syn-2.0.1/src/punctuated.rs", + "vendor/syn-2.0.1/src/restriction.rs", + "vendor/syn-2.0.1/src/sealed.rs", + "vendor/syn-2.0.1/src/span.rs", + "vendor/syn-2.0.1/src/spanned.rs", + "vendor/syn-2.0.1/src/stmt.rs", + "vendor/syn-2.0.1/src/thread.rs", + "vendor/syn-2.0.1/src/token.rs", + "vendor/syn-2.0.1/src/tt.rs", + "vendor/syn-2.0.1/src/ty.rs", + "vendor/syn-2.0.1/src/verbatim.rs", + "vendor/syn-2.0.1/src/whitespace.rs", ], crate = "syn", - crate_root = "vendor/syn-1.0.105/src/lib.rs", - edition = "2018", - features = [ - "clone-impls", - "default", - "derive", - "full", - "parsing", - "printing", - "proc-macro", - "quote", - ], - rustc_flags = [ - "--cap-lints=allow", - "@$(location :syn-1.0.105-build-script-build-args)", - ], - visibility = [], - deps = [ - ":proc-macro2-1.0.47", - ":quote-1.0.21", - ":unicode-ident-1.0.5", - ], -) - -rust_binary( - name = "syn-1.0.105-build-script-build", - srcs = ["vendor/syn-1.0.105/build.rs"], - crate = "build_script_build", - crate_root = "vendor/syn-1.0.105/build.rs", - edition = "2018", + crate_root = "vendor/syn-2.0.1/src/lib.rs", + edition = "2021", features = [ "clone-impls", "default", @@ -480,51 +453,37 @@ rust_binary( ], rustc_flags = ["--cap-lints=allow"], visibility = [], -) - -buildscript_args( - name = "syn-1.0.105-build-script-build-args", - package_name = "syn", - buildscript_rule = ":syn-1.0.105-build-script-build", - cfgs = [], - features = [ - "clone-impls", - "default", - "derive", - "full", - "parsing", - "printing", - "proc-macro", - "quote", + deps = [ + ":proc-macro2-1.0.52", + ":quote-1.0.26", + ":unicode-ident-1.0.8", ], - outfile = "args.txt", - version = "1.0.105", ) -rust_library( - name = "termcolor-1.1.3", - srcs = ["vendor/termcolor-1.1.3/src/lib.rs"], +third_party_rust_library( + name = "termcolor-1.2.0", + srcs = ["vendor/termcolor-1.2.0/src/lib.rs"], crate = "termcolor", - crate_root = "vendor/termcolor-1.1.3/src/lib.rs", + crate_root = "vendor/termcolor-1.2.0/src/lib.rs", edition = "2018", rustc_flags = ["--cap-lints=allow"], visibility = [], ) -rust_library( - name = "unicode-ident-1.0.5", +third_party_rust_library( + name = "unicode-ident-1.0.8", srcs = [ - "vendor/unicode-ident-1.0.5/src/lib.rs", - "vendor/unicode-ident-1.0.5/src/tables.rs", + "vendor/unicode-ident-1.0.8/src/lib.rs", + "vendor/unicode-ident-1.0.8/src/tables.rs", ], crate = "unicode_ident", - crate_root = "vendor/unicode-ident-1.0.5/src/lib.rs", + crate_root = "vendor/unicode-ident-1.0.8/src/lib.rs", edition = "2018", rustc_flags = ["--cap-lints=allow"], visibility = [], ) -rust_library( +third_party_rust_library( name = "unicode-width-0.1.10", srcs = [ "vendor/unicode-width-0.1.10/src/lib.rs", diff --git a/third-party/BUILD b/third-party/BUILD index 1b599321..7fc2b0f2 100644 --- a/third-party/BUILD +++ b/third-party/BUILD @@ -1,202 +1,29 @@ -load( - "//tools/bazel:third_party.bzl", - cargo_build_script = "third_party_cargo_build_script", - glob = "third_party_glob", - rust_library = "third_party_rust_library", -) - -rust_library( - name = "bitflags", - srcs = glob(["vendor/bitflags-1.3.2/src/**/*.rs"]), - edition = "2018", -) - -rust_library( - name = "cc", - srcs = glob(["vendor/cc-1.0.77/src/**/*.rs"]), - edition = "2018", - visibility = ["//visibility:public"], -) - -rust_library( - name = "clap", - srcs = glob(["vendor/clap-4.0.29/src/**/*.rs"]) + ["vendor/clap-4.0.29/examples/demo.rs"], - crate_features = [ - "error-context", - "help", - "std", - "usage", - ], - data = ["vendor/clap-4.0.29/examples/demo.md"], - edition = "2021", - visibility = ["//visibility:public"], - deps = [ - ":bitflags", - ":clap_lex", - ], -) - -rust_library( - name = "clap_lex", - srcs = glob(["vendor/clap_lex-0.3.0/src/**/*.rs"]), - edition = "2021", - deps = [ - ":os_str_bytes", - ], -) - -rust_library( - name = "codespan-reporting", - srcs = glob(["vendor/codespan-reporting-0.11.1/src/**/*.rs"]), - edition = "2018", - visibility = ["//visibility:public"], - deps = [ - ":termcolor", - ":unicode-width", - ], -) - -rust_library( - name = "once_cell", - srcs = glob(["vendor/once_cell-1.16.0/src/**/*.rs"]), - crate_features = [ - "alloc", - "default", - "race", - "std", - ], - edition = "2021", - visibility = ["//visibility:public"], -) - -rust_library( - name = "os_str_bytes", - srcs = glob(["vendor/os_str_bytes-6.4.1/src/**/*.rs"]), - crate_features = [ - "raw_os_str", - ], - edition = "2021", -) - -rust_library( - name = "proc-macro2", - srcs = glob(["vendor/proc-macro2-1.0.47/src/**/*.rs"]), - crate_features = [ - "default", - "proc-macro", - "span-locations", - ], - edition = "2018", - visibility = ["//visibility:public"], - deps = [ - ":proc-macro2@build", - ":unicode-ident", - ], -) - -cargo_build_script( - name = "proc-macro2@build", - srcs = ["vendor/proc-macro2-1.0.47/build.rs"], - crate_features = [ - "default", - "proc-macro", - "span-locations", - ], - crate_name = "build", - edition = "2018", -) - -rust_library( - name = "quote", - srcs = glob(["vendor/quote-1.0.21/src/**/*.rs"]), - crate_features = [ - "default", - "proc-macro", - ], - edition = "2018", - visibility = ["//visibility:public"], - deps = [ - ":proc-macro2", - ":quote@build", - ], -) - -cargo_build_script( - name = "quote@build", - srcs = ["vendor/quote-1.0.21/build.rs"], - crate_features = [ - "default", - "proc-macro", - ], - crate_name = "build", - edition = "2018", -) - -rust_library( - name = "scratch", - srcs = glob(["vendor/scratch-1.0.2/src/**/*.rs"]), - edition = "2015", - rustc_env = {"OUT_DIR": ""}, - visibility = ["//visibility:public"], -) - -rust_library( - name = "syn", - srcs = glob(["vendor/syn-1.0.105/src/**/*.rs"]), - crate_features = [ - "clone-impls", - "default", - "derive", - "full", - "parsing", - "printing", - "proc-macro", - "quote", - ], - edition = "2018", - visibility = ["//visibility:public"], - deps = [ - ":proc-macro2", - ":quote", - ":syn@build", - ":unicode-ident", - ], -) - -cargo_build_script( - name = "syn@build", - srcs = ["vendor/syn-1.0.105/build.rs"], - crate_features = [ - "clone-impls", - "default", - "derive", - "full", - "parsing", - "printing", - "proc-macro", +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"], + mode = "remote", + tags = ["manual"], + vendor_path = "bazel", +) + +[ + alias( + name = name, + actual = "//third-party/bazel:{}".format(name), + visibility = ["//visibility:public"], + ) + for name in [ + "cc", + "clap", + "codespan-reporting", + "once_cell", + "proc-macro2", "quote", - ], - crate_name = "build", - edition = "2018", -) - -rust_library( - name = "termcolor", - srcs = glob(["vendor/termcolor-1.1.3/src/**/*.rs"]), - edition = "2018", -) - -rust_library( - name = "unicode-ident", - srcs = glob(["vendor/unicode-ident-1.0.5/src/**/*.rs"]), - edition = "2018", -) - -rust_library( - name = "unicode-width", - srcs = glob(["vendor/unicode-width-0.1.10/src/**/*.rs"]), - crate_features = [ - "default", - ], - edition = "2015", -) + "scratch", + "syn", + ] +] diff --git a/third-party/Cargo.lock b/third-party/Cargo.lock index 1c054218..fd14b818 100644 --- a/third-party/Cargo.lock +++ b/third-party/Cargo.lock @@ -10,15 +10,15 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "cc" -version = "1.0.77" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" [[package]] name = "clap" -version = "4.0.29" +version = "4.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d63b9e9c07271b9957ad22c173bae2a4d9a81127680962039296abcd2f8251d" +checksum = "ce38afc168d8665cfc75c7b1dd9672e50716a137f433f070991619744a67342a" dependencies = [ "bitflags", "clap_lex", @@ -26,9 +26,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.3.0" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" dependencies = [ "os_str_bytes", ] @@ -45,9 +45,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.16.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "os_str_bytes" @@ -57,33 +57,33 @@ checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" [[package]] name = "proc-macro2" -version = "1.0.47" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.21" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] [[package]] name = "scratch" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" +checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" [[package]] name = "syn" -version = "1.0.105" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908" +checksum = "55ee2415bee46ba26eac9cd8e52966995c46bf0e842b6304eb8fcf99826548ed" dependencies = [ "proc-macro2", "quote", @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.3" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] @@ -115,9 +115,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.5" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-width" diff --git a/third-party/Cargo.toml b/third-party/Cargo.toml index 84657de5..5a069811 100644 --- a/third-party/Cargo.toml +++ b/third-party/Cargo.toml @@ -15,4 +15,4 @@ once_cell = "1.9" proc-macro2 = { version = "1.0.39", features = ["span-locations"] } quote = "1.0.4" scratch = "1" -syn = { version = "1.0.95", features = ["full"] } +syn = { version = "2.0.1", features = ["full"] } diff --git a/third-party/bazel/BUILD.bazel b/third-party/bazel/BUILD.bazel new file mode 100644 index 00000000..d35ae840 --- /dev/null +++ b/third-party/bazel/BUILD.bazel @@ -0,0 +1,74 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +package(default_visibility = ["//visibility:public"]) + +exports_files( + [ + "cargo-bazel.json", + "crates.bzl", + "defs.bzl", + ] + glob(["*.bazel"]), +) + +filegroup( + name = "srcs", + srcs = glob([ + "*.bazel", + "*.bzl", + ]), +) + +# Workspace Member Dependencies +alias( + name = "cc", + actual = "@vendor__cc-1.0.79//:cc", + tags = ["manual"], +) + +alias( + name = "clap", + actual = "@vendor__clap-4.1.10//:clap", + tags = ["manual"], +) + +alias( + name = "codespan-reporting", + actual = "@vendor__codespan-reporting-0.11.1//:codespan_reporting", + tags = ["manual"], +) + +alias( + name = "once_cell", + actual = "@vendor__once_cell-1.17.1//:once_cell", + tags = ["manual"], +) + +alias( + name = "proc-macro2", + actual = "@vendor__proc-macro2-1.0.52//:proc_macro2", + tags = ["manual"], +) + +alias( + name = "quote", + actual = "@vendor__quote-1.0.26//:quote", + tags = ["manual"], +) + +alias( + name = "scratch", + actual = "@vendor__scratch-1.0.5//:scratch", + tags = ["manual"], +) + +alias( + name = "syn", + actual = "@vendor__syn-2.0.1//:syn", + tags = ["manual"], +) diff --git a/third-party/bazel/BUILD.bitflags-1.3.2.bazel b/third-party/bazel/BUILD.bitflags-1.3.2.bazel new file mode 100644 index 00000000..39360f23 --- /dev/null +++ b/third-party/bazel/BUILD.bitflags-1.3.2.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # MIT/Apache-2.0 +# ]) + +rust_library( + name = "bitflags", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=bitflags", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.3.2", +) diff --git a/third-party/bazel/BUILD.cc-1.0.79.bazel b/third-party/bazel/BUILD.cc-1.0.79.bazel new file mode 100644 index 00000000..102bc5d1 --- /dev/null +++ b/third-party/bazel/BUILD.cc-1.0.79.bazel @@ -0,0 +1,41 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # MIT OR Apache-2.0 +# ]) + +rust_library( + name = "cc", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=cc", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.79", +) diff --git a/third-party/bazel/BUILD.clap-4.1.10.bazel b/third-party/bazel/BUILD.clap-4.1.10.bazel new file mode 100644 index 00000000..7070273f --- /dev/null +++ b/third-party/bazel/BUILD.clap-4.1.10.bazel @@ -0,0 +1,51 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # MIT OR Apache-2.0 +# ]) + +rust_library( + name = "clap", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "error-context", + "help", + "std", + "usage", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=clap", + "manual", + "noclippy", + "norustfmt", + ], + version = "4.1.10", + deps = [ + "@vendor__bitflags-1.3.2//:bitflags", + "@vendor__clap_lex-0.3.3//:clap_lex", + ], +) diff --git a/third-party/bazel/BUILD.clap_lex-0.3.3.bazel b/third-party/bazel/BUILD.clap_lex-0.3.3.bazel new file mode 100644 index 00000000..60fe11b4 --- /dev/null +++ b/third-party/bazel/BUILD.clap_lex-0.3.3.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # MIT OR Apache-2.0 +# ]) + +rust_library( + name = "clap_lex", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=clap_lex", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.3.3", + deps = [ + "@vendor__os_str_bytes-6.4.1//:os_str_bytes", + ], +) diff --git a/third-party/bazel/BUILD.codespan-reporting-0.11.1.bazel b/third-party/bazel/BUILD.codespan-reporting-0.11.1.bazel new file mode 100644 index 00000000..a75a1369 --- /dev/null +++ b/third-party/bazel/BUILD.codespan-reporting-0.11.1.bazel @@ -0,0 +1,45 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # Apache-2.0 +# ]) + +rust_library( + name = "codespan_reporting", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=codespan-reporting", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.11.1", + deps = [ + "@vendor__termcolor-1.2.0//:termcolor", + "@vendor__unicode-width-0.1.10//:unicode_width", + ], +) diff --git a/third-party/bazel/BUILD.once_cell-1.17.1.bazel b/third-party/bazel/BUILD.once_cell-1.17.1.bazel new file mode 100644 index 00000000..7132498a --- /dev/null +++ b/third-party/bazel/BUILD.once_cell-1.17.1.bazel @@ -0,0 +1,47 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # MIT OR Apache-2.0 +# ]) + +rust_library( + name = "once_cell", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "alloc", + "default", + "race", + "std", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=once_cell", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.17.1", +) diff --git a/third-party/bazel/BUILD.os_str_bytes-6.4.1.bazel b/third-party/bazel/BUILD.os_str_bytes-6.4.1.bazel new file mode 100644 index 00000000..2510ac16 --- /dev/null +++ b/third-party/bazel/BUILD.os_str_bytes-6.4.1.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # MIT OR Apache-2.0 +# ]) + +rust_library( + name = "os_str_bytes", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "raw_os_str", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=os_str_bytes", + "manual", + "noclippy", + "norustfmt", + ], + version = "6.4.1", +) diff --git a/third-party/bazel/BUILD.proc-macro2-1.0.52.bazel b/third-party/bazel/BUILD.proc-macro2-1.0.52.bazel new file mode 100644 index 00000000..d93678a9 --- /dev/null +++ b/third-party/bazel/BUILD.proc-macro2-1.0.52.bazel @@ -0,0 +1,92 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # MIT OR Apache-2.0 +# ]) + +rust_library( + name = "proc_macro2", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "proc-macro", + "span-locations", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=proc-macro2", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.52", + deps = [ + "@vendor__proc-macro2-1.0.52//:build_script_build", + "@vendor__unicode-ident-1.0.8//:unicode_ident", + ], +) + +cargo_build_script( + name = "proc-macro2_build_script", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + "proc-macro", + "span-locations", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=proc-macro2", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.52", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = "proc-macro2_build_script", + tags = ["manual"], +) diff --git a/third-party/bazel/BUILD.quote-1.0.26.bazel b/third-party/bazel/BUILD.quote-1.0.26.bazel new file mode 100644 index 00000000..9cb74311 --- /dev/null +++ b/third-party/bazel/BUILD.quote-1.0.26.bazel @@ -0,0 +1,90 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # MIT OR Apache-2.0 +# ]) + +rust_library( + name = "quote", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + "proc-macro", + ], + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=quote", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.26", + deps = [ + "@vendor__proc-macro2-1.0.52//:proc_macro2", + "@vendor__quote-1.0.26//:build_script_build", + ], +) + +cargo_build_script( + name = "quote_build_script", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + "proc-macro", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=quote", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.26", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = "quote_build_script", + tags = ["manual"], +) diff --git a/third-party/bazel/BUILD.scratch-1.0.5.bazel b/third-party/bazel/BUILD.scratch-1.0.5.bazel new file mode 100644 index 00000000..ae28c649 --- /dev/null +++ b/third-party/bazel/BUILD.scratch-1.0.5.bazel @@ -0,0 +1,81 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # MIT OR Apache-2.0 +# ]) + +rust_library( + name = "scratch", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=scratch", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.5", + deps = [ + "@vendor__scratch-1.0.5//:build_script_build", + ], +) + +cargo_build_script( + name = "scratch_build_script", + srcs = glob(["**/*.rs"]), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=scratch", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.5", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = "scratch_build_script", + tags = ["manual"], +) diff --git a/third-party/bazel/BUILD.syn-2.0.1.bazel b/third-party/bazel/BUILD.syn-2.0.1.bazel new file mode 100644 index 00000000..42cdf318 --- /dev/null +++ b/third-party/bazel/BUILD.syn-2.0.1.bazel @@ -0,0 +1,56 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # MIT OR Apache-2.0 +# ]) + +rust_library( + name = "syn", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "clone-impls", + "default", + "derive", + "full", + "parsing", + "printing", + "proc-macro", + "quote", + ], + crate_root = "src/lib.rs", + edition = "2021", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=syn", + "manual", + "noclippy", + "norustfmt", + ], + version = "2.0.1", + deps = [ + "@vendor__proc-macro2-1.0.52//:proc_macro2", + "@vendor__quote-1.0.26//:quote", + "@vendor__unicode-ident-1.0.8//:unicode_ident", + ], +) diff --git a/third-party/bazel/BUILD.termcolor-1.2.0.bazel b/third-party/bazel/BUILD.termcolor-1.2.0.bazel new file mode 100644 index 00000000..fa7481ea --- /dev/null +++ b/third-party/bazel/BUILD.termcolor-1.2.0.bazel @@ -0,0 +1,53 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # Unlicense OR MIT +# ]) + +rust_library( + name = "termcolor", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=termcolor", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.2.0", + deps = select({ + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@vendor__winapi-util-0.1.5//:winapi_util", # cfg(windows) + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@vendor__winapi-util-0.1.5//:winapi_util", # cfg(windows) + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@vendor__winapi-util-0.1.5//:winapi_util", # cfg(windows) + ], + "//conditions:default": [], + }), +) diff --git a/third-party/bazel/BUILD.unicode-ident-1.0.8.bazel b/third-party/bazel/BUILD.unicode-ident-1.0.8.bazel new file mode 100644 index 00000000..c831cece --- /dev/null +++ b/third-party/bazel/BUILD.unicode-ident-1.0.8.bazel @@ -0,0 +1,41 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # (MIT OR Apache-2.0) AND Unicode-DFS-2016 +# ]) + +rust_library( + name = "unicode_ident", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=unicode-ident", + "manual", + "noclippy", + "norustfmt", + ], + version = "1.0.8", +) diff --git a/third-party/bazel/BUILD.unicode-width-0.1.10.bazel b/third-party/bazel/BUILD.unicode-width-0.1.10.bazel new file mode 100644 index 00000000..103a2036 --- /dev/null +++ b/third-party/bazel/BUILD.unicode-width-0.1.10.bazel @@ -0,0 +1,44 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # MIT/Apache-2.0 +# ]) + +rust_library( + name = "unicode_width", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=unicode-width", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.1.10", +) diff --git a/third-party/bazel/BUILD.winapi-0.3.9.bazel b/third-party/bazel/BUILD.winapi-0.3.9.bazel new file mode 100644 index 00000000..7af60b17 --- /dev/null +++ b/third-party/bazel/BUILD.winapi-0.3.9.bazel @@ -0,0 +1,105 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # MIT/Apache-2.0 +# ]) + +rust_library( + name = "winapi", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_features = [ + "consoleapi", + "errhandlingapi", + "fileapi", + "minwindef", + "processenv", + "std", + "winbase", + "wincon", + "winerror", + "winnt", + ], + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=winapi", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.3.9", + deps = [ + "@vendor__winapi-0.3.9//:build_script_build", + ], +) + +cargo_build_script( + name = "winapi_build_script", + srcs = glob(["**/*.rs"]), + crate_features = [ + "consoleapi", + "errhandlingapi", + "fileapi", + "minwindef", + "processenv", + "std", + "winbase", + "wincon", + "winerror", + "winnt", + ], + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=winapi", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.3.9", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = "winapi_build_script", + tags = ["manual"], +) diff --git a/third-party/bazel/BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel b/third-party/bazel/BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel new file mode 100644 index 00000000..ae3de314 --- /dev/null +++ b/third-party/bazel/BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel @@ -0,0 +1,81 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # MIT/Apache-2.0 +# ]) + +rust_library( + name = "winapi_i686_pc_windows_gnu", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=winapi-i686-pc-windows-gnu", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.0", + deps = [ + "@vendor__winapi-i686-pc-windows-gnu-0.4.0//:build_script_build", + ], +) + +cargo_build_script( + name = "winapi-i686-pc-windows-gnu_build_script", + srcs = glob(["**/*.rs"]), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=winapi-i686-pc-windows-gnu", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.0", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = "winapi-i686-pc-windows-gnu_build_script", + tags = ["manual"], +) diff --git a/third-party/bazel/BUILD.winapi-util-0.1.5.bazel b/third-party/bazel/BUILD.winapi-util-0.1.5.bazel new file mode 100644 index 00000000..6ca7e9a7 --- /dev/null +++ b/third-party/bazel/BUILD.winapi-util-0.1.5.bazel @@ -0,0 +1,53 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # Unlicense/MIT +# ]) + +rust_library( + name = "winapi_util", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2018", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=winapi-util", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.1.5", + deps = select({ + "@rules_rust//rust/platform:aarch64-pc-windows-msvc": [ + "@vendor__winapi-0.3.9//:winapi", # cfg(windows) + ], + "@rules_rust//rust/platform:i686-pc-windows-msvc": [ + "@vendor__winapi-0.3.9//:winapi", # cfg(windows) + ], + "@rules_rust//rust/platform:x86_64-pc-windows-msvc": [ + "@vendor__winapi-0.3.9//:winapi", # cfg(windows) + ], + "//conditions:default": [], + }), +) diff --git a/third-party/bazel/BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel b/third-party/bazel/BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel new file mode 100644 index 00000000..c145846b --- /dev/null +++ b/third-party/bazel/BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel @@ -0,0 +1,81 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### + +load("@rules_rust//cargo:defs.bzl", "cargo_build_script") +load("@rules_rust//rust:defs.bzl", "rust_library") + +package(default_visibility = ["//visibility:public"]) + +# licenses([ +# "TODO", # MIT/Apache-2.0 +# ]) + +rust_library( + name = "winapi_x86_64_pc_windows_gnu", + srcs = glob(["**/*.rs"]), + compile_data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + crate_root = "src/lib.rs", + edition = "2015", + rustc_flags = ["--cap-lints=allow"], + tags = [ + "cargo-bazel", + "crate-name=winapi-x86_64-pc-windows-gnu", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.0", + deps = [ + "@vendor__winapi-x86_64-pc-windows-gnu-0.4.0//:build_script_build", + ], +) + +cargo_build_script( + name = "winapi-x86_64-pc-windows-gnu_build_script", + srcs = glob(["**/*.rs"]), + crate_name = "build_script_build", + crate_root = "build.rs", + data = glob( + include = ["**"], + exclude = [ + "**/* *", + "BUILD", + "BUILD.bazel", + "WORKSPACE", + "WORKSPACE.bazel", + ], + ), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-bazel", + "crate-name=winapi-x86_64-pc-windows-gnu", + "manual", + "noclippy", + "norustfmt", + ], + version = "0.4.0", + visibility = ["//visibility:private"], +) + +alias( + name = "build_script_build", + actual = "winapi-x86_64-pc-windows-gnu_build_script", + tags = ["manual"], +) diff --git a/third-party/bazel/crates.bzl b/third-party/bazel/crates.bzl new file mode 100644 index 00000000..6d61f64a --- /dev/null +++ b/third-party/bazel/crates.bzl @@ -0,0 +1,25 @@ +############################################################################### +# @generated +# This file is auto-generated by the cargo-bazel tool. +# +# DO NOT MODIFY: Local changes may be replaced in future executions. +############################################################################### +"""Rules for defining repositories for remote `crates_vendor` repositories""" + +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +# buildifier: disable=bzl-visibility +load("@cxx.rs//third-party/bazel:defs.bzl", _crate_repositories = "crate_repositories") + +# buildifier: disable=bzl-visibility +load("@rules_rust//crate_universe/private:crates_vendor.bzl", "crates_vendor_remote_repository") + +def crate_repositories(): + maybe( + crates_vendor_remote_repository, + name = "vendor", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.bazel"), + defs_module = Label("@cxx.rs//third-party/bazel:defs.bzl"), + ) + + _crate_repositories() diff --git a/third-party/bazel/defs.bzl b/third-party/bazel/defs.bzl new file mode 100644 index 00000000..e799b0e9 --- /dev/null +++ b/third-party/bazel/defs.bzl @@ -0,0 +1,551 @@ +############################################################################### +# @generated +# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To +# regenerate this file, run the following: +# +# bazel run @//third-party:vendor +############################################################################### +""" +# `crates_repository` API + +- [aliases](#aliases) +- [crate_deps](#crate_deps) +- [all_crate_deps](#all_crate_deps) +- [crate_repositories](#crate_repositories) + +""" + +load("@bazel_skylib//lib:selects.bzl", "selects") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +############################################################################### +# MACROS API +############################################################################### + +# An identifier that represent common dependencies (unconditional). +_COMMON_CONDITION = "" + +def _flatten_dependency_maps(all_dependency_maps): + """Flatten a list of dependency maps into one dictionary. + + Dependency maps have the following structure: + + ```python + DEPENDENCIES_MAP = { + # The first key in the map is a Bazel package + # name of the workspace this file is defined in. + "workspace_member_package": { + + # Not all dependnecies are supported for all platforms. + # the condition key is the condition required to be true + # on the host platform. + "condition": { + + # An alias to a crate target. # The label of the crate target the + # Aliases are only crate names. # package name refers to. + "package_name": "@full//:label", + } + } + } + ``` + + Args: + all_dependency_maps (list): A list of dicts as described above + + Returns: + dict: A dictionary as described above + """ + dependencies = {} + + for workspace_deps_map in all_dependency_maps: + for pkg_name, conditional_deps_map in workspace_deps_map.items(): + if pkg_name not in dependencies: + non_frozen_map = dict() + for key, values in conditional_deps_map.items(): + non_frozen_map.update({key: dict(values.items())}) + dependencies.setdefault(pkg_name, non_frozen_map) + continue + + for condition, deps_map in conditional_deps_map.items(): + # If the condition has not been recorded, do so and continue + if condition not in dependencies[pkg_name]: + dependencies[pkg_name].setdefault(condition, dict(deps_map.items())) + continue + + # Alert on any miss-matched dependencies + inconsistent_entries = [] + for crate_name, crate_label in deps_map.items(): + existing = dependencies[pkg_name][condition].get(crate_name) + if existing and existing != crate_label: + inconsistent_entries.append((crate_name, existing, crate_label)) + dependencies[pkg_name][condition].update({crate_name: crate_label}) + + return dependencies + +def crate_deps(deps, package_name = None): + """Finds the fully qualified label of the requested crates for the package where this macro is called. + + Args: + deps (list): The desired list of crate targets. + package_name (str, optional): The package name of the set of dependencies to look up. + Defaults to `native.package_name()`. + + Returns: + list: A list of labels to generated rust targets (str) + """ + + if not deps: + return [] + + if package_name == None: + package_name = native.package_name() + + # Join both sets of dependencies + dependencies = _flatten_dependency_maps([ + _NORMAL_DEPENDENCIES, + _NORMAL_DEV_DEPENDENCIES, + _PROC_MACRO_DEPENDENCIES, + _PROC_MACRO_DEV_DEPENDENCIES, + _BUILD_DEPENDENCIES, + _BUILD_PROC_MACRO_DEPENDENCIES, + ]).pop(package_name, {}) + + # Combine all conditional packages so we can easily index over a flat list + # TODO: Perhaps this should actually return select statements and maintain + # the conditionals of the dependencies + flat_deps = {} + for deps_set in dependencies.values(): + for crate_name, crate_label in deps_set.items(): + flat_deps.update({crate_name: crate_label}) + + missing_crates = [] + crate_targets = [] + for crate_target in deps: + if crate_target not in flat_deps: + missing_crates.append(crate_target) + else: + crate_targets.append(flat_deps[crate_target]) + + if missing_crates: + fail("Could not find crates `{}` among dependencies of `{}`. Available dependencies were `{}`".format( + missing_crates, + package_name, + dependencies, + )) + + return crate_targets + +def all_crate_deps( + normal = False, + normal_dev = False, + proc_macro = False, + proc_macro_dev = False, + build = False, + build_proc_macro = False, + package_name = None): + """Finds the fully qualified label of all requested direct crate dependencies \ + for the package where this macro is called. + + If no parameters are set, all normal dependencies are returned. Setting any one flag will + otherwise impact the contents of the returned list. + + Args: + normal (bool, optional): If True, normal dependencies are included in the + output list. + normal_dev (bool, optional): If True, normal dev dependencies will be + included in the output list.. + proc_macro (bool, optional): If True, proc_macro dependencies are included + in the output list. + proc_macro_dev (bool, optional): If True, dev proc_macro dependencies are + included in the output list. + build (bool, optional): If True, build dependencies are included + in the output list. + build_proc_macro (bool, optional): If True, build proc_macro dependencies are + included in the output list. + package_name (str, optional): The package name of the set of dependencies to look up. + Defaults to `native.package_name()` when unset. + + Returns: + list: A list of labels to generated rust targets (str) + """ + + if package_name == None: + package_name = native.package_name() + + # Determine the relevant maps to use + all_dependency_maps = [] + if normal: + all_dependency_maps.append(_NORMAL_DEPENDENCIES) + if normal_dev: + all_dependency_maps.append(_NORMAL_DEV_DEPENDENCIES) + if proc_macro: + all_dependency_maps.append(_PROC_MACRO_DEPENDENCIES) + if proc_macro_dev: + all_dependency_maps.append(_PROC_MACRO_DEV_DEPENDENCIES) + if build: + all_dependency_maps.append(_BUILD_DEPENDENCIES) + if build_proc_macro: + all_dependency_maps.append(_BUILD_PROC_MACRO_DEPENDENCIES) + + # Default to always using normal dependencies + if not all_dependency_maps: + all_dependency_maps.append(_NORMAL_DEPENDENCIES) + + dependencies = _flatten_dependency_maps(all_dependency_maps).pop(package_name, None) + + if not dependencies: + if dependencies == None: + fail("Tried to get all_crate_deps for package " + package_name + " but that package had no Cargo.toml file") + else: + return [] + + crate_deps = list(dependencies.pop(_COMMON_CONDITION, {}).values()) + for condition, deps in dependencies.items(): + crate_deps += selects.with_or({_CONDITIONS[condition]: deps.values()}) + + return crate_deps + +def aliases( + normal = False, + normal_dev = False, + proc_macro = False, + proc_macro_dev = False, + build = False, + build_proc_macro = False, + package_name = None): + """Produces a map of Crate alias names to their original label + + If no dependency kinds are specified, `normal` and `proc_macro` are used by default. + Setting any one flag will otherwise determine the contents of the returned dict. + + Args: + normal (bool, optional): If True, normal dependencies are included in the + output list. + normal_dev (bool, optional): If True, normal dev dependencies will be + included in the output list.. + proc_macro (bool, optional): If True, proc_macro dependencies are included + in the output list. + proc_macro_dev (bool, optional): If True, dev proc_macro dependencies are + included in the output list. + build (bool, optional): If True, build dependencies are included + in the output list. + build_proc_macro (bool, optional): If True, build proc_macro dependencies are + included in the output list. + package_name (str, optional): The package name of the set of dependencies to look up. + Defaults to `native.package_name()` when unset. + + Returns: + dict: The aliases of all associated packages + """ + if package_name == None: + package_name = native.package_name() + + # Determine the relevant maps to use + all_aliases_maps = [] + if normal: + all_aliases_maps.append(_NORMAL_ALIASES) + if normal_dev: + all_aliases_maps.append(_NORMAL_DEV_ALIASES) + if proc_macro: + all_aliases_maps.append(_PROC_MACRO_ALIASES) + if proc_macro_dev: + all_aliases_maps.append(_PROC_MACRO_DEV_ALIASES) + if build: + all_aliases_maps.append(_BUILD_ALIASES) + if build_proc_macro: + all_aliases_maps.append(_BUILD_PROC_MACRO_ALIASES) + + # Default to always using normal aliases + if not all_aliases_maps: + all_aliases_maps.append(_NORMAL_ALIASES) + all_aliases_maps.append(_PROC_MACRO_ALIASES) + + aliases = _flatten_dependency_maps(all_aliases_maps).pop(package_name, None) + + if not aliases: + return dict() + + common_items = aliases.pop(_COMMON_CONDITION, {}).items() + + # If there are only common items in the dictionary, immediately return them + if not len(aliases.keys()) == 1: + return dict(common_items) + + # Build a single select statement where each conditional has accounted for the + # common set of aliases. + crate_aliases = {"//conditions:default": common_items} + for condition, deps in aliases.items(): + condition_triples = _CONDITIONS[condition] + if condition_triples in crate_aliases: + crate_aliases[condition_triples].update(deps) + else: + crate_aliases.update({_CONDITIONS[condition]: dict(deps.items() + common_items)}) + + return selects.with_or(crate_aliases) + +############################################################################### +# WORKSPACE MEMBER DEPS AND ALIASES +############################################################################### + +_NORMAL_DEPENDENCIES = { + "third-party": { + _COMMON_CONDITION: { + "cc": "@vendor__cc-1.0.79//:cc", + "clap": "@vendor__clap-4.1.10//:clap", + "codespan-reporting": "@vendor__codespan-reporting-0.11.1//:codespan_reporting", + "once_cell": "@vendor__once_cell-1.17.1//:once_cell", + "proc-macro2": "@vendor__proc-macro2-1.0.52//:proc_macro2", + "quote": "@vendor__quote-1.0.26//:quote", + "scratch": "@vendor__scratch-1.0.5//:scratch", + "syn": "@vendor__syn-2.0.1//:syn", + }, + }, +} + +_NORMAL_ALIASES = { + "third-party": { + _COMMON_CONDITION: { + }, + }, +} + +_NORMAL_DEV_DEPENDENCIES = { + "third-party": { + }, +} + +_NORMAL_DEV_ALIASES = { + "third-party": { + }, +} + +_PROC_MACRO_DEPENDENCIES = { + "third-party": { + }, +} + +_PROC_MACRO_ALIASES = { + "third-party": { + }, +} + +_PROC_MACRO_DEV_DEPENDENCIES = { + "third-party": { + }, +} + +_PROC_MACRO_DEV_ALIASES = { + "third-party": { + }, +} + +_BUILD_DEPENDENCIES = { + "third-party": { + }, +} + +_BUILD_ALIASES = { + "third-party": { + }, +} + +_BUILD_PROC_MACRO_DEPENDENCIES = { + "third-party": { + }, +} + +_BUILD_PROC_MACRO_ALIASES = { + "third-party": { + }, +} + +_CONDITIONS = { + "cfg(windows)": ["aarch64-pc-windows-msvc", "i686-pc-windows-msvc", "x86_64-pc-windows-msvc"], + "i686-pc-windows-gnu": [], + "x86_64-pc-windows-gnu": [], +} + +############################################################################### + +def crate_repositories(): + """A macro for defining repositories for all generated crates""" + maybe( + http_archive, + name = "vendor__bitflags-1.3.2", + sha256 = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/bitflags/1.3.2/download"], + strip_prefix = "bitflags-1.3.2", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.bitflags-1.3.2.bazel"), + ) + + maybe( + http_archive, + name = "vendor__cc-1.0.79", + sha256 = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/cc/1.0.79/download"], + strip_prefix = "cc-1.0.79", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.cc-1.0.79.bazel"), + ) + + maybe( + http_archive, + name = "vendor__clap-4.1.10", + sha256 = "ce38afc168d8665cfc75c7b1dd9672e50716a137f433f070991619744a67342a", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/clap/4.1.10/download"], + strip_prefix = "clap-4.1.10", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.clap-4.1.10.bazel"), + ) + + maybe( + http_archive, + name = "vendor__clap_lex-0.3.3", + sha256 = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/clap_lex/0.3.3/download"], + strip_prefix = "clap_lex-0.3.3", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.clap_lex-0.3.3.bazel"), + ) + + maybe( + http_archive, + name = "vendor__codespan-reporting-0.11.1", + sha256 = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/codespan-reporting/0.11.1/download"], + strip_prefix = "codespan-reporting-0.11.1", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.codespan-reporting-0.11.1.bazel"), + ) + + maybe( + http_archive, + name = "vendor__once_cell-1.17.1", + sha256 = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/once_cell/1.17.1/download"], + strip_prefix = "once_cell-1.17.1", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.once_cell-1.17.1.bazel"), + ) + + maybe( + http_archive, + name = "vendor__os_str_bytes-6.4.1", + sha256 = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/os_str_bytes/6.4.1/download"], + strip_prefix = "os_str_bytes-6.4.1", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.os_str_bytes-6.4.1.bazel"), + ) + + maybe( + http_archive, + name = "vendor__proc-macro2-1.0.52", + sha256 = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/proc-macro2/1.0.52/download"], + strip_prefix = "proc-macro2-1.0.52", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.proc-macro2-1.0.52.bazel"), + ) + + maybe( + http_archive, + name = "vendor__quote-1.0.26", + sha256 = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/quote/1.0.26/download"], + strip_prefix = "quote-1.0.26", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.quote-1.0.26.bazel"), + ) + + maybe( + http_archive, + name = "vendor__scratch-1.0.5", + sha256 = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/scratch/1.0.5/download"], + strip_prefix = "scratch-1.0.5", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.scratch-1.0.5.bazel"), + ) + + maybe( + http_archive, + name = "vendor__syn-2.0.1", + sha256 = "55ee2415bee46ba26eac9cd8e52966995c46bf0e842b6304eb8fcf99826548ed", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/syn/2.0.1/download"], + strip_prefix = "syn-2.0.1", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.syn-2.0.1.bazel"), + ) + + maybe( + http_archive, + name = "vendor__termcolor-1.2.0", + sha256 = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/termcolor/1.2.0/download"], + strip_prefix = "termcolor-1.2.0", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.termcolor-1.2.0.bazel"), + ) + + maybe( + http_archive, + name = "vendor__unicode-ident-1.0.8", + sha256 = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/unicode-ident/1.0.8/download"], + strip_prefix = "unicode-ident-1.0.8", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.unicode-ident-1.0.8.bazel"), + ) + + maybe( + http_archive, + name = "vendor__unicode-width-0.1.10", + sha256 = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/unicode-width/0.1.10/download"], + strip_prefix = "unicode-width-0.1.10", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.unicode-width-0.1.10.bazel"), + ) + + maybe( + http_archive, + name = "vendor__winapi-0.3.9", + sha256 = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/winapi/0.3.9/download"], + strip_prefix = "winapi-0.3.9", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.winapi-0.3.9.bazel"), + ) + + maybe( + http_archive, + name = "vendor__winapi-i686-pc-windows-gnu-0.4.0", + sha256 = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/winapi-i686-pc-windows-gnu/0.4.0/download"], + strip_prefix = "winapi-i686-pc-windows-gnu-0.4.0", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel"), + ) + + maybe( + http_archive, + name = "vendor__winapi-util-0.1.5", + sha256 = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/winapi-util/0.1.5/download"], + strip_prefix = "winapi-util-0.1.5", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.winapi-util-0.1.5.bazel"), + ) + + maybe( + http_archive, + name = "vendor__winapi-x86_64-pc-windows-gnu-0.4.0", + sha256 = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f", + type = "tar.gz", + urls = ["https://crates.io/api/v1/crates/winapi-x86_64-pc-windows-gnu/0.4.0/download"], + strip_prefix = "winapi-x86_64-pc-windows-gnu-0.4.0", + build_file = Label("@cxx.rs//third-party/bazel:BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel"), + ) diff --git a/third-party/reindeer.toml b/third-party/reindeer.toml index eb65857c..a7daf6e0 100644 --- a/third-party/reindeer.toml +++ b/third-party/reindeer.toml @@ -10,4 +10,6 @@ generated_file_header = """ """ buckfile_imports = """ load("//tools/buck:buildscript.bzl", "buildscript_args") +load("//tools/buck:third_party.bzl", "third_party_rust_library") """ +rust_library = "third_party_rust_library" diff --git a/tools/bazel/third_party.bzl b/tools/bazel/third_party.bzl deleted file mode 100644 index 5b2ec3fe..00000000 --- a/tools/bazel/third_party.bzl +++ /dev/null @@ -1,18 +0,0 @@ -load("@rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script") -load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library") -load("@third-party//:vendor.bzl", "vendored") - -def third_party_glob(include): - return vendored and native.glob(include) - -def third_party_cargo_build_script(rustc_flags = [], **kwargs): - rustc_flags = rustc_flags + ["--cap-lints=allow"] - cargo_build_script(rustc_flags = rustc_flags, **kwargs) - -def third_party_rust_binary(rustc_flags = [], **kwargs): - rustc_flags = rustc_flags + ["--cap-lints=allow"] - rust_binary(rustc_flags = rustc_flags, **kwargs) - -def third_party_rust_library(rustc_flags = [], **kwargs): - rustc_flags = rustc_flags + ["--cap-lints=allow"] - rust_library(rustc_flags = rustc_flags, **kwargs) diff --git a/tools/bazel/vendor.bzl b/tools/bazel/vendor.bzl deleted file mode 100644 index 0f199145..00000000 --- a/tools/bazel/vendor.bzl +++ /dev/null @@ -1,81 +0,0 @@ -"""A module defining a repository rule for vendoring the dependencies -of a crate in the current workspace. -""" - -load("@rules_rust//rust:defs.bzl", "rust_common") -load("@rules_rust//rust:repositories.bzl", "load_arbitrary_tool") -load("@rules_rust//rust/platform:triple.bzl", "get_host_triple") - -def _impl(repository_ctx): - # Link cxx repository into @third-party. - lockfile = repository_ctx.path(repository_ctx.attr.lockfile) - workspace = lockfile.dirname.dirname - repository_ctx.symlink(workspace, "workspace") - - # Figure out which version of cargo to use. - if repository_ctx.attr.target_triple: - target_triple = repository_ctx.attr.target_triple - else: - target_triple = get_host_triple(repository_ctx).str - - # Download cargo. - load_arbitrary_tool( - ctx = repository_ctx, - tool_name = "cargo", - tool_subdirectories = ["cargo"], - version = repository_ctx.attr.cargo_version, - iso_date = repository_ctx.attr.cargo_iso_date, - target_triple = target_triple, - ) - - cmd = ["{}/bin/cargo".format(repository_ctx.path(".")), "vendor", "--versioned-dirs"] - result = repository_ctx.execute( - cmd, - quiet = True, - working_directory = "workspace/third-party", - ) - _log_cargo_vendor(repository_ctx, result) - if result.return_code != 0: - fail("failed to execute `{}`".format(" ".join(cmd))) - - # Produce a token for third_party_glob to depend on so that the necessary - # sequencing is visible to Bazel. - repository_ctx.file("BUILD", executable = False) - repository_ctx.file("vendor.bzl", "vendored = True", executable = False) - -def _copy_file(repository_ctx, *, src, dst): - content = repository_ctx.read(src) - if not dst.exists or content != repository_ctx.read(dst): - repository_ctx.file(dst, content = content, executable = False) - -def _log_cargo_vendor(repository_ctx, result): - relevant = "" - for line in result.stderr.splitlines(True): - if line.strip() and not line.startswith("To use vendored sources,"): - relevant += line - if relevant: - # Render it as command output. - # If we just use print(), Bazel will cache and repeat the output even - # when not rerunning the command. - print = ["echo", relevant] - repository_ctx.execute(print, quiet = False) - -vendor = repository_rule( - doc = "A rule used to vendor the dependencies of a crate in the current workspace", - attrs = { - "cargo_version": attr.string( - doc = "The version of cargo to use", - ), - "cargo_iso_date": attr.string( - doc = "The date of the tool (or None, if the version is a specific version)", - ), - "target_triple": attr.string( - doc = "The target triple of the cargo binary to download", - ), - "lockfile": attr.label( - doc = "A lockfile providing the set of crates to vendor", - ), - }, - local = True, - implementation = _impl, -) diff --git a/tools/buck/buildscript.bzl b/tools/buck/buildscript.bzl index bbcf1060..e4d5e1e4 100644 --- a/tools/buck/buildscript.bzl +++ b/tools/buck/buildscript.bzl @@ -1,11 +1,15 @@ def buildscript_args( - name, - package_name, - buildscript_rule, - cfgs, - features, - outfile, - version): + name: str.type, + package_name: str.type, + buildscript_rule: str.type, + outfile: str.type, + version: str.type, + cfgs: [str.type] = [], + features: [str.type] = []): + _ = package_name + _ = version + _ = cfgs + _ = features native.genrule( name = name, out = outfile, diff --git a/tools/buck/prelude b/tools/buck/prelude -Subproject bed5249482b20f591d9d231663b23f318b6c10b +Subproject 08670e1d9a3fde1fd3cdc12839747a9ea1852a5 diff --git a/tools/buck/rust_cxx_bridge.bzl b/tools/buck/rust_cxx_bridge.bzl index 49e38fce..18bb2458 100644 --- a/tools/buck/rust_cxx_bridge.bzl +++ b/tools/buck/rust_cxx_bridge.bzl @@ -1,4 +1,7 @@ -def rust_cxx_bridge(name, src, deps = []): +def rust_cxx_bridge( + name: str.type, + src: str.type, + deps: [str.type] = []): native.genrule( name = "%s/header" % name, out = src + ".h", diff --git a/tools/buck/third_party.bzl b/tools/buck/third_party.bzl new file mode 100644 index 00000000..84e5ca8f --- /dev/null +++ b/tools/buck/third_party.bzl @@ -0,0 +1,5 @@ +def third_party_rust_library(**kwargs): + native.rust_library( + doctests = False, + **kwargs + ) diff --git a/tools/buck/toolchains/BUCK b/tools/buck/toolchains/BUCK index 87ee8933..6984a86b 100644 --- a/tools/buck/toolchains/BUCK +++ b/tools/buck/toolchains/BUCK @@ -1,4 +1,5 @@ load("@prelude//toolchains:cxx.bzl", "system_cxx_toolchain") +load("@prelude//toolchains:genrule.bzl", "system_genrule_toolchain") load("@prelude//toolchains:python.bzl", "system_python_bootstrap_toolchain") load("@prelude//toolchains:rust.bzl", "system_rust_toolchain") @@ -7,6 +8,11 @@ system_cxx_toolchain( visibility = ["PUBLIC"], ) +system_genrule_toolchain( + name = "genrule", + visibility = ["PUBLIC"], +) + system_python_bootstrap_toolchain( name = "python_bootstrap", visibility = ["PUBLIC"], @@ -15,7 +21,5 @@ system_python_bootstrap_toolchain( system_rust_toolchain( name = "rust", default_edition = None, - rustc_flags = ["-Clink-arg=-fuse-ld=lld"], - rustdoc_flags = ["-Zunstable-options"], # doc builds use unstable '--extern-html-root-url' visibility = ["PUBLIC"], ) |