diff options
| author | ruki <[email protected]> | 2024-01-26 23:46:36 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-01-26 23:46:36 +0800 |
| commit | 2a43a89241ff5044661fa7449d6455386cd3a449 (patch) | |
| tree | 1bc2de8cabea8dad373b9bc916156d9e322d4831 | |
| parent | 647e8c36c5d54635df12666f3a0bc45b45084389 (diff) | |
select runtimes for buildhash
| -rw-r--r-- | xmake/core/package/package.lua | 31 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/package.lua | 37 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/xmake.lua | 11 |
3 files changed, 53 insertions, 26 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 870fa63d5..5f9524019 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -1136,23 +1136,7 @@ function _instance:runtimes() if runtimes == nil then runtimes = self:config("runtimes") if runtimes then - local runtimes_supported = hashset.new() - local toolchains = self:toolchains() or platform.load(self:plat(), self:arch()):toolchains() - if toolchains then - for _, toolchain_inst in ipairs(toolchains) do - if toolchain_inst:is_standalone() and toolchain_inst:get("runtimes") then - for _, runtime in ipairs(table.wrap(toolchain_inst:get("runtimes"))) do - runtimes_supported:insert(runtime) - end - end - end - end - local runtimes_current = {} - for _, runtime in ipairs(table.wrap(runtimes:split(",", {plain = true}))) do - if runtimes_supported:has(runtime) then - table.insert(runtimes_current, runtime) - end - end + local runtimes_current = runtimes:split(",", {plain = true}) runtimes = table.unwrap(runtimes_current) end runtimes = runtimes or false @@ -1515,6 +1499,10 @@ function _instance:_configs_for_buildhash() local value = configs_required[name] if value == nil then value = self:extraconf("configs", name, "default") + -- support for the deprecated vs_runtime in add_configs + if name == "runtimes" and value == nil then + value = self:extraconf("configs", "vs_runtime", "default") + end end configs[name] = value end @@ -1527,10 +1515,19 @@ function _instance:_configs_for_buildhash() return configs and configs or nil end +-- compute the build hash +function _instance:_compute_buildhash() + self._BUILDHASH_PREPRARED = true + self:buildhash() +end + -- get the build hash function _instance:buildhash() local buildhash = self._BUILDHASH if buildhash == nil then + if not self._BUILDHASH_PREPRARED then + os.raise("package:buildhash() must be called after loading package") + end local function _get_buildhash(configs, opt) opt = opt or {} local str = self:plat() .. self:arch() diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index eff4316cc..5d352ee01 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -28,6 +28,7 @@ import("core.cache.memcache") import("core.project.project") import("core.project.config") import("core.tool.toolchain") +import("core.platform.platform") import("core.package.package", {alias = "core_package"}) import("devel.git") import("private.action.require.impl.repository") @@ -805,6 +806,35 @@ function _select_artifacts(package, artifacts_manifest) end end +-- select package runtimes +function _select_package_runtimes(package) + local runtimes = package:config("runtimes") + if runtimes then + local runtimes_supported = hashset.new() + local toolchains = package:toolchains() or platform.load(package:plat(), package:arch()):toolchains() + if toolchains then + for _, toolchain_inst in ipairs(toolchains) do + if toolchain_inst:is_standalone() and toolchain_inst:get("runtimes") then + for _, runtime in ipairs(table.wrap(toolchain_inst:get("runtimes"))) do + runtimes_supported:insert(runtime) + end + end + end + end + local runtimes_current = {} + for _, runtime in ipairs(table.wrap(runtimes:split(",", {plain = true}))) do + if runtimes_supported:has(runtime) then + table.insert(runtimes_current, runtime) + end + end + -- we need update runtimes for buildhash, configs ... + local requireinfo = package:requireinfo() + if requireinfo and requireinfo.configs then + requireinfo.configs.runtimes = #runtimes_current > 0 and table.concat(runtimes_current, ",") or nil + end + end +end + -- load required packages function _load_package(packagename, requireinfo, opt) @@ -938,6 +968,13 @@ function _load_package(packagename, requireinfo, opt) -- check package configurations _check_package_configurations(package) + -- we need to select package runtimes before computing buildhash + -- @see https://github.com/xmake-io/xmake/pull/4630#issuecomment-1910216561 + _select_package_runtimes(package) + + -- pre-compute the package buildhash + package:_compute_buildhash() + -- save artifacts info, we need to add it at last before buildhash need depend on package configurations -- it will switch to install precompiled binary package from xmake-mirror/build-artifacts if from_repo and not option.get("build") and not requireinfo.build then diff --git a/xmake/toolchains/xcode/xmake.lua b/xmake/toolchains/xcode/xmake.lua index ff304e3b2..2f9e6a053 100644 --- a/xmake/toolchains/xcode/xmake.lua +++ b/xmake/toolchains/xcode/xmake.lua @@ -18,20 +18,13 @@ -- @file xmake.lua -- --- define toolchain toolchain("xcode") - - -- set homepage + set_kind("standalone") set_homepage("https://developer.apple.com/xcode/") set_description("Xcode IDE") + set_runtimes("c++_static", "c++_shared", "stdc++_static", "stdc++_shared") - -- mark as standalone toolchain - set_kind("standalone") - - -- check toolchain on_check("check") - - -- load toolchain on_load(function (toolchain) -- set toolset |
