summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-10-21 22:52:32 +0800
committerruki <[email protected]>2025-10-21 22:52:32 +0800
commit09bd81144accabe2a7779b8d862559784a263f00 (patch)
tree59e4b0f59005da0a214438547201fa1db1f9083e
parent405221a5f79cda33cab7df2694a3ee818d188168 (diff)
recheck target toolchains in vsxmake
-rw-r--r--xmake/actions/config/main.lua40
-rw-r--r--xmake/modules/private/utils/target.lua38
-rw-r--r--xmake/plugins/project/vsxmake/getinfo.lua3
3 files changed, 43 insertions, 38 deletions
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 8f6640881..fa9ab6782 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -35,6 +35,7 @@ import("configfiles", {alias = "generate_configfiles"})
import("private.action.require.register", {alias = "register_packages"})
import("private.action.require.install", {alias = "install_packages"})
import("private.service.remote_build.action", {alias = "remote_build_action"})
+import("private.utils.target", {alias = "target_utils"})
-- filter option
function _option_filter(name)
@@ -124,43 +125,6 @@ function _check_targets()
end
end
--- check target toolchains
-function _check_target_toolchains()
- -- check toolchains configuration for all target in the current project
- -- @note we must check targets after loading options
- for _, target in pairs(project.targets()) do
- 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
- target:platform():check()
-
- -- check target toolchains next
- local target_toolchains = target:get("toolchains")
- if target_toolchains then
- 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
- raise("toolchain(\"%s\"): not found!", toolchain_inst:name())
- end
- end
- end
- elseif not target:get("toolset") then
- -- we only abort it when we know that toolchains of platform and target do not found
- local toolchain_found
- for _, toolchain_inst in pairs(target:toolchains()) do
- if toolchain_inst:is_standalone() then
- toolchain_found = true
- end
- end
- assert(toolchain_found, "target(%s): toolchain not found!", target:name())
- end
- end
-end
-
-- find default mode
function _find_default_mode()
local mode = config.mode()
@@ -406,7 +370,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
-- check target toolchains
if recheck then
- _check_target_toolchains()
+ target_utils.check_target_toolchains()
end
-- load targets
diff --git a/xmake/modules/private/utils/target.lua b/xmake/modules/private/utils/target.lua
index ad6046b44..07a4932ad 100644
--- a/xmake/modules/private/utils/target.lua
+++ b/xmake/modules/private/utils/target.lua
@@ -125,3 +125,41 @@ function get_project_targets()
end
return project.targets()
end
+
+-- check target toolchains
+function check_target_toolchains()
+ -- check toolchains configuration for all target in the current project
+ -- @note we must check targets after loading options
+ for _, target in pairs(project.targets()) do
+ 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
+ target:platform():check()
+
+ -- check target toolchains next
+ local target_toolchains = target:get("toolchains")
+ if target_toolchains then
+ 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
+ raise("toolchain(\"%s\"): not found!", toolchain_inst:name())
+ end
+ end
+ end
+ elseif not target:get("toolset") then
+ -- we only abort it when we know that toolchains of platform and target do not found
+ local toolchain_found
+ for _, toolchain_inst in pairs(target:toolchains()) do
+ if toolchain_inst:is_standalone() then
+ toolchain_found = true
+ end
+ end
+ assert(toolchain_found, "target(%s): toolchain not found!", target:name())
+ end
+ end
+end
+
diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua
index 08c10ca60..67bc8c968 100644
--- a/xmake/plugins/project/vsxmake/getinfo.lua
+++ b/xmake/plugins/project/vsxmake/getinfo.lua
@@ -479,6 +479,9 @@ function main(outputdir, vsinfo)
-- install and update requires
install_requires()
+ -- check target toolchains
+ target_utils.check_target_toolchains()
+
-- load targets
project.load_targets()