-
Notifications
You must be signed in to change notification settings - Fork 4
/
SConstruct.py
70 lines (60 loc) · 1.56 KB
/
SConstruct.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
"""SConstruct file that builds:
- kpabe static lib
- main.cpp
- unittests
"""
import os
CXXFLAGS = ["-std=gnu++14",]
def getNativeEnv():
"""Get the environment.
"""
INCLUDES = [
"-I.",
"-I/usr/local/include",
"-I/usr/local/include/pbc",
]
LIBPATH = [
"#",
"/usr/local/lib",
]
LIBS = [
"pbc",
"gmp",
"mbedcrypto",
"m",
]
env = DefaultEnvironment(CXXFLAGS=CXXFLAGS + ["-Os"] + INCLUDES,
LIBS=LIBS,
LIBPATH=LIBPATH)
return env
def getKpabeLib(env):
"""Get target for kpabe static lib.
"""
return env.StaticLibrary("kpabe", ["kpabe.cpp"])
def getTestsTarget(env):
"""Get test targets.
"""
BOOST_H = "/usr/local/include/boost"
BOOST_TEST_LIB = "boost_unit_test_framework"
files = ["kpabe_test.cpp"]
testEnv = env.Clone()
testEnv["LIBS"].insert(0, ["kpabe", BOOST_TEST_LIB])
testCases = [];
for f in files:
targetFile = os.path.join("#",
str(f).split('.')[0].split(os.path.sep)[-1])
testCases.append(testEnv.Program(targetFile, [f]))
return testCases
def getMainTarget(env):
"""Get main target.
"""
mainEnv = env.Clone()
mainEnv["LIBS"].insert(0, "kpabe")
return mainEnv.Program("main", "#main.cpp")
def getAllTargets(env):
"""Get all targets.
"""
targets = getTestsTarget(env) + getMainTarget(env)
return targets
env = getNativeEnv()
env.Default(getAllTargets(env) + getKpabeLib(env))