blob: 07f3da7f7f840a57579edfb7a19828ecb79a77eb [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")
Lorenz Brunddd6caf2021-03-04 17:16:04 +010018
19defs = [
20 "NDEBUG", # Doesn't compile without it because their assertions reference non-existent fields
21 "_GNU_SOURCE",
22 "ENABLE_BLKID",
23 "HAVE_FSETXATTR",
24 "HAVE_GETFSMAP",
25 "HAVE_GETMNTENT",
26 "HAVE_MNTENT",
27 "VERSION=\\\"0.0.0\\\"",
28]
29
Lorenz Brunddd6caf2021-03-04 17:16:04 +010030cc_library(
31 name = "util",
32 srcs = [
33 "libfrog/util.c",
Lorenz Brun688ee2b2024-08-21 17:38:46 +020034 "include/platform_defs.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +010035 ],
36 hdrs = ["libfrog/util.h"],
37 local_defines = defs,
Lorenz Brun688ee2b2024-08-21 17:38:46 +020038 deps = [
39 "@urcu",
40 ],
Lorenz Brunddd6caf2021-03-04 17:16:04 +010041)
42
43cc_library(
44 name = "radix_tree",
45 srcs = [
46 "libfrog/radix-tree.c",
Lorenz Brun688ee2b2024-08-21 17:38:46 +020047 "include/platform_defs.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +010048 ],
49 hdrs = ["libfrog/radix-tree.h"],
50 local_defines = defs,
Lorenz Brun688ee2b2024-08-21 17:38:46 +020051 deps = [
52 "@urcu",
53 ],
Lorenz Brunddd6caf2021-03-04 17:16:04 +010054)
55
56cc_binary(
57 name = "gen_crc32table",
58 srcs = [
59 "libfrog/crc32defs.h",
60 "libfrog/gen_crc32table.c",
61 ],
62)
63
64genrule(
65 name = "crc32table",
66 srcs = [],
67 outs = ["crc32table.h"],
68 cmd = "./$(location :gen_crc32table) > \"$@\"",
69 tools = [":gen_crc32table"],
70)
71
72cc_library(
73 name = "crc32c",
74 srcs = [
75 "include/xfs_arch.h",
76 "libfrog/crc32.c",
77 "libfrog/crc32defs.h",
78 ":crc32table",
Lorenz Brun688ee2b2024-08-21 17:38:46 +020079 "include/platform_defs.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +010080 ],
Lorenz Brun688ee2b2024-08-21 17:38:46 +020081 hdrs = [
82 "libfrog/crc32c.h",
83 ],
Lorenz Brunddd6caf2021-03-04 17:16:04 +010084 local_defines = defs,
85)
86
87cc_library(
88 name = "list_sort",
89 srcs = ["libfrog/list_sort.c"],
90 hdrs = ["include/list.h"],
91 local_defines = defs,
92)
93
94cc_library(
95 name = "fsgeom",
96 srcs = ["libfrog/fsgeom.c"],
97 hdrs = ["libfrog/fsgeom.h"],
98 local_defines = defs,
99 deps = [
100 ":libxfs",
101 ":util",
102 ],
103)
104
105cc_library(
106 name = "projects",
107 srcs = [
108 "include/input.h",
109 "libfrog/projects.c",
110 "libfrog/projects.h",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200111 "include/platform_defs.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100112 ],
113 hdrs = ["libfrog/projects.h"],
114 local_defines = defs,
115 deps = [
116 ":libxfs",
117 ],
118)
119
120cc_library(
121 name = "convert",
122 srcs = [
123 "include/input.h",
124 "libfrog/convert.c",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200125 "include/platform_defs.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100126 ],
127 hdrs = ["libfrog/convert.h"],
128 local_defines = defs,
129 deps = [
130 ":projects",
131 ],
132)
133
134cc_library(
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100135 name = "platform",
136 srcs = ["libfrog/linux.c"],
137 local_defines = defs,
138 visibility = ["//visibility:public"],
139 deps = [":libxfs"],
140)
141
142cc_library(
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200143 name = "randbytes",
144 srcs = ["libfrog/randbytes.c"],
145 hdrs = ["libfrog/randbytes.h"],
146 local_defines = defs,
147 deps = [
148 ":util",
149 ],
150)
151
152cc_library(
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100153 name = "libxfs",
154 srcs = glob([
155 "libxfs/*.c",
156 "libxfs/*.h",
157 ]) + [
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200158 "include/platform_defs.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100159 "include/xfs.h",
160 "libfrog/platform.h",
161 "include/linux.h",
162 "include/hlist.h",
163 "include/cache.h",
164 "include/bitops.h",
165 "include/kmem.h",
166 "include/atomic.h",
167 "include/xfs_mount.h",
168 "include/xfs_inode.h",
169 "include/xfs_trans.h",
170 "include/xfs_trace.h",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200171 "include/xfs_multidisk.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100172 "libfrog/linux.c",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200173 "libfrog/bitmask.h",
174 "libfrog/div64.h",
175 "include/spinlock.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100176 "include/xfs_fs_compat.h",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200177 "include/libxcmd.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100178 ],
179 hdrs = ["include/libxfs.h"],
180 local_defines = defs,
181 deps = [
182 ":crc32c",
183 ":list_sort",
184 ":radix_tree",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200185 ":randbytes",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100186 "@util_linux//:uuid",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200187 "@urcu",
188 "@util_linux//:blkid",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100189 ],
190)
191
192cc_binary(
193 name = "mkfs",
194 srcs = [
195 "include/xfs_multidisk.h",
196 "mkfs/proto.c",
197 "mkfs/xfs_mkfs.c",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200198 "libfrog/crc32cselftest.h",
199 "libfrog/randbytes.h",
200 "libfrog/dahashselftest.h",
201 "mkfs/proto.h",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100202 ],
203 linkopts = ["-lpthread"],
204 local_defines = defs,
205 deps = [
206 ":convert",
207 ":fsgeom",
208 ":libxfs",
209 ":platform",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100210 ":util",
211 "@inih",
Lorenz Brun688ee2b2024-08-21 17:38:46 +0200212 "@urcu",
Lorenz Brunddd6caf2021-03-04 17:16:04 +0100213 ],
214 visibility = ["//visibility:public"],
215)