makerelease.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/bin/sh
  2. srcdir="$(dirname "$0")"
  3. [ "$(echo "$srcdir" | cut -c1)" = '/' ] || srcdir="$PWD/$srcdir"
  4. die() { echo "$*"; exit 1; }
  5. # Import the makerelease.lib
  6. # http://bues.ch/gitweb?p=misc.git;a=blob_plain;f=makerelease.lib;hb=HEAD
  7. for path in $(echo "$PATH" | tr ':' ' '); do
  8. [ -f "$MAKERELEASE_LIB" ] && break
  9. MAKERELEASE_LIB="$path/makerelease.lib"
  10. done
  11. [ -f "$MAKERELEASE_LIB" ] && . "$MAKERELEASE_LIB" || die "makerelease.lib not found."
  12. hook_get_version()
  13. {
  14. local file="$1/firmware/version.h"
  15. local regex='#define[[:space:]]VERSION[[:space:]]'
  16. version="$(grep -e "$regex" "$file" | head -n1 | cut -d'"' -f2)"
  17. }
  18. hook_testbuild()
  19. {
  20. default_hook_testbuild "$1/firmware"
  21. }
  22. hook_regression_tests()
  23. {
  24. make -C "$1/firmware" tests
  25. }
  26. do_build()
  27. {
  28. local fwdir="$1"
  29. local targetdir="$2"
  30. shift 2
  31. echo
  32. echo "Building configuration: $*"
  33. mkdir -p "$targetdir"
  34. echo "$*" | tr '[:space:]' '\n' > "$targetdir/build_config.txt"
  35. make -C "$fwdir" all "$@" C=1
  36. echo "Fuse configuration:" > "$targetdir/fuses.txt"
  37. echo >> "$targetdir/fuses.txt"
  38. make --no-print-directory -C "$fwdir" print_fuses "$@" >> "$targetdir/fuses.txt"
  39. mv "$fwdir"/*.hex "$targetdir"/
  40. make -C "$fwdir" distclean "$@"
  41. }
  42. hook_pre_archives()
  43. {
  44. # Build the hex files.
  45. for hw in legacy smd; do
  46. for dev in 88 88p 328p; do
  47. local releases="release"
  48. [ $dev = 328p ] && local releases="release debug"
  49. for rel in $releases; do
  50. local fwdir="$2/firmware"
  51. local targetdir="$2/hex/board_$hw/atmega$dev/$rel"
  52. if [ $hw = legacy ]; then
  53. local CONF_IDLETOGGLE=1
  54. else
  55. local CONF_IDLETOGGLE=0
  56. fi
  57. if [ $dev = 88 -o $dev = 88p ]; then
  58. local CONF_KCONF=0
  59. else
  60. local CONF_KCONF=1
  61. fi
  62. if [ $rel = debug ]; then
  63. local CONF_DEBUG=1
  64. else
  65. local CONF_DEBUG=0
  66. fi
  67. do_build "$fwdir" "$targetdir" \
  68. HW=$hw DEV=m$dev \
  69. CONF_PRESETS=1 \
  70. CONF_BOOST=0 \
  71. CONF_IDLE=1 \
  72. CONF_IDLETOGGLE=$CONF_IDLETOGGLE \
  73. CONF_DEBUG=$CONF_DEBUG \
  74. CONF_EERING=1 \
  75. CONF_ADJ=1 \
  76. CONF_KCONF=$CONF_KCONF
  77. done
  78. done
  79. done
  80. # Move the documentation.
  81. mv "$2"/schematics-lf1600/lf1600.pdf "$2"/schematics-lf1600.pdf
  82. }
  83. hook_pre_documentation()
  84. {
  85. # Update the README
  86. local makefile="$1/firmware/Makefile"
  87. for arch in M88 M88P M328P; do
  88. local lfuse="$(grep -e "$arch"'_LFUSE[[:space:]]*:=' "$makefile" | head -n1 | cut -d'=' -f2 | tr -d '[[:space:]]')"
  89. local hfuse="$(grep -e "$arch"'_HFUSE[[:space:]]*:=' "$makefile" | head -n1 | cut -d'=' -f2 | tr -d '[[:space:]]')"
  90. local efuse="$(grep -e "$arch"'_EFUSE[[:space:]]*:=' "$makefile" | head -n1 | cut -d'=' -f2 | tr -d '[[:space:]]')"
  91. sed -i -e 's/%%'"$arch"'_LFUSE%%/'"$lfuse"'/g' \
  92. -e 's/%%'"$arch"'_HFUSE%%/'"$hfuse"'/g' \
  93. -e 's/%%'"$arch"'_EFUSE%%/'"$efuse"'/g' \
  94. "$1/README.md"
  95. done
  96. }
  97. project=xytronic-lf
  98. default_archives="tar.xz"
  99. makerelease "$@"