Skip to content

Commit

Permalink
Use all cpu cores as default when compiling for android & linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangbin committed Aug 20, 2014
1 parent f8f9121 commit f7158ae
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions plugins/project_compile/project_compile.py
Expand Up @@ -59,7 +59,7 @@ def _add_custom_options(self, parser):
from argparse import ArgumentParser
parser.add_argument("-m", "--mode", dest="mode", default='debug',
help="Set the compile mode, should be debug|release, default is debug.")
parser.add_argument("-j", "--jobs", dest="jobs", type=int, default=1,
parser.add_argument("-j", "--jobs", dest="jobs", type=int,
help="Allow N jobs at once.")

group = parser.add_argument_group("Android Options")
Expand Down Expand Up @@ -123,7 +123,11 @@ def _check_custom_options(self, args):
self._compile_script = (self._mode == "release")

self._ap = args.android_platform
self._jobs = args.jobs

if args.jobs is not None:
self._jobs = args.jobs
else:
self._jobs = self.get_num_of_cpu()

self._has_sourcemap = args.source_map
self._no_res = args.no_res
Expand All @@ -137,6 +141,21 @@ def _check_custom_options(self, args):

self._gen_custom_step_args()

def get_num_of_cpu(self):
try:
platform = sys.platform
if platform == 'win32':
if 'NUMBER_OF_PROCESSORS' in os.environ:
return int(os.environ['NUMBER_OF_PROCESSORS'])
else:
return 1
else:
from numpy.distutils import cpuinfo
return cpuinfo.cpu._getNCPUs()
except Exception:
print "Can't know cpuinfo, use default 1 cpu"
return 1

def _get_output_dir(self):
project_dir = self._project.get_project_dir()
cur_platform = self._platforms.get_current_platform()
Expand Down

0 comments on commit f7158ae

Please sign in to comment.