feat add spdlog
Some checks failed
sm-rpc / build (Debug, aarch64-linux-gnu) (push) Failing after 29s
sm-rpc / build (Debug, arm-linux-gnueabihf) (push) Failing after 16s
sm-rpc / build (Debug, host.gcc) (push) Failing after 11s
sm-rpc / build (Debug, mipsel-linux-gnu) (push) Failing after 12s
sm-rpc / build (Release, aarch64-linux-gnu) (push) Failing after 11s
sm-rpc / build (Release, arm-linux-gnueabihf) (push) Failing after 11s
sm-rpc / build (Release, host.gcc) (push) Failing after 12s
sm-rpc / build (Release, mipsel-linux-gnu) (push) Failing after 16s

This commit is contained in:
tqcq
2025-08-22 18:22:57 +08:00
parent 3d395b45f0
commit c68893bace
2331 changed files with 1306786 additions and 103 deletions

View File

@@ -0,0 +1,7 @@
exports_files(
glob([
"*.BUILD",
"*.tpl",
]),
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,105 @@
licenses(["notice"]) # MIT license
config_setting(
name = "osx",
constraint_values = [
"@platforms//os:osx",
],
)
config_setting(
name = "windows",
constraint_values = [
"@platforms//os:windows",
],
)
config_setting(
name = "with_ssl",
define_values = {
"with_civetweb_ssl": "true",
},
visibility = ["//visibility:public"],
)
COPTS = [
"-DUSE_IPV6",
"-DNDEBUG",
"-DNO_CGI",
"-DNO_CACHING",
"-DNO_FILES",
"-UDEBUG",
] + select({
":with_ssl": [
"-DOPENSSL_API_1_1",
"-DNO_SSL_DL",
],
"//conditions:default": [
"-DNO_SSL",
],
})
DEPS = select({
":with_ssl": [
"@boringssl//:crypto",
"@boringssl//:ssl",
],
"//conditions:default": [],
})
cc_library(
name = "civetweb",
srcs = [
"src/civetweb.c",
],
hdrs = [
"include/civetweb.h",
],
copts = COPTS,
includes = [
"include",
],
linkopts = select({
":windows": [],
"//conditions:default": ["-lpthread"],
}) + select({
":osx": [],
":windows": [],
"//conditions:default": ["-lrt"],
}),
textual_hdrs = [
"src/handle_form.inl",
"src/match.inl",
"src/md5.inl",
"src/response.inl",
"src/sort.inl",
],
visibility = ["//visibility:public"],
deps = DEPS,
)
cc_library(
name = "civetserver",
srcs = [
"src/CivetServer.cpp",
],
hdrs = [
"include/CivetServer.h",
],
copts = COPTS,
includes = [
"include",
],
linkopts = select({
":windows": [],
"//conditions:default": ["-lpthread"],
}) + select({
":osx": [],
":windows": [],
"//conditions:default": ["-lrt"],
}),
visibility = ["//visibility:public"],
deps = [
":civetweb",
],
)

60
third_party/prometheus/bazel/curl.BUILD vendored Normal file
View File

@@ -0,0 +1,60 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
# Builds CURL from a distribution.
# copied from: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/bazel/curl.BUILD
load("@com_github_jupp0r_prometheus_cpp//bazel:curl.bzl", "CURL_COPTS")
package(features = ["no_copts_tokenization"])
config_setting(
name = "windows",
constraint_values = [
"@platforms//os:windows",
],
visibility = ["//visibility:private"],
)
config_setting(
name = "osx",
constraint_values = [
"@platforms//os:osx",
],
visibility = ["//visibility:private"],
)
cc_library(
name = "curl",
srcs = glob([
"lib/**/*.c",
]),
hdrs = glob([
"include/curl/*.h",
"lib/**/*.h",
]),
copts = CURL_COPTS + [
"-DOS=\"os\"",
],
defines = ["CURL_STATICLIB"],
includes = [
"include/",
"lib/",
],
linkopts = select({
"//:windows": [
"-DEFAULTLIB:ws2_32.lib",
"-DEFAULTLIB:advapi32.lib",
"-DEFAULTLIB:crypt32.lib",
"-DEFAULTLIB:Normaliz.lib",
],
"//:osx": [
"-framework SystemConfiguration",
"-lpthread",
],
"//conditions:default": [
"-lpthread",
],
}),
visibility = ["//visibility:public"],
)

183
third_party/prometheus/bazel/curl.bzl vendored Normal file
View File

@@ -0,0 +1,183 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
# Compiler options for building libcurl.
# copied from: https://github.com/open-telemetry/opentelemetry-cpp/blob/main/bazel/curl.bzl
BASE_CURL_COPTS = [
# Disable everything else except HTTP protocol.
"-DHTTP_ONLY=1",
"-DENABLE_IPV6=1",
"-DGETHOSTNAME_TYPE_ARG2=size_t",
"-DHAVE_ALARM=1",
"-DHAVE_ALARM=1",
"-DHAVE_ALLOCA_H=1",
"-DHAVE_ARPA_INET_H=1",
"-DHAVE_ARPA_TFTP_H=1",
"-DHAVE_ASSERT_H=1",
"-DHAVE_BASENAME=1",
"-DHAVE_BOOL_T=1",
"-DHAVE_CLOCK_GETTIME_MONOTONIC=1",
"-DHAVE_CONNECT=1",
"-DHAVE_DLFCN_H=1",
"-DHAVE_ENGINE_LOAD_BUILTIN_ENGINES=1",
"-DHAVE_ERRNO_H=1",
"-DHAVE_FCNTL=1",
"-DHAVE_FCNTL_H=1",
"-DHAVE_FCNTL_O_NONBLOCK=1",
"-DHAVE_FREEADDRINFO=1",
"-DHAVE_FSETXATTR=1",
"-DHAVE_FSETXATTR_5=1",
"-DHAVE_FTRUNCATE=1",
"-DHAVE_GAI_STRERROR=1",
"-DHAVE_GETADDRINFO=1",
"-DHAVE_GETADDRINFO_THREADSAFE=1",
"-DHAVE_GETEUID=1",
"-DHAVE_GETHOSTBYNAME=1",
"-DHAVE_GETHOSTBYNAME_R=1",
"-DHAVE_GETHOSTBYNAME_R_6=1",
"-DHAVE_GETHOSTNAME=1",
"-DHAVE_GETIFADDRS=1",
"-DHAVE_GETPPID=1",
"-DHAVE_GETPWUID=1",
"-DHAVE_GETPWUID_R=1",
"-DHAVE_GETRLIMIT=1",
"-DHAVE_GETSOCKNAME=1",
"-DHAVE_GETTIMEOFDAY=1",
"-DHAVE_GMTIME_R=1",
"-DHAVE_IFADDRS_H=1",
"-DHAVE_IF_NAMETOINDEX=1",
"-DHAVE_INET_NTOP=1",
"-DHAVE_INET_PTON=1",
"-DHAVE_INTTYPES_H=1",
"-DHAVE_IOCTL=1",
"-DHAVE_IOCTL_FIONBIO=1",
"-DHAVE_IOCTL_SIOCGIFADDR=1",
"-DHAVE_LIBGEN_H=1",
"-DHAVE_LL=1",
"-DHAVE_LOCALE_H=1",
"-DHAVE_LOCALTIME_R=1",
"-DHAVE_LONGLONG=1",
"-DHAVE_MALLOC_H=1",
"-DHAVE_MEMORY_H=1",
"-DHAVE_NETDB_H=1",
"-DHAVE_NETINET_IN_H=1",
"-DHAVE_NETINET_TCP_H=1",
"-DHAVE_NET_IF_H=1",
"-DHAVE_PIPE=1",
"-DHAVE_POLL=1",
"-DHAVE_POLL_FINE=1",
"-DHAVE_POLL_H=1",
"-DHAVE_POSIX_STRERROR_R=1",
"-DHAVE_PTHREAD_H=1",
"-DHAVE_PWD_H=1",
"-DHAVE_RECV=1",
"-DHAVE_SA_FAMILY_T=1",
"-DHAVE_SELECT=1",
"-DHAVE_SEND=1",
"-DHAVE_SETJMP_H=1",
"-DHAVE_SETLOCALE=1",
"-DHAVE_SETRLIMIT=1",
"-DHAVE_SETSOCKOPT=1",
"-DHAVE_SIGACTION=1",
"-DHAVE_SIGINTERRUPT=1",
"-DHAVE_SIGNAL=1",
"-DHAVE_SIGNAL_H=1",
"-DHAVE_SIGSETJMP=1",
"-DHAVE_SNPRINTF=1",
"-DHAVE_SOCKADDR_IN6_SIN6_SCOPE_ID=1",
"-DHAVE_SOCKET=1",
"-DHAVE_SOCKETPAIR=1",
"-DHAVE_STDBOOL_H=1",
"-DHAVE_STDINT_H=1",
"-DHAVE_STDIO_H=1",
"-DHAVE_STDLIB_H=1",
"-DHAVE_STRCASECMP=1",
"-DHAVE_STRDUP=1",
"-DHAVE_STRERROR_R=1",
"-DHAVE_STRINGS_H=1",
"-DHAVE_STRING_H=1",
"-DHAVE_STRNCASECMP=1",
"-DHAVE_STRSTR=1",
"-DHAVE_STRTOK_R=1",
"-DHAVE_STRTOLL=1",
"-DHAVE_STRUCT_SOCKADDR_STORAGE=1",
"-DHAVE_STRUCT_TIMEVAL=1",
"-DHAVE_SYS_IOCTL_H=1",
"-DHAVE_SYS_PARAM_H=1",
"-DHAVE_SYS_POLL_H=1",
"-DHAVE_SYS_RESOURCE_H=1",
"-DHAVE_SYS_SELECT_H=1",
"-DHAVE_SYS_SOCKET_H=1",
"-DHAVE_SYS_STAT_H=1",
"-DHAVE_SYS_TIME_H=1",
"-DHAVE_SYS_TYPES_H=1",
"-DHAVE_SYS_UIO_H=1",
"-DHAVE_SYS_UN_H=1",
"-DHAVE_SYS_WAIT_H=1",
"-DHAVE_SYS_XATTR_H=1",
"-DHAVE_TERMIOS_H=1",
"-DHAVE_TERMIO_H=1",
"-DHAVE_TIME_H=1",
"-DHAVE_UNISTD_H=1",
"-DHAVE_UTIME=1",
"-DHAVE_UTIMES=1",
"-DHAVE_UTIME_H=1",
"-DHAVE_VARIADIC_MACROS_C99=1",
"-DHAVE_VARIADIC_MACROS_GCC=1",
"-DHAVE_WRITABLE_ARGV=1",
"-DHAVE_WRITEV=1",
"-DRECV_TYPE_ARG1=int",
"-DRECV_TYPE_ARG2=void*",
"-DRECV_TYPE_ARG3=size_t",
"-DRECV_TYPE_ARG4=int",
"-DRECV_TYPE_RETV=ssize_t",
"-DSELECT_QUAL_ARG5=",
"-DSELECT_TYPE_ARG1=int",
"-DSELECT_TYPE_ARG234=fd_set*",
"-DSELECT_TYPE_RETV=int",
"-DSEND_QUAL_ARG2=const",
"-DSEND_TYPE_ARG1=int",
"-DSEND_TYPE_ARG2=void*",
"-DSEND_TYPE_ARG3=size_t",
"-DSEND_TYPE_ARG4=int",
"-DSEND_TYPE_RETV=ssize_t",
"-DSIZEOF_CURL_OFF_T=8",
"-DSIZEOF_INT=4",
"-DSIZEOF_LONG=8",
"-DSIZEOF_OFF_T=8",
"-DSIZEOF_SHORT=2",
"-DSIZEOF_SIZE_T=8",
"-DSIZEOF_TIME_T=8",
"-DSTDC_HEADERS=1",
"-DSTRERROR_R_TYPE_ARG3=size_t",
"-DTIME_WITH_SYS_TIME=1",
"-DUSE_THREADS_POSIX=1",
"-DUSE_UNIX_SOCKETS=1",
# Extra defines needed by curl
"-DBUILDING_LIBCURL",
"-DCURL_HIDDEN_SYMBOLS",
]
LINUX_CURL_COPTS = [
"-DHAVE_LINUX_TCP_H=1",
"-DHAVE_MSG_NOSIGNAL=1",
]
CURL_COPTS = select({
"//:windows": [
# Disable everything else except HTTP protocol.
"/DHTTP_ONLY=1",
"/DCURL_STATICLIB",
"/DWIN32",
"/DBUILDING_LIBCURL",
"/DUSE_WIN32_IDN",
"/DWANT_IDN_PROTOTYPES",
"/DUSE_IPV6",
"/DUSE_WINDOWS_SSPI",
"/DUSE_SCHANNEL",
],
"//:osx": BASE_CURL_COPTS,
"//conditions:default": BASE_CURL_COPTS + LINUX_CURL_COPTS,
})

View File

@@ -0,0 +1,4 @@
#pragma once
#define {BASE_NAME}_EXPORT
#define {BASE_NAME}_NO_EXPORT

View File

@@ -0,0 +1,21 @@
def _generate_dummy_export_header_impl(ctx):
ctx.actions.expand_template(
template = ctx.file._template,
output = ctx.outputs.header_file,
substitutions = {
"{BASE_NAME}": ctx.attr.basename,
},
)
generate_dummy_export_header = rule(
attrs = {
"basename": attr.string(mandatory = True),
"header": attr.string(mandatory = True),
"_template": attr.label(
allow_single_file = True,
default = Label("@com_github_jupp0r_prometheus_cpp//bazel:dummy_export.h.tpl"),
),
},
implementation = _generate_dummy_export_header_impl,
outputs = {"header_file": "%{header}"},
)

View File

@@ -0,0 +1,74 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
def prometheus_cpp_repositories():
maybe(
http_archive,
name = "civetweb",
strip_prefix = "civetweb-1.16",
sha256 = "f0e471c1bf4e7804a6cfb41ea9d13e7d623b2bcc7bc1e2a4dd54951a24d60285",
urls = [
"https://github.com/civetweb/civetweb/archive/v1.16.tar.gz",
],
build_file = "@com_github_jupp0r_prometheus_cpp//bazel:civetweb.BUILD",
)
# These legacy style repos have bzlmod support, they are re-added here for legacy support
maybe(
http_archive,
name = "com_github_curl",
sha256 = "f91249c87f68ea00cf27c44fdfa5a78423e41e71b7d408e5901a9896d905c495",
strip_prefix = "curl-8.7.1",
urls = [
"https://github.com/curl/curl/releases/download/curl-8_7_1/curl-8.7.1.tar.gz",
"https://curl.haxx.se/download/curl-8.7.1.tar.gz",
],
build_file = "@com_github_jupp0r_prometheus_cpp//bazel:curl.BUILD",
)
maybe(
http_archive,
name = "com_google_googletest",
sha256 = "81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2",
strip_prefix = "googletest-release-1.12.1",
urls = [
"https://github.com/google/googletest/archive/release-1.12.1.tar.gz",
],
)
maybe(
http_archive,
name = "com_github_google_benchmark",
sha256 = "6bc180a57d23d4d9515519f92b0c83d61b05b5bab188961f36ac7b06b0d9e9ce",
strip_prefix = "benchmark-1.8.3",
urls = [
"https://github.com/google/benchmark/archive/v1.8.3.tar.gz",
],
)
maybe(
http_archive,
name = "boringssl",
# Use github mirror instead of https://boringssl.googlesource.com/boringssl
# to obtain a boringssl archive with consistent sha256
sha256 = "b21994a857a7aa6d5256ffe355c735ad4c286de44c6c81dfc04edc41a8feaeef",
strip_prefix = "boringssl-2ff4b968a7e0cfee66d9f151cb95635b43dc1d5b",
urls = [
"https://github.com/google/boringssl/archive/2ff4b968a7e0cfee66d9f151cb95635b43dc1d5b.tar.gz",
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/boringssl/archive/2ff4b968a7e0cfee66d9f151cb95635b43dc1d5b.tar.gz",
],
)
maybe(
http_archive,
name = "zlib",
sha256 = "b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30",
strip_prefix = "zlib-1.2.13",
urls = [
"https://mirror.bazel.build/zlib.net/zlib-1.2.13.tar.gz",
"https://zlib.net/zlib-1.2.13.tar.gz",
"https://storage.googleapis.com/bazel-mirror/zlib.net/zlib-1.2.13.tar.gz",
],
build_file = "@com_github_jupp0r_prometheus_cpp//bazel:zlib.BUILD",
)

22
third_party/prometheus/bazel/zlib.BUILD vendored Normal file
View File

@@ -0,0 +1,22 @@
# copied from: https://github.com/bazelbuild/bazel/blob/master/third_party/zlib/BUILD
licenses(["notice"]) # BSD/MIT-like license (for zlib)
cc_library(
name = "zlib",
srcs = glob(["*.c"]),
hdrs = glob(["*.h"]),
# Use -Dverbose=-1 to turn off zlib's trace logging. (bazelbuild/bazel#3280)
copts = [
"-w",
"-Dverbose=-1",
],
includes = ["."],
local_defines = select({
"@bazel_tools//src/conditions:windows": [],
"//conditions:default": [
"Z_HAVE_UNISTD_H",
],
}),
visibility = ["//visibility:public"],
)