My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

build_all_examples 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. unset BRANCH
  26. unset FIRST_CONF
  27. if [[ -f "$STAT_FILE" ]]; then
  28. IFS='*' read BRANCH FIRST_CONF <"$STAT_FILE"
  29. fi
  30. # If -c is given start from the last attempted build
  31. if [[ $1 == '-c' ]]; then
  32. if [[ -z $BRANCH || -z $FIRST_CONF ]]; then
  33. echo "Nothing to continue"
  34. exit
  35. fi
  36. elif [[ $1 == '-s' ]]; then
  37. if [[ -n $BRANCH && -n $FIRST_CONF ]]; then
  38. SKIP_CONF=1
  39. else
  40. echo "Nothing to skip"
  41. exit
  42. fi
  43. else
  44. BRANCH=${1:-"import-2.0.x"}
  45. FIRST_CONF=$2
  46. fi
  47. # Check if the current repository has unmerged changes
  48. if [[ $SKIP_CONF ]]; then
  49. echo "Skipping $FIRST_CONF"
  50. elif [[ $FIRST_CONF ]]; then
  51. echo "Resuming from $FIRST_CONF"
  52. else
  53. git diff --quiet || { echo "The working copy is modified. Commit or stash changes before proceeding."; exit ; }
  54. fi
  55. # Create a temporary folder inside .pio
  56. TMP=./.pio/build-$BRANCH
  57. [[ -d "$TMP" ]] || mkdir -p $TMP
  58. # Download Configurations into the temporary folder
  59. if [[ ! -e "$TMP/README.md" ]]; then
  60. echo "Downloading Configurations from GitHub into $TMP"
  61. git clone --depth=1 --single-branch --branch "$BRANCH" $GITREPO "$TMP" || { echo "Failed to clone the configuration repository"; exit ; }
  62. else
  63. echo "Using previously downloaded Configurations at $TMP"
  64. fi
  65. echo -e "Start building now...\n====================="
  66. shopt -s nullglob
  67. IFS='
  68. '
  69. CONF_TREE=$( ls -d "$TMP"/config/examples/*/ "$TMP"/config/examples/*/*/ "$TMP"/config/examples/*/*/*/ "$TMP"/config/examples/*/*/*/*/ | grep -vE ".+\.(\w+)$" )
  70. DOSKIP=0
  71. for CONF in $CONF_TREE ; do
  72. # Get a config's directory name
  73. DIR=$( echo $CONF | sed "s|$TMP/config/examples/||" )
  74. # If looking for a config, skip others
  75. [[ $FIRST_CONF ]] && [[ $FIRST_CONF != $DIR && "$FIRST_CONF/" != $DIR ]] && continue
  76. # Once found, stop looking
  77. unset FIRST_CONF
  78. # If skipping, don't build the found one
  79. [[ $SKIP_CONF ]] && { unset SKIP_CONF ; continue ; }
  80. # ...if skipping, don't build this one
  81. compgen -G "${CONF}Con*.h" > /dev/null || continue
  82. echo "${BRANCH}*${DIR}" >"$STAT_FILE"
  83. "$HERE/build_example" "internal" "$TMP" "$DIR" || { echo "Failed to build $DIR"; exit ; }
  84. done
  85. # Delete the temp folder and build state
  86. [[ -e "$TMP/config/examples" ]] && rm -rf "$TMP"
  87. rm "$STAT_FILE"