RpiPicoW_UDP_Communication/compilAndFlash.sh

34 lines
685 B
Bash
Executable File

#!/bin/bash
# Build the project
if [ "$1" = "-D" ] || [ "$1" = "--delete" ]; then
rm -rf build/*
echo "Build directory cleaned"
fi
# Create build directory if it doesn't exist
if [ ! -d "build" ]; then
mkdir build
fi
# Enter build directory
cd build || exit 1
# Only run CMake if CMakeCache.txt doesn't exist or if it's older than CMakeLists.txt
if [ ! -f "CMakeCache.txt" ] || [ "../CMakeLists.txt" -nt "CMakeCache.txt" ]; then
cmake -DPICO_BOARD=pico_w ..
if [ $? -ne 0 ]; then
echo "CMake configuration failed"
exit 1
fi
fi
# Build the project
if ! make -j; then
echo "Build failed"
exit 1
fi
# Flash the device
sudo make Flash