mirror of
https://github.com/macalimlim/ftw
synced 2024-11-10 04:24:12 +00:00
auto detect macosx sdk and osxcross target versions
This commit is contained in:
parent
3e6b03d3df
commit
770c46364f
1 changed files with 15 additions and 2 deletions
|
@ -22,6 +22,9 @@ pub enum FtwCompiler {
|
|||
}
|
||||
|
||||
const DOCKER_IMAGE: &str = "macalimlim/godot-rust-cross-compiler:0.6.0";
|
||||
const MACOSX_CROSS_COMPILER_PATH: &str = "/opt/macosx-build-tools/cross-compiler";
|
||||
const MIN_MACOSX_SDK_VERSION: &str = "11.3";
|
||||
const MIN_OSXCROSS_TARGET_VERSION: &str = "20.4";
|
||||
|
||||
#[rustfmt::skip::macros(cmd, format)]
|
||||
impl Compiler for FtwCompiler {
|
||||
|
@ -76,10 +79,20 @@ impl Compiler for FtwCompiler {
|
|||
let current_dir = Path::new(".").canonicalize()?;
|
||||
let current_dir_display = current_dir.display();
|
||||
let volume_mount = format!("{current_dir_display}:/build");
|
||||
let macosx_sdk_version_output = cmd!(docker run (DOCKER_IMAGE) ("/bin/bash") ("-c") ("echo $MACOSX_SDK_VERSION"))
|
||||
.output()?;
|
||||
let macosx_sdk_version = String::from_utf8(macosx_sdk_version_output.stdout)
|
||||
.unwrap_or(String::from(MIN_MACOSX_SDK_VERSION));
|
||||
let macosx_sdk_version = macosx_sdk_version.trim();
|
||||
let macosx_c_include_path = format!("C_INCLUDE_PATH={MACOSX_CROSS_COMPILER_PATH}/SDK/MacOSX{macosx_sdk_version}.sdk/usr/include");
|
||||
let osxcross_target_output = cmd!(docker run (DOCKER_IMAGE) ("/bin/bash") ("-c") ("{MACOSX_CROSS_COMPILER_PATH}/bin/osxcross-conf | grep OSXCROSS_TARGET= | sed 's/export OSXCROSS_TARGET=darwin//g'"))
|
||||
.output()?;
|
||||
let osxcross_target_version = String::from_utf8(osxcross_target_output.stdout)
|
||||
.unwrap_or(String::from(MIN_OSXCROSS_TARGET_VERSION));
|
||||
let macosx_cc = format!("CC={MACOSX_CROSS_COMPILER_PATH}/bin/{target_cli_arg}{osxcross_target_version}-cc");
|
||||
cmd!(docker run ("-v") (volume_mount)
|
||||
if (target == &FtwTarget::WindowsX86_64Gnu || target == &FtwTarget::WindowsX86_64Msvc) {("-e") ("C_INCLUDE_PATH=/usr/x86_64-w64-mingw32/include")}
|
||||
if (target == &FtwTarget::MacOsX86_64) {("-e") ("CC=/opt/macosx-build-tools/cross-compiler/bin/x86_64-apple-darwin20.4-cc") ("-e") ("C_INCLUDE_PATH=/opt/macosx-build-tools/cross-compiler/SDK/MacOSX11.3.sdk/usr/include")}
|
||||
if (target == &FtwTarget::MacOsAarch64) {("-e") ("CC=/opt/macosx-build-tools/cross-compiler/bin/aarch64-apple-darwin20.4-cc") ("-e") ("C_INCLUDE_PATH=/opt/macosx-build-tools/cross-compiler/SDK/MacOSX11.3.sdk/usr/include")}
|
||||
if (target == &FtwTarget::MacOsAarch64 || target == &FtwTarget::MacOsX86_64) {("-e") (macosx_cc) ("-e") (macosx_c_include_path)}
|
||||
(DOCKER_IMAGE) ("/bin/bash") ("-c")
|
||||
(cargo_build_cmd)).run()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue