From c2ad7d4240288fd8f5c5fb4aed3a5f62c5e2b566 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 12 Mar 2025 00:49:06 +0800 Subject: [PATCH 1/4] add on_prepare stages --- xmake/core/project/rule.lua | 9 +++++++++ xmake/core/project/target.lua | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua index 571790fc50..a483943d81 100644 --- a/xmake/core/project/rule.lua +++ b/xmake/core/project/rule.lua @@ -287,6 +287,9 @@ function rule.apis() , "rule.on_test" , "rule.on_load" , "rule.on_config" + , "rule.on_prepare" + , "rule.on_prepare_file" + , "rule.on_prepare_files" , "rule.on_link" , "rule.on_build" , "rule.on_build_file" @@ -306,6 +309,9 @@ function rule.apis() , "rule.before_test" , "rule.before_load" , "rule.before_config" + , "rule.before_prepare" + , "rule.before_prepare_file" + , "rule.before_prepare_files" , "rule.before_link" , "rule.before_build" , "rule.before_build_file" @@ -325,6 +331,9 @@ function rule.apis() , "rule.after_test" , "rule.after_load" , "rule.after_config" + , "rule.after_prepare" + , "rule.after_prepare_file" + , "rule.after_prepare_files" , "rule.after_link" , "rule.after_build" , "rule.after_build_file" diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 360edb9ccc..2dd779f151 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -2923,6 +2923,9 @@ function target.apis() , "target.on_test" , "target.on_load" , "target.on_config" + , "target.on_prepare" + , "target.on_prepare_file" + , "target.on_prepare_files" , "target.on_link" , "target.on_build" , "target.on_build_file" @@ -2936,6 +2939,10 @@ function target.apis() -- target.before_xxx , "target.before_run" , "target.before_test" + , "target.before_config" + , "target.before_prepare" + , "target.before_prepare_file" + , "target.before_prepare_files" , "target.before_link" , "target.before_build" , "target.before_build_file" @@ -2950,6 +2957,10 @@ function target.apis() , "target.after_run" , "target.after_test" , "target.after_load" + , "target.after_config" + , "target.after_prepare" + , "target.after_prepare_file" + , "target.after_prepare_files" , "target.after_link" , "target.after_build" , "target.after_build_file" From fac8335046f5c5dec46dc03480a33c297bb3598a Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 12 Mar 2025 00:50:10 +0800 Subject: [PATCH 2/4] add missing target config --- .../sandbox/modules/import/core/project/project.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua index 61b538bb1b..c696b79b7b 100644 --- a/xmake/core/sandbox/modules/import/core/project/project.lua +++ b/xmake/core/sandbox/modules/import/core/project/project.lua @@ -128,6 +128,10 @@ end -- config target function sandbox_core_project._config_target(target, opt) + 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 @@ -152,9 +156,13 @@ function sandbox_core_project._config_target(target, opt) after_config(target, opt) end end + local config_after = target:script("config_after") + if config_after then + config_after(target, opt) + end end --- config targets +-- config targets, TODO: We should support parallel configuration -- -- @param opt the extra option, e.g. {recheck = false} -- From 3a195e64c5e03b054a89da7f37ffb11d675dc14b Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 13 Mar 2025 00:51:56 +0800 Subject: [PATCH 3/4] add prepare stub --- xmake/actions/build/build.lua | 5 ++++- xmake/actions/build/build_files.lua | 4 ++++ xmake/actions/build/prepare.lua | 26 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 xmake/actions/build/prepare.lua diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua index 28a33db78d..8d5ffb72ed 100644 --- a/xmake/actions/build/build.lua +++ b/xmake/actions/build/build.lua @@ -28,6 +28,7 @@ import("private.utils.batchcmds") import("core.base.hashset") import("private.service.remote_cache.client", {alias = "remote_cache_client"}) import("private.service.distcc_build.client", {alias = "distcc_build_client"}) +import("prepare", {alias = "prepare_build"}) -- clean target for rebuilding function _clean_target(target) @@ -299,9 +300,11 @@ function get_batchjobs(targetnames, group_pattern) return batchjobs end --- the main entry function main(targetnames, group_pattern) + -- prepare to build + prepare_build(targetnames, {group_pattern = group_pattern}) + -- enable distcc? local distcc if distcc_build_client.is_connected() then diff --git a/xmake/actions/build/build_files.lua b/xmake/actions/build/build_files.lua index ad85d8b2a7..c44b8ecd1e 100644 --- a/xmake/actions/build/build_files.lua +++ b/xmake/actions/build/build_files.lua @@ -26,6 +26,7 @@ import("core.project.project") import("private.async.jobpool") import("async.runjobs") import("kinds.object") +import("prepare", {alias = "prepare_build"}) -- match source files function _match_sourcefiles(sourcefile, filepatterns) @@ -196,6 +197,9 @@ end -- the main entry function main(targetname, group_pattern, sourcefiles) + -- prepare to build + prepare_build(targetnames, {group_pattern = group_pattern, sourcefiles = sourcefiles}) + -- convert all sourcefiles to lua pattern local filepatterns = _get_file_patterns(sourcefiles) diff --git a/xmake/actions/build/prepare.lua b/xmake/actions/build/prepare.lua new file mode 100644 index 0000000000..52a0152af4 --- /dev/null +++ b/xmake/actions/build/prepare.lua @@ -0,0 +1,26 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file prepare.lua +-- + +-- imports +import("core.base.option") +import("core.project.config") + +function main(targetnames, opt) +end From 6591719f6bfe0ee47d9ccce2c03ff9af6f5d5862 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 14 Mar 2025 00:53:08 +0800 Subject: [PATCH 4/4] add jobgraph stub --- tests/modules/async/jobgraph.lua | 7 ++++ .../modules/{scheduler => async}/runjobs.lua | 0 xmake/modules/async/jobgraph.lua | 36 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 tests/modules/async/jobgraph.lua rename tests/modules/{scheduler => async}/runjobs.lua (100%) create mode 100644 xmake/modules/async/jobgraph.lua diff --git a/tests/modules/async/jobgraph.lua b/tests/modules/async/jobgraph.lua new file mode 100644 index 0000000000..dd8cb05f8a --- /dev/null +++ b/tests/modules/async/jobgraph.lua @@ -0,0 +1,7 @@ +import("core.base.scheduler") +import("async.jobgraph") + +function main() + +end + diff --git a/tests/modules/scheduler/runjobs.lua b/tests/modules/async/runjobs.lua similarity index 100% rename from tests/modules/scheduler/runjobs.lua rename to tests/modules/async/runjobs.lua diff --git a/xmake/modules/async/jobgraph.lua b/xmake/modules/async/jobgraph.lua new file mode 100644 index 0000000000..519544cf29 --- /dev/null +++ b/xmake/modules/async/jobgraph.lua @@ -0,0 +1,36 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file jobgraph.lua +-- + +-- imports +import("core.base.object") +import("core.base.graph") + +-- define module +local jobgraph = jobgraph or object {_init = {"_size"}} + +-- tostring +function jobgraph:__tostring() + return "" +end + +-- new a jobgraph +function new() + return jobgraph {0} +end