This repository has been archived by the owner on Jan 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
CMakeLists.txt
80 lines (65 loc) · 2.7 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
# CMakefile for the XDP P4-16 back-end.
message(STATUS "Start configuring XDP back end")
set (P4C_XDP_SOURCES
p4c-xdp.cpp
xdpModel.cpp
xdpControl.cpp
xdpProgram.cpp
target.cpp
xdpBackend.cpp
../../backends/ebpf/ebpfProgram.cpp
../../backends/ebpf/ebpfOptions.cpp
../../backends/ebpf/ebpfTable.cpp
../../backends/ebpf/ebpfControl.cpp
../../backends/ebpf/ebpfParser.cpp
../../backends/ebpf/target.cpp
../../backends/ebpf/ebpfType.cpp
../../backends/ebpf/codeGen.cpp
../../backends/ebpf/ebpfModel.cpp
../../backends/ebpf/midend.cpp
../../backends/ebpf/lower.cpp
)
set (P4C_XDP_HEADERS
xdpModel.h
xdpProgram.h
xdpControl.h
target.h
xdpBackend.h
)
set (XDP_DIST_HEADERS p4include/xdp_model.p4)
add_cpplint_FILES(${CMAKE_CURRENT_SOURCE_DIR} "${P4C_XDP_SOURCES};${P4C_XDP_HEADERS}")
build_unified(P4C_XDP_SOURCES)
add_executable(p4c-xdp ${P4C_XDP_SOURCES})
target_link_libraries(p4c-xdp ${P4C_LIBRARIES} ${P4C_LIB_DEPS})
install (TARGETS p4c-xdp
RUNTIME DESTINATION ${P4C_RUNTIME_OUTPUT_DIRECTORY})
install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/p4include
DESTINATION ${P4C_ARTIFACTS_OUTPUT_DIRECTORY})
add_custom_target(linkp4cxdp
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_BINARY_DIR}/p4c-xdp ${P4C_BINARY_DIR}/p4c-xdp
COMMAND ${CMAKE_COMMAND} -E make_directory ${P4C_BINARY_DIR}/p4include &&
${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${XDP_DIST_HEADERS} ${P4C_BINARY_DIR}/p4include
COMMAND ${CMAKE_COMMAND} -E create_symlink ${P4C_BINARY_DIR}/p4include ${CMAKE_CURRENT_BINARY_DIR}/p4include
)
# check for the libbpf library, it is required for p4c-xdp to work
find_library(LIBBPF_XDP NAMES bpf HINTS "${P4C_SOURCE_DIR}/backends/ebpf/runtime/usr/lib64/")
if (LIBBPF_XDP)
message(STATUS "Found libbpf library")
else()
message(FATAL_ERROR "Missing the libbpf dependency, disabling kernel tests."
" You can install libbpf by running './build_libbpf' in the "
"$${P4C_SOURCE_DIR}/backends/ebpf/runtime folder.")
endif()
# Automatically insert the xdp_target in the targets folder
if(CMAKE_HOST_UNIX)
EXECUTE_PROCESS(COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/xdp_target.py ${P4C_SOURCE_DIR}/backends/ebpf/targets/xdp_target.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif(CMAKE_HOST_UNIX)
set (XFAIL_TESTS_XDP)
add_dependencies(p4c_driver linkp4cxdp)
set(XDP_DRIVER "${P4C_SOURCE_DIR}/backends/ebpf/run-ebpf-test.py -t xdp -c \"${P4C_BINARY_DIR}/p4c-xdp\"")
# This file will not run the full tests, but it will attempt to compile the p4 files down to C
set (XDP_TEST_SUITES "${CMAKE_CURRENT_SOURCE_DIR}/tests/xdp*.p4")
p4c_add_tests("xdp" ${XDP_DRIVER} ${XDP_TEST_SUITES} "${XFAIL_TESTS_XDP}")
message(STATUS "Done with configuring XDP back end")