summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-03-14 00:25:41 +0800
committerruki <[email protected]>2020-03-13 20:34:11 +0800
commit87272da2962c65216670860a2390638c4516841b (patch)
tree55029bdf7baa633c6e625968b94a92da707d19bf
parent6b9c77991a4f6f69fe1faa4e2e9905f71bc5ce94 (diff)
enable build_object batch
-rw-r--r--xmake/actions/build/build.lua2
-rw-r--r--xmake/rules/asm/xmake.lua2
-rw-r--r--xmake/rules/cuda/xmake.lua4
-rw-r--r--xmake/rules/dlang/xmake.lua2
-rw-r--r--xmake/rules/go/build/object.lua23
-rw-r--r--xmake/rules/go/xmake.lua2
-rw-r--r--xmake/rules/objc++/xmake.lua4
-rw-r--r--xmake/rules/swift/xmake.lua2
-rw-r--r--xmake/rules/winsdk/xmake.lua2
9 files changed, 20 insertions, 23 deletions
diff --git a/xmake/actions/build/build.lua b/xmake/actions/build/build.lua
index 74bc77f26..7aa3fff0a 100644
--- a/xmake/actions/build/build.lua
+++ b/xmake/actions/build/build.lua
@@ -185,8 +185,8 @@ function _get_batchjobs(targetname)
if default == nil or default == true or option.get("all") then
for _, depname in ipairs(target:get("deps")) do
depset:insert(depname)
- table.insert(targets, target)
end
+ table.insert(targets, target)
end
end
for _, target in pairs(targets) do
diff --git a/xmake/rules/asm/xmake.lua b/xmake/rules/asm/xmake.lua
index 0c80b2ee5..4bf5ae0d3 100644
--- a/xmake/rules/asm/xmake.lua
+++ b/xmake/rules/asm/xmake.lua
@@ -21,7 +21,7 @@
-- define rule: asm.build
rule("asm.build")
set_sourcekinds("as")
- on_build_files("private.action.build.object")
+ on_build_files("private.action.build.object", {batch = true})
-- define rule: asm
rule("asm")
diff --git a/xmake/rules/cuda/xmake.lua b/xmake/rules/cuda/xmake.lua
index 220299e55..914ac25a5 100644
--- a/xmake/rules/cuda/xmake.lua
+++ b/xmake/rules/cuda/xmake.lua
@@ -22,9 +22,7 @@
rule("cuda.build")
set_sourcekinds("cu")
add_deps("cuda.build.devlink")
- on_build_files(function (target, sourcebatch, opt)
- import("private.action.build.object")(target, sourcebatch, opt)
- end)
+ on_build_files("private.action.build.object", {batch = true})
-- define rule: cuda
rule("cuda")
diff --git a/xmake/rules/dlang/xmake.lua b/xmake/rules/dlang/xmake.lua
index 4e5a957f7..0027b71a6 100644
--- a/xmake/rules/dlang/xmake.lua
+++ b/xmake/rules/dlang/xmake.lua
@@ -21,7 +21,7 @@
-- define rule: dlang.build
rule("dlang.build")
set_sourcekinds("dc")
- on_build_files("private.action.build.object")
+ on_build_files("private.action.build.object", {batch = true})
-- define rule: dlang
rule("dlang")
diff --git a/xmake/rules/go/build/object.lua b/xmake/rules/go/build/object.lua
index 26ab17a59..e32a3f98b 100644
--- a/xmake/rules/go/build/object.lua
+++ b/xmake/rules/go/build/object.lua
@@ -26,7 +26,7 @@ import("core.tool.compiler")
import("core.project.depend")
-- build the source files
-function main(target, sourcebatch, opt)
+function _build_sourcefiles(target, sourcebatch, opt)
-- is verbose?
local verbose = option.get("verbose")
@@ -72,16 +72,11 @@ function main(target, sourcebatch, opt)
-- trace progress info
for index, sourcefile in ipairs(sourcefiles) do
-
- -- calculate progress
- local progress_now = progress.start + ((index - 1) * (progress.stop - progress.start)) / #sourcefiles
-
- -- trace progress info
- cprintf("${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} ", progress_now)
+ local progress_prefix = "${color.build.progress}" .. theme.get("text.build.progress_format") .. ":${clear} "
if verbose then
- cprint("${dim color.build.object}compiling.$(mode) %s", sourcefile)
+ cprint(progress_prefix .. "${dim color.build.object}compiling.$(mode) %s", progress, sourcefile)
else
- cprint("${color.build.object}compiling.$(mode) %s", sourcefile)
+ cprint(progress_prefix .. "${color.build.object}compiling.$(mode) %s", progress, sourcefile)
end
end
@@ -90,9 +85,6 @@ function main(target, sourcebatch, opt)
print(compinst:compcmd(sourcefiles, objectfile, {compflags = compflags}))
end
- -- flush io buffer to update progress info
- io.flush()
-
-- compile it
dependinfo.files = {}
assert(compinst:compile(sourcefiles, objectfile, {dependinfo = dependinfo, compflags = compflags}))
@@ -102,3 +94,10 @@ function main(target, sourcebatch, opt)
table.join2(dependinfo.files, sourcefiles)
depend.save(dependinfo, dependfile)
end
+
+-- add batch jobs to build the source files
+function main(target, batchjobs, sourcebatch, opt)
+ return batchjobs:addjob(target:name() .. "/build_files", function (index, total)
+ _build_sourcefiles(target, sourcebatch, {progress = (index * 100) / total})
+ end, opt.rootjob)
+end
diff --git a/xmake/rules/go/xmake.lua b/xmake/rules/go/xmake.lua
index b7610b0f6..87c04aece 100644
--- a/xmake/rules/go/xmake.lua
+++ b/xmake/rules/go/xmake.lua
@@ -21,7 +21,7 @@
-- define rule: go.build
rule("go.build")
set_sourcekinds("gc")
- on_build_files("build.object")
+ on_build_files("build.object", {batch = true})
-- define rule: cpp
rule("go")
diff --git a/xmake/rules/objc++/xmake.lua b/xmake/rules/objc++/xmake.lua
index 5235aeff8..9f649a834 100644
--- a/xmake/rules/objc++/xmake.lua
+++ b/xmake/rules/objc++/xmake.lua
@@ -22,13 +22,13 @@
rule("objc.build")
set_sourcekinds("mm")
add_deps("c.build.pcheader")
- on_build_files("private.action.build.object")
+ on_build_files("private.action.build.object", {batch = true})
-- define rule: objc++.build
rule("objc++.build")
set_sourcekinds("mxx")
add_deps("c++.build.pcheader")
- on_build_files("private.action.build.object")
+ on_build_files("private.action.build.object", {batch = true})
-- define rule: objc
rule("objc++")
diff --git a/xmake/rules/swift/xmake.lua b/xmake/rules/swift/xmake.lua
index 8207262a4..158a001e3 100644
--- a/xmake/rules/swift/xmake.lua
+++ b/xmake/rules/swift/xmake.lua
@@ -21,7 +21,7 @@
-- define rule: swift.build
rule("swift.build")
set_sourcekinds("sc")
- on_build_files("private.action.build.object")
+ on_build_files("private.action.build.object", {batch = true})
-- define rule: swift
rule("swift")
diff --git a/xmake/rules/winsdk/xmake.lua b/xmake/rules/winsdk/xmake.lua
index 1ab1d55cb..9108e5af7 100644
--- a/xmake/rules/winsdk/xmake.lua
+++ b/xmake/rules/winsdk/xmake.lua
@@ -21,7 +21,7 @@
-- define rule: win.sdk.resource
rule("win.sdk.resource")
set_extensions(".rc")
- on_build_files("private.action.build.object")
+ on_build_files("private.action.build.object", {batch = true})
-- define rule: application
rule("win.sdk.application")