diff options
Diffstat (limited to 'xmake/plugins/project/utils/target_cmds.lua')
| -rw-r--r-- | xmake/plugins/project/utils/target_cmds.lua | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/xmake/plugins/project/utils/target_cmds.lua b/xmake/plugins/project/utils/target_cmds.lua index 4c7f4f008..0b98a4ed7 100644 --- a/xmake/plugins/project/utils/target_cmds.lua +++ b/xmake/plugins/project/utils/target_cmds.lua @@ -39,28 +39,39 @@ function _sourcebatch_is_built(sourcebatch) end -- get target buildcmd commands -function get_target_buildcmd(target, cmds, suffix) +function get_target_buildcmd(target, cmds, opt) + opt = opt or {} + local suffix = opt.suffix + local ignored_rules = hashset.from(opt.ignored_rules or {}) for _, ruleinst in ipairs(target:orderules()) do - local scriptname = "buildcmd" .. (suffix and ("_" .. suffix) or "") - local script = ruleinst:script(scriptname) - if script then - local batchcmds_ = batchcmds.new({target = target}) - script(target, batchcmds_, {}) - if not batchcmds_:empty() then - table.join2(cmds, batchcmds_:cmds()) + if not ignored_rules:has(ruleinst:name()) then + local scriptname = "buildcmd" .. (suffix and ("_" .. suffix) or "") + local script = ruleinst:script(scriptname) + if script then + local batchcmds_ = batchcmds.new({target = target}) + script(target, batchcmds_, {}) + if not batchcmds_:empty() then + table.join2(cmds, batchcmds_:cmds()) + end end end end end -- get target buildcmd_files commands -function get_target_buildcmd_files(target, cmds, sourcebatch, suffix) +function get_target_buildcmd_files(target, cmds, sourcebatch, opt) + opt = opt or {} -- get rule local rulename = assert(sourcebatch.rulename, "unknown rule for sourcebatch!") local ruleinst = assert(target:rule(rulename) or project.rule(rulename) or rule.rule(rulename), "unknown rule: %s", rulename) + local ignored_rules = hashset.from(opt.ignored_rules or {}) + if ignored_rules:has(ruleinst:name()) then + return + end -- generate commands for xx_buildcmd_files + local suffix = opt.suffix local scriptname = "buildcmd_files" .. (suffix and ("_" .. suffix) or "") local script = ruleinst:script(scriptname) if script then @@ -89,14 +100,14 @@ function get_target_buildcmd_files(target, cmds, sourcebatch, suffix) end -- get target buildcmd commands of source group -function get_target_buildcmd_sourcegroups(target, cmds, sourcegroups, suffix) +function get_target_buildcmd_sourcegroups(target, cmds, sourcegroups, opt) for idx, group in irpairs(sourcegroups) do for _, item in pairs(group) do -- buildcmd scripts are always in rule, so we need to ignore target item (item.target). local sourcebatch = item.sourcebatch if item.rule then if not _sourcebatch_is_built(sourcebatch) then - get_target_buildcmd_files(target, cmds, sourcebatch, suffix) + get_target_buildcmd_files(target, cmds, sourcebatch, opt) end end end |
