summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-03-31 14:11:30 +0800
committerruki <[email protected]>2017-03-31 14:11:30 +0800
commitda740edbeca1c0beef66a147a21311a2f5adb734 (patch)
tree1eee975ed6f42749015a3c7063d04a75f2b6fd4b
parent61ba954332d48aea024ec0585adec740df414094 (diff)
delay check toolchains
-rw-r--r--xmake/core/platform/platform.lua19
-rw-r--r--xmake/platforms/android/check.lua116
-rw-r--r--xmake/platforms/checker.lua181
-rw-r--r--xmake/platforms/iphoneos/check.lua70
-rw-r--r--xmake/platforms/linux/check.lua146
-rw-r--r--xmake/platforms/macosx/check.lua118
-rw-r--r--xmake/platforms/mingw/check.lua56
-rw-r--r--xmake/platforms/watchos/check.lua70
-rw-r--r--xmake/platforms/windows/check.lua136
9 files changed, 553 insertions, 359 deletions
diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua
index c8bf71346..e1c894add 100644
--- a/xmake/core/platform/platform.lua
+++ b/xmake/core/platform/platform.lua
@@ -242,10 +242,23 @@ end
--
-- .e.g cc, cxx, mm, mxx, as, ar, ld, sh, ..
--
-function platform.tool(kind)
+function platform.tool(toolkind)
- -- get it
- return config.get(kind)
+ -- attempt to get it from config first
+ local toolpath = config.get(toolkind)
+ if toolpath ~= nil then
+ return toolpath
+ else
+
+ -- check the tool path
+ local check = platform.get("check")
+ if check then
+ check("config", toolkind)
+ end
+
+ -- get it again
+ return config.get(toolkind)
+ end
end
-- get the all platforms
diff --git a/xmake/platforms/android/check.lua b/xmake/platforms/android/check.lua
index d5afcdbd0..68d20375e 100644
--- a/xmake/platforms/android/check.lua
+++ b/xmake/platforms/android/check.lua
@@ -74,15 +74,15 @@ function _check_ndk_sdkver(config)
end
end
--- check the toolchains
-function _check_toolchains(config)
+-- check toolchains directory
+function _check_toolchains_dir(config)
- -- get architecture
- local arch = config.get("arch")
+ -- get toolchains directory
+ local toolchains_dir = config.get("toolchains")
+ if not toolchains_dir then
- -- get toolchains
- local toolchains = config.get("toolchains")
- if not toolchains then
+ -- get architecture
+ local arch = config.get("arch")
-- get ndk
local ndk = config.get("ndk")
@@ -90,35 +90,56 @@ function _check_toolchains(config)
-- match all toolchains
if arch and arch:startswith("arm64") then
- toolchains = os.match("%s/toolchains/aarch64-linux-android-**/prebuilt/*/bin/aarch64-linux-android-*", false, ndk)
+ toolchains_dir = os.match("%s/toolchains/aarch64-linux-android-**/prebuilt/*/bin/aarch64-linux-android-*", false, ndk)
else
- toolchains = os.match("%s/toolchains/arm-linux-androideabi-**/prebuilt/*/bin/arm-linux-androideabi-*", false, ndk)
+ toolchains_dir = os.match("%s/toolchains/arm-linux-androideabi-**/prebuilt/*/bin/arm-linux-androideabi-*", false, ndk)
end
-- save the toolchains directory
- for _, filepath in ipairs(toolchains) do
+ for _, filepath in ipairs(toolchains_dir) do
config.set("toolchains", path.directory(filepath))
break
end
end
end
+end
+
+-- check toolchains version
+function _check_toolchains_ver(config)
-- get toolchains version
- local toolchains = config.get("toolchains")
- if toolchains then
- local pos, _, toolchains_ver = toolchains:find("%-(%d*%.%d*)[/\\]")
- if pos and toolchains_ver then
+ local toolchains_ver = config.get("toolchains_ver")
+ if not toolchains_ver then
- -- save the toolchains version
- config.set("toolchains_ver", toolchains_ver)
-
- -- trace
- cprint("checking for the version of toolchains ... ${green}%s", toolchains_ver)
- else
- -- trace
- cprint("checking for the version of toolchains ... ${red}no")
+ -- get toolchains directory
+ local toolchains_dir = config.get("toolchains")
+ if toolchains_dir then
+ local pos, _, toolchains_ver = toolchains_dir:find("%-(%d*%.%d*)[/\\]")
+ if pos and toolchains_ver then
+
+ -- save the toolchains version
+ config.set("toolchains_ver", toolchains_ver)
+
+ -- trace
+ cprint("checking for the version of toolchains ... ${green}%s", toolchains_ver)
+ else
+ -- trace
+ cprint("checking for the version of toolchains ... ${red}no")
+ end
end
end
+end
+
+-- get toolchains
+function _toolchains(config)
+
+ -- attempt to get it from cache first
+ if _g.TOOLCHAINS then
+ return _g.TOOLCHAINS
+ end
+
+ -- get architecture
+ local arch = config.get("arch")
-- get cross
local cross = "arm-linux-androideabi-"
@@ -126,26 +147,40 @@ function _check_toolchains(config)
cross = "aarch64-linux-android-"
end
- -- check it for c/c++
- checker.check_toolchain(config, "cc", cross, "gcc", "the c compiler")
- checker.check_toolchain(config, "cxx", cross, "g++", "the c++ compiler")
- checker.check_toolchain(config, "as", cross, "gcc", "the assember")
- checker.check_toolchain(config, "ld", cross, "g++", "the linker")
- checker.check_toolchain(config, "ld", cross, "gcc", "the linker")
- checker.check_toolchain(config, "ar", cross, "ar", "the static library archiver")
- checker.check_toolchain(config, "ex", cross, "ar", "the static library extractor")
- checker.check_toolchain(config, "sh", cross, "g++", "the shared library linker")
- checker.check_toolchain(config, "sh", cross, "gcc", "the shared library linker")
+ -- init toolchains
+ local toolchains = {}
- -- check for rust tools
- checker.check_toolchain(config, "rc", "", "rustc", "the rust compiler")
- checker.check_toolchain(config, "rc-ar", "", "rustc", "the rust static library archiver")
- checker.check_toolchain(config, "rc-sh", "", "rustc", "the rust shared library linker")
- checker.check_toolchain(config, "rc-ld", "", "rustc", "the rust linker")
+ -- check c/c++ tools to toolchains
+ checker.toolchain_insert(toolchains, "cc", cross, "gcc", "the c compiler")
+ checker.toolchain_insert(toolchains, "cxx", cross, "g++", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "as", cross, "gcc", "the assember")
+ checker.toolchain_insert(toolchains, "ld", cross, "g++", "the linker")
+ checker.toolchain_insert(toolchains, "ld", cross, "gcc", "the linker")
+ checker.toolchain_insert(toolchains, "ar", cross, "ar", "the static library archiver")
+ checker.toolchain_insert(toolchains, "ex", cross, "ar", "the static library extractor")
+ checker.toolchain_insert(toolchains, "sh", cross, "g++", "the shared library linker")
+ checker.toolchain_insert(toolchains, "sh", cross, "gcc", "the shared library linker")
+
+ -- insert rust tools to toolchains
+ checker.toolchain_insert(toolchains, "rc", "", "rustc", "the rust compiler")
+ checker.toolchain_insert(toolchains, "rc-ar", "", "rustc", "the rust static library archiver")
+ checker.toolchain_insert(toolchains, "rc-sh", "", "rustc", "the rust shared library linker")
+ checker.toolchain_insert(toolchains, "rc-ld", "", "rustc", "the rust linker")
+
+ -- save toolchains
+ _g.TOOLCHAINS = toolchains
+
+ -- ok
+ return toolchains
end
-- check it
-function main(kind)
+function main(kind, toolkind)
+
+ -- only check the given tool?
+ if toolkind then
+ return checker.toolchain_check(import("core.project." .. kind), toolkind, _toolchains)
+ end
-- init the check list of config
_g.config =
@@ -153,7 +188,10 @@ function main(kind)
{ checker.check_arch, "armv7-a" }
, checker.check_ccache
, _check_ndk_sdkver
- , _check_toolchains
+ , _check_toolchains_dir
+ , _check_toolchains_ver
+ , { checker.toolchain_check, "sh", _toolchains }
+ , { checker.toolchain_check, "ld", _toolchains }
}
-- init the check list of global
diff --git a/xmake/platforms/checker.lua b/xmake/platforms/checker.lua
index 856b3c696..f578d6f8a 100644
--- a/xmake/platforms/checker.lua
+++ b/xmake/platforms/checker.lua
@@ -25,6 +25,87 @@
-- imports
import("core.tool.tool")
+-- find the given tool
+function _toolchain_check(config, toolkind, toolinfo)
+
+ -- get the tool path
+ local toolpath = config.get(toolkind)
+ if not toolpath then
+
+ -- get name
+ local name = toolinfo.name
+
+ -- get cross
+ local cross = config.get("cross") or toolinfo.cross
+
+ -- get shell name from the env if not cross-compilation
+ if cross and cross:trim() == "" then
+ local shellname = os.getenv(toolkind:upper():split('-')[1])
+ if shellname and shellname:trim() ~= "" then
+ toolpath = tool.check(shellname)
+ end
+ end
+
+ -- check it using the custom script
+ if not toolpath and toolinfo.check then
+
+ -- check it
+ try
+ {
+ function ()
+
+ -- check it
+ toolinfo.check(cross .. name)
+
+ -- ok
+ toolpath = cross .. name
+ end
+ }
+ end
+
+ -- get toolchains
+ local toolchains = config.get("toolchains")
+ if not toolchains then
+ local sdkdir = config.get("sdk")
+ if sdkdir then
+ toolchains = path.join(sdkdir, "bin")
+ end
+ end
+
+ -- attempt to check it from the given cross toolchains
+ if not toolpath and toolchains then
+ toolpath = tool.check(cross .. name, toolchains)
+ end
+
+ -- attempt to check it with cross prefix
+ if not toolpath then
+ toolpath = tool.check(cross .. name)
+ end
+
+ -- attempt to check it without cross prefix
+ if not toolpath then
+ toolpath = tool.check(name)
+ end
+
+ -- check ok?
+ if toolpath then
+
+ -- update config
+ config.set(toolkind, toolpath)
+ end
+
+ -- trace
+ if toolpath then
+ cprint("checking for %s (%s) ... ${green}%s", toolinfo.description, toolkind, path.filename(toolpath))
+ else
+ cprint("checking for %s (%s: ${red}%s${clear}) ... ${red}no", toolinfo.description, toolkind, name)
+ end
+ end
+
+ -- get tool path
+ return toolpath
+end
+
-- check all for the given config kind
function check(kind, checkers)
@@ -35,16 +116,19 @@ function check(kind, checkers)
for _, checker in ipairs(checkers[kind]) do
-- has arguments?
- local args = nil
+ local args = {}
if type(checker) == "table" then
- if #checker > 1 then
- args = checker[2]
+ for idx, arg in ipairs(checker) do
+ if idx == 1 then
+ checker = arg
+ else
+ table.insert(args, arg)
+ end
end
- checker = checker[1]
end
-- check it
- checker(config, args)
+ checker(config, unpack(args))
end
end
@@ -203,79 +287,30 @@ function check_ccache(config)
end
end
--- check the toolchain
-function check_toolchain(config, kind, cross, name, description, check)
-
- -- get the tool path
- local toolpath = config.get(kind)
- if not toolpath then
-
- -- get the cross
- cross = config.get("cross") or cross
-
- -- get shell name from the env if not cross-compilation
- if cross and cross:trim() == "" then
- local shellname = os.getenv(kind:upper():split('-')[1])
- if shellname and shellname:trim() ~= "" then
- toolpath = tool.check(shellname)
- end
- end
-
- -- check it using the custom script
- if not toolpath and check then
-
- -- check it
- try
- {
- function ()
-
- -- check it
- check(cross .. name)
-
- -- ok
- toolpath = cross .. name
- end
- }
- end
+-- insert toolchain
+function toolchain_insert(toolchains, toolkind, cross, name, description, check)
- -- get toolchains
- local toolchains = config.get("toolchains")
- if not toolchains then
- local sdkdir = config.get("sdk")
- if sdkdir then
- toolchains = path.join(sdkdir, "bin")
- end
- end
-
- -- attempt to check it from the given cross toolchains
- if not toolpath and toolchains then
- toolpath = tool.check(cross .. name, toolchains)
- end
-
- -- attempt to check it with cross prefix
- if not toolpath then
- toolpath = tool.check(cross .. name)
- end
-
- -- attempt to check it without cross prefix
- if not toolpath then
- toolpath = tool.check(name)
- end
+ -- insert to the given toolchain
+ toolchains[toolkind] = toolchains[toolkind] or {}
+ table.insert(toolchains[toolkind], {cross = cross, name = name, description = description, check = check})
+end
- -- check ok?
- if toolpath then
+-- check the toolchain
+function toolchain_check(config, toolkind, toolchains)
- -- update config
- config.set(kind, toolpath)
- end
+ -- load toolchains if be function
+ if type(toolchains) == "function" then
+ toolchains = toolchains(config)
+ end
- -- trace
- if toolpath then
- cprint("checking for %s (%s) ... ${green}%s", description, kind, path.filename(toolpath))
- else
- cprint("checking for %s (%s: ${red}%s${clear}) ... ${red}no", description, kind, name)
+ -- check this toolchain
+ for _, toolinfo in ipairs(toolchains[toolkind]) do
+ if _toolchain_check(config, toolkind, toolinfo) then
+ break
end
end
-end
+ -- save config
+ config.save()
+end
diff --git a/xmake/platforms/iphoneos/check.lua b/xmake/platforms/iphoneos/check.lua
index d247c4bf8..2e5b050d4 100644
--- a/xmake/platforms/iphoneos/check.lua
+++ b/xmake/platforms/iphoneos/check.lua
@@ -40,8 +40,13 @@ function _check_as(shellname)
os.rm(tmpfile)
end
--- check the toolchains
-function _check_toolchains(config)
+-- get toolchains
+function _toolchains(config)
+
+ -- attempt to get it from cache first
+ if _g.TOOLCHAINS then
+ return _g.TOOLCHAINS
+ end
-- init architecture
local arch = config.get("arch")
@@ -50,38 +55,52 @@ function _check_toolchains(config)
-- init cross
local cross = ifelse(simulator, "xcrun -sdk iphonesimulator ", "xcrun -sdk iphoneos ")
- -- check for c/c++ tools
- checker.check_toolchain(config, "cc", cross, "clang", "the c compiler")
- checker.check_toolchain(config, "cxx", cross, "clang", "the c++ compiler")
- checker.check_toolchain(config, "cxx", cross, "clang++", "the c++ compiler")
- checker.check_toolchain(config, "ld", cross, "clang++", "the linker")
- checker.check_toolchain(config, "ld", cross, "clang", "the linker")
- checker.check_toolchain(config, "ar", cross, "ar", "the static library archiver")
- checker.check_toolchain(config, "ex", cross, "ar", "the static library extractor")
- checker.check_toolchain(config, "sh", cross, "clang++", "the shared library linker")
- checker.check_toolchain(config, "sh", cross, "clang", "the shared library linker")
- checker.check_toolchain(config, "dg", cross, "lldb", "the debugger")
+ -- init toolchains
+ local toolchains = {}
+
+ -- insert c/c++ tools to toolchains
+ checker.toolchain_insert(toolchains, "cc", cross, "clang", "the c compiler")
+ checker.toolchain_insert(toolchains, "cxx", cross, "clang", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "cxx", cross, "clang++", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "ld", cross, "clang++", "the linker")
+ checker.toolchain_insert(toolchains, "ld", cross, "clang", "the linker")
+ checker.toolchain_insert(toolchains, "ar", cross, "ar", "the static library archiver")
+ checker.toolchain_insert(toolchains, "ex", cross, "ar", "the static library extractor")
+ checker.toolchain_insert(toolchains, "sh", cross, "clang++", "the shared library linker")
+ checker.toolchain_insert(toolchains, "sh", cross, "clang", "the shared library linker")
+ checker.toolchain_insert(toolchains, "dg", cross, "lldb", "the debugger")
+
+ -- insert objc/c++ tools to toolchains
+ checker.toolchain_insert(toolchains, "mm", cross, "clang", "the objc compiler")
+ checker.toolchain_insert(toolchains, "mxx", cross, "clang++", "the objc++ compiler")
+ checker.toolchain_insert(toolchains, "mxx", cross, "clang", "the objc++ compiler")
- -- check for objc/c++ tools
- checker.check_toolchain(config, "mm", cross, "clang", "the objc compiler")
- checker.check_toolchain(config, "mxx", cross, "clang++", "the objc++ compiler")
- checker.check_toolchain(config, "mxx", cross, "clang", "the objc++ compiler")
+ -- insert swift tools to toolchains
+ checker.toolchain_insert(toolchains, "sc", cross, "swiftc", "the swift compiler")
+ checker.toolchain_insert(toolchains, "sc-ld", cross, "swiftc", "the swift linker")
+ checker.toolchain_insert(toolchains, "sc-sh", cross, "swiftc", "the swift shared library linker")
- -- check for asm tools
+ -- insert asm tools to toolchains
if simulator then
- checker.check_toolchain(config, "as", cross, "clang", "the assember")
+ checker.toolchain_insert(toolchains, "as", cross, "clang", "the assember")
else
- checker.check_toolchain(config, "as", path.join(os.toolsdir(), "utils/gas-preprocessor.pl " .. cross), "clang", "the assember", _check_as)
+ checker.toolchain_insert(toolchains, "as", path.join(os.toolsdir(), "utils/gas-preprocessor.pl " .. cross), "clang", "the assember", _check_as)
end
- -- check for swift tools
- checker.check_toolchain(config, "sc", cross, "swiftc", "the swift compiler")
- checker.check_toolchain(config, "sc-ld", cross, "swiftc", "the swift linker")
- checker.check_toolchain(config, "sc-sh", cross, "swiftc", "the swift shared library linker")
+ -- save toolchains
+ _g.TOOLCHAINS = toolchains
+
+ -- ok
+ return toolchains
end
-- check it
-function main(kind)
+function main(kind, toolkind)
+
+ -- only check the given tool?
+ if toolkind then
+ return checker.toolchain_check(import("core.project." .. kind), toolkind, _toolchains)
+ end
-- init the check list of config
_g.config =
@@ -91,7 +110,6 @@ function main(kind)
, checker.check_xcode_sdkver
, checker.check_target_minver
, checker.check_ccache
- , _check_toolchains
}
-- init the check list of global
diff --git a/xmake/platforms/linux/check.lua b/xmake/platforms/linux/check.lua
index cbe89854b..75e582161 100644
--- a/xmake/platforms/linux/check.lua
+++ b/xmake/platforms/linux/check.lua
@@ -41,22 +41,27 @@ function __check_arch(config)
end
end
--- check the toolchains
-function _check_toolchains(config)
+-- get toolchains
+function _toolchains(config)
- -- get toolchains
- local toolchains = config.get("toolchains")
- if not toolchains then
+ -- attempt to get it from cache first
+ if _g.TOOLCHAINS then
+ return _g.TOOLCHAINS
+ end
+
+ -- get toolchains directory
+ local toolchainsdir = config.get("toolchains")
+ if not toolchainsdir then
local sdkdir = config.get("sdk")
if sdkdir then
- toolchains = path.join(sdkdir, "bin")
+ toolchainsdir = path.join(sdkdir, "bin")
end
end
-- get cross
local cross = ""
- if toolchains then
- local ldpathes = os.match(path.join(toolchains, "*-ld"))
+ if toolchainsdir then
+ local ldpathes = os.match(path.join(toolchainsdir, "*-ld"))
for _, ldpath in ipairs(ldpathes) do
local ldname = path.basename(ldpath)
if ldname then
@@ -65,76 +70,89 @@ function _check_toolchains(config)
end
end
- -- check for c/c++ tools
- checker.check_toolchain(config, "cc", cross, "gcc", "the c compiler")
- checker.check_toolchain(config, "cc", cross, "clang", "the c compiler")
- checker.check_toolchain(config, "cxx", cross, "gcc", "the c++ compiler")
- checker.check_toolchain(config, "cxx", cross, "clang", "the c++ compiler")
- checker.check_toolchain(config, "cxx", cross, "g++", "the c++ compiler")
- checker.check_toolchain(config, "cxx", cross, "clang++", "the c++ compiler")
- checker.check_toolchain(config, "ld", cross, "g++", "the linker")
- checker.check_toolchain(config, "ld", cross, "gcc", "the linker")
- checker.check_toolchain(config, "ld", cross, "clang++", "the linker")
- checker.check_toolchain(config, "ld", cross, "clang", "the linker")
- checker.check_toolchain(config, "ar", cross, "ar", "the static library archiver")
- checker.check_toolchain(config, "ex", cross, "ar", "the static library extractor")
- checker.check_toolchain(config, "sh", cross, "g++", "the shared library linker")
- checker.check_toolchain(config, "sh", cross, "gcc", "the shared library linker")
- checker.check_toolchain(config, "sh", cross, "clang++", "the shared library linker")
- checker.check_toolchain(config, "sh", cross, "clang", "the shared library linker")
- checker.check_toolchain(config, "dg", cross, "gdb", "the debugger")
- checker.check_toolchain(config, "dg", cross, "lldb", "the debugger")
+ -- init toolchains
+ local toolchains = {}
+
+ -- insert c/c++ tools to toolchains
+ checker.toolchain_insert(toolchains, "cc", cross, "gcc", "the c compiler")
+ checker.toolchain_insert(toolchains, "cc", cross, "clang", "the c compiler")
+ checker.toolchain_insert(toolchains, "cxx", cross, "gcc", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "cxx", cross, "clang", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "cxx", cross, "g++", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "cxx", cross, "clang++", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "ld", cross, "g++", "the linker")
+ checker.toolchain_insert(toolchains, "ld", cross, "gcc", "the linker")
+ checker.toolchain_insert(toolchains, "ld", cross, "clang++", "the linker")
+ checker.toolchain_insert(toolchains, "ld", cross, "clang", "the linker")
+ checker.toolchain_insert(toolchains, "ar", cross, "ar", "the static library archiver")
+ checker.toolchain_insert(toolchains, "ex", cross, "ar", "the static library extractor")
+ checker.toolchain_insert(toolchains, "sh", cross, "g++", "the shared library linker")
+ checker.toolchain_insert(toolchains, "sh", cross, "gcc", "the shared library linker")
+ checker.toolchain_insert(toolchains, "sh", cross, "clang++", "the shared library linker")
+ checker.toolchain_insert(toolchains, "sh", cross, "clang", "the shared library linker")
+ checker.toolchain_insert(toolchains, "dg", cross, "gdb", "the debugger")
+ checker.toolchain_insert(toolchains, "dg", cross, "lldb", "the debugger")
+
+ -- insert objc/c++ tools to toolchains
+ checker.toolchain_insert(toolchains, "mm", cross, "clang", "the objc compiler")
+ checker.toolchain_insert(toolchains, "mm", cross, "gcc", "the objc compiler")
+ checker.toolchain_insert(toolchains, "mxx", cross, "clang++", "the objc++ compiler")
+ checker.toolchain_insert(toolchains, "mxx", cross, "clang", "the objc++ compiler")
+ checker.toolchain_insert(toolchains, "mxx", cross, "g++", "the objc++ compiler")
+ checker.toolchain_insert(toolchains, "mxx", cross, "gcc", "the objc++ compiler")
- -- check for objc/c++ tools
- checker.check_toolchain(config, "mm", cross, "clang", "the objc compiler")
- checker.check_toolchain(config, "mm", cross, "gcc", "the objc compiler")
- checker.check_toolchain(config, "mxx", cross, "clang++", "the objc++ compiler")
- checker.check_toolchain(config, "mxx", cross, "clang", "the objc++ compiler")
- checker.check_toolchain(config, "mxx", cross, "g++", "the objc++ compiler")
- checker.check_toolchain(config, "mxx", cross, "gcc", "the objc++ compiler")
+ -- insert asm tools to toolchains
+ checker.toolchain_insert(toolchains, "as", cross, "clang", "the assember")
+ checker.toolchain_insert(toolchains, "as", cross, "gcc", "the assember")
- -- check for asm tools
- checker.check_toolchain(config, "as", cross, "clang", "the assember")
- checker.check_toolchain(config, "as", cross, "gcc", "the assember")
+ -- insert golang tools to toolchains
+ checker.toolchain_insert(toolchains, "gc", "", "go", "the golang compiler")
+ checker.toolchain_insert(toolchains, "gc", "", "gccgo", "the golang compiler")
+ checker.toolchain_insert(toolchains, "gc-ar", "", "go", "the golang static library archiver")
+ checker.toolchain_insert(toolchains, "gc-ar", "", "gccgo", "the golang static library archiver")
+ checker.toolchain_insert(toolchains, "gc-ld", "", "go", "the golang linker")
+ checker.toolchain_insert(toolchains, "gc-ld", "", "gccgo", "the golang linker")
- -- check for golang tools
- checker.check_toolchain(config, "gc", "", "go", "the golang compiler")
- checker.check_toolchain(config, "gc", "", "gccgo", "the golang compiler")
- checker.check_toolchain(config, "gc-ar", "", "go", "the golang static library archiver")
- checker.check_toolchain(config, "gc-ar", "", "gccgo", "the golang static library archiver")
- checker.check_toolchain(config, "gc-ld", "", "go", "the golang linker")
- checker.check_toolchain(config, "gc-ld", "", "gccgo", "the golang linker")
+ -- insert dlang tools to toolchains
+ checker.toolchain_insert(toolchains, "dc", "", "dmd", "the dlang compiler")
+ checker.toolchain_insert(toolchains, "dc", "", "ldc2", "the dlang compiler")
+ checker.toolchain_insert(toolchains, "dc", "", "gdc", "the dlang compiler")
+ checker.toolchain_insert(toolchains, "dc-ar", "", "dmd", "the dlang static library archiver")
+ checker.toolchain_insert(toolchains, "dc-ar", "", "ldc2", "the dlang static library archiver")
+ checker.toolchain_insert(toolchains, "dc-ar", "", "gdc", "the dlang static library archiver")
+ checker.toolchain_insert(toolchains, "dc-sh", "", "dmd", "the dlang shared library linker")
+ checker.toolchain_insert(toolchains, "dc-sh", "", "ldc2", "the dlang shared library linker")
+ checker.toolchain_insert(toolchains, "dc-sh", "", "gdc", "the dlang shared library linker")
+ checker.toolchain_insert(toolchains, "dc-ld", "", "dmd", "the dlang linker")
+ checker.toolchain_insert(toolchains, "dc-ld", "", "ldc2", "the dlang linker")
+ checker.toolchain_insert(toolchains, "dc-ld", "", "gdc", "the dlang linker")
- -- check for dlang tools
- checker.check_toolchain(config, "dc", "", "dmd", "the dlang compiler")
- checker.check_toolchain(config, "dc", "", "ldc2", "the dlang compiler")
- checker.check_toolchain(config, "dc", "", "gdc", "the dlang compiler")
- checker.check_toolchain(config, "dc-ar", "", "dmd", "the dlang static library archiver")
- checker.check_toolchain(config, "dc-ar", "", "ldc2", "the dlang static library archiver")
- checker.check_toolchain(config, "dc-ar", "", "gdc", "the dlang static library archiver")
- checker.check_toolchain(config, "dc-sh", "", "dmd", "the dlang shared library linker")
- checker.check_toolchain(config, "dc-sh", "", "ldc2", "the dlang shared library linker")
- checker.check_toolchain(config, "dc-sh", "", "gdc", "the dlang shared library linker")
- checker.check_toolchain(config, "dc-ld", "", "dmd", "the dlang linker")
- checker.check_toolchain(config, "dc-ld", "", "ldc2", "the dlang linker")
- checker.check_toolchain(config, "dc-ld", "", "gdc", "the dlang linker")
+ -- insert rust tools to toolchains
+ checker.toolchain_insert(toolchains, "rc", "", "rustc", "the rust compiler")
+ checker.toolchain_insert(toolchains, "rc-ar", "", "rustc", "the rust static library archiver")
+ checker.toolchain_insert(toolchains, "rc-sh", "", "rustc", "the rust shared library linker")
+ checker.toolchain_insert(toolchains, "rc-ld", "", "rustc", "the rust linker")
- -- check for rust tools
- checker.check_toolchain(config, "rc", "", "rustc", "the rust compiler")
- checker.check_toolchain(config, "rc-ar", "", "rustc", "the rust static library archiver")
- checker.check_toolchain(config, "rc-sh", "", "rustc", "the rust shared library linker")
- checker.check_toolchain(config, "rc-ld", "", "rustc", "the rust linker")
+ -- save toolchains
+ _g.TOOLCHAINS = toolchains
+
+ -- ok
+ return toolchains
end
-- check it
-function main(kind)
+function main(kind, toolkind)
+
+ -- only check the given tool?
+ if toolkind then
+ return checker.toolchain_check(import("core.project." .. kind), toolkind, _toolchains)
+ end
-- init the check list of config
_g.config =
{
__check_arch
, checker.check_ccache
- , _check_toolchains
}
-- init the check list of global
diff --git a/xmake/platforms/macosx/check.lua b/xmake/platforms/macosx/check.lua
index f82f16dc4..9955e3bb6 100644
--- a/xmake/platforms/macosx/check.lua
+++ b/xmake/platforms/macosx/check.lua
@@ -26,65 +26,84 @@
import("core.tool.tool")
import("platforms.checker", {rootdir = os.programdir()})
--- check the toolchains
-function _check_toolchains(config)
+-- get toolchains
+function _toolchains(config)
- -- check for c/c++ tools
- checker.check_toolchain(config, "cc", "xcrun -sdk macosx ", "clang", "the c compiler")
- checker.check_toolchain(config, "cxx", "xcrun -sdk macosx ", "clang", "the c++ compiler")
- checker.check_toolchain(config, "cxx", "xcrun -sdk macosx ", "clang++", "the c++ compiler")
- checker.check_toolchain(config, "ld", "xcrun -sdk macosx ", "clang++", "the linker")
- checker.check_toolchain(config, "ld", "xcrun -sdk macosx ", "clang", "the linker")
- checker.check_toolchain(config, "ar", "xcrun -sdk macosx ", "ar", "the static library archiver")
- checker.check_toolchain(config, "ex", "xcrun -sdk macosx ", "ar", "the static library extractor")
- checker.check_toolchain(config, "sh", "xcrun -sdk macosx ", "clang++", "the shared library linker")
- checker.check_toolchain(config, "sh", "xcrun -sdk macosx ", "clang", "the shared library linker")
- checker.check_toolchain(config, "dg", "xcrun -sdk macosx ", "lldb", "the debugger")
+ -- attempt to get it from cache first
+ if _g.TOOLCHAINS then
+ return _g.TOOLCHAINS
+ end
- -- check for objc/c++ tools
- checker.check_toolchain(config, "mm", "xcrun -sdk macosx ", "clang", "the objc compiler")
- checker.check_toolchain(config, "mxx", "xcrun -sdk macosx ", "clang++", "the objc++ compiler")
- checker.check_toolchain(config, "mxx", "xcrun -sdk macosx ", "clang", "the objc++ compiler")
+ -- init toolchains
+ local toolchains = {}
- -- check for asm tools
- checker.check_toolchain(config, "as", "xcrun -sdk macosx ", "clang", "the assember")
+ -- insert c/c++ tools to toolchains
+ checker.toolchain_insert(toolchains, "cc", "xcrun -sdk macosx ", "clang", "the c compiler")
+ checker.toolchain_insert(toolchains, "cxx", "xcrun -sdk macosx ", "clang", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "cxx", "xcrun -sdk macosx ", "clang++", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "ld", "xcrun -sdk macosx ", "clang++", "the linker")
+ checker.toolchain_insert(toolchains, "ld", "xcrun -sdk macosx ", "clang", "the linker")
+ checker.toolchain_insert(toolchains, "ar", "xcrun -sdk macosx ", "ar", "the static library archiver")
+ checker.toolchain_insert(toolchains, "ex", "xcrun -sdk macosx ", "ar", "the static library extractor")
+ checker.toolchain_insert(toolchains, "sh", "xcrun -sdk macosx ", "clang++", "the shared library linker")
+ checker.toolchain_insert(toolchains, "sh", "xcrun -sdk macosx ", "clang", "the shared library linker")
+ checker.toolchain_insert(toolchains, "dg", "xcrun -sdk macosx ", "lldb", "the debugger")
- -- check for swift tools
- checker.check_toolchain(config, "sc", "xcrun -sdk macosx ", "swiftc", "the swift compiler")
- checker.check_toolchain(config, "sc-ld", "xcrun -sdk macosx ", "swiftc", "the swift linker")
- checker.check_toolchain(config, "sc-sh", "xcrun -sdk macosx ", "swiftc", "the swift shared library linker")
+ -- insert objc/c++ tools to toolchains
+ checker.toolchain_insert(toolchains, "mm", "xcrun -sdk macosx ", "clang", "the objc compiler")
+ checker.toolchain_insert(toolchains, "mxx", "xcrun -sdk macosx ", "clang++", "the objc++ compiler")
+ checker.toolchain_insert(toolchains, "mxx", "xcrun -sdk macosx ", "clang", "the objc++ compiler")
- -- check for golang tools
- checker.check_toolchain(config, "gc", "", "go", "the golang compiler")
- checker.check_toolchain(config, "gc", "", "gccgo", "the golang compiler")
- checker.check_toolchain(config, "gc-ar", "", "go", "the golang static library archiver")
- checker.check_toolchain(config, "gc-ar", "", "gccgo", "the golang static library archiver")
- checker.check_toolchain(config, "gc-ld", "", "go", "the golang linker")
- checker.check_toolchain(config, "gc-ld", "", "gccgo", "the golang linker")
+ -- insert asm tools to toolchains
+ checker.toolchain_insert(toolchains, "as", "xcrun -sdk macosx ", "clang", "the assember")
- -- check for dlang tools
- checker.check_toolchain(config, "dc", "", "dmd", "the dlang compiler")
- checker.check_toolchain(config, "dc", "", "ldc2", "the dlang compiler")
- checker.check_toolchain(config, "dc", "", "gdc", "the dlang compiler")
- checker.check_toolchain(config, "dc-ar", "", "dmd", "the dlang static library archiver")
- checker.check_toolchain(config, "dc-ar", "", "ldc2", "the dlang static library archiver")
- checker.check_toolchain(config, "dc-ar", "", "gdc", "the dlang static library archiver")
- checker.check_toolchain(config, "dc-sh", "", "dmd", "the dlang shared library linker")
- checker.check_toolchain(config, "dc-sh", "", "ldc2", "the dlang shared library linker")
- checker.check_toolchain(config, "dc-sh", "", "gdc", "the dlang shared library linker")
- checker.check_toolchain(config, "dc-ld", "", "dmd", "the dlang linker")
- checker.check_toolchain(config, "dc-ld", "", "ldc2", "the dlang linker")
- checker.check_toolchain(config, "dc-ld", "", "gdc", "the dlang linker")
+ -- insert swift tools to toolchains
+ checker.toolchain_insert(toolchains, "sc", "xcrun -sdk macosx ", "swiftc", "the swift compiler")
+ checker.toolchain_insert(toolchains, "sc-ld", "xcrun -sdk macosx ", "swiftc", "the swift linker")
+ checker.toolchain_insert(toolchains, "sc-sh", "xcrun -sdk macosx ", "swiftc", "the swift shared library linker")
- -- check for rust tools
- checker.check_toolchain(config, "rc", "", "rustc", "the rust compiler")
- checker.check_toolchain(config, "rc-ar", "", "rustc", "the rust static library archiver")
- checker.check_toolchain(config, "rc-sh", "", "rustc", "the rust shared library linker")
- checker.check_toolchain(config, "rc-ld", "", "rustc", "the rust linker")
+ -- insert golang tools to toolchains
+ checker.toolchain_insert(toolchains, "gc", "", "go", "the golang compiler")
+ checker.toolchain_insert(toolchains, "gc", "", "gccgo", "the golang compiler")
+ checker.toolchain_insert(toolchains, "gc-ar", "", "go", "the golang static library archiver")
+ checker.toolchain_insert(toolchains, "gc-ar", "", "gccgo", "the golang static library archiver")
+ checker.toolchain_insert(toolchains, "gc-ld", "", "go", "the golang linker")
+ checker.toolchain_insert(toolchains, "gc-ld", "", "gccgo", "the golang linker")
+
+ -- insert dlang tools to toolchains
+ checker.toolchain_insert(toolchains, "dc", "", "dmd", "the dlang compiler")
+ checker.toolchain_insert(toolchains, "dc", "", "ldc2", "the dlang compiler")
+ checker.toolchain_insert(toolchains, "dc", "", "gdc", "the dlang compiler")
+ checker.toolchain_insert(toolchains, "dc-ar", "", "dmd", "the dlang static library archiver")
+ checker.toolchain_insert(toolchains, "dc-ar", "", "ldc2", "the dlang static library archiver")
+ checker.toolchain_insert(toolchains, "dc-ar", "", "gdc", "the dlang static library archiver")
+ checker.toolchain_insert(toolchains, "dc-sh", "", "dmd", "the dlang shared library linker")
+ checker.toolchain_insert(toolchains, "dc-sh", "", "ldc2", "the dlang shared library linker")
+ checker.toolchain_insert(toolchains, "dc-sh", "", "gdc", "the dlang shared library linker")
+ checker.toolchain_insert(toolchains, "dc-ld", "", "dmd", "the dlang linker")
+ checker.toolchain_insert(toolchains, "dc-ld", "", "ldc2", "the dlang linker")
+ checker.toolchain_insert(toolchains, "dc-ld", "", "gdc", "the dlang linker")
+
+ -- insert rust tools to toolchains
+ checker.toolchain_insert(toolchains, "rc", "", "rustc", "the rust compiler")
+ checker.toolchain_insert(toolchains, "rc-ar", "", "rustc", "the rust static library archiver")
+ checker.toolchain_insert(toolchains, "rc-sh", "", "rustc", "the rust shared library linker")
+ checker.toolchain_insert(toolchains, "rc-ld", "", "rustc", "the rust linker")
+
+ -- save toolchains
+ _g.TOOLCHAINS = toolchains
+
+ -- ok
+ return toolchains
end
-- check it
-function main(kind)
+function main(kind, toolkind)
+
+ -- only check the given tool?
+ if toolkind then
+ return checker.toolchain_check(import("core.project." .. kind), toolkind, _toolchains)
+ end
-- init the check list of config
_g.config =
@@ -94,7 +113,6 @@ function main(kind)
, checker.check_xcode_sdkver
, checker.check_target_minver
, checker.check_ccache
- , _check_toolchains
}
-- init the check list of global
diff --git a/xmake/platforms/mingw/check.lua b/xmake/platforms/mingw/check.lua
index 7a0908017..a7c1222e5 100644
--- a/xmake/platforms/mingw/check.lua
+++ b/xmake/platforms/mingw/check.lua
@@ -26,22 +26,27 @@
import("core.tool.tool")
import("platforms.checker", {rootdir = os.programdir()})
--- check the toolchains
-function _check_toolchains(config)
+-- get toolchains
+function _toolchains(config)
+
+ -- attempt to get it from cache first
+ if _g.TOOLCHAINS then
+ return _g.TOOLCHAINS
+ end
-- get toolchains
- local toolchains = config.get("toolchains")
- if not toolchains then
+ local toolchainsdir = config.get("toolchains")
+ if not toolchainsdir then
local sdkdir = config.get("sdk")
if sdkdir then
- toolchains = path.join(sdkdir, "bin")
+ toolchainsdir = path.join(sdkdir, "bin")
end
end
-- get cross
local cross = ""
- if toolchains then
- local ldpathes = os.match(path.join(toolchains, "*-ld"))
+ if toolchainsdir then
+ local ldpathes = os.match(path.join(toolchainsdir, "*-ld"))
for _, ldpath in ipairs(ldpathes) do
local ldname = path.basename(ldpath)
if ldname then
@@ -50,28 +55,39 @@ function _check_toolchains(config)
end
end
- -- check
- checker.check_toolchain(config, "cc", cross, "gcc", "the c compiler")
- checker.check_toolchain(config, "cxx", cross, "g++", "the c++ compiler")
- checker.check_toolchain(config, "cxx", cross, "gcc", "the c++ compiler")
- checker.check_toolchain(config, "as", cross, "gcc", "the assember")
- checker.check_toolchain(config, "ld", cross, "g++", "the linker")
- checker.check_toolchain(config, "ld", cross, "gcc", "the linker")
- checker.check_toolchain(config, "ar", cross, "ar", "the static library archiver")
- checker.check_toolchain(config, "ex", cross, "ar", "the static library extractor")
- checker.check_toolchain(config, "sh", cross, "g++", "the shared library linker")
- checker.check_toolchain(config, "sh", cross, "gcc", "the shared library linker")
+ -- make toolchains
+ local toolchains = {}
+ checker.toolchain_insert(toolchains, "cc", cross, "gcc", "the c compiler")
+ checker.toolchain_insert(toolchains, "cxx", cross, "g++", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "cxx", cross, "gcc", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "as", cross, "gcc", "the assember")
+ checker.toolchain_insert(toolchains, "ld", cross, "g++", "the linker")
+ checker.toolchain_insert(toolchains, "ld", cross, "gcc", "the linker")
+ checker.toolchain_insert(toolchains, "ar", cross, "ar", "the static library archiver")
+ checker.toolchain_insert(toolchains, "ex", cross, "ar", "the static library extractor")
+ checker.toolchain_insert(toolchains, "sh", cross, "g++", "the shared library linker")
+ checker.toolchain_insert(toolchains, "sh", cross, "gcc", "the shared library linker")
+
+ -- save toolchains
+ _g.TOOLCHAINS = toolchains
+
+ -- ok
+ return toolchains
end
-- check it
-function main(kind)
+function main(kind, toolkind)
+
+ -- only check the given tool?
+ if toolkind then
+ return checker.toolchain_check(import("core.project." .. kind), toolkind, _toolchains)
+ end
-- init the check list of config
_g.config =
{
{ checker.check_arch, "i386" }
, checker.check_ccache
- , _check_toolchains
}
-- init the check list of global
diff --git a/xmake/platforms/watchos/check.lua b/xmake/platforms/watchos/check.lua
index 2475495bf..38963a4e6 100644
--- a/xmake/platforms/watchos/check.lua
+++ b/xmake/platforms/watchos/check.lua
@@ -40,8 +40,13 @@ function _check_as(shellname)
os.rm(tmpfile)
end
--- check the toolchains
-function _check_toolchains(config)
+-- get toolchains
+function _toolchains(config)
+
+ -- attempt to get it from cache first
+ if _g.TOOLCHAINS then
+ return _g.TOOLCHAINS
+ end
-- init architecture
local arch = config.get("arch")
@@ -50,38 +55,52 @@ function _check_toolchains(config)
-- init cross
local cross = ifelse(simulator, "xcrun -sdk watchsimulator ", "xcrun -sdk watchos ")
- -- check for c/c++ tools
- checker.check_toolchain(config, "cc", cross, "clang", "the c compiler")
- checker.check_toolchain(config, "cxx", cross, "clang", "the c++ compiler")
- checker.check_toolchain(config, "cxx", cross, "clang++", "the c++ compiler")
- checker.check_toolchain(config, "ld", cross, "clang++", "the linker")
- checker.check_toolchain(config, "ld", cross, "clang", "the linker")
- checker.check_toolchain(config, "ar", cross, "ar", "the static library archiver")
- checker.check_toolchain(config, "ex", cross, "ar", "the static library extractor")
- checker.check_toolchain(config, "sh", cross, "clang++", "the shared library linker")
- checker.check_toolchain(config, "sh", cross, "clang", "the shared library linker")
- checker.check_toolchain(config, "dg", cross, "lldb", "the debugger")
+ -- init toolchains
+ local toolchains = {}
+
+ -- insert c/c++ tools to toolchains
+ checker.toolchain_insert(toolchains, "cc", cross, "clang", "the c compiler")
+ checker.toolchain_insert(toolchains, "cxx", cross, "clang", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "cxx", cross, "clang++", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "ld", cross, "clang++", "the linker")
+ checker.toolchain_insert(toolchains, "ld", cross, "clang", "the linker")
+ checker.toolchain_insert(toolchains, "ar", cross, "ar", "the static library archiver")
+ checker.toolchain_insert(toolchains, "ex", cross, "ar", "the static library extractor")
+ checker.toolchain_insert(toolchains, "sh", cross, "clang++", "the shared library linker")
+ checker.toolchain_insert(toolchains, "sh", cross, "clang", "the shared library linker")
+ checker.toolchain_insert(toolchains, "dg", cross, "lldb", "the debugger")
+
+ -- insert objc/c++ tools to toolchains
+ checker.toolchain_insert(toolchains, "mm", cross, "clang", "the objc compiler")
+ checker.toolchain_insert(toolchains, "mxx", cross, "clang++", "the objc++ compiler")
+ checker.toolchain_insert(toolchains, "mxx", cross, "clang", "the objc++ compiler")
- -- check for objc/c++ tools
- checker.check_toolchain(config, "mm", cross, "clang", "the objc compiler")
- checker.check_toolchain(config, "mxx", cross, "clang++", "the objc++ compiler")
- checker.check_toolchain(config, "mxx", cross, "clang", "the objc++ compiler")
+ -- insert swift tools to toolchains
+ checker.toolchain_insert(toolchains, "sc", cross, "swiftc", "the swift compiler")
+ checker.toolchain_insert(toolchains, "sc-ld", cross, "swiftc", "the swift linker")
+ checker.toolchain_insert(toolchains, "sc-sh", cross, "swiftc", "the swift shared library linker")
- -- check for asm tools
+ -- insert asm tools to toolchains
if simulator then
- checker.check_toolchain(config, "as", cross, "clang", "the assember")
+ checker.toolchain_insert(toolchains, "as", cross, "clang", "the assember")
else
- checker.check_toolchain(config, "as", path.join(os.toolsdir(), "utils/gas-preprocessor.pl " .. cross), "clang", "the assember", _check_as)
+ checker.toolchain_insert(toolchains, "as", path.join(os.toolsdir(), "utils/gas-preprocessor.pl " .. cross), "clang", "the assember", _check_as)
end
- -- check for swift tools
- checker.check_toolchain(config, "sc", cross, "swiftc", "the swift compiler")
- checker.check_toolchain(config, "sc-ld", cross, "swiftc", "the swift linker")
- checker.check_toolchain(config, "sc-sh", cross, "swiftc", "the swift shared library linker")
+ -- save toolchains
+ _g.TOOLCHAINS = toolchains
+
+ -- ok
+ return toolchains
end
-- check it
-function main(kind)
+function main(kind, toolkind)
+
+ -- only check the given tool?
+ if toolkind then
+ return checker.toolchain_check(import("core.project." .. kind), toolkind, _toolchains)
+ end
-- init the check list of config
_g.config =
@@ -91,7 +110,6 @@ function main(kind)
, checker.check_xcode_sdkver
, checker.check_target_minver
, checker.check_ccache
- , _check_toolchains
}
-- init the check list of global
diff --git a/xmake/platforms/windows/check.lua b/xmake/platforms/windows/check.lua
index c1f335aba..9b4fb9770 100644
--- a/xmake/platforms/windows/check.lua
+++ b/xmake/platforms/windows/check.lua
@@ -199,62 +199,6 @@ function _check_vs(config)
end
end
--- check the toolchains
-function _check_toolchains(config)
-
- -- apply vs envirnoment (maybe config.arch has been updated)
- if not _apply_vsenv(config, config.get("vs")) then
- return
- end
-
- -- enter environment
- environment.enter("toolchains")
-
- -- check
- checker.check_toolchain(config, "cc", "", "cl.exe", "the c compiler")
- checker.check_toolchain(config, "cxx", "", "cl.exe", "the c++ compiler")
- checker.check_toolchain(config, "ld", "", "link.exe", "the linker")
- checker.check_toolchain(config, "ar", "", "link.exe -lib", "the static library archiver")
- checker.check_toolchain(config, "sh", "", "link.exe -dll", "the shared library linker")
- checker.check_toolchain(config, "ex", "", "lib.exe", "the static library extractor")
- if config.get("arch"):find("64") then
- checker.check_toolchain(config, "as", "", "ml64.exe", "the assember")
- else
- checker.check_toolchain(config, "as", "", "ml.exe", "the assember")
- end
-
- -- leave environment
- environment.leave("toolchains")
-
- -- check for golang tools
- checker.check_toolchain(config, "gc", "", "go", "the golang compiler")
- checker.check_toolchain(config, "gc", "", "gccgo", "the golang compiler")
- checker.check_toolchain(config, "gc-ar", "", "go", "the golang static library archiver")
- checker.check_toolchain(config, "gc-ar", "", "gccgo", "the golang static library archiver")
- checker.check_toolchain(config, "gc-ld", "", "go", "the golang linker")
- checker.check_toolchain(config, "gc-ld", "", "gccgo", "the golang linker")
-
- -- check for dlang tools
- checker.check_toolchain(config, "dc", "", "dmd", "the dlang compiler")
- checker.check_toolchain(config, "dc", "", "ldc2", "the dlang compiler")
- checker.check_toolchain(config, "dc", "", "gdc", "the dlang compiler")
- checker.check_toolchain(config, "dc-ar", "", "dmd", "the dlang static library archiver")
- checker.check_toolchain(config, "dc-ar", "", "ldc2", "the dlang static library archiver")
- checker.check_toolchain(config, "dc-ar", "", "gdc", "the dlang static library archiver")
- checker.check_toolchain(config, "dc-sh", "", "dmd", "the dlang shared library linker")
- checker.check_toolchain(config, "dc-sh", "", "ldc2", "the dlang shared library linker")
- checker.check_toolchain(config, "dc-sh", "", "gdc", "the dlang shared library linker")
- checker.check_toolchain(config, "dc-ld", "", "dmd", "the dlang linker")
- checker.check_toolchain(config, "dc-ld", "", "ldc2", "the dlang linker")
- checker.check_toolchain(config, "dc-ld", "", "gdc", "the dlang linker")
-
- -- check for rust tools
- checker.check_toolchain(config, "rc", "", "rustc", "the rust compiler")
- checker.check_toolchain(config, "rc-ar", "", "rustc", "the rust static library archiver")
- checker.check_toolchain(config, "rc-sh", "", "rustc", "the rust shared library linker")
- checker.check_toolchain(config, "rc-ld", "", "rustc", "the rust linker")
-end
-
-- check the debugger
function _check_debugger(config)
@@ -313,15 +257,91 @@ function _check_debugger(config)
end
end
+-- get toolchains
+function _toolchains(config)
+
+ -- attempt to get it from cache first
+ if _g.TOOLCHAINS then
+ return _g.TOOLCHAINS
+ end
+
+ -- apply vs envirnoment (maybe config.arch has been updated)
+ if not _apply_vsenv(config, config.get("vs")) then
+ return
+ end
+
+ -- init toolchains
+ local toolchains = {}
+
+ -- enter environment
+ environment.enter("toolchains")
+
+ -- insert c/c++ tools to toolchains
+ checker.toolchain_insert(toolchains, "cc", "", "cl.exe", "the c compiler")
+ checker.toolchain_insert(toolchains, "cxx", "", "cl.exe", "the c++ compiler")
+ checker.toolchain_insert(toolchains, "ld", "", "link.exe", "the linker")
+ checker.toolchain_insert(toolchains, "ar", "", "link.exe -lib", "the static library archiver")
+ checker.toolchain_insert(toolchains, "sh", "", "link.exe -dll", "the shared library linker")
+ checker.toolchain_insert(toolchains, "ex", "", "lib.exe", "the static library extractor")
+
+ -- insert asm tools to toolchains
+ if config.get("arch"):find("64") then
+ checker.toolchain_insert(toolchains, "as", "", "ml64.exe", "the assember")
+ else
+ checker.toolchain_insert(toolchains, "as", "", "ml.exe", "the assember")
+ end
+
+ -- leave environment
+ environment.leave("toolchains")
+
+ -- insert golang tools to toolchains
+ checker.toolchain_insert(toolchains, "gc", "", "go", "the golang compiler")
+ checker.toolchain_insert(toolchains, "gc", "", "gccgo", "the golang compiler")
+ checker.toolchain_insert(toolchains, "gc-ar", "", "go", "the golang static library archiver")
+ checker.toolchain_insert(toolchains, "gc-ar", "", "gccgo", "the golang static library archiver")
+ checker.toolchain_insert(toolchains, "gc-ld", "", "go", "the golang linker")
+ checker.toolchain_insert(toolchains, "gc-ld", "", "gccgo", "the golang linker")
+
+ -- insert dlang tools to toolchains
+ checker.toolchain_insert(toolchains, "dc", "", "dmd", "the dlang compiler")
+ checker.toolchain_insert(toolchains, "dc", "", "ldc2", "the dlang compiler")
+ checker.toolchain_insert(toolchains, "dc", "", "gdc", "the dlang compiler")
+ checker.toolchain_insert(toolchains, "dc-ar", "", "dmd", "the dlang static library archiver")
+ checker.toolchain_insert(toolchains, "dc-ar", "", "ldc2", "the dlang static library archiver")
+ checker.toolchain_insert(toolchains, "dc-ar", "", "gdc", "the dlang static library archiver")
+ checker.toolchain_insert(toolchains, "dc-sh", "", "dmd", "the dlang shared library linker")
+ checker.toolchain_insert(toolchains, "dc-sh", "", "ldc2", "the dlang shared library linker")
+ checker.toolchain_insert(toolchains, "dc-sh", "", "gdc", "the dlang shared library linker")
+ checker.toolchain_insert(toolchains, "dc-ld", "", "dmd", "the dlang linker")
+ checker.toolchain_insert(toolchains, "dc-ld", "", "ldc2", "the dlang linker")
+ checker.toolchain_insert(toolchains, "dc-ld", "", "gdc", "the dlang linker")
+
+ -- insert rust tools to toolchains
+ checker.toolchain_insert(toolchains, "rc", "", "rustc", "the rust compiler")
+ checker.toolchain_insert(toolchains, "rc-ar", "", "rustc", "the rust static library archiver")
+ checker.toolchain_insert(toolchains, "rc-sh", "", "rustc", "the rust shared library linker")
+ checker.toolchain_insert(toolchains, "rc-ld", "", "rustc", "the rust linker")
+
+ -- save toolchains
+ _g.TOOLCHAINS = toolchains
+
+ -- ok
+ return toolchains
+end
+
-- check it
-function main(kind)
+function main(kind, toolkind)
+
+ -- only check the given tool?
+ if toolkind then
+ return checker.toolchain_check(import("core.project." .. kind), toolkind, _toolchains)
+ end
-- init the check list of config
_g.config =
{
{ checker.check_arch, "x86" }
, _check_vs
- , _check_toolchains
, _check_debugger
}