diff options
| author | ruki <[email protected]> | 2024-02-19 14:13:17 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-02-19 14:13:17 +0800 |
| commit | c20e333c5384f2c196a7945a5426da40f20aaa7e (patch) | |
| tree | 4a406a4c3c02adca9ce4c0170da17400621f61f5 /xmake/plugins/project/utils/target_cmds.lua | |
| parent | 7e126bdbcc883f59c43ccc94eb80f2607d612ef0 (diff) | |
| parent | a73fb131e47000b890e49b1918f36bf603c1b948 (diff) | |
Merge pull request #4746 from xmake-io/modules
Add native modules support for cmake generator
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 |
