summaryrefslogtreecommitdiffstats
path: root/library/backtrace/build.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /library/backtrace/build.rs
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/backtrace/build.rs')
-rw-r--r--library/backtrace/build.rs31
1 files changed, 20 insertions, 11 deletions
diff --git a/library/backtrace/build.rs b/library/backtrace/build.rs
index 9bd3abd16..ed4e07a85 100644
--- a/library/backtrace/build.rs
+++ b/library/backtrace/build.rs
@@ -11,17 +11,27 @@ pub fn main() {
}
}
+// Used to detect the value of the `__ANDROID_API__`
+// builtin #define
+const MARKER: &str = "BACKTRACE_RS_ANDROID_APIVERSION";
+const ANDROID_API_C: &str = "
+BACKTRACE_RS_ANDROID_APIVERSION __ANDROID_API__
+";
+
fn build_android() {
- // Resolve `src/android-api.c` relative to this file.
+ // Create `android-api.c` on demand.
// Required to support calling this from the `std` build script.
- let android_api_c = Path::new(file!())
- .parent()
- .unwrap()
- .join("src/android-api.c");
- let expansion = match cc::Build::new().file(android_api_c).try_expand() {
+ let out_dir = env::var_os("OUT_DIR").unwrap();
+ let android_api_c = Path::new(&out_dir).join("android-api.c");
+ std::fs::write(&android_api_c, ANDROID_API_C).unwrap();
+
+ let expansion = match cc::Build::new().file(&android_api_c).try_expand() {
Ok(result) => result,
Err(e) => {
- println!("failed to run C compiler: {}", e);
+ eprintln!(
+ "warning: android version detection failed while running C compiler: {}",
+ e
+ );
return;
}
};
@@ -29,13 +39,12 @@ fn build_android() {
Ok(s) => s,
Err(_) => return,
};
- println!("expanded android version detection:\n{}", expansion);
- let marker = "APIVERSION";
- let i = match expansion.find(marker) {
+ eprintln!("expanded android version detection:\n{}", expansion);
+ let i = match expansion.find(MARKER) {
Some(i) => i,
None => return,
};
- let version = match expansion[i + marker.len() + 1..].split_whitespace().next() {
+ let version = match expansion[i + MARKER.len() + 1..].split_whitespace().next() {
Some(s) => s,
None => return,
};