|
@@ -1,12 +1,36 @@
|
1
|
1
|
#!/usr/bin/env bash
|
2
|
2
|
# generate_version_header_for_marlin
|
3
|
3
|
|
4
|
|
-DIR="$1" export DIR
|
5
|
|
-OUTFILE="$2" export OUTFILE
|
6
|
|
-
|
7
|
|
-BUILDATE=$(date '+"%s"')
|
8
|
|
-DISTDATE=$(date '+"%Y-%m-%d %H:%M"')
|
9
|
|
-
|
|
4
|
+DIR="$1"
|
|
5
|
+OUTFILE="$2"
|
|
6
|
+
|
|
7
|
+BUILDATE=$(date '+%s')
|
|
8
|
+DISTDATE=$(date '+%Y-%m-%d %H:%M')
|
|
9
|
+
|
|
10
|
+BRANCH=$(git -C "${DIR}" symbolic-ref -q --short HEAD)
|
|
11
|
+VERSION=$(git -C "${DIR}" describe --tags --first-parent 2>/dev/null)
|
|
12
|
+
|
|
13
|
+# Voodoo version tag generator
|
|
14
|
+if [ -z "${VERSION}" ]; then
|
|
15
|
+ VERSION=$(git -C "${DIR}" describe --tags --first-parent --always 2>/dev/null)
|
|
16
|
+ SHORT_BUILD_VERSION=$(echo "${VERSION}" | sed "s/-.*/${BRANCH}/")
|
|
17
|
+ DETAILED_BUILD_VERSION=$(echo "${VERSION}" | sed "s/-/${BRANCH}-/")
|
|
18
|
+else
|
|
19
|
+ SHORT_BUILD_VERSION=$(echo "${BRANCH}")
|
|
20
|
+ DETAILED_BUILD_VERSION=$(echo "${BRANCH}-${VERSION}")
|
|
21
|
+fi
|
|
22
|
+
|
|
23
|
+# Gets some misc options from their defaults
|
|
24
|
+DEFAULT_MACHINE_UUID=$(awk -F'"' \
|
|
25
|
+ '/#define DEFAULT_MACHINE_UUID/{ print $2 }' < "${DIR}/Version.h")
|
|
26
|
+MACHINE_NAME=$(awk -F'"' \
|
|
27
|
+ '/#define MACHINE_NAME/{ print $2 }' < "${DIR}/Version.h")
|
|
28
|
+PROTOCOL_VERSION=$(awk -F'"' \
|
|
29
|
+ '/#define PROTOCOL_VERSION/{ print $2 }' < "${DIR}/Version.h")
|
|
30
|
+SOURCE_CODE_URL=$(awk -F'"' \
|
|
31
|
+ '/#define SOURCE_CODE_URL/{ print $2 }' < "${DIR}/Version.h")
|
|
32
|
+WEBSITE_URL=$(awk -F'"' \
|
|
33
|
+ '/#define WEBSITE_URL/{ print $2 }' < "${DIR}/Version.h")
|
10
|
34
|
|
11
|
35
|
cat > "$OUTFILE" <<EOF
|
12
|
36
|
/**
|
|
@@ -14,34 +38,15 @@ cat > "$OUTFILE" <<EOF
|
14
|
38
|
* IT DOES NOT GET COMMITTED TO THE REPOSITORY.
|
15
|
39
|
*/
|
16
|
40
|
|
17
|
|
-#define BUILD_UNIX_DATETIME ${BUILDATE}
|
18
|
|
-#define STRING_DISTRIBUTION_DATE ${DISTDATE}
|
19
|
|
-#define PROTOCOL_VERSION "1.0"
|
20
|
|
-#define MACHINE_NAME "Travis CI"
|
21
|
|
-#define SOURCE_CODE_URL "https://github.com/MarlinFirmware/Marlin"
|
22
|
|
-#define DEFAULT_MACHINE_UUID "3442baa1-08ee-435b-8a10-99d185bd43b8"
|
23
|
|
-#define WEBSITE_URL "http://marlinfw.org"
|
24
|
|
-EOF
|
|
41
|
+#define BUILD_UNIX_DATETIME "${BUILDATE}"
|
|
42
|
+#define STRING_DISTRIBUTION_DATE "${DISTDATE}"
|
25
|
43
|
|
26
|
|
-( set +e
|
27
|
|
- cd "$DIR"
|
28
|
|
-
|
29
|
|
- BRANCH=`git symbolic-ref -q --short HEAD`
|
30
|
|
- if [ "x$BRANCH" == "x" ] ; then
|
31
|
|
- BRANCH=""
|
32
|
|
- elif [ "x$BRANCH" == "xDevelopment" ] ; then
|
33
|
|
- BRANCH=" dev"
|
34
|
|
- else
|
35
|
|
- BRANCH=" $BRANCH"
|
36
|
|
- fi
|
37
|
|
-
|
38
|
|
- VERSION=`git describe --tags --first-parent 2>/dev/null`
|
39
|
|
- if [ "x$VERSION" != "x" ] ; then
|
40
|
|
- echo "#define SHORT_BUILD_VERSION \"$VERSION\"" | sed "s/-.*/$BRANCH\"/" >>"$OUTFILE"
|
41
|
|
- echo "#define DETAILED_BUILD_VERSION \"$VERSION\"" | sed "s/-/$BRANCH-/" >>"$OUTFILE"
|
42
|
|
- else
|
43
|
|
- VERSION=`git describe --tags --first-parent --always 2>/dev/null`
|
44
|
|
- echo "#define SHORT_BUILD_VERSION \"$BRANCH\"" >>"$OUTFILE"
|
45
|
|
- echo "#define DETAILED_BUILD_VERSION \"${BRANCH}-$VERSION\"" >>"$OUTFILE"
|
46
|
|
- fi
|
47
|
|
-)
|
|
44
|
+#define SHORT_BUILD_VERSION "${SHORT_BUILD_VERSION}"
|
|
45
|
+#define DETAILED_BUILD_VERSION "${DETAILED_BUILD_VERSION}"
|
|
46
|
+
|
|
47
|
+#define PROTOCOL_VERSION "${PROTOCOL_VERSION}"
|
|
48
|
+#define MACHINE_NAME "${MACHINE_NAME}"
|
|
49
|
+#define SOURCE_CODE_URL "${SOURCE_CODE_URL}"
|
|
50
|
+#define DEFAULT_MACHINE_UUID "${DEFAULT_MACHINE_UUID}"
|
|
51
|
+#define WEBSITE_URL "${WEBSITE_URL}"
|
|
52
|
+EOF
|