mirror of
https://gitee.com/openharmony/third_party_rust_link-cplusplus
synced 2024-11-22 23:10:04 +00:00
Implement build script
This commit is contained in:
parent
d4e0bcec2c
commit
9601a516d7
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/Cargo.lock
|
||||
/target
|
14
Cargo.toml
Normal file
14
Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "link-cplusplus"
|
||||
version = "0.0.0"
|
||||
authors = ["David Tolnay <dtolnay@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
||||
|
||||
[features]
|
||||
default = [] # automatic
|
||||
libstdcxx = [] # force libstdc++
|
||||
libcxx = [] # force libc++
|
||||
nothing = [] # link nothing, determined somewhere else
|
25
build.rs
Normal file
25
build.rs
Normal file
@ -0,0 +1,25 @@
|
||||
fn main() {
|
||||
let libstdcxx = cfg!(feature = "libstdcxx");
|
||||
let libcxx = cfg!(feature = "libcxx");
|
||||
let nothing = cfg!(feature = "nothing");
|
||||
|
||||
if nothing {
|
||||
return;
|
||||
}
|
||||
|
||||
if libstdcxx && libcxx {
|
||||
println!(
|
||||
"cargo:warning=-lstdc++ and -lc++ are both requested, \
|
||||
using the platform's default"
|
||||
);
|
||||
}
|
||||
|
||||
match (libstdcxx, libcxx) {
|
||||
(true, false) => println!("cargo:rustc-link-lib=stdc++"),
|
||||
(false, true) => println!("cargo:rustc-link-lib=c++"),
|
||||
(false, false) | (true, true) => {
|
||||
// The platform's default.
|
||||
cc::Build::new().cpp(true).compile("link-cplusplus");
|
||||
}
|
||||
}
|
||||
}
|
1
src/lib.rs
Normal file
1
src/lib.rs
Normal file
@ -0,0 +1 @@
|
||||
// woohoo
|
Loading…
Reference in New Issue
Block a user