versioning script
This commit is contained in:
43
scripts/pre-build.py
Normal file
43
scripts/pre-build.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from subprocess import Popen, PIPE, check_output
|
||||
from tempfile import mkstemp
|
||||
from shutil import move
|
||||
from os import remove, close
|
||||
import re, subprocess, sys
|
||||
|
||||
branch = check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).rstrip().decode("utf-8")
|
||||
shorthash = check_output(["git", "log", "--pretty=format:%h", "-n 1"]).rstrip().decode("utf-8")
|
||||
revcount = len(check_output(["git", "log", "--oneline"]).split(b'\n')) - 1
|
||||
tag = check_output(["git", "describe", "--tags", "--abbrev=0"]).rstrip().decode("utf-8")
|
||||
config = sys.argv[1]
|
||||
|
||||
version = "%s.%d (%s-%s-%s)" % (tag, revcount, shorthash, branch, config)
|
||||
version_number = "%s.%d" % (tag, revcount)
|
||||
|
||||
print("Compiling version: %s" % version)
|
||||
|
||||
version_gen_h = '// AUTO GENERATED FILE - DON\'T MODIFY\n'
|
||||
version_gen_h += '#define PP_VERSION_NUMBER_STRING "%s"\n' % version_number
|
||||
version_gen_h += '#define PP_VERSION_STRING "%s"\n' % version
|
||||
f = open("engine/version.gen.h", "w")
|
||||
f.write(version_gen_h)
|
||||
|
||||
|
||||
"""
|
||||
file_path = "Setup\\Product.wxs";
|
||||
#Create temp file
|
||||
fh, abs_path = mkstemp()
|
||||
regex = re.compile(r'Version="\d+\.\d+\.\d+\.\d+"')
|
||||
with open(abs_path,'w') as new_file:
|
||||
with open(file_path) as old_file:
|
||||
for line in old_file:
|
||||
new_line = regex.sub('Version="%s"' % version, line)
|
||||
new_file.write(new_line)
|
||||
close(fh)
|
||||
#Remove original file
|
||||
remove(file_path)
|
||||
#Move new file
|
||||
move(abs_path, file_path)
|
||||
"""
|
||||
|
||||
|
||||
exit(0)
|
||||
Reference in New Issue
Block a user