config.sh 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #!/bin/bash
  2. #
  3. # Version 1.0.1 Build 9
  4. #
  5. # config.sh - multi-language support configuration script
  6. # Definition of absolute paths etc.
  7. # This file is 'included' in all scripts.
  8. #
  9. #############################################################################
  10. # Change log:
  11. # 31 May 2018, XPila, Initial
  12. # 17 Dec. 2021, 3d-gussner, Change default Arduino path to by PF-build.sh
  13. # created one
  14. # Prepare to use one config file for all languages
  15. # 11 Jan. 2022, 3d-gussner, Added version and Change log colored output
  16. # Use `git rev-list --count HEAD config.sh`
  17. # to get Build Nr
  18. # Check if variables are set by other scripts
  19. # and use these. More flexible for different build
  20. # scripts
  21. # Check correctly if files or dirs exist
  22. #############################################################################
  23. #
  24. # Arduino main folder:
  25. if [ -z "$ARDUINO" ]; then
  26. export ARDUINO=../../PF-build-env-1.0.6/1.8.5-1.0.4-linux-64 #C:/arduino-1.8.5
  27. fi
  28. #
  29. # Arduino builder:
  30. if [ -z "$BUILDER" ]; then
  31. export BUILDER=$ARDUINO/arduino-builder
  32. fi
  33. #
  34. # AVR gcc tools:
  35. if [ -z "$OBJCOPY" ]; then
  36. export OBJCOPY=$ARDUINO/hardware/tools/avr/bin/avr-objcopy
  37. fi
  38. if [ -z "$OBJDUMP" ]; then
  39. export OBJDUMP=$ARDUINO/hardware/tools/avr/bin/avr-objdump
  40. fi
  41. #
  42. # Output folder:
  43. if [ -z "$OUTDIR" ]; then
  44. export OUTDIR="../../Prusa-Firmware-build"
  45. fi
  46. #
  47. # Objects folder:
  48. if [ -z "$OBJDIR" ]; then
  49. export OBJDIR="$OUTDIR/sketch"
  50. fi
  51. #
  52. # Generated elf file:
  53. if [ -z "$INOELF" ]; then
  54. export INOELF="$OUTDIR/Firmware.ino.elf"
  55. fi
  56. #
  57. # Generated hex file:
  58. if [ -z "$INOHEX" ]; then
  59. export INOHEX="$OUTDIR/Firmware.ino.hex"
  60. fi
  61. #
  62. # Set default languages
  63. if [ -z "$LANGUAGES" ]; then
  64. export LANGUAGES="cz de es fr it pl"
  65. fi
  66. #
  67. # Check for community languages
  68. MAX_COMMINITY_LANG=10 # Total 16 - 6 default
  69. COMMUNITY_LANGUAGES=""
  70. #Search Firmware/config.h for active community group
  71. COMMUNITY_LANG_GROUP=$(grep --max-count=1 "^#define COMMUNITY_LANG_GROUP" ../Firmware/config.h| cut -d ' ' -f3)
  72. # Search Firmware/config.h for active community languanges
  73. if [ "$COMMUNITY_LANG_GROUP" = "1" ]; then
  74. 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' ' ')
  75. elif [ "$COMMUNITY_LANG_GROUP" = "2" ]; then
  76. 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' ' ')
  77. elif [ "$COMMUNITY_LANG_GROUP" = "3" ]; then
  78. 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' ' ')
  79. fi
  80. if [ -z "$COMMUNITY_LANGUAGES" ]; then
  81. export COMMUNITY_LANGUAGES="$COMMUNITY_LANGUAGES"
  82. fi
  83. echo "$(tput setaf 2)config.sh started$(tput sgr0)" >&2
  84. _err=0
  85. echo -n " Arduino main folder: " >&2
  86. if [ -d $ARDUINO ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=1; fi
  87. echo -n " Arduino builder: " >&2
  88. if [ -e $BUILDER ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=2; fi
  89. echo " AVR gcc tools:" >&2
  90. echo -n " objcopy " >&2
  91. if [ -e $OBJCOPY ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=3; fi
  92. echo -n " objdump " >&2
  93. if [ -e $OBJDUMP ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=4; fi
  94. echo -n " Output folder: " >&2
  95. if [ -d $OUTDIR ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=5; fi
  96. echo -n " Objects folder: " >&2
  97. if [ -d $OBJDIR ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=6; fi
  98. echo -n " Generated elf file: " >&2
  99. if [ -e $INOELF ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=7; fi
  100. echo -n " Generated hex file: " >&2
  101. if [ -e $INOHEX ]; then echo "$(tput setaf 2)OK$(tput sgr0)" >&2; else echo "$(tput setaf 1)NG!$(tput sgr0)" >&2; _err=8; fi
  102. echo -n " Languages: " >&2
  103. echo "$(tput setaf 2)$LANGUAGES$(tput sgr0)" >&2
  104. echo -n " Community languages: " >&2
  105. echo "$(tput setaf 2)$COMMUNITY_LANGUAGES$(tput sgr0)" >&2
  106. if [ $_err -eq 0 ]; then
  107. echo "$(tput setaf 2)config.sh finished with success$(tput sgr0)" >&2
  108. export CONFIG_OK=1
  109. else
  110. echo "$(tput setaf 1)config.sh finished with errors!$(tput sgr0)" >&2
  111. export CONFIG_OK=0
  112. fi