|
| 1 | +load("@@//bazel/rules:so_symlink.bzl", "so_symlink") |
| 2 | +load("@bazel_skylib//rules:expand_template.bzl", "expand_template") |
| 3 | +load("@rules_cc//cc:defs.bzl", "cc_library") |
| 4 | +load("@rules_pkg//pkg:install.bzl", "pkg_install") |
| 5 | +load("@rules_pkg//pkg:mappings.bzl", "pkg_files") |
| 6 | + |
| 7 | +_VERSION = "2.39.2" |
| 8 | + |
| 9 | +expand_template( |
| 10 | + name = "blkid_h", |
| 11 | + out = "blkid.h", |
| 12 | + template = "libblkid/src/blkid.h.in", |
| 13 | + substitutions = { |
| 14 | + "@LIBBLKID_DATE@": "REDACTED", |
| 15 | + "@LIBBLKID_VERSION@": _VERSION, |
| 16 | + }, |
| 17 | +) |
| 18 | + |
| 19 | +cc_library( |
| 20 | + name = "libcommon", |
| 21 | + srcs = [ |
| 22 | + "lib/blkdev.c", |
| 23 | + "lib/buffer.c", |
| 24 | + "lib/caputils.c", |
| 25 | + "lib/canonicalize.c", |
| 26 | + "lib/color-names.c", |
| 27 | + "lib/cpuset.c", |
| 28 | + "lib/crc32.c", |
| 29 | + "lib/crc32c.c", |
| 30 | + "lib/crc64.c", |
| 31 | + "lib/c_strtod.c", |
| 32 | + "lib/encode.c", |
| 33 | + "lib/env.c", |
| 34 | + "lib/fileutils.c", |
| 35 | + "lib/idcache.c", |
| 36 | + "lib/jsonwrt.c", |
| 37 | + "lib/linux_version.c", |
| 38 | + "lib/loopdev.c", |
| 39 | + "lib/mangle.c", |
| 40 | + "lib/match.c", |
| 41 | + "lib/mbsalign.c", |
| 42 | + "lib/mbsedit.c", |
| 43 | + "lib/md5.c", |
| 44 | + "lib/path.c", |
| 45 | + "lib/procfs.c", |
| 46 | + "lib/pwdutils.c", |
| 47 | + "lib/randutils.c", |
| 48 | + "lib/sha1.c", |
| 49 | + "lib/sha256.c", |
| 50 | + "lib/signames.c", |
| 51 | + "lib/strutils.c", |
| 52 | + "lib/strv.c", |
| 53 | + "lib/sysfs.c", |
| 54 | + "lib/timeutils.c", |
| 55 | + "lib/ttyutils.c", |
| 56 | + "lib/xxhash.c", |
| 57 | + ] + ["generated/config.h"], |
| 58 | + hdrs = glob(["include/*.h"]), |
| 59 | + includes = [ |
| 60 | + "include", |
| 61 | + ], |
| 62 | + visibility = ["//visibility:private"], |
| 63 | + copts = [ |
| 64 | + "-include generated/config.h", |
| 65 | + ], |
| 66 | + local_defines = [ |
| 67 | + "_GNU_SOURCE", |
| 68 | + ], |
| 69 | +) |
| 70 | + |
| 71 | +cc_library( |
| 72 | + name = "libblkid", |
| 73 | + srcs = glob([ |
| 74 | + "libblkid/src/**/*.c", |
| 75 | + "libblkid/src/**/*.h", |
| 76 | + ]) + ["generated/config.h"], |
| 77 | + hdrs = [":blkid_h"], |
| 78 | + deps = [":libcommon"], |
| 79 | + includes = [ |
| 80 | + "libblkid/src", |
| 81 | + "include", |
| 82 | + "generated", |
| 83 | + ], |
| 84 | + copts = [ |
| 85 | + "-include generated/config.h", |
| 86 | + ], |
| 87 | + local_defines = [ |
| 88 | + "_GNU_SOURCE", |
| 89 | + ], |
| 90 | +) |
| 91 | + |
| 92 | +cc_shared_library( |
| 93 | + name = "blkid", |
| 94 | + deps = [":libblkid"], |
| 95 | +) |
| 96 | + |
| 97 | +expand_template( |
| 98 | + name = "gen_blkid_pkgconfig", |
| 99 | + out = "blkid.pc", |
| 100 | + substitutions = { |
| 101 | + # Prepare the .pc file for our own substitution later |
| 102 | + "@prefix@": "##PREFIX##", |
| 103 | + "@exec_prefix@": "${prefix}", |
| 104 | + "@libdir@": "${prefix}/lib", |
| 105 | + "@includedir@": "${prefix}/include", |
| 106 | + "@LIBBLKID_VERSION@": _VERSION, |
| 107 | + }, |
| 108 | + template = "libblkid/blkid.pc.in", |
| 109 | +) |
| 110 | + |
| 111 | +so_symlink( |
| 112 | + name = "libblkid_libfiles", |
| 113 | + src = ":blkid", |
| 114 | + libname = "libblkid", |
| 115 | + version = "1.1.0", |
| 116 | +) |
| 117 | + |
| 118 | +pkg_files( |
| 119 | + name = "blkid_hdr_files", |
| 120 | + srcs = [":blkid_h"], |
| 121 | + prefix = "include/blkid", |
| 122 | +) |
| 123 | + |
| 124 | +pkg_files( |
| 125 | + name = "blkid_pc_file", |
| 126 | + srcs = [":gen_blkid_pkgconfig"], |
| 127 | + prefix = "lib/pkgconfig", |
| 128 | +) |
| 129 | + |
| 130 | +pkg_install( |
| 131 | + name = "blkid_install", |
| 132 | + srcs = [ |
| 133 | + ":blkid_hdr_files", |
| 134 | + ":libblkid_libfiles", |
| 135 | + ":blkid_pc_file", |
| 136 | + ], |
| 137 | +) |
0 commit comments