diff options
| -rw-r--r-- | tests/projects/wdk/umdf/echo/xmake.lua | 1 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 61 | ||||
| -rw-r--r-- | xmake/rules/wdk/load.lua | 6 |
3 files changed, 58 insertions, 10 deletions
diff --git a/tests/projects/wdk/umdf/echo/xmake.lua b/tests/projects/wdk/umdf/echo/xmake.lua index e946a868f..143b3491a 100644 --- a/tests/projects/wdk/umdf/echo/xmake.lua +++ b/tests/projects/wdk/umdf/echo/xmake.lua @@ -7,7 +7,6 @@ add_defines("_UNICODE", "UNICODE") -- add target target("echo") - set_default(false) -- add rules add_rules("wdk.umdf.driver") diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 722516bb6..09d0a8ada 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -147,13 +147,37 @@ end -- set the value to the target info function target:set(name_or_info, ...) + + -- set values to the given key? if type(name_or_info) == "string" then - local args = ... - if args ~= nil then - self._INFO[name_or_info] = table.unwrap(table.unique(table.join(...))) + + -- get extra config + local values = {...} + local extra_config = values[#values] + if table.is_dictionary(extra_config) then + table.remove(values) + else + extra_config = nil + end + + -- set values + local name = name_or_info + if #values > 0 then + self._INFO[name] = table.unwrap(table.unique(values)) else - self._INFO[name_or_info] = nil + self._INFO[name] = nil end + + -- save extra config + if extra_config then + self._INFO["__extra_" .. name] = self._INFO["__extra_" .. name] or {} + local extrascope = self._INFO["__extra_" .. name] + for _, value in ipairs(values) do + extrascope[value] = extra_config + end + end + + -- set a dictionary values elseif table.is_dictionary(name_or_info) then for name, info in pairs(table.join(name_or_info, ...)) do self:set(name, info) @@ -163,9 +187,34 @@ end -- add the value to the target info function target:add(name_or_info, ...) + + -- add values to the given key? if type(name_or_info) == "string" then - local info = table.wrap(self._INFO[name_or_info]) - self._INFO[name_or_info] = table.unwrap(table.unique(table.join(info, ...))) + + -- get extra config + local values = {...} + local extra_config = values[#values] + if table.is_dictionary(extra_config) then + table.remove(values) + else + extra_config = nil + end + + -- add values + local name = name_or_info + local info = table.wrap(self._INFO[name]) + self._INFO[name] = table.unwrap(table.unique(table.join(info, values))) + + -- save extra config + if extra_config then + self._INFO["__extra_" .. name] = self._INFO["__extra_" .. name] or {} + local extrascope = self._INFO["__extra_" .. name] + for _, value in ipairs(values) do + extrascope[value] = extra_config + end + end + + -- add a dictionary values elseif table.is_dictionary(name_or_info) then for name, info in pairs(table.join(name_or_info, ...)) do self:add(name, info) diff --git a/xmake/rules/wdk/load.lua b/xmake/rules/wdk/load.lua index cce968f3e..0a1bee1d2 100644 --- a/xmake/rules/wdk/load.lua +++ b/xmake/rules/wdk/load.lua @@ -55,7 +55,7 @@ function _load_for_umdf(target, wdk, arch, kind) target:add("links", "WdfDriverStubUm") end target:add("links", "ntdll", "OneCoreUAP", "mincore", "ucrt") - target:add("ldflags", "-NODEFAULTLIB:kernel32.lib", "-NODEFAULTLIB:user32.lib", "-NODEFAULTLIB:libucrt.lib") + target:add("ldflags", "-NODEFAULTLIB:kernel32.lib", "-NODEFAULTLIB:user32.lib", "-NODEFAULTLIB:libucrt.lib", {force = true}) end -- load for kmdf @@ -81,11 +81,11 @@ function main(target, opt) -- load for umdf if opt.mode == "umdf" then - _load_for_umdf(target, wdk, arch, kind) + _load_for_umdf(target, wdk, arch, opt.kind) end -- load for kmdf if opt.mode == "kmdf" then - _load_for_kmdf(target, wdk, arch, kind) + _load_for_kmdf(target, wdk, arch, opt.kind) end end |
