summaryrefslogtreecommitdiff
path: root/xmake/modules/private/utils/target.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2026-03-30 21:58:26 +0800
committerGitHub <[email protected]>2026-03-30 21:58:26 +0800
commit4222dfcc1e73ec1f6fbe399ff1de6fb52e17af1e (patch)
treeb46f1bda336f1a56a2804a06108649f032eb4a00 /xmake/modules/private/utils/target.lua
parent01c2251b193482d9f308c92c27bb113c77dd60b4 (diff)
parent53748c3a92f9f6c11453ed2f3a9af761275e732a (diff)
Merge pull request #7440 from xmake-io/comments
Improve comments
Diffstat (limited to 'xmake/modules/private/utils/target.lua')
-rw-r--r--xmake/modules/private/utils/target.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/xmake/modules/private/utils/target.lua b/xmake/modules/private/utils/target.lua
index 56fb6faeb..217daad52 100644
--- a/xmake/modules/private/utils/target.lua
+++ b/xmake/modules/private/utils/target.lua
@@ -26,6 +26,12 @@ import("core.project.project")
import("utils.binary.deplibs", {alias = "get_depend_libraries"})
-- Is this target has these tools?
+-- check if the given tool is in the tools list
+--
+-- @param toolname the tool name to check
+-- @param tools the tools table
+-- @return true if found
+--
function has_tool(toolname, tools)
if toolname then
-- We need compatibility with gcc/g++, clang/clang++ for c++ compiler/linker
@@ -56,6 +62,13 @@ end
-- only for clang: add_cxxflags("clang::-stdlib=libc++")
-- only for clang and multiple flags: add_cxxflags("-stdlib=libc++", "-DFOO", {tools = "clang"})
--
+-- check if a flag belongs to the given tool
+--
+-- @param flag the flag string
+-- @param toolinst the tool instance
+-- @param extraconf the extra configuration
+-- @return the flag if belongs, or nil
+--
function flag_belong_to_tool(flag, toolinst, extraconf)
local for_this_tool = true
local flagconf = extraconf and extraconf[flag]
@@ -122,6 +135,10 @@ function translate_flags_in_tool(target, flagkind, flags)
end
-- get project targets
+-- get all enabled project targets
+--
+-- @return the targets array
+--
function get_project_targets()
local selected_target = option.get("target")
if selected_target then
@@ -169,6 +186,11 @@ function check_target_toolchains()
end
-- config target
+-- configure the given target (run on_config rules)
+--
+-- @param target the target instance
+-- @param opt the options (optional)
+--
function config_target(target, opt)
for _, rule in ipairs(table.wrap(target:orderules())) do
local before_config = rule:script("config_before")
@@ -197,6 +219,10 @@ function config_target(target, opt)
end
-- config targets
+-- configure all project targets
+--
+-- @param opt the options (optional)
+--
function config_targets(opt)
opt = opt or {}
for _, target in ipairs(table.wrap(project.ordertargets())) do