Browse Source

Travis will now generate and use the custom version header file

João Brázio 8 years ago
parent
commit
08b485a310
No account linked to committer's email address
2 changed files with 17 additions and 13 deletions
  1. 5
    4
      .travis.yml
  2. 12
    9
      buildroot/bin/generate_version_header_for_marlin

+ 5
- 4
.travis.yml View File

3
   #
3
   #
4
 before_install:
4
 before_install:
5
   #
5
   #
6
-  # Travis runs a detached head. We need to find the current branch
7
-  - git checkout `git branch --contains HEAD | grep -v '*'`
8
-  #
9
-  # Also tags for the root(s) of the minor version(s)
6
+  # Fetch the tag information for the current branch
10
   - git fetch origin --tags
7
   - git fetch origin --tags
11
   #
8
   #
12
   # Publish the buildroot script folder
9
   # Publish the buildroot script folder
50
   # Change current working directory to the build dir
47
   # Change current working directory to the build dir
51
   - cd ${TRAVIS_BUILD_DIR}
48
   - cd ${TRAVIS_BUILD_DIR}
52
   #
49
   #
50
+  # Generate custom version include
51
+  - generate_version_header_for_marlin ${TRAVIS_BUILD_DIR}/Marlin
52
+  - cat ${TRAVIS_BUILD_DIR}/Marlin/_Version.h
53
+  #
53
 script:
54
 script:
54
   #
55
   #
55
   # Backup Configuration.h, Configuration_adv.h, and pins_RAMPS_14.h
56
   # Backup Configuration.h, Configuration_adv.h, and pins_RAMPS_14.h

+ 12
- 9
buildroot/bin/generate_version_header_for_marlin View File

1
 #!/usr/bin/env bash
1
 #!/usr/bin/env bash
2
 # generate_version_header_for_marlin
2
 # generate_version_header_for_marlin
3
 
3
 
4
-DIR="$1"
5
-OUTFILE="$2"
4
+DIR="${1}"
6
 
5
 
7
 BUILDATE=$(date '+%s')
6
 BUILDATE=$(date '+%s')
8
 DISTDATE=$(date '+%Y-%m-%d %H:%M')
7
 DISTDATE=$(date '+%Y-%m-%d %H:%M')
10
 BRANCH=$(git -C "${DIR}" symbolic-ref -q --short HEAD)
9
 BRANCH=$(git -C "${DIR}" symbolic-ref -q --short HEAD)
11
 VERSION=$(git -C "${DIR}" describe --tags --first-parent 2>/dev/null)
10
 VERSION=$(git -C "${DIR}" describe --tags --first-parent 2>/dev/null)
12
 
11
 
13
-# Voodoo version tag generator
12
+if [ -z "${BRANCH}" ]; then
13
+  BRANCH=$(echo "${TRAVIS_BRANCH}")
14
+fi
15
+
14
 if [ -z "${VERSION}" ]; then
16
 if [ -z "${VERSION}" ]; then
15
   VERSION=$(git -C "${DIR}" describe --tags --first-parent --always 2>/dev/null)
17
   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
18
 fi
22
 
19
 
20
+SHORT_BUILD_VERSION=$(echo "${BRANCH}")
21
+DETAILED_BUILD_VERSION=$(echo "${BRANCH}-${VERSION}")
22
+
23
 # Gets some misc options from their defaults
23
 # Gets some misc options from their defaults
24
 DEFAULT_MACHINE_UUID=$(awk -F'"' \
24
 DEFAULT_MACHINE_UUID=$(awk -F'"' \
25
   '/#define DEFAULT_MACHINE_UUID/{ print $2 }' < "${DIR}/Version.h")
25
   '/#define DEFAULT_MACHINE_UUID/{ print $2 }' < "${DIR}/Version.h")
32
 WEBSITE_URL=$(awk -F'"' \
32
 WEBSITE_URL=$(awk -F'"' \
33
   '/#define WEBSITE_URL/{ print $2 }' < "${DIR}/Version.h")
33
   '/#define WEBSITE_URL/{ print $2 }' < "${DIR}/Version.h")
34
 
34
 
35
-cat > "$OUTFILE" <<EOF
35
+cat > "${DIR}/_Version.h" <<EOF
36
 /**
36
 /**
37
  * THIS FILE IS AUTOMATICALLY GENERATED DO NOT MANUALLY EDIT IT.
37
  * THIS FILE IS AUTOMATICALLY GENERATED DO NOT MANUALLY EDIT IT.
38
  * IT DOES NOT GET COMMITTED TO THE REPOSITORY.
38
  * IT DOES NOT GET COMMITTED TO THE REPOSITORY.
39
+ *
40
+ * Branch: ${BRANCH}
41
+ * Version: ${VERSION}
39
  */
42
  */
40
 
43
 
41
 #define BUILD_UNIX_DATETIME "${BUILDATE}"
44
 #define BUILD_UNIX_DATETIME "${BUILDATE}"

Loading…
Cancel
Save