diff mbox series

[v2,2/3] kernel-shark: Configuration information in ${HOME}/.cache/kernelshark

Message ID 20190313152220.22026-3-ykaradzhov@vmware.com (mailing list archive)
State Superseded
Headers show
Series Tuning the KernelShark build system | expand

Commit Message

Yordan Karadzhov March 13, 2019, 3:22 p.m. UTC
By default the "Last session" configuration file will be saved in
${HOME}/.cache/kernelshark

After applying this patch you may need to clean the CMAKE cache.
This can be done by:

    cd kernel-shark/build/;./cmake_clean.sh; cd -
    make gui

Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 Makefile                          |  2 +-
 kernel-shark/CMakeLists.txt       | 13 ++++++++-----
 kernel-shark/build/deff.h.cmake   |  4 ++--
 kernel-shark/src/KsMainWindow.cpp |  4 ++--
 4 files changed, 13 insertions(+), 10 deletions(-)

Comments

Steven Rostedt March 26, 2019, 8:51 p.m. UTC | #1
On Wed, 13 Mar 2019 17:22:19 +0200
Yordan Karadzhov <ykaradzhov@vmware.com> wrote:

> @@ -12,10 +12,12 @@ message("\n project: Kernel Shark: (version: ${KS_VERSION_STRING})\n")
>  
>  set(KS_DIR ${CMAKE_SOURCE_DIR})
>  
> -# Make a directory to hold configuration files. To change this do:
> -# cmake .. -DKS_CONF_DIR=/your/preferred/path
> -set(KS_CONF_DIR "${KS_DIR}/.ksconf" CACHE STRING "Directory for configuration files.")
> -file(MAKE_DIRECTORY ${KS_CONF_DIR})
> +# Make a directory to hold cached configuration files. To change this do:
> +# cmake .. -DKS_CACHE_DIR=/your/preferred/path
> +set(KS_CACHE_DIR "$ENV{HOME}/.cache/kernelshark"
> +    CACHE STRING "Directory for cached configuration files.")
> +
> +file(MAKE_DIRECTORY ${KS_CACHE_DIR})
>  

This time I'm not confused (I tried it out).

The build process should *not* make the .cache/kernelshark directory.
It should be made by the application, just like all other applications
do.

-- Steve
Yordan Karadzhov March 27, 2019, 8:58 a.m. UTC | #2
On 26.03.19 г. 22:51 ч., Steven Rostedt wrote:
> On Wed, 13 Mar 2019 17:22:19 +0200
> Yordan Karadzhov <ykaradzhov@vmware.com> wrote:
> 
>> @@ -12,10 +12,12 @@ message("\n project: Kernel Shark: (version: ${KS_VERSION_STRING})\n")
>>   
>>   set(KS_DIR ${CMAKE_SOURCE_DIR})
>>   
>> -# Make a directory to hold configuration files. To change this do:
>> -# cmake .. -DKS_CONF_DIR=/your/preferred/path
>> -set(KS_CONF_DIR "${KS_DIR}/.ksconf" CACHE STRING "Directory for configuration files.")
>> -file(MAKE_DIRECTORY ${KS_CONF_DIR})
>> +# Make a directory to hold cached configuration files. To change this do:
>> +# cmake .. -DKS_CACHE_DIR=/your/preferred/path
>> +set(KS_CACHE_DIR "$ENV{HOME}/.cache/kernelshark"
>> +    CACHE STRING "Directory for cached configuration files.")
>> +
>> +file(MAKE_DIRECTORY ${KS_CACHE_DIR})
>>   
> 
> This time I'm not confused (I tried it out).
> 
> The build process should *not* make the .cache/kernelshark directory.
> It should be made by the application, just like all other applications
> do.
> 

Yes, this makes sense. I will make the application creating the 
.cache/kernelshark directory if it doesn't exist.

But do I need to remove the creation of directory in the build process?

Thanks!
Yordan


> -- Steve
>
Steven Rostedt March 27, 2019, 1:07 p.m. UTC | #3
On Wed, 27 Mar 2019 08:58:20 +0000
Yordan Karadzhov <ykaradzhov@vmware.com> wrote:

> Yes, this makes sense. I will make the application creating the 
> .cache/kernelshark directory if it doesn't exist.
> 
> But do I need to remove the creation of directory in the build process?

Yes, please remove it. A build process shouldn't modify directories
outside the build directory unless specifically told to do so (like
make install).

