From 1d7f27a491b32f96d7823e298680d5f2fe5e237c Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Tue, 23 Jan 2024 22:30:06 -0500 Subject: [PATCH] Add build script to set target configuration variable --- Cargo.toml | 1 + src/build.rs | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 src/build.rs diff --git a/Cargo.toml b/Cargo.toml index d464851..ea9ed07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ name = "libretunes" version = "0.1.0" edition = "2021" +build = "src/build.rs" [lib] crate-type = ["cdylib", "rlib"] diff --git a/src/build.rs b/src/build.rs new file mode 100644 index 0000000..32eb98c --- /dev/null +++ b/src/build.rs @@ -0,0 +1,9 @@ +// Set the target config variable to the target triple of the current build +// This is used so we can determine the target triple at compile time +// See https://stackoverflow.com/a/51311222 +fn main() { + println!( + "cargo:rustc-cfg=target=\"{}\"", + std::env::var("TARGET").unwrap() + ); +}