Skip to content

Commit 499cc17

Browse files
FozzTexxtschak909
authored andcommitted
Restore version.h.
1 parent 2f0833c commit 499cc17

File tree

2 files changed

+26
-35
lines changed

2 files changed

+26
-35
lines changed

build_version.py

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#env.Replace (MKSPIFFSTOOL = "mklittlefs")
1515

1616
# Disable automatic versioning
17-
if 0:
17+
if 1:
1818
print("Automatic versioning disabled")
1919

2020
# Don't do anything if nothing has changed
@@ -23,58 +23,49 @@
2323

2424
else:
2525
try:
26-
ver_commit = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], universal_newlines=True).strip()
27-
ver_build = subprocess.check_output(["git", "describe", "HEAD"], universal_newlines=True).strip()
26+
ver_build = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], universal_newlines=True).strip()
2827
except subprocess.CalledProcessError as e:
2928
ver_build = "NOGIT"
3029

3130
header_file = "include/version.h"
3231

33-
# FIXME - only use current date if there are uncommitted changes
3432
ver_date = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
3533

36-
rxs = {
37-
'MAJOR': r'^#define FN_VERSION_MAJOR (\w)',
38-
'MINOR': r'^#define FN_VERSION_MINOR (\w)',
39-
'BUILD': r'^(#define FN_VERSION_BUILD)',
40-
'DATE': r'^(#define FN_VERSION_DATE)',
41-
'FULL': r'^(#define FN_VERSION_FULL)',
42-
}
34+
rxs = ['^#define FN_VERSION_MAJOR (\\w)', '^#define FN_VERSION_MINOR (\\w)',
35+
'^(#define FN_VERSION_BUILD)', '^(#define FN_VERSION_DATE)', '^(#define FN_VERSION_FULL)']
4336

4437
ver_maj = ""
4538
ver_min = ""
46-
m = re.match(r"^v([0-9]+)[.]([0-9]+)[.]", ver_build)
47-
if m:
48-
ver_maj = m.group(1)
49-
ver_min = m.group(2)
5039

5140
txt = [line for line in open(header_file)]
5241

5342
fout = open(header_file, "w")
5443

5544
for line in txt:
5645

57-
for key in rxs:
58-
m = re.match(rxs[key], line)
46+
for i in range(len(rxs)):
47+
m = re.match(rxs[i], line)
5948
if m is not None:
6049
break
6150

6251
if m is not None:
63-
if key == 'MAJOR':
64-
if not ver_maj:
65-
ver_maj = m.groups(0)[0]
66-
line = line[:m.span(1)[0]] + ver_maj + "\n"
67-
elif key == 'MINOR':
68-
if not ver_min:
69-
ver_min = m.groups(0)[0]
70-
line = line[:m.span(1)[0]] + ver_min + "\n"
71-
elif key == 'BUILD':
72-
line = m.groups(0)[0] + " \"" + ver_commit + "\"\n"
73-
elif key == 'DATE':
74-
line = m.groups(0)[0] + " \"" + ver_date + "\"\n"
75-
elif key == 'FULL':
52+
if i == 0:
53+
ver_maj = m.groups(0)[0]
54+
fout.write(line)
55+
elif i == 1:
56+
ver_min = m.groups(0)[0]
57+
fout.write(line)
58+
elif i == 2:
7659
line = m.groups(0)[0] + " \"" + ver_build + "\"\n"
77-
78-
fout.write(line)
60+
fout.write(line)
61+
elif i == 3:
62+
line = m.groups(0)[0] + " \"" + ver_date + "\"\n"
63+
fout.write(line)
64+
elif i == 4:
65+
line = m.groups(0)[0] + " \"" + ver_maj + "." + \
66+
ver_min + "." + ver_build + "\"\n"
67+
fout.write(line)
68+
else:
69+
fout.write(line)
7970

8071
fout.close()

include/version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#define FN_VERSION_MAJOR 1
1111
#define FN_VERSION_MINOR 4
1212

13-
#define FN_VERSION_BUILD "79b22adb"
13+
#define FN_VERSION_BUILD "50c5568d4bef0663423a0c867890b344a5e20e61"
1414

15-
#define FN_VERSION_DATE "2024-09-22 16:10:46"
15+
#define FN_VERSION_DATE "2024-08-07 20:49:13"
1616

17-
#define FN_VERSION_FULL "v1.4.0-76-g79b22adb"
17+
#define FN_VERSION_FULL "v1.4"

0 commit comments

Comments
 (0)