Move header include path to rust/cxx.h
diff --git a/BUCK b/BUCK
index 2d12753..2f80c9b 100644
--- a/BUCK
+++ b/BUCK
@@ -38,11 +38,11 @@
cxx_library(
name = "core",
- srcs = ["src/cxxbridge.cc"],
+ srcs = ["src/cxx.cc"],
visibility = ["PUBLIC"],
- header_namespace = "cxxbridge",
+ header_namespace = "rust",
exported_headers = {
- "cxxbridge.h": "include/cxxbridge.h",
+ "cxx.h": "include/cxx.h",
},
exported_linker_flags = ["-lstdc++"],
)
diff --git a/BUILD b/BUILD
index 0405df1..db22203 100644
--- a/BUILD
+++ b/BUILD
@@ -3,7 +3,7 @@
rust_library(
name = "cxx",
srcs = glob(["src/**/*.rs"]),
- data = ["src/gen/include/cxxbridge.h"],
+ data = ["src/gen/include/cxx.h"],
visibility = ["//visibility:public"],
deps = [
":core-lib",
@@ -23,7 +23,7 @@
rust_binary(
name = "codegen",
srcs = glob(["cmd/src/**/*.rs"]),
- data = ["cmd/src/gen/include/cxxbridge.h"],
+ data = ["cmd/src/gen/include/cxx.h"],
visibility = ["//visibility:public"],
deps = [
"//third-party:anyhow",
@@ -39,16 +39,16 @@
cc_library(
name = "core",
- hdrs = ["include/cxxbridge.h"],
- include_prefix = "cxxbridge",
+ hdrs = ["include/cxx.h"],
+ include_prefix = "rust",
strip_include_prefix = "include",
visibility = ["//visibility:public"],
)
cc_library(
name = "core-lib",
- srcs = ["src/cxxbridge.cc"],
- hdrs = ["include/cxxbridge.h"],
+ srcs = ["src/cxx.cc"],
+ hdrs = ["include/cxx.h"],
)
rust_library(
diff --git a/README.md b/README.md
index 07ea91e..2886082 100644
--- a/README.md
+++ b/README.md
@@ -306,9 +306,9 @@
<tr><td></td><td></td><td></td></tr>
</table>
-The C++ API of the `cxxbridge` namespace is defined by the *include/cxxbridge.h*
-file in this repo. You will need to include this header in your C++ code when
-working with those types.
+The C++ API of the `rust` namespace is defined by the *include/cxx.h* file in
+this repo. You will need to include this header in your C++ code when working
+with those types.
The following types are intended to be supported "soon" but are just not
implemented yet. I don't expect any of these to be hard to make work but it's a
diff --git a/build.rs b/build.rs
index ea562c2..bdda779 100644
--- a/build.rs
+++ b/build.rs
@@ -1,8 +1,8 @@
fn main() {
cc::Build::new()
- .file("src/cxxbridge.cc")
+ .file("src/cxx.cc")
.flag("-std=c++11")
.compile("cxxbridge01");
- println!("cargo:rerun-if-changed=src/cxxbridge.cc");
- println!("cargo:rerun-if-changed=include/cxxbridge.h");
+ println!("cargo:rerun-if-changed=src/cxx.cc");
+ println!("cargo:rerun-if-changed=include/cxx.h");
}
diff --git a/cmd/src/main.rs b/cmd/src/main.rs
index 26b6ef6..06b3bbe 100644
--- a/cmd/src/main.rs
+++ b/cmd/src/main.rs
@@ -14,7 +14,7 @@
usage = "\
cxxbridge <input>.rs Emit .cc file for bridge to stdout
cxxbridge <input>.rs --header Emit .h file for bridge to stdout
- cxxbridge --header Emit cxxbridge.h header to stdout",
+ cxxbridge --header Emit rust/cxx.h header to stdout",
help_message = "Print help information",
version_message = "Print version information"
)]
diff --git a/demo-cxx/demo.h b/demo-cxx/demo.h
index a579986..fafc474 100644
--- a/demo-cxx/demo.h
+++ b/demo-cxx/demo.h
@@ -1,5 +1,5 @@
#pragma once
-#include "cxxbridge/cxxbridge.h"
+#include "rust/cxx.h"
#include <memory>
#include <string>
diff --git a/gen/include.rs b/gen/include.rs
index e34d9d0..a4b416a 100644
--- a/gen/include.rs
+++ b/gen/include.rs
@@ -1,6 +1,6 @@
use std::fmt::{self, Display};
-pub static HEADER: &str = include_str!("include/cxxbridge.h");
+pub static HEADER: &str = include_str!("include/cxx.h");
pub fn get(guard: &str) -> &'static str {
let ifndef = format!("#ifndef {}", guard);
@@ -10,7 +10,7 @@
if let (Some(begin), Some(end)) = (begin, end) {
&HEADER[begin..end + endif.len()]
} else {
- panic!("not found in cxxbridge.h header: {}", guard)
+ panic!("not found in cxx.h header: {}", guard)
}
}
diff --git a/gen/write.rs b/gen/write.rs
index 601f7ef..9ab98fa 100644
--- a/gen/write.rs
+++ b/gen/write.rs
@@ -126,7 +126,7 @@
out.begin_block("inline namespace cxxbridge01");
if needs_rust_box || needs_manually_drop || needs_maybe_uninit {
- writeln!(out, "// #include \"cxxbridge.h\"");
+ writeln!(out, "// #include \"rust/cxx.h\"");
}
if needs_rust_box {
diff --git a/include/cxxbridge.h b/include/cxx.h
similarity index 100%
rename from include/cxxbridge.h
rename to include/cxx.h
diff --git a/src/cxxbridge.cc b/src/cxx.cc
similarity index 98%
rename from src/cxxbridge.cc
rename to src/cxx.cc
index b44204d..f7b02ec 100644
--- a/src/cxxbridge.cc
+++ b/src/cxx.cc
@@ -1,4 +1,4 @@
-#include "../include/cxxbridge.h"
+#include "../include/cxx.h"
#include <cstring>
#include <iostream>
#include <memory>
diff --git a/src/lib.rs b/src/lib.rs
index 006159a..316918f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -310,9 +310,9 @@
//! <tr><td></td><td></td><td></td></tr>
//! </table>
//!
-//! The C++ API of the `cxxbridge` namespace is defined by the
-//! *include/cxxbridge.h* file in https://github.com/dtolnay/cxx. You will need
-//! to include this header in your C++ code when working with those types.
+//! The C++ API of the `rust` namespace is defined by the *include/cxx.h* file
+//! in https://github.com/dtolnay/cxx. You will need to include this header in
+//! your C++ code when working with those types.
//!
//! The following types are intended to be supported "soon" but are just not
//! implemented yet. I don't expect any of these to be hard to make work but
@@ -463,10 +463,10 @@
let mut build = paths::cc_build();
build.file(&bridge_path);
- let ref cxxbridge_h = paths::include_dir()?.join("cxxbridge").join("cxxbridge.h");
- let _ = fs::create_dir_all(cxxbridge_h.parent().unwrap());
- let _ = fs::remove_file(cxxbridge_h);
- let _ = fs::write(cxxbridge_h, gen::include::HEADER);
+ let ref cxx_h = paths::include_dir()?.join("rust").join("cxx.h");
+ let _ = fs::create_dir_all(cxx_h.parent().unwrap());
+ let _ = fs::remove_file(cxx_h);
+ let _ = fs::write(cxx_h, gen::include::HEADER);
Ok(build)
}
diff --git a/tests/ffi/tests.h b/tests/ffi/tests.h
index f41cc5e..7cff6fa 100644
--- a/tests/ffi/tests.h
+++ b/tests/ffi/tests.h
@@ -1,5 +1,5 @@
#pragma once
-#include "cxxbridge/cxxbridge.h"
+#include "rust/cxx.h"
#include <memory>
#include <string>