summaryrefslogtreecommitdiff
path: root/xmake/modules/lib
diff options
context:
space:
mode:
authorruki <[email protected]>2020-06-23 22:37:44 +0800
committerGitHub <[email protected]>2020-06-23 22:37:44 +0800
commitc18d15eb89116a0f3ce96bd56f3ccf861849f6ec (patch)
tree52b63db3274349f9a41872414208c7c30058cfd7 /xmake/modules/lib
parent53df324acd9c7432336a5894ceef578daa1ce38d (diff)
parent18bded45c229f5580c13fc8b4afc5edb6f18819a (diff)
Merge pull request #857 from xmake-io/toolchain
Improve toolchain to support host and cross toolchains at same time
Diffstat (limited to 'xmake/modules/lib')
-rw-r--r--xmake/modules/lib/detect/features.lua2
-rw-r--r--xmake/modules/lib/detect/find_tool.lua2
-rw-r--r--xmake/modules/lib/detect/has_flags.lua6
3 files changed, 5 insertions, 5 deletions
diff --git a/xmake/modules/lib/detect/features.lua b/xmake/modules/lib/detect/features.lua
index 048ee85a6..9146e5da6 100644
--- a/xmake/modules/lib/detect/features.lua
+++ b/xmake/modules/lib/detect/features.lua
@@ -32,7 +32,7 @@ import("core.base.scheduler")
-- @code
-- local features = features("clang")
-- local features = features("clang", {flags = "-O0", program = "xcrun -sdk macosx clang"})
--- local features = features("clang", {flags = {"-g", "-O0"}})
+-- local features = features("clang", {flags = {"-g", "-O0"}, envs = {PATH = ""}})
-- @endcode
--
function main(name, opt)
diff --git a/xmake/modules/lib/detect/find_tool.lua b/xmake/modules/lib/detect/find_tool.lua
index 7e40c0b0e..83f543ebf 100644
--- a/xmake/modules/lib/detect/find_tool.lua
+++ b/xmake/modules/lib/detect/find_tool.lua
@@ -41,7 +41,7 @@ end
-- @param name the tool name
-- @param opt the options, e.g. {program = "xcrun -sdk macosx clang", pathes = {"/usr/bin"},
-- check = function (tool) os.run("%s -h", tool) end, version = true
--- force = true, cachekey = "xxx"}
+-- force = true, cachekey = "xxx", envs = {PATH = "xxx"}}
--
-- @return {name = "", program = "", version = ""} or nil
--
diff --git a/xmake/modules/lib/detect/has_flags.lua b/xmake/modules/lib/detect/has_flags.lua
index 833bbcf65..4e4f3535a 100644
--- a/xmake/modules/lib/detect/has_flags.lua
+++ b/xmake/modules/lib/detect/has_flags.lua
@@ -62,14 +62,14 @@ function main(name, flags, opt)
opt.programver = tool.version
-- get tool platform
- local plat = config.get("plat") or os.host()
+ local plat = opt.plat or config.get("plat") or os.host()
-- get tool architecture
--
-- some tools select arch by path environment, not be flags, e.g. cl.exe of msvc)
-- so, it will affect the cache result
--
- local arch = config.get("arch") or os.arch()
+ local arch = opt.arch or config.get("arch") or os.arch()
-- init cache key
local key = plat .. "_" .. arch .. "_" .. tool.program .. "_" .. (tool.version or "") .. "_" .. (opt.toolkind or "") .. "_" .. (opt.flagkind or "") .. "_" .. table.concat(opt.sysflags, " ") .. "_" .. opt.flagskey
@@ -113,7 +113,7 @@ function main(name, flags, opt)
if hasflags then
result, errors = hasflags(checkflags, opt)
else
- result = try { function () os.runv(tool.program, checkflags); return true end, catch { function (errs) errors = errs end }}
+ result = try { function () os.runv(tool.program, checkflags, {envs = opt.envs}); return true end, catch { function (errs) errors = errs end }}
end
_g._checking = nil
result = result or false