summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-11-19 22:36:05 +0800
committerruki <[email protected]>2020-11-19 22:36:05 +0800
commit845936d08ddbf9d0c6c9ba98292de92a1f2e7875 (patch)
tree7dc7eca79c8bb22b9a00b895f2d30c77ea9ea68a
parent31248cdb8ff9a40e6662d6b2793cdfbad4599f78 (diff)
improve set_symbols for msvc
-rw-r--r--xmake/core/tool/builder.lua36
-rw-r--r--xmake/modules/core/tools/cl.lua33
2 files changed, 44 insertions, 25 deletions
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua
index 6ebff1861..6b9aec322 100644
--- a/xmake/core/tool/builder.lua
+++ b/xmake/core/tool/builder.lua
@@ -318,7 +318,7 @@ function builder:_add_flags_from_language(flags, target, getters)
-- get api name of tool
--
- -- ignore "nf_" and "_if_ok"
+ -- ignore "nf_" and "_if_ok" (deprecated)
--
-- e.g.
--
@@ -326,22 +326,34 @@ function builder:_add_flags_from_language(flags, target, getters)
-- defines_if_ok => define
-- ...
--
- local apiname = flagname:gsub("^nf_", ""):gsub("_if_ok$", "")
+ local apiname = flagname:gsub("^nf_", ""):gsub("_if_ok$", "")
+
+ -- use multiple values mapper if be defined in tool module
+ local multival = false
if apiname:endswith("s") then
- apiname = apiname:sub(1, #apiname - 1)
+ if self:_tool()["nf_" .. apiname] then
+ multival = true
+ else
+ apiname = apiname:sub(1, #apiname - 1)
+ end
end
- -- map name flag to real flag
+ -- map named flags to real flags
local mapper = self:_tool()["nf_" .. apiname]
if mapper then
-
- -- add the flags
- for _, flagvalue in ipairs(table.wrap(getter(flagname))) do
-
- -- map and check flag
- local flag = mapper(self:_tool(), flagvalue, target, self:_targetkind())
- if flag and flag ~= "" and (not checkstate or self:has_flags(flag)) then
- table.join2(flags, flag)
+ if multival then
+ local results = mapper(self:_tool(), table.wrap(getter(flagname)), target, self:_targetkind())
+ for _, flag in ipairs(table.wrap(results)) do
+ if flag and flag ~= "" and (not checkstate or self:has_flags(flag)) then
+ table.join2(flags, flag)
+ end
+ end
+ else
+ for _, flagvalue in ipairs(table.wrap(getter(flagname))) do
+ local flag = mapper(self:_tool(), flagvalue, target, self:_targetkind())
+ if flag and flag ~= "" and (not checkstate or self:has_flags(flag)) then
+ table.join2(flags, flag)
+ end
end
end
end
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index f5fac3cb2..0db8df367 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -21,6 +21,7 @@
-- imports
import("core.base.option")
import("core.base.global")
+import("core.base.hashset")
import("core.project.project")
import("core.language.language")
import("private.tools.vstool")
@@ -88,14 +89,23 @@ function init(self)
})
end
--- make the symbol flag
-function nf_symbol(self, level, target)
-
- -- debug? generate *.pdb file
+-- make the symbol flags
+function nf_symbols(self, levels, target)
local flags = nil
- if level == "debug" then
+ local values = hashset.from(levels)
+ if values:has("debug") then
+ flags = {}
+ if values:has("edit") then
+ table.insert(flags, "-ZI")
+ elseif values:has("embed") then
+ table.insert(flags, "-Z7")
+ else
+ table.insert(flags, "-Zi")
+ end
+
+ -- generate *.pdb file
local symbolfile = nil
- if target and target.symbolfile then
+ if target and target.symbolfile and not values:has("embed") then
symbolfile = target:symbolfile()
end
if symbolfile then
@@ -107,16 +117,13 @@ function nf_symbol(self, level, target)
end
-- check and add symbol output file
- flags = "-Zi -Fd" .. path.join(symboldir, "compile." .. path.filename(symbolfile))
- if self:has_flags({"-Zi", "-FS", "-Fd" .. os.nuldev() .. ".pdb"}, "cxflags", { flagskey = "-Zi -FS -Fd" }) then
- flags = "-FS " .. flags
+ local pdbflags = "-Fd" .. path.join(symboldir, "compile." .. path.filename(symbolfile))
+ if self:has_flags({"-FS", "-Fd" .. os.nuldev() .. ".pdb"}, "cxflags", { flagskey = "-FS -Fd" }) then
+ pdbflags = {"-FS", pdbflags}
end
- else
- flags = "-Zi"
+ table.join2(flags, pdbflags)
end
end
-
- -- none
return flags
end