(build_root, build_type)
| 963 | |
| 964 | |
| 965 | def make_build(build_root, build_type): |
| 966 | debug_print(f'make_build(build_root={build_root}, build_type={build_type})') |
| 967 | if CPU_CORES > 1: |
| 968 | print(f'Performing a parallel build with {CPU_CORES} cores.') |
| 969 | else: |
| 970 | print('Performing a singlethreaded build.') |
| 971 | |
| 972 | make = [find_cmake(), '--build', '.', '--config', build_type] |
| 973 | if 'Visual Studio' in CMAKE_GENERATOR: |
| 974 | # Visual Studio historically has had a two-tier problem in its build system design. A single MSBuild.exe instance only governs |
| 975 | # the build of a single project (.exe/.lib/.dll) in a solution. Passing the -j parameter above will only enable multiple MSBuild.exe |
| 976 | # instances to be spawned to build multiple projects in parallel, but each MSBuild.exe is still singlethreaded. |
| 977 | # To enable each MSBuild.exe instance to also compile several .cpp files in parallel inside a single project, pass the extra |
| 978 | # MSBuild.exe specific "Multi-ToolTask" (MTT) setting /p:CL_MPCount. This enables each MSBuild.exe to parallelize builds wide. |
| 979 | # This requires CMake 3.12 or newer. |
| 980 | make += ['-j', str(CPU_CORES), '--', '/p:CL_MPCount=' + str(CPU_CORES)] |
| 981 | else: |
| 982 | # Pass -j to native make, CMake might not support -j option. |
| 983 | make += ['--', '-j', str(CPU_CORES)] |
| 984 | |
| 985 | # Build |
| 986 | try: |
| 987 | print('Running build: ' + str(make)) |
| 988 | ret = subprocess.check_call(make, cwd=build_root, env=build_env()) |
| 989 | if ret != 0: |
| 990 | errlog(f'Build failed with exit code {ret}!') |
| 991 | errlog('Working directory: ' + build_root) |
| 992 | return False |
| 993 | except Exception as e: |
| 994 | errlog('Build failed due to exception!') |
| 995 | errlog('Working directory: ' + build_root) |
| 996 | errlog(str(e)) |
| 997 | return False |
| 998 | |
| 999 | return True |
| 1000 | |
| 1001 | |
| 1002 | def cmake_configure(generator, build_root, src_root, build_type, extra_cmake_args): |
no test coverage detected