From 9f6c075e3ccadb38ed73b416c8eaf1122e16afde Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 7 Sep 2020 22:26:46 -0700 Subject: [PATCH] Inline cxx-symbols crate into cxx The separation is no longer needed for Buck when linking with lld. --- BUCK | 9 +-------- BUILD | 15 ++------------- Cargo.toml | 3 +-- src/lib.rs | 4 +++- src/{symbols => }/macros/assert.rs | 0 src/{symbols => }/macros/concat.rs | 0 src/{symbols => }/macros/mod.rs | 0 src/rust_vec.rs | 2 +- src/symbols/Cargo.toml | 13 ------------- src/symbols/lib.rs | 9 --------- src/symbols/mod.rs | 4 ++++ src/symbols/rust_string.rs | 5 ----- src/symbols/rust_vec.rs | 6 +----- third-party/Cargo.lock | 5 ----- 14 files changed, 13 insertions(+), 62 deletions(-) rename src/{symbols => }/macros/assert.rs (100%) rename src/{symbols => }/macros/concat.rs (100%) rename src/{symbols => }/macros/mod.rs (100%) delete mode 100644 src/symbols/Cargo.toml delete mode 100644 src/symbols/lib.rs create mode 100644 src/symbols/mod.rs diff --git a/BUCK b/BUCK index 5f2a65fc..695c0796 100644 --- a/BUCK +++ b/BUCK @@ -1,11 +1,10 @@ rust_library( name = "cxx", - srcs = glob(["src/**"], exclude = ["src/symbols/**"]), + srcs = glob(["src/**"]), visibility = ["PUBLIC"], deps = [ ":core", ":macro", - ":symbols", ], ) @@ -32,12 +31,6 @@ cxx_library( "cxx.h": "include/cxx.h", }, exported_linker_flags = ["-lstdc++"], - deps = [":symbols"], -) - -rust_library( - name = "symbols", - srcs = glob(["src/symbols/**"]), ) rust_library( diff --git a/BUILD b/BUILD index 197cef22..27c69319 100644 --- a/BUILD +++ b/BUILD @@ -2,18 +2,12 @@ load("//tools/bazel:rust.bzl", "rust_binary", "rust_library") rust_library( name = "cxx", - srcs = glob( - ["src/**/*.rs"], - exclude = ["src/symbols/**/*.rs"], - ), + srcs = glob(["src/**/*.rs"]), proc_macro_deps = [ ":cxxbridge-macro", ], visibility = ["//visibility:public"], - deps = [ - ":core-lib", - ":symbols", - ], + deps = [":core-lib"], ) rust_binary( @@ -44,11 +38,6 @@ cc_library( hdrs = ["include/cxx.h"], ) -rust_library( - name = "symbols", - srcs = glob(["src/symbols/**/*.rs"]), -) - rust_library( name = "cxxbridge-macro", srcs = glob(["macro/src/**"]), diff --git a/Cargo.toml b/Cargo.toml index a2aaf8ac..73539f71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ default = ["cxxbridge-flags/default"] # c++11 "c++20" = ["cxxbridge-flags/c++20"] [dependencies] -cxx-symbols = { version = "=0.4.3", path = "src/symbols" } cxxbridge-macro = { version = "=0.4.3", path = "macro" } link-cplusplus = "1.0" @@ -35,7 +34,7 @@ rustversion = "1.0" trybuild = { version = "1.0.33", features = ["diff"] } [workspace] -members = ["demo", "flags", "gen/build", "gen/cmd", "gen/lib", "macro", "src/symbols", "tests/ffi"] +members = ["demo", "flags", "gen/build", "gen/cmd", "gen/lib", "macro", "tests/ffi"] [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/src/lib.rs b/src/lib.rs index 8c7344bf..b0fe00df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -369,8 +369,9 @@ #[cfg(built_with_cargo)] extern crate link_cplusplus; + #[macro_use] -extern crate symbols; +mod macros; mod cxx_string; mod cxx_vector; @@ -383,6 +384,7 @@ mod rust_sliceu8; mod rust_str; mod rust_string; mod rust_vec; +mod symbols; mod unique_ptr; mod unwind; diff --git a/src/symbols/macros/assert.rs b/src/macros/assert.rs similarity index 100% rename from src/symbols/macros/assert.rs rename to src/macros/assert.rs diff --git a/src/symbols/macros/concat.rs b/src/macros/concat.rs similarity index 100% rename from src/symbols/macros/concat.rs rename to src/macros/concat.rs diff --git a/src/symbols/macros/mod.rs b/src/macros/mod.rs similarity index 100% rename from src/symbols/macros/mod.rs rename to src/macros/mod.rs diff --git a/src/rust_vec.rs b/src/rust_vec.rs index 5e7082ae..6f1d567a 100644 --- a/src/rust_vec.rs +++ b/src/rust_vec.rs @@ -3,7 +3,7 @@ use std::mem::ManuallyDrop; #[repr(C)] pub struct RustVec { - repr: Vec, + pub(crate) repr: Vec, } impl RustVec { diff --git a/src/symbols/Cargo.toml b/src/symbols/Cargo.toml deleted file mode 100644 index 93283add..00000000 --- a/src/symbols/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "cxx-symbols" -version = "0.4.3" -authors = ["David Tolnay "] -edition = "2018" -license = "MIT OR Apache-2.0" -description = "Implementation detail of the `cxx` crate" -repository = "https://github.com/dtolnay/cxx" -documentation = "https://docs.rs/cxx" - -[lib] -name = "symbols" -path = "lib.rs" diff --git a/src/symbols/lib.rs b/src/symbols/lib.rs deleted file mode 100644 index da0f223b..00000000 --- a/src/symbols/lib.rs +++ /dev/null @@ -1,9 +0,0 @@ -//! *Implementation detail of the `cxx` crate.* - -#[macro_use] -mod macros; - -mod exception; -mod rust_str; -mod rust_string; -mod rust_vec; diff --git a/src/symbols/mod.rs b/src/symbols/mod.rs new file mode 100644 index 00000000..a9d158db --- /dev/null +++ b/src/symbols/mod.rs @@ -0,0 +1,4 @@ +mod exception; +mod rust_str; +mod rust_string; +mod rust_vec; diff --git a/src/symbols/rust_string.rs b/src/symbols/rust_string.rs index 94b2110d..5c2982d8 100644 --- a/src/symbols/rust_string.rs +++ b/src/symbols/rust_string.rs @@ -3,11 +3,6 @@ use std::ptr; use std::slice; use std::str; -#[repr(C)] -pub(crate) struct RustString { - repr: String, -} - #[export_name = "cxxbridge04$string$new"] unsafe extern "C" fn string_new(this: &mut MaybeUninit) { ptr::write(this.as_mut_ptr(), String::new()); diff --git a/src/symbols/rust_vec.rs b/src/symbols/rust_vec.rs index 77894544..fb49b40c 100644 --- a/src/symbols/rust_vec.rs +++ b/src/symbols/rust_vec.rs @@ -1,12 +1,8 @@ use crate::rust_string::RustString; +use crate::rust_vec::RustVec; use std::mem; use std::ptr; -#[repr(C)] -pub(crate) struct RustVec { - repr: Vec, -} - macro_rules! rust_vec_shims { ($segment:expr, $ty:ty) => { const_assert_eq!(mem::size_of::<[usize; 3]>(), mem::size_of::>()); diff --git a/third-party/Cargo.lock b/third-party/Cargo.lock index 92ac6b32..8a2ee256 100644 --- a/third-party/Cargo.lock +++ b/third-party/Cargo.lock @@ -63,7 +63,6 @@ version = "0.4.3" dependencies = [ "cc", "cxx-build", - "cxx-symbols", "cxx-test-suite", "cxxbridge-flags", "cxxbridge-macro", @@ -95,10 +94,6 @@ dependencies = [ "syn", ] -[[package]] -name = "cxx-symbols" -version = "0.4.3" - [[package]] name = "cxx-test-suite" version = "0.0.0"