forked from tumi8/vermont
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_test.py
executable file
·100 lines (83 loc) · 2.57 KB
/
build_test.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env python
# This is a testing scripts that tries to build vermont with all
# avaiable options. Do not use this to build vermont if you want
# to have a usable built of vermont.
# Note: We have a lot of options for configuring vermont available.
# This test builts will run for ages to complete all of them ...
OptionList = [
'DEBUG',
'DISABLE_MEMMANAGER',
'IPFIXLOLIB_RAWDIR_SUPPORT',
'SUPPORT_DTLS',
# 'SUPPORT_DTLS_OVER_SCTP',
'SUPPORT_MYSQL',
'SUPPORT_NETFLOWV9',
# 'SUPPORT_ORACLE',
'SUPPORT_POSTGRESQL',
'SUPPORT_SCTP',
'USE_GSL',
# 'USE_PCAPMMAP',
# 'USE_PFRING',
'WITH_TESTS',
'WITH_TOOLS',
'SUPPORT_MONGO'
]
def rm_rf(d):
"""Recursively delete content of d. Used to clean the previous builts"""
for path in (os.path.join(d,f) for f in os.listdir(d)):
if os.path.isdir(path):
rm_rf(path)
else:
os.unlink(path)
def do_build(optlist):
buildstring = "cmake ../ "
for i in optlist:
buildstring += i + " "
print "Trying to build vermont with options: \n\t",
print buildstring
rm_rf(".")
if os.system(buildstring) != 0:
print "Failed configuring vermont!"
sys.exit(-1)
if os.system("make") != 0:
print "Failed building vermont!"
sys.exit(-1)
def build_all_option_list(optList):
build(list(), optList)
def build(fixed, rest):
if len(rest) == 0:
do_build(fixed)
return
# build option list recursively
option = rest.pop(0)
restOn = list(rest)
restOff = list(rest)
withOn = list(fixed)
withOff = list(fixed)
withOn.append("-D" + option + "=ON")
withOff.append("-D" + option + "=OFF")
build(withOn, restOn)
build(withOff, restOff)
if __name__ == "__main__":
import os
import sys
# we are working with rm -rf. Do not run this as root.
if os.geteuid()==0:
sys.exit("\nDo not run this script as root!!!");
# we need to clean a previous make cache. If we don't do this
# cmake will reuse the cache and does not create a new cache in
# vermont/build/. But we don't want to do this automatically, so
# let the user decide if we wants to do this
if os.access("./CMakeCache.txt", os.R_OK):
print "Found a previous CMakeCache.txt. I cannot make the test builds while this cache is ",
print "resides in the vermont source directory. If you want to make the test builds, please",
print "remove the file CMakeCache.txt. Please note that you have to redo your insource built",
print "afterwards..."
sys.exit(-1)
print "Creating build directory ..."
if not os.access("./build/", os.R_OK | os.W_OK):
os.makedirs("./build/")
os.chdir("./build/")
print "Starting build process ..."
build_all_option_list(OptionList)
pass