From 9cec2e11ce55efaf1a0656607daff4de29dd579c Mon Sep 17 00:00:00 2001 From: Krzysztof Jackiewicz Date: Thu, 8 Nov 2012 12:37:59 +0100 Subject: [PATCH] Profiling disabled for other configurations [Issue#] N/A [Bug] Profiling library was compiled and used regardless of the build configuration. Logs should be disabled in configurations other than Debug. [Problem] N/A [Cause] Incorrect cmake configuration. [Solution] Compilation is triggered only in Profiling build configuration. Logs allowed only in Debug mode. [Verification] 1.Compile wrt with build_type set to Profiling and any other (Release, Debug). Both should succeed. 2.For both configurations run rpm -qlp | grep profiling. Only in case of Profiling the library should be present. 3.Run any widget. It should be displayed properly in both cases. 4.Run profiling scripts. In case of profiling they should produce graphs. It should fail (freeze) in other configurations. 5.Check compilation output. Logs should be enabled only in Debug mode Change-Id: Ia60d609433e1896750f43a3508ca343b7e86695a --- CMakeLists.txt | 28 ++++++++++++++++------------ src/CMakeLists.txt | 4 +++- src/profiling/profiling_util.h | 2 ++ 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d14f21..3db18e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,12 +42,23 @@ ENDIF(NOT CMAKE_BUILD_TYPE) OPTION(DPL_LOG "DPL logs status" ON) -IF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling") - MESSAGE(STATUS "Logging enabled for DPL") +# logs can be only enabled in debug mode +IF(CMAKE_BUILD_TYPE MATCHES "Debug" AND DPL_LOG) ADD_DEFINITIONS("-DDPL_LOGS_ENABLED") -ELSE(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling") + MESSAGE(STATUS "Logging enabled for DPL") +ELSE(CMAKE_BUILD_TYPE MATCHES "Debug" AND DPL_LOG) MESSAGE(STATUS "Logging disabled for DPL") -ENDIF(DPL_LOG AND NOT CMAKE_BUILD_TYPE MATCHES "profiling") +ENDIF(CMAKE_BUILD_TYPE MATCHES "Debug" AND DPL_LOG) + +MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") +OPTION(PROFILING "Profiling status" OFF) +IF(CMAKE_BUILD_TYPE MATCHES "Profiling") + MESSAGE(STATUS "PROFILING: ENABLED") + ADD_DEFINITIONS("-DPROFILING_ENABLED") + SET(PROFILING ON) +ELSE(CMAKE_BUILD_TYPE MATCHES "Profiling") + MESSAGE(STATUS "PROFILING: DISABLED") +ENDIF(CMAKE_BUILD_TYPE MATCHES "Profiling") # Compiler flags SET(CMAKE_C_FLAGS_PROFILING "-O2") @@ -117,16 +128,9 @@ SET(TARGET_VIEW_MODULE_LIB "wrt-view-module") SET(TARGET_CORE_MODULE_LIB "wrt-core-module") SET(TARGET_BUNDLES_LIB "wrt-wk2-bundle") -# PROFILING -# need to check build with OFF -OPTION(PROFILING "Profiling enabled" ON) +SET(PROF_LIB "") IF(PROFILING) - MESSAGE(STATUS "PROFILING: ENABLED") - ADD_DEFINITIONS("-DPROFILING_ENABLED") SET(PROF_LIB ${TARGET_PROFILING_LIB}) -ELSE(PROFILING) - MESSAGE(STATUS "PROFILING: DISABLED") - SET(PROF_LIB "") ENDIF(PROFILING) INSTALL(FILES diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 13abe28..2bdb064 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -141,4 +141,6 @@ ADD_SUBDIRECTORY(api_new) ADD_SUBDIRECTORY(wrt-client) ADD_SUBDIRECTORY(wrt-launcher) ADD_SUBDIRECTORY(plugin-service) -ADD_SUBDIRECTORY(profiling) +IF(PROFILING) + ADD_SUBDIRECTORY(profiling) +ENDIF(PROFILING) diff --git a/src/profiling/profiling_util.h b/src/profiling/profiling_util.h index 2e5cc89..64b909a 100644 --- a/src/profiling/profiling_util.h +++ b/src/profiling/profiling_util.h @@ -48,6 +48,8 @@ void AddStdoutProfilingMeasurment(const char* name, bool start); #else //PROFILING_ENABLED #define ADD_PROFILING_POINT(name, ...) (void)1 +#define LOG_PROFILE_START(x) (void)1 +#define LOG_PROFILE_STOP(x) (void)1 #endif //PROFILING_ENABLED -- 2.7.4