blob: 9e64243d82d54fb9cf3970f60d80f30c095b2b5d [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_library")
18load("@dev_source_monogon//build/utils:template_file.bzl", "template_file")
19
20# These are only for the headers of libcommon, which is a private dependency of libblkid and
21# libuuid. Bazel doesn't support private dependencies and we want to avoid propagating these up
22# to all users of libblkid and libuuid, so manually inject them one level up.
23libcommon_hdrs_defines = [
24 "_GNU_SOURCE",
25 "HAVE_BYTESWAP_H",
26 "HAVE_CLOSE_RANGE",
27 "HAVE_CPU_SET_T",
28 "HAVE_DECL_CPU_ALLOC",
29 "HAVE_DIRFD",
30 "HAVE_ENDIAN_H",
31 "HAVE_ERR_H",
32 "HAVE_ERR",
33 "HAVE_ERRX",
34 "HAVE_LOFF_T",
35 "HAVE_MEMPCPY",
36 "HAVE_NANOSLEEP",
37 "HAVE_SETNS",
38 "HAVE_SRANDOM",
39 "HAVE_STDIO_EXT_H",
40 "HAVE_STRNDUP",
41 "HAVE_STRNLEN",
42 "HAVE_SENDFILE",
43 "HAVE_PIDFD_SEND_SIGNAL",
44 "HAVE_PIDFD_OPEN",
45 "HAVE_PATHS_H",
46 "HAVE_LINUX_VERSION_H",
47 "HAVE_OPENAT",
48 "HAVE_SYS_IOCTL_H",
49 "HAVE_SYS_SENDFILE_H",
50 "HAVE_SYS_SYSMACROS_H",
51 "HAVE_SYS_TTYDEFAULTS_H",
52 "HAVE_TIMEGM",
53 "HAVE_TIMER_CREATE",
54 "HAVE_UNSHARE",
55 "HAVE_WARN",
56 "HAVE_WARNX",
57 "HAVE_WIDECHAR",
58 "HAVE_FSYNC",
59 "HAVE___FPENDING",
60]
61
62template_file(
63 name = "blkid.h",
64 src = "libblkid/src/blkid.h.in",
65 substitutions = {
66 "@LIBBLKID_VERSION@": "0.0.0",
67 "@LIBBLKID_DATE@": "01.01.1970",
68 },
69)
70
71cc_library(
72 name = "common",
73 srcs = glob(["lib/*.h"]) + [
74 "lib/blkdev.c",
75 "lib/canonicalize.c",
76 "lib/crc32.c",
77 "lib/crc32c.c",
78 "lib/env.c",
79 "lib/idcache.c",
80 "lib/encode.c",
81 "lib/fileutils.c",
82 "lib/color-names.c",
83 "lib/mangle.c",
84 "lib/match.c",
85 "lib/mbsalign.c",
86 "lib/mbsedit.c",
87 "lib/md5.c",
88 "lib/pager.c",
89 "lib/procutils.c",
90 "lib/pwdutils.c",
91 "lib/randutils.c",
92 "lib/setproctitle.c",
93 "lib/strutils.c",
94 "lib/sysfs.c",
95 "lib/timeutils.c",
96 "lib/ttyutils.c",
97 "lib/strv.c",
98 "lib/path.c",
99 "lib/cpuset.c",
100 "lib/sha1.c",
101 "lib/signames.c",
102 ],
103 hdrs = glob(["include/*.h"]),
104 # Locale-related defines are intentionally missing as we don't want locale support
105 local_defines = libcommon_hdrs_defines + [
106 "HAVE_DECL_CPU_ALLOC",
107 "HAVE_ENVIRON_DECL",
108 "HAVE_ERRNO_H",
109 "HAVE_GETDTABLESIZE",
110 "HAVE_GETRANDOM",
111 "HAVE_GETRLIMIT",
112 "HAVE_LINUX_CDROM_H",
113 "HAVE_LINUX_FD_H",
114 "HAVE_JRAND48",
115 "HAVE_MKOSTEMP",
116 "HAVE_SYS_PRCTL_H",
117 "HAVE_MNTENT_H",
118 "HAVE_PRCTL",
119 "HAVE_SECURE_GETENV",
120 "HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC",
121 "HAVE_SYS_STAT_H",
122 "HAVE_SYS_TYPES_H",
123 "HAVE_EXPLICIT_BZERO",
124 "HAVE_UNISTD_H",
125 "HAVE_TLS",
126 ],
127 visibility = ["//visibility:private"],
128)
129
130cc_library(
131 name = "uuid",
132 srcs = [
133 "libuuid/src/clear.c",
134 "libuuid/src/compare.c",
135 "libuuid/src/copy.c",
136 "libuuid/src/gen_uuid.c",
137 "libuuid/src/isnull.c",
138 "libuuid/src/pack.c",
139 "libuuid/src/parse.c",
140 "libuuid/src/predefined.c",
141 "libuuid/src/unpack.c",
142 "libuuid/src/unparse.c",
143 "libuuid/src/uuidP.h",
144 "libuuid/src/uuid_time.c",
145 ],
146 hdrs = [
147 "libuuid/src/uuid.h",
148 "libuuid/src/uuidd.h",
149 ],
150 local_defines = libcommon_hdrs_defines + [
151 "HAVE_NET_IF_H",
152 "HAVE_NETINET_IN_H",
153 "HAVE_STDLIB_H",
154 "HAVE_SYS_FILE_H",
155 "HAVE_SYS_SOCKET_H",
156 "HAVE_SYS_SYSCALL_H",
157 "HAVE_SYS_TIME_H",
158 "HAVE_SYS_UN_H",
159 "HAVE_TLS",
160 "HAVE_UNISTD_H",
161 ],
162 visibility = ["//visibility:public"],
163 deps = [":common"],
164)
165
166cc_library(
167 name = "blkid",
168 srcs = glob([
169 "libblkid/src/**/*.c",
170 "libblkid/src/**/*.h",
171 ]),
172 hdrs = [":blkid.h"],
173 local_defines = libcommon_hdrs_defines + [
174 "LIBBLKID_VERSION=\\\"0.0.0\\\"",
175 "LIBBLKID_DATE=\\\"01.01.1970\\\"",
176 "HAVE_SYS_STAT_H",
177 "HAVE_ERRNO_H",
178 "HAVE_LINUX_CDROM_H",
179 "HAVE_POSIX_FADVISE",
180 "HAVE_STDLIB_H",
181 "HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC",
182 "HAVE_SYS_STAT_H",
183 "HAVE_SYS_TYPES_H",
184 "HAVE_UNISTD_H",
185 ],
186 visibility = ["//visibility:public"],
187 deps = ["//:common"],
188)