summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2020-05-24 21:10:49 +0800
committerGitHub <[email protected]>2020-05-24 21:10:49 +0800
commitfb2ba113ca1534249b0872002af0f133becd7e51 (patch)
treed5bc9fb1553f622842712b18a7959a0c08a92d63 /xmake/modules
parentdd09a2264181f82a0b6aefb38dce5c92fb3af8fe (diff)
parent5ad2eaee8cd65987359dbdfc5149bdd61b9260fc (diff)
Merge pull request #792 from xmake-io/toolchain
Improve to detect cross-compilation toolchains
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/core/tools/dmd.lua27
-rw-r--r--xmake/modules/core/tools/go.lua2
-rw-r--r--xmake/modules/core/tools/ld.lua99
-rw-r--r--xmake/modules/core/tools/ldc2.lua2
-rw-r--r--xmake/modules/core/tools/llvm_ar.lua3
-rw-r--r--xmake/modules/core/tools/nasm.lua139
-rw-r--r--xmake/modules/core/tools/rustc.lua6
-rw-r--r--xmake/modules/detect/sdks/find_mingw.lua6
-rw-r--r--xmake/modules/detect/sdks/find_ndk.lua10
-rw-r--r--xmake/modules/detect/tools/find_fasm.lua1
-rw-r--r--xmake/modules/detect/tools/find_ld.lua (renamed from xmake/modules/private/platform/check_arch.lua)36
-rw-r--r--xmake/modules/detect/tools/find_nasm.lua (renamed from xmake/modules/private/platform/toolchain.lua)43
-rw-r--r--xmake/modules/package/manager/conan/install_package.lua2
-rw-r--r--xmake/modules/private/action/trybuild/autotools.lua2
-rw-r--r--xmake/modules/private/platform/check_toolchain.lua83
-rw-r--r--xmake/modules/private/platform/check_vstudio.lua103
-rw-r--r--xmake/modules/private/platform/check_xcode.lua58
17 files changed, 325 insertions, 297 deletions
diff --git a/xmake/modules/core/tools/dmd.lua b/xmake/modules/core/tools/dmd.lua
index eaadb249c..378c68642 100644
--- a/xmake/modules/core/tools/dmd.lua
+++ b/xmake/modules/core/tools/dmd.lua
@@ -27,10 +27,10 @@ import("core.project.project")
function init(self)
-- init arflags
- self:set("dc-arflags", "-lib")
+ self:set("dcarflags", "-lib")
-- init shflags
- self:set("dc-shflags", "-shared", "-fPIC")
+ self:set("dcshflags", "-shared", "-fPIC")
-- init dcflags for the kind: shared
self:set("shared.dcflags", "-fPIC")
@@ -134,15 +134,30 @@ end
-- make the rpathdir flag
function nf_rpathdir(self, dir)
- local flag = "-L-rpath=" .. os.args(dir)
- if self:has_flags(flag) then
- return flag
+ dir = path.translate(dir)
+ if self:has_flags("-L-rpath=" .. dir, "ldflags") then
+ return "-L-rpath=" .. os.args(dir:gsub("@[%w_]+", function (name)
+ local maps = {["@loader_path"] = "$ORIGIN", ["@executable_path"] = "$ORIGIN"}
+ return maps[name]
+ end))
+
+ elseif self:has_flags("-L-rpath -L" .. dir, "ldflags") then
+ return "-L-rpath -L" .. os.args(dir:gsub("%$ORIGIN", "@loader_path"))
end
end
-- make the link arguments list
function linkargv(self, objectfiles, targetkind, targetfile, flags)
- return self:program(), table.join(flags, "-of" .. targetfile, objectfiles)
+
+ -- add rpath for dylib (macho), e.g. -install_name @rpath/file.dylib
+ local flags_extra = {}
+ if targetkind == "shared" and is_plat("macosx") then
+ table.insert(flags_extra, "-L-install_name")
+ table.insert(flags_extra, "-L@rpath/" .. path.filename(targetfile))
+ end
+
+ -- init arguments
+ return self:program(), table.join(flags, flags_extra, "-of" .. targetfile, objectfiles)
end
-- link the target file
diff --git a/xmake/modules/core/tools/go.lua b/xmake/modules/core/tools/go.lua
index 944a14eff..80230ba4f 100644
--- a/xmake/modules/core/tools/go.lua
+++ b/xmake/modules/core/tools/go.lua
@@ -27,7 +27,7 @@ import("core.project.project")
function init(self)
-- init arflags
- self:set("gc-arflags", "grc")
+ self:set("gcarflags", "grc")
-- init the file formats
self:set("formats", { static = "$(name).a" })
diff --git a/xmake/modules/core/tools/ld.lua b/xmake/modules/core/tools/ld.lua
new file mode 100644
index 000000000..6894d21b8
--- /dev/null
+++ b/xmake/modules/core/tools/ld.lua
@@ -0,0 +1,99 @@
+--!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 ld.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.project.config")
+import("core.project.project")
+import("core.language.language")
+
+-- init it
+function init(self)
+
+ -- init shflags
+ self:set("shflags", "-shared")
+
+ -- add -fPIC for shared
+ if not is_plat("windows", "mingw") then
+ self:add("shflags", "-fPIC")
+ self:add("shared.cxflags", "-fPIC")
+ end
+end
+
+-- make the strip flag
+function nf_strip(self, level)
+ local maps =
+ {
+ debug = "-S"
+ , all = "-s"
+ }
+
+ local plat = config.plat()
+ if plat == "macosx" or plat == "iphoneos" then
+ maps.all = "-Wl,-x"
+ maps.debug = "-Wl,-S"
+ end
+ return maps[level]
+end
+
+-- make the link flag
+function nf_link(self, lib)
+ return "-l" .. lib
+end
+
+-- make the syslink flag
+function nf_syslink(self, lib)
+ return nf_link(self, lib)
+end
+
+-- make the linkdir flag
+function nf_linkdir(self, dir)
+ return "-L" .. os.args(path.translate(dir))
+end
+
+-- make the link arguments list
+function linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
+
+ -- init arguments
+ local argv = table.join("-o", targetfile, objectfiles, flags)
+
+ -- too long arguments for windows?
+ if is_host("windows") then
+ opt = opt or {}
+ local args = os.args(argv, {escape = true})
+ if #args > 1024 and not opt.rawargs then
+ local argsfile = os.tmpfile(args) .. ".args.txt"
+ io.writefile(argsfile, args)
+ argv = {"@" .. argsfile}
+ end
+ end
+ return self:program(), argv
+end
+
+-- link the target file
+function link(self, objectfiles, targetkind, targetfile, flags)
+
+ -- ensure the target directory
+ os.mkdir(path.directory(targetfile))
+
+ -- link it
+ os.runv(linkargv(self, objectfiles, targetkind, targetfile, flags))
+end
+
diff --git a/xmake/modules/core/tools/ldc2.lua b/xmake/modules/core/tools/ldc2.lua
index ef4796156..9cf9fd48b 100644
--- a/xmake/modules/core/tools/ldc2.lua
+++ b/xmake/modules/core/tools/ldc2.lua
@@ -28,7 +28,7 @@ function init(self)
_super.init(self)
-- init shflags
- self:set("dc-shflags", "-shared")
+ self:set("dcshflags", "-shared")
-- init cxflags for the kind: shared
self:set("shared.dcflags", "")
diff --git a/xmake/modules/core/tools/llvm_ar.lua b/xmake/modules/core/tools/llvm_ar.lua
index b9674ffaf..0d890bd5c 100644
--- a/xmake/modules/core/tools/llvm_ar.lua
+++ b/xmake/modules/core/tools/llvm_ar.lua
@@ -24,9 +24,6 @@ import("core.tool.compiler")
-- init it
function init(self)
self:set("arflags", "cr")
- if is_plat("cross") and is_subhost("windows") then
- self:set("formats", { static = "$(name).lib" })
- end
end
-- make the strip flag
diff --git a/xmake/modules/core/tools/nasm.lua b/xmake/modules/core/tools/nasm.lua
new file mode 100644
index 000000000..a02091f07
--- /dev/null
+++ b/xmake/modules/core/tools/nasm.lua
@@ -0,0 +1,139 @@
+--!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 nasm.lua
+--
+
+-- imports
+import("core.base.option")
+
+-- init it
+function init(self)
+
+ -- init flags map
+ self:set("mapflags",
+ {
+ -- symbols
+ ["-g"] = ""
+ , ["-fvisibility=.*"] = ""
+
+ -- warnings
+ , ["-Wall"] = "" -- = "-Wall" will enable too more warnings
+ , ["-W1"] = ""
+ , ["-W2"] = ""
+ , ["-W3"] = ""
+ , ["-Werror"] = ""
+ , ["%-Wno%-error=.*"] = ""
+
+ -- others
+ , ["-ftrapv"] = ""
+ , ["-fsanitize=address"] = ""
+ })
+end
+
+-- make the warning flag
+function nf_warning(self, level)
+
+ -- the maps
+ local maps =
+ {
+ none = "-w"
+ }
+
+ -- make it
+ return maps[level]
+end
+
+-- make the define flag
+function nf_define(self, macro)
+ return "-D" .. macro
+end
+
+-- make the undefine flag
+function nf_undefine(self, macro)
+ return "-U" .. macro
+end
+
+-- make the includedir flag
+function nf_includedir(self, dir)
+ return "-I" .. os.args(dir)
+end
+
+-- make the compile arguments list
+function _compargv1(self, sourcefile, objectfile, flags)
+ return self:program(), table.join(flags, "-o", objectfile, sourcefile)
+end
+
+-- compile the source file
+function _compile1(self, sourcefile, objectfile, dependinfo, flags)
+
+ -- ensure the object directory
+ os.mkdir(path.directory(objectfile))
+
+ -- compile it
+ local outdata, errdata = try
+ {
+ function ()
+ return os.iorunv(_compargv1(self, sourcefile, objectfile, flags))
+ end,
+ catch
+ {
+ function (errors)
+
+ -- try removing the old object file for forcing to rebuild this source file
+ os.tryrm(objectfile)
+
+ -- raise compiling errors
+ raise(tostring(errors))
+ end
+ },
+ finally
+ {
+ function (ok, outdata, errdata)
+
+ -- show warnings?
+ if ok and errdata and (option.get("diagnosis") or option.get("warning")) then
+ errdata = errdata:trim()
+ if #errdata > 0 then
+ cprint("${color.warning}%s", errdata)
+ end
+ end
+ end
+ }
+ }
+end
+
+-- make the compile arguments list
+function compargv(self, sourcefiles, objectfile, flags)
+
+ -- only support single source file now
+ assert(type(sourcefiles) ~= "table", "'object:sources' not support!")
+
+ -- for only single source file
+ return _compargv1(self, sourcefiles, objectfile, flags)
+end
+
+-- compile the source file
+function compile(self, sourcefiles, objectfile, dependinfo, flags)
+
+ -- only support single source file now
+ assert(type(sourcefiles) ~= "table", "'object:sources' not support!")
+
+ -- for only single source file
+ _compile1(self, sourcefiles, objectfile, dependinfo, flags)
+end
+
diff --git a/xmake/modules/core/tools/rustc.lua b/xmake/modules/core/tools/rustc.lua
index 227c6ad43..0ec83c803 100644
--- a/xmake/modules/core/tools/rustc.lua
+++ b/xmake/modules/core/tools/rustc.lua
@@ -27,13 +27,13 @@ import("core.project.project")
function init(self)
-- init arflags
- self:set("rc-arflags", "--crate-type=lib")
+ self:set("rcarflags", "--crate-type=lib")
-- init shflags
- self:set("rc-shflags", "--crate-type=dylib")
+ self:set("rcshflags", "--crate-type=dylib")
-- init ldflags
- self:set("rc-ldflags", "--crate-type=bin")
+ self:set("rcldflags", "--crate-type=bin")
-- init the file formats
self:set("formats", { static = "lib$(name).rlib" })
diff --git a/xmake/modules/detect/sdks/find_mingw.lua b/xmake/modules/detect/sdks/find_mingw.lua
index a8c22a9ee..6aa5e3f2a 100644
--- a/xmake/modules/detect/sdks/find_mingw.lua
+++ b/xmake/modules/detect/sdks/find_mingw.lua
@@ -33,6 +33,8 @@ function _find_mingwdir(sdkdir)
if not sdkdir then
if is_host("macosx") then
sdkdir = "/usr/local/opt/mingw-w64"
+ elseif is_host("linux") then
+ sdkdir = "/usr"
end
end
@@ -54,11 +56,11 @@ function _find_mingw(sdkdir, bindir, cross)
-- find mingw root directory
sdkdir = _find_mingwdir(sdkdir)
if not sdkdir then
- return {}
+ return
end
-- select cross on macos, e.g x86_64-w64-mingw32- or i686-w64-mingw32-
- if is_host("macosx") and not cross then
+ if is_host("macosx", "linux") and not cross then
local arch = config.get("arch")
if not arch or arch == "i386" then
cross = "i686-*-"
diff --git a/xmake/modules/detect/sdks/find_ndk.lua b/xmake/modules/detect/sdks/find_ndk.lua
index 7dee10690..f0ee66676 100644
--- a/xmake/modules/detect/sdks/find_ndk.lua
+++ b/xmake/modules/detect/sdks/find_ndk.lua
@@ -101,7 +101,7 @@ function _find_ndk(sdkdir, arch, ndk_sdkver, ndk_toolchains_ver)
-- find ndk root directory
sdkdir = _find_ndkdir(sdkdir)
if not sdkdir then
- return {}
+ return
end
-- get cross
@@ -142,14 +142,11 @@ function _find_ndk(sdkdir, arch, ndk_sdkver, ndk_toolchains_ver)
bindir = find_directory("bin", path.join(sdkdir, "toolchains", gcc_toolchain_subdir, "prebuilt", "*"))
end
if not bindir then
- return {}
+ return
end
-- find the sdk version
local sdkver = ndk_sdkver or _find_ndk_sdkver(sdkdir, bindir, arch)
- if not sdkver then
- return {}
- end
-- find the gcc toolchain
local gcc_toolchain = find_directory("bin", path.join(sdkdir, "toolchains", gcc_toolchain_subdir, "prebuilt", "*"))
@@ -159,9 +156,6 @@ function _find_ndk(sdkdir, arch, ndk_sdkver, ndk_toolchains_ver)
-- find the toolchains version
local toolchains_ver = ndk_toolchains_ver or _find_ndk_toolchains_ver(gcc_toolchain or bindir)
- if not toolchains_ver then
- return {}
- end
-- get ndk version, e.g. r16b, ..
local ndkver = nil
diff --git a/xmake/modules/detect/tools/find_fasm.lua b/xmake/modules/detect/tools/find_fasm.lua
index 5ebf9e699..0b555a406 100644
--- a/xmake/modules/detect/tools/find_fasm.lua
+++ b/xmake/modules/detect/tools/find_fasm.lua
@@ -39,6 +39,7 @@ function main(opt)
-- init options
opt = opt or {}
+ opt.norun = true
-- find program
local program = find_program(opt.program or "fasm", opt)
diff --git a/xmake/modules/private/platform/check_arch.lua b/xmake/modules/detect/tools/find_ld.lua
index 4e67f8ae9..7b015e043 100644
--- a/xmake/modules/private/platform/check_arch.lua
+++ b/xmake/modules/detect/tools/find_ld.lua
@@ -15,24 +15,32 @@
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
--- @file check_arch.lua
+-- @file find_ld.lua
--
-- imports
-import("core.base.option")
+import("core.tool.compiler")
+import("lib.detect.find_program")
--- check the architecture
-function main(config, default)
-
- -- get the architecture
- local arch = config.get("arch")
- if not arch then
+-- find ar
+--
+-- @param opt the argument options, e.g. {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local ar = find_ld()
+-- local ar, version = find_ld({program = "ld", version = true})
+--
+-- @endcode
+--
+function main(opt)
- -- init the default architecture
- config.set("arch", default or os.arch())
+ -- init options
+ opt = opt or {}
+ opt.norun = true
- -- trace
- cprint("checking for the architecture ... ${color.success}%s", config.get("arch"))
- end
+ -- find program
+ return find_program(opt.program or "ld", opt)
end
-
diff --git a/xmake/modules/private/platform/toolchain.lua b/xmake/modules/detect/tools/find_nasm.lua
index 7ddf361d6..68936502e 100644
--- a/xmake/modules/private/platform/toolchain.lua
+++ b/xmake/modules/detect/tools/find_nasm.lua
@@ -15,24 +15,41 @@
-- Copyright (C) 2015-2020, TBOOX Open Source Group.
--
-- @author ruki
--- @file toolchain.lua
+-- @file find_nasm.lua
--
-- imports
-import("core.base.object")
+import("lib.detect.find_program")
+import("lib.detect.find_programver")
--- init toolchain
-local toolchain = toolchain or object {_init = {"description", "list"}}
+-- find nasm
+--
+-- @param opt the argument options, e.g. {version = true}
+--
+-- @return program, version
+--
+-- @code
+--
+-- local nasm = find_nasm()
+-- local nasm, version = find_nasm({program = "nasm", version = true})
+--
+-- @endcode
+--
+function main(opt)
+
+ -- init options
+ opt = opt or {}
+ opt.check = "-v"
+
+ -- find program
+ local program = find_program(opt.program or "nasm", opt)
--- add tool to toolchain list
-function toolchain:add(...)
- for _, item in ipairs({...}) do
- table.insert(self.list, item)
+ -- find program version
+ local version = nil
+ if program and opt and opt.version then
+ version = find_programver(program, opt)
end
-end
--- create a toolchain object
-function main(description)
- return toolchain {description, {}}
+ -- ok?
+ return program, version
end
-
diff --git a/xmake/modules/package/manager/conan/install_package.lua b/xmake/modules/package/manager/conan/install_package.lua
index a74cd8817..201c50841 100644
--- a/xmake/modules/package/manager/conan/install_package.lua
+++ b/xmake/modules/package/manager/conan/install_package.lua
@@ -30,7 +30,7 @@ import("net.fasturl")
function _conan_get_build_env(name, plat)
local value = config.get(name)
if value == nil then
- value = platform.get(name, plat)
+ value = platform.toolconfig(name, plat)
end
if value == nil then
value = platform.tool(name, plat)
diff --git a/xmake/modules/private/action/trybuild/autotools.lua b/xmake/modules/private/action/trybuild/autotools.lua
index 5c08c6ae0..bf4c30709 100644
--- a/xmake/modules/private/action/trybuild/autotools.lua
+++ b/xmake/modules/private/action/trybuild/autotools.lua
@@ -39,7 +39,7 @@ end
function _get_buildenv(key)
local value = config.get(key)
if value == nil then
- value = platform.get(key, config.plat())
+ value = platform.toolconfig(key, config.plat())
end
if value == nil then
value = platform.tool(key, config.plat())
diff --git a/xmake/modules/private/platform/check_toolchain.lua b/xmake/modules/private/platform/check_toolchain.lua
deleted file mode 100644
index 839e6600d..000000000
--- a/xmake/modules/private/platform/check_toolchain.lua
+++ /dev/null
@@ -1,83 +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 check_toolchain.lua
---
-
--- imports
-import("core.base.option")
-import("lib.detect.find_tool")
-
--- check the given tool
-function _check_tool(config, toolkind, description, name, cross, pathes, check)
-
- -- get the program
- local program = config.get(toolkind)
- if not program then
-
- -- translate program name to attempt to get `$(env XX)`
- name = vformat(name)
- if #name == 0 then
- return
- end
-
- -- attempt to check it
- local toolname = nil
- if not program then
- local tool = find_tool(name, {program = (cross or "") .. name, pathes = pathes or config.get("bin"), check = check})
- if tool then
- program = tool.program
- toolname = tool.name
- end
- end
-
- -- check ok?
- if program then
- config.set(toolkind, program)
- config.set("__toolname_" .. toolkind, toolname)
- config.save()
- end
-
- -- trace
- if option.get("verbose") then
- if program then
- cprint("${dim}checking for %s (%s) ... ${color.success}%s", description, toolkind, path.filename(program))
- else
- cprint("${dim}checking for %s (%s: ${bright}%s${clear}) ... ${color.nothing}${text.nothing}", description, toolkind, name)
- end
- end
- end
-
- -- ok?
- return program
-end
-
--- check the toolchain
-function main(config, name, toolchain)
- for _, toolinfo in ipairs(toolchain.list) do
- if type(toolinfo) == "string" then
- if _check_tool(config, name, toolchain.description, toolinfo) then
- break
- end
- else
- if _check_tool(config, name, toolchain.description, toolinfo.name, toolinfo.cross, toolinfo.pathes, toolinfo.check) then
- break
- end
- end
- end
-end
-
diff --git a/xmake/modules/private/platform/check_vstudio.lua b/xmake/modules/private/platform/check_vstudio.lua
deleted file mode 100644
index 6657e43ea..000000000
--- a/xmake/modules/private/platform/check_vstudio.lua
+++ /dev/null
@@ -1,103 +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 check_vstudio.lua
---
-
--- imports
-import("core.base.option")
-import("detect.sdks.find_vstudio")
-import("lib.detect.find_tool")
-import("core.platform.environment")
-
--- attempt to check vs environment
-function _check_vsenv(config)
-
- -- 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
- environment.enter("toolchains")
- local program = nil
- local tool = find_tool("cl.exe", {force = true})
- if tool then
- program = tool.program
- end
- environment.leave("toolchains")
-
- -- ok?
- if program then
- return vsver
- end
- end
- end
- end
-end
-
--- check the visual studio
-function main(config, opt)
-
- -- attempt to check the given vs version first
- local vs = _check_vsenv(config)
- if vs then
-
- -- save it
- config.set("vs", vs, {readonly = true, force = true})
-
- -- trace
- cprint("checking for the Microsoft Visual Studio (%s) version ... ${color.success}%s", config.get("arch"), vs)
- else
- -- failed
- 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
-end
-
-
diff --git a/xmake/modules/private/platform/check_xcode.lua b/xmake/modules/private/platform/check_xcode.lua
deleted file mode 100644
index e0188beb4..000000000
--- a/xmake/modules/private/platform/check_xcode.lua
+++ /dev/null
@@ -1,58 +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 check_xcode.lua
---
-
--- imports
-import("core.base.option")
-import("detect.sdks.find_xcode")
-
--- check the xcode application directory
-function main(config, optional)
-
- -- find xcode
- local xcode = find_xcode(config.get("xcode"), {force = not optional, verbose = true, plat = config.get("plat"), arch = config.get("arch")})
- if xcode then
-
- -- save it (maybe to global)
- config.set("xcode", xcode.sdkdir, {force = true, readonly = true})
-
- elseif not optional then
-
- -- failed
- cprint("${bright color.error}please run:")
- cprint(" - xmake config --xcode=xxx")
- cprint("or - xmake global --xcode=xxx")
- raise()
- end
-
- -- save target minver
- local xcode_sdkver = config.get("xcode_sdkver")
- local target_minver = config.get("target_minver")
- if xcode_sdkver and not target_minver then
- target_minver = xcode_sdkver
- if 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)
- end
-end
-