-
Notifications
You must be signed in to change notification settings - Fork 3
/
reggaefile.py
57 lines (44 loc) · 1.89 KB
/
reggaefile.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
from reggae import object_files, link, Build, user_vars, optional
san_opts = ""
if 'production' in user_vars:
san_opts = '-fsanitize=address'
includes = [".", "example/cpp/test", "example/src",
"example/deps", "example/cpp/mocks"]
common_flags = san_opts + " -Wall -Werror -Wextra -g"
c_flags = common_flags
prod_flags = c_flags + " -include mocks.h"
cpp_flags = common_flags + " -std=c++14"
linker_flags = san_opts
# production code we want to test
prod_objs = object_files(src_dirs=["example/src"],
includes=includes,
flags=prod_flags)
# C dependencies of the production code
dep_objs = object_files(src_dirs=["example/deps"],
flags=c_flags)
# Test code where the mock implementations live
mock_objs = object_files(src_dirs=["example/cpp/mocks"],
includes=includes,
flags=cpp_flags)
# The unit tests themselves
test_objs = object_files(src_dirs=["example/cpp/test"],
includes=includes,
flags=cpp_flags)
# The example_cpp binary
example_cpp = link(exe_name="example_cpp",
dependencies=[test_objs, prod_objs,
dep_objs, mock_objs],
flags=linker_flags)
# Unit tests for premock itself
ut_cpp_objs = object_files(src_dirs=["tests"],
flags=cpp_flags,
includes=[".", "tests"])
ut_cpp = link(exe_name="ut_cpp", dependencies=ut_cpp_objs, flags=linker_flags)
d_objs = object_files(src_dirs=["example/d"],
src_files=["premock.d"],
flags='-g -unittest',
includes=[".", "example/d"])
ut_d = link(exe_name="example_d",
dependencies=[d_objs, prod_objs, dep_objs],
flags="-L-lstdc++")
build = Build(example_cpp, ut_cpp, optional(ut_d))