Skip to content

Commit

Permalink
Merge pull request #129 from garbear/build-parallel
Browse files Browse the repository at this point in the history
Build cores in parellel
  • Loading branch information
garbear authored Jul 19, 2024
2 parents 713e545 + 889c4d5 commit ea97c6c
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion templates/addon/depends/common/{{ game.name }}/CMakeLists.txt.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ include(ExternalProject)

string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)

# Jenkins CI jobs can have this env var set
# Use it if available
if(DEFINED ENV{BUILDTHREADS})
set(build_job_count -j$ENV{BUILDTHREADS})
message(STATUS "Using $ENV{BUILDTHREADS} threads from ENV var BUILDTHREADS")
else()
# Most likely a non CI build, so do a best attempt just using ProcessorCount
include(ProcessorCount)
ProcessorCount(cpu_count)
if(NOT cpu_count EQUAL 0)
set(build_job_count -j${cpu_count})
message(STATUS "Using ${cpu_count} threads deduced by ProcessorCount")
endif()
endif()

set(LIBRETRO_BINARY_DIR {{ config.binary_dir | default(makefile.dir) }})
set(LIBRETRO_SONAME {{ library.soname }}${CMAKE_SHARED_LIBRARY_SUFFIX})
set(LIBRETRO_JNISONAME {{ library.jnisoname }}${CMAKE_SHARED_LIBRARY_SUFFIX})
Expand All @@ -24,9 +39,9 @@ if(CORE_SYSTEM_NAME STREQUAL windows)
set(MSYSTEM MINGW32)
endif()
set(BUILD_COMMAND ${MINGW_MAKE}
-j$ENV{NUMBER_OF_PROCESSORS}
-C {{ makefile.dir }}
-f {{ makefile.file }}
${build_job_count}
${LIBRETRO_DEBUG}
GIT_VERSION=
MSYSTEM=${MSYSTEM}
Expand All @@ -36,6 +51,7 @@ elseif(CORE_SYSTEM_NAME STREQUAL linux)
set(BUILD_COMMAND $(MAKE)
-C {{ makefile.dir }}
-f {{ makefile.file }}
${build_job_count}
${LIBRETRO_DEBUG}
GIT_VERSION=
platform=unix
Expand All @@ -49,6 +65,7 @@ elseif(CORE_SYSTEM_NAME STREQUAL osx)
set(BUILD_COMMAND $(MAKE)
-C {{ makefile.dir }}
-f {{ makefile.file }}
${build_job_count}
${LIBRETRO_DEBUG}
arch=${ARCH}
CROSS_COMPILE=1
Expand All @@ -68,6 +85,7 @@ elseif(CORE_SYSTEM_NAME STREQUAL ios OR CORE_SYSTEM_NAME STREQUAL darwin_embedde
set(BUILD_COMMAND IOSSDK=${CMAKE_OSX_SYSROOT} $(MAKE)
-C {{ makefile.dir }}
-f {{ makefile.file }}
${build_job_count}
${LIBRETRO_DEBUG}
GIT_VERSION=
platform=${PLATFORM}
Expand All @@ -77,6 +95,7 @@ elseif(CORE_SYSTEM_NAME STREQUAL ios OR CORE_SYSTEM_NAME STREQUAL darwin_embedde
set(BUILD_COMMAND IOSSDK=${CMAKE_OSX_SYSROOT} $(MAKE)
-C {{ makefile.dir }}
-f {{ makefile.file }}
${build_job_count}
${LIBRETRO_DEBUG}
GIT_VERSION=
platform=tvos-arm64
Expand All @@ -97,6 +116,7 @@ elseif(CORE_SYSTEM_NAME STREQUAL android)
endif()
set(BUILD_COMMAND GNUMAKE=$(MAKE) ${NDKROOT}/ndk-build
-C {{ makefile.jni }}
${build_job_count}
${LIBRETRO_DEBUG}
APP_ABI=${PLATFORM}
APP_SHORT_COMMANDS=true
Expand All @@ -119,6 +139,7 @@ elseif(CORE_SYSTEM_NAME STREQUAL android)
set(BUILD_COMMAND PATH=${TOOLCHAIN_DIR}:$ENV{PATH} $(MAKE)
-C {{ makefile.dir }}
-f {{ makefile.file }}
${build_job_count}
${LIBRETRO_DEBUG}
GIT_VERSION=
platform=${PLATFORM}
Expand All @@ -130,6 +151,7 @@ elseif(CORE_SYSTEM_NAME STREQUAL freebsd)
set(BUILD_COMMAND $(MAKE)
-C {{ makefile.dir }}
-f {{ makefile.file }}
${build_job_count}
${LIBRETRO_DEBUG}
GIT_VERSION=
platform=unix
Expand Down

0 comments on commit ea97c6c

Please sign in to comment.