summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-03-14 10:20:26 +0800
committerruki <[email protected]>2020-03-14 10:20:26 +0800
commit20eff88a7ef198356a19a28346d19d76acf7d140 (patch)
tree7cc1f10c49f040d15edd11d36957de121146c955
parent9477b131e2f4ce5735ef282ec907cc56a7c37757 (diff)
fix build golang target
-rw-r--r--tests/projects/other/merge_archive/xmake.lua1
-rw-r--r--xmake/actions/build/kinds/binary.lua14
-rw-r--r--xmake/actions/build/kinds/shared.lua14
-rw-r--r--xmake/actions/build/kinds/static.lua14
-rw-r--r--xmake/rules/go/xmake.lua4
5 files changed, 35 insertions, 12 deletions
diff --git a/tests/projects/other/merge_archive/xmake.lua b/tests/projects/other/merge_archive/xmake.lua
index 86a08ab8a..07be717b8 100644
--- a/tests/projects/other/merge_archive/xmake.lua
+++ b/tests/projects/other/merge_archive/xmake.lua
@@ -14,6 +14,7 @@ target("mul")
set_kind("static")
add_deps("add", "sub")
add_files("src/mul.c")
+ set_values("build.across_targets_in_parallel", false)
if is_plat("windows") then
add_files("$(buildir)/merge_archive/*.lib")
else
diff --git a/xmake/actions/build/kinds/binary.lua b/xmake/actions/build/kinds/binary.lua
index aa9a4df4a..ba8077122 100644
--- a/xmake/actions/build/kinds/binary.lua
+++ b/xmake/actions/build/kinds/binary.lua
@@ -153,11 +153,17 @@ end
-- add batch jobs for building binary target
function main(batchjobs, rootjob, target)
- -- we need only return and depend the link job for each target,
- -- so we can compile the source files for each target in parallel
+
+ -- add link job
local job_link = batchjobs:addjob(target:name() .. "/link", function (index, total)
_link_target(target, {progress = (index * 100) / total})
end, rootjob)
- add_batchjobs_for_object(batchjobs, job_link, target)
- return job_link
+
+ -- we need only return and depend the link job for each target,
+ -- so we can compile the source files for each target in parallel
+ --
+ -- unless call set_values("build.across_targets_in_parallel") to disable to build across targets in parallel.
+ --
+ local job_objects = add_batchjobs_for_object(batchjobs, job_link, target)
+ return target:values("build.across_targets_in_parallel") == false and job_objects or job_link
end
diff --git a/xmake/actions/build/kinds/shared.lua b/xmake/actions/build/kinds/shared.lua
index 873e4df0f..544f8fcbf 100644
--- a/xmake/actions/build/kinds/shared.lua
+++ b/xmake/actions/build/kinds/shared.lua
@@ -166,11 +166,17 @@ end
-- add batch jobs for building shared target
function main(batchjobs, rootjob, target)
- -- we need only return and depend the link job for each target,
- -- so we can compile the source files for each target in parallel
+
+ -- add link job
local job_link = batchjobs:addjob(target:name() .. "/link", function (index, total)
_link_target(target, {progress = (index * 100) / total})
end, rootjob)
- add_batchjobs_for_object(batchjobs, job_link, target)
- return job_link
+
+ -- we need only return and depend the link job for each target,
+ -- so we can compile the source files for each target in parallel
+ --
+ -- unless call set_values("build.across_targets_in_parallel") to disable to build across targets in parallel.
+ --
+ local job_objects = add_batchjobs_for_object(batchjobs, job_link, target)
+ return target:values("build.across_targets_in_parallel") == false and job_objects or job_link
end
diff --git a/xmake/actions/build/kinds/static.lua b/xmake/actions/build/kinds/static.lua
index a4227e013..a53bd9cca 100644
--- a/xmake/actions/build/kinds/static.lua
+++ b/xmake/actions/build/kinds/static.lua
@@ -162,11 +162,17 @@ end
-- add batch jobs for building static target
function main(batchjobs, rootjob, target)
- -- we need only return and depend the link job for each target,
- -- so we can compile the source files for each target in parallel
+
+ -- add link job
local job_link = batchjobs:addjob(target:name() .. "/link", function (index, total)
_link_target(target, {progress = (index * 100) / total})
end, rootjob)
- add_batchjobs_for_object(batchjobs, job_link, target)
- return job_link
+
+ -- we need only return and depend the link job for each target,
+ -- so we can compile the source files for each target in parallel
+ --
+ -- unless call set_values("build.across_targets_in_parallel") to disable to build across targets in parallel.
+ --
+ local job_objects = add_batchjobs_for_object(batchjobs, job_link, target)
+ return target:values("build.across_targets_in_parallel") == false and job_objects or job_link
end
diff --git a/xmake/rules/go/xmake.lua b/xmake/rules/go/xmake.lua
index b7610b0f6..e32dbe95e 100644
--- a/xmake/rules/go/xmake.lua
+++ b/xmake/rules/go/xmake.lua
@@ -21,6 +21,10 @@
-- define rule: go.build
rule("go.build")
set_sourcekinds("gc")
+ on_load(function (target)
+ -- we disable to build across targets in parallel, because the source files may depend on other target modules
+ target:set("values.build.across_targets_in_parallel", false)
+ end)
on_build_files("build.object")
-- define rule: cpp