From fd9c0fa4b232b83c0d567c7be7a3e69771851dd8 Mon Sep 17 00:00:00 2001 From: Valerii Hiora Date: Wed, 31 Dec 2014 16:20:01 +0200 Subject: [PATCH] Additional archs for iOS --- src/lib.rs | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 73a90a8..ef6d674 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -175,24 +175,34 @@ fn cflags() -> Vec { } fn ios_flags(target: &str) -> Vec { - let mut is_device_arch = false; + enum ArchSpec { + Device(&'static str), + Simulator(&'static str), + } + let mut res = Vec::new(); - if target.starts_with("arm-") { - res.push("-arch"); - res.push("armv7"); - is_device_arch = true; - } else if target.starts_with("arm64-") { - res.push("-arch"); - res.push("arm64"); - is_device_arch = true; - } else if target.starts_with("i386-") { - res.push("-m32"); - } else if target.starts_with("x86_64-") { - res.push("-m64"); - } + let arch = target.split('-').nth(0).expect("expected target in format `arch-vendor-os`"); + let arch = match arch { + "arm" | "armv7" | "thumbv7" => ArchSpec::Device("armv7"), + "armv7s" | "thumbv7s" => ArchSpec::Device("armv7s"), + "arm64" | "aarch64" => ArchSpec::Device("aarch64"), + "i386" | "i686" => ArchSpec::Simulator("-m32"), + "x86_64" => ArchSpec::Simulator("-m64"), + _ => unreachable!("Unknown arch for iOS target") + }; - let sdk = if is_device_arch {"iphoneos"} else {"iphonesimulator"}; + let sdk = match arch { + ArchSpec::Device(arch) => { + res.push("-arch"); + res.push(arch); + "iphoneos" + }, + ArchSpec::Simulator(arch) => { + res.push(arch); + "iphonesimulator" + } + }; println!("Detecting iOS SDK path for {}", sdk); let sdk_path = Command::new("xcrun")