1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
Description: generate bindings if needed.
if pre-generated bindings are not available on the current architecture,
generate them rather than failing the build.
This does mean unconditionally depending on bindgen for the build script
which will slow down builds a bit, but I think that is an acceptable
tradeoff for Debian.
Author: Peter Michael Green <plugwash@debian.org>
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -34,7 +34,6 @@
[build-dependencies.bindgen]
version = "0.66.1"
-optional = true
[build-dependencies.pkg-config]
version = "0.3.18"
@@ -43,4 +42,4 @@
version = "0.12.0"
[features]
-generate-bindings = ["bindgen"]
+generate-bindings = []
--- a/build.rs
+++ b/build.rs
@@ -1,7 +1,6 @@
// Copyright 2021 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0
-#[cfg(feature = "generate-bindings")]
use std::path::PathBuf;
const MINIMUM_VERSION: &str = "2.4.6";
@@ -32,7 +31,13 @@
(Architecture::X86_64, OperatingSystem::Darwin) => {}
(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);
+ //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);
+ //no bindings available, lets generate some
+ let out_path = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
+ let esys_path = out_path.join("tss_esapi_bindings.rs");
+ generate_from_system(esys_path);
+ //tell the main code to use the generated bindings
+ print!("cargo:rustc-cfg=feature=\"generate-bindings\"\n");
}
}
@@ -57,7 +62,6 @@
}
}
-#[cfg(feature = "generate-bindings")]
pub fn generate_from_system(esapi_out: PathBuf) {
pkg_config::Config::new()
.atleast_version(MINIMUM_VERSION)
|