Skip to content

Commit 0904a6e

Browse files
committed
Added python script to generate version info on platformio install
1 parent 97562e0 commit 0904a6e

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

library.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,8 @@
2525
},
2626
"license": "MIT",
2727
"frameworks": "*",
28-
"platforms": "*"
28+
"platforms": "*",
29+
"scripts": {
30+
"postinstall": "piogenversion.py"
31+
}
2932
}

piogenversion.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
ver = ""
2+
with open("VERSION", 'r') as file:
3+
ver = file.read()
4+
5+
lines = [
6+
"#ifdef __cplusplus\n",
7+
"extern \"C\" {\n",
8+
"#endif\n",
9+
"extern const char* const RCPT_VERSION;\n",
10+
"extern const char* const RCPT_VERSION_END;\n",
11+
"const char* const RCPT_VERSION = \"" + ver + "\";\n",
12+
"const char* const RCPT_VERSION_END = RCPT_VERSION + " + str(len(ver)) + ";\n",
13+
"#ifdef __cplusplus\n",
14+
"}\n",
15+
"#endif\n"
16+
]
17+
18+
with open("src/VERSION.cpp", 'w') as file:
19+
file.writelines(lines)
20+

0 commit comments

Comments
 (0)