|
| 1 | +#=============================================================================== |
| 2 | +# Copyright contributors to the oneDAL project |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +#=============================================================================== |
| 16 | + |
| 17 | +# This BUILD.bazel file is based on the original from the Catch2 project. |
| 18 | +# Catch2 is licensed under the Boost Software License 1.0 (BSL-1.0). |
| 19 | +# |
| 20 | +# Original source: https://github.com/catchorg/Catch2 |
| 21 | +# License text: see LICENSE.MIT in this repository |
| 22 | +# |
| 23 | +# Modifications for oneDAL: |
| 24 | +# - Adjusted substitutions specific for oneDAL (e.g. enabled CATCH_CONFIG_NO_POSIX_SIGNALS) |
| 25 | +# - Added comments related to enabling/disabling macros |
| 26 | +# - Removed `license()` rule and `package()` directive to avoid dependency on `rules_license` |
| 27 | +# |
| 28 | +# SPDX-License-Identifier: BSL-1.0 |
| 29 | + |
| 30 | +load("@bazel_skylib//rules:expand_template.bzl", "expand_template") |
| 31 | + |
| 32 | +# oneDAL verison of catch2 bazel build file |
| 33 | +expand_template( |
| 34 | + name = "catch_user_config", |
| 35 | + out = "catch2/catch_user_config.hpp", |
| 36 | + substitutions = { |
| 37 | + "@CATCH_CONFIG_CONSOLE_WIDTH@": "80", |
| 38 | + "@CATCH_CONFIG_DEFAULT_REPORTER@": "console", |
| 39 | + "#cmakedefine CATCH_CONFIG_ANDROID_LOGWRITE": "", |
| 40 | + "#cmakedefine CATCH_CONFIG_BAZEL_SUPPORT": "#define CATCH_CONFIG_BAZEL_SUPPORT", |
| 41 | + "#cmakedefine CATCH_CONFIG_COLOUR_WIN32": "", |
| 42 | + "#cmakedefine CATCH_CONFIG_COUNTER": "", |
| 43 | + "#cmakedefine CATCH_CONFIG_CPP11_TO_STRING": "", |
| 44 | + "#cmakedefine CATCH_CONFIG_CPP17_BYTE": "", |
| 45 | + "#cmakedefine CATCH_CONFIG_CPP17_OPTIONAL": "", |
| 46 | + "#cmakedefine CATCH_CONFIG_CPP17_STRING_VIEW": "", |
| 47 | + "#cmakedefine CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS": "", |
| 48 | + "#cmakedefine CATCH_CONFIG_CPP17_VARIANT": "", |
| 49 | + "#cmakedefine CATCH_CONFIG_DEPRECATION_ANNOTATIONS": "", |
| 50 | + "#cmakedefine CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER": "", |
| 51 | +# Disables unexpected exceptions handing in Catch2. |
| 52 | +# It is easier to debug exception via GDB if there is handler. |
| 53 | + "#cmakedefine CATCH_CONFIG_DISABLE_EXCEPTIONS": "#define CATCH_CONFIG_DISABLE_EXCEPTIONS", |
| 54 | + "#cmakedefine CATCH_CONFIG_DISABLE_STRINGIFICATION": "", |
| 55 | + "#cmakedefine CATCH_CONFIG_DISABLE": "", |
| 56 | + "#cmakedefine CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS": "", |
| 57 | + "#cmakedefine CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER": "", |
| 58 | + "#cmakedefine CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER": "", |
| 59 | + "#cmakedefine CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER": "", |
| 60 | + "#cmakedefine CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER": "", |
| 61 | + "#cmakedefine CATCH_CONFIG_EXPERIMENTAL_REDIRECT": "", |
| 62 | + "#cmakedefine CATCH_CONFIG_FALLBACK_STRINGIFIER @CATCH_CONFIG_FALLBACK_STRINGIFIER@": "", |
| 63 | + "#cmakedefine CATCH_CONFIG_FAST_COMPILE": "", |
| 64 | + "#cmakedefine CATCH_CONFIG_GETENV": "", |
| 65 | + "#cmakedefine CATCH_CONFIG_GLOBAL_NEXTAFTER": "", |
| 66 | + "#cmakedefine CATCH_CONFIG_NO_ANDROID_LOGWRITE": "", |
| 67 | + "#cmakedefine CATCH_CONFIG_NO_COLOUR_WIN32": "", |
| 68 | + "#cmakedefine CATCH_CONFIG_NO_COUNTER": "", |
| 69 | + "#cmakedefine CATCH_CONFIG_NO_CPP11_TO_STRING": "", |
| 70 | + "#cmakedefine CATCH_CONFIG_NO_CPP17_BYTE": "", |
| 71 | + "#cmakedefine CATCH_CONFIG_NO_CPP17_OPTIONAL": "", |
| 72 | + "#cmakedefine CATCH_CONFIG_NO_CPP17_STRING_VIEW": "", |
| 73 | + "#cmakedefine CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS": "", |
| 74 | + "#cmakedefine CATCH_CONFIG_NO_CPP17_VARIANT": "", |
| 75 | + "#cmakedefine CATCH_CONFIG_NO_DEPRECATION_ANNOTATIONS": "", |
| 76 | + "#cmakedefine CATCH_CONFIG_NO_GETENV": "", |
| 77 | + "#cmakedefine CATCH_CONFIG_NO_GLOBAL_NEXTAFTER": "", |
| 78 | +# CATCH_CONFIG_POSIX_SIGNAL enables handling of POSIX signals. |
| 79 | +# For unknown reason user-defined handlers for signals |
| 80 | +# (see https://en.wikipedia.org/wiki/C_signal_handling) |
| 81 | +# catches SIGSEGV signal when USM pointer is accessed on host. |
| 82 | +# To make USM work, we disable signal handling in Catch2. |
| 83 | + "#cmakedefine CATCH_CONFIG_NO_POSIX_SIGNALS": "#define CATCH_CONFIG_NO_POSIX_SIGNALS", |
| 84 | + "#cmakedefine CATCH_CONFIG_NO_USE_ASYNC": "", |
| 85 | + "#cmakedefine CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT": "", |
| 86 | + "#cmakedefine CATCH_CONFIG_NO_WCHAR": "", |
| 87 | + "#cmakedefine CATCH_CONFIG_NO_WINDOWS_SEH": "", |
| 88 | + "#cmakedefine CATCH_CONFIG_NOSTDOUT": "", |
| 89 | + "#cmakedefine CATCH_CONFIG_POSIX_SIGNALS": "", |
| 90 | + "#cmakedefine CATCH_CONFIG_PREFIX_ALL": "", |
| 91 | + "#cmakedefine CATCH_CONFIG_PREFIX_MESSAGES": "", |
| 92 | + "#cmakedefine CATCH_CONFIG_SHARED_LIBRARY": "", |
| 93 | + "#cmakedefine CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT": "", |
| 94 | + "#cmakedefine CATCH_CONFIG_USE_ASYNC": "", |
| 95 | + "#cmakedefine CATCH_CONFIG_WCHAR": "", |
| 96 | + "#cmakedefine CATCH_CONFIG_WINDOWS_CRTDBG": "", |
| 97 | + "#cmakedefine CATCH_CONFIG_WINDOWS_SEH": "", |
| 98 | + "#cmakedefine CATCH_CONFIG_USE_BUILTIN_CONSTANT_P": "", |
| 99 | + "#cmakedefine CATCH_CONFIG_NO_USE_BUILTIN_CONSTANT_P": "", |
| 100 | + "#cmakedefine CATCH_CONFIG_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS": "", |
| 101 | + "#cmakedefine CATCH_CONFIG_NO_EXPERIMENTAL_THREAD_SAFE_ASSERTIONS": "", |
| 102 | + }, |
| 103 | + template = "src/catch2/catch_user_config.hpp.in", |
| 104 | +) |
| 105 | + |
| 106 | +# Generated header library, modifies the include prefix to account for |
| 107 | +# generation path so that we can include <catch2/catch_user_config.hpp> |
| 108 | +# correctly. |
| 109 | +cc_library( |
| 110 | + name = "catch2_generated", |
| 111 | + hdrs = ["catch2/catch_user_config.hpp"], |
| 112 | + include_prefix = ".", # to manipulate -I of dependencies |
| 113 | + visibility = ["//visibility:public"], |
| 114 | +) |
| 115 | + |
| 116 | +# Static library, without main. |
| 117 | +cc_library( |
| 118 | + name = "catch2", |
| 119 | + srcs = glob( |
| 120 | + ["src/catch2/**/*.cpp"], |
| 121 | + exclude = ["src/catch2/internal/catch_main.cpp"], |
| 122 | + ), |
| 123 | + hdrs = glob(["src/catch2/**/*.hpp"]), |
| 124 | + includes = ["src/"], |
| 125 | + linkstatic = True, |
| 126 | + visibility = ["//visibility:public"], |
| 127 | + deps = [":catch2_generated"], |
| 128 | +) |
| 129 | + |
| 130 | +# Static library, with main. |
| 131 | +cc_library( |
| 132 | + name = "catch2_main", |
| 133 | + srcs = ["src/catch2/internal/catch_main.cpp"], |
| 134 | + includes = ["src/"], |
| 135 | + linkstatic = True, |
| 136 | + visibility = ["//visibility:public"], |
| 137 | + deps = [":catch2"], |
| 138 | +) |
0 commit comments