• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// Copyright (C) 2014 The Android Open Source 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
17package {
18    default_applicable_licenses: ["external_libcxxabi_license"],
19}
20
21// Added automatically by a large-scale-change that took the approach of
22// 'apply every license found to every target'. While this makes sure we respect
23// every license restriction, it may not be entirely correct.
24//
25// e.g. GPL in an MIT project might only apply to the contrib/ directory.
26//
27// Please consider splitting the single license below into multiple licenses,
28// taking care not to lose any license_kind information, and overriding the
29// default license using the 'licenses: [...]' property on targets as needed.
30//
31// For unused files, consider creating a 'fileGroup' with "//visibility:private"
32// to attach the license to, and including a comment whether the files may be
33// used in the current project.
34//
35// large-scale-change included anything that looked like it might be a license
36// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
37//
38// Please consider removing redundant or irrelevant files from 'license_text:'.
39// See: http://go/android-license-faq
40license {
41    name: "external_libcxxabi_license",
42    visibility: [":__subpackages__"],
43    license_kinds: [
44        "SPDX-license-identifier-Apache-2.0",
45        "SPDX-license-identifier-BSD",
46        "SPDX-license-identifier-MIT",
47        "SPDX-license-identifier-NCSA",
48    ],
49    license_text: [
50        "LICENSE.TXT",
51        "NOTICE",
52    ],
53}
54
55cc_defaults {
56    name: "libc++abi_defaults",
57    vendor_available: true,
58    product_available: true,
59    ramdisk_available: true,
60    vendor_ramdisk_available: true,
61    recovery_available: true,
62    native_bridge_supported: true,
63    include_dirs: ["external/libcxx/include"],
64    local_include_dirs: ["include"],
65    export_include_dirs: ["include"],
66    cflags: [
67        "-Wall",
68        "-Werror",
69    ],
70    cppflags: [
71        "-std=c++14",
72        "-fexceptions",
73        "-Wextra",
74        "-Wno-unused-function",
75        "-Wno-implicit-fallthrough",
76        // src/cxa_demangle.cpp:2591 -Wimplicit-fallthrough
77    ],
78    sanitize: {
79        never: true,
80    },
81    stl: "none",
82    rtti: true,
83}
84
85cc_library_static {
86    name: "libc++demangle",
87    defaults: ["libc++abi_defaults"],
88    host_supported: false,
89    srcs: ["src/cxa_demangle.cpp"],
90    apex_available: [
91        "//apex_available:platform",
92        "//apex_available:anyapex",
93    ],
94    min_sdk_version: "apex_inherit",
95}
96
97cc_library_static {
98    name: "libc++abi",
99    defaults: ["libc++abi_defaults"],
100    host_supported: true,
101    srcs: [
102        "src/abort_message.cpp",
103        "src/cxa_aux_runtime.cpp",
104        "src/cxa_default_handlers.cpp",
105        "src/cxa_demangle.cpp",
106        "src/cxa_exception.cpp",
107        "src/cxa_exception_storage.cpp",
108        "src/cxa_guard.cpp",
109        "src/cxa_handlers.cpp",
110        "src/cxa_personality.cpp",
111        "src/cxa_thread_atexit.cpp",
112        "src/cxa_unexpected.cpp",
113        "src/cxa_vector.cpp",
114        "src/cxa_virtual.cpp",
115        "src/fallback_malloc.cpp",
116        "src/private_typeinfo.cpp",
117        "src/stdlib_exception.cpp",
118        "src/stdlib_new_delete.cpp",
119        "src/stdlib_stdexcept.cpp",
120        "src/stdlib_typeinfo.cpp",
121    ],
122    cppflags: ["-DLIBCXXABI_USE_LLVM_UNWINDER=1"],
123    target: {
124        android: {
125            cppflags: ["-DHAVE___CXA_THREAD_ATEXIT_IMPL"],
126            // Packaged in libc++demangle for Android to reduce bloat.
127            exclude_srcs: ["src/cxa_demangle.cpp"],
128        },
129        darwin: {
130            // libcxxabi really doesn't like the non-LLVM assembler on Darwin
131            asflags: ["-integrated-as"],
132            cflags: [
133                "-integrated-as",
134                "-D_LIBCPP_DISABLE_AVAILABILITY",
135            ],
136            cppflags: ["-integrated-as"],
137        },
138        linux_bionic: {
139            cppflags: ["-DHAVE___CXA_THREAD_ATEXIT_IMPL"],
140            enabled: true,
141        },
142        windows: {
143            enabled: true,
144            cppflags: [
145                "-D_LIBCPP_HAS_THREAD_API_WIN32",
146                "-D_LIBCXXABI_BUILDING_LIBRARY",
147                "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
148                "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
149            ],
150            exclude_srcs: [
151                "src/cxa_thread_atexit.cpp",
152
153                // Building stdlib_new_delete.cpp in libcxxabi causes
154                // multiple-definition errors against definitions in
155                // libcxx/src/new.cpp on Windows.  This works on Linux and
156                // Android where the functions have 'weak' linkage and are
157                // discarded by the linker.
158                "src/stdlib_new_delete.cpp",
159            ],
160        },
161    },
162    apex_available: [
163        "//apex_available:platform",
164        "//apex_available:anyapex",
165    ],
166    min_sdk_version: "apex_inherit",
167}
168
169cc_fuzz {
170    name: "cxa_demangle_fuzzer",
171    host_supported: true,
172    local_include_dirs: ["include"],
173
174    srcs: [
175        "fuzz/cxa_demangle_fuzzer.cpp",
176        "src/cxa_demangle.cpp",
177    ],
178}
179
180// Export libc++abi headers for inclusion in the musl sysroot.
181genrule {
182    name: "libc_musl_sysroot_libc++abi_headers",
183    visibility: ["//external/musl"],
184    srcs: [
185        "NOTICE",
186        "include/**/*",
187    ],
188    out: ["libc_musl_sysroot_libc++abi_headers.zip"],
189    tools: [
190        "soong_zip",
191        "zip2zip",
192    ],
193    cmd: "LIBCXXABI_DIR=$$(dirname $(location NOTICE)) && " +
194        "$(location soong_zip) -o $(genDir)/sysroot.zip -symlinks=false" +
195        // NOTICE
196        " -j -f $(location NOTICE) " +
197        // headers
198        " -P include/c++ " +
199        "  -C $${LIBCXXABI_DIR}/include " +
200        "  -D $${LIBCXXABI_DIR}/include " +
201        " && " +
202        "$(location zip2zip) -i $(genDir)/sysroot.zip -o $(out) " +
203        " include/**/*:include " +
204        " NOTICE:NOTICE.libc++abi",
205}
206