diff options
| author | ruki <[email protected]> | 2025-03-28 00:44:36 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-04-08 15:31:56 +0800 |
| commit | d7473e4d4ceb8e83bd2d6bff5c91373110a08c4d (patch) | |
| tree | 9c5e184989669223f704cc7f4759d5f40e49410b | |
| parent | b45bad5035bd1b3af98cd90d9f44c08015958f9a (diff) | |
improve to prepare files
| -rw-r--r-- | xmake/actions/build/builtin/prepare_binary.lua | 22 | ||||
| -rw-r--r-- | xmake/actions/build/builtin/prepare_files.lua (renamed from xmake/actions/build/builtin/prepare_sourcefiles.lua) | 4 | ||||
| -rw-r--r-- | xmake/actions/build/builtin/prepare_moduleonly.lua | 22 | ||||
| -rw-r--r-- | xmake/actions/build/builtin/prepare_object.lua | 22 | ||||
| -rw-r--r-- | xmake/actions/build/builtin/prepare_shared.lua | 22 | ||||
| -rw-r--r-- | xmake/actions/build/builtin/prepare_static.lua | 22 | ||||
| -rw-r--r-- | xmake/actions/build/target_utils.lua | 109 |
7 files changed, 59 insertions, 164 deletions
diff --git a/xmake/actions/build/builtin/prepare_binary.lua b/xmake/actions/build/builtin/prepare_binary.lua deleted file mode 100644 index b81abaee3..000000000 --- a/xmake/actions/build/builtin/prepare_binary.lua +++ /dev/null @@ -1,22 +0,0 @@ ---!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_binary.lua --- - --- imports -inherit("prepare_sourcefiles") diff --git a/xmake/actions/build/builtin/prepare_sourcefiles.lua b/xmake/actions/build/builtin/prepare_files.lua index 1b3414278..c63257fd0 100644 --- a/xmake/actions/build/builtin/prepare_sourcefiles.lua +++ b/xmake/actions/build/builtin/prepare_files.lua @@ -15,14 +15,14 @@ -- Copyright (C) 2015-present, TBOOX Open Source Group. -- -- @author ruki --- @file prepare_sourcefiles.lua +-- @file prepare_files.lua -- -- imports import("core.base.option") function main(jobgraph, target) - jobgraph:add("prepare_sourcefiles", function (index, total, opt) + jobgraph:add("prepare_files", function (index, total, opt) print("prepare sourcefiles") end) end diff --git a/xmake/actions/build/builtin/prepare_moduleonly.lua b/xmake/actions/build/builtin/prepare_moduleonly.lua deleted file mode 100644 index 4866e016c..000000000 --- a/xmake/actions/build/builtin/prepare_moduleonly.lua +++ /dev/null @@ -1,22 +0,0 @@ ---!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_moduleonly.lua --- - --- imports -inherit("prepare_sourcefiles") diff --git a/xmake/actions/build/builtin/prepare_object.lua b/xmake/actions/build/builtin/prepare_object.lua deleted file mode 100644 index 0bc44b29c..000000000 --- a/xmake/actions/build/builtin/prepare_object.lua +++ /dev/null @@ -1,22 +0,0 @@ ---!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_object.lua --- - --- imports -inherit("prepare_sourcefiles") diff --git a/xmake/actions/build/builtin/prepare_shared.lua b/xmake/actions/build/builtin/prepare_shared.lua deleted file mode 100644 index 31a277a53..000000000 --- a/xmake/actions/build/builtin/prepare_shared.lua +++ /dev/null @@ -1,22 +0,0 @@ ---!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_shared.lua --- - --- imports -inherit("prepare_sourcefiles") diff --git a/xmake/actions/build/builtin/prepare_static.lua b/xmake/actions/build/builtin/prepare_static.lua deleted file mode 100644 index 6427fd1d8..000000000 --- a/xmake/actions/build/builtin/prepare_static.lua +++ /dev/null @@ -1,22 +0,0 @@ ---!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_static.lua --- - --- imports -inherit("prepare_sourcefiles") diff --git a/xmake/actions/build/target_utils.lua b/xmake/actions/build/target_utils.lua index 28b5872e4..b6f9617c8 100644 --- a/xmake/actions/build/target_utils.lua +++ b/xmake/actions/build/target_utils.lua @@ -26,6 +26,7 @@ import("core.project.project") import("async.runjobs", {alias = "async_runjobs"}) import("async.jobgraph", {alias = "async_jobgraph"}) import("private.utils.batchcmds") +import("builtin.prepare_files") -- clean target for rebuilding function _clean_target(target) @@ -38,60 +39,15 @@ end -- add jobs for the builtin script function _add_jobs_for_builtin_script(jobgraph, target, job_kind) if target:is_static() or target:is_binary() or target:is_shared() or target:is_object() or target:is_moduleonly() then - local script = import("builtin." .. job_kind .. "_" .. target:kind(), {anonymous = true}) - if script then - script(jobgraph, target) - end - end -end - --- add jobs for the given script -function _add_jobs_for_script(jobgraph, instance, script_name, scriptcmd_name) - local has_script = false - local script = instance:script(script_name) - if script then - -- call custom script with jobgraph - -- e.g. - -- - -- target("test") - -- on_build(function (target, jobgraph, opt) - -- end, {jobgraph = true}) - if instance:extraconf(script_name, "jobgraph") then - script(target, jobgraph) - elseif instance:extraconf(script_name, "batch") then - wprint("%s.%s: the batch mode is deprecated, please use jobgraph mode instead of it, or disable `build.jobgraph` policy to use it.", instance:fullname(), script_name) + if job_kind == "prepare" then + prepare_files(jobgraph, target) else - -- call custom script directly - -- e.g. - -- - -- target("test") - -- on_build(function (target, opt) - -- end) - local jobname = string.format("%s/%s/%s", instance == target and "target" or "rule", instance:fullname(), script_name) - jobgraph:add(jobname, function (index, total, opt) - script(target, {progress = opt.progress}) - end) - end - has_script = true - else - -- call command script - -- e.g. - -- - -- target("test") - -- on_buildcmd(function (target, batchcmds, opt) - -- end) - local scriptcmd = instance:script(scriptcmd_name) - if scriptcmd then - local jobname = string.format("%s/%s/%s", instance == target and "target" or "rule", instance:fullname(), scriptcmd_name) - jobgraph:add(jobname, function (index, total, opt) - local batchcmds_ = batchcmds.new({target = target}) - scriptcmd(target, batchcmds_, {progress = opt.progress}) - batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")}) - end) - has_script = true + local script = import("builtin.build_" .. target:kind(), {anonymous = true}) + if script then + script(jobgraph, target) + end end end - return has_script end -- add jobs for the given target stage @@ -120,7 +76,7 @@ function _add_jobs_for_target_stage(jobgraph, target, stage, opt) jobgraph:group(group_name, function () local has_script = false for _, instance in ipairs(instances) do - if _add_jobs_for_script(jobgraph, instance, script_name, scriptcmd_name) then + if add_jobs_for_script(jobgraph, instance, script_name, scriptcmd_name) then has_script = true end end @@ -220,6 +176,55 @@ function _get_jobs(targets_root, opt) return jobgraph end +-- add jobs for the given script +function add_jobs_for_script(jobgraph, instance, script_name, scriptcmd_name) + local has_script = false + local script = instance:script(script_name) + if script then + -- call custom script with jobgraph + -- e.g. + -- + -- target("test") + -- on_build(function (target, jobgraph, opt) + -- end, {jobgraph = true}) + if instance:extraconf(script_name, "jobgraph") then + script(target, jobgraph) + elseif instance:extraconf(script_name, "batch") then + wprint("%s.%s: the batch mode is deprecated, please use jobgraph mode instead of it, or disable `build.jobgraph` policy to use it.", instance:fullname(), script_name) + else + -- call custom script directly + -- e.g. + -- + -- target("test") + -- on_build(function (target, opt) + -- end) + local jobname = string.format("%s/%s/%s", instance == target and "target" or "rule", instance:fullname(), script_name) + jobgraph:add(jobname, function (index, total, opt) + script(target, {progress = opt.progress}) + end) + end + has_script = true + else + -- call command script + -- e.g. + -- + -- target("test") + -- on_buildcmd(function (target, batchcmds, opt) + -- end) + local scriptcmd = instance:script(scriptcmd_name) + if scriptcmd then + local jobname = string.format("%s/%s/%s", instance == target and "target" or "rule", instance:fullname(), scriptcmd_name) + jobgraph:add(jobname, function (index, total, opt) + local batchcmds_ = batchcmds.new({target = target}) + scriptcmd(target, batchcmds_, {progress = opt.progress}) + batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")}) + end) + has_script = true + end + end + return has_script +end + -- get all root targets function get_root_targets(targetnames, opt) opt = opt or {} |
