Skip to content

Commit

Permalink
New version of prebuild script, to work with imageproc-settings migra…
Browse files Browse the repository at this point in the history
…tion.

Update for cleaner extraction of ident str
  • Loading branch information
apullin committed Jan 8, 2015
1 parent 4d849fa commit acc1004
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 34 deletions.
41 changes: 41 additions & 0 deletions prebuild.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python

"""
Write version and date information to a .c file, so compiles can be updated
authors: ronf, fgb, apullin
"""

import time, os, sys, re

VER_STR_LENGTH_MAX = 80

if len(sys.argv) < 2:
print("Not enough arguments given. Need path to settings.h file.")
sys.exit()

settingsFile = sys.argv[1] # path to settings.h

infile = open(settingsFile, 'r') #read only
#infile = open('settings.h')

for line in infile:
if '#define IDENT_STR' in line:
identStrLine = line
infile.close()
break

identStr = re.findall(r'"(.*?)"', line)[0]
timestamp = time.strftime("%a %b %d %H:%M:%S %Y")
verStr = identStr + " " + timestamp
verStrClip = verStr[0:VER_STR_LENGTH_MAX]

# Write string to header file
filename = 'source/version-string.h'
fileout = open(filename,'w')
fileout.write(
'/* automatically generated by version.py - do not edit! Do not enter into SCM! */\n\n' + \
'#define VERSION_STRING "'+ verStrClip + '"\n\n' )
fileout.close()

print('updated ' + os.getcwd() + os.sep + filename)
2 changes: 1 addition & 1 deletion version.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "version-string.h" //This will define the version string, and VERSION_STRING macro
#ifndef VERSION_STRING
#error "No version string is defined. This is strictly required to build. Check pre-build python step, version.py ."
#error "No version string is defined. This is strictly required to build. Check pre-build python step, prebuild.py and setting.h ."
#else
static char version[] = VERSION_STRING ;
#endif
Expand Down
33 changes: 0 additions & 33 deletions version.py

This file was deleted.

0 comments on commit acc1004

Please sign in to comment.