forked from infinit/dopenssl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drakefile
99 lines (81 loc) · 2.83 KB
/
drakefile
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
import drake
import drake.cxx
config = None
lib_static = None
lib_dynamic = None
rule_build = None
rule_check = None
rule_install = None
rule_tests = None
def configure(cxx_toolkit = None,
cxx_config = None,
openssl_config = None,
openssl_lib_crypto = None,
openssl_lib_ssl = None,
prefix = '/usr'):
global config, lib_static, lib_dynamic, rule_build, rule_check, rule_install
# Toolkit
cxx_toolkit = cxx_toolkit or drake.cxx.Toolkit()
# Global Configuration
config = drake.cxx.Config(cxx_config)
config.add_local_include_path('src')
# Local Configuration
cxx_config = drake.cxx.Config(config)
# Sources
sources = drake.nodes(
'src/dopenssl/all.h',
'src/dopenssl/bn.c',
'src/dopenssl/bn.h',
'src/dopenssl/rand.c',
'src/dopenssl/rand.h',
'src/dopenssl/rsa.c',
'src/dopenssl/rsa.h',
)
# Tests
tests = ['bn',
'rand',
'rsa']
openssl_libs = []
if openssl_lib_crypto and openssl_lib_ssl:
cxx_config += openssl_config
openssl_libs = drake.copy([openssl_lib_crypto, openssl_lib_ssl],
'lib', strip_prefix = True)
else:
cxx_config += openssl_config
openssl_config = drake.cxx.find_library('openssl/opensslconf.h', prefix = openssl_config)
cxx_config.lib('crypto')
cxx_config.lib('ssl')
cxx_config.lib_path_runtime('.')
lib_static = drake.cxx.StaticLib('lib/dopenssl',
sources + openssl_libs,
cxx_toolkit, cxx_config)
lib_dynamic = drake.cxx.DynLib('lib/dopenssl',
sources + openssl_libs,
cxx_toolkit, cxx_config)
# Build
rule_build = drake.Rule('build')
rule_build << lib_static
rule_build << lib_dynamic
# Tests
global rule_check, rule_tests
rule_tests = drake.Rule('tests')
rule_check = drake.Rule('check')
tests_cxx_config = drake.cxx.Config(cxx_config)
for test in tests:
config_test = drake.cxx.Config(tests_cxx_config)
config_test.lib_path_runtime('%s../../lib' % ('../' * test.count('/')))
path = drake.Path('tests/dopenssl/%s.c' % test)
bin_path = drake.Path('tests/dopenssl/%s' % test)
bin = drake.cxx.Executable(bin_path,
drake.nodes(path) +
[lib_dynamic] + openssl_libs,
cxx_toolkit, config_test)
rule_tests << bin
runner = drake.Runner(bin)
rule_check << runner.status
# Install
rule_install = drake.Rule('install')
prefix = drake.Path(prefix)
rule_install << drake.install(lib_dynamic, prefix)
rule_install << drake.install(lib_static, prefix)
rule_install << drake.install(list(filter(lambda n: isinstance(n, drake.cxx.Header), sources)), prefix / 'include', 'src')