summaryrefslogtreecommitdiff
path: root/xmake
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-28 20:31:13 +0800
committerruki <[email protected]>2025-12-29 00:09:39 +0800
commitbdfa86bccebb1bed6f3c7cec97db58d69ec44572 (patch)
tree870f7980ac7db09a695125af5457aa9e706873a0 /xmake
parentefbe455bd1bbbd320174d36af99e95fb1628dfa5 (diff)
fix xmake test for std modules
Diffstat (limited to 'xmake')
-rw-r--r--xmake/actions/test/main.lua2
-rw-r--r--xmake/core/sandbox/modules/import/core/project/project.lua37
-rw-r--r--xmake/modules/private/utils/target.lua39
3 files changed, 44 insertions, 34 deletions
diff --git a/xmake/actions/test/main.lua b/xmake/actions/test/main.lua
index 0e7192d83..85866814a 100644
--- a/xmake/actions/test/main.lua
+++ b/xmake/actions/test/main.lua
@@ -31,6 +31,7 @@ import("private.action.run.runenvs")
import("private.service.remote_build.action", {alias = "remote_build_action"})
import("actions.build.main", {rootdir = os.programdir(), alias = "build_action"})
import("utils.progress")
+import("private.utils.target", {alias = "target_utils"})
-- test target
function _do_test_target(target, opt)
@@ -522,6 +523,7 @@ function get_tests()
if extra.packages then
target_new:add("packages", extra.packages)
end
+ target_utils.config_target(target_new)
testinfo.target = target_new
end
end
diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua
index 8a808e7da..9b69349d0 100644
--- a/xmake/core/sandbox/modules/import/core/project/project.lua
+++ b/xmake/core/sandbox/modules/import/core/project/project.lua
@@ -127,41 +127,10 @@ function sandbox_core_project.check_options()
end
end
--- config target
-function sandbox_core_project._config_target(target, opt)
- for _, rule in ipairs(table.wrap(target:orderules())) do
- local before_config = rule:script("config_before")
- if before_config then
- before_config(target, opt)
- end
- end
-
- for _, rule in ipairs(table.wrap(target:orderules())) do
- local on_config = rule:script("config")
- if on_config then
- on_config(target, opt)
- end
- end
- local on_config = target:script("config")
- if on_config then
- on_config(target, opt)
- end
-
- for _, rule in ipairs(table.wrap(target:orderules())) do
- local after_config = rule:script("config_after")
- if after_config then
- after_config(target, opt)
- end
- end
-end
-
+-- config targets
function sandbox_core_project._config_targets(opt)
- opt = opt or {}
- for _, target in ipairs(table.wrap(project.ordertargets())) do
- if target:is_enabled() then
- sandbox_core_project._config_target(target, opt)
- end
- end
+ import("private.utils.target", {alias = "target_utils"})
+ target_utils.config_targets(opt)
end
-- config targets
diff --git a/xmake/modules/private/utils/target.lua b/xmake/modules/private/utils/target.lua
index d06f1293c..728bd6016 100644
--- a/xmake/modules/private/utils/target.lua
+++ b/xmake/modules/private/utils/target.lua
@@ -50,6 +50,7 @@ end
-- @see https://github.com/xmake-io/xmake/issues/3022
--
-- e.g.
+--
-- for all: add_cxxflags("-g")
-- only for clang: add_cxxflags("clang::-stdlib=libc++")
-- only for clang and multiple flags: add_cxxflags("-stdlib=libc++", "-DFOO", {tools = "clang"})
@@ -104,6 +105,7 @@ function translate_flags_in_tool(target, flagkind, flags)
-- @see https://github.com/xmake-io/xmake/issues/3022
--
-- e.g.
+ --
-- for all: add_cxxflags("-g")
-- only for clang: add_cxxflags("clang::-stdlib=libc++")
-- only for clang and multiple flags: add_cxxflags("-stdlib=libc++", "-DFOO", {tools = "clang"})
@@ -165,3 +167,40 @@ function check_target_toolchains()
end
end
+-- config target
+function config_target(target, opt)
+ for _, rule in ipairs(table.wrap(target:orderules())) do
+ local before_config = rule:script("config_before")
+ if before_config then
+ before_config(target, opt)
+ end
+ end
+
+ for _, rule in ipairs(table.wrap(target:orderules())) do
+ local on_config = rule:script("config")
+ if on_config then
+ on_config(target, opt)
+ end
+ end
+ local on_config = target:script("config")
+ if on_config then
+ on_config(target, opt)
+ end
+
+ for _, rule in ipairs(table.wrap(target:orderules())) do
+ local after_config = rule:script("config_after")
+ if after_config then
+ after_config(target, opt)
+ end
+ end
+end
+
+-- config targets
+function config_targets(opt)
+ opt = opt or {}
+ for _, target in ipairs(table.wrap(project.ordertargets())) do
+ if target:is_enabled() then
+ config_target(target, opt)
+ end
+ end
+end