summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-02-22 21:42:25 +0800
committerruki <[email protected]>2017-02-22 21:42:25 +0800
commitb69ebb909d9f62f1300d75067938e98d4d7ae36a (patch)
tree20ee05babd6bc9a700f2264ac7b46857922d9604
parent28519b50187de9a1f69900c8ab58c73e3a54707c (diff)
improve check for macosx
-rw-r--r--xmake/core/tool/tool.lua11
-rw-r--r--xmake/platforms/checker.lua16
-rw-r--r--xmake/platforms/macosx/check.lua106
3 files changed, 61 insertions, 72 deletions
diff --git a/xmake/core/tool/tool.lua b/xmake/core/tool/tool.lua
index a873cc0ba..d73ccfb13 100644
--- a/xmake/core/tool/tool.lua
+++ b/xmake/core/tool/tool.lua
@@ -246,8 +246,16 @@ function tool.check(shellname, dirs, check)
-- check
assert(shellname)
- -- attempt to check it directly first
+ -- attempt to get result from cache first
+ tool._CHECKINFO = tool._CHECKINFO or {}
+ local result = tool._CHECKINFO[shellname]
+ if result then
+ return result
+ end
+
+ -- attempt to check it directly
if tool._check(shellname, check) then
+ tool._CHECKINFO[shellname] = shellname
return shellname
end
@@ -261,6 +269,7 @@ function tool.check(shellname, dirs, check)
-- check it
if tool._check(toolpath, check) then
+ tool._CHECKINFO[shellname] = toolpath
return toolpath
end
end
diff --git a/xmake/platforms/checker.lua b/xmake/platforms/checker.lua
index 0f0a2fbb3..e6a4ce268 100644
--- a/xmake/platforms/checker.lua
+++ b/xmake/platforms/checker.lua
@@ -210,6 +210,12 @@ function check_toolchain(config, kind, cross, name, description, check)
local toolpath = config.get(kind)
if not toolpath then
+ -- get shell name from the env
+ local shellname = os.getenv(kind:upper())
+ if shellname and shellname:trim() ~= "" then
+ toolpath = tool.check(shellname)
+ end
+
-- get the cross
cross = config.get("cross") or cross
@@ -239,22 +245,26 @@ function check_toolchain(config, kind, cross, name, description, check)
end
end
- -- attempt to get it from the given cross toolchains
+ -- attempt to check it from the given cross toolchains
if not toolpath and toolchains then
toolpath = tool.check(cross .. name, toolchains)
end
- -- attempt to run it directly
+ -- 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(kind, toolpath)
-
end
-- trace
diff --git a/xmake/platforms/macosx/check.lua b/xmake/platforms/macosx/check.lua
index bd8cd86f3..abde4ca4f 100644
--- a/xmake/platforms/macosx/check.lua
+++ b/xmake/platforms/macosx/check.lua
@@ -29,82 +29,52 @@ import("platforms.checker", {rootdir = os.programdir()})
-- check the toolchains
function _check_toolchains(config)
- -- check from env
- checker.check_toolchain_from_env(config, "cc", "CC", "the c compiler")
- checker.check_toolchain_from_env(config, "cxx", "CXX", "the c++ compiler")
- checker.check_toolchain_from_env(config, "mm", "MM", "the objc compiler")
- checker.check_toolchain_from_env(config, "mxx", "MXX", "the objc++ compiler")
- checker.check_toolchain_from_env(config, "sc", "SC", "the swift compiler")
- checker.check_toolchain_from_env(config, "as", "AS", "the assember")
- checker.check_toolchain_from_env(config, "ld", "LD", "the linker")
- checker.check_toolchain_from_env(config, "ar", "AR", "the static library archiver")
- checker.check_toolchain_from_env(config, "ex", "AR", "the static library extractor")
- checker.check_toolchain_from_env(config, "sh", "SH", "the shared library linker")
+ -- 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")
- -- check with xcrun
- 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, "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")
- checker.check_toolchain(config, "as", "xcrun -sdk macosx ", "clang", "the assember")
- 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")
+ -- 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")
- -- check without xcrun
- checker.check_toolchain(config, "cc", "", "clang", "the c compiler")
- checker.check_toolchain(config, "cxx", "", "clang", "the c++ compiler")
- checker.check_toolchain(config, "cxx", "", "clang++", "the c++ compiler")
- checker.check_toolchain(config, "mm", "", "clang", "the objc compiler")
- checker.check_toolchain(config, "mxx", "", "clang++", "the objc++ compiler")
- checker.check_toolchain(config, "mxx", "", "clang", "the objc++ compiler")
- checker.check_toolchain(config, "as", "", "clang", "the assember")
- checker.check_toolchain(config, "ld", "", "clang++", "the linker")
- checker.check_toolchain(config, "ld", "", "clang", "the linker")
- checker.check_toolchain(config, "ar", "", "ar", "the static library archiver")
- checker.check_toolchain(config, "ex", "", "ar", "the static library extractor")
- checker.check_toolchain(config, "sh", "", "clang++", "the shared library linker")
- checker.check_toolchain(config, "sh", "", "clang", "the shared library linker")
- checker.check_toolchain(config, "dg", "", "lldb", "the debugger")
+ -- check for asm tools
+ checker.check_toolchain(config, "as", "xcrun -sdk macosx ", "clang", "the assember")
-- check for swift tools
- checker.check_toolchain_from_env(config, "sc", "SC", "the swift compiler")
- checker.check_toolchain(config, "sc", "xcrun -sdk macosx ", "swiftc", "the swift compiler")
- checker.check_toolchain(config, "sc", "", "swiftc", "the swift compiler")
- checker.check_toolchain_from_env(config, "sc-ld", "SC", "the swift linker")
- checker.check_toolchain(config, "sc-ld", "xcrun -sdk macosx ", "swiftc", "the swift linker")
- checker.check_toolchain(config, "sc-ld", "", "swiftc", "the swift linker")
- checker.check_toolchain_from_env(config, "sc-sh", "SC", "the swift shared library linker")
- checker.check_toolchain(config, "sc-sh", "xcrun -sdk macosx ", "swiftc", "the swift shared library linker")
- checker.check_toolchain(config, "sc-sh", "", "swiftc", "the swift shared library linker")
+ 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")
-- check for golang tools
- checker.check_toolchain(config, "go", "", "go", "the golang compiler")
- checker.check_toolchain(config, "go", "", "gccgo", "the golang compiler")
- checker.check_toolchain(config, "go-ar", "", "go", "the golang static library archiver")
- checker.check_toolchain(config, "go-ar", "", "gccgo", "the golang static library archiver")
- checker.check_toolchain(config, "go-ld", "", "go", "the golang linker")
- checker.check_toolchain(config, "go-ld", "", "gccgo", "the golang linker")
+ checker.check_toolchain(config, "go", "", "go", "the golang compiler")
+ checker.check_toolchain(config, "go", "", "gccgo", "the golang compiler")
+ checker.check_toolchain(config, "go-ar", "", "go", "the golang static library archiver")
+ checker.check_toolchain(config, "go-ar", "", "gccgo", "the golang static library archiver")
+ checker.check_toolchain(config, "go-ld", "", "go", "the golang linker")
+ checker.check_toolchain(config, "go-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")
+ 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")
end
-- check it