Skip to content

Commit

Permalink
Set C++ std in cxx_build for simpler usage
Browse files Browse the repository at this point in the history
  • Loading branch information
roligugus committed Sep 25, 2020
1 parent 1fa8579 commit ea7bb1f
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 4 deletions.
6 changes: 6 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ rust_library(
],
)

rust_library(
name = "cxxbridge-flags",
srcs = glob(["flags/src/**"]),
)

rust_library(
name = "build",
srcs = glob(["gen/build/src/**/*.rs"]),
Expand All @@ -61,6 +66,7 @@ rust_library(
"//third-party:proc-macro2",
"//third-party:quote",
"//third-party:syn",
"//:cxxbridge-flags",
],
)

Expand Down
1 change: 0 additions & 1 deletion demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ cxx = { path = "..", features= ["c++14"] }

[build-dependencies]
cxx-build = { path = "../gen/build" }
cxxbridge-flags = { path = "../flags" }

1 change: 0 additions & 1 deletion demo/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
fn main() {
cxx_build::bridge("src/main.rs")
.file("src/demo.cc")
.flag_if_supported(cxxbridge_flags::STD)
.compile("cxxbridge-demo");

println!("cargo:rerun-if-changed=src/main.rs");
Expand Down
1 change: 1 addition & 0 deletions gen/build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ codespan-reporting = "0.9"
proc-macro2 = { version = "1.0.17", default-features = false, features = ["span-locations"] }
quote = { version = "1.0", default-features = false }
syn = { version = "1.0.20", default-features = false, features = ["parsing", "printing", "clone-impls", "full"] }
cxxbridge-flags = { version = "=0.4.7", path = "../../flags", default-features = false }

[dev-dependencies]
cxx-gen = { version = "0.4", path = "../lib" }
Expand Down
2 changes: 2 additions & 0 deletions gen/build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ fn build(rust_source_files: &mut dyn Iterator<Item = impl AsRef<Path>>) -> Resul
build.cpp(true);
build.cpp_link_stdlib(None); // linked via link-cplusplus crate
build.include(&include_dir);
// Set feature parameters, such as C++ std, for simpler usage
build.flag_if_supported(cxxbridge_flags::STD);
write_header(prj);
let crate_dir = symlink_crate(prj, &mut build);

Expand Down
1 change: 0 additions & 1 deletion tests/ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ cxx = { path = "../.." }

[build-dependencies]
cxx-build = { path = "../../gen/build" }
cxxbridge-flags = { path = "../../flags" }
1 change: 0 additions & 1 deletion tests/ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ fn main() {
let sources = vec!["lib.rs", "module.rs"];
cxx_build::bridges(sources)
.file("tests.cc")
.flag_if_supported(cxxbridge_flags::STD)
.compile("cxx-test-suite");
}

0 comments on commit ea7bb1f

Please sign in to comment.