Inline cxx-symbols crate into cxx

The separation is no longer needed for Buck when linking with lld.
This commit is contained in:
David Tolnay 2020-09-07 22:26:46 -07:00
parent 7aa5e21ab7
commit 9f6c075e3c
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
14 changed files with 13 additions and 62 deletions

9
BUCK
View File

@ -1,11 +1,10 @@
rust_library( rust_library(
name = "cxx", name = "cxx",
srcs = glob(["src/**"], exclude = ["src/symbols/**"]), srcs = glob(["src/**"]),
visibility = ["PUBLIC"], visibility = ["PUBLIC"],
deps = [ deps = [
":core", ":core",
":macro", ":macro",
":symbols",
], ],
) )
@ -32,12 +31,6 @@ cxx_library(
"cxx.h": "include/cxx.h", "cxx.h": "include/cxx.h",
}, },
exported_linker_flags = ["-lstdc++"], exported_linker_flags = ["-lstdc++"],
deps = [":symbols"],
)
rust_library(
name = "symbols",
srcs = glob(["src/symbols/**"]),
) )
rust_library( rust_library(

15
BUILD
View File

@ -2,18 +2,12 @@ load("//tools/bazel:rust.bzl", "rust_binary", "rust_library")
rust_library( rust_library(
name = "cxx", name = "cxx",
srcs = glob( srcs = glob(["src/**/*.rs"]),
["src/**/*.rs"],
exclude = ["src/symbols/**/*.rs"],
),
proc_macro_deps = [ proc_macro_deps = [
":cxxbridge-macro", ":cxxbridge-macro",
], ],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [":core-lib"],
":core-lib",
":symbols",
],
) )
rust_binary( rust_binary(
@ -44,11 +38,6 @@ cc_library(
hdrs = ["include/cxx.h"], hdrs = ["include/cxx.h"],
) )
rust_library(
name = "symbols",
srcs = glob(["src/symbols/**/*.rs"]),
)
rust_library( rust_library(
name = "cxxbridge-macro", name = "cxxbridge-macro",
srcs = glob(["macro/src/**"]), srcs = glob(["macro/src/**"]),

View File

@ -20,7 +20,6 @@ default = ["cxxbridge-flags/default"] # c++11
"c++20" = ["cxxbridge-flags/c++20"] "c++20" = ["cxxbridge-flags/c++20"]
[dependencies] [dependencies]
cxx-symbols = { version = "=0.4.3", path = "src/symbols" }
cxxbridge-macro = { version = "=0.4.3", path = "macro" } cxxbridge-macro = { version = "=0.4.3", path = "macro" }
link-cplusplus = "1.0" link-cplusplus = "1.0"
@ -35,7 +34,7 @@ rustversion = "1.0"
trybuild = { version = "1.0.33", features = ["diff"] } trybuild = { version = "1.0.33", features = ["diff"] }
[workspace] [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] [package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"] targets = ["x86_64-unknown-linux-gnu"]

View File

@ -369,8 +369,9 @@
#[cfg(built_with_cargo)] #[cfg(built_with_cargo)]
extern crate link_cplusplus; extern crate link_cplusplus;
#[macro_use] #[macro_use]
extern crate symbols; mod macros;
mod cxx_string; mod cxx_string;
mod cxx_vector; mod cxx_vector;
@ -383,6 +384,7 @@ mod rust_sliceu8;
mod rust_str; mod rust_str;
mod rust_string; mod rust_string;
mod rust_vec; mod rust_vec;
mod symbols;
mod unique_ptr; mod unique_ptr;
mod unwind; mod unwind;

View File

@ -3,7 +3,7 @@ use std::mem::ManuallyDrop;
#[repr(C)] #[repr(C)]
pub struct RustVec<T> { pub struct RustVec<T> {
repr: Vec<T>, pub(crate) repr: Vec<T>,
} }
impl<T> RustVec<T> { impl<T> RustVec<T> {

View File

@ -1,13 +0,0 @@
[package]
name = "cxx-symbols"
version = "0.4.3"
authors = ["David Tolnay <dtolnay@gmail.com>"]
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"

View File

@ -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;

4
src/symbols/mod.rs Normal file
View File

@ -0,0 +1,4 @@
mod exception;
mod rust_str;
mod rust_string;
mod rust_vec;

View File

@ -3,11 +3,6 @@ use std::ptr;
use std::slice; use std::slice;
use std::str; use std::str;
#[repr(C)]
pub(crate) struct RustString {
repr: String,
}
#[export_name = "cxxbridge04$string$new"] #[export_name = "cxxbridge04$string$new"]
unsafe extern "C" fn string_new(this: &mut MaybeUninit<String>) { unsafe extern "C" fn string_new(this: &mut MaybeUninit<String>) {
ptr::write(this.as_mut_ptr(), String::new()); ptr::write(this.as_mut_ptr(), String::new());

View File

@ -1,12 +1,8 @@
use crate::rust_string::RustString; use crate::rust_string::RustString;
use crate::rust_vec::RustVec;
use std::mem; use std::mem;
use std::ptr; use std::ptr;
#[repr(C)]
pub(crate) struct RustVec<T> {
repr: Vec<T>,
}
macro_rules! rust_vec_shims { macro_rules! rust_vec_shims {
($segment:expr, $ty:ty) => { ($segment:expr, $ty:ty) => {
const_assert_eq!(mem::size_of::<[usize; 3]>(), mem::size_of::<Vec<$ty>>()); const_assert_eq!(mem::size_of::<[usize; 3]>(), mem::size_of::<Vec<$ty>>());

5
third-party/Cargo.lock generated vendored
View File

@ -63,7 +63,6 @@ version = "0.4.3"
dependencies = [ dependencies = [
"cc", "cc",
"cxx-build", "cxx-build",
"cxx-symbols",
"cxx-test-suite", "cxx-test-suite",
"cxxbridge-flags", "cxxbridge-flags",
"cxxbridge-macro", "cxxbridge-macro",
@ -95,10 +94,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "cxx-symbols"
version = "0.4.3"
[[package]] [[package]]
name = "cxx-test-suite" name = "cxx-test-suite"
version = "0.0.0" version = "0.0.0"