Skip to content

Commit

Permalink
Merge pull request #5759 from xmake-io/object
Browse files Browse the repository at this point in the history
improve to object target #5729
  • Loading branch information
waruqi authored Oct 24, 2024
2 parents b805dc5 + 82aafe2 commit deb5564
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
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

0 comments on commit deb5564

Please sign in to comment.