• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2018 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package {
16    default_applicable_licenses: ["external_catch2_license"],
17}
18
19// Added automatically by a large-scale-change that took the approach of
20// 'apply every license found to every target'. While this makes sure we respect
21// every license restriction, it may not be entirely correct.
22//
23// e.g. GPL in an MIT project might only apply to the contrib/ directory.
24//
25// Please consider splitting the single license below into multiple licenses,
26// taking care not to lose any license_kind information, and overriding the
27// default license using the 'licenses: [...]' property on targets as needed.
28//
29// For unused files, consider creating a 'fileGroup' with "//visibility:private"
30// to attach the license to, and including a comment whether the files may be
31// used in the current project.
32// See: http://go/android-license-faq
33license {
34    name: "external_catch2_license",
35    visibility: [":__subpackages__"],
36    license_kinds: [
37        "SPDX-license-identifier-BSD",
38        "SPDX-license-identifier-BSL-1.0",
39        "SPDX-license-identifier-GPL",
40        "SPDX-license-identifier-MIT",
41    ],
42    license_text: [
43        "LICENSE.txt",
44    ],
45}
46
47cc_defaults {
48    name: "libcatch2-defaults",
49    host_supported: true,
50    local_include_dirs: ["include"],  // cc_test ignores export_include_dirs
51    export_include_dirs: ["include"],
52    srcs: ["include/**/*.cpp"],
53    exclude_srcs: ["include/catch_with_main.cpp"],
54}
55
56// !!! IMPORTANT: Use 'whole_static_libs' or the linker will dead-code-eliminate
57// parts of the important code (the console and junit reporters).
58
59// Android users: libcatch2-main is what you want 99% of the time.
60// Using the pre-defined main speeds up compilation significantly.
61// If for some reason you want to provide your own `main`, use "libcatch2"
62// See also docs/configuration.md
63cc_library_static {
64    name: "libcatch2-main",
65    defaults: [
66        "libcatch2-defaults",
67    ],
68    srcs: [
69        "include/catch_with_main.cpp",
70    ],
71}
72
73// libcatch2 without the pre-defined main.
74// This is only useful if your program will define its own main.
75cc_library_static {
76    name: "libcatch2",
77    defaults: [
78        "libcatch2-defaults",
79    ],
80    cflags: ["-DCATCH_CONFIG_DISABLE_EXCEPTIONS"],
81}
82
83// This rule can be used by other external/ projects that depend on catch2
84// without turning off exceptions.
85cc_library_static {
86    name: "libcatch2-upstream",
87    defaults: [
88        "libcatch2-defaults",
89    ],
90    cflags: ["-fexceptions"],
91}
92
93// Configurations meant for validating upstream. Not intended to be used by anything else.
94
95cc_defaults {
96    name: "libcatch2-defaults-tests",
97    host_supported: true,
98    srcs: [
99        "projects/SelfTest/**/*.cpp",
100    ],
101    // This directory just re-includes existing tests 100x over.
102    // This is extremely slow to build, we don't lose coverage by excluding it.
103    exclude_srcs: [
104        "projects/SelfTest/CompileTimePerfTests/**/*.cpp",
105    ],
106    shared_libs: ["liblog"],
107}
108
109// Upstream config: Exceptions are enabled.
110// This should be validated first after an upstream merge.
111cc_test {
112    name: "libcatch2-tests-upstream",
113    defaults: [
114        "libcatch2-defaults-tests",
115    ],
116
117    gtest: false,
118    cflags: ["-fexceptions"],
119
120    whole_static_libs: [
121        "libcatch2-upstream",
122    ],
123}
124
125// Android config: Exceptions are disabled.
126// This should be validated second after an upstream merge.
127cc_test {
128    name: "libcatch2-tests",
129    defaults: [
130        "libcatch2-defaults-tests",
131    ],
132    cflags: [
133        "-DCATCH_CONFIG_DISABLE_EXCEPTIONS",
134        "-Wno-unused-function",
135    ],
136    gtest: false,
137    whole_static_libs: [
138        "libcatch2",
139    ],
140}
141