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=11",
8        "-DF2FS_TOOLS_VERSION=\"1.12.0\"",
9        "-DF2FS_TOOLS_DATE=\"2018-11-12\"",
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    ],
46}
47
48cc_defaults {
49    name: "make_f2fs_src_files",
50    srcs: [
51        "lib/libf2fs_io.c",
52        "mkfs/f2fs_format_main.c",
53    ],
54}
55
56cc_defaults {
57    name: "fsck_main_src_files",
58    srcs: [
59        "fsck/dir.c",
60        "fsck/dict.c",
61        "fsck/mkquota.c",
62        "fsck/quotaio.c",
63        "fsck/quotaio_tree.c",
64        "fsck/quotaio_v2.c",
65        "fsck/node.c",
66        "fsck/segment.c",
67        "fsck/xattr.c",
68        "fsck/main.c",
69        "fsck/mount.c",
70        "lib/libf2fs.c",
71        "lib/libf2fs_io.c",
72    ],
73}
74
75cc_library_static {
76    name: "libf2fs_fmt",
77    recovery_available: true,
78    defaults: [
79        "f2fs-tools-defaults",
80        "libf2fs_src_files"
81    ],
82}
83
84cc_library_host_static {
85    name: "libf2fs_fmt_host",
86    defaults: [
87        "f2fs-tools-defaults",
88        "libf2fs_src_files"
89    ],
90    target: {
91        windows: {
92            include_dirs: [ "external/e2fsprogs/include/mingw" ],
93            cflags: [
94                "-DANDROID_WINDOWS_HOST",
95                "-Wno-typedef-redefinition",
96                "-Wno-unused-parameter",
97            ],
98            enabled: true
99        },
100    },
101}
102
103cc_binary {
104    name: "make_f2fs",
105    defaults: [
106        "f2fs-tools-defaults",
107        "make_f2fs_src_files",
108    ],
109    host_supported: true,
110    recovery_available: true,
111    target: {
112        android: {
113            static_libs: [
114                "libf2fs_fmt",
115            ],
116            shared_libs: [
117                "libext2_uuid",
118                "libsparse",
119                "libbase",
120            ],
121        },
122        host: {
123            static_libs: [
124                "libf2fs_fmt_host",
125                "libext2_uuid",
126                "libsparse",
127                "libbase",
128                "libz",
129            ],
130        },
131        windows: {
132            include_dirs: [ "external/e2fsprogs/include/mingw" ],
133            cflags: ["-DANDROID_WINDOWS_HOST"],
134            ldflags: ["-static"],
135            host_ldlibs: ["-lws2_32"],
136            enabled: true
137        },
138    },
139}
140
141cc_binary {
142    name: "fsck.f2fs",
143    defaults: [
144        "f2fs-tools-defaults",
145        "fsck_main_src_files",
146    ],
147    host_supported: true,
148    cflags: ["-DWITH_RESIZE", "-DWITH_DEFRAG"],
149    srcs: ["fsck/fsck.c", "fsck/resize.c", "fsck/defrag.c"],
150    shared_libs: [
151        "libext2_uuid",
152        "libsparse",
153        "libbase",
154    ],
155    symlinks: ["resize.f2fs", "defrag.f2fs"],
156}
157
158cc_binary {
159    name: "sload_f2fs",
160    defaults: [
161        "f2fs-tools-defaults",
162        "fsck_main_src_files",
163    ],
164    host_supported: true,
165    recovery_available: true,
166    cflags: ["-DWITH_SLOAD"],
167    srcs: ["fsck/fsck.c", "fsck/sload.c"],
168    target: {
169        android: {
170            shared_libs: [
171                "libext2_uuid",
172                "libsparse",
173                "libbase",
174                "libcrypto",
175                "libselinux",
176                "libcutils",
177                "liblog",
178            ],
179        },
180        host: {
181            static_libs: [
182                "libext2_uuid",
183                "libsparse",
184                "libbase",
185                "libcrypto",
186                "libselinux",
187                "libcutils",
188                "liblog",
189                "libz",
190            ],
191        },
192    },
193    stl: "libc++_static",
194}
195
196cc_binary {
197    name: "check_f2fs",
198    host_supported: false,
199    cflags: ["--static"],
200    srcs: ["tools/check_f2fs.c"],
201    product_specific: true,
202}
203
204cc_defaults {
205    name: "tools-defaults",
206    cflags: [
207        "-Wno-unused-function",
208    ],
209    local_include_dirs: [
210        "include",
211    ],
212    target: {
213        windows: {
214            enabled: false,
215        },
216        darwin: {
217            enabled: false,
218        },
219    },
220    product_specific: true,
221}
222
223cc_binary {
224    name: "f2fscrypt",
225    defaults: [
226        "tools-defaults",
227    ],
228    shared_libs: [
229        "libext2_uuid",
230    ],
231    srcs: [
232        "tools/f2fscrypt.c",
233        "tools/sha512.c",
234    ],
235}
236
237cc_binary {
238    name: "f2fsstat",
239    defaults: [
240        "tools-defaults",
241    ],
242    srcs: [
243        "tools/f2fstat.c",
244    ],
245}
246
247cc_binary {
248    name: "f2fs.fibmap",
249    defaults: [
250        "tools-defaults",
251    ],
252    srcs: [
253        "tools/fibmap.c",
254    ],
255}
256