rusefi/firmware/config/boards/common_script_read_meta_env...

40 lines
1.0 KiB
PHP
Raw Normal View History

#!/bin/bash
# this script is supposed to be executed from within 'firmware' folder
if [ -z "$1" ]; then
echo "Read meta.env: The file path was not given as a parameter!"
exit -3
fi
BOARD_META_PATH=./$1
2024-02-15 13:01:03 -08:00
BOARD_META_DIR=${BOARD_META_PATH%/*}
export BOARD_DIR=${BOARD_DIR:-$BOARD_META_DIR}
if [ ! -f ${BOARD_META_PATH} ]; then
echo "Read meta.env: The file was not found!"
exit -4
fi
if [ ! -f ${BOARD_DIR}/board.mk ]; then
echo "WARNING! board.mk not found @ ${BOARD_DIR}..."
fi
echo "[META] Reading meta env from ${BOARD_META_PATH}"
2024-02-15 13:01:03 -08:00
VARS=$(grep "=" "$BOARD_META_PATH")
2024-02-15 13:01:03 -08:00
while IFS= read -r L; do
# get the key and delete all spaces
K=$(echo "$L" | cut -d '=' -f "-1" | tr -d ' ')
# get the value and delete any leading space
V=$(echo "$L" | cut -d '=' -f "2-" | awk '{$1=$1};1')
# put them together, closing the value in quotes
export $K="$V"
done <<< "$VARS"
echo "[META] PROJECT_BOARD=${PROJECT_BOARD}"
echo "[META] PROJECT_CPU=${PROJECT_CPU}"
echo "[META] POST_BUILD_SCRIPT=${POST_BUILD_SCRIPT}"
echo "[META] BOARD_DIR=${BOARD_DIR}"