-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGen.py
executable file
·86 lines (64 loc) · 2.36 KB
/
Gen.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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python3
import os
import sys
import configparser
import time
import subprocess
file_path = os.path.split(os.path.abspath(__file__))[0]
if file_path == '':
file_path = os.path.abspath(os.path.getcwd())
cfg = configparser.ConfigParser()
cfg.read_file(open('Build/Build.cfg'))
fd = open('Makefile.version')
versionfile = fd.read().strip().split('.')
cfg.add_section('Server')
cfg.set('Server', 'version_major', versionfile[0])
cfg.set('Server', 'version_minor', versionfile[1])
cfg.set('Server', 'version_patch', versionfile[2])
fd.close()
noct = False
incPath = '/usr/include'
if "LOCAL_DEPS_INCLUDE" in os.environ:
incPath = os.environ["LOCAL_DEPS_INCLUDE"]
if not os.path.exists( incPath + '/vzctl/libvzctl.h' ):
print('Warning: libvzctl-devel packages is not installed')
noct = True
if not os.path.exists( incPath + '/ploop/libploop.h' ):
print('Warning: ploop-devel packages is not installed')
noct = True
try:
fd = open('Build/Build.pri', 'w')
except IOErrore:
print('Failed to open "Build/Build.pri"')
sys.exit(1)
fd.write("DEFINES += PRL_PROD_SERVER=1\n")
fd.write('DEFINES += _LIN_\n')
if not noct:
fd.write('DYN_VZLIB = TRUE\n')
fd.write('\n')
fd.write('# Product name\n')
fd.write('PRODUCT = server\n')
fd.write( '\n' )
fd.write( '# SDK library versions\n' )
fd.write( 'SDK_VER_MAJ = "%s"\n' % cfg.getint('sdk', 'major'))
fd.write( 'SDK_VER_MIN = "%s"\n' % cfg.getint('sdk', 'minor'))
fd.write('PREFIX = "%s"' % cfg.get('Build.cfg', 'install_prefix'))
fd.close()
time_fmt = "%a, %d %b %Y %H:%M:%S"
v_date = cfg.get("Build.cfg", "version_date")
v_ts = int(time.mktime(time.strptime(v_date, time_fmt)))
fd = open('Build/Current-gen.ver', 'w')
fd.write("""/* generated by Gen.py; DO NOT EDIT */
#define VER_FULL_BUILD_NUMBER_RELEASE_MAJOR %(version_major)d
#define VER_FULL_BUILD_NUMBER_RELEASE_MINOR %(version_minor)d
#define VER_FULL_BUILD_NUMBER_RELEASE_PATCH %(version_patch)d
#define VER_BUILD_TIMESTAMP %(version_timestamp)d
#define VER_SPECIAL_BUILD_STR "%(version_date)s"
""" % {'version_major': cfg.getint('Server', 'version_major'),
'version_minor': cfg.getint('Server', 'version_minor'),
'version_patch': cfg.getint('Server', 'version_patch'),
'version_date': v_date,
'version_timestamp': v_ts})
fd.write('#define VER_COPYRIGHT_YEAR %d\n' % time.localtime().tm_year)
fd.write('#define VER_COPYRIGHT_YEAR %d\n' % time.localtime().tm_year)
fd.close()