summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-04-08 00:40:15 +0800
committerruki <[email protected]>2025-04-08 15:31:58 +0800
commit6fc28a78bf95490b5c230a42c0f4a40ab5aad2e4 (patch)
tree765fdf40b993ba33760b114b04a8b92eb3093d7a
parent07ac1c481e0a30161389328365efcbebc15d88d9 (diff)
move target files
-rw-r--r--xmake/actions/build/build.lua2
-rw-r--r--xmake/actions/build/build_files.lua2
-rw-r--r--xmake/modules/private/action/build/build_binary.lua38
-rw-r--r--xmake/modules/private/action/build/build_moduleonly.lua26
-rw-r--r--xmake/modules/private/action/build/build_object.lua26
-rw-r--r--xmake/modules/private/action/build/build_shared.lua26
-rw-r--r--xmake/modules/private/action/build/build_static.lua26
-rw-r--r--xmake/modules/private/action/build/link_objects.lua68
-rw-r--r--xmake/modules/private/action/build/prepare_files.lua27
-rw-r--r--xmake/modules/private/action/build/target.lua (renamed from xmake/actions/build/target_utils.lua)9
10 files changed, 244 insertions, 6 deletions
diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua
index d3fdd8e80..270b24ea7 100644
--- a/xmake/actions/build/build.lua
+++ b/xmake/actions/build/build.lua
@@ -22,8 +22,8 @@
import("core.base.option")
import("core.project.config")
import("core.project.project")
-import("target_utils")
import("private.service.distcc_build.client", {alias = "distcc_build_client"})
+import("private.action.build.target", {alias = "target_utils"})
import("deprecated.build", {alias = "deprecated_build"})
-- run prepare jobs
diff --git a/xmake/actions/build/build_files.lua b/xmake/actions/build/build_files.lua
index 854f7de3f..12d9b00ee 100644
--- a/xmake/actions/build/build_files.lua
+++ b/xmake/actions/build/build_files.lua
@@ -23,8 +23,8 @@ import("core.base.option")
import("core.base.hashset")
import("core.project.config")
import("core.project.project")
-import("target_utils")
import("private.service.distcc_build.client", {alias = "distcc_build_client"})
+import("private.action.build.target", {alias = "target_utils"})
import("deprecated.build_files", {alias = "deprecated_build_files"})
-- convert all sourcefiles to lua pattern
diff --git a/xmake/modules/private/action/build/build_binary.lua b/xmake/modules/private/action/build/build_binary.lua
new file mode 100644
index 000000000..c30addfef
--- /dev/null
+++ b/xmake/modules/private/action/build/build_binary.lua
@@ -0,0 +1,38 @@
+--!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 build_binary.lua
+--
+
+-- imports
+import("build_object")
+import("private.action.build.target", {alias = "target_utils"})
+
+function main(jobgraph, target)
+ local objects_group = target:fullname() .. "/objects"
+ local jobsize = jobgraph:size()
+ jobgraph:group(objects_group, function ()
+ build_object(jobgraph, target)
+ end)
+ if jobgraph:size() > jobsize then
+ local link_group = target:fullname() .. "/link"
+ jobgraph:group(link_group, function ()
+ target_utils.add_linkjobs(jobgraph, target)
+ end)
+ jobgraph:add_orders(objects_group, link_group)
+ end
+end
diff --git a/xmake/modules/private/action/build/build_moduleonly.lua b/xmake/modules/private/action/build/build_moduleonly.lua
new file mode 100644
index 000000000..e3cc87c27
--- /dev/null
+++ b/xmake/modules/private/action/build/build_moduleonly.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 build_moduleonly.lua
+--
+
+-- imports
+import("build_object")
+
+function main(jobgraph, target)
+ build_object(jobgraph, target)
+end
diff --git a/xmake/modules/private/action/build/build_object.lua b/xmake/modules/private/action/build/build_object.lua
new file mode 100644
index 000000000..2a44bcea6
--- /dev/null
+++ b/xmake/modules/private/action/build/build_object.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 build_object.lua
+--
+
+-- imports
+import("private.action.build.target", {alias = "target_utils"})
+
+function main(jobgraph, target)
+ target_utils.add_filejobs(jobgraph, target, {job_kind = "build"})
+end
diff --git a/xmake/modules/private/action/build/build_shared.lua b/xmake/modules/private/action/build/build_shared.lua
new file mode 100644
index 000000000..077489710
--- /dev/null
+++ b/xmake/modules/private/action/build/build_shared.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 build_shared.lua
+--
+
+-- imports
+import("build_binary")
+
+function main(jobgraph, target)
+ build_binary(jobgraph, target)
+end
diff --git a/xmake/modules/private/action/build/build_static.lua b/xmake/modules/private/action/build/build_static.lua
new file mode 100644
index 000000000..8b9b2ffaf
--- /dev/null
+++ b/xmake/modules/private/action/build/build_static.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 build_static.lua
+--
+
+-- imports
+import("build_binary")
+
+function main(jobgraph, target)
+ build_binary(jobgraph, target)
+end
diff --git a/xmake/modules/private/action/build/link_objects.lua b/xmake/modules/private/action/build/link_objects.lua
new file mode 100644
index 000000000..099674d3e
--- /dev/null
+++ b/xmake/modules/private/action/build/link_objects.lua
@@ -0,0 +1,68 @@
+--!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 link_objects.lua
+--
+
+-- imports
+import("core.base.option")
+import("core.tool.linker")
+import("core.tool.compiler")
+import("core.project.depend")
+import("utils.progress")
+import("build_object")
+import("private.action.build.target", {alias = "target_utils"})
+
+-- do link target
+function _do_link_target(target, opt)
+ local linkinst = linker.load(target:kind(), target:sourcekinds(), {target = target})
+ local linkflags = linkinst:linkflags({target = target})
+
+ -- need build this target?
+ local depfiles = target_utils.get_linkdepfiles(target)
+ local dryrun = option.get("dry-run")
+ local depvalues = {linkinst:program(), linkflags}
+ depend.on_changed(function ()
+ local filename = target:filename()
+ if target:namespace() then
+ filename = target:namespace() .. "::" .. filename
+ end
+ progress.show(opt.progress, "${color.build.target}linking.$(mode) %s", filename)
+
+ local targetfile = target:targetfile()
+ local objectfiles = target:objectfiles()
+ local verbose = option.get("verbose")
+ if verbose then
+ -- show the full link command with raw arguments, it will expand @xxx.args for msvc/link on windows
+ print(linkinst:linkcmd(objectfiles, targetfile, {linkflags = linkflags, rawargs = true}))
+ end
+
+ if not dryrun then
+ assert(linkinst:link(objectfiles, targetfile, {linkflags = linkflags}))
+ end
+ end, {dependfile = target:dependfile(),
+ lastmtime = os.mtime(target:targetfile()),
+ changed = target:is_rebuilt() or option.get("linkonly"),
+ values = depvalues, files = depfiles, dryrun = dryrun})
+end
+
+function main(jobgraph, target)
+ local linkjob = target:fullname() .. "/link_objects"
+ jobgraph:add(linkjob, function (index, total, opt)
+ _do_link_target(target, opt)
+ end)
+end
diff --git a/xmake/modules/private/action/build/prepare_files.lua b/xmake/modules/private/action/build/prepare_files.lua
new file mode 100644
index 000000000..a0ecc242a
--- /dev/null
+++ b/xmake/modules/private/action/build/prepare_files.lua
@@ -0,0 +1,27 @@
+--!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_files.lua
+--
+
+-- imports
+import("core.base.option")
+import("private.action.build.target", {alias = "target_utils"})
+
+function main(jobgraph, target)
+ target_utils.add_filejobs(jobgraph, target, {job_kind = "prepare"})
+end
diff --git a/xmake/actions/build/target_utils.lua b/xmake/modules/private/action/build/target.lua
index 2f68830c0..b6d428692 100644
--- a/xmake/actions/build/target_utils.lua
+++ b/xmake/modules/private/action/build/target.lua
@@ -15,7 +15,7 @@
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author ruki
--- @file target_utils.lua
+-- @file target.lua
--
-- imports
@@ -122,11 +122,11 @@ end
function add_targetjobs_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
if job_kind == "prepare" then
- import("builtin.prepare_files", {anonymous = true})(jobgraph, target)
+ import("private.action.build.prepare_files", {anonymous = true})(jobgraph, target)
elseif job_kind == "link" then
- import("builtin.link_objects", {anonymous = true})(jobgraph, target)
+ import("private.action.build.link_objects", {anonymous = true})(jobgraph, target)
else
- import("builtin.build_" .. target:kind(), {anonymous = true})(jobgraph, target)
+ import("private.action.build.build_" .. target:kind(), {anonymous = true})(jobgraph, target)
end
end
end
@@ -715,3 +715,4 @@ function run_filejobs(targets_root, opt)
return true
end
end
+