xref: /aosp_15_r20/external/fmtlib/Android.bp (revision 5c90c05cd622c0a81b57953a4d343e0e489f2e08)
1package {
2    default_applicable_licenses: ["external_fmtlib_license"],
3}
4
5// Added automatically by a large-scale-change that took the approach of
6// 'apply every license found to every target'. While this makes sure we respect
7// every license restriction, it may not be entirely correct.
8//
9// e.g. GPL in an MIT project might only apply to the contrib/ directory.
10//
11// Please consider splitting the single license below into multiple licenses,
12// taking care not to lose any license_kind information, and overriding the
13// default license using the 'licenses: [...]' property on targets as needed.
14//
15// For unused files, consider creating a 'fileGroup' with "//visibility:private"
16// to attach the license to, and including a comment whether the files may be
17// used in the current project.
18//
19// large-scale-change included anything that looked like it might be a license
20// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
21//
22// Please consider removing redundant or irrelevant files from 'license_text:'.
23// See: http://go/android-license-faq
24license {
25    name: "external_fmtlib_license",
26    visibility: [":__subpackages__"],
27    license_kinds: [
28        "SPDX-license-identifier-BSD",
29        "SPDX-license-identifier-CC0-1.0",
30        "SPDX-license-identifier-MIT",
31        "SPDX-license-identifier-PSF-2.0",
32        "legacy_unencumbered",
33    ],
34    license_text: [
35        "LICENSE",
36        "NOTICE",
37    ],
38}
39
40cc_defaults {
41    name: "fmtlib-non-test-defaults",
42    cflags: [
43        "-fno-exceptions",
44        // If built without exceptions, libfmt uses assert.
45        // The tests *require* exceptions, so we can't win here.
46        // (This is also why we have two cc_defaults in this file.)
47        // Unless proven to be a bad idea, let's at least have some run-time
48        // checking.
49        "-UNDEBUG",
50    ],
51    srcs: ["src/format.cc"],
52    local_include_dirs: ["include"],
53    export_include_dirs: ["include"],
54    visibility: ["//system/libbase"],
55    min_sdk_version: "29",
56}
57
58cc_library_headers {
59    name: "fmtlib_headers",
60    export_include_dirs: ["include"],
61
62    vendor_available: true,
63    product_available: true,
64    ramdisk_available: true,
65    vendor_ramdisk_available: true,
66    recovery_available: true,
67    host_supported: true,
68    native_bridge_supported: true,
69    target: {
70        linux_bionic: {
71            enabled: true,
72        },
73        windows: {
74            enabled: true,
75        },
76    },
77    visibility: ["//system/libbase"],
78    min_sdk_version: "29",
79    sdk_version: "current",
80    apex_available: [
81        "//apex_available:anyapex",
82        "//apex_available:platform",
83    ],
84}
85
86// This is built into libbase.  If you want to use this library, link to libbase instead.
87cc_library_static {
88    name: "fmtlib",
89    defaults: ["fmtlib-non-test-defaults"],
90
91    vendor_available: true,
92    product_available: true,
93    ramdisk_available: true,
94    vendor_ramdisk_available: true,
95    recovery_available: true,
96    host_supported: true,
97    native_bridge_supported: true,
98    target: {
99        linux_bionic: {
100            enabled: true,
101        },
102        windows: {
103            enabled: true,
104        },
105    },
106    apex_available: [
107        "//apex_available:anyapex",
108        "//apex_available:platform",
109    ],
110    min_sdk_version: "29",
111}
112
113cc_library_static {
114    name: "fmtlib_ndk",
115    defaults: ["fmtlib-non-test-defaults"],
116    sdk_version: "current",
117    stl: "c++_static",
118    apex_available: [
119        "//apex_available:platform",
120        "com.android.mediaprovider",
121    ],
122}
123
124cc_defaults {
125    name: "fmtlib-test-defaults",
126    srcs: [
127        "src/format.cc",
128        "src/os.cc",
129        "test/gtest-extra.cc",
130        "test/util.cc",
131    ],
132    local_include_dirs: ["include"],
133    host_supported: true,
134    test_suites: ["general-tests"],
135    // The tests require exceptions and RTTI.
136    cflags: [
137        "-fexceptions",
138    ],
139    rtti: true,
140    // The usual "gtest *and* gmock, please" dance...
141    gtest: false,
142    include_dirs: [
143        "external/googletest/googlemock/include/gmock",
144        "external/googletest/googletest/include/gtest",
145    ],
146    static_libs: [
147        "libgmock",
148        "libgtest",
149        "libgtest_main",
150    ],
151}
152
153// Most of the fmtlib tests.
154cc_test {
155    name: "fmtlib_test_1",
156    defaults: ["fmtlib-test-defaults"],
157    srcs: [
158        "test/args-test.cc",
159        "test/base-test.cc",
160        "test/chrono-test.cc",
161        "test/color-test.cc",
162        "test/enforce-checks-test.cc",
163        "test/format-test.cc",
164        "test/noexception-test.cc",
165        // Some of the os-test tests deliberately try to do bad things with
166        // file descriptors, but Android's fdsan won't let them.
167        // "test/os-test.cc",
168        "test/ranges-odr-test.cc",
169        // Includes fmt/format-inl.h twice, causing duplicated symbols.
170        // "test/scan-test.cc",
171        // Depends on filesystem_error declarations which are not linked.
172        // "test/std-test.cc",
173        "test/unicode-test.cc",
174        "test/xchar-test.cc",
175    ],
176}
177
178// This one needs to be separate because some of the test names overlap with
179// other tests.
180cc_test {
181    name: "fmtlib_test_2",
182    defaults: ["fmtlib-test-defaults"],
183    srcs: [
184        "test/ostream-test.cc",
185        "test/printf-test.cc",
186    ],
187}
188
189cc_test {
190    name: "fmtlib_test_3",
191    defaults: ["fmtlib-test-defaults"],
192    srcs: [
193        "test/ranges-test.cc",
194    ],
195}
196