Skip to content

Commit 958f4e5

Browse files
committed
deps: allow a --generator switch to update_deps.py
This allows you to use any CMake generator available on your system to configure the dependent repositories, allowing you to match the same generator being used by the project build. update_deps.py: - Take a parameter to specify a CMake generator, and pass it to CMake if present - Allow the user to reduce the count of parallel make jobs that can happen at one time - remove an unnecessary semicolon
1 parent e87666d commit 958f4e5

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

scripts/update_deps.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,12 @@ def CMakeConfig(self, repos):
415415
cmake_cmd.append('-A')
416416
cmake_cmd.append('x64')
417417

418+
# Apply a generator, if one is specified. This can be used to supply
419+
# a specific generator for the dependent repositories to match
420+
# that of the main repository.
421+
if self._args.generator is not None:
422+
cmake_cmd.extend(['-G', self._args.generator])
423+
418424
if VERBOSE:
419425
print("CMake command: " + " ".join(cmake_cmd))
420426

@@ -435,8 +441,15 @@ def CMakeBuild(self):
435441
# Speed up the build.
436442
if platform.system() == 'Linux' or platform.system() == 'Darwin':
437443
cmake_cmd.append('--')
438-
cmake_cmd.append('-j{ncpu}'
439-
.format(ncpu=multiprocessing.cpu_count()))
444+
num_make_jobs = multiprocessing.cpu_count()
445+
env_make_jobs = os.environ.get('MAKE_JOBS', None)
446+
if env_make_jobs is not None:
447+
try:
448+
num_make_jobs = min(num_make_jobs, int(env_make_jobs))
449+
except ValueError:
450+
print('warning: environment variable MAKE_JOBS has non-numeric value "{}". '
451+
'Using {} (CPU count) instead.'.format(env_make_jobs, num_make_jobs))
452+
cmake_cmd.append('-j{}'.format(num_make_jobs))
440453
if platform.system() == 'Windows':
441454
cmake_cmd.append('--')
442455
cmake_cmd.append('/maxcpucount')
@@ -594,6 +607,11 @@ def main():
594607
type=str.lower,
595608
help="Set build files configuration",
596609
default='debug')
610+
parser.add_argument(
611+
'--generator',
612+
dest='generator',
613+
help="Set the CMake generator",
614+
default=None)
597615

598616
args = parser.parse_args()
599617
save_cwd = os.getcwd()
@@ -628,7 +646,7 @@ def main():
628646
'build_platforms',
629647
'repo_dir',
630648
'on_build_platform')
631-
repo_dict[repo.name] = {field: getattr(repo, field) for field in field_list};
649+
repo_dict[repo.name] = {field: getattr(repo, field) for field in field_list}
632650

633651
# If the repo has a CI whitelist, skip the repo unless
634652
# one of the CI's environment variable is set to true.

0 commit comments

Comments
 (0)