Pārlūkot izejas kodu

Fix/improve configs build script (#21086)

X-Ryl669 3 gadus atpakaļ
vecāks
revīzija
7b23f41fd4
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam

+ 2
- 0
Marlin/src/pins/pins.h Parādīt failu

@@ -252,6 +252,8 @@
252 252
   #include "mega/pins_WANHAO_ONEPLUS.h"         // ATmega2560                             env:mega2560
253 253
 #elif MB(OVERLORD)
254 254
   #include "mega/pins_OVERLORD.h"               // ATmega2560                             env:mega2560
255
+#elif MB(HJC2560C_REV1)
256
+  #include "mega/pins_HJC2560C_REV1.h"          // ATmega2560                             env:mega2560
255 257
 #elif MB(HJC2560C_REV2)
256 258
   #include "mega/pins_HJC2560C_REV2.h"          // ATmega2560                             env:mega2560
257 259
 #elif MB(LEAPFROG_XEED2015)

+ 60
- 41
buildroot/bin/build_all_examples Parādīt failu

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

+ 19
- 25
buildroot/bin/build_example Parādīt failu

@@ -1,35 +1,29 @@
1 1
 #!/usr/bin/env bash
2
+#
3
+# build_example
4
+#
5
+# Usage: build_example internal config-home config-folder
6
+#
2 7
 
3
-if [ "$1" != "internal" ]; then
4
-  echo "Don't call this script directly, use build_all_examples instead."
5
-  exit 1
6
-fi
7
-
8
-SED=$(which gsed || which sed)
9
-HERE=`dirname "$0"`
8
+# Require 'internal' as the first argument
9
+[[ "$1" == "internal" ]] || { echo "Don't call this script directly, use build_all_examples instead." ; exit 1 ; }
10 10
 
11 11
 echo "Testing $3:"
12 12
 
13
-shopt -s nullglob
14
-for sub in find $2/config/examples/$3 -type d; do
15
-  [[ -d $sub ]] || continue
16
-  base=`basename "$sub"`
13
+SUB=$2/config/examples/$3
14
+[[ -d "$SUB" ]] || { echo "$SUB is not a good path" ; exit 1 ; }
17 15
 
18
-  if [[ ! -f $sub/Configuration.h ]] && [[ ! -f $sub/Configuration_adv.h ]]; then
19
-    echo "No configuration files found in $sub"
20
-    continue
21
-  fi
16
+compgen -G "${SUB}Con*.h" > /dev/null || { echo "No configuration files found in $SUB" ; exit 1 ; }
22 17
 
23
-  echo "Getting configuration files from $sub"
24
-  cp "$2/config/default"/*.h    Marlin/
25
-  cp "$sub"/Configuration.h     Marlin/ 2>/dev/null
26
-  cp "$sub"/Configuration_adv.h Marlin/ 2>/dev/null
27
-  cp "$sub"/_Bootscreen.h       Marlin/ 2>/dev/null
28
-  cp "$sub"/_Statusscreen.h     Marlin/ 2>/dev/null
18
+echo "Getting configuration files from $SUB"
19
+cp "$2/config/default"/*.h    Marlin/
20
+cp "$SUB"/Configuration.h     Marlin/ 2>/dev/null
21
+cp "$SUB"/Configuration_adv.h Marlin/ 2>/dev/null
22
+cp "$SUB"/_Bootscreen.h       Marlin/ 2>/dev/null
23
+cp "$SUB"/_Statusscreen.h     Marlin/ 2>/dev/null
29 24
 
30
-  echo "Building the firmware now..."
31
-  echo "$HERE/mftest" -a || exit 1
32
-done
25
+echo "Building the firmware now..."
26
+HERE=`dirname "$0"`
27
+$HERE/mftest -a || { echo "Failed"; exit 1; }
33 28
 
34 29
 echo "Success"
35
-exit 0

+ 1
- 2
buildroot/bin/mftest Parādīt failu

@@ -6,7 +6,6 @@
6 6
 #  mftest [name] [index] [-y]         Set config options and optionally build a test
7 7
 #
8 8
 
9
-MFINFO=$(mfinfo) || exit 1
10 9
 [[ -d Marlin/src ]] || { echo "Please 'cd' to the Marlin repo root." ; exit 1 ; }
11 10
 
12 11
 perror() { echo -e "$0: \033[0;31m$1 -- $2\033[0m" ; }
@@ -37,7 +36,7 @@ env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 tee
37 36
 
38 37
 TESTPATH=buildroot/tests
39 38
 
40
-STATE_FILE=$( echo ./.pio/.mftestrc )
39
+STATE_FILE="./.pio/.mftestrc"
41 40
 SED=$(which gsed || which sed)
42 41
 
43 42
 shopt -s extglob nocasematch

Notiek ielāde…
Atcelt
Saglabāt