You've already forked dspico-firmware
mirror of
https://github.com/LNH-team/dspico-firmware.git
synced 2026-01-09 16:28:22 -08:00
* 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.
42 lines
1.2 KiB
Bash
Executable File
42 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
###############################################################
|
|
# File: compile.sh
|
|
# Creation Date: 10/11/2022 (DD/MM/YYYY)
|
|
# Description: All-in-one script to update, setup and
|
|
# build the DSpico firmware.
|
|
#
|
|
# Author: pedro-javierf
|
|
# 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/ || 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).
|
|
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
|
|
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"
|