/
generate_version
executable file
·132 lines (116 loc) · 4.11 KB
/
generate_version
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/env bash
#
# generate_version
#
# Make a Version.h file to accompany CUSTOM_VERSION_FILE
#
# Authors: jbrazio, thinkyhead, InsanityAutomation, rfinnie
#
set -e
DIR="${1:-Marlin}"
READ_FILE="${READ_FILE:-${DIR}/Version.h}"
WRITE_FILE="${WRITE_FILE:-${READ_FILE}}"
BRANCH="$(git -C "${DIR}" symbolic-ref -q --short HEAD 2>/dev/null || true)"
VERSION="$(git -C "${DIR}" describe --tags --first-parent 2>/dev/null || true)"
STRING_DISTRIBUTION_DATE="${STRING_DISTRIBUTION_DATE:-$(date '+%Y-%m-%d %H:%M')}"
SHORT_BUILD_VERSION="${SHORT_BUILD_VERSION:-${BRANCH}}"
DETAILED_BUILD_VERSION="${DETAILED_BUILD_VERSION:-${BRANCH}-${VERSION}}"
# Gets some misc options from their defaults
DEFAULT_MACHINE_UUID="${DEFAULT_MACHINE_UUID:-$(awk -F'"' \
'/#define DEFAULT_MACHINE_UUID/{ print $2 }' < "${READ_FILE}")}"
MACHINE_NAME="${MACHINE_NAME:-$(awk -F'"' \
'/#define MACHINE_NAME/{ print $2 }' < "${READ_FILE}")}"
PROTOCOL_VERSION="${PROTOCOL_VERSION:-$(awk -F'"' \
'/#define PROTOCOL_VERSION/{ print $2 }' < "${READ_FILE}")}"
SOURCE_CODE_URL="${SOURCE_CODE_URL:-$(awk -F'"' \
'/#define SOURCE_CODE_URL/{ print $2 }' < "${READ_FILE}")}"
WEBSITE_URL="${WEBSITE_URL:-$(awk -F'"' \
'/#define WEBSITE_URL/{ print $2 }' < "${READ_FILE}")}"
cat > "${WRITE_FILE}" <<EOF
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* THIS FILE IS AUTOMATICALLY GENERATED DO NOT MANUALLY EDIT IT.
* IT DOES NOT GET COMMITTED TO THE REPOSITORY.
*
* Branch: ${BRANCH}
* Version: ${VERSION}
*/
/**
* Marlin release version identifier
*/
#ifndef SHORT_BUILD_VERSION
#define SHORT_BUILD_VERSION "${SHORT_BUILD_VERSION}"
#endif
/**
* Verbose version identifier which should contain a reference to the location
* from where the binary was downloaded or the source code was compiled.
*/
#ifndef DETAILED_BUILD_VERSION
#define DETAILED_BUILD_VERSION "${DETAILED_BUILD_VERSION}"
#endif
/**
* The STRING_DISTRIBUTION_DATE represents when the binary file was built,
* here we define this default string as the date where the latest release
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "${STRING_DISTRIBUTION_DATE}"
#endif
/**
* The protocol for communication to the host. Protocol indicates communication
* standards such as the use of ASCII, "echo:" and "error:" line prefixes, etc.
* (Other behaviors are given by the firmware version and capabilities report.)
*/
#ifndef PROTOCOL_VERSION
#define PROTOCOL_VERSION "${PROTOCOL_VERSION}"
#endif
/**
* Defines a generic printer name to be output to the LCD after booting Marlin.
*/
#ifndef MACHINE_NAME
#define MACHINE_NAME "${MACHINE_NAME}"
#endif
/**
* The SOURCE_CODE_URL is the location where users will find the Marlin Source
* Code which is installed on the device. In most cases —unless the manufacturer
* has a distinct Github fork— the Source Code URL should just be the main
* Marlin repository.
*/
#ifndef SOURCE_CODE_URL
#define SOURCE_CODE_URL "${SOURCE_CODE_URL}"
#endif
/**
* Default generic printer UUID.
*/
#ifndef DEFAULT_MACHINE_UUID
#define DEFAULT_MACHINE_UUID "${DEFAULT_MACHINE_UUID}"
#endif
/**
* The WEBSITE_URL is the location where users can get more information such as
* documentation about a specific Marlin release.
*/
#ifndef WEBSITE_URL
#define WEBSITE_URL "${WEBSITE_URL}"
#endif
EOF