2021-12-20 16:36:29 +00:00
|
|
|
#!/bin/bash
|
2018-05-31 00:57:41 +00:00
|
|
|
#
|
2022-01-11 12:18:48 +00:00
|
|
|
# Version 1.0.1 Build 9
|
|
|
|
#
|
2018-05-31 00:57:41 +00:00
|
|
|
# config.sh - multi-language support configuration script
|
|
|
|
# Definition of absolute paths etc.
|
|
|
|
# This file is 'included' in all scripts.
|
|
|
|
#
|
2022-01-11 12:18:48 +00:00
|
|
|
#############################################################################
|
|
|
|
# Change log:
|
|
|
|
# 31 May 2018, XPila, Initial
|
|
|
|
# 17 Dec. 2021, 3d-gussner, Change default Arduino path to by PF-build.sh
|
|
|
|
# created one
|
|
|
|
# Prepare to use one config file for all languages
|
|
|
|
# 11 Jan. 2022, 3d-gussner, Added version and Change log colored output
|
|
|
|
# Use `git rev-list --count HEAD config.sh`
|
|
|
|
# to get Build Nr
|
|
|
|
# Check if variables are set by other scripts
|
|
|
|
# and use these. More flexible for different build
|
|
|
|
# scripts
|
|
|
|
# Check correctly if files or dirs exist
|
|
|
|
#############################################################################
|
|
|
|
#
|
2018-05-31 00:57:41 +00:00
|
|
|
# Arduino main folder:
|
2018-11-26 19:24:24 +00:00
|
|
|
if [ -z "$ARDUINO" ]; then
|
2021-12-17 14:23:00 +00:00
|
|
|
export ARDUINO=../../PF-build-env-1.0.6/1.8.5-1.0.4-linux-64 #C:/arduino-1.8.5
|
2018-11-26 19:24:24 +00:00
|
|
|
fi
|
2018-05-31 00:57:41 +00:00
|
|
|
#
|
|
|
|
# Arduino builder:
|
2022-01-11 12:18:48 +00:00
|
|
|
if [ -z "$BUILDER" ]; then
|
|
|
|
export BUILDER=$ARDUINO/arduino-builder
|
|
|
|
fi
|
2018-05-31 00:57:41 +00:00
|
|
|
#
|
|
|
|
# AVR gcc tools:
|
2022-01-11 12:18:48 +00:00
|
|
|
if [ -z "$OBJCOPY" ]; then
|
|
|
|
export OBJCOPY=$ARDUINO/hardware/tools/avr/bin/avr-objcopy
|
|
|
|
fi
|
|
|
|
if [ -z "$OBJDUMP" ]; then
|
|
|
|
export OBJDUMP=$ARDUINO/hardware/tools/avr/bin/avr-objdump
|
|
|
|
fi
|
2018-05-31 00:57:41 +00:00
|
|
|
#
|
|
|
|
# Output folder:
|
2021-04-23 10:15:48 +00:00
|
|
|
if [ -z "$OUTDIR" ]; then
|
|
|
|
export OUTDIR="../../Prusa-Firmware-build"
|
|
|
|
fi
|
2018-05-31 00:57:41 +00:00
|
|
|
#
|
|
|
|
# Objects folder:
|
2022-01-11 12:18:48 +00:00
|
|
|
if [ -z "$OBJDIR" ]; then
|
|
|
|
export OBJDIR="$OUTDIR/sketch"
|
|
|
|
fi
|
2018-05-31 00:57:41 +00:00
|
|
|
#
|
|
|
|
# Generated elf file:
|
2022-01-11 12:18:48 +00:00
|
|
|
if [ -z "$INOELF" ]; then
|
|
|
|
export INOELF="$OUTDIR/Firmware.ino.elf"
|
|
|
|
fi
|
2018-05-31 00:57:41 +00:00
|
|
|
#
|
|
|
|
# Generated hex file:
|
2022-01-11 12:18:48 +00:00
|
|
|
if [ -z "$INOHEX" ]; then
|
|
|
|
export INOHEX="$OUTDIR/Firmware.ino.hex"
|
|
|
|
fi
|
2021-12-17 14:24:52 +00:00
|
|
|
#
|
|
|
|
# Set default languages
|
|
|
|
if [ -z "$LANGUAGES" ]; then
|
|
|
|
export LANGUAGES="cz de es fr it pl"
|
|
|
|
fi
|
|
|
|
#
|
|
|
|
# Check for community languages
|
|
|
|
MAX_COMMINITY_LANG=10 # Total 16 - 6 default
|
|
|
|
COMMUNITY_LANGUAGES=""
|
|
|
|
#Search Firmware/config.h for active community group
|
|
|
|
COMMUNITY_LANG_GROUP=$(grep --max-count=1 "^#define COMMUNITY_LANG_GROUP" ../Firmware/config.h| cut -d ' ' -f3)
|
2018-05-31 00:57:41 +00:00
|
|
|
|
2021-12-17 14:24:52 +00:00
|
|
|
# Search Firmware/config.h for active community languanges
|
|
|
|
if [ "$COMMUNITY_LANG_GROUP" = "1" ]; then
|
|
|
|
COMMUNITY_LANGUAGES=$(grep --max-count=$MAX_COMMINITY_LANG "^#define COMMUNITY_LANG_GROUP1_" ../Firmware/config.h| cut -d '_' -f4 |cut -d ' ' -f1 |tr '[:upper:]' '[:lower:]'| tr '\n' ' ')
|
|
|
|
elif [ "$COMMUNITY_LANG_GROUP" = "2" ]; then
|
|
|
|
COMMUNITY_LANGUAGES=$(grep --max-count=$MAX_COMMINITY_LANG "^#define COMMUNITY_LANG_GROUP2_" ../Firmware/config.h| cut -d '_' -f4 |cut -d ' ' -f1 |tr '[:upper:]' '[:lower:]'| tr '\n' ' ')
|
|
|
|
elif [ "$COMMUNITY_LANG_GROUP" = "3" ]; then
|
|
|
|
COMMUNITY_LANGUAGES=$(grep --max-count=$MAX_COMMINITY_LANG "^#define COMMUNITY_LANG_GROUP3_" ../Firmware/config.h| cut -d '_' -f4 |cut -d ' ' -f1 |tr '[:upper:]' '[:lower:]'| tr '\n' ' ')
|
|
|
|
fi
|
2021-12-20 16:36:29 +00:00
|
|
|
|
2021-12-17 14:24:52 +00:00
|
|
|
if [ -z "$COMMUNITY_LANGUAGES" ]; then
|
|
|
|
export COMMUNITY_LANGUAGES="$COMMUNITY_LANGUAGES"
|
|
|
|
fi
|
2018-05-31 00:57:41 +00:00
|
|
|
|
2022-01-11 12:18:48 +00:00
|
|
|
echo "$(tput setaf 2)config.sh started$(tput sgr0)" >&2
|
2018-05-31 00:57:41 +00:00
|
|
|
|
|
|
|
_err=0
|
|
|
|
|
|
|
|
echo -n " Arduino main folder: " >&2
|
2022-01-11 12:18:48 +00:00
|
|
|
if [ -d $ARDUINO ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=1; fi
|
2018-05-31 00:57:41 +00:00
|
|
|
|
|
|
|
echo -n " Arduino builder: " >&2
|
2022-01-11 12:18:48 +00:00
|
|
|
if [ -e $BUILDER ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=2; fi
|
2018-05-31 00:57:41 +00:00
|
|
|
|
|
|
|
echo " AVR gcc tools:" >&2
|
|
|
|
echo -n " objcopy " >&2
|
2022-01-11 12:18:48 +00:00
|
|
|
if [ -e $OBJCOPY ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=3; fi
|
2018-05-31 00:57:41 +00:00
|
|
|
echo -n " objdump " >&2
|
2022-01-11 12:18:48 +00:00
|
|
|
if [ -e $OBJDUMP ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=4; fi
|
2018-05-31 00:57:41 +00:00
|
|
|
|
|
|
|
echo -n " Output folder: " >&2
|
2022-01-11 12:18:48 +00:00
|
|
|
if [ -d $OUTDIR ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=5; fi
|
2018-05-31 00:57:41 +00:00
|
|
|
|
|
|
|
echo -n " Objects folder: " >&2
|
2022-01-11 12:18:48 +00:00
|
|
|
if [ -d $OBJDIR ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=6; fi
|
2018-05-31 00:57:41 +00:00
|
|
|
|
|
|
|
echo -n " Generated elf file: " >&2
|
2022-01-11 12:18:48 +00:00
|
|
|
if [ -e $INOELF ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=7; fi
|
2018-05-31 00:57:41 +00:00
|
|
|
|
|
|
|
echo -n " Generated hex file: " >&2
|
2022-01-11 12:18:48 +00:00
|
|
|
if [ -e $INOHEX ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=8; fi
|
2018-05-31 00:57:41 +00:00
|
|
|
|
2021-12-17 14:24:52 +00:00
|
|
|
echo -n " Languages: " >&2
|
2022-01-11 12:18:48 +00:00
|
|
|
echo "$(tput setaf 2)$LANGUAGES$(tput sgr0)" >&2
|
2021-12-17 14:24:52 +00:00
|
|
|
|
|
|
|
echo -n " Community languages: " >&2
|
2022-01-11 12:18:48 +00:00
|
|
|
echo "$(tput setaf 2)$COMMUNITY_LANGUAGES$(tput sgr0)" >&2
|
2021-12-17 14:24:52 +00:00
|
|
|
|
2018-05-31 00:57:41 +00:00
|
|
|
if [ $_err -eq 0 ]; then
|
2022-01-11 12:18:48 +00:00
|
|
|
echo "$(tput setaf 2)config.sh finished with success$(tput sgr0)" >&2
|
2018-05-31 00:57:41 +00:00
|
|
|
export CONFIG_OK=1
|
|
|
|
else
|
2022-01-11 12:18:48 +00:00
|
|
|
echo "$(tput setaf 1)config.sh finished with errors!$(tput sgr0)" >&2
|
2018-05-31 00:57:41 +00:00
|
|
|
export CONFIG_OK=0
|
|
|
|
fi
|