diff mbox series

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

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

Commit Message

Yordan Karadzhov March 27, 2019, 4:03 p.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 | 26 ++++++++++++++++++++++++++
 kernel-shark/src/CMakeLists.txt  | 20 ++++++++++++++++++++
 2 files changed, 46 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..978085c
--- /dev/null
+++ b/kernel-shark/build/py/pybuild.sh
@@ -0,0 +1,26 @@ 
+#!/bin/bash
+
+python np_setup.py --pykslibdir=$1 \
+                   --trlibdir=$2 \
+                   --trincdir=$3 \
+                   --evlibdir=$4 \
+                   --evincdir=$5 \
+                   --jsnincdir=$6 \
+                   build_ext -i &> pybuild.log
+
+if grep -q 'error:' pybuild.log; 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 > 2)); 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 a3c6743..886ddad 100644
--- a/kernel-shark/src/CMakeLists.txt
+++ b/kernel-shark/src/CMakeLists.txt
@@ -45,6 +45,26 @@  if (PYTHONLIBS_FOUND AND CYTHON_FOUND AND NUMPY_FOUND)
                                    ${CMAKE_DL_LIBS}
                                    ${JSONC_LIBRARIES})
 
+
+    add_custom_target(kshark_wrapper ALL DEPENDS pykshark libkshark-py.c
+                                     COMMENT "Generating libkshark_wrapper.c")
+
+    add_custom_command(TARGET kshark_wrapper
+                       PRE_BUILD
+                       COMMAND ./pybuild.sh ${KS_DIR}/lib/
+                                            ${TRACECMD_LIBRARY_DIR}   ${TRACECMD_INCLUDE_DIR}
+                                            ${TRACEEVENT_LIBRARY_DIR} ${TRACEEVENT_INCLUDE_DIR}
+                                            ${JSONC_INCLUDE_DIR}
+                       COMMAND cp libkshark_wrapper.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/libkshark_wrapper.so"
+                                           "${KS_DIR}/build/py/libkshark_wrapper.so"
+                                           "${KS_DIR}/build/py/libkshark_wrapper.c")
+
 endif (PYTHONLIBS_FOUND AND CYTHON_FOUND AND NUMPY_FOUND)
 
 if (Qt5Widgets_FOUND AND Qt5Network_FOUND)