Skip to content

Commit d328816

Browse files
committed
Set C++ std in cxx_build for simpler usage
1 parent 1fa8579 commit d328816

File tree

7 files changed

+9
-4
lines changed

7 files changed

+9
-4
lines changed

BUILD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ rust_library(
5050
],
5151
)
5252

53+
rust_library(
54+
name = "cxxbridge-flags",
55+
srcs = glob(["flags/src/*.rs"]),
56+
)
57+
5358
rust_library(
5459
name = "build",
5560
srcs = glob(["gen/build/src/**/*.rs"]),
@@ -61,6 +66,7 @@ rust_library(
6166
"//third-party:proc-macro2",
6267
"//third-party:quote",
6368
"//third-party:syn",
69+
"//:cxxbridge-flags",
6470
],
6571
)
6672

demo/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ cxx = { path = "..", features= ["c++14"] }
1010

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

demo/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
fn main() {
22
cxx_build::bridge("src/main.rs")
33
.file("src/demo.cc")
4-
.flag_if_supported(cxxbridge_flags::STD)
54
.compile("cxxbridge-demo");
65

76
println!("cargo:rerun-if-changed=src/main.rs");

gen/build/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ codespan-reporting = "0.9"
1616
proc-macro2 = { version = "1.0.17", default-features = false, features = ["span-locations"] }
1717
quote = { version = "1.0", default-features = false }
1818
syn = { version = "1.0.20", default-features = false, features = ["parsing", "printing", "clone-impls", "full"] }
19+
cxxbridge-flags = { version = "=0.4.7", path = "../../flags", default-features = false }
1920

2021
[dev-dependencies]
2122
cxx-gen = { version = "0.4", path = "../lib" }

gen/build/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ fn build(rust_source_files: &mut dyn Iterator<Item = impl AsRef<Path>>) -> Resul
134134
build.cpp(true);
135135
build.cpp_link_stdlib(None); // linked via link-cplusplus crate
136136
build.include(&include_dir);
137+
// Set feature parameters, such as C++ std, for simpler usage
138+
build.flag_if_supported(cxxbridge_flags::STD);
137139
write_header(prj);
138140
let crate_dir = symlink_crate(prj, &mut build);
139141

tests/ffi/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ cxx = { path = "../.." }
1212

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

tests/ffi/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ fn main() {
66
let sources = vec!["lib.rs", "module.rs"];
77
cxx_build::bridges(sources)
88
.file("tests.cc")
9-
.flag_if_supported(cxxbridge_flags::STD)
109
.compile("cxx-test-suite");
1110
}

0 commit comments

Comments
 (0)