Lorenz Brun | ddd6caf | 2021-03-04 17:16:04 +0100 | [diff] [blame] | 1 | # 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 | |
| 17 | load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") |
| 18 | load("@dev_source_monogon//build/utils:template_file.bzl", "template_file") |
| 19 | |
| 20 | defs = [ |
| 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 | |
| 31 | template_file( |
| 32 | name = "platform_defs.h", |
| 33 | src = "include/platform_defs.h.in", |
| 34 | substitutions = { |
| 35 | "#undef SIZEOF_LONG": "#define SIZEOF_LONG sizeof(long)", # Because C reasons |
| 36 | }, |
| 37 | ) |
| 38 | |
| 39 | cc_library( |
| 40 | name = "util", |
| 41 | srcs = [ |
| 42 | "libfrog/util.c", |
| 43 | ":platform_defs.h", |
| 44 | ], |
| 45 | hdrs = ["libfrog/util.h"], |
| 46 | local_defines = defs, |
| 47 | ) |
| 48 | |
| 49 | cc_library( |
| 50 | name = "radix_tree", |
| 51 | srcs = [ |
| 52 | "libfrog/radix-tree.c", |
| 53 | ":platform_defs.h", |
| 54 | ], |
| 55 | hdrs = ["libfrog/radix-tree.h"], |
| 56 | local_defines = defs, |
| 57 | ) |
| 58 | |
| 59 | cc_binary( |
| 60 | name = "gen_crc32table", |
| 61 | srcs = [ |
| 62 | "libfrog/crc32defs.h", |
| 63 | "libfrog/gen_crc32table.c", |
| 64 | ], |
| 65 | ) |
| 66 | |
| 67 | genrule( |
| 68 | name = "crc32table", |
| 69 | srcs = [], |
| 70 | outs = ["crc32table.h"], |
| 71 | cmd = "./$(location :gen_crc32table) > \"$@\"", |
| 72 | tools = [":gen_crc32table"], |
| 73 | ) |
| 74 | |
| 75 | cc_library( |
| 76 | name = "crc32c", |
| 77 | srcs = [ |
| 78 | "include/xfs_arch.h", |
| 79 | "libfrog/crc32.c", |
| 80 | "libfrog/crc32defs.h", |
| 81 | ":crc32table", |
| 82 | ":platform_defs.h", |
| 83 | ], |
| 84 | hdrs = ["libfrog/crc32c.h"], |
| 85 | local_defines = defs, |
| 86 | ) |
| 87 | |
| 88 | cc_library( |
| 89 | name = "list_sort", |
| 90 | srcs = ["libfrog/list_sort.c"], |
| 91 | hdrs = ["include/list.h"], |
| 92 | local_defines = defs, |
| 93 | ) |
| 94 | |
| 95 | cc_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 | |
| 106 | cc_library( |
| 107 | name = "projects", |
| 108 | srcs = [ |
| 109 | "include/input.h", |
| 110 | "libfrog/projects.c", |
| 111 | "libfrog/projects.h", |
| 112 | ":platform_defs.h", |
| 113 | ], |
| 114 | hdrs = ["libfrog/projects.h"], |
| 115 | local_defines = defs, |
| 116 | deps = [ |
| 117 | ":libxfs", |
| 118 | ], |
| 119 | ) |
| 120 | |
| 121 | cc_library( |
| 122 | name = "convert", |
| 123 | srcs = [ |
| 124 | "include/input.h", |
| 125 | "libfrog/convert.c", |
| 126 | ":platform_defs.h", |
| 127 | ], |
| 128 | hdrs = ["libfrog/convert.h"], |
| 129 | local_defines = defs, |
| 130 | deps = [ |
| 131 | ":projects", |
| 132 | ], |
| 133 | ) |
| 134 | |
| 135 | cc_library( |
| 136 | name = "topology", |
| 137 | srcs = [ |
| 138 | "include/xfs_multidisk.h", |
| 139 | "libfrog/topology.c", |
| 140 | ], |
| 141 | hdrs = [ |
| 142 | "include/libxcmd.h", |
| 143 | "libfrog/topology.h", |
| 144 | ], |
| 145 | local_defines = defs, |
| 146 | visibility = ["//visibility:public"], |
| 147 | deps = [ |
| 148 | ":libxfs", |
| 149 | "@util_linux//:blkid", |
| 150 | ], |
| 151 | ) |
| 152 | |
| 153 | cc_library( |
| 154 | name = "platform", |
| 155 | srcs = ["libfrog/linux.c"], |
| 156 | local_defines = defs, |
| 157 | visibility = ["//visibility:public"], |
| 158 | deps = [":libxfs"], |
| 159 | ) |
| 160 | |
| 161 | cc_library( |
| 162 | name = "libxfs", |
| 163 | srcs = glob([ |
| 164 | "libxfs/*.c", |
| 165 | "libxfs/*.h", |
| 166 | ]) + [ |
| 167 | ":platform_defs.h", |
| 168 | "include/xfs.h", |
| 169 | "libfrog/platform.h", |
| 170 | "include/linux.h", |
| 171 | "include/hlist.h", |
| 172 | "include/cache.h", |
| 173 | "include/bitops.h", |
| 174 | "include/kmem.h", |
| 175 | "include/atomic.h", |
| 176 | "include/xfs_mount.h", |
| 177 | "include/xfs_inode.h", |
| 178 | "include/xfs_trans.h", |
| 179 | "include/xfs_trace.h", |
| 180 | "libfrog/linux.c", |
| 181 | "include/xfs_fs_compat.h", |
| 182 | ], |
| 183 | hdrs = ["include/libxfs.h"], |
| 184 | local_defines = defs, |
| 185 | deps = [ |
| 186 | ":crc32c", |
| 187 | ":list_sort", |
| 188 | ":radix_tree", |
| 189 | "@util_linux//:uuid", |
| 190 | ], |
| 191 | ) |
| 192 | |
| 193 | cc_binary( |
| 194 | name = "mkfs", |
| 195 | srcs = [ |
| 196 | "include/xfs_multidisk.h", |
| 197 | "mkfs/proto.c", |
| 198 | "mkfs/xfs_mkfs.c", |
| 199 | ], |
| 200 | linkopts = ["-lpthread"], |
| 201 | local_defines = defs, |
| 202 | deps = [ |
| 203 | ":convert", |
| 204 | ":fsgeom", |
| 205 | ":libxfs", |
| 206 | ":platform", |
| 207 | ":topology", |
| 208 | ":util", |
| 209 | "@inih", |
| 210 | ], |
| 211 | visibility = ["//visibility:public"], |
| 212 | ) |