blob: 6a2b56f252f114f360902582fb3c7c3bdca94977 [file] [log] [blame]
Lorenz Brunddd6caf2021-03-04 17:16:04 +01001# Copyright 2020 The Monogon Project Authors.
2#
3# SPDX-License-Identifier: Apache-2.0
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
Tim Windelschmidtafeb4c42024-07-17 21:37:26 +020018load("@@//build/utils:template_file.bzl", "template_file")
Lorenz Brunddd6caf2021-03-04 17:16:04 +010019
20defs = [
21 "NDEBUG", # Doesn't compile without it because their assertions reference non-existent fields
22 "_GNU_SOURCE",
23 "ENABLE_BLKID",
24 "HAVE_FSETXATTR",
25 "HAVE_GETFSMAP",
26 "HAVE_GETMNTENT",
27 "HAVE_MNTENT",
28 "VERSION=\\\"0.0.0\\\"",
29]
30
Lorenz Brunddd6caf2021-03-04 17:16:04 +010031cc_library(
32 name = "util",
33 srcs = [
34 "libfrog/util.c",
Lorenz Brun688ee2b2024-08-21 17:38:46 +020035 "include/platform_defs.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +010036 ],
37 hdrs = ["libfrog/util.h"],
38 local_defines = defs,
Lorenz Brun688ee2b2024-08-21 17:38:46 +020039 deps = [
40 "@urcu",
41 ],
Lorenz Brunddd6caf2021-03-04 17:16:04 +010042)
43
44cc_library(
45 name = "radix_tree",
46 srcs = [
47 "libfrog/radix-tree.c",
Lorenz Brun688ee2b2024-08-21 17:38:46 +020048 "include/platform_defs.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +010049 ],
50 hdrs = ["libfrog/radix-tree.h"],
51 local_defines = defs,
Lorenz Brun688ee2b2024-08-21 17:38:46 +020052 deps = [
53 "@urcu",
54 ],
Lorenz Brunddd6caf2021-03-04 17:16:04 +010055)
56
57cc_binary(
58 name = "gen_crc32table",
59 srcs = [
60 "libfrog/crc32defs.h",
61 "libfrog/gen_crc32table.c",
62 ],
63)
64
65genrule(
66 name = "crc32table",
67 srcs = [],
68 outs = ["crc32table.h"],
69 cmd = "./$(location :gen_crc32table) > \"$@\"",
70 tools = [":gen_crc32table"],
71)
72
73cc_library(
74 name = "crc32c",
75 srcs = [
76 "include/xfs_arch.h",
77 "libfrog/crc32.c",
78 "libfrog/crc32defs.h",
79 ":crc32table",
Lorenz Brun688ee2b2024-08-21 17:38:46 +020080 "include/platform_defs.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +010081 ],
Lorenz Brun688ee2b2024-08-21 17:38:46 +020082 hdrs = [
83 "libfrog/crc32c.h",
84 ],
Lorenz Brunddd6caf2021-03-04 17:16:04 +010085 local_defines = defs,
86)
87
88cc_library(
89 name = "list_sort",
90 srcs = ["libfrog/list_sort.c"],
91 hdrs = ["include/list.h"],
92 local_defines = defs,
93)
94
95cc_library(
96 name = "fsgeom",
97 srcs = ["libfrog/fsgeom.c"],
98 hdrs = ["libfrog/fsgeom.h"],
99 local_defines = defs,
100 deps = [
101 ":libxfs",
102 ":util",
103 ],
104)
105
106cc_library(
107 name = "projects",
108 srcs = [
109 "include/input.h",
110 "libfrog/projects.c",
111 "libfrog/projects.h",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200112 "include/platform_defs.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100113 ],
114 hdrs = ["libfrog/projects.h"],
115 local_defines = defs,
116 deps = [
117 ":libxfs",
118 ],
119)
120
121cc_library(
122 name = "convert",
123 srcs = [
124 "include/input.h",
125 "libfrog/convert.c",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200126 "include/platform_defs.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100127 ],
128 hdrs = ["libfrog/convert.h"],
129 local_defines = defs,
130 deps = [
131 ":projects",
132 ],
133)
134
135cc_library(
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100136 name = "platform",
137 srcs = ["libfrog/linux.c"],
138 local_defines = defs,
139 visibility = ["//visibility:public"],
140 deps = [":libxfs"],
141)
142
143cc_library(
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200144 name = "randbytes",
145 srcs = ["libfrog/randbytes.c"],
146 hdrs = ["libfrog/randbytes.h"],
147 local_defines = defs,
148 deps = [
149 ":util",
150 ],
151)
152
153cc_library(
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100154 name = "libxfs",
155 srcs = glob([
156 "libxfs/*.c",
157 "libxfs/*.h",
158 ]) + [
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200159 "include/platform_defs.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100160 "include/xfs.h",
161 "libfrog/platform.h",
162 "include/linux.h",
163 "include/hlist.h",
164 "include/cache.h",
165 "include/bitops.h",
166 "include/kmem.h",
167 "include/atomic.h",
168 "include/xfs_mount.h",
169 "include/xfs_inode.h",
170 "include/xfs_trans.h",
171 "include/xfs_trace.h",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200172 "include/xfs_multidisk.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100173 "libfrog/linux.c",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200174 "libfrog/bitmask.h",
175 "libfrog/div64.h",
176 "include/spinlock.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100177 "include/xfs_fs_compat.h",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200178 "include/libxcmd.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100179 ],
180 hdrs = ["include/libxfs.h"],
181 local_defines = defs,
182 deps = [
183 ":crc32c",
184 ":list_sort",
185 ":radix_tree",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200186 ":randbytes",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100187 "@util_linux//:uuid",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200188 "@urcu",
189 "@util_linux//:blkid",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100190 ],
191)
192
193cc_binary(
194 name = "mkfs",
195 srcs = [
196 "include/xfs_multidisk.h",
197 "mkfs/proto.c",
198 "mkfs/xfs_mkfs.c",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200199 "libfrog/crc32cselftest.h",
200 "libfrog/randbytes.h",
201 "libfrog/dahashselftest.h",
202 "mkfs/proto.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100203 ],
204 linkopts = ["-lpthread"],
205 local_defines = defs,
206 deps = [
207 ":convert",
208 ":fsgeom",
209 ":libxfs",
210 ":platform",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100211 ":util",
212 "@inih",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200213 "@urcu",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100214 ],
215 visibility = ["//visibility:public"],
216)