diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-06-13 20:55:40 +0200 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-07-26 09:56:20 +0200 |
commit | a9c7bc7c9aa81fa394a1bf46aa6ff7ac536afe88 (patch) | |
tree | e47ca8084b74812ec7a58a6006045439bf239611 | |
parent | ee4e6d2fbaf545ad9c1405cb804c6dce1cc13d5f (diff) | |
download | rockbox-a9c7bc7c9aa81fa394a1bf46aa6ff7ac536afe88.tar.gz rockbox-a9c7bc7c9aa81fa394a1bf46aa6ff7ac536afe88.zip |
deploy: Simplify retrieving CPU count.
The multiprocessing module is part of Python since 2.6, so no need to do
an extra check here.
Change-Id: If1c223edf9f04b6de8fdf757ba00f79897783a53
-rwxr-xr-x | utils/common/deploy.py | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/utils/common/deploy.py b/utils/common/deploy.py index 1dbeb494dd..04eef0b7d5 100755 --- a/utils/common/deploy.py +++ b/utils/common/deploy.py | |||
@@ -44,16 +44,11 @@ import time | |||
44 | import hashlib | 44 | import hashlib |
45 | import tempfile | 45 | import tempfile |
46 | from datetime import datetime | 46 | from datetime import datetime |
47 | import multiprocessing | ||
47 | import gitscraper | 48 | import gitscraper |
48 | 49 | ||
49 | # modules that are not part of python itself. | 50 | CPUS = multiprocessing.cpu_count() |
50 | cpus = 1 | 51 | print("Info: %s cores found." % CPUS) |
51 | try: | ||
52 | import multiprocessing | ||
53 | cpus = multiprocessing.cpu_count() | ||
54 | print("Info: %s cores found." % cpus) | ||
55 | except ImportError: | ||
56 | print("Warning: multiprocessing module not found. Assuming 1 core.") | ||
57 | 52 | ||
58 | # == Global stuff == | 53 | # == Global stuff == |
59 | # DLL files to ignore when searching for required DLL files. | 54 | # DLL files to ignore when searching for required DLL files. |
@@ -216,9 +211,9 @@ def build(wd=".", platform=sys.platform, cross=""): | |||
216 | print("Building ...") | 211 | print("Building ...") |
217 | # use the current platforms make here, cross compiling uses the native make. | 212 | # use the current platforms make here, cross compiling uses the native make. |
218 | command = [make[sys.platform]] | 213 | command = [make[sys.platform]] |
219 | if cpus > 1: | 214 | if CPUS > 1: |
220 | command.append("-j") | 215 | command.append("-j") |
221 | command.append(str(cpus)) | 216 | command.append(str(CPUS)) |
222 | output = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=wd) | 217 | output = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=wd) |
223 | while True: | 218 | while True: |
224 | c = output.stdout.readline() | 219 | c = output.stdout.readline() |