diff options
| author | ruki <[email protected]> | 2025-07-31 23:45:20 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-07-31 23:45:20 +0800 |
| commit | 03a44ff1ecd4800c4abba211aa68744c71806432 (patch) | |
| tree | 111733352cb39e77c3c3bac55304c6594d6e2039 | |
| parent | 9a69715ad0b6d1f92bed9766178185ccf090ff6f (diff) | |
improve to config targets
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/project.lua | 55 | ||||
| -rw-r--r-- | xmake/modules/private/action/build/target.lua | 8 |
2 files changed, 9 insertions, 54 deletions
diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua index 70f135706..ae185dc2c 100644 --- a/xmake/core/sandbox/modules/import/core/project/project.lua +++ b/xmake/core/sandbox/modules/import/core/project/project.lua @@ -126,51 +126,7 @@ function sandbox_core_project.check_options() end end --- config target -function sandbox_core_project._config_target(target, opt) - - -- enter the environments of the target packages - local oldenvs = os.addenvs(target:pkgenvs()) - - -- do config - local before_config = target:script("config_before") - if before_config then - before_config(target, opt) - end - 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 - local config_after = target:script("config_after") - if config_after then - config_after(target, opt) - end - - -- leave the environments of the target packages - os.setenvs(oldenvs) -end - --- config targets, TODO: We should support parallel configuration +-- config targets -- -- @param opt the extra option, e.g. {recheck = false} -- @@ -182,12 +138,9 @@ end -- end -- 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.action.build.target", {alias = "target_buildutils"}) + local targets_root = target_buildutils.get_root_targets() + target_buildutils.run_targetjobs(targets_root, {job_kind = "config", job_opt = opt}) end -- load rules in the required packages for target diff --git a/xmake/modules/private/action/build/target.lua b/xmake/modules/private/action/build/target.lua index 370145188..683b30664 100644 --- a/xmake/modules/private/action/build/target.lua +++ b/xmake/modules/private/action/build/target.lua @@ -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) @@ -243,7 +244,8 @@ function add_targetjobs_with_stage(jobgraph, target, stage, opt) 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 |
