diff options
| author | ruki <[email protected]> | 2020-06-23 22:37:44 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-06-23 22:37:44 +0800 |
| commit | c18d15eb89116a0f3ce96bd56f3ccf861849f6ec (patch) | |
| tree | 52b63db3274349f9a41872414208c7c30058cfd7 /xmake/toolchains/xcode | |
| parent | 53df324acd9c7432336a5894ceef578daa1ce38d (diff) | |
| parent | 18bded45c229f5580c13fc8b4afc5edb6f18819a (diff) | |
Merge pull request #857 from xmake-io/toolchain
Improve toolchain to support host and cross toolchains at same time
Diffstat (limited to 'xmake/toolchains/xcode')
| -rw-r--r-- | xmake/toolchains/xcode/check.lua | 25 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/load_iphoneos.lua | 6 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/load_macosx.lua | 6 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/load_watchos.lua | 6 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/xmake.lua | 14 |
5 files changed, 36 insertions, 21 deletions
diff --git a/xmake/toolchains/xcode/check.lua b/xmake/toolchains/xcode/check.lua index 925db3870..e49957b17 100644 --- a/xmake/toolchains/xcode/check.lua +++ b/xmake/toolchains/xcode/check.lua @@ -27,7 +27,7 @@ import("detect.sdks.find_xcode") function main(toolchain) -- find xcode - local xcode = find_xcode(config.get("xcode"), {force = not optional, verbose = true, plat = config.get("plat"), arch = config.get("arch")}) + local xcode = find_xcode(config.get("xcode"), {force = not optional, verbose = true, plat = toolchain:plat(), arch = toolchain:arch()}) if xcode then config.set("xcode", xcode.sdkdir, {force = true, readonly = true}) else @@ -35,17 +35,32 @@ function main(toolchain) end -- save target minver - local xcode_sdkver = config.get("xcode_sdkver") - local target_minver = config.get("target_minver") + -- + -- @note we need to differentiate the version for the system, + -- because the xcode toolchain of iphoneos/macosx may need to be used at the same time. + -- + -- e.g. + -- + -- target("test") + -- set_toolchains("xcode", {plat = os.host(), arch = os.arch()}) + -- + local xcode_sdkver = toolchain:is_plat(config.plat()) and config.get("xcode_sdkver") + if not xcode_sdkver then + xcode_sdkver = config.get("xcode_sdkver_" .. toolchain:plat()) + end + local target_minver = toolchain:is_plat(config.plat()) and config.get("target_minver") + if not target_minver then + target_minver = config.get("target_minver_" .. toolchain:plat()) + end if xcode_sdkver and not target_minver then target_minver = xcode_sdkver - if is_plat("macosx") then + if toolchain:is_plat("macosx") then local macos_ver = macos.version() if macos_ver then target_minver = macos_ver:major() .. "." .. macos_ver:minor() end end - config.set("target_minver", target_minver) + config.set("target_minver_" .. toolchain:plat(), target_minver) end return true end diff --git a/xmake/toolchains/xcode/load_iphoneos.lua b/xmake/toolchains/xcode/load_iphoneos.lua index 3aeb78672..1d495a5cb 100644 --- a/xmake/toolchains/xcode/load_iphoneos.lua +++ b/xmake/toolchains/xcode/load_iphoneos.lua @@ -25,14 +25,14 @@ import("core.project.config") function main(toolchain) -- init architecture - local arch = config.get("arch") or "arm64" + local arch = toolchain:arch() local simulator = (arch == "i386" or arch == "x86_64") -- init platform name local platname = simulator and "iPhoneSimulator" or "iPhoneOS" -- init target minimal version - local target_minver = config.get("target_minver") + local target_minver = config.get("target_minver_iphoneos") if target_minver and tonumber(target_minver) > 10 and (arch == "armv7" or arch == "armv7s" or arch == "i386") then target_minver = "10" -- iOS 10 is the maximum deployment target for 32-bit targets end @@ -40,7 +40,7 @@ function main(toolchain) -- init the xcode sdk directory local xcode_dir = config.get("xcode") - local xcode_sdkver = config.get("xcode_sdkver") + local xcode_sdkver = config.get("xcode_sdkver_iphoneos") local xcode_sdkdir = format("%s/Contents/Developer/Platforms/%s.platform/Developer/SDKs/%s%s.sdk", xcode_dir, platname, platname, xcode_sdkver) -- init flags for c/c++ diff --git a/xmake/toolchains/xcode/load_macosx.lua b/xmake/toolchains/xcode/load_macosx.lua index de7dddb1e..c16fd6665 100644 --- a/xmake/toolchains/xcode/load_macosx.lua +++ b/xmake/toolchains/xcode/load_macosx.lua @@ -25,12 +25,12 @@ import("core.project.config") function main(toolchain) -- init flags for architecture - local arch = config.get("arch") or os.arch() - local target_minver = config.get("target_minver") + local arch = toolchain:arch() + local target_minver = config.get("target_minver_macosx") -- init flags for the xcode sdk directory local xcode_dir = config.get("xcode") - local xcode_sdkver = config.get("xcode_sdkver") + local xcode_sdkver = config.get("xcode_sdkver_macosx") local xcode_sdkdir = nil if xcode_dir and xcode_sdkver then xcode_sdkdir = xcode_dir .. "/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX" .. xcode_sdkver .. ".sdk" diff --git a/xmake/toolchains/xcode/load_watchos.lua b/xmake/toolchains/xcode/load_watchos.lua index 5048f4bb7..cae0b40d4 100644 --- a/xmake/toolchains/xcode/load_watchos.lua +++ b/xmake/toolchains/xcode/load_watchos.lua @@ -25,19 +25,19 @@ import("core.project.config") function main(toolchain) -- init architecture - local arch = config.get("arch") + local arch = toolchain:arch() local simulator = arch == "i386" -- init platform name local platname = simulator and "WatchSimulator" or "WatchOS" -- init target minimal version - local target_minver = config.get("target_minver") + local target_minver = config.get("target_minver_watchos") local target_minver_flags = (simulator and "-mwatchos-simulator-version-min=" or "-mwatchos-version-min=") .. target_minver -- init the xcode sdk directory local xcode_dir = config.get("xcode") - local xcode_sdkver = config.get("xcode_sdkver") + local xcode_sdkver = config.get("xcode_sdkver_watchos") local xcode_sdkdir = format("%s/Contents/Developer/Platforms/%s.platform/Developer/SDKs/%s%s.sdk", xcode_dir, platname, platname, xcode_sdkver) -- init flags for c/c++ diff --git a/xmake/toolchains/xcode/xmake.lua b/xmake/toolchains/xcode/xmake.lua index 776c142af..7394c8a13 100644 --- a/xmake/toolchains/xcode/xmake.lua +++ b/xmake/toolchains/xcode/xmake.lua @@ -36,14 +36,14 @@ toolchain("xcode") -- get cross local cross, arch, simulator - if is_plat("macosx") then + if toolchain:is_plat("macosx") then cross = "xcrun -sdk macosx " - elseif is_plat("iphoneos") then - arch = get_config("arch") or os.arch() + elseif toolchain:is_plat("iphoneos") then + arch = toolchain:arch() simulator = (arch == "i386" or arch == "x86_64") cross = simulator and "xcrun -sdk iphonesimulator " or "xcrun -sdk iphoneos " - elseif is_plat("watchos") then - arch = get_config("arch") or os.arch() + elseif toolchain:is_plat("watchos") then + arch = toolchain:arch() simulator = (arch == "i386") cross = simulator and "xcrun -sdk watchsimulator " or "xcrun -sdk watchos " else @@ -67,7 +67,7 @@ toolchain("xcode") if arch then toolchain:set("toolset", "cpp", cross .. "clang -arch " .. arch .. " -E") end - if is_plat("macosx") then + if toolchain:is_plat("macosx") then toolchain:set("toolset", "as", cross .. "clang") elseif simulator then toolchain:set("toolset", "as", cross .. "clang") @@ -76,5 +76,5 @@ toolchain("xcode") end -- load configurations - import("load_" .. get_config("plat"))(toolchain) + import("load_" .. toolchain:plat())(toolchain) end) |
