Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def set_max_job_count(env, count = 0):
- """
- Sets the max job count for SCons execution.
- If count == 0 then we determine the number of CPU's on the system
- and sets the maximum job count accordingly.
- """
- def get_cpu_nums():
- """
- Detects the number of CPUs on a system.
- """
- # Linux, Unix and MacOS:
- if hasattr(os, "sysconf"):
- if os.sysconf_names.has_key("SC_NPROCESSORS_ONLN"):
- # Linux & Unix:
- ncpus = os.sysconf("SC_NPROCESSORS_ONLN")
- if isinstance(ncpus, int) and ncpus > 0:
- return ncpus
- else: # OSX:
- return int(os.popen2("sysctl -n hw.ncpu")[1].read())
- # Windows:
- if os.environ.has_key("NUMBER_OF_PROCESSORS"):
- ncpus = int(os.environ["NUMBER_OF_PROCESSORS"]);
- if ncpus > 0:
- return ncpus
- return 1 # Default
- job_count = get_cpu_nums() if not count else count
- print "scons: Max %d parallel jobs" % job_count
- env.SetOption("num_jobs", job_count)
Add Comment
Please, Sign In to add comment