My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

build_all_examples 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/usr/bin/env bash
  2. #
  3. # build_all_examples base_branch [resume_point]
  4. #
  5. GITREPO=https://github.com/MarlinFirmware/Configurations.git
  6. STAT_FILE=./.pio/.buildall
  7. # Check dependencies
  8. which curl 1>/dev/null 2>&1 || { echo "curl not found! Please install it."; exit ; }
  9. which git 1>/dev/null 2>&1 || { echo "git not found! Please install it."; exit ; }
  10. SED=$(command -v gsed 2>/dev/null || command -v sed 2>/dev/null)
  11. [[ -z "$SED" ]] && { echo "No sed found, please install sed" ; exit 1 ; }
  12. SELF=`basename "$0"`
  13. HERE=`dirname "$0"`
  14. # Check if called in the right location
  15. [[ -e "Marlin/src" ]] || { echo -e "This script must be called from a Marlin working copy with:\n ./buildroot/bin/$SELF $1" ; exit ; }
  16. if [[ $# -lt 1 || $# -gt 2 ]]; then
  17. echo "Usage: $SELF base_branch [resume_point]
  18. base_branch - Configuration branch to download and build
  19. resume_point - Configuration path to start from"
  20. exit
  21. fi
  22. echo "This script downloads all Configurations and builds Marlin with each one."
  23. echo "On failure the last-built configs will be left in your working copy."
  24. echo "Restore your configs with 'git checkout -f' or 'git reset --hard HEAD'."
  25. # If -c is given start from the last attempted build
  26. if [[ $1 == '-c' ]]; then
  27. if [[ -f "$STAT_FILE" ]]; then
  28. read BRANCH FIRST_CONF <"$STAT_FILE"
  29. else
  30. echo "Nothing to continue"
  31. exit
  32. fi
  33. else
  34. BRANCH=${1:-"import-2.0.x"}
  35. FIRST_CONF=$2
  36. fi
  37. # Check if the current repository has unmerged changes
  38. if [[ -z "$FIRST_CONF" ]]; then
  39. git diff --quiet || { echo "The working copy is modified. Commit or stash changes before proceeding."; exit ; }
  40. else
  41. echo "Resuming from $FIRST_CONF"
  42. fi
  43. # Create a temporary folder inside .pio
  44. TMP=./.pio/build-$BRANCH
  45. [[ -d "$TMP" ]] || mkdir -p $TMP
  46. # Download Configurations into the temporary folder
  47. if [[ ! -e "$TMP/README.md" ]]; then
  48. echo "Downloading Configurations from GitHub into $TMP"
  49. git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$TMP" || { echo "Failed to clone the configuration repository"; exit ; }
  50. else
  51. echo "Using previously downloaded Configurations at $TMP"
  52. fi
  53. echo -e "Start building now...\n====================="
  54. shopt -s nullglob
  55. IFS='
  56. '
  57. CONF_TREE=$( ls -d "$TMP"/config/examples/*/ "$TMP"/config/examples/*/*/ "$TMP"/config/examples/*/*/*/ "$TMP"/config/examples/*/*/*/*/ | grep -vE ".+\.(\w+)$" )
  58. for CONF in $CONF_TREE ; do
  59. DIR=$( echo $CONF | sed "s|$TMP/config/examples/||" )
  60. [[ ! -z $FIRST_CONF ]] && [[ $FIRST_CONF != $DIR && "$FIRST_CONF/" != $DIR ]] && continue
  61. unset FIRST_CONF
  62. compgen -G "${CONF}Con*.h" > /dev/null || continue
  63. echo -e "$BRANCH\n$DIR" >"$STAT_FILE"
  64. "$HERE/build_example" "internal" "$TMP" "$DIR" || { echo "Failed to build $DIR"; exit ; }
  65. done
  66. # Delete the temp folder and build state
  67. [[ -e "$TMP/config/examples" ]] && rm -rf "$TMP"
  68. rm "$STAT_FILE"