forked from biomimetics/imageproc-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.py
30 lines (23 loc) · 884 Bytes
/
version.py
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
#!/usr/bin/env python
"""
Write version and date information to a .c file, so compiles can be updated
authors: ronf, fgb, apullin
"""
import sys, os, time
# Check and parse arguments
if len(sys.argv) < 2:
print("Not enough arguments given. Need version string within single quotes.")
sys.exit()
filename = 'version.c'
fileheader = 'version.h'
version = sys.argv[1] # version string within single quotes
date = time.strftime("%a %b %d %H:%M:%S %Y")
# Write version and date information
fileout = open(filename,'w')
fileout.write(
'/* automatically generated by version.py - do not edit! */\n\n' + \
'#include "' + fileheader + '"\n\n' + \
'static char version[] = "' + version + ': ' + date + '";\n\n' + \
'char* versionGetString(void) { return version; }\n')
fileout.close()
print('updated ' + os.getcwd() + os.sep + filename)