From 965afc4b2ea519f339e249392c54f544f77ed3f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Mon, 28 Dec 2020 11:21:04 +0100 Subject: [PATCH] Split CATCH_CONFIG_ANDROID_LOGWRITE into its own header Part of #2041 --- src/CMakeLists.txt | 1 + src/catch2/catch_all.hpp | 1 + .../internal/catch_compiler_capabilities.hpp | 5 --- .../catch_config_android_logwrite.hpp | 31 +++++++++++++++++++ src/catch2/internal/catch_debug_console.cpp | 2 +- 5 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 src/catch2/internal/catch_config_android_logwrite.hpp 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 #include #include +#include #include #include #include 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 -#include +#include #include #include #include