| 1 | use super::TargetInfo; |
| 2 | |
| 3 | impl TargetInfo<'_> { |
| 4 | pub(crate) fn apple_sdk_name(&self) -> &'static str { |
| 5 | match (self.os, self.abi) { |
| 6 | ("macos" , "" ) => "macosx" , |
| 7 | ("ios" , "" ) => "iphoneos" , |
| 8 | ("ios" , "sim" ) => "iphonesimulator" , |
| 9 | ("ios" , "macabi" ) => "macosx" , |
| 10 | ("tvos" , "" ) => "appletvos" , |
| 11 | ("tvos" , "sim" ) => "appletvsimulator" , |
| 12 | ("watchos" , "" ) => "watchos" , |
| 13 | ("watchos" , "sim" ) => "watchsimulator" , |
| 14 | ("visionos" , "" ) => "xros" , |
| 15 | ("visionos" , "sim" ) => "xrsimulator" , |
| 16 | (os, _) => panic!("invalid Apple target OS {}" , os), |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | pub(crate) fn apple_version_flag(&self, min_version: &str) -> String { |
| 21 | // There are many aliases for these, and `-mtargetos=` is preferred on Clang nowadays, but |
| 22 | // for compatibility with older Clang, we use the earliest supported name here. |
| 23 | // |
| 24 | // NOTE: GCC does not support `-miphoneos-version-min=` etc. (because it does not support |
| 25 | // iOS in general), but we specify them anyhow in case we actually have a Clang-like |
| 26 | // compiler disguised as a GNU-like compiler, or in case GCC adds support for these in the |
| 27 | // future. |
| 28 | // |
| 29 | // See also: |
| 30 | // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mmacos-version-min |
| 31 | // https://clang.llvm.org/docs/AttributeReference.html#availability |
| 32 | // https://gcc.gnu.org/onlinedocs/gcc/Darwin-Options.html#index-mmacosx-version-min |
| 33 | match (self.os, self.abi) { |
| 34 | ("macos" , "" ) => format!("-mmacosx-version-min= {min_version}" ), |
| 35 | ("ios" , "" ) => format!("-miphoneos-version-min= {min_version}" ), |
| 36 | ("ios" , "sim" ) => format!("-mios-simulator-version-min= {min_version}" ), |
| 37 | ("ios" , "macabi" ) => format!("-mtargetos=ios {min_version}-macabi" ), |
| 38 | ("tvos" , "" ) => format!("-mappletvos-version-min= {min_version}" ), |
| 39 | ("tvos" , "sim" ) => format!("-mappletvsimulator-version-min= {min_version}" ), |
| 40 | ("watchos" , "" ) => format!("-mwatchos-version-min= {min_version}" ), |
| 41 | ("watchos" , "sim" ) => format!("-mwatchsimulator-version-min= {min_version}" ), |
| 42 | // `-mxros-version-min` does not exist |
| 43 | // https://github.com/llvm/llvm-project/issues/88271 |
| 44 | ("visionos" , "" ) => format!("-mtargetos=xros {min_version}" ), |
| 45 | ("visionos" , "sim" ) => format!("-mtargetos=xros {min_version}-simulator" ), |
| 46 | (os, _) => panic!("invalid Apple target OS {}" , os), |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |