Skip to content

Commit

Permalink
Modify handling of cross-compilation targets
Browse files Browse the repository at this point in the history
That way, hard float variants are accepted as well.

Signed-off-by: Hugues de Valon <[email protected]>
  • Loading branch information
hug-dev committed Apr 6, 2021
1 parent bab141a commit 8af7386
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions tss-esapi-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ links = "tss2-esys"
[build-dependencies]
bindgen = { version = "0.57.0", optional = true }
pkg-config = "0.3.18"
target-lexicon = "0.12.0"

[features]
generate-bindings = ["bindgen"]
21 changes: 11 additions & 10 deletions tss-esapi-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ fn main() {

#[cfg(not(feature = "generate-bindings"))]
{
let supported_platforms = vec![
String::from("x86_64-unknown-linux-gnu"),
String::from("aarch64-unknown-linux-gnu"),
String::from("armv7-unknown-linux-gnueabi"),
String::from("arm-unknown-linux-gnueabi"),
];
let target = std::env::var("TARGET").unwrap();
use std::str::FromStr;
use target_lexicon::{Architecture, OperatingSystem, Triple};

// check if target is in the list of supported ones or panic with nice message
if !supported_platforms.contains(&target) {
panic!(format!("Compilation target ({}) is not part of the supported targets ({:?}). Please compile with the \"generate-bindings\" feature or add support for your platform :)", target, supported_platforms));
let target = Triple::from_str(&std::env::var("TARGET").unwrap())
.expect("Failed to parse target triple");
match (target.architecture, target.operating_system) {
(Architecture::Arm(_), OperatingSystem::Linux) => {}
(Architecture::Aarch64(_), OperatingSystem::Linux) => {}
(Architecture::X86_64, OperatingSystem::Linux) => {}
(arch, os) => {
panic!("Compilation target (architecture, OS) tuple ({}, {}) is not part of the supported tuples. Please compile with the \"generate-bindings\" feature or add support for your platform :)", arch, os);
}
}

pkg_config::Config::new()
Expand Down

0 comments on commit 8af7386

Please sign in to comment.