diff mbox series

kernel-shark: Get the path to trace-cmd executable from _INSTALL_PREFIX

Message ID 20190723182542.1295-1-y.karadz@gmail.com (mailing list archive)
State Accepted
Commit 80940d027767d36db535943e35de4135443dd647
Headers show
Series kernel-shark: Get the path to trace-cmd executable from _INSTALL_PREFIX | expand

Commit Message

Yordan Karadzhov July 23, 2019, 6:25 p.m. UTC
The absolute path to the trace-cmd executable gets derived from
"_INSTALL_PREFIX", and the "Record" dialog will be using its installed
version. This is done because nothing guaranties that the trace-cmd
executable will be presented at the time when the KernelShark package
is built. The rule has one exception and this is the case when the build
type is "Debug". In "Debug" mode the "Record" dialog will try to use the
version of the trace-cmd executable from the build location.

Sugested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark/CMakeLists.txt           |  8 ++++----
 kernel-shark/README                   |  7 ++++++-
 kernel-shark/build/FindTraceCmd.cmake | 10 ++++++++--
 3 files changed, 18 insertions(+), 7 deletions(-)

Comments

Steven Rostedt July 23, 2019, 6:48 p.m. UTC | #1
On Tue, 23 Jul 2019 21:25:42 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> The absolute path to the trace-cmd executable gets derived from
> "_INSTALL_PREFIX", and the "Record" dialog will be using its installed
> version. This is done because nothing guaranties that the trace-cmd
> executable will be presented at the time when the KernelShark package
> is built. The rule has one exception and this is the case when the build
> type is "Debug". In "Debug" mode the "Record" dialog will try to use the
> version of the trace-cmd executable from the build location.
> 
> Sugested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>

Thanks Yordan!

I just applied this and tested it this way.

On my build system, I removed all trace-cmd and kernelshark code, and
did this:

 $ mkdir /tmp/packages
 $ make clean
 $ make DESTDIR=/tmp/packages prefix=/usr install_gui
 $ cd /tmp/packages
 $ tar -cvjf /tmp/ks-package.tar.bz2 .
 $ scp /tmp/ks-package.tar.bz2 test-machine:/tmp

on test-machine:

 $ su -
 # cd /
 # tar xvf /tmp/ks-package.tar.bz2
 # cd ~
 # which kernelshark
/usr/bin/kernelshark
 # kernelshark

And tried a record, and all seems to be working!

-- Steve


> ---
>  kernel-shark/CMakeLists.txt           |  8 ++++----
>  kernel-shark/README                   |  7 ++++++-
>  kernel-shark/build/FindTraceCmd.cmake | 10 ++++++++--
>  3 files changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/kernel-shark/CMakeLists.txt b/kernel-shark/CMakeLists.txt
> index 45c6f23..075c4af 100644
> --- a/kernel-shark/CMakeLists.txt
> +++ b/kernel-shark/CMakeLists.txt
> @@ -13,6 +13,10 @@ message("\n project: Kernel Shark: (version: ${KS_VERSION_STRING})\n")
>  
>  set(KS_DIR ${CMAKE_SOURCE_DIR})
>  
> +if (NOT _INSTALL_PREFIX)
> +    set(_INSTALL_PREFIX "/usr/local")
> +endif (NOT _INSTALL_PREFIX)
> +
>  include(${KS_DIR}/build/FindTraceCmd.cmake)
>  include(${KS_DIR}/build/FindJSONC.cmake)
>  
> @@ -50,10 +54,6 @@ if (NOT CMAKE_CXX_FLAGS_PACKAGE)
>      set(CMAKE_CXX_FLAGS_PACKAGE "-O3")
>  endif (NOT CMAKE_CXX_FLAGS_PACKAGE)
>  
> -if (NOT _INSTALL_PREFIX)
> -    set(_INSTALL_PREFIX "/usr/local")
> -endif (NOT _INSTALL_PREFIX)
> -
>  set(KS_PLUGIN_INSTALL_PREFIX ${_INSTALL_PREFIX}/lib/${KS_APP_NAME}/plugins/)
>  
>  set(KS_ICON        KS_icon_shark.svg)
> diff --git a/kernel-shark/README b/kernel-shark/README
> index 7e50479..6c360bb 100644
> --- a/kernel-shark/README
> +++ b/kernel-shark/README
> @@ -86,9 +86,14 @@ By default this build type adds the "-O2" compiler flag. Package maintainers
>  can chose their own compiler flags by providing the corresponding
>  CMAKE_XXXX_FLAGS_PACKAGE Command-Line options (see the example below).
>  
> -Note that when built as a "Package" the RPATH-s of the executables are
> +-- Note that when built as a "Package" the RPATH-s of the executables are
>  set directly to _INSTALL_PREFIX/lib/kernelshark/
>  
> +-- Note that when built as a "Debug" the "Record" dialog will try to use the
> +version of the trace-cmd executable from the build location. In all other cases
> +the dialog will derive the absolut path to the trace-cmd executable from
> +"_INSTALL_PREFIX", hence the dialog will use the installed version.
> +
>  If no build types is specified, the type will be "RelWithDebInfo".
>  
>  Examples:
> diff --git a/kernel-shark/build/FindTraceCmd.cmake b/kernel-shark/build/FindTraceCmd.cmake
> index 2da4eee..d3e145c 100644
> --- a/kernel-shark/build/FindTraceCmd.cmake
> +++ b/kernel-shark/build/FindTraceCmd.cmake
> @@ -21,6 +21,12 @@ if (CMAKE_BUILD_TYPE MATCHES Debug)
>  
>  endif (CMAKE_BUILD_TYPE MATCHES Debug)
>  
> +if (NOT TRACECMD_EXECUTABLE)
> +
> +  set(TRACECMD_EXECUTABLE "${_INSTALL_PREFIX}/bin/trace-cmd")
> +
> +endif (NOT TRACECMD_EXECUTABLE)
> +
>  find_path(TRACECMD_INCLUDE_DIR  NAMES  trace-cmd/trace-cmd.h
>                                  PATHS  $ENV{TRACE_CMD}/include/
>                                         ${CMAKE_SOURCE_DIR}/../include/
> @@ -43,11 +49,11 @@ find_path(TRACECMD_INCLUDE_DIR  NAMES  trace-cmd/trace-cmd.h)
>  find_library(TRACECMD_LIBRARY   NAMES  trace-cmd/libtracecmd.so)
>  find_library(TRACEEVENT_LIBRARY NAMES  traceevent/libtraceevent.so)
>  
> -IF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY AND TRACECMD_EXECUTABLE)
> +IF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY)
>  
>    SET(TRACECMD_FOUND TRUE)
>  
> -ENDIF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY AND TRACECMD_EXECUTABLE)
> +ENDIF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY)
>  
>  IF (TRACECMD_FOUND)
>
diff mbox series

