1// Copyright (C) 2020 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_team: "trendy_team_android_resources",
17    default_applicable_licenses: ["system_incremental_delivery_incfs_license"],
18}
19
20// Added automatically by a large-scale-change that took the approach of
21// 'apply every license found to every target'. While this makes sure we respect
22// every license restriction, it may not be entirely correct.
23//
24// e.g. GPL in an MIT project might only apply to the contrib/ directory.
25//
26// Please consider splitting the single license below into multiple licenses,
27// taking care not to lose any license_kind information, and overriding the
28// default license using the 'licenses: [...]' property on targets as needed.
29//
30// For unused files, consider creating a 'fileGroup' with "//visibility:private"
31// to attach the license to, and including a comment whether the files may be
32// used in the current project.
33// See: http://go/android-license-faq
34license {
35    name: "system_incremental_delivery_incfs_license",
36    visibility: [":__subpackages__"],
37    license_kinds: [
38        "SPDX-license-identifier-Apache-2.0",
39    ],
40    license_text: [
41        "NOTICE",
42    ],
43}
44
45cc_defaults {
46    name: "libincfs_defaults_common",
47    cpp_std: "c++2a",
48    cflags: [
49        "-Werror",
50        "-Wall",
51        "-Wextra",
52        "-Wno-deprecated-enum-enum-conversion",
53        "-D_FILE_OFFSET_BITS=64",
54    ],
55    tidy: true,
56    tidy_checks: [
57        "android-*",
58        "cert-*",
59        "clang-analyzer-security*",
60        "-cert-err34-c",
61        "clang-analyzer-security*",
62        // Disabling due to many unavoidable warnings from POSIX API usage.
63        "-google-runtime-int",
64        "-google-explicit-constructor",
65        // operator=() does not handle self-assignment properly - all protobuf-generated classes
66        "-cert-oop54-cpp",
67    ],
68    target: {
69        linux_bionic: {
70            enabled: true,
71        },
72    },
73}
74
75cc_defaults {
76    name: "libincfs_defaults",
77    defaults: [
78        "libincfs_defaults_common",
79        "linux_bionic_supported",
80    ],
81    header_libs: ["libincfs_headers"],
82    export_header_lib_headers: ["libincfs_headers"],
83    static_libs: [
84        "libbase",
85    ],
86    shared_libs: [
87        "libcrypto",
88        "liblog",
89        "libselinux",
90    ],
91    target: {
92        android: {
93            static_libs: [
94                "libcom.android.sysprop.incremental",
95            ],
96        },
97    },
98}
99
100cc_library {
101    name: "libincfs",
102    defaults: ["libincfs_defaults"],
103    srcs: [
104        "incfs_ndk.c",
105        "incfs.cpp",
106        "MountRegistry.cpp",
107        "path.cpp",
108    ],
109}
110
111cc_library_static {
112    name: "libincfs-utils",
113    defaults: ["libincfs_defaults_common"],
114    local_include_dirs: ["util/include"],
115    export_include_dirs: ["util/include"],
116    host_supported: true,
117    srcs: [
118        "util/map_ptr.cpp",
119    ],
120    target: {
121        android: {
122            header_libs: ["libincfs_headers"],
123            shared_libs: [
124                "libbase",
125                "libincfs",
126                "libutils",
127            ],
128        },
129        host: {
130            static_libs: [
131                "libbase",
132                "libutils",
133            ],
134        },
135        windows: {
136            enabled: true,
137        },
138    },
139}
140
141cc_library_headers {
142    name: "libincfs_headers",
143    export_include_dirs: [
144        "include/",
145        "kernel-headers",
146    ],
147    host_supported: true,
148    target: {
149        linux_bionic: {
150            enabled: true,
151        },
152    },
153}
154
155cc_test {
156    name: "libincfs-test",
157    defaults: ["libincfs_defaults"],
158    local_include_dirs: ["tests/include"],
159    static_libs: [
160        "libincfs",
161        "libincfs-utils",
162    ],
163    shared_libs: [
164        "libbase",
165        "libutils",
166    ],
167    srcs: [
168        "tests/util/map_ptr_test.cpp",
169        "tests/incfs_test.cpp",
170        "tests/MountRegistry_test.cpp",
171    ],
172    require_root: true,
173    test_suites: [
174        "general-tests",
175        "device-tests",
176    ],
177}
178
179cc_benchmark {
180    name: "hardening-benchmark",
181    defaults: ["libincfs_defaults"],
182
183    srcs: [
184        "tests/hardening_benchmark.cpp",
185    ],
186    static_libs: [
187        "libziparchive_for_incfs",
188        "libutils",
189        "libincfs",
190        "libincfs-utils",
191    ],
192}
193
194cc_binary {
195    name: "incfsdump",
196    defaults: ["libincfs_defaults"],
197    host_supported: true,
198    static_libs: [
199        "libbase",
200    ],
201    srcs: [
202        "incfsdump/main.cpp",
203        "incfsdump/dump.cpp",
204    ],
205    target: {
206        linux_glibc: {
207            enabled: true,
208        },
209    },
210}
211