xref: /aosp_15_r20/external/erofs-utils/Android.bp (revision 33b1fccf6a0fada2c2875d400ed01119b7676ee5)
1//
2// Copyright (C) 2020 Gao Xiang
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
16package {
17    default_applicable_licenses: ["external_erofs-utils_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: "external_erofs-utils_license",
36    visibility: [":__subpackages__"],
37    license_kinds: [
38        "SPDX-license-identifier-GPL",
39        "SPDX-license-identifier-GPL-2.0",
40        "SPDX-license-identifier-LGPL",
41    ],
42    license_text: [
43        "COPYING",
44    ],
45}
46
47genrule {
48    name: "erofs-utils-version.h",
49    srcs: ["VERSION"],
50    out: ["erofs-utils-version.h"],
51    cmd: "sed -n '1p' $(in) | tr -d '\n' | sed 's/\\(.*\\)/#define PACKAGE_VERSION \"\\1\"/' > $(out)",
52}
53
54cc_defaults {
55    name: "erofs-utils_export_defaults",
56
57    cflags: [
58        "-Wall",
59        "-Werror",
60        "-Wno-error=#warnings",
61        "-Wno-ignored-qualifiers",
62        "-Wno-pointer-arith",
63        "-Wno-unused-parameter",
64        "-Wno-unused-function",
65        "-DHAVE_FALLOCATE",
66        "-DHAVE_LINUX_TYPES_H",
67        "-DHAVE_LIBSELINUX",
68        "-DHAVE_LIBUUID",
69        "-DLZ4_ENABLED",
70        "-DLZ4HC_ENABLED",
71        "-DWITH_ANDROID",
72        "-DHAVE_MEMRCHR",
73        "-DHAVE_SYS_IOCTL_H",
74        "-DHAVE_LLISTXATTR",
75        "-DHAVE_LGETXATTR",
76        "-D_FILE_OFFSET_BITS=64",
77        "-DEROFS_MAX_BLOCK_SIZE=16384",
78        "-DHAVE_UTIMENSAT",
79    ],
80}
81
82cc_defaults {
83    name: "erofs-utils_defaults",
84    defaults: ["erofs-utils_export_defaults"],
85
86    cflags: [
87        "-include erofs-utils-version.h",
88    ],
89    local_include_dirs: [
90        "include",
91    ],
92    include_dirs: [
93        "external/e2fsprogs/lib/",
94    ],
95    generated_headers: ["erofs-utils-version.h"],
96    target: {
97        android: {
98            shared_libs: [
99                "libbase",
100                "libcutils",
101                "libext2_uuid",
102                "liblog",
103                "liblz4",
104                "libselinux",
105            ],
106        },
107        host: {
108            static_libs: [
109                "libbase",
110                "libcutils",
111                "libext2_uuid",
112                "liblog",
113                "liblz4",
114                "libselinux",
115            ],
116        },
117    },
118}
119
120cc_library {
121    host_supported: true,
122    recovery_available: true,
123    name: "liberofs",
124    defaults: ["erofs-utils_defaults"],
125    srcs: [
126        "lib/*.c",
127    ],
128    exclude_srcs: [
129        "lib/compressor_libdeflate.c",
130        "lib/compressor_libzstd.c",
131        "lib/workqueue.c",
132    ],
133    export_include_dirs: ["include"],
134
135    target: {
136        darwin: {
137            enabled: false,
138        },
139    },
140}
141
142cc_defaults {
143    name: "mkfs-erofs_defaults",
144
145    defaults: ["erofs-utils_defaults"],
146
147    srcs: [
148        "mkfs/*.c",
149    ],
150    static_libs: [
151        "liberofs",
152    ],
153
154    target: {
155        darwin: {
156            enabled: false,
157        },
158    },
159}
160
161cc_binary {
162    name: "mkfs.erofs",
163
164    defaults: ["mkfs-erofs_defaults"],
165    host_supported: true,
166}
167
168cc_binary {
169    name: "mkfs.erofs.recovery",
170    defaults: ["mkfs-erofs_defaults"],
171    recovery: true,
172    stem: "mkfs.erofs",
173}
174
175cc_binary_host {
176    name: "make_erofs",
177
178    defaults: ["mkfs-erofs_defaults"],
179    stl: "libc++_static"
180}
181
182cc_defaults {
183    name: "dump.erofs_defaults",
184    defaults: ["erofs-utils_defaults"],
185    srcs: [
186        "dump/*.c",
187    ],
188    static_libs: [
189        "liberofs",
190    ],
191}
192
193cc_binary {
194    name: "dump.erofs",
195    defaults: ["dump.erofs_defaults"],
196    host_supported: true,
197    target: {
198        darwin: {
199            enabled: false,
200        },
201    },
202}
203
204cc_binary {
205    name: "dump.erofs.recovery",
206    defaults: ["dump.erofs_defaults"],
207    recovery: true,
208    stem: "dump.erofs",
209}
210
211cc_defaults {
212    name: "fsck.erofs_defaults",
213    defaults: ["erofs-utils_defaults"],
214    srcs: [
215        "fsck/*.c",
216    ],
217    static_libs: [
218        "liberofs",
219    ],
220}
221
222cc_binary {
223    name: "fsck.erofs",
224    defaults: ["fsck.erofs_defaults"],
225    host_supported: true,
226    target: {
227        darwin: {
228            enabled: false,
229        },
230    },
231}
232
233cc_binary {
234    name: "fsck.erofs.recovery",
235    defaults: ["fsck.erofs_defaults"],
236    recovery: true,
237    stem: "fsck.erofs",
238}