From 0768cc5665cd063fbcfdc072b9322894b0d5f34d Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 11 Aug 2023 00:51:32 +0800 Subject: improve target toolchains --- xmake/core/project/target.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 60a4d182a..6e49bd7d0 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -2077,9 +2077,9 @@ function _instance:toolchains() if toolchains == nil then -- load target toolchains + toolchains = {} local target_toolchains = self:get("toolchains") if target_toolchains then - toolchains = {} for _, name in ipairs(table.wrap(target_toolchains)) do local toolchain_opt = table.copy(self:extraconf("toolchains", name)) toolchain_opt.arch = self:arch() @@ -2094,10 +2094,9 @@ function _instance:toolchains() end table.insert(toolchains, toolchain_inst) end - else - -- load platform toolchains - toolchains = self:platform():toolchains() end + -- load platform toolchains + table.join2(toolchains, self:platform():toolchains()) self:_memcache():set("toolchains", toolchains) end return toolchains -- cgit v1.3.1 From 40f70328407b66a02fb45484ec290703317fa654 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 11 Aug 2023 00:51:58 +0800 Subject: update comment --- xmake/core/project/target.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 6e49bd7d0..efebba746 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -2076,7 +2076,7 @@ function _instance:toolchains() local toolchains = self:_memcache():get("toolchains") if toolchains == nil then - -- load target toolchains + -- load target toolchains first toolchains = {} local target_toolchains = self:get("toolchains") if target_toolchains then @@ -2095,8 +2095,11 @@ function _instance:toolchains() table.insert(toolchains, toolchain_inst) end end - -- load platform toolchains + + -- we need merge target and platform toolchains, + -- because we maybe only set partial toolchains in target, e.g. nasm toolchain table.join2(toolchains, self:platform():toolchains()) + self:_memcache():set("toolchains", toolchains) end return toolchains -- cgit v1.3.1 From e9bb721deae72ae84f0f262b673496dbd60a08bd Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 11 Aug 2023 22:43:02 +0800 Subject: fix target toolchains --- xmake/actions/config/main.lua | 2 +- xmake/core/project/target.lua | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index 47f542706..30150f81f 100644 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -130,7 +130,7 @@ function _check_target_toolchains() target_toolchains = hashset.from(table.wrap(target_toolchains)) for _, toolchain_inst in pairs(target:toolchains()) do -- check toolchains for `target/set_toolchains()` - if not toolchain_inst:check() and target_toolchains:has(toolchain_inst:name()) then + if target_toolchains:has(toolchain_inst:name()) and not toolchain_inst:check() then raise("toolchain(\"%s\"): not found!", toolchain_inst:name()) end end diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index efebba746..4d4bf94dc 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -2078,6 +2078,7 @@ function _instance:toolchains() -- load target toolchains first toolchains = {} + local has_standalone = false local target_toolchains = self:get("toolchains") if target_toolchains then for _, name in ipairs(table.wrap(target_toolchains)) do @@ -2092,13 +2093,26 @@ function _instance:toolchains() if not toolchain_inst then os.raise(errors) end + if toolchain_inst:is_standalone() then + has_standalone = true + end table.insert(toolchains, toolchain_inst) end end -- we need merge target and platform toolchains, -- because we maybe only set partial toolchains in target, e.g. nasm toolchain - table.join2(toolchains, self:platform():toolchains()) + for _, toolchain_inst in ipairs(self:platform():toolchains()) do + if toolchain_inst:is_standalone() then + -- we can only add one standalone toolchain + if not has_standalone then + table.insert(toolchains, toolchain_inst) + end + has_standalone = true + else + table.insert(toolchains, toolchain_inst) + end + end self:_memcache():set("toolchains", toolchains) end -- cgit v1.3.1 From d77ae95506850e96a07b9a0b807d363df80856bb Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 11 Aug 2023 22:50:22 +0800 Subject: improve toolchains --- .../package/toolchain_muslcc/xmake-requires.lock | 16 +++++++-------- xmake/core/project/target.lua | 24 +++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/projects/package/toolchain_muslcc/xmake-requires.lock b/tests/projects/package/toolchain_muslcc/xmake-requires.lock index 00f23d026..986902c39 100644 --- a/tests/projects/package/toolchain_muslcc/xmake-requires.lock +++ b/tests/projects/package/toolchain_muslcc/xmake-requires.lock @@ -17,15 +17,15 @@ commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, - version = "1.16.4" + version = "1.16.5" }, ["cmake#31fecfc4"] = { repo = { branch = "master", - commit = "d3260ca0867f8b26aa2a72818bca3e6113a4fc42", - url = "https://github.com/xmake-io/xmake-repo.git" + commit = "bd51a8d551dad9aae6749511b2139658285d847f", + url = "https://gitee.com/tboox/xmake-repo.git" }, - version = "3.22.1" + version = "3.25.3" }, ["gmp#31fecfc4"] = { repo = { @@ -38,7 +38,7 @@ ["libisl 0.22#67114504"] = { repo = { branch = "master", - commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", + commit = "123c0b54565571402683bb4efcf0d5cbaee53115", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "0.22" @@ -62,7 +62,7 @@ ["libtool#31fecfc4"] = { repo = { branch = "master", - commit = "dd4abbd658b9897c9e1dcacf2e4bdeeb02d05860", + commit = "2918fbb829482398c8ab2676d05a46779d0f44b1", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "2.4.6" @@ -73,7 +73,7 @@ commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, - version = "1.4.19" + version = "1.4.6" }, ["muslcc#31fecfc4"] = { repo = { @@ -142,4 +142,4 @@ version = "v1.2.11" } } -} +} \ No newline at end of file diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 4d4bf94dc..e9a603476 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -2077,10 +2077,10 @@ function _instance:toolchains() if toolchains == nil then -- load target toolchains first - toolchains = {} local has_standalone = false local target_toolchains = self:get("toolchains") if target_toolchains then + toolchains = {} for _, name in ipairs(table.wrap(target_toolchains)) do local toolchain_opt = table.copy(self:extraconf("toolchains", name)) toolchain_opt.arch = self:arch() @@ -2098,20 +2098,20 @@ function _instance:toolchains() end table.insert(toolchains, toolchain_inst) end - end - -- we need merge target and platform toolchains, - -- because we maybe only set partial toolchains in target, e.g. nasm toolchain - for _, toolchain_inst in ipairs(self:platform():toolchains()) do - if toolchain_inst:is_standalone() then - -- we can only add one standalone toolchain - if not has_standalone then - table.insert(toolchains, toolchain_inst) + -- we always need a standalone toolchain + -- because we maybe only set partial toolchains in target, e.g. nasm toolchain + if not has_standalone then + for _, toolchain_inst in ipairs(self:platform():toolchains()) do + if toolchain_inst:is_standalone() then + table.insert(toolchains, toolchain_inst) + has_standalone = true + break + end end - has_standalone = true - else - table.insert(toolchains, toolchain_inst) end + else + toolchains = self:platform():toolchains() end self:_memcache():set("toolchains", toolchains) -- cgit v1.3.1 From d9257ab70b12faf725c49272db91d59b54adc8e3 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 11 Aug 2023 22:51:55 +0800 Subject: revert check --- xmake/actions/config/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index 30150f81f..47f542706 100644 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -130,7 +130,7 @@ function _check_target_toolchains() target_toolchains = hashset.from(table.wrap(target_toolchains)) for _, toolchain_inst in pairs(target:toolchains()) do -- check toolchains for `target/set_toolchains()` - if target_toolchains:has(toolchain_inst:name()) and not toolchain_inst:check() then + if not toolchain_inst:check() and target_toolchains:has(toolchain_inst:name()) then raise("toolchain(\"%s\"): not found!", toolchain_inst:name()) end end -- cgit v1.3.1 From 793c35405c44f43ce6bdadc19f75b3f275f22367 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 11 Aug 2023 22:52:04 +0800 Subject: revert require lock --- .../package/toolchain_muslcc/xmake-requires.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/projects/package/toolchain_muslcc/xmake-requires.lock b/tests/projects/package/toolchain_muslcc/xmake-requires.lock index 986902c39..00f23d026 100644 --- a/tests/projects/package/toolchain_muslcc/xmake-requires.lock +++ b/tests/projects/package/toolchain_muslcc/xmake-requires.lock @@ -17,15 +17,15 @@ commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, - version = "1.16.5" + version = "1.16.4" }, ["cmake#31fecfc4"] = { repo = { branch = "master", - commit = "bd51a8d551dad9aae6749511b2139658285d847f", - url = "https://gitee.com/tboox/xmake-repo.git" + commit = "d3260ca0867f8b26aa2a72818bca3e6113a4fc42", + url = "https://github.com/xmake-io/xmake-repo.git" }, - version = "3.25.3" + version = "3.22.1" }, ["gmp#31fecfc4"] = { repo = { @@ -38,7 +38,7 @@ ["libisl 0.22#67114504"] = { repo = { branch = "master", - commit = "123c0b54565571402683bb4efcf0d5cbaee53115", + commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "0.22" @@ -62,7 +62,7 @@ ["libtool#31fecfc4"] = { repo = { branch = "master", - commit = "2918fbb829482398c8ab2676d05a46779d0f44b1", + commit = "dd4abbd658b9897c9e1dcacf2e4bdeeb02d05860", url = "https://github.com/xmake-io/xmake-repo.git" }, version = "2.4.6" @@ -73,7 +73,7 @@ commit = "8d4f0875fe9a3c63be4948cefca9f232954e3e87", url = "https://github.com/xmake-io/xmake-repo.git" }, - version = "1.4.6" + version = "1.4.19" }, ["muslcc#31fecfc4"] = { repo = { @@ -142,4 +142,4 @@ version = "v1.2.11" } } -} \ No newline at end of file +} -- cgit v1.3.1 From 704cc78dd4fa1e108f946fc51fcd538ea05d01de Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 11 Aug 2023 22:59:49 +0800 Subject: improve platform check for target toolchains --- xmake/actions/config/main.lua | 14 ++++++++------ xmake/core/platform/platform.lua | 6 ++++++ xmake/core/project/target.lua | 2 ++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index 47f542706..eaa61f490 100644 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -125,6 +125,14 @@ function _check_target_toolchains() if target:is_enabled() and (target:get("toolchains") or not target:is_plat(config.get("plat")) or not target:is_arch(config.get("arch"))) then + + -- check platform toolchains first + -- `target/set_plat()` and target:toolchains() need it + local ok, errors = target:platform():check() + if not ok then + raise(errors) + end + local target_toolchains = target:get("toolchains") if target_toolchains then target_toolchains = hashset.from(table.wrap(target_toolchains)) @@ -134,12 +142,6 @@ function _check_target_toolchains() raise("toolchain(\"%s\"): not found!", toolchain_inst:name()) end end - else - -- check platform toolchains for `target/set_plat()` - local ok, errors = target:platform():check() - if not ok then - raise(errors) - end end elseif not target:get("toolset") then -- we only abort it when we know that toolchains of platform and target do not found diff --git a/xmake/core/platform/platform.lua b/xmake/core/platform/platform.lua index 01d5b0e5e..148120d49 100644 --- a/xmake/core/platform/platform.lua +++ b/xmake/core/platform/platform.lua @@ -234,6 +234,10 @@ end -- do check function _instance:check() + local checked = self._CHECKED + if checked ~= nil then + return checked + end -- check toolchains local toolchains = self:toolchains({all = true}) @@ -256,11 +260,13 @@ function _instance:check() end end if #toolchains == 0 then + self._CHECKED = false return false, "toolchains not found!" end -- save valid toolchains config.set("__toolchains_" .. self:name() .. "_" .. self:arch(), toolchains_valid) + self._CHECKED = true return true end diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index e9a603476..ca46a7b69 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -2101,6 +2101,8 @@ function _instance:toolchains() -- we always need a standalone toolchain -- because we maybe only set partial toolchains in target, e.g. nasm toolchain + -- + -- @note platform has been checked in config/_check_target_toolchains if not has_standalone then for _, toolchain_inst in ipairs(self:platform():toolchains()) do if toolchain_inst:is_standalone() then -- cgit v1.3.1