summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2022-02-28 23:56:38 +0100
committerLinus Groh <mail@linusgroh.de>2022-03-08 17:12:35 +0100
commit3192cabc0ed73b5efd13d184fef943d9affc47e6 (patch)
treebfb96bc83f47c996f1b507480df012c8890b1596
parent7036f8c89c622ed770b56979584c13ed341defaa (diff)
downloadserenity-3192cabc0ed73b5efd13d184fef943d9affc47e6.zip
Meta: Read MAKEJOBS to limit jobs for ninja in serenity.sh
The default behavior of using all cores will still apply if no MAKEJOBS variable is supplied.
-rw-r--r--Meta/CMake/processor-count.cmake3
-rwxr-xr-xMeta/serenity.sh8
2 files changed, 9 insertions, 2 deletions
diff --git a/Meta/CMake/processor-count.cmake b/Meta/CMake/processor-count.cmake
new file mode 100644
index 0000000000..d77786de4c
--- /dev/null
+++ b/Meta/CMake/processor-count.cmake
@@ -0,0 +1,3 @@
+include(ProcessorCount)
+ProcessorCount(N)
+message("${N}")
diff --git a/Meta/serenity.sh b/Meta/serenity.sh
index a4b75f8409..0bb9bab652 100755
--- a/Meta/serenity.sh
+++ b/Meta/serenity.sh
@@ -218,12 +218,16 @@ build_target() {
# invoked superbuild for serenity target that doesn't set -DBUILD_LAGOM=ON
cmake -S "$SERENITY_SOURCE_DIR/Meta/Lagom" -B "$BUILD_DIR" -DBUILD_LAGOM=ON
fi
+
+ # Get either the environement MAKEJOBS or all processors via CMake
+ [ -z "$MAKEJOBS" ] && MAKEJOBS=$(cmake -P "$SERENITY_SOURCE_DIR/Meta/CMake/processor-count.cmake")
+
# With zero args, we are doing a standard "build"
# With multiple args, we are doing an install/image/run
if [ $# -eq 0 ]; then
- cmake --build "$SUPER_BUILD_DIR"
+ CMAKE_BUILD_PARALLEL_LEVEL="$MAKEJOBS" cmake --build "$SUPER_BUILD_DIR"
else
- ninja -C "$BUILD_DIR" -- "$@"
+ ninja -j "$MAKEJOBS" -C "$BUILD_DIR" -- "$@"
fi
}