|
@@ -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"
|