Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add on_prepare stages #6209

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion xmake/actions/build/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions xmake/actions/build/build_files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
26 changes: 26 additions & 0 deletions xmake/actions/build/prepare.lua
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions xmake/core/project/rule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions xmake/core/project/target.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
10 changes: 9 additions & 1 deletion xmake/core/sandbox/modules/import/core/project/project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
--
Expand Down
Loading