Skip to content

Commit

Permalink
Work around Linux bot not having 'cmake --build . -j' flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
juj committed Jan 27, 2023
1 parent dc7b6ac commit f2aec02
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions emsdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,14 +926,18 @@ def make_build(build_root, build_type, build_target_platform='x64'):
else:
print('Performing a singlethreaded build.')

make = ['cmake', '--build', '.', '--config', build_type, '-j', str(CPU_CORES)]
make = ['cmake', '--build', '.', '--config', build_type]
if 'Visual Studio' in CMAKE_GENERATOR:
# Visual Studio historically has had a two-tier problem in its build system design. A single MSBuild.exe instance only governs
# the build of a single project (.exe/.lib/.dll) in a solution. Passing the -j parameter above will only enable multiple MSBuild.exe
# instances to be spawned to build multiple projects in parallel, but each MSBuild.exe is still singlethreaded.
# To enable each MSBuild.exe instance to also compile several .cpp files in parallel inside a single project, pass the extra
# MSBuild.exe specific "Multi-ToolTask" (MTT) setting /p:CL_MPCount. This enables each MSBuild.exe to parallelize builds wide.
make += ['--', '/p:CL_MPCount=' + str(CPU_CORES)]
# This requires CMake 3.12 or newer.
make += ['-j', str(CPU_CORES), '--', '/p:CL_MPCount=' + str(CPU_CORES)]
else:
# Pass -j to native make, CMake might not support -j option.
make += ['--', '-j', str(CPU_CORES)]

# Build
try:
Expand Down

0 comments on commit f2aec02

Please sign in to comment.