You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
175 lines
6.1 KiB
175 lines
6.1 KiB
From 7774f87f17effff3affa6d04a7e9f7b5a8b5ade1 Mon Sep 17 00:00:00 2001
|
|
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
|
|
Date: Fri, 4 Oct 2024 13:28:53 -0400
|
|
Subject: [PATCH] Downstream-only: always use the system isa-l shared library
|
|
and regenerate bindings
|
|
|
|
---
|
|
build.rs | 122 ++---------------------------------------------
|
|
src/igzip_lib.rs | 6 +--
|
|
2 files changed, 7 insertions(+), 121 deletions(-)
|
|
|
|
diff --git a/build.rs b/build.rs
|
|
index b439804..dfe9780 100644
|
|
--- a/build.rs
|
|
+++ b/build.rs
|
|
@@ -1,131 +1,17 @@
|
|
use std::path::PathBuf;
|
|
-use std::{
|
|
- io::{self, Write},
|
|
- process::{Command, Stdio},
|
|
-};
|
|
|
|
fn main() {
|
|
+ // Downstream patch: always use the system shared library, and always regenerate bindings.
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
+ println!("cargo:rustc-link-lib=isal");
|
|
|
|
- let is_static = cfg!(feature = "static");
|
|
- let is_shared = cfg!(feature = "shared");
|
|
- let target = std::env::var("TARGET").unwrap();
|
|
- let out_dir = PathBuf::from(&std::env::var("OUT_DIR").unwrap());
|
|
-
|
|
- // Copy isa-l source into out; not allow to modify things outside of out dir
|
|
- let src_dir = out_dir.join("isa-l");
|
|
- if src_dir.exists() {
|
|
- std::fs::remove_dir_all(&src_dir).unwrap(); // maybe from a previous build
|
|
- }
|
|
- copy_dir::copy_dir("isa-l", &src_dir).unwrap();
|
|
-
|
|
- let install_path = std::env::var("ISAL_INSTALL_PREFIX")
|
|
- .map(|p| PathBuf::from(&p).clone())
|
|
- .unwrap_or(out_dir.clone());
|
|
-
|
|
- let current_dir = std::env::current_dir().unwrap();
|
|
- std::env::set_current_dir(&src_dir).unwrap();
|
|
-
|
|
- // build from source
|
|
- #[cfg(not(feature = "use-system-isal"))]
|
|
- {
|
|
- #[cfg(not(target_os = "windows"))]
|
|
- let cmd = {
|
|
- let status = Command::new("./autogen.sh")
|
|
- .stdout(Stdio::piped())
|
|
- .stderr(Stdio::piped())
|
|
- .output()
|
|
- .unwrap();
|
|
- io::stdout().write_all(&status.stdout).unwrap();
|
|
- io::stderr().write_all(&status.stderr).unwrap();
|
|
- if !status.status.success() {
|
|
- panic!("autogen failed");
|
|
- }
|
|
-
|
|
- let compiler = cc::Build::new().get_compiler();
|
|
- let cflags = compiler.cflags_env().into_string().unwrap();
|
|
-
|
|
- let mut configure_args = vec![
|
|
- format!("--prefix={}", install_path.display()),
|
|
- format!("--host={}", target),
|
|
- format!("--enable-static={}", if is_static { "yes" } else { "no" }),
|
|
- format!("--enable-shared={}", if is_shared { "yes" } else { "no" }),
|
|
- format!("CFLAGS={}", cflags),
|
|
- format!("CC={}", compiler.path().display()),
|
|
- ];
|
|
-
|
|
- if !cfg!(target_os = "macos") {
|
|
- let ldflag = if is_static { "static" } else { "shared" };
|
|
- configure_args.push(format!("LDFLAGS=-{}", ldflag));
|
|
- configure_args.push("--with-pic=yes".to_string());
|
|
- }
|
|
-
|
|
- let status = Command::new("./configure")
|
|
- .args(&configure_args)
|
|
- .stdout(Stdio::piped())
|
|
- .stderr(Stdio::piped())
|
|
- .output()
|
|
- .unwrap();
|
|
- io::stdout().write_all(&status.stdout).unwrap();
|
|
- io::stderr().write_all(&status.stderr).unwrap();
|
|
- if !status.status.success() {
|
|
- panic!("configure failed");
|
|
- }
|
|
-
|
|
- Command::new("make")
|
|
- .args(&["install-libLTLIBRARIES"])
|
|
- .stdout(Stdio::piped())
|
|
- .stderr(Stdio::piped())
|
|
- .spawn()
|
|
- };
|
|
-
|
|
- #[cfg(target_os = "windows")]
|
|
- let mut cmd = {
|
|
- Command::new("nmake")
|
|
- .args(["-f", "Makefile.nmake"])
|
|
- .stdout(Stdio::piped())
|
|
- .stderr(Stdio::piped())
|
|
- .spawn()
|
|
- };
|
|
-
|
|
- std::env::set_current_dir(¤t_dir).unwrap();
|
|
-
|
|
- let output = cmd.unwrap().wait_with_output().unwrap();
|
|
- io::stdout().write_all(&output.stdout).unwrap();
|
|
- io::stderr().write_all(&output.stderr).unwrap();
|
|
- if !output.status.success() {
|
|
- panic!("Building isa-l failed");
|
|
- }
|
|
- }
|
|
-
|
|
- let libname = if cfg!(target_os = "windows") {
|
|
- println!("cargo:rustc-link-search=native={}", src_dir.display());
|
|
- if cfg!(feature = "static") {
|
|
- "isa-l_static"
|
|
- } else {
|
|
- "isa-l"
|
|
- }
|
|
- } else {
|
|
- for subdir in ["bin", "lib", "lib64"] {
|
|
- let search_path = install_path.join(subdir);
|
|
- println!("cargo:rustc-link-search=native={}", search_path.display());
|
|
- }
|
|
- "isal"
|
|
- };
|
|
-
|
|
- #[cfg(feature = "static")]
|
|
- println!("cargo:rustc-link-lib=static={}", libname);
|
|
-
|
|
- #[cfg(feature = "shared")]
|
|
- println!("cargo:rustc-link-lib={}", libname);
|
|
-
|
|
- #[cfg(feature = "regenerate-bindings")]
|
|
{
|
|
let out = PathBuf::from(&(format!("{}/igzip_lib.rs", std::env::var("OUT_DIR").unwrap())));
|
|
bindgen::Builder::default()
|
|
// The input header we would like to generate
|
|
// bindings for.
|
|
- .header("isa-l/include/igzip_lib.h")
|
|
+ // Downstream patch: use the system header.
|
|
+ .header("/usr/include/isa-l/igzip_lib.h")
|
|
// Tell cargo to invalidate the built crate whenever any of the
|
|
// included header files changed.
|
|
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
|
|
diff --git a/src/igzip_lib.rs b/src/igzip_lib.rs
|
|
index dff227e..c6cbe31 100644
|
|
--- a/src/igzip_lib.rs
|
|
+++ b/src/igzip_lib.rs
|
|
@@ -1,12 +1,12 @@
|
|
pub use bindings::*;
|
|
|
|
-#[cfg(feature = "regenerate-bindings")]
|
|
+// Downstream patch: always regenerate bindings
|
|
pub mod bindings {
|
|
include!(concat!(env!("OUT_DIR"), "/igzip_lib.rs"));
|
|
}
|
|
|
|
-// copy from target dir when updating bindings
|
|
-#[cfg(not(feature = "regenerate-bindings"))]
|
|
+// Downstream patch: always regenerate bindings. cfg(any()) is false
|
|
+#[cfg(any())]
|
|
pub mod bindings {
|
|
/* automatically generated by rust-bindgen 0.69.4 */
|
|
|
|
--
|
|
2.46.1
|
|
|