1//
2// Copyright (C) 2008-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: ["system_logging_liblog_license"],
19}
20
21// Added automatically by a large-scale-change
22license {
23    name: "system_logging_liblog_license",
24    visibility: [":__subpackages__"],
25    license_kinds: [
26        "SPDX-license-identifier-Apache-2.0",
27    ],
28    license_text: [
29        "NOTICE",
30    ],
31}
32
33liblog_sources = [
34    "log_event_list.cpp",
35    "log_event_write.cpp",
36    "logger_name.cpp",
37    "logger_read.cpp",
38    "logger_write.cpp",
39    "logprint.cpp",
40    "properties.cpp",
41]
42liblog_target_sources = [
43    "event_tag_map.cpp",
44    "log_time.cpp",
45    "pmsg_reader.cpp",
46    "pmsg_writer.cpp",
47    "logd_reader.cpp",
48    "logd_writer.cpp",
49]
50
51cc_library_headers {
52    name: "liblog_headers",
53    host_supported: true,
54    vendor_available: true,
55    product_available: true,
56    ramdisk_available: true,
57    vendor_ramdisk_available: true,
58    recovery_available: true,
59    apex_available: [
60        "//apex_available:platform",
61        "//apex_available:anyapex",
62    ],
63    min_sdk_version: "29",
64    sdk_version: "minimum",
65    native_bridge_supported: true,
66    export_include_dirs: ["include"],
67    system_shared_libs: [],
68    stl: "none",
69    target: {
70        windows: {
71            enabled: true,
72        },
73        linux_bionic: {
74            enabled: true,
75        },
76        vendor: {
77            override_export_include_dirs: ["include_vndk"],
78        },
79        product: {
80            override_export_include_dirs: ["include_vndk"],
81        },
82    },
83}
84
85// Shared and static library for host and device
86// ========================================================
87cc_library {
88    name: "liblog",
89    host_supported: true,
90    ramdisk_available: true,
91    vendor_ramdisk_available: true,
92    recovery_available: true,
93    native_bridge_supported: true,
94    llndk: {
95        symbol_file: "liblog.map.txt",
96        override_export_include_dirs: ["include_vndk"],
97    },
98    srcs: liblog_sources,
99
100    target: {
101        android: {
102            version_script: "liblog.map.txt",
103            srcs: liblog_target_sources,
104            // AddressSanitizer runtime library depends on liblog.
105            sanitize: {
106                address: false,
107            },
108        },
109        android_arm: {
110            // TODO: This is to work around b/24465209. Remove after root cause is fixed
111            pack_relocations: false,
112            ldflags: ["-Wl,--hash-style=both"],
113        },
114        windows: {
115            enabled: true,
116        },
117        not_windows: {
118            srcs: ["event_tag_map.cpp"],
119        },
120        linux_bionic: {
121            enabled: true,
122        },
123    },
124
125    header_libs: [
126        "libbase_headers",
127        "libcutils_headers",
128        "liblog_headers",
129    ],
130    export_header_lib_headers: ["liblog_headers"],
131
132    stubs: {
133        symbol_file: "liblog.map.txt",
134        versions: ["29", "30"],
135    },
136
137    cflags: [
138        "-Wall",
139        "-Werror",
140        "-Wextra",
141        "-Wexit-time-destructors",
142        // This is what we want to do:
143        //  liblog_cflags := $(shell \
144        //   sed -n \
145        //       's/^\([0-9]*\)[ \t]*liblog[ \t].*/-DLIBLOG_LOG_TAG=\1/p' \
146        //       $(LOCAL_PATH)/event.logtags)
147        // so make sure we do not regret hard-coding it as follows:
148        "-DLIBLOG_LOG_TAG=1006",
149        "-DSNET_EVENT_LOG_TAG=1397638484",
150    ],
151    logtags: ["event.logtags"],
152    compile_multilib: "both",
153    apex_available: [
154        "//apex_available:platform",
155        // liblog is exceptionally available to the runtime APEX
156        // because the dynamic linker has to use it statically.
157        // See b/151051671
158        "com.android.runtime",
159        // DO NOT add more apex names here
160    ],
161    pgo: {
162        sampling: true,
163        profile_file: "logging/liblog.profdata",
164    },
165}
166
167ndk_headers {
168    name: "liblog_ndk_headers",
169    from: "include/android",
170    to: "android",
171    srcs: ["include/android/log.h"],
172    license: "NOTICE",
173}
174
175ndk_library {
176    name: "liblog",
177    symbol_file: "liblog.map.txt",
178    first_version: "9",
179    unversioned_until: "current",
180}
181
182rust_bindgen {
183    name: "liblog_event_list_bindgen",
184    wrapper_src: "rust/liblog_wrapper.h",
185    crate_name: "log_event_list_bindgen",
186    source_stem: "bindings",
187
188    bindgen_flags: [
189        "--size_t-is-usize",
190        "--allowlist-function=create_android_logger",
191        "--allowlist-function=android_log_destroy",
192        "--allowlist-function=android_log_write_int32",
193        "--allowlist-function=android_log_write_string8_len",
194        "--allowlist-function=android_log_write_list",
195        "--allowlist-function=__android_log_security",
196        "--allowlist-type=log_id",
197    ],
198}
199