You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.8 KiB

  1. #!/bin/bash
  2. # Copyright 2021 Nick Brassel (@tzarc)
  3. # SPDX-License-Identifier: GPL-2.0-or-later
  4. set -eEuo pipefail
  5. job_count=$(getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)
  6. source_ref="0.11.0"
  7. dest_ref="develop"
  8. ignore_ref="master"
  9. unset skip_zero
  10. function usage() {
  11. echo "Usage: $(basename "$0") [-h] [-j <jobs>] [-s <source>] [-d <dest>] [-n] planck/rev6:default"
  12. echo " -h : Shows this usage page."
  13. echo " -j <threads> : Change the number of threads to execute with. Defaults to \`$job_count\`."
  14. echo " -s <source> : Use source commit, branch, tag, or sha1 to start the search. Defaults to \`$source_ref\`."
  15. echo " -d <dest> : Use destination commit, branch, tag, or sha1 to end the search. Defaults to \`$dest_ref\`."
  16. echo " -i <ignore> : The branch to ignore refs from. Defaults to \`$ignore_ref\`."
  17. echo " -n : Skips printing changes if the delta is zero."
  18. exit 1
  19. }
  20. if [[ ${#} -eq 0 ]]; then
  21. usage
  22. fi
  23. while getopts "hj:s:d:i:n" opt "$@" ; do
  24. case "$opt" in
  25. h) usage; exit 0;;
  26. j) job_count="${OPTARG:-}";;
  27. s) source_ref="${OPTARG:-}";;
  28. d) dest_ref="${OPTARG:-}";;
  29. i) ignore_ref="${OPTARG:-}";;
  30. n) skip_zero=1;;
  31. \?) usage >&2; exit 1;;
  32. esac
  33. done
  34. # Work out the target board
  35. shift $((OPTIND-1))
  36. keyboard_target=$1
  37. last_size=0
  38. last_line=""
  39. function build_executor() {
  40. git rev-list --oneline --no-merges ${source_ref}...${dest_ref} ^${ignore_ref} | while IFS= read -r line ; do
  41. revision=$(echo $line | cut -d' ' -f1)
  42. make distclean >/dev/null 2>&1
  43. git checkout $revision >/dev/null 2>&1 || { echo "Failed to check out revision ${revision}" >&2 ; exit 1 ; }
  44. make -j${job_count} $keyboard_target >/dev/null 2>&1 || true
  45. file_size=$(arm-none-eabi-size .build/*.elf 2>/dev/null | awk '/elf/ {print $1}' 2>/dev/null || true)
  46. if [[ "$last_size" == 0 ]] ; then last_size=$file_size ; fi
  47. if [[ -z "$file_size" ]] ; then file_size=0 ; fi
  48. if [[ -n "$last_line" ]] ; then
  49. size_delta=$(( $last_size - $file_size ))
  50. if { [[ -n "${skip_zero:-}" ]] && [[ $size_delta -ne 0 ]] ; } || [[ $file_size -eq 0 ]] ; then
  51. printf "Size: %8d, delta: %+6d -- %s\n" "$last_size" "$size_delta" "$last_line"
  52. fi
  53. fi
  54. last_size=$file_size
  55. last_line=$line
  56. done
  57. if [ -n "$last_line" ] ; then
  58. size_delta=0
  59. printf "Size: %8d, delta: %+6d -- %s\n" "$last_size" "$size_delta" "$last_line"
  60. fi
  61. }
  62. # The actual execution of all the builds needs to be the last command in the entire script
  63. # - During builds, this script file will disappear, so we need the entire script to be
  64. # loaded into the script interpreter at the time of execution. Do not refactor.
  65. build_executor