From 2bedd687dbac7fbef80bd948720ea703433db616 Mon Sep 17 00:00:00 2001 From: disarray2077 <86157825+disarray2077@users.noreply.github.com> Date: Thu, 7 Jul 2022 21:22:08 -0300 Subject: [PATCH 1/2] Add Ninja as a optional CMake Generator Ninja: real 2m25.508s user 9m52.981s sys 0m32.548s Without ninja: real 8m38.425s user 8m5.723s sys 0m30.840s --- bin/build.sh | 9 +++++++-- extern/llvm_build.sh | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/bin/build.sh b/bin/build.sh index 22c3b141..8fefad49 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -7,6 +7,11 @@ ROOTPATH="$(dirname "$SCRIPTPATH")" echo Building from from $SCRIPTPATH cd $SCRIPTPATH +USE_NINJA="" +if command -v ninja >/dev/null 2>&1 ; then + USE_NINJA="-GNinja" +fi + # exit when any command fails set -e @@ -35,10 +40,10 @@ if [ ! -d jbuild_d ]; then mkdir jbuild fi cd jbuild_d -cmake -DCMAKE_BUILD_TYPE=Debug ../ +cmake $USE_NINJA -DCMAKE_BUILD_TYPE=Debug ../ cmake --build . cd ../jbuild -cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ../ +cmake $USE_NINJA -DCMAKE_BUILD_TYPE=RelWithDebInfo ../ cmake --build . cd ../IDE/dist diff --git a/extern/llvm_build.sh b/extern/llvm_build.sh index 261e8062..b81e11b6 100755 --- a/extern/llvm_build.sh +++ b/extern/llvm_build.sh @@ -1,6 +1,11 @@ #!/bin/bash set -e +USE_NINJA="" +if command -v ninja >/dev/null 2>&1 ; then + USE_NINJA="-GNinja" +fi + if [ ! -d llvm-project_13_0_1 ]; then if [ -f llvm-13.0.1.src.tar.xz ]; then # if user downloaded llvm-13.0.1.src.tar.xz then use it instead tar -xf llvm-13.0.1.src.tar.xz @@ -17,7 +22,7 @@ fi if [ ! -d llvm_linux_13_0_1/bin ]; then cd llvm_linux_13_0_1 - cmake ../llvm-project_13_0_1/llvm -DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86;WebAssembly" -DCMAKE_BUILD_TYPE:String="Debug" + cmake $USE_NINJA ../llvm-project_13_0_1/llvm -DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86;WebAssembly" -DCMAKE_BUILD_TYPE:String="Debug" cmake --build . -t $(cat ../llvm_targets.txt) cd .. fi @@ -28,7 +33,7 @@ fi if [ ! -d llvm_linux_rel_13_0_1/bin ]; then cd llvm_linux_rel_13_0_1 - cmake ../llvm-project_13_0_1/llvm -DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86;WebAssembly" -DCMAKE_BUILD_TYPE:String="Release" + cmake $USE_NINJA ../llvm-project_13_0_1/llvm -DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86;WebAssembly" -DCMAKE_BUILD_TYPE:String="Release" cmake --build . -t $(cat ../llvm_targets.txt) cd .. fi From 986b326c250ba4d8cbc63cbbdea042995164877f Mon Sep 17 00:00:00 2001 From: disarray2077 <86157825+disarray2077@users.noreply.github.com> Date: Thu, 7 Jul 2022 22:54:17 -0300 Subject: [PATCH 2/2] Don't use Ninja if the build files weren't generated by Ninja --- bin/build.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/bin/build.sh b/bin/build.sh index 8fefad49..155770f3 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -4,12 +4,28 @@ echo Starting build.sh PATH=/usr/local/bin:$PATH:$HOME/bin SCRIPTPATH=$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P) ROOTPATH="$(dirname "$SCRIPTPATH")" -echo Building from from $SCRIPTPATH +echo Building from $SCRIPTPATH cd $SCRIPTPATH -USE_NINJA="" +if [[ $1 == "clean" ]]; then + rm -rf ../jbuild + rm -rf ../jbuild_d +fi + if command -v ninja >/dev/null 2>&1 ; then - USE_NINJA="-GNinja" + CAN_USE_NINJA=1 + if [ -d ../jbuild_d ] && [ ! -f ../jbuild_d/build.ninja ]; then + CAN_USE_NINJA=0 + fi + + if [ $CAN_USE_NINJA == 1 ]; then + echo "Ninja is enabled for this build." + USE_NINJA="-GNinja" + else + echo "Ninja couldn't be enabled for this build, consider doing a clean build to start using Ninja for faster build speeds." + fi +else + echo "Ninja isn't installed, consider installing it for faster build speeds." fi # exit when any command fails