diff options
| author | ruki <[email protected]> | 2021-09-07 00:55:33 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-09-07 00:55:33 +0800 |
| commit | 0a271b992bb97a3d2e6b00d9facf1eb26ef2f899 (patch) | |
| tree | 1c3d73587e2258e69350723093298d00adec38c3 | |
| parent | 02411882d17b8a71ba900cd803dfc3b5ec612da7 (diff) | |
improve njob
| -rw-r--r-- | xmake/actions/build/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/actions/require/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/project/project.lua | 2 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/interpreter/os.lua | 43 | ||||
| -rw-r--r-- | xmake/modules/package/tools/autoconf.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/package/tools/cmake.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/package/tools/make.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/package/tools/ninja.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/package/tools/scons.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/xrepo/action/install.lua | 2 |
10 files changed, 32 insertions, 31 deletions
diff --git a/xmake/actions/build/xmake.lua b/xmake/actions/build/xmake.lua index 3323ac5b1..631536f24 100644 --- a/xmake/actions/build/xmake.lua +++ b/xmake/actions/build/xmake.lua @@ -47,7 +47,7 @@ task("build") , {nil, "dry-run", "k", nil , "Dry run to build target." } , {} - , {'j', "jobs", "kv", tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)), + , {'j', "jobs", "kv", tostring(os.default_njob()), "Set the number of parallel compilation jobs." } , {nil, "linkjobs", "kv", nil, "Set the number of parallel link jobs." } , {'w', "warning", "k", false , "Enable the warnings output." } diff --git a/xmake/actions/require/xmake.lua b/xmake/actions/require/xmake.lua index f33188f77..3ffd17fe3 100644 --- a/xmake/actions/require/xmake.lua +++ b/xmake/actions/require/xmake.lua @@ -46,7 +46,7 @@ task("require") " $ xmake require --clean", " $ xmake require --clean zlib tbox pcr*" } , {'f', "force", "k", nil, "Force to reinstall all package dependencies." } - , {'j', "jobs", "kv", tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)), + , {'j', "jobs", "kv", tostring(os.default_njob()), "Set the number of parallel compilation jobs." } , {nil, "linkjobs", "kv", nil, "Set the number of parallel link jobs." } , {nil, "shallow", "k", nil, "Does not install dependent packages." } diff --git a/xmake/core/sandbox/modules/import/core/project/project.lua b/xmake/core/sandbox/modules/import/core/project/project.lua index 34b5fa7ac..2330dccd0 100644 --- a/xmake/core/sandbox/modules/import/core/project/project.lua +++ b/xmake/core/sandbox/modules/import/core/project/project.lua @@ -110,7 +110,7 @@ function sandbox_core_project.check() end -- check all options - local jobs = baseoption.get("jobs") or math.ceil(os.cpuinfo().ncpu * 3 / 2) + local jobs = baseoption.get("jobs") or os.default_njob() import("private.async.runjobs", {anonymous = true})("check_options", instance:fork(checktask):script(), {total = #options, comax = jobs}) -- save all options to the cache file diff --git a/xmake/core/sandbox/modules/interpreter/os.lua b/xmake/core/sandbox/modules/interpreter/os.lua index 10c4b710c..dff4a14d7 100644 --- a/xmake/core/sandbox/modules/interpreter/os.lua +++ b/xmake/core/sandbox/modules/interpreter/os.lua @@ -27,27 +27,28 @@ local interpreter = require("base/interpreter") local sandbox_os = sandbox_os or {} -- export some readonly interfaces -sandbox_os.term = os.term -sandbox_os.host = os.host -sandbox_os.arch = os.arch -sandbox_os.subhost = os.subhost -sandbox_os.subarch = os.subarch -sandbox_os.date = os.date -sandbox_os.time = os.time -sandbox_os.mtime = os.mtime -sandbox_os.mclock = os.mclock -sandbox_os.getenv = os.getenv -sandbox_os.isdir = os.isdir -sandbox_os.isfile = os.isfile -sandbox_os.exists = os.exists -sandbox_os.curdir = os.curdir -sandbox_os.tmpdir = os.tmpdir -sandbox_os.cpuinfo = os.cpuinfo -sandbox_os.filesize = os.filesize -sandbox_os.programdir = os.programdir -sandbox_os.programfile = os.programfile -sandbox_os.projectdir = os.projectdir -sandbox_os.projectfile = os.projectfile +sandbox_os.term = os.term +sandbox_os.host = os.host +sandbox_os.arch = os.arch +sandbox_os.subhost = os.subhost +sandbox_os.subarch = os.subarch +sandbox_os.date = os.date +sandbox_os.time = os.time +sandbox_os.mtime = os.mtime +sandbox_os.mclock = os.mclock +sandbox_os.getenv = os.getenv +sandbox_os.isdir = os.isdir +sandbox_os.isfile = os.isfile +sandbox_os.exists = os.exists +sandbox_os.curdir = os.curdir +sandbox_os.tmpdir = os.tmpdir +sandbox_os.cpuinfo = os.cpuinfo +sandbox_os.default_njob = os.default_njob +sandbox_os.filesize = os.filesize +sandbox_os.programdir = os.programdir +sandbox_os.programfile = os.programfile +sandbox_os.projectdir = os.projectdir +sandbox_os.projectfile = os.projectfile -- match files function sandbox_os.files(pattern, ...) diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua index 209e6c68a..9e4f8c4b4 100644 --- a/xmake/modules/package/tools/autoconf.lua +++ b/xmake/modules/package/tools/autoconf.lua @@ -299,7 +299,7 @@ function install(package, configs, opt) -- do make and install opt = opt or {} - local njob = opt.jobs or option.get("jobs") or tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) + local njob = opt.jobs or option.get("jobs") or tostring(os.default_njob()) local argv = {"-j" .. njob} if option.get("verbose") then table.insert(argv, "V=1") diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 73af75b32..857f859be 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -30,7 +30,7 @@ import("package.tools.ninja") -- get the number of parallel jobs function _get_parallel_njobs(opt) - return opt.jobs or option.get("jobs") or tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) + return opt.jobs or option.get("jobs") or tostring(os.default_njob()) end -- translate paths diff --git a/xmake/modules/package/tools/make.lua b/xmake/modules/package/tools/make.lua index ff6dce8ed..a40cd57c1 100644 --- a/xmake/modules/package/tools/make.lua +++ b/xmake/modules/package/tools/make.lua @@ -91,7 +91,7 @@ function build(package, configs, opt) opt = opt or {} -- pass configurations - local njob = opt.jobs or option.get("jobs") or tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) + local njob = opt.jobs or option.get("jobs") or tostring(os.default_njob()) local argv = {"-j" .. njob} if option.get("verbose") then table.insert(argv, "VERBOSE=1") diff --git a/xmake/modules/package/tools/ninja.lua b/xmake/modules/package/tools/ninja.lua index e1feccc14..e16731670 100644 --- a/xmake/modules/package/tools/ninja.lua +++ b/xmake/modules/package/tools/ninja.lua @@ -26,7 +26,7 @@ import("lib.detect.find_tool") function build(package, configs, opt) opt = opt or {} local buildir = opt.buildir or os.curdir() - local njob = opt.jobs or option.get("jobs") or tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) + local njob = opt.jobs or option.get("jobs") or tostring(os.default_njob()) local ninja = assert(find_tool("ninja"), "ninja not found!") local argv = {"-C", buildir} if option.get("verbose") then @@ -44,7 +44,7 @@ end function install(package, configs, opt) opt = opt or {} local buildir = opt.buildir or os.curdir() - local njob = tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) + local njob = tostring(os.default_njob()) local ninja = assert(find_tool("ninja"), "ninja not found!") local argv = {"install", "-C", buildir} if option.get("verbose") then diff --git a/xmake/modules/package/tools/scons.lua b/xmake/modules/package/tools/scons.lua index 386645bba..0c197933f 100644 --- a/xmake/modules/package/tools/scons.lua +++ b/xmake/modules/package/tools/scons.lua @@ -86,7 +86,7 @@ end function build(package, configs, opt) opt = opt or {} local buildir = opt.buildir or os.curdir() - local njob = opt.jobs or option.get("jobs") or tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)) + local njob = opt.jobs or option.get("jobs") or tostring(os.default_njob()) local scons = assert(find_tool("scons"), "scons not found!") local argv = {"-C", buildir, "-j", njob} configs = _get_configs(package, configs) diff --git a/xmake/modules/private/xrepo/action/install.lua b/xmake/modules/private/xrepo/action/install.lua index ccd14c839..f6f111185 100644 --- a/xmake/modules/private/xrepo/action/install.lua +++ b/xmake/modules/private/xrepo/action/install.lua @@ -40,7 +40,7 @@ function menu_options() "e.g.", " - xrepo install -f \"vs_runtime=MD\" zlib", " - xrepo install -f \"regex=true,thread=true\" boost"}, - {'j', "jobs", "kv", tostring(math.ceil(os.cpuinfo().ncpu * 3 / 2)), + {'j', "jobs", "kv", tostring(os.default_njob()), "Set the number of parallel compilation jobs."}, {nil, "linkjobs", "kv", nil, "Set the number of parallel link jobs."}, {nil, "includes", "kv", nil, "Includes extra lua configuration files.", |
