diff options
| author | ruki <[email protected]> | 2025-08-06 17:19:53 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-06 17:19:53 +0800 |
| commit | 248afd9bd01f8135e813616f6ce81467decd9dc1 (patch) | |
| tree | ec51e255431ff98aeec896d3b771aa55f6d2af55 /xmake/modules | |
| parent | 8be13f815541675a1592f58505c047e0f27b3a8e (diff) | |
| parent | 30200cba21674a06566c3da913cc7c57f5fd4752 (diff) | |
Merge pull request #6676 from xmake-io/config
Merge pull request #6667 from xmake-io/config
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/private/action/build/target.lua | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/xmake/modules/private/action/build/target.lua b/xmake/modules/private/action/build/target.lua index 370145188..0116dcd6f 100644 --- a/xmake/modules/private/action/build/target.lua +++ b/xmake/modules/private/action/build/target.lua @@ -131,13 +131,13 @@ end -- add target jobs for the builtin script function add_targetjobs_for_builtin_script(jobgraph, target, opt) opt = opt or {} - local job_kind = opt.job_kind + local job_kind = opt.job_kind or "build" if target:is_static() or target:is_binary() or target:is_shared() or target:is_object() or target:is_moduleonly() then if job_kind == "prepare" then import("private.action.build.prepare_files", {anonymous = true})(jobgraph, target, opt) elseif job_kind == "link" then import("private.action.build.link_objects", {anonymous = true})(jobgraph, target, opt) - else + elseif job_kind == "build" then import("private.action.build.build_" .. target:kind(), {anonymous = true})(jobgraph, target, opt) end end @@ -148,6 +148,7 @@ function add_targetjobs_for_script(jobgraph, target, instance, opt) opt = opt or {} local has_script = false local buildcmds = opt.buildcmds + local job_opt = opt.job_opt local job_prefix = target:fullname() if target == instance then job_prefix = job_prefix .. "/target" @@ -179,7 +180,7 @@ function add_targetjobs_for_script(jobgraph, target, instance, opt) -- end) local jobname = string.format("%s/%s", job_prefix, script_name) jobgraph:add(jobname, function (index, total, opt) - script(target, {progress = opt.progress}) + script(target, table.join({progress = opt.progress}, job_opt)) end) end has_script = true @@ -203,7 +204,7 @@ function add_targetjobs_for_script(jobgraph, target, instance, opt) scriptcmd(target, buildcmds, {progress = opt.progress}) else local batchcmds_ = batchcmds.new({target = target}) - scriptcmd(target, batchcmds_, {progress = opt.progress}) + scriptcmd(target, batchcmds_, table.join({progress = opt.progress}, job_opt)) batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")}) end end) @@ -237,13 +238,20 @@ function add_targetjobs_with_stage(jobgraph, target, stage, opt) table.insert(instances, ruleinst) end end + -- on_config is different from on_build/on_prepare, + -- it does not rewrite all rules, and target.on_config needs to be called last. + if job_kind == "config" then + instances = table.slice(instances, 2) + table.insert(instances, target) + end local jobsize = jobgraph:size() jobgraph:group(group_name, function () local has_script = false local script_opt = { script_name = script_name, scriptcmd_name = scriptcmd_name, - buildcmds = opt.buildcmds + buildcmds = opt.buildcmds, + job_opt = opt.job_opt } for _, instance in ipairs(instances) do -- we need to use this group to sort rule scripts with add_orders @@ -739,13 +747,14 @@ function get_root_targets(targetnames, opt) end end else + local all = opt.all local group_pattern = opt.group_pattern local depset = hashset.new() local targets = {} for _, target in ipairs(project.ordertargets()) do if target:is_enabled() then local group = target:get("group") - if (target:is_default() and not group_pattern) or option.get("all") or (group_pattern and group and group:match(group_pattern)) then + if (target:is_default() and not group_pattern) or all or option.get("all") or (group_pattern and group and group:match(group_pattern)) then for _, depname in ipairs(target:get("deps")) do depset:insert(depname) end |
