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_applicable_licenses: ["system_incremental_delivery_incfs_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: "system_incremental_delivery_incfs_license",
35    visibility: [":__subpackages__"],
36    license_kinds: [
37        "SPDX-license-identifier-Apache-2.0",
38        "SPDX-license-identifier-GPL-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: ["-Werror", "-Wall", "-Wextra"],
49    tidy: true,
50    tidy_checks: [
51        "android-*",
52        "cert-*",
53        "clang-analyzer-security*",
54        "-cert-err34-c",
55        "clang-analyzer-security*",
56        // Disabling due to many unavoidable warnings from POSIX API usage.
57        "-google-runtime-int",
58        "-google-explicit-constructor",
59        // operator=() does not handle self-assignment properly - all protobuf-generated classes
60        "-cert-oop54-cpp",
61    ],
62    target: {
63        linux_bionic: {
64            enabled: true,
65        },
66    },
67}
68
69cc_defaults {
70    name: "libincfs_defaults",
71    defaults: [
72        "libincfs_defaults_common",
73        "linux_bionic_supported",
74    ],
75    header_libs: ["libincfs_headers"],
76    export_header_lib_headers: ["libincfs_headers"],
77    static_libs: [
78        "libbase",
79    ],
80    shared_libs: [
81        "libcrypto",
82        "liblog",
83        "libselinux",
84    ],
85    target: {
86        android: {
87            static_libs: [
88                "com.android.sysprop.incremental",
89            ],
90        },
91    },
92}
93
94cc_library {
95    name: "libincfs",
96    defaults: ["libincfs_defaults"],
97    srcs: [
98        "incfs_ndk.c",
99        "incfs.cpp",
100        "MountRegistry.cpp",
101        "path.cpp",
102    ],
103}
104
105cc_library_static {
106    name: "libincfs-utils",
107    defaults: ["libincfs_defaults_common"],
108    local_include_dirs: ["util/include"],
109    export_include_dirs: ["util/include"],
110    host_supported: true,
111    srcs: [
112        "util/map_ptr.cpp",
113    ],
114    target: {
115        android: {
116            header_libs: ["libincfs_headers"],
117            shared_libs: [
118                "libbase",
119                "libincfs",
120                "libutils",
121            ],
122        },
123        host: {
124            static_libs: [
125                "libbase",
126                "libutils",
127            ],
128        },
129        windows: {
130            enabled: true,
131        },
132    },
133}
134
135cc_library_headers {
136    name: "libincfs_headers",
137    export_include_dirs: ["include/", "kernel-headers",],
138    host_supported: true,
139    target: {
140        linux_bionic: {
141            enabled: true,
142        }
143    }
144}
145
146cc_test {
147    name: "libincfs-test",
148    defaults: ["libincfs_defaults"],
149    local_include_dirs: ["tests/include"],
150    static_libs: [
151        "libincfs",
152        "libincfs-utils",
153    ],
154    shared_libs: [
155        "libbase",
156        "libutils",
157    ],
158    srcs: [
159        "tests/util/map_ptr_test.cpp",
160        "tests/incfs_test.cpp",
161        "tests/MountRegistry_test.cpp",
162    ],
163    require_root: true,
164}
165
166cc_benchmark {
167    name: "hardening-benchmark",
168    defaults: ["libincfs_defaults"],
169
170    srcs: [
171        "tests/hardening_benchmark.cpp",
172    ],
173    static_libs: [
174        "libziparchive_for_incfs",
175        "libutils",
176        "libincfs",
177        "libincfs-utils",
178    ],
179}
180
181cc_binary {
182    name: "incfsdump",
183    defaults: ["libincfs_defaults"],
184    host_supported: true,
185    static_libs: [
186        "libbase",
187    ],
188    srcs: [
189        "incfsdump/main.cpp",
190        "incfsdump/dump.cpp",
191    ],
192}
193