-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
executable file
·67 lines (56 loc) · 1.81 KB
/
build.py
File metadata and controls
executable file
·67 lines (56 loc) · 1.81 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/python
from subprocess import call
import re
def getMakefileVariable(name):
value = ""
makefile = open( "Makefile", "r" )
for line in makefile:
a = re.compile(name+" = (.*)")
match = a.match(line)
if match:
value = match.group(1).strip()
makefile.close()
return value
def getUserVariable(variable, regex):
current = getMakefileVariable(variable)
new = raw_input(variable.title() + " (Default = " + current + "): ")
if new == "":
new = current
if re.match(regex, new) == None:
print("'" + new + "' does not match the " + variable + " regex '" + regex + "'. Exiting...")
exit()
return new
def updateMakefileVariable(name, value):
newLines = []
makefile = open("Makefile", "r")
for line in makefile:
a = re.compile(name+" = (.*)")
match = a.match(line)
if match:
newLines.append(name + " = " + value + "\n")
else:
newLines.append(line)
makefile.close()
tempMakefile = open('Makefile.tmp', 'w')
for line in newLines:
tempMakefile.write(line)
tempMakefile.close()
call(["mv", "Makefile.tmp", "Makefile"])
name = getUserVariable('NAME', '^[a-z0-9-]+$')
major = getUserVariable('MAJOR', '^[0-9]+$')
minor = getUserVariable('MINOR', '^[0-9]+$')
fix = getUserVariable('FIX', '^[0-9]+$')
label = getUserVariable('LABEL', '^(dev|alpha|beta|rc|rel){1}$')
build = getUserVariable('BUILD', '^[0-9]+$')
version = major + '.' + minor + '.' + fix
release = name + '-' + version + '-' + label + build
print("Building " + release)
confirm = raw_input("Confirm [y|n]: ")
if confirm == 'y':
updateMakefileVariable("NAME", name)
updateMakefileVariable("MAJOR", major)
updateMakefileVariable("MINOR", minor)
updateMakefileVariable("FIX", fix)
updateMakefileVariable("LABEL", label)
updateMakefileVariable("BUILD", build)
call(["make", "release"])