Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify handling of cross-compilation targets #219

Merged
merged 1 commit into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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