fn lipo_native_library(wstp_lib: &PathBuf, lipo_arch: &str) -> PathBuf {
    let wstp_lib = wstp_lib
        .to_str()
        .expect("could not convert WSTP archive path to str");

    // `lipo` will return an error if run on a non-universal binary, so avoid doing
    // that by using the `file` command to check the type of `wstp_lib`.
    let is_universal_binary = {
        let stdout = process::Command::new("file")
            .args(&[wstp_lib])
            .output()
            .expect("failed to run `file` system utility")
            .stdout;
        let stdout = String::from_utf8(stdout).unwrap();
        stdout.contains("Mach-O universal binary")
    };

    if !is_universal_binary {
        return PathBuf::from(wstp_lib);
    }

    // Place the lipo'd library file in the system temporary directory.
    let output_lib = std::env::temp_dir().join("libWSTP-thin.a");
    let output_lib = output_lib
        .to_str()
        .expect("could not convert WSTP archive path to str");

    let output = process::Command::new("lipo")
        .args(&[wstp_lib, "-thin", lipo_arch, "-output", output_lib])
        .output()
        .expect("failed to invoke macOS `lipo` command");

    if !output.status.success() {
        panic!("unable to lipo WSTP library: {:#?}", output);
    }

    PathBuf::from(output_lib)
}
/// Use the macOS `lipo` command to construct an x86_64 archive file from the WSTPi4.a
/// file in the Mathematica layout. This is necessary as a workaround to a bug in the
/// Rust compiler at the moment: https://github.com/rust-lang/rust/issues/50220.
/// The problem is that WSTPi4.a is a so called "universal binary"; it's an archive
/// file with multiple copies of the same library, each for a different target
/// architecture. The `lipo -thin` command creates a new archive which contains just
/// the library for the named architecture.
Use the macOS `lipo` command to construct an x86_64 archive file from the WSTPi4.a
file in the Mathematica layout.
Use the macOS ` lipo ` command to construct an x86_64 archive file from the WSTPi4 . a file in the Mathematica layout .
fn lipo_native_library(wstp_lib: &PathBuf, lipo_arch: &str) -> PathBuf {
    let wstp_lib = wstp_lib
        .to_str()
        .expect("could not convert WSTP archive path to str");
    // `lipo` will return an error if run on a non-universal binary, so avoid doing
    // that by using the `file` command to check the type of `wstp_lib`.
    let is_universal_binary = {
        let stdout = process::Command::new("file")
            .args(&[wstp_lib])
            .output()
            .expect("failed to run `file` system utility")
            .stdout;
        let stdout = String::from_utf8(stdout).unwrap();
        stdout.contains("Mach-O universal binary")
    };
    if !is_universal_binary {
        return PathBuf::from(wstp_lib);
    }
    // Place the lipo'd library file in the system temporary directory.
    let output_lib = std::env::temp_dir().join("libWSTP-thin.a");
    let output_lib = output_lib
        .to_str()
        .expect("could not convert WSTP archive path to str");
    let output = process::Command::new("lipo")
        .args(&[wstp_lib, "-thin", lipo_arch, "-output", output_lib])
        .output()
        .expect("failed to invoke macOS `lipo` command");
    if !output.status.success() {
        panic!("unable to lipo WSTP library: {:#?}", output);
    }
    PathBuf::from(output_lib)
}
fn lipo_native_library ( wstp_lib : & PathBuf , lipo_arch : & str ) -> PathBuf { let wstp_lib = wstp_lib . to_str ( ) . expect ( " " ) ; // `lipo` will return an error if run on a non-universal binary, so avoid doing // that by using the `file` command to check the type of `wstp_lib`. let is_universal_binary = { let stdout = process :: Command :: new ( " " ) . args ( & [ wstp_lib ] ) . output ( ) . expect ( " " ) . stdout ; let stdout = String :: from_utf8 ( stdout ) . unwrap ( ) ; stdout . contains ( " " ) } ; if ! is_universal_binary { return PathBuf :: from ( wstp_lib ) ; } // Place the lipo'd library file in the system temporary directory. let output_lib = std :: env :: temp_dir ( ) . join ( " " ) ; let output_lib = output_lib . to_str ( ) . expect ( " " ) ; let output = process :: Command :: new ( " " ) . args ( & [ wstp_lib , " " , lipo_arch , " " , output_lib ] ) . output ( ) . expect ( " " ) ; if ! output . status . success ( ) { panic ! ( " " output ) ; } PathBuf :: from ( output_lib ) }
Use the macOS `lipo` command to construct an x86_64 archive file from the WSTPi4.a
file in the Mathematica layout.
Use the macOS ` lipo ` command to construct an x86_64 archive file from the WSTPi4 . a file in the Mathematica layout .
wstp_lib
&PathBuf
lipo_arch
&str