浏览代码

Travis will now generate and use the custom version header file

João Brázio 8 年前
父节点
当前提交
08b485a310
没有帐户链接到提交者的电子邮件
共有 2 个文件被更改,包括 17 次插入13 次删除
  1. 5
    4
      .travis.yml
  2. 12
    9
      buildroot/bin/generate_version_header_for_marlin

+ 5
- 4
.travis.yml 查看文件

@@ -3,10 +3,7 @@ language: c
3 3
   #
4 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 7
   - git fetch origin --tags
11 8
   #
12 9
   # Publish the buildroot script folder
@@ -50,6 +47,10 @@ before_script:
50 47
   # Change current working directory to the build dir
51 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 54
 script:
54 55
   #
55 56
   # Backup Configuration.h, Configuration_adv.h, and pins_RAMPS_14.h

+ 12
- 9
buildroot/bin/generate_version_header_for_marlin 查看文件

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

正在加载...
取消
保存