Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Split CATCH_CONFIG_ANDROID_LOGWRITE into its own header

Part of #2041
Commit
965afc4b2ea519f339e249392c54f544f77ed3f5
Author
Martin Hořeňovský ·
Parents
77643ce2e562

Files · Download .tar.gz

Changes

 src/CMakeLists.txt                                 |  1 +
 src/catch2/catch_all.hpp                           |  1 +
 .../internal/catch_compiler_capabilities.hpp       |  5 ----
 .../internal/catch_config_android_logwrite.hpp     | 31 ++++++++++++++++++++++
 src/catch2/internal/catch_debug_console.cpp        |  2 +-
 5 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 15fe1e7e..ab764872 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -51,6 +51,7 @@ set(INTERNAL_HEADERS
     ${SOURCES_DIR}/internal/catch_source_line_info.hpp
     ${SOURCES_DIR}/internal/catch_compiler_capabilities.hpp
     ${SOURCES_DIR}/catch_config.hpp
+    ${SOURCES_DIR}/internal/catch_config_android_logwrite.hpp
     ${SOURCES_DIR}/internal/catch_config_uncaught_exceptions.hpp
     ${SOURCES_DIR}/internal/catch_console_colour.hpp
     ${SOURCES_DIR}/internal/catch_context.hpp
diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp
index f6acd83b..770c7244 100644
--- a/src/catch2/catch_all.hpp
+++ b/src/catch2/catch_all.hpp
@@ -50,6 +50,7 @@
 #include <catch2/internal/catch_clara.hpp>
 #include <catch2/internal/catch_commandline.hpp>
 #include <catch2/internal/catch_compiler_capabilities.hpp>
+#include <catch2/internal/catch_config_android_logwrite.hpp>
 #include <catch2/internal/catch_config_uncaught_exceptions.hpp>
 #include <catch2/internal/catch_console_colour.hpp>
 #include <catch2/internal/catch_console_width.hpp>
diff --git a/src/catch2/internal/catch_compiler_capabilities.hpp b/src/catch2/internal/catch_compiler_capabilities.hpp
index a2b784f1..e8de815b 100644
--- a/src/catch2/internal/catch_compiler_capabilities.hpp
+++ b/src/catch2/internal/catch_compiler_capabilities.hpp
@@ -118,7 +118,6 @@
 // Android somehow still does not support std::to_string
 #if defined(__ANDROID__)
 #    define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING
-#    define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE
 #endif
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -320,10 +319,6 @@
 #  define CATCH_CONFIG_USE_ASYNC
 #endif
 
-#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE)
-#  define CATCH_CONFIG_ANDROID_LOGWRITE
-#endif
-
 #if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
 #  define CATCH_CONFIG_GLOBAL_NEXTAFTER
 #endif
diff --git a/src/catch2/internal/catch_config_android_logwrite.hpp b/src/catch2/internal/catch_config_android_logwrite.hpp
new file mode 100644
index 00000000..199c9375
--- /dev/null
+++ b/src/catch2/internal/catch_config_android_logwrite.hpp
@@ -0,0 +1,31 @@
+
+//              Copyright Catch2 Authors
+// Distributed under the Boost Software License, Version 1.0.
+//   (See accompanying file LICENSE_1_0.txt or copy at
+//        https://www.boost.org/LICENSE_1_0.txt)
+
+// SPDX-License-Identifier: BSL-1.0
+
+/** \file
+ * Wrapper for ANDROID_LOGWRITE configuration option
+ *
+ * We want to default to enabling it when compiled for android, but
+ * users of the library should also be able to disable it if they want
+ * to.
+ */
+
+#ifndef CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED
+#define CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED
+
+#if defined(__ANDROID__)
+#    define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE
+#endif
+
+
+#if defined( CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE ) && \
+    !defined( CATCH_CONFIG_NO_ANDROID_LOGWRITE ) &&      \
+    !defined( CATCH_CONFIG_ANDROID_LOGWRITE )
+#    define CATCH_CONFIG_ANDROID_LOGWRITE
+#endif
+
+#endif // CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED
diff --git a/src/catch2/internal/catch_debug_console.cpp b/src/catch2/internal/catch_debug_console.cpp
index da7f1686..5942524e 100644
--- a/src/catch2/internal/catch_debug_console.cpp
+++ b/src/catch2/internal/catch_debug_console.cpp
@@ -6,7 +6,7 @@
 
 // SPDX-License-Identifier: BSL-1.0
 #include <catch2/internal/catch_debug_console.hpp>
-#include <catch2/internal/catch_compiler_capabilities.hpp>
+#include <catch2/internal/catch_config_android_logwrite.hpp>
 #include <catch2/internal/catch_stream.hpp>
 #include <catch2/internal/catch_platform.hpp>
 #include <catch2/internal/catch_windows_h_proxy.hpp>