1// Copyright 2017 The Android Open Source Project
2
3cc_defaults {
4    name: "f2fs-tools-defaults",
5    cflags: [
6        "-DF2FS_MAJOR_VERSION=1",
7        "-DF2FS_MINOR_VERSION=13",
8        "-DF2FS_TOOLS_VERSION=\"1.13.0\"",
9        "-DF2FS_TOOLS_DATE=\"2019-09-24\"",
10        "-DWITH_ANDROID",
11        "-Wall",
12        "-Werror",
13        "-Wno-format",
14        "-Wno-macro-redefined",
15        "-Wno-missing-field-initializers",
16        "-Wno-pointer-arith",
17        "-Wno-sign-compare",
18        "-Wno-unused-function",
19        "-Wno-string-plus-int",
20    ],
21    local_include_dirs: [
22        "include",
23        "mkfs",
24        "fsck",
25    ],
26    include_dirs: [
27        "external/e2fsprogs/lib/",
28        "system/core/libsparse/include",
29    ],
30    target: {
31        windows: {
32            enabled: false,
33        },
34    },
35}
36
37cc_defaults {
38    name: "libf2fs_src_files",
39    cflags: ["-DWITH_BLKDISCARD"],
40    srcs: [
41        "lib/libf2fs.c",
42        "mkfs/f2fs_format.c",
43        "mkfs/f2fs_format_utils.c",
44        "lib/libf2fs_zoned.c",
45        "lib/nls_utf8.c",
46    ],
47}
48
49cc_defaults {
50    name: "make_f2fs_src_files",
51    srcs: [
52        "lib/libf2fs_io.c",
53        "mkfs/f2fs_format_main.c",
54    ],
55}
56
57cc_defaults {
58    name: "fsck_main_src_files",
59    srcs: [
60        "fsck/dir.c",
61        "fsck/dict.c",
62        "fsck/mkquota.c",
63        "fsck/quotaio.c",
64        "fsck/quotaio_tree.c",
65        "fsck/quotaio_v2.c",
66        "fsck/node.c",
67        "fsck/segment.c",
68        "fsck/xattr.c",
69        "fsck/main.c",
70        "fsck/mount.c",
71        "lib/libf2fs.c",
72        "lib/libf2fs_io.c",
73        "lib/nls_utf8.c",
74        "fsck/dump.c",
75    ],
76}
77
78cc_library_static {
79    name: "libf2fs_fmt",
80    recovery_available: true,
81    defaults: [
82        "f2fs-tools-defaults",
83        "libf2fs_src_files"
84    ],
85}
86
87cc_library_host_static {
88    name: "libf2fs_fmt_host",
89    defaults: [
90        "f2fs-tools-defaults",
91        "libf2fs_src_files"
92    ],
93    target: {
94        windows: {
95            include_dirs: [ "external/e2fsprogs/include/mingw" ],
96            cflags: [
97                "-DANDROID_WINDOWS_HOST",
98                "-Wno-typedef-redefinition",
99                "-Wno-unused-parameter",
100            ],
101            enabled: true
102        },
103    },
104}
105
106cc_binary {
107    name: "make_f2fs",
108    defaults: [
109        "f2fs-tools-defaults",
110        "make_f2fs_src_files",
111    ],
112    host_supported: true,
113    recovery_available: true,
114    target: {
115        android: {
116            static_libs: [
117                "libf2fs_fmt",
118            ],
119            shared_libs: [
120                "libext2_uuid",
121                "libsparse",
122                "libbase",
123            ],
124        },
125        host: {
126            static_libs: [
127                "libf2fs_fmt_host",
128                "libext2_uuid",
129                "libsparse",
130                "libbase",
131                "libz",
132            ],
133        },
134        windows: {
135            include_dirs: [ "external/e2fsprogs/include/mingw" ],
136            cflags: ["-DANDROID_WINDOWS_HOST"],
137            ldflags: ["-static"],
138            host_ldlibs: ["-lws2_32"],
139            enabled: true
140        },
141    },
142}
143
144cc_binary {
145    name: "fsck.f2fs",
146    defaults: [
147        "f2fs-tools-defaults",
148        "fsck_main_src_files",
149    ],
150    host_supported: true,
151    cflags: ["-DWITH_RESIZE", "-DWITH_DEFRAG", "-DWITH_DUMP"],
152    srcs: ["fsck/fsck.c", "fsck/resize.c", "fsck/defrag.c"],
153    shared_libs: [
154        "libext2_uuid",
155        "libsparse",
156        "libbase",
157    ],
158    symlinks: ["resize.f2fs", "defrag.f2fs", "dump.f2fs"],
159}
160
161cc_binary {
162    name: "sload_f2fs",
163    defaults: [
164        "f2fs-tools-defaults",
165        "fsck_main_src_files",
166    ],
167    host_supported: true,
168    recovery_available: true,
169    cflags: ["-DWITH_SLOAD"],
170    srcs: ["fsck/fsck.c", "fsck/sload.c"],
171    target: {
172        android: {
173            shared_libs: [
174                "libext2_uuid",
175                "libsparse",
176                "libbase",
177                "libcrypto",
178                "libselinux",
179                "libcutils",
180                "liblog",
181            ],
182        },
183        host: {
184            static_libs: [
185                "libext2_uuid",
186                "libsparse",
187                "libbase",
188                "libcrypto",
189                "libselinux",
190                "libcutils",
191                "liblog",
192                "libz",
193            ],
194        },
195    },
196    stl: "libc++_static",
197}
198
199cc_binary {
200    name: "check_f2fs",
201    host_supported: false,
202    cflags: [
203        "--static",
204        "-U_FORTIFY_SOURCE",
205    ],
206    srcs: ["tools/check_f2fs.c"],
207    product_specific: true,
208}
209
210cc_defaults {
211    name: "tools-defaults",
212    cflags: [
213        "-Wno-unused-function",
214    ],
215    local_include_dirs: [
216        "include",
217    ],
218    target: {
219        windows: {
220            enabled: false,
221        },
222        darwin: {
223            enabled: false,
224        },
225    },
226    product_specific: true,
227}
228
229cc_binary {
230    name: "f2fscrypt",
231    defaults: [
232        "tools-defaults",
233    ],
234    shared_libs: [
235        "libext2_uuid",
236    ],
237    srcs: [
238        "tools/f2fscrypt.c",
239        "tools/sha512.c",
240    ],
241}
242
243cc_binary {
244    name: "f2fsstat",
245    defaults: [
246        "tools-defaults",
247    ],
248    srcs: [
249        "tools/f2fstat.c",
250    ],
251}
252
253cc_binary {
254    name: "f2fs.fibmap",
255    defaults: [
256        "tools-defaults",
257    ],
258    srcs: [
259        "tools/fibmap.c",
260    ],
261}
262