summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-06-20 21:32:31 +0800
committerruki <[email protected]>2020-06-20 21:32:31 +0800
commit17561f833fe7dba0721cfd8f48a88213867231a0 (patch)
tree81979aa293c29499146a8aa4f5cac90d348ef733
parent9952e551b93d71d5428dc99633fb770d8e0636f4 (diff)
fix check features
-rw-r--r--xmake/core/sandbox/modules/import/core/tool/compiler.lua4
-rw-r--r--xmake/core/tool/builder.lua10
-rw-r--r--xmake/modules/detect/tools/cl/features.lua7
-rw-r--r--xmake/modules/lib/detect/features.lua2
4 files changed, 16 insertions, 7 deletions
diff --git a/xmake/core/sandbox/modules/import/core/tool/compiler.lua b/xmake/core/sandbox/modules/import/core/tool/compiler.lua
index 0fdeb3124..9cab2b54d 100644
--- a/xmake/core/sandbox/modules/import/core/tool/compiler.lua
+++ b/xmake/core/sandbox/modules/import/core/tool/compiler.lua
@@ -194,7 +194,7 @@ function sandbox_core_tool_compiler.features(langkind, opt)
local flags = instance:compflags(opt)
-- get features
- local ok, results_or_errors = sandbox.load(sandbox_core_tool_compiler._features, instance:name(), {flags = flags, program = instance:program()})
+ local ok, results_or_errors = sandbox.load(sandbox_core_tool_compiler._features, instance:name(), {flags = flags, program = instance:program(), envs = instance:runenvs()})
if not ok then
raise(results_or_errors)
end
@@ -257,7 +257,7 @@ function sandbox_core_tool_compiler.has_features(features, opt)
local flags = instance:compflags(opt)
-- has features?
- local ok, results_or_errors = sandbox.load(sandbox_core_tool_compiler._has_features, instance:name(), features, {flags = flags, program = instance:program()})
+ local ok, results_or_errors = sandbox.load(sandbox_core_tool_compiler._has_features, instance:name(), features, {flags = flags, program = instance:program(), envs = instance:runenvs()})
if not ok then
raise(results_or_errors)
end
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua
index 03a9f34ed..d8a01ba2a 100644
--- a/xmake/core/tool/builder.lua
+++ b/xmake/core/tool/builder.lua
@@ -383,6 +383,16 @@ function builder:program()
return self:_tool():program()
end
+-- get toolchain of this tool
+function builder:toolchain()
+ return self:_tool():toolchain()
+end
+
+-- get the run environments
+function builder:runenvs()
+ return self:_tool():runenvs()
+end
+
-- get properties of the tool
function builder:get(name)
return self:_tool():get(name)
diff --git a/xmake/modules/detect/tools/cl/features.lua b/xmake/modules/detect/tools/cl/features.lua
index 976085659..fb4c98cca 100644
--- a/xmake/modules/detect/tools/cl/features.lua
+++ b/xmake/modules/detect/tools/cl/features.lua
@@ -36,8 +36,8 @@ function _get_macro_defines(snippets, extension, opt)
local defines = try
{
function ()
- os.runv(opt.program, table.join(opt.flags or {}, {"-nologo", "-Fo" .. objectfile, sourcefile, "-link", "-out:" .. binaryfile}))
- return os.iorunv(binaryfile)
+ os.runv(opt.program, table.join(opt.flags or {}, {"-nologo", "-Fo" .. objectfile, sourcefile, "-link", "-out:" .. binaryfile}), {envs = opt.envs})
+ return os.iorunv(binaryfile, {}, {envs = opt.envs})
end
}
if defines then
@@ -50,8 +50,6 @@ function _get_macro_defines(snippets, extension, opt)
os.tryrm(sourcefile)
os.tryrm(objectfile)
os.tryrm(binaryfile)
-
- -- ok?
return results
end
@@ -97,6 +95,7 @@ end
function check_features(opt)
-- check features with all extensions
+ opt = opt or {}
local results = {}
for extension, features in pairs(_g.features) do
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)