Fix cross compilation on a macos host

In a build script `cfg(target_os=...)` refers to the host, not the target. Using the `CARGO_CFG_TARGET_OS` environment variable sets the link parameters properly.
This commit is contained in:
alexmoon
2023-06-19 13:40:07 -04:00
parent ea971242a8
commit 411e243dcd
+6 -7
View File
@@ -14,12 +14,11 @@
* limitations under the License.
*/
#[cfg(any(target_os = "macos", target_os = "ios"))]
fn main() {
println!("cargo:rustc-link-lib=framework=CoreMedia");
println!("cargo:rustc-link-lib=framework=AVFoundation");
println!("cargo:rustc-link-lib=framework=CoreVideo");
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
if target_os == "macos" || target_os == "ios" {
println!("cargo:rustc-link-lib=framework=CoreMedia");
println!("cargo:rustc-link-lib=framework=AVFoundation");
println!("cargo:rustc-link-lib=framework=CoreVideo");
}
}
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
fn main() {}