From f4f65e4c8444d1402f55356797edda10b07c6233 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 4 Dec 2015 21:06:29 +0200 Subject: [PATCH] Improve code builder for parallel builds (up to 4 times faster than before) --- HISTORY.rst | 1 + platformio/__init__.py | 2 +- platformio/platforms/base.py | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 4cba0f05..06c18d5e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,7 @@ PlatformIO 2.0 2.5.0 (2015-12-??) ~~~~~~~~~~~~~~~~~~ +* Improved code builder for parallel builds (up to 4 times faster than before) * Generate `.travis.yml `__ CI config for embedded projects by default (`issue #354 `_) diff --git a/platformio/__init__.py b/platformio/__init__.py index 3365b850..ba9f8ca5 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION = (2, 5, "0.dev0") +VERSION = (2, 5, "0.dev1") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/platforms/base.py b/platformio/platforms/base.py index c4488dd1..ccfe1364 100644 --- a/platformio/platforms/base.py +++ b/platformio/platforms/base.py @@ -15,6 +15,7 @@ import os import re from imp import load_source +from multiprocessing import cpu_count from os.path import isdir, isfile, join import click @@ -389,6 +390,8 @@ class BasePlatform(object): [ "scons", "-Q", + "-j %d" % self.get_job_nums(), + "--warn=no-no-parallel-support", "-f", join(util.get_source_dir(), "builder", "main.py") ] + variables + targets, stdout=util.AsyncPipe(self.on_run_out), @@ -432,3 +435,9 @@ class BasePlatform(object): self._last_echo_line = line click.secho(line, fg=fg, err=level < 3) + + def get_job_nums(self): + try: + return cpu_count() + except NotImplementedError: + return 1