-- Steve
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index b780718..4cebd00 100644
--- a/Makefile
+++ b/Makefile
@@ -254,7 +254,7 @@  all_cmd: $(CMD_TARGETS)
 CMAKE_COMMAND = /usr/bin/cmake
 
 $(kshark-dir)/build/Makefile: $(kshark-dir)/CMakeLists.txt
-	$(Q) cd $(kshark-dir)/build && $(CMAKE_COMMAND) ..
+	$(Q) cd $(kshark-dir)/build && $(CMAKE_COMMAND) -DKS_CACHE_DIR=$(HOME)/.cache/kernelshark ..
 
 gui: force $(CMD_TARGETS) $(kshark-dir)/build/Makefile
 	$(Q)$(MAKE) $(S) -C $(kshark-dir)/build
diff --git a/kernel-shark/CMakeLists.txt b/kernel-shark/CMakeLists.txt
index 20ced14..c3743b4 100644
--- a/kernel-shark/CMakeLists.txt
+++ b/kernel-shark/CMakeLists.txt
@@ -12,10 +12,12 @@  message("\n project: Kernel Shark: (version: ${KS_VERSION_STRING})\n")
 
 set(KS_DIR ${CMAKE_SOURCE_DIR})
 
-# Make a directory to hold configuration files. To change this do:
-# cmake .. -DKS_CONF_DIR=/your/preferred/path
-set(KS_CONF_DIR "${KS_DIR}/.ksconf" CACHE STRING "Directory for configuration files.")
-file(MAKE_DIRECTORY ${KS_CONF_DIR})
+# Make a directory to hold cached configuration files. To change this do:
+# cmake .. -DKS_CACHE_DIR=/your/preferred/path
+set(KS_CACHE_DIR "$ENV{HOME}/.cache/kernelshark"
+    CACHE STRING "Directory for cached configuration files.")
+
+file(MAKE_DIRECTORY ${KS_CACHE_DIR})
 
 include(${KS_DIR}/build/FindTraceCmd.cmake)
 include(${KS_DIR}/build/FindJSONC.cmake)
@@ -59,7 +61,8 @@  include_directories(${KS_DIR}/src/
 message("")
 message(STATUS "C flags      : " ${CMAKE_C_FLAGS})
 message(STATUS "CXX flags    : " ${CMAKE_CXX_FLAGS})
-message(STATUS "Linker flags : " ${CMAKE_EXE_LINKER_FLAGS})
+message(STATUS "Linker flags : " ${CMAKE_EXE_LINKER_FLAGS}\n)
+message(STATUS "config. files saved in ${KS_CACHE_DIR}")
 
 add_subdirectory(${KS_DIR}/src)
 add_subdirectory(${KS_DIR}/examples)
diff --git a/kernel-shark/build/deff.h.cmake b/kernel-shark/build/deff.h.cmake
index 80d624c..56b37da 100644
--- a/kernel-shark/build/deff.h.cmake
+++ b/kernel-shark/build/deff.h.cmake
@@ -14,8 +14,8 @@ 
 /** KernelShark source code path. */
 #cmakedefine KS_DIR "@KS_DIR@"
 
-/** KernelShark configuration directory path. */
-#cmakedefine KS_CONF_DIR "@KS_CONF_DIR@"
+/** KernelShark cache directory path. */
+#cmakedefine KS_CACHE_DIR "@KS_CACHE_DIR@"
 
 /** Location of the trace-cmd executable. */
 #cmakedefine TRACECMD_BIN_DIR "@TRACECMD_BIN_DIR@"
diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
index 8ac19a7..d832f3f 100644
--- a/kernel-shark/src/KsMainWindow.cpp
+++ b/kernel-shark/src/KsMainWindow.cpp
@@ -133,7 +133,7 @@  KsMainWindow::KsMainWindow(QWidget *parent)
 KsMainWindow::~KsMainWindow()
 {
 	kshark_context *kshark_ctx(nullptr);
-	QString file = KS_CONF_DIR;
+	QString file = KS_CACHE_DIR;
 
 	file += "/lastsession.json";
 
@@ -370,7 +370,7 @@  void KsMainWindow::_open()
 
 void KsMainWindow::_restorSession()
 {
-	QString file = KS_CONF_DIR;
+	QString file = KS_CACHE_DIR;
 	file += "/lastsession.json";
 
 	loadSession(file);