diff options
author | japm48 <japm48@users.noreply.github.com> | 2020-04-17 05:06:10 +0200 |
---|---|---|
committer | Michael Dickens <michael.dickens@ettus.com> | 2020-04-26 18:59:26 -0400 |
commit | e9f9ac51bded33e24a15378a1754de6aa985a2b6 (patch) | |
tree | fe1197fd6cf052240711b31aa420f6de273f6309 /grc/gui/Utils.py | |
parent | 3e62d311565dfcccffaf4a380f399db4d0df9c98 (diff) |
grc: use cmake --build instead of make
This allows the use of other toolchains (ninja, MSVC, etc.).
Also, use all available CPU cores (equivalent of "make -j$(nproc)").
Diffstat (limited to 'grc/gui/Utils.py')
-rw-r--r-- | grc/gui/Utils.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/grc/gui/Utils.py b/grc/gui/Utils.py index 5d710532bd..7538da75ff 100644 --- a/grc/gui/Utils.py +++ b/grc/gui/Utils.py @@ -9,6 +9,7 @@ SPDX-License-Identifier: GPL-2.0-or-later from __future__ import absolute_import from sys import platform +import os import numbers from gi.repository import GLib @@ -174,3 +175,21 @@ def get_modifier_key(angle_brackets=False): return "<Ctrl>" else: return "Ctrl" + + +_nproc = None +def get_cmake_nproc(): + """ Get number of cmake processes for C++ flowgraphs """ + global _nproc # Cached result + if _nproc: + return _nproc + try: + # See https://docs.python.org/3.8/library/os.html#os.cpu_count + _nproc = len(os.sched_getaffinity(0)) + except: + _nproc = os.cpu_count() + if not _nproc: + _nproc = 1 + + _nproc = max(_nproc//2 - 1, 1) + return _nproc |