diff mbox series

[RFC,v2,5/6] kernel-shark: Add automatic building of the NumPy interface

Message ID 20190405101411.25466-6-ykaradzhov@vmware.com (mailing list archive)
State Superseded
Headers show
Series NumPy Interface for KernelShark | expand

Commit Message

Yordan Karadzhov April 5, 2019, 10:14 a.m. UTC
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
diff mbox series

Patch

diff --git a/kernel-shark/build/py/pybuild.sh b/kernel-shark/build/py/pybuild.sh
new file mode 100755
index 0000000..fc07711
--- /dev/null
+++ b/kernel-shark/build/py/pybuild.sh
@@ -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
diff --git a/kernel-shark/src/CMakeLists.txt b/kernel-shark/src/CMakeLists.txt
index b9a05e1..ba97c42 100644
--- a/kernel-shark/src/CMakeLists.txt
+++ b/kernel-shark/src/CMakeLists.txt
@@ -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)