mirror of
https://github.com/varun-r-mallya/pylibbpf.git
synced 2026-02-12 16:11:00 +00:00
Make libbpf headers possible to include
This commit is contained in:
@ -35,10 +35,20 @@ elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "loongarch64")
|
|||||||
set(ARCH "loongarch")
|
set(ARCH "loongarch")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(LIBBPF_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/libbpf)
|
set(LIBBPF_INCLUDE_DIRS
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libbpf
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/libbpf/include
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/libbpf/usr/include)
|
||||||
set(LIBBPF_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/libbpf/libbpf.a)
|
set(LIBBPF_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/libbpf/libbpf.a)
|
||||||
|
|
||||||
# EXAMPLE_VERSION_INFO is defined by setup.py and passed into the C++ code as a
|
# EXAMPLE_VERSION_INFO is defined by setup.py and passed into the C++ code as a
|
||||||
# define (VERSION_INFO) here.
|
# define (VERSION_INFO) here.
|
||||||
target_compile_definitions(pylibbpf
|
target_compile_definitions(pylibbpf
|
||||||
PRIVATE VERSION_INFO=${PYLIBBPF_VERSION_INFO})
|
PRIVATE VERSION_INFO=${PYLIBBPF_VERSION_INFO})
|
||||||
|
|
||||||
|
# ensure build order
|
||||||
|
add_dependencies(pylibbpf libbpf)
|
||||||
|
|
||||||
|
# headers + linking
|
||||||
|
target_include_directories(pylibbpf PRIVATE ${LIBBPF_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(pylibbpf PRIVATE ${LIBBPF_LIBRARIES})
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
#include <pybind11/pybind11.h>
|
#include <pybind11/pybind11.h>
|
||||||
|
|
||||||
#define STRINGIFY(x) #x
|
#define STRINGIFY(x) #x
|
||||||
#define MACRO_STRINGIFY(x) STRINGIFY(x)
|
#define MACRO_STRINGIFY(x) STRINGIFY(x)
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "bpf/libbpf.h"
|
||||||
|
}
|
||||||
|
|
||||||
int add(int i, int j) {
|
int add(int i, int j) {
|
||||||
return i + j;
|
return i + j;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user