wolfBoot/tools/scripts/cmake_test.sh

50 lines
1.6 KiB
Bash

#!/bin/bash
# Specify the executable shell checker you want to use:
MY_SHELLCHECK="shellcheck"
# Check if the executable is available in the PATH
if command -v "$MY_SHELLCHECK" >/dev/null 2>&1; then
# Run your command here
shellcheck "$0" || exit 1
else
echo "$MY_SHELLCHECK is not installed. Please install it if changes to this script have been made."
fi
# Resolve this script's absolute path and its directories
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
SCRIPT_PATH="${SCRIPT_DIR}/$(basename -- "${BASH_SOURCE[0]}")"
REPO_ROOT="$(cd -- "${SCRIPT_DIR}/../../" && pwd)"
# Normalize to physical paths (no symlinks, no trailing slashes)
# SCRIPT_DIR_P="$(cd -- "$SCRIPT_DIR" && pwd -P)"
REPO_ROOT_P="$(cd -- "$REPO_ROOT" && pwd -P)"
CALLER_CWD_P="$(pwd -P)" # <— where the user ran the script from
# Print only if caller's cwd is neither REPO_ROOT nor REPO_ROOT/scripts
case "$CALLER_CWD_P" in
"$REPO_ROOT_P" | "$REPO_ROOT_P"/scripts)
: # silent
;;
*)
echo "Script paths:"
echo "-- SCRIPT_PATH =$SCRIPT_PATH"
echo "-- SCRIPT_DIR =$SCRIPT_DIR"
echo "-- REPO_ROOT =$REPO_ROOT"
;;
esac
# Always work from the repo root, regardless of where the script was invoked
cd -- "$REPO_ROOT_P" || { printf 'Failed to cd to: %s\n' "$REPO_ROOT_P" >&2; exit 1; }
echo "Starting $0 from $(pwd -P)"
echo "Remove prior build directories..."
rm -rf ./build-stm32l4
echo "cmake --preset stm32l4"
cmake --preset stm32l4
echo "cmake --build --preset stm32l4"
cmake --build --preset stm32l4