Skip to content

Commit 986c211

Browse files
committed
Invoke backtrace-rs' buildscript in std's buildscript
1 parent 2643b16 commit 986c211

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

library/std/build.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
use std::env;
22

3+
// backtrace-rs requires a feature check on Android targets, so
4+
// we need to run its build.rs as well. Note that we use an
5+
// include! rather than #[path = ""] because backtrace-rs's main
6+
// function is private.
7+
#[allow(unused_extern_crates)]
8+
mod backtrace_rs_build_rs {
9+
include!("../backtrace/build.rs");
10+
11+
#[inline]
12+
pub fn call_main() {
13+
main();
14+
}
15+
}
16+
317
fn main() {
418
println!("cargo:rerun-if-changed=build.rs");
519
let target = env::var("TARGET").expect("TARGET was not set");
@@ -49,4 +63,6 @@ fn main() {
4963
}
5064
println!("cargo:rustc-env=STD_ENV_ARCH={}", env::var("CARGO_CFG_TARGET_ARCH").unwrap());
5165
println!("cargo:rustc-cfg=backtrace_in_libstd");
66+
67+
backtrace_rs_build_rs::call_main();
5268
}

library/std/src/android-api.c

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Used from backtrace-rs' build script to detect the value of the `__ANDROID_API__`
2+
// builtin #define
3+
4+
APIVERSION __ANDROID_API__

0 commit comments

Comments
 (0)