summaryrefslogtreecommitdiff
path: root/xmake/core/base/os.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2021-09-07 00:54:27 +0800
committerruki <[email protected]>2021-09-07 00:54:27 +0800
commit02411882d17b8a71ba900cd803dfc3b5ec612da7 (patch)
tree0a40385acc5009208eae2d23e0cfa3b86ffc7110 /xmake/core/base/os.lua
parentb6923a6915f452da991fa2818028dde2c1ff1ac5 (diff)
add os.default_njob
Diffstat (limited to 'xmake/core/base/os.lua')
-rw-r--r--xmake/core/base/os.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index ea913b977..312d5705d 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -1237,6 +1237,21 @@ function os.cpuinfo(name)
return require("base/cpu").info(name)
end
+-- get the default parallel jobs number
+function os.default_njob()
+ local njob = math.ceil(os.cpuinfo().ncpu * 3 / 2)
+ if os.host() == "windows" and njob > 128 then
+ njob = 128
+ end
+ if njob > 512 then
+ njob = 512
+ end
+ if njob < 1 then
+ njob = 1
+ end
+ return njob
+end
+
-- read the content of symlink
function os.readlink(symlink)
return os._readlink(path.absolute(symlink))