forked from pluginized-protocols/libxbgp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
167 lines (139 loc) · 6.29 KB
/
CMakeLists.txt
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
cmake_minimum_required(VERSION 3.15)
project(libxbgp_vm C)
find_package(PkgConfig)
find_package(Threads)
set(CMAKE_C_STANDARD 11)
set(TESTS_DIR "${CMAKE_SOURCE_DIR}/tests")
set(PLUGIN_TESTS_DIR "${TESTS_DIR}/plugins")
set(MICHELFRALLOC_DIR "${CMAKE_SOURCE_DIR}/memalloc")
set(UBPF_VM_DIR "${CMAKE_SOURCE_DIR}/ubpf_vm/vm")
set(TOMMYDS_DIR "${CMAKE_SOURCE_DIR}/tommyds")
set(MICROBENCH_DIR "${TESTS_DIR}/microbenchmarks")
set(UBPF_VM_SOURCES
${UBPF_VM_DIR}/ubpf_jit_x86_64.c
${UBPF_VM_DIR}/ubpf_loader.c
${UBPF_VM_DIR}/ubpf_vm.c)
# Ugly hack since I don't want to have many includes for libxbgp...
# MICHELFRALLOC generates 2 static libs for 3 object files only...
add_custom_command(OUTPUT ${MICHELFRALLOC_DIR}/michelfralloc.o
${MICHELFRALLOC_DIR}/sbrk.o
${MICHELFRALLOC_DIR}/ptmalloc3/malloc.o
COMMAND make clean && make
WORKING_DIRECTORY ${MICHELFRALLOC_DIR}
)
set(MICHELFRA_OBJS
"${MICHELFRALLOC_DIR}/michelfralloc.o"
"${MICHELFRALLOC_DIR}/sbrk.o"
"${MICHELFRALLOC_DIR}/ptmalloc3/malloc.o")
add_custom_command(OUTPUT ${TOMMYDS_DIR}/tommy.o
COMMAND make
WORKING_DIRECTORY ${TOMMYDS_DIR})
set(TOMMYDS_OBJS "${TOMMYDS_DIR}/tommy.o")
include_directories(.)
include_directories(include)
include_directories(ubpf_vm/vm)
include_directories(ubpf_vm/vm/inc)
include_directories(xbgp_deps)
include_directories(tommyds/tommyds)
# set default build type if not specified by user
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE debug)
endif()
set(DEBUG_SYMBOLS "-gdwarf -gdwarf-5 -g3 -fvar-tracking -fvar-tracking-assignments")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -march=native -mtune=native")
set(CMAKE_C_FLAGS_DEBUG "-O0 ${DEBUG_SYMBOLS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CC_WARNING_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wwrite-strings")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-qual")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-prototypes")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-declarations")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpointer-arith")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wbad-function-cast")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-prototypes")
add_library(xbgp
${UBPF_VM_SOURCES}
${MICHELFRA_OBJS}
${TOMMYDS_OBJS}
bpf_plugin.c bpf_plugin.h
context_function.c context_function.h
dict.c dict.h
event.c event.h
evt_plugins.c evt_plugins.h
insertion_point.c insertion_point.h
log.c log.h
plugin_extra_configuration.c plugin_extra_configuration.h
plugin_socket.c plugin_socket.h
plugins_manager.c plugins_manager.h
pluglet_validation.c pluglet_validation.h
queue.c queue.h
shared_memory.c shared_memory.h
static_injection.c static_injection.h
tree.c tree.h
ubpf_api.c ubpf_api.h
ubpf_context.c ubpf_context.h
ubpf_manager.c ubpf_manager.h
ubpf_memory_pool.c ubpf_memory_pool.h
ubpf_misc.c ubpf_misc.h
url_parser.c url_parser.h
uthash.h utlist.h jhash.h)
add_executable(libxbgp_tests ${TESTS_DIR}/main_tests.c
${TESTS_DIR}/extra_info_big.c ${TESTS_DIR}/extra_info_big.h
${TESTS_DIR}/extra_info_test.c ${TESTS_DIR}/extra_info_test.h
${TESTS_DIR}/ffi_closure_tests.c ${TESTS_DIR}/ffi_closure_tests.h
${TESTS_DIR}/internal_tests.c ${TESTS_DIR}/internal_tests.h
${TESTS_DIR}/job_plugins_tests.c ${TESTS_DIR}/job_plugins_tests.h
${TESTS_DIR}/mempool_tests.c ${TESTS_DIR}/mempool_tests.h
${TESTS_DIR}/monitoring_tests.c ${TESTS_DIR}/mempool_tests.h
${TESTS_DIR}/next_replace_tests.c ${TESTS_DIR}/next_replace_tests.h
${TESTS_DIR}/permissions_test.c ${TESTS_DIR}/permissions_test.h
${TESTS_DIR}/runtime_memcheck_test.c ${TESTS_DIR}/runtime_memcheck_test.h
${TESTS_DIR}/sockets_tests.c ${TESTS_DIR}/sockets_tests.h
${TESTS_DIR}/tree_test.c ${TESTS_DIR}/tree_test.h
${TESTS_DIR}/test_rust_plugins.c ${TESTS_DIR}/test_rust_plugins.h
${TESTS_DIR}/ubpf_manager_test.c ${TESTS_DIR}/ubpf_manager_test.h)
add_executable(microbench
${MICROBENCH_DIR}/microbench_main.c
${MICROBENCH_DIR}/defs_type.h
tests/microbenchmarks/check_ret_vals.c
tests/microbenchmarks/check_ret_vals.h
${MICROBENCH_DIR}/plugins/no_insts.c
${MICROBENCH_DIR}/plugins/10_insts.c
${MICROBENCH_DIR}/plugins/100_insts.c
${MICROBENCH_DIR}/plugins/1000_insts.c
${MICROBENCH_DIR}/plugins/10000_insts.c
${MICROBENCH_DIR}/plugins/100000_insts.c
${MICROBENCH_DIR}/plugins/1000000_insts.c
${MICROBENCH_DIR}/plugins/1000_insts_1api.c
${MICROBENCH_DIR}/plugins/1000_insts_2api.c
${MICROBENCH_DIR}/plugins/1000_insts_3api.c
${MICROBENCH_DIR}/plugins/1000_insts_getset.c
tests/microbenchmarks/plugins/dumb_functions.h
tests/microbenchmarks/dumb_function_exec.c
tests/microbenchmarks/dumb_function_exec.h
tests/microbenchmarks/utils.h
${MICROBENCH_DIR}/plugins/fake_api/fake_api.c
${MICROBENCH_DIR}/plugins/fake_api/fake_api.h
tests/microbenchmarks/plugins/fake_api/fake_api_plugin.h)
add_executable(ebpf_inst_counter
misc/insts_counter/ebpf_insts_counter.c)
pkg_check_modules(JSON-C REQUIRED json-c)
pkg_check_modules(FFI REQUIRED libffi)
pkg_check_modules(CUNIT REQUIRED cunit)
CHECK_LIBRARY_EXISTS(m sin "" HAVE_LIB_M)
if (HAVE_LIB_M)
set(LIBM m)
endif (HAVE_LIB_M)
add_custom_target(gen_ebpf_test_obj COMMAND make
WORKING_DIRECTORY ${PLUGIN_TESTS_DIR})
target_link_libraries(libxbgp_tests xbgp ${FFI_LIBRARIES}
${JSON-C_LIBRARIES} ${CUNIT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${LIBM})
add_dependencies(libxbgp_tests gen_ebpf_test_obj)
target_link_libraries(microbench xbgp ${FFI_LIBRARIES}
${JSON-C_LIBRARIES} ${CUNIT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${LIBM})
target_link_libraries(ebpf_inst_counter xbgp ${FFI_LIBRARIES}
${JSON-C_LIBRARIES} ${CUNIT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${LIBM})
enable_testing()
add_test(Working_uBPF_VM libxbgp_tests -p ${PLUGIN_TESTS_DIR})