forked from OctaForge/OctaBuild
add numcpus and numjobs
parent
b97b71d281
commit
2f5a95327b
|
@ -7,6 +7,9 @@ if (=s $CC "") [
|
||||||
echo "using compiler:" $CC
|
echo "using compiler:" $CC
|
||||||
]
|
]
|
||||||
|
|
||||||
|
echo "number of CPUs:" $numcpus
|
||||||
|
echo "number of jobs:" $numjobs
|
||||||
|
|
||||||
rule all test
|
rule all test
|
||||||
|
|
||||||
OBJ = (strreplace (glob "*.c") ".c" ".o")
|
OBJ = (strreplace (glob "*.c") ".c" ".o")
|
||||||
|
|
13
main.cc
13
main.cc
|
@ -1,3 +1,4 @@
|
||||||
|
#include <limits.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <ostd/types.hh>
|
#include <ostd/types.hh>
|
||||||
|
@ -5,6 +6,7 @@
|
||||||
#include <ostd/vector.hh>
|
#include <ostd/vector.hh>
|
||||||
#include <ostd/atomic.hh>
|
#include <ostd/atomic.hh>
|
||||||
#include <ostd/filesystem.hh>
|
#include <ostd/filesystem.hh>
|
||||||
|
#include <ostd/platform.hh>
|
||||||
|
|
||||||
#include <cubescript.hh>
|
#include <cubescript.hh>
|
||||||
|
|
||||||
|
@ -289,6 +291,10 @@ int main(int argc, char **argv) {
|
||||||
cscript::init_lib_string(os.cs);
|
cscript::init_lib_string(os.cs);
|
||||||
cscript::init_lib_list(os.cs);
|
cscript::init_lib_list(os.cs);
|
||||||
|
|
||||||
|
int ncpus = ostd::cpu_count_get();
|
||||||
|
os.cs.add_ident(cscript::ID_VAR, "numcpus", INT_MAX, 1, &ncpus);
|
||||||
|
os.cs.add_ident(cscript::ID_VAR, "numjobs", INT_MAX, 1, &os.jobs);
|
||||||
|
|
||||||
ConstCharRange fname = "cubefile";
|
ConstCharRange fname = "cubefile";
|
||||||
ConstCharRange fcont;
|
ConstCharRange fcont;
|
||||||
|
|
||||||
|
@ -307,9 +313,12 @@ int main(int argc, char **argv) {
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
return ob_print_help(argv[0], ostd::out, 0);
|
return ob_print_help(argv[0], ostd::out, 0);
|
||||||
case 'j':
|
case 'j': {
|
||||||
os.jobs = ostd::max(1, atoi(optarg));
|
int val = atoi(optarg);
|
||||||
|
if (!val) val = ncpus + 1;
|
||||||
|
os.jobs = ostd::max(1, val);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 'E':
|
case 'E':
|
||||||
ignore_env = true;
|
ignore_env = true;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue