diff options
| author | ruki <[email protected]> | 2023-08-28 09:04:33 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-08-28 09:04:33 +0800 |
| commit | a0e464bebf1ddd493ca33d381da399b12dfc8358 (patch) | |
| tree | d758fde0f00727ce9e664f7fa90a9ae2ea63ea50 | |
| parent | 2c894cb2c8062e6291d0b2fc4dafebef018f8003 (diff) | |
| parent | c682992ea53d296667953314ada87ddaf8584f30 (diff) | |
Merge pull request #4129 from xmake-io/emcc
improve the ignored configs for buildhash
| -rw-r--r-- | xmake/core/package/package.lua | 53 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/package.lua | 7 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/utils/requirekey.lua | 5 | ||||
| -rw-r--r-- | xmake/toolchains/emcc/xmake.lua | 2 |
4 files changed, 50 insertions, 17 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 36a9aba9f..b15651ef7 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -1327,9 +1327,44 @@ 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 - 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 + else + configs = false + end + self._CONFIGS = configs + end + return configs and configs or nil +end + +-- get the given configuration value of package for buildhash +function _instance:_config_for_buildhash(name) + local value + local configs = self:_configs_for_buildhash() + if configs then + value = configs[name] + end + return value +end + +-- get the configurations of package for buildhash +-- @note on_test still need these configs +function _instance:_configs_for_buildhash() + local configs = self._CONFIGS_FOR_BUILDHASH + if configs == nil then + local configs_defined = self:get("configs") + if configs_defined then + configs = {} + local requireinfo = self:requireinfo() + local configs_required = requireinfo and requireinfo.configs or {} + local ignored_configs_for_buildhash = hashset.from(requireinfo and requireinfo.ignored_configs_for_buildhash or {}) + for _, name in ipairs(table.wrap(configs_defined)) do + if not ignored_configs_for_buildhash:has(name) then local value = configs_required[name] if value == nil then value = self:extraconf("configs", name, "default") @@ -1340,7 +1375,7 @@ function _instance:configs() else configs = false end - self._CONFIGS = configs + self._CONFIGS_FOR_BUILDHASH = configs end return configs and configs or nil end @@ -1388,7 +1423,7 @@ function _instance:buildhash() str = str .. "_" .. table.concat(hashs, "_") end end - local toolchains = self:config("toolchains") + local toolchains = self:_config_for_buildhash("toolchains") if opt.toolchains ~= false and toolchains then toolchains = table.copy(table.wrap(toolchains)) table.sort(toolchains) @@ -1407,8 +1442,8 @@ function _instance:buildhash() -- we need to be compatible with the hash value string for the previous xmake version -- without builtin pic configuration (< 2.5.1). - if self:config("pic") then - local configs = table.copy(self:configs()) + if self:_config_for_buildhash("pic") then + local configs = table.copy(self:_configs_for_buildhash()) configs.pic = nil buildhash = _get_buildhash(configs, {sourcehash = false, toolchains = false}) if not os.isdir(_get_installdir(buildhash)) then @@ -1419,7 +1454,7 @@ function _instance:buildhash() -- we need to be compatible with the hash value string for the previous xmake version -- without sourcehash (< 2.5.2) if not buildhash then - buildhash = _get_buildhash(self:configs(), {sourcehash = false, toolchains = false}) + buildhash = _get_buildhash(self:_configs_for_buildhash(), {sourcehash = false, toolchains = false}) if not os.isdir(_get_installdir(buildhash)) then buildhash = nil end @@ -1428,7 +1463,7 @@ function _instance:buildhash() -- we need to be compatible with the previous xmake version -- without toolchains (< 2.6.4) if not buildhash then - buildhash = _get_buildhash(self:configs(), {toolchains = false}) + buildhash = _get_buildhash(self:_configs_for_buildhash(), {toolchains = false}) if not os.isdir(_get_installdir(buildhash)) then buildhash = nil end @@ -1436,7 +1471,7 @@ function _instance:buildhash() -- get build hash for current version if not buildhash then - buildhash = _get_buildhash(self:configs()) + buildhash = _get_buildhash(self:_configs_for_buildhash()) end self._BUILDHASH = buildhash end diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index 4a94677b4..77b4abbd0 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -502,8 +502,9 @@ function _init_requireinfo(requireinfo, package, opt) requireinfo.configs.lto = requireinfo.configs.lto or project.policy("build.optimization.lto") end -- but we will ignore some configs for buildhash in the headeronly and host/binary package + -- @note on_test still need these configs, @see https://github.com/xmake-io/xmake/issues/4124 if package:is_headeronly() or (package:is_binary() and not package:is_cross()) then - requireinfo.ignored_configs = {"vs_runtime", "toolchains", "lto", "pic"} + requireinfo.ignored_configs_for_buildhash = {"vs_runtime", "toolchains", "lto", "pic"} end end @@ -1151,9 +1152,9 @@ function get_configs_str(package) if requireinfo.kind then table.insert(configs, requireinfo.kind) end - local ignored_configs = hashset.from(requireinfo.ignored_configs or {}) + local ignored_configs_for_buildhash = hashset.from(requireinfo.ignored_configs_for_buildhash or {}) for k, v in pairs(requireinfo.configs) do - if not ignored_configs:has(k) then + if not ignored_configs_for_buildhash:has(k) then if type(v) == "boolean" then table.insert(configs, k .. ":" .. (v and "y" or "n")) else diff --git a/xmake/modules/private/action/require/impl/utils/requirekey.lua b/xmake/modules/private/action/require/impl/utils/requirekey.lua index e44679f92..45adac2b4 100644 --- a/xmake/modules/private/action/require/impl/utils/requirekey.lua +++ b/xmake/modules/private/action/require/impl/utils/requirekey.lua @@ -52,14 +52,11 @@ 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 - if not ignored_configs:has(k) then - table.insert(configs_order, k .. "=" .. tostring(v)) - end + table.insert(configs_order, k .. "=" .. tostring(v)) end table.sort(configs_order) key = key .. ":" .. string.serialize(configs_order, true) diff --git a/xmake/toolchains/emcc/xmake.lua b/xmake/toolchains/emcc/xmake.lua index cd7d1ad62..b95e67145 100644 --- a/xmake/toolchains/emcc/xmake.lua +++ b/xmake/toolchains/emcc/xmake.lua @@ -45,7 +45,7 @@ toolchain("emcc") toolchain:config_set("bindir", emsdk.emscripten) toolchain:config_set("sdkdir", emsdk.sdkdir) toolchain:configs_save() - return emcc + return emsdk end end end |
