summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-08-19 22:33:37 +0800
committerruki <[email protected]>2022-08-19 22:33:37 +0800
commita76bf73ea702886e85f8c2e61e62aa73b4c9e072 (patch)
tree52d4e91e86be7d9f28070f1ccb42fcfd370f7ba3
parent3c54402ff5d8c8cb2e085a09cd1fc4c10297817e (diff)
improve require configs for headeronly
-rw-r--r--xmake/core/package/package.lua11
-rw-r--r--xmake/modules/private/action/require/impl/package.lua23
-rw-r--r--xmake/modules/private/action/require/impl/utils/requirekey.lua8
3 files changed, 27 insertions, 15 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 11db68e0d..75946c3ec 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -1160,12 +1160,15 @@ function _instance:configs()
configs = {}
local requireinfo = self:requireinfo()
local configs_required = requireinfo and requireinfo.configs or {}
+ local ignored_configs = hashset.from(requireinfo and requireinfo.ignored_configs or {})
for _, name in ipairs(table.wrap(configs_defined)) do
- local value = configs_required[name]
- if value == nil then
- value = self:extraconf("configs", name, "default")
+ if not ignored_configs:has(name) then
+ local value = configs_required[name]
+ if value == nil then
+ value = self:extraconf("configs", name, "default")
+ end
+ configs[name] = value
end
- configs[name] = value
end
else
configs = false
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index e90922171..afe0ded1d 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -468,7 +468,6 @@ function _init_requireinfo(requireinfo, package, opt)
requireinfo.is_toplevel = true
-- we always pass some configurations from toplevel even it's headeronly, because it's library deps need inherit them
- -- but we will reset it for headeronly package after finishing requireinfo
-- @see https://github.com/xmake-io/xmake/issues/2688
if package:is_library() then
requireinfo.configs.toolchains = requireinfo.configs.toolchains or project.get("target.toolchains")
@@ -481,17 +480,18 @@ function _init_requireinfo(requireinfo, package, opt)
requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or get_config("vs_runtime")
end
requireinfo.configs.lto = requireinfo.configs.lto or project.policy("build.optimization.lto")
+
+ -- but we will ignore some configs for buildhash in the headeronly package
+ if package:is_headeronly() then
+ requireinfo.ignored_configs = {"vs_runtime", "toolchains", "lto", "pic"}
+ end
end
end
-- finish requireinfo
function _finish_requireinfo(requireinfo, package)
requireinfo.configs = requireinfo.configs or {}
- if package:is_headeronly() then
- requireinfo.configs.vs_runtime = nil
- requireinfo.configs.toolchains = nil
- requireinfo.configs.lto = nil
- else
+ if not package:is_headeronly() then
if requireinfo.configs.vs_runtime == nil and package:is_plat("windows") then
requireinfo.configs.vs_runtime = "MT"
end
@@ -1012,11 +1012,14 @@ function get_configs_str(package)
if requireinfo.kind then
table.insert(configs, requireinfo.kind)
end
+ local ignored_configs = hashset.from(requireinfo.ignored_configs or {})
for k, v in pairs(requireinfo.configs) do
- if type(v) == "boolean" then
- table.insert(configs, k .. ":" .. (v and "y" or "n"))
- else
- table.insert(configs, k .. ":" .. string.serialize(v, {strip = true, indent = false}))
+ if not ignored_configs:has(k) then
+ if type(v) == "boolean" then
+ table.insert(configs, k .. ":" .. (v and "y" or "n"))
+ else
+ table.insert(configs, k .. ":" .. string.serialize(v, {strip = true, indent = false}))
+ end
end
end
end
diff --git a/xmake/modules/private/action/require/impl/utils/requirekey.lua b/xmake/modules/private/action/require/impl/utils/requirekey.lua
index cede66d30..41f64fa44 100644
--- a/xmake/modules/private/action/require/impl/utils/requirekey.lua
+++ b/xmake/modules/private/action/require/impl/utils/requirekey.lua
@@ -18,6 +18,9 @@
-- @file requirekey.lua
--
+-- imports
+import("core.base.hashset")
+
-- get require key from requireinfo
function main(requireinfo, opt)
opt = opt or {}
@@ -46,11 +49,14 @@ function main(requireinfo, opt)
if key:startswith("/") then
key = key:sub(2)
end
+ local ignored_configs = hashset.from(requireinfo.ignored_configs or {})
local configs = requireinfo.configs
if configs then
local configs_order = {}
for k, v in pairs(configs) do
- table.insert(configs_order, k .. "=" .. tostring(v))
+ if not ignored_configs:has(k) then
+ table.insert(configs_order, k .. "=" .. tostring(v))
+ end
end
table.sort(configs_order)
key = key .. ":" .. string.serialize(configs_order, true)