| load("@rules_cc//cc:cc_library.bzl", "cc_library") |
| |
| package(default_visibility = ["//visibility:public"]) |
| |
| genrule( |
| name = "gen_systemd_stubs", |
| outs = ["systemd_stubs.c"], |
| cmd = """ |
| cat << 'EOF' > $@ |
| #include <errno.h> |
| #include <sys/socket.h> |
| #include <stddef.h> |
| |
| const char* errno_to_name(int e) { return "EUNKNOWN"; } |
| int errno_from_name(const char *name) { return -1; } |
| |
| int af_from_ipv4_ipv6(const char *name) { |
| if (!name) return AF_UNSPEC; |
| if (name[0] == '4') return AF_INET; |
| if (name[0] == '6') return AF_INET6; |
| return AF_UNSPEC; |
| } |
| |
| const char* af_to_ipv4_ipv6(int af) { |
| if (af == AF_INET) return "4"; |
| if (af == AF_INET6) return "6"; |
| return NULL; |
| } |
| |
| const char* capability_to_name(int cap) { return NULL; } |
| int capability_from_name(const char *name) { return -1; } |
| |
| const void *filesystem_sets = NULL; |
| int fs_in_group(const char *fstype, const char *group) { return 0; } |
| EOF |
| """, |
| ) |
| |
| cc_library( |
| name = "libsystemd", |
| srcs = glob( |
| [ |
| "src/basic/**/*.c", |
| "src/fundamental/**/*.c", |
| "src/libsystemd/**/*.c", |
| ], |
| exclude = [ |
| "src/basic/*-list.c", |
| "src/basic/arphrd-util.c", |
| "src/basic/build.c", |
| "src/basic/filesystems.c", |
| "src/basic/path-lookup.c", |
| "src/libsystemd/sd-path/**/*.c", |
| "src/libsystemd/sd-journal/**/*.c", |
| "src/libsystemd/sd-hwdb/**/*.c", |
| "src/libsystemd/sd-netlink/**/*.c", |
| "src/libsystemd/sd-resolve/**/*.c", |
| "src/libsystemd/sd-device/**/*.c", |
| "src/libsystemd/sd-login/**/*.c", |
| "src/libsystemd/**/test-*.c", |
| "src/libsystemd/**/fuzz-*.c", |
| ], |
| ) + [":gen_systemd_stubs"], |
| hdrs = glob([ |
| "src/systemd/*.h", |
| "src/basic/**/*.h", |
| "src/fundamental/**/*.h", |
| "src/libsystemd/**/*.h", |
| ]), |
| copts = [ |
| "-D_GNU_SOURCE", |
| "-DGPERF_LEN_TYPE=size_t", |
| "-DRELATIVE_SOURCE_PATH=\\\"\\\"", |
| "-DFALLBACK_HOSTNAME=\\\"localhost\\\"", |
| "-DDEFAULT_USER_SHELL=\\\"/bin/sh\\\"", |
| "-DNOBODY_USER_NAME=\\\"nobody\\\"", |
| "-DNOBODY_GROUP_NAME=\\\"nobody\\\"", |
| "-DNOLOGIN=\\\"/sbin/nologin\\\"", |
| "-DDEFAULT_TIMEOUT_SEC=25", |
| "-DBUILD_MODE_DEVELOPER=0", |
| "-DDEFAULT_COMPRESSION=0", |
| "-DHAVE_XZ=0", |
| "-DHAVE_LZ4=0", |
| "-DHAVE_ZSTD=0", |
| "-DTTY_MODE=0620", |
| "-D_FILE_OFFSET_BITS=64", |
| "-DDYNAMIC_UID_MIN=0x0000ed00", |
| "-DDYNAMIC_UID_MAX=0x0000ef3f", |
| "-DCONTAINER_UID_BASE_MIN=0x00080000", |
| "-DCONTAINER_UID_BASE_MAX=0x7fff0000", |
| "-DSYSTEM_ALLOC_UID_MIN=1", |
| "-DSYSTEM_UID_MAX=999", |
| "-DSYSTEM_ALLOC_GID_MIN=1", |
| "-DSYSTEM_GID_MAX=999", |
| "-DHAVE_REALLOCARRAY=1", |
| "-DHAVE_STRUCT_STATX=1", |
| "-DHAVE_STRUCT_MOUNT_ATTR=1", |
| "-DHAVE_NAME_TO_HANDLE_AT=1", |
| "-DHAVE_EXPLICIT_BZERO=1", |
| "-DHAVE_MEMFD_CREATE=1", |
| "-DHAVE_GETRANDOM=0", |
| "-DHAVE_SYS_RANDOM_H=1", |
| "-DHAVE_DECL_GETTID=1", |
| "-DSIZEOF_PID_T=4", |
| "-DSIZEOF_UID_T=4", |
| "-DSIZEOF_GID_T=4", |
| "-DSIZEOF_TIME_T=8", |
| "-DSIZEOF_RLIM_T=8", |
| "-DSIZEOF_DEV_T=8", |
| "-DSIZEOF_INO_T=8", |
| "-DSIZEOF_TIMEX_MEMBER=8", |
| "-Wno-format-nonliteral", |
| "-Wno-override-init", |
| "-Wno-pointer-arith", |
| "-Wno-unused-result", |
| "-Wno-unknown-warning-option", |
| ], |
| includes = [ |
| "src/basic", |
| "src/fundamental", |
| "src/libsystemd", |
| "src/libsystemd/sd-bus", |
| "src/libsystemd/sd-event", |
| "src/libsystemd/sd-id128", |
| "src/systemd", |
| ], |
| linkopts = ["-lcap"], |
| visibility = ["//visibility:public"], |
| ) |