new file mode 100755
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# SPDX-License-Identifier: GPL-2.0
+
+python3 np_setup.py --kslibdir=$1 \
+ --trlibdir=$2 \
+ --trincdir=$3 \
+ --evlibdir=$4 \
+ --evincdir=$5 \
+ --jsnincdir=$6 \
+ build_ext -i &> pybuild.log
+
+WC=$(grep 'error' pybuild.log | wc -l)
+if ((WC > 2)); then
+ cat pybuild.log
+fi
+
+if grep -q 'Error' pybuild.log; then
+ cat pybuild.log
+fi
+
+WC=$(grep 'warning' pybuild.log | wc -l)
+if ((WC > 3)); then
+ cat pybuild.log
+fi
+
+if grep -q 'usage' pybuild.log; then
+ cat pybuild.log
+fi
@@ -45,6 +45,28 @@ if (PYTHONLIBS_FOUND AND CYTHON_FOUND AND NUMPY_FOUND)
target_link_libraries(kshark-static ${LIBKSHARK_LINK_LIBS})
+
+ add_custom_target(kshark_wrapper ALL DEPENDS kshark-static libkshark-py.c
+ COMMENT "Generating libkshark_wrapper.c")
+
+ add_custom_command(TARGET kshark_wrapper
+ PRE_BUILD
+ COMMAND rm -rf build
+ COMMAND ./pybuild.sh ${KS_DIR}/lib/
+ ${TRACECMD_LIBRARY_DIR} ${TRACECMD_INCLUDE_DIR}
+ ${TRACEEVENT_LIBRARY_DIR} ${TRACEEVENT_INCLUDE_DIR}
+ ${JSONC_INCLUDE_DIR}
+ COMMAND mv ksharkpy.cpython-*.so ksharkpy.so
+ COMMAND cp ksharkpy.so ${KS_DIR}/bin
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/py
+ DEPENDS ${KS_DIR}/build/py/np_setup.py ${KS_DIR}/src/libkshark-py.c)
+
+ set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
+ "${KS_DIR}/bin/ksharkpy.so"
+ "${KS_DIR}/build/py/ksharkpy.so"
+ "${KS_DIR}/build/py/libkshark_wrapper.c"
+ "${KS_DIR}/build/py/build")
+
endif (PYTHONLIBS_FOUND AND CYTHON_FOUND AND NUMPY_FOUND)
if (Qt5Widgets_FOUND AND Qt5Network_FOUND)
CMAKE will call the python script that build the NumPy interface. It will also takes care about cleaning. Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com> --- kernel-shark/build/py/pybuild.sh | 29 +++++++++++++++++++++++++++++ kernel-shark/src/CMakeLists.txt | 22 ++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100755 kernel-shark/build/py/pybuild.sh