From 92dd2db73694ab13671db73194ab1e9fae1b9371 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 19 Jun 2020 00:48:33 +0800 Subject: improve the plat/arch of toolchain --- xmake/toolchains/xcode/check.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xmake/toolchains/xcode/check.lua') diff --git a/xmake/toolchains/xcode/check.lua b/xmake/toolchains/xcode/check.lua index 925db3870..d5f79ab27f 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 @@ -39,7 +39,7 @@ function main(toolchain) local target_minver = config.get("target_minver") 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() -- cgit v1.3.1 From f5392149886b2083ec0d6db2adef3da405297fe8 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 20 Jun 2020 00:38:29 +0800 Subject: improve xcode and msvc toolchains --- xmake/core/project/project.lua | 4 +- xmake/modules/detect/sdks/find_xcode.lua | 10 +- .../package/manager/conan/install_package.lua | 2 +- xmake/platforms/windows/xmake.lua | 2 +- xmake/rules/qt/deploy/macosx.lua | 2 +- xmake/rules/xcode/info_plist/xmake.lua | 2 +- xmake/rules/xcode/storyboard/xmake.lua | 15 ++- xmake/rules/xcode/xcassets/xmake.lua | 9 +- xmake/toolchains/msvc/check.lua | 113 +++++++++++++++++++++ xmake/toolchains/msvc/load.lua | 88 ++++++++++++++++ xmake/toolchains/msvc/xmake.lua | 35 +++++++ xmake/toolchains/vs/check.lua | 113 --------------------- xmake/toolchains/vs/load.lua | 90 ---------------- xmake/toolchains/vs/xmake.lua | 35 ------- xmake/toolchains/xcode/check.lua | 21 +++- xmake/toolchains/xcode/load_iphoneos.lua | 4 +- xmake/toolchains/xcode/load_macosx.lua | 4 +- xmake/toolchains/xcode/load_watchos.lua | 4 +- 18 files changed, 291 insertions(+), 262 deletions(-) create mode 100644 xmake/toolchains/msvc/check.lua create mode 100644 xmake/toolchains/msvc/load.lua create mode 100644 xmake/toolchains/msvc/xmake.lua delete mode 100644 xmake/toolchains/vs/check.lua delete mode 100644 xmake/toolchains/vs/load.lua delete mode 100644 xmake/toolchains/vs/xmake.lua (limited to 'xmake/toolchains/xcode/check.lua') diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index 795f863b5..be0694235 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -433,9 +433,7 @@ function project._load_targets() if toolchains then t._TOOLCHAINS = {} for _, name in ipairs(table.wrap(toolchains)) do - local toolchain_plat = t:extraconf("toolchains", name, "plat") - local toolchain_arch = t:extraconf("toolchains", name, "arch") - local toolchain_inst, errors = toolchain.load(name, {plat = toolchain_plat, arch = toolchain_arch}) + local toolchain_inst, errors = toolchain.load(name, t:extraconf("toolchains", name)) -- attempt to load toolchain from project if not toolchain_inst then toolchain_inst = project.toolchain(name) diff --git a/xmake/modules/detect/sdks/find_xcode.lua b/xmake/modules/detect/sdks/find_xcode.lua index 3b33ab955..a1ab709df 100644 --- a/xmake/modules/detect/sdks/find_xcode.lua +++ b/xmake/modules/detect/sdks/find_xcode.lua @@ -147,13 +147,19 @@ function main(sdkdir, opt) local plat = opt.plat or config.get("plat") or "macosx" local arch = opt.arch or config.get("arch") or "x86_64" + -- get xcode sdk version + local xcode_sdkver = (plat == config.plat()) and config.get("xcode_sdkver") + if not xcode_sdkver then + xcode_sdkver = config.get("xcode_sdkver_" .. plat) + end + -- find xcode - local xcode = _find_xcode(sdkdir or config.get("xcode") or global.get("xcode"), opt.sdkver or config.get("xcode_sdkver"), plat, arch) + local xcode = _find_xcode(sdkdir or config.get("xcode") or global.get("xcode"), opt.sdkver or xcode_sdkver, plat, arch) if xcode and xcode.sdkdir then -- save to config config.set("xcode", xcode.sdkdir, {force = true, readonly = true}) - config.set("xcode_sdkver", xcode.sdkver, {force = true, readonly = true}) + config.set("xcode_sdkver_" .. plat, xcode.sdkver, {force = true, readonly = true}) config.set("xcode_codesign_identity", xcode.codesign_identity, {force = true, readonly = true}) config.set("xcode_mobile_provision", xcode.mobile_provision, {force = true, readonly = true}) diff --git a/xmake/modules/package/manager/conan/install_package.lua b/xmake/modules/package/manager/conan/install_package.lua index 201c50841..e1ad06df4 100644 --- a/xmake/modules/package/manager/conan/install_package.lua +++ b/xmake/modules/package/manager/conan/install_package.lua @@ -219,7 +219,7 @@ function main(name, opt) table.insert(argv, "compiler.runtime=" .. opt.vs_runtime) end elseif opt.plat == "iphoneos" then - 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 == "x86") then target_minver = "10" -- iOS 10 is the maximum deployment target for 32-bit targets end diff --git a/xmake/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua index 5c29b0e0b..9dd8fecbd 100644 --- a/xmake/platforms/windows/xmake.lua +++ b/xmake/platforms/windows/xmake.lua @@ -48,7 +48,7 @@ platform("windows") end) -- set toolchains - set_toolchains("vs", "clang", "yasm", "nasm", "cuda", "dlang", "rust", "go") + set_toolchains("msvc", "clang", "yasm", "nasm", "cuda", "dlang", "rust", "go") -- set menu set_menu { diff --git a/xmake/rules/qt/deploy/macosx.lua b/xmake/rules/qt/deploy/macosx.lua index bbefe38ee..6b3549ec2 100644 --- a/xmake/rules/qt/deploy/macosx.lua +++ b/xmake/rules/qt/deploy/macosx.lua @@ -59,7 +59,7 @@ function _save_info_plist(target, info_plist_file) NSPrincipalClass NSApplication -]], name, name, name, name, get_config("target_minver") or (macos.version():major() .. "." .. macos.version():minor()))) +]], name, name, name, name, get_config("target_minver_macosx") or (macos.version():major() .. "." .. macos.version():minor()))) end -- deploy application package for macosx diff --git a/xmake/rules/xcode/info_plist/xmake.lua b/xmake/rules/xcode/info_plist/xmake.lua index 611969e0c..6f1899f8e 100644 --- a/xmake/rules/xcode/info_plist/xmake.lua +++ b/xmake/rules/xcode/info_plist/xmake.lua @@ -60,7 +60,7 @@ rule("xcode.info_plist") PRODUCT_NAME = target:name(), PRODUCT_DISPLAY_NAME = target:name(), CURRENT_PROJECT_VERSION = target:version() and tostring(target:version()) or "1.0", - MACOSX_DEPLOYMENT_TARGET = get_config("target_minver") + MACOSX_DEPLOYMENT_TARGET = get_config("target_minver_macosx") } if target:rule("xcode.bundle") then maps.PRODUCT_BUNDLE_PACKAGE_TYPE = "BNDL" diff --git a/xmake/rules/xcode/storyboard/xmake.lua b/xmake/rules/xcode/storyboard/xmake.lua index bc9444d38..264525b61 100644 --- a/xmake/rules/xcode/storyboard/xmake.lua +++ b/xmake/rules/xcode/storyboard/xmake.lua @@ -57,11 +57,14 @@ rule("xcode.storyboard") os.tryrm(base_lproj) -- do compile + local target_minver local argv = {"--errors", "--warnings", "--notices", "--auto-activate-custom-fonts", "--output-format", "human-readable-text"} if is_plat("macosx") then + target_minver = get_config("target_minver_macosx") table.insert(argv, "--target-device") table.insert(argv, "mac") elseif is_plat("iphoneos") then + target_minver = get_config("target_minver_iphoneos") table.insert(argv, "--target-device") table.insert(argv, "iphone") table.insert(argv, "--target-device") @@ -69,8 +72,10 @@ rule("xcode.storyboard") else assert("unknown device!") end - table.insert(argv, "--minimum-deployment-target") - table.insert(argv, get_config("target_minver")) + if target_minver then + table.insert(argv, "--minimum-deployment-target") + table.insert(argv, target_minver) + end table.insert(argv, "--compilation-directory") table.insert(argv, base_lproj) table.insert(argv, sourcefile) @@ -82,8 +87,10 @@ rule("xcode.storyboard") table.insert(argv, "--target-device") table.insert(argv, "mac") end - table.insert(argv, "--minimum-deployment-target") - table.insert(argv, get_config("target_minver")) + if target_minver then + table.insert(argv, "--minimum-deployment-target") + table.insert(argv, target_minver) + end table.insert(argv, "--link") table.insert(argv, resourcesdir) table.insert(argv, path.join(base_lproj, path.filename(sourcefile) .. "c")) diff --git a/xmake/rules/xcode/xcassets/xmake.lua b/xmake/rules/xcode/xcassets/xmake.lua index df25794e5..6803a2999 100644 --- a/xmake/rules/xcode/xcassets/xmake.lua +++ b/xmake/rules/xcode/xcassets/xmake.lua @@ -60,13 +60,16 @@ rule("xcode.xcassets") io.writefile(assetcatalog_generated_info_plist, "") -- do compile + local target_minver local argv = {"--warnings", "--notices", "--output-format", "human-readable-text"} if is_plat("macosx") then + target_minver = get_config("target_minver_macosx") table.insert(argv, "--target-device") table.insert(argv, "mac") table.insert(argv, "--platform") table.insert(argv, "macosx") elseif is_plat("iphoneos") then + target_minver = get_config("target_minver_iphoneos") table.insert(argv, "--target-device") table.insert(argv, "iphone") table.insert(argv, "--target-device") @@ -76,8 +79,10 @@ rule("xcode.xcassets") else assert("unknown device!") end - table.insert(argv, "--minimum-deployment-target") - table.insert(argv, get_config("target_minver")) + if target_minver then + table.insert(argv, "--minimum-deployment-target") + table.insert(argv, target_minver) + end table.insert(argv, "--app-icon") table.insert(argv, "AppIcon") if is_plat("iphoneos") then diff --git a/xmake/toolchains/msvc/check.lua b/xmake/toolchains/msvc/check.lua new file mode 100644 index 000000000..bf42ca64f --- /dev/null +++ b/xmake/toolchains/msvc/check.lua @@ -0,0 +1,113 @@ +--!A cross-toolchain build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file check.lua +-- + +-- imports +import("core.base.option") +import("core.project.config") +import("detect.sdks.find_vstudio") +import("lib.detect.find_tool") + +-- attempt to check vs environment +function _check_vsenv(toolchain) + + -- have been checked? + local vs = config.get("vs") + if vs and config.get("__vcvarsall") then + return vs + end + + -- find vstudio + local vstudio = find_vstudio({vcvars_ver = config.get("vs_toolset"), sdkver = config.get("vs_sdkver")}) + if vstudio then + + -- make order vsver + local vsvers = {} + for vsver, _ in pairs(vstudio) do + if not vs or vs ~= vsver then + table.insert(vsvers, vsver) + end + end + table.sort(vsvers, function (a, b) return tonumber(a) > tonumber(b) end) + if vs then + table.insert(vsvers, 1, vs) + end + + -- get vcvarsall + for _, vsver in ipairs(vsvers) do + local vcvarsall = (vstudio[vsver] or {}).vcvarsall or {} + local vsenv = vcvarsall[toolchain:arch()] + if vsenv and vsenv.path and vsenv.include and vsenv.lib then + + -- save vsenv + config.set("__vcvarsall", vcvarsall) + + -- check compiler + local oldenvs = {} + oldenvs.PATH = os.getenv("PATH") + oldenvs.LIB = os.getenv("LIB") + os.setenv("PATH", vsenv.path .. ';' .. (oldenvs.PATH or "")) + os.setenv("LIB", vsenv.lib .. ';' .. (oldenvs.LIB or "")) + local program = nil + local tool = find_tool("cl.exe", {force = true}) + if tool then + program = tool.program + end + for name, values in pairs(oldenvs) do + os.setenv(name, values) + end + + -- ok? + if program then + return vsver + end + end + end + end +end + +-- check the visual studio +function _check_vstudio(toolchain) + local vs = _check_vsenv(toolchain) + if vs then + config.set("vs", vs, {readonly = true, force = true}) + cprint("checking for the Microsoft Visual Studio (%s) version ... ${color.success}%s", toolchain:arch(), vs) + else + cprint("checking for the Microsoft Visual Studio (%s) version ... ${color.nothing}${text.nothing}", toolchain:arch()) + if not (opt and opt.try) then + print("please run:") + print(" - xmake config --vs=xxx [--vs_toolset=xxx]") + print("or - xmake global --vs=xxx") + raise() + end + end + return vs +end + +-- main entry +function main(toolchain) + -- @see https://github.com/xmake-io/xmake/pull/679 + local cc = path.basename(config.get("cc") or "cl"):lower() + local cxx = path.basename(config.get("cxx") or "cl"):lower() + local mrc = path.basename(config.get("mrc") or "rc"):lower() + if cc == "cl" or cxx == "cl" or mrc == "rc" then + return _check_vstudio(toolchain) + end +end + diff --git a/xmake/toolchains/msvc/load.lua b/xmake/toolchains/msvc/load.lua new file mode 100644 index 000000000..c6d53f86a --- /dev/null +++ b/xmake/toolchains/msvc/load.lua @@ -0,0 +1,88 @@ +--!A cross-toolchain build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file load.lua +-- + +-- imports +import("core.base.option") +import("core.project.config") +import("detect.sdks.find_vstudio") + +-- add the given vs environment +function _add_vsenv(toolchain, name) + + -- get vcvarsall + local vcvarsall = config.get("__vcvarsall") + if not vcvarsall then + return + end + + -- get vs environment for the current arch + local arch = toolchain:arch() + local vsenv = vcvarsall[arch] or {} + + -- switch vstudio environment if vs_sdkver has been changed + local switch_vsenv = false + local vs = config.get("vs") + local vs_sdkver = config.get("vs_sdkver") + if vs and vs_sdkver and vsenv.WindowsSDKVersion and vs_sdkver ~= vsenv.WindowsSDKVersion then + switch_vsenv = true + end + if switch_vsenv then + -- find vstudio + local vstudio = find_vstudio({vcvars_ver = config.get("vs_toolset"), sdkver = vs_sdkver}) + if vstudio then + vcvarsall = (vstudio[vs] or {}).vcvarsall or {} + vsenv = vcvarsall[arch] or {} + if vsenv and vsenv.path and vsenv.include and vsenv.lib then + config.set("__vcvarsall", vcvarsall) + end + end + end + + -- get the pathes for the vs environment + local new = vsenv[name] + if new then + toolchain:add("runenvs", name:upper(), path.splitenv(new)) + end +end + +-- main entry +function main(toolchain) + + -- set toolset + toolchain:set("toolset", "cc", "cl.exe") + toolchain:set("toolset", "cxx", "cl.exe") + toolchain:set("toolset", "mrc", "rc.exe") + if toolchain:is_arch("x64") then + toolchain:set("toolset", "as", "ml64.exe") + else + toolchain:set("toolset", "as", "ml.exe") + end + toolchain:set("toolset", "ld", "link.exe") + toolchain:set("toolset", "sh", "link.exe -dll") + toolchain:set("toolset", "ar", "link.exe -lib") + toolchain:set("toolset", "ex", "lib.exe") + + -- add vs environments + _add_vsenv(toolchain, "path") + _add_vsenv(toolchain, "lib") + _add_vsenv(toolchain, "include") + _add_vsenv(toolchain, "libpath") +end + diff --git a/xmake/toolchains/msvc/xmake.lua b/xmake/toolchains/msvc/xmake.lua new file mode 100644 index 000000000..bbef5815d --- /dev/null +++ b/xmake/toolchains/msvc/xmake.lua @@ -0,0 +1,35 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +-- define toolchain +toolchain("msvc") + + -- set homepage + set_homepage("https://visualstudio.microsoft.com") + set_description("VisualStudio IDE") + + -- mark as standalone toolchain + set_kind("standalone") + + -- check toolchain + on_check("check") + + -- load toolchain + on_load("load") diff --git a/xmake/toolchains/vs/check.lua b/xmake/toolchains/vs/check.lua deleted file mode 100644 index 12fac2aa0..000000000 --- a/xmake/toolchains/vs/check.lua +++ /dev/null @@ -1,113 +0,0 @@ ---!A cross-toolchain build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-2020, TBOOX Open Source Group. --- --- @author ruki --- @file check.lua --- - --- imports -import("core.base.option") -import("core.project.config") -import("detect.sdks.find_vstudio") -import("lib.detect.find_tool") - --- attempt to check vs environment -function _check_vsenv() - - -- have been checked? - local vs = config.get("vs") - if vs and config.get("__vcvarsall") then - return vs - end - - -- find vstudio - local vstudio = find_vstudio({vcvars_ver = config.get("vs_toolset"), sdkver = config.get("vs_sdkver")}) - if vstudio then - - -- make order vsver - local vsvers = {} - for vsver, _ in pairs(vstudio) do - if not vs or vs ~= vsver then - table.insert(vsvers, vsver) - end - end - table.sort(vsvers, function (a, b) return tonumber(a) > tonumber(b) end) - if vs then - table.insert(vsvers, 1, vs) - end - - -- get vcvarsall - for _, vsver in ipairs(vsvers) do - local vcvarsall = (vstudio[vsver] or {}).vcvarsall or {} - local vsenv = vcvarsall[config.get("arch") or ""] - if vsenv and vsenv.path and vsenv.include and vsenv.lib then - - -- save vsenv - config.set("__vcvarsall", vcvarsall) - - -- check compiler - local oldenvs = {} - oldenvs.PATH = os.getenv("PATH") - oldenvs.LIB = os.getenv("LIB") - os.setenv("PATH", vsenv.path .. ';' .. (oldenvs.PATH or "")) - os.setenv("LIB", vsenv.lib .. ';' .. (oldenvs.LIB or "")) - local program = nil - local tool = find_tool("cl.exe", {force = true}) - if tool then - program = tool.program - end - for name, values in pairs(oldenvs) do - os.setenv(name, values) - end - - -- ok? - if program then - return vsver - end - end - end - end -end - --- check the visual studio -function _check_vstudio() - local vs = _check_vsenv() - if vs then - config.set("vs", vs, {readonly = true, force = true}) - cprint("checking for the Microsoft Visual Studio (%s) version ... ${color.success}%s", config.get("arch"), vs) - else - cprint("checking for the Microsoft Visual Studio (%s) version ... ${color.nothing}${text.nothing}", config.get("arch")) - if not (opt and opt.try) then - print("please run:") - print(" - xmake config --vs=xxx [--vs_toolset=xxx]") - print("or - xmake global --vs=xxx") - raise() - end - end - return vs -end - --- main entry -function main() - -- @see https://github.com/xmake-io/xmake/pull/679 - local cc = path.basename(config.get("cc") or "cl"):lower() - local cxx = path.basename(config.get("cxx") or "cl"):lower() - local mrc = path.basename(config.get("mrc") or "rc"):lower() - if cc == "cl" or cxx == "cl" or mrc == "rc" then - return _check_vstudio(config) - end -end - diff --git a/xmake/toolchains/vs/load.lua b/xmake/toolchains/vs/load.lua deleted file mode 100644 index af32ca092..000000000 --- a/xmake/toolchains/vs/load.lua +++ /dev/null @@ -1,90 +0,0 @@ ---!A cross-toolchain build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-2020, TBOOX Open Source Group. --- --- @author ruki --- @file load.lua --- - --- imports -import("core.base.option") -import("core.project.config") -import("detect.sdks.find_vstudio") - --- add the given vs environment -function _add_vsenv(toolchain, name) - - -- get vcvarsall - local vcvarsall = config.get("__vcvarsall") - if not vcvarsall then - return - end - - -- get arch - local arch = config.get("arch") or "" - - -- get vs environment for the current arch - local vsenv = vcvarsall[arch] or {} - - -- switch vstudio environment if vs_sdkver has been changed - local switch_vsenv = false - local vs = config.get("vs") - local vs_sdkver = config.get("vs_sdkver") - if vs and vs_sdkver and vsenv.WindowsSDKVersion and vs_sdkver ~= vsenv.WindowsSDKVersion then - switch_vsenv = true - end - if switch_vsenv then - -- find vstudio - local vstudio = find_vstudio({vcvars_ver = config.get("vs_toolset"), sdkver = vs_sdkver}) - if vstudio then - vcvarsall = (vstudio[vs] or {}).vcvarsall or {} - vsenv = vcvarsall[arch] or {} - if vsenv and vsenv.path and vsenv.include and vsenv.lib then - config.set("__vcvarsall", vcvarsall) - end - end - end - - -- get the pathes for the vs environment - local new = vsenv[name] - if new then - toolchain:add("runenvs", name:upper(), path.splitenv(new)) - end -end - --- main entry -function main(toolchain) - - -- set toolset - toolchain:set("toolset", "cc", "cl.exe") - toolchain:set("toolset", "cxx", "cl.exe") - toolchain:set("toolset", "mrc", "rc.exe") - if is_arch("x64") then - toolchain:set("toolset", "as", "ml64.exe") - else - toolchain:set("toolset", "as", "ml.exe") - end - toolchain:set("toolset", "ld", "link.exe") - toolchain:set("toolset", "sh", "link.exe -dll") - toolchain:set("toolset", "ar", "link.exe -lib") - toolchain:set("toolset", "ex", "lib.exe") - - -- add vs environments - _add_vsenv(toolchain, "path") - _add_vsenv(toolchain, "lib") - _add_vsenv(toolchain, "include") - _add_vsenv(toolchain, "libpath") -end - diff --git a/xmake/toolchains/vs/xmake.lua b/xmake/toolchains/vs/xmake.lua deleted file mode 100644 index 4bbc5798c..000000000 --- a/xmake/toolchains/vs/xmake.lua +++ /dev/null @@ -1,35 +0,0 @@ ---!A cross-platform build utility based on Lua --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- --- Copyright (C) 2015-2020, TBOOX Open Source Group. --- --- @author ruki --- @file xmake.lua --- - --- define toolchain -toolchain("vs") - - -- set homepage - set_homepage("https://visualstudio.microsoft.com") - set_description("VisualStudio IDE") - - -- mark as standalone toolchain - set_kind("standalone") - - -- check toolchain - on_check("check") - - -- load toolchain - on_load("load") diff --git a/xmake/toolchains/xcode/check.lua b/xmake/toolchains/xcode/check.lua index d5f79ab27f..e49957b17 100644 --- a/xmake/toolchains/xcode/check.lua +++ b/xmake/toolchains/xcode/check.lua @@ -35,8 +35,23 @@ 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 toolchain:is_plat("macosx") then @@ -45,7 +60,7 @@ function main(toolchain) 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 842064cb7..1d495a5cb 100644 --- a/xmake/toolchains/xcode/load_iphoneos.lua +++ b/xmake/toolchains/xcode/load_iphoneos.lua @@ -32,7 +32,7 @@ function main(toolchain) 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 f2060ad68..c16fd6665 100644 --- a/xmake/toolchains/xcode/load_macosx.lua +++ b/xmake/toolchains/xcode/load_macosx.lua @@ -26,11 +26,11 @@ function main(toolchain) -- init flags for architecture local arch = toolchain:arch() - local target_minver = config.get("target_minver") + 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 6730784b1..cae0b40d4 100644 --- a/xmake/toolchains/xcode/load_watchos.lua +++ b/xmake/toolchains/xcode/load_watchos.lua @@ -32,12 +32,12 @@ function main(toolchain) 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++ -- cgit v1.3.1