From c869617eb653729b9dde82f1406403af85a8d355 Mon Sep 17 00:00:00 2001 From: Thad House Date: Thu, 30 Jul 2020 09:00:32 -0700 Subject: [PATCH] Skip calling CLOG if logging is disabled (#652) * Skip calling CLOG if logging is disabled Adds an unnecessary dependency if logging is disabled anyway * Fiox dist * Remove ifdef * Rename and merge function * Fix build, move clog targets into folder * Skip folder when not actually using clog Co-authored-by: Nick Banks --- CMakeLists.txt | 28 ++++++++++++++++++++-------- src/core/CMakeLists.txt | 4 +--- src/core/unittest/CMakeLists.txt | 4 +--- src/perf/bin/CMakeLists.txt | 2 +- src/perf/lib/CMakeLists.txt | 2 +- src/platform/CMakeLists.txt | 4 +--- src/platform/datapath_winuser.c | 1 + src/platform/platform_winuser.c | 3 +++ src/platform/unittest/CMakeLists.txt | 4 +--- src/test/bin/CMakeLists.txt | 4 +--- src/test/lib/CMakeLists.txt | 4 +--- 11 files changed, 32 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f074b3304..986ec4e13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,8 +153,6 @@ set(QUIC_OUTPUT_DIR ${QUIC_BUILD_DIR}/bin/$,Debug,Release> CA set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${QUIC_BUILD_DIR}/obj/$,Debug,Release>) -execute_process(COMMAND clog --installDirectory ${CMAKE_SOURCE_DIR}/build/clog) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${QUIC_OUTPUT_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${QUIC_OUTPUT_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${QUIC_OUTPUT_DIR}) @@ -162,12 +160,26 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${QUIC_OUTPUT_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${QUIC_OUTPUT_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${QUIC_OUTPUT_DIR}) -set(CMAKE_CLOG_OUTPUT_DIRECTORY ${QUIC_BUILD_DIR}/inc) -set(CMAKE_CLOG_SIDECAR_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/manifest) -set(CLOG_INCLUDE_DIRECTORY ${CMAKE_SOURCE_DIR}/build/clog) -set(CMAKE_CLOG_GENERATE_FILE ${CMAKE_SOURCE_DIR}/build/clog/CLog.cmake) -set(CMAKE_CLOG_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/manifest/msquic.clog_config) -include(${CMAKE_CLOG_GENERATE_FILE}) +if (QUIC_ENABLE_LOGGING) + execute_process(COMMAND clog --installDirectory ${CMAKE_SOURCE_DIR}/build/clog) + + set(CMAKE_CLOG_OUTPUT_DIRECTORY ${QUIC_BUILD_DIR}/inc) + set(CMAKE_CLOG_SIDECAR_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/manifest) + set(CLOG_INCLUDE_DIRECTORY ${CMAKE_SOURCE_DIR}/build/clog) + set(CMAKE_CLOG_GENERATE_FILE ${CMAKE_SOURCE_DIR}/build/clog/CLog.cmake) + set(CMAKE_CLOG_CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/manifest/msquic.clog_config) + include(${CMAKE_CLOG_GENERATE_FILE}) + + function(add_clog_library) + CLOG_GENERATE_TARGET(${ARGV}) + target_link_libraries(${ARGV0} PRIVATE inc) + set_property(TARGET ${ARGV0} PROPERTY FOLDER "clog") + endfunction() +else() + function(add_clog_library) + add_library(${ARGV0} INTERFACE) + endfunction() +endif() set(QUIC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/inc) set(MANIFESTED_HEADER_FILENAME ${QUIC_BUILD_DIR}/inc/MsQuicEtw.h) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 118a0af32..e6186b5e0 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -44,9 +44,7 @@ if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") endif() # Allow CLOG to preprocess all the source files. -CLOG_GENERATE_TARGET(core.clog STATIC ${SOURCES}) - -target_link_libraries(core.clog PRIVATE inc) +add_clog_library(core.clog STATIC ${SOURCES}) add_library(core STATIC ${SOURCES}) diff --git a/src/core/unittest/CMakeLists.txt b/src/core/unittest/CMakeLists.txt index 671dae20d..6a048b194 100644 --- a/src/core/unittest/CMakeLists.txt +++ b/src/core/unittest/CMakeLists.txt @@ -12,9 +12,7 @@ set(SOURCES ) # Allow CLOG to preprocess all the source files. -CLOG_GENERATE_TARGET(msquiccoretest.clog STATIC ${SOURCES}) - -target_link_libraries(msquiccoretest.clog PRIVATE inc) +add_clog_library(msquiccoretest.clog STATIC ${SOURCES}) add_executable(msquiccoretest ${SOURCES}) diff --git a/src/perf/bin/CMakeLists.txt b/src/perf/bin/CMakeLists.txt index 04875806e..d91d9385a 100644 --- a/src/perf/bin/CMakeLists.txt +++ b/src/perf/bin/CMakeLists.txt @@ -6,7 +6,7 @@ set(SOURCES ) # Allow CLOG to preprocess all the source files. -CLOG_GENERATE_TARGET(perfbin.clog STATIC ${SOURCES}) +add_clog_library(perfbin.clog STATIC ${SOURCES}) add_executable(quicperf ${SOURCES}) diff --git a/src/perf/lib/CMakeLists.txt b/src/perf/lib/CMakeLists.txt index c817baaf5..78f4bc402 100644 --- a/src/perf/lib/CMakeLists.txt +++ b/src/perf/lib/CMakeLists.txt @@ -8,7 +8,7 @@ set(SOURCES ) # Allow CLOG to preprocess all the source files. -CLOG_GENERATE_TARGET(perflib.clog STATIC ${SOURCES}) +add_clog_library(perflib.clog STATIC ${SOURCES}) add_library(perflib ${SOURCES}) diff --git a/src/platform/CMakeLists.txt b/src/platform/CMakeLists.txt index ba4d32205..b005bfaa1 100644 --- a/src/platform/CMakeLists.txt +++ b/src/platform/CMakeLists.txt @@ -48,9 +48,7 @@ else() endif() # Allow CLOG to preprocess all the source files. -CLOG_GENERATE_TARGET(platform.clog STATIC ${SOURCES}) - -target_link_libraries(platform.clog PRIVATE inc) +add_clog_library(platform.clog STATIC ${SOURCES}) add_library(platform STATIC ${SOURCES}) diff --git a/src/platform/datapath_winuser.c b/src/platform/datapath_winuser.c index a88e158b0..6dc2b3e16 100644 --- a/src/platform/datapath_winuser.c +++ b/src/platform/datapath_winuser.c @@ -2402,6 +2402,7 @@ QuicSendContextComplete( _In_ ULONG IoResult ) { + UNREFERENCED_PARAMETER(SocketContext); if (IoResult != QUIC_STATUS_SUCCESS) { QuicTraceEvent( DatapathErrorStatus, diff --git a/src/platform/platform_winuser.c b/src/platform/platform_winuser.c index a373b7d1e..60ac08a6b 100644 --- a/src/platform/platform_winuser.c +++ b/src/platform/platform_winuser.c @@ -340,6 +340,9 @@ QuicPlatformLogAssert( _In_z_ const char* Expr ) { + UNREFERENCED_PARAMETER(File); + UNREFERENCED_PARAMETER(Line); + UNREFERENCED_PARAMETER(Expr); QuicTraceEvent( LibraryAssert, "[ lib] ASSERT, %u:%s - %s.", diff --git a/src/platform/unittest/CMakeLists.txt b/src/platform/unittest/CMakeLists.txt index ce40c03f1..9ca0d93b5 100644 --- a/src/platform/unittest/CMakeLists.txt +++ b/src/platform/unittest/CMakeLists.txt @@ -10,9 +10,7 @@ set(SOURCES ) # Allow CLOG to preprocess all the source files. -CLOG_GENERATE_TARGET(msquicplatformtest.clog STATIC ${SOURCES}) - -target_link_libraries(msquicplatformtest.clog PRIVATE inc) +add_clog_library(msquicplatformtest.clog STATIC ${SOURCES}) add_executable(msquicplatformtest ${SOURCES}) diff --git a/src/test/bin/CMakeLists.txt b/src/test/bin/CMakeLists.txt index 8392405b8..5287f6db1 100644 --- a/src/test/bin/CMakeLists.txt +++ b/src/test/bin/CMakeLists.txt @@ -7,9 +7,7 @@ set(SOURCES ) # Allow CLOG to preprocess all the source files. -CLOG_GENERATE_TARGET(msquictest.clog STATIC ${SOURCES}) - -target_link_libraries(msquictest.clog PRIVATE inc) +add_clog_library(msquictest.clog STATIC ${SOURCES}) add_executable(msquictest ${SOURCES}) diff --git a/src/test/lib/CMakeLists.txt b/src/test/lib/CMakeLists.txt index 87f7d0c80..571814614 100644 --- a/src/test/lib/CMakeLists.txt +++ b/src/test/lib/CMakeLists.txt @@ -17,9 +17,7 @@ set(SOURCES ) # Allow CLOG to preprocess all the source files. -CLOG_GENERATE_TARGET(testlib.clog STATIC ${SOURCES}) - -target_link_libraries(testlib.clog PRIVATE inc) +add_clog_library(testlib.clog STATIC ${SOURCES}) add_library(testlib ${SOURCES})