From 49cd6a117f00418e6be8fbfaef8f5286b9a99197 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Fri, 4 Aug 2017 11:13:14 +0200 Subject: [PATCH] Add argument to specify the number of jobs Using the python method 'cpu_count()' is not working everywhere. In Linux containers, 'multiprocessing.cpu_count()' returns the number of cpu's of the host machine, not the number assigned to the linux container. --- scripts/jenkins.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/jenkins.py b/scripts/jenkins.py index 00218e638..35cadadb3 100644 --- a/scripts/jenkins.py +++ b/scripts/jenkins.py @@ -35,7 +35,7 @@ class Builder: os.environ['PATH'] += os.pathsep + self._get_qt_binary_path() self._specific_prepare() - def build(self, dev_build): + def build(self, jobs, dev_build): """ Run the build itself. Pass dev_build=True to enable a dev build """ @@ -50,8 +50,10 @@ class Builder: qmake_call += ['-r', os.pardir] subprocess.check_call(qmake_call, env=dict(os.environ)) - job_arg = '-j{0}'.format(multiprocessing.cpu_count()) - subprocess.check_call([self.make_cmd, job_arg], env=dict(os.environ)) + if not jobs: + jobs = multiprocessing.cpu_count() + jobs_arg = '-j{0}'.format(jobs) + subprocess.check_call([self.make_cmd, jobs_arg], env=dict(os.environ)) def checks(self): """ @@ -327,9 +329,10 @@ def main(argv): word_size = '' tool_chain = '' dev_build = False + jobs = None try: - opts, args = getopt.getopt(argv, 'hc:w:t:d', ['config=', 'wordsize=', 'toolchain=', 'dev']) + opts, args = getopt.getopt(argv, 'hc:w:t:j:d', ['config=', 'wordsize=', 'toolchain=', 'jobs=', 'dev']) except getopt.GetoptError: print_help() sys.exit(2) @@ -351,6 +354,8 @@ def main(argv): word_size = arg elif opt in ('-t', '--toolchain'): tool_chain = arg + elif opt in ('-j', '--jobs'): + jobs = arg elif opt in ('-d', '--dev'): dev_build = True @@ -375,7 +380,7 @@ def main(argv): builder = builders[platform.system()][tool_chain](config_file, word_size) builder.prepare() - builder.build(dev_build) + builder.build(jobs, dev_build) builder.checks() builder.install() builder.package_xswiftbus()