build(bazel): drop support for non-bazelmod builds

This commit is contained in:
Gregor Jasny
2024-11-03 13:56:02 +01:00
parent e5fada4313
commit dbdb5d90aa
16 changed files with 16 additions and 470 deletions
+5 -9
View File
@@ -29,24 +29,20 @@ jobs:
if: runner.os == 'macOS'
run: brew install telegraf
- name: Build with SSL (without bzlmod)
if: runner.os != 'macOS'
run: bazel build --noenable_bzlmod --config=ssl //...
- name: Build with SSL
if: runner.os != 'macOS'
run: bazel build --enable_bzlmod --config=ssl //...
run: bazel build --config=ssl //...
- name: Test with SSL
if: runner.os != 'macOS'
run: bazel test --enable_bzlmod --config=ssl --test_output=all //...
run: bazel test --config=ssl --test_output=all //...
- name: Build
run: bazel build --enable_bzlmod //...
run: bazel build //...
- name: Test
run: bazel test --enable_bzlmod --test_output=all //...
run: bazel test --test_output=all //...
- name: Scraping Test
if: runner.os != 'Windows'
run: bazel test --enable_bzlmod --test_output=all //pull/tests/integration:scrape-test
run: bazel test --test_output=all //pull/tests/integration:scrape-test
+3 -3
View File
@@ -6,10 +6,10 @@ module(
bazel_dep(name = "boringssl", version = "0.0.0-20240530-2db0eb3")
bazel_dep(name = "civetweb", version = "1.16")
bazel_dep(name = "curl", version = "8.7.1", repo_name = "com_github_curl")
bazel_dep(name = "curl", version = "8.7.1")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "zlib", version = "1.3.1")
bazel_dep(name = "google_benchmark", version = "1.8.3", dev_dependency = True, repo_name = "com_github_google_benchmark")
bazel_dep(name = "googletest", version = "1.12.1", dev_dependency = True, repo_name = "com_google_googletest")
bazel_dep(name = "google_benchmark", version = "1.8.3", dev_dependency = True)
bazel_dep(name = "googletest", version = "1.12.1", dev_dependency = True)
-5
View File
@@ -1,5 +0,0 @@
workspace(name = "com_github_jupp0r_prometheus_cpp")
load("//bazel:repositories.bzl", "prometheus_cpp_repositories")
prometheus_cpp_repositories()
-1
View File
@@ -1,6 +1,5 @@
exports_files(
glob([
"*.BUILD",
"*.tpl",
]),
visibility = ["//visibility:public"],
-105
View File
@@ -1,105 +0,0 @@
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
View File
@@ -1,60 +0,0 @@
# 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
View File
@@ -1,183 +0,0 @@
# 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,
})
-74
View File
@@ -1,74 +0,0 @@
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
View File
@@ -1,22 +0,0 @@
# 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"],
)
+1 -1
View File
@@ -7,6 +7,6 @@ cc_binary(
linkstatic = True,
deps = [
"//core",
"@com_github_google_benchmark//:benchmark",
"@google_benchmark//:benchmark",
],
)
+1 -1
View File
@@ -8,6 +8,6 @@ cc_test(
linkstatic = True,
deps = [
"//core",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest_main",
],
)
+2 -2
View File
@@ -44,7 +44,7 @@ cc_test(
linkstatic = True,
deps = [
"//pull",
"@com_github_curl//:curl",
"@com_google_googletest//:gtest_main",
"@curl",
"@googletest//:gtest_main",
],
)
+1 -1
View File
@@ -5,6 +5,6 @@ cc_test(
linkstatic = True,
deps = [
"//pull",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest_main",
],
)
+1 -1
View File
@@ -25,7 +25,7 @@ cc_library(
deps = [
"//core",
"//util",
"@com_github_curl//:curl",
"@curl",
],
)
+1 -1
View File
@@ -5,6 +5,6 @@ cc_test(
linkstatic = True,
deps = [
"//push:push_internal_headers",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest_main",
],
)
+1 -1
View File
@@ -5,6 +5,6 @@ cc_test(
linkstatic = True,
deps = [
"//util",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest_main",
],
)