add -j option to make

Parallelism is usually a good thing when it comes to build source codes.
This patch adds the -j option to make utils using ncpus+1 when -j is not
provided by the user.

Reference: https://trello.com/c/H4e7SuOCSigned-off-by: NAmador Pahim <apahim@redhat.com>
上级 eb89520e
......@@ -12,6 +12,7 @@
# Copyright: Red Hat Inc. 2013-2014
# Author: Lucas Meneghel Rodrigues <lmr@redhat.com>
import multiprocessing
import os
from . import process
......@@ -41,6 +42,15 @@ def make(path, make='make', env=None, extra_args='', ignore_status=False, allow_
cwd = os.getcwd()
os.chdir(path)
cmd = make
# Set default number of jobs as ncpus + 1
if "-j" not in os.environ.get("MAKEFLAGS", ""):
jobs = multiprocessing.cpu_count() + 1
if not env:
env = {"MAKEFLAGS": "-j%s" % jobs}
elif "-j" not in env:
env["MAKEFLAGS"] = "-j%s" % jobs
makeopts = os.environ.get('MAKEOPTS', '')
if makeopts:
cmd += ' %s' % makeopts
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册