Patch

diff --git a/kernel-shark/CMakeLists.txt b/kernel-shark/CMakeLists.txt
index 45c6f23..075c4af 100644
--- a/kernel-shark/CMakeLists.txt
+++ b/kernel-shark/CMakeLists.txt
@@ -13,6 +13,10 @@  message("\n project: Kernel Shark: (version: ${KS_VERSION_STRING})\n")
 
 set(KS_DIR ${CMAKE_SOURCE_DIR})
 
+if (NOT _INSTALL_PREFIX)
+    set(_INSTALL_PREFIX "/usr/local")
+endif (NOT _INSTALL_PREFIX)
+
 include(${KS_DIR}/build/FindTraceCmd.cmake)
 include(${KS_DIR}/build/FindJSONC.cmake)
 
@@ -50,10 +54,6 @@  if (NOT CMAKE_CXX_FLAGS_PACKAGE)
     set(CMAKE_CXX_FLAGS_PACKAGE "-O3")
 endif (NOT CMAKE_CXX_FLAGS_PACKAGE)
 
-if (NOT _INSTALL_PREFIX)
-    set(_INSTALL_PREFIX "/usr/local")
-endif (NOT _INSTALL_PREFIX)
-
 set(KS_PLUGIN_INSTALL_PREFIX ${_INSTALL_PREFIX}/lib/${KS_APP_NAME}/plugins/)
 
 set(KS_ICON        KS_icon_shark.svg)
diff --git a/kernel-shark/README b/kernel-shark/README
index 7e50479..6c360bb 100644
--- a/kernel-shark/README
+++ b/kernel-shark/README
@@ -86,9 +86,14 @@  By default this build type adds the "-O2" compiler flag. Package maintainers
 can chose their own compiler flags by providing the corresponding
 CMAKE_XXXX_FLAGS_PACKAGE Command-Line options (see the example below).
 
-Note that when built as a "Package" the RPATH-s of the executables are
+-- Note that when built as a "Package" the RPATH-s of the executables are
 set directly to _INSTALL_PREFIX/lib/kernelshark/
 
+-- Note that when built as a "Debug" the "Record" dialog will try to use the
+version of the trace-cmd executable from the build location. In all other cases
+the dialog will derive the absolut path to the trace-cmd executable from
+"_INSTALL_PREFIX", hence the dialog will use the installed version.
+
 If no build types is specified, the type will be "RelWithDebInfo".
 
 Examples:
diff --git a/kernel-shark/build/FindTraceCmd.cmake b/kernel-shark/build/FindTraceCmd.cmake
index 2da4eee..d3e145c 100644
--- a/kernel-shark/build/FindTraceCmd.cmake
+++ b/kernel-shark/build/FindTraceCmd.cmake
@@ -21,6 +21,12 @@  if (CMAKE_BUILD_TYPE MATCHES Debug)
 
 endif (CMAKE_BUILD_TYPE MATCHES Debug)
 
+if (NOT TRACECMD_EXECUTABLE)
+
+  set(TRACECMD_EXECUTABLE "${_INSTALL_PREFIX}/bin/trace-cmd")
+
+endif (NOT TRACECMD_EXECUTABLE)
+
 find_path(TRACECMD_INCLUDE_DIR  NAMES  trace-cmd/trace-cmd.h
                                 PATHS  $ENV{TRACE_CMD}/include/
                                        ${CMAKE_SOURCE_DIR}/../include/
@@ -43,11 +49,11 @@  find_path(TRACECMD_INCLUDE_DIR  NAMES  trace-cmd/trace-cmd.h)
 find_library(TRACECMD_LIBRARY   NAMES  trace-cmd/libtracecmd.so)
 find_library(TRACEEVENT_LIBRARY NAMES  traceevent/libtraceevent.so)
 
-IF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY AND TRACECMD_EXECUTABLE)
+IF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY)
 
   SET(TRACECMD_FOUND TRUE)
 
-ENDIF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY AND TRACECMD_EXECUTABLE)
+ENDIF (TRACECMD_INCLUDE_DIR AND TRACECMD_LIBRARY)
 
 IF (TRACECMD_FOUND)