From 8e5e43f44e52c12899ecdccb755206b5c079f258 Mon Sep 17 00:00:00 2001 From: PoroCYon Date: Thu, 27 Nov 2025 12:38:09 +0100 Subject: [PATCH 1/2] Fix compatibility issues in compile.sh * Use '/usr/bin/env bash', because not all distros put bash in /bin (some in /usr/bin), and with NixOS it's even more complicated. This should make it compatible across all distros. * The 'set -euo pipefail' makes the script exit immediately on error, otherwise it tries to continue e.g. running make when the CMake configuration failed. * Change to the directory the script sits in, in case it is ever called from another directory. * With CMake 4.x, declaring compatibility with version 3.5 straight up errors. Passing the environment variable fixes this issue. See https://gitlab.kitware.com/cmake/cmake/-/issues/26613 and https://gitlab.kitware.com/cmake/cmake/-/issues/26698 for more info. * CMake doesn't always emit Makefiles by default, so use `cmake --build' to build using whatever method CMake will choose. * Compile using all available cores, instead of only using a single CPU core. --- compile.sh | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) mode change 100644 => 100755 compile.sh diff --git a/compile.sh b/compile.sh old mode 100644 new mode 100755 index 2151319..d993528 --- a/compile.sh +++ b/compile.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ############################################################### # File: compile.sh # Creation Date: 10/11/2022 (DD/MM/YYYY) @@ -9,26 +9,33 @@ # Copyright: LNH team (c) 2022, all rights reserved ################################################################ +set -euo pipefail +# change directory to the one containing the source code project +cd "$(dirname "$(realpath "$0")")" + +# check available CMake version echo "[>] Configuring project with CMake.." # Clean previous build/ folders if they exist -rm -rf build/ -mkdir build - -# Export the SDK Path before running CMAKE -export PICO_SDK_PATH=../pico-sdk +rm -rf build/ || true +mkdir -p build # Specify CMAKE where we want the build tree to be at. # In our case, the build/ directory. # The source directory will be . (the current directory, # where the CMakeLists.txt is located). -cmake -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -B build/ . +PICO_SDK_PATH=../pico-sdk \ +CMAKE_POLICY_VERSION_MINIMUM=3.5 \ + cmake -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \ + -B build/ . echo "[>] Building FIRMWARE: " # Go and build the firmware -cd build -make +PICO_SDK_PATH=../pico-sdk \ +CMAKE_POLICY_VERSION_MINIMUM=3.5 \ +CMAKE_BUILD_PARALLEL_LEVEL="$(nproc)" \ + cmake --build build echo "[>] Build completed. Find the DSpico.uf2 file inside build/ folder" From a7e49ca01725dd28b64898cf72ee58517b00e71a Mon Sep 17 00:00:00 2001 From: PoroCYon Date: Wed, 10 Dec 2025 15:24:39 +0100 Subject: [PATCH 2/2] fix compatibility with macOS in compile.sh --- .gitignore | 3 ++- compile.sh | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4d0f7c7..eff7f39 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ Debug/ Release/ build/ +cmake-build*/ out/ # Compiled source # @@ -48,4 +49,4 @@ Thumbs.db *.a .vscode/ roms/*.nds -data/uartBufv060.bin \ No newline at end of file +data/uartBufv060.bin diff --git a/compile.sh b/compile.sh index d993528..eb036d9 100755 --- a/compile.sh +++ b/compile.sh @@ -11,6 +11,14 @@ set -euo pipefail +if command -v nproc >/dev/null 2>&1; then + NPROC="$(nproc)" +else + # macOS doesn't have nproc(1). using getconf here is also more general than + # using sysctl + NPROC="$(getconf _NPROCESSORS_ONLN)" +fi + # change directory to the one containing the source code project cd "$(dirname "$(realpath "$0")")" @@ -35,7 +43,7 @@ echo "[>] Building FIRMWARE: " # Go and build the firmware PICO_SDK_PATH=../pico-sdk \ CMAKE_POLICY_VERSION_MINIMUM=3.5 \ -CMAKE_BUILD_PARALLEL_LEVEL="$(nproc)" \ +CMAKE_BUILD_PARALLEL_LEVEL="${NPROC}" \ cmake --build build echo "[>] Build completed. Find the DSpico.uf2 file inside build/ folder"