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

improve to object target #5729 #5759

Merged
merged 1 commit into from
Oct 24, 2024
Merged
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
4 changes: 2 additions & 2 deletions xmake/actions/build/kinds/binary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import("core.tool.compiler")
import("core.project.depend")
import("utils.progress")
import("private.utils.batchcmds")
import("object", {alias = "add_batchjobs_for_object"})
import("object", {alias = "object_target"})
import("linkdepfiles", {alias = "get_linkdepfiles"})

-- do link target
Expand Down Expand Up @@ -143,6 +143,6 @@ function main(batchjobs, rootjob, target)
--
-- unless call set_policy("build.across_targets_in_parallel", false) to disable to build across targets in parallel.
--
local job_objects = add_batchjobs_for_object(batchjobs, job_link, target)
local job_objects = object_target.add_batchjobs_for_object(batchjobs, job_link, target)
return target:policy("build.across_targets_in_parallel") == false and job_objects or job_link, job_objects
end
17 changes: 16 additions & 1 deletion xmake/actions/build/kinds/object.lua
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,22 @@ function add_batchjobs_for_sourcefiles(batchjobs, rootjob, target, sourcebatches
end

-- add batch jobs for building object files
function main(batchjobs, rootjob, target)
function add_batchjobs_for_object(batchjobs, rootjob, target)
return add_batchjobs_for_sourcefiles(batchjobs, rootjob, target, target:sourcebatches())
end

-- add batch jobs for building object target
function main(batchjobs, rootjob, target)

-- add a fake link job
local job_link = batchjobs:addjob(target:name() .. "/fakelink", function (index, total, opt)
end, {rootjob = rootjob})

-- we only need to return and depend the link job for each target,
-- so we can compile the source files for each target in parallel
--
-- unless call set_policy("build.across_targets_in_parallel", false) to disable to build across targets in parallel.
--
local job_objects = add_batchjobs_for_object(batchjobs, job_link, target)
return target:policy("build.across_targets_in_parallel") == false and job_objects or job_link, job_objects
end
4 changes: 2 additions & 2 deletions xmake/actions/build/kinds/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import("core.tool.compiler")
import("core.project.depend")
import("utils.progress")
import("private.utils.batchcmds")
import("object", {alias = "add_batchjobs_for_object"})
import("object", {alias = "object_target"})
import("linkdepfiles", {alias = "get_linkdepfiles"})

-- do link target
Expand Down Expand Up @@ -144,6 +144,6 @@ function main(batchjobs, rootjob, target)
--
-- unless call set_policy("build.across_targets_in_parallel", false) to disable to build across targets in parallel.
--
local job_objects = add_batchjobs_for_object(batchjobs, job_link, target)
local job_objects = object_target.add_batchjobs_for_object(batchjobs, job_link, target)
return target:policy("build.across_targets_in_parallel") == false and job_objects or job_link, job_objects
end
4 changes: 2 additions & 2 deletions xmake/actions/build/kinds/static.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import("core.tool.compiler")
import("core.project.depend")
import("utils.progress")
import("private.utils.batchcmds")
import("object", {alias = "add_batchjobs_for_object"})
import("object", {alias = "object_target"})
import("linkdepfiles", {alias = "get_linkdepfiles"})

-- do link target
Expand Down Expand Up @@ -144,6 +144,6 @@ function main(batchjobs, rootjob, target)
--
-- unless call set_policy("build.across_targets_in_parallel", false) to disable to build across targets in parallel.
--
local job_objects = add_batchjobs_for_object(batchjobs, job_link, target)
local job_objects = object_target.add_batchjobs_for_object(batchjobs, job_link, target)
return target:policy("build.across_targets_in_parallel") == false and job_objects or job_link, job_objects
end
Loading