Skip to content

Commit

Permalink
chore: move base64 implementation into internal utility library
Browse files Browse the repository at this point in the history
  • Loading branch information
gjasny committed Dec 18, 2023
1 parent 5de72e8 commit bd80293
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 21 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -125,6 +125,7 @@ endif()
# prometheus-cpp

add_subdirectory(core)
add_subdirectory(util)

if(ENABLE_PULL)
add_subdirectory(pull)
Expand Down
1 change: 1 addition & 0 deletions pull/BUILD.bazel
Expand Up @@ -22,6 +22,7 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
"//core",
"//util",
"@civetweb",
"@zlib",
],
Expand Down
3 changes: 1 addition & 2 deletions pull/CMakeLists.txt
Expand Up @@ -31,8 +31,6 @@ add_library(pull
src/handler.h
src/metrics_collector.cc
src/metrics_collector.h

src/detail/base64.h
)

add_library(${PROJECT_NAME}::pull ALIAS pull)
Expand All @@ -46,6 +44,7 @@ target_link_libraries(pull
PUBLIC
${PROJECT_NAME}::core
PRIVATE
${PROJECT_NAME}::util
Threads::Threads
$<IF:$<BOOL:${USE_THIRDPARTY_LIBRARIES}>,${PROJECT_NAME}::civetweb,civetweb::civetweb-cpp>
$<$<AND:$<BOOL:UNIX>,$<NOT:$<BOOL:APPLE>>>:rt>
Expand Down
2 changes: 1 addition & 1 deletion pull/src/basic_auth.cc
Expand Up @@ -3,7 +3,7 @@
#include <utility>

#include "CivetServer.h"
#include "detail/base64.h"
#include "prometheus/detail/base64.h"

namespace prometheus {

Expand Down
1 change: 0 additions & 1 deletion pull/tests/CMakeLists.txt
@@ -1,3 +1,2 @@
add_subdirectory(integration)
add_subdirectory(internal)
add_subdirectory(unit)
14 changes: 0 additions & 14 deletions pull/tests/internal/CMakeLists.txt

This file was deleted.

12 changes: 12 additions & 0 deletions util/BUILD.bazel
@@ -0,0 +1,12 @@
cc_library(
name = "util",
srcs = glob([
"src/**/*.cc",
"src/**/*.h",
]),
hdrs = glob(
["include/**/*.h"],
),
strip_include_prefix = "include",
visibility = ["//:__subpackages__"],
)
33 changes: 33 additions & 0 deletions util/CMakeLists.txt
@@ -0,0 +1,33 @@
add_library(util INTERFACE
include/prometheus/detail/base64.h
)

add_library(${PROJECT_NAME}::util ALIAS util)

target_compile_features(util
INTERFACE
cxx_std_11
)

target_include_directories(util
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

set_target_properties(util
PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}-util
)

install(
TARGETS util
EXPORT ${PROJECT_NAME}-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

if(ENABLE_TESTING)
add_subdirectory(tests)
endif()
File renamed without changes.
1 change: 1 addition & 0 deletions util/tests/CMakeLists.txt
@@ -0,0 +1 @@
add_subdirectory(unit)
@@ -1,13 +1,13 @@
cc_test(
name = "internal",
name = "unit",
srcs = glob([
"*.cc",
"*.h",
]),
copts = ["-Iexternal/googletest/include"],
linkstatic = True,
deps = [
"//pull:pull_internal_headers",
"//util",
"@com_google_googletest//:gtest_main",
],
)
15 changes: 15 additions & 0 deletions util/tests/unit/CMakeLists.txt
@@ -0,0 +1,15 @@
add_executable(prometheus_util_test
base64_test.cc
)

target_link_libraries(prometheus_util_test
PUBLIC
${PROJECT_NAME}::util
PRIVATE
GTest::gmock_main
)

add_test(
NAME prometheus_util_test
COMMAND prometheus_util_test
)
@@ -1,4 +1,4 @@
#include "detail/base64.h"
#include "prometheus/detail/base64.h"

#include <gtest/gtest.h>

Expand Down

0 comments on commit bd80293

Please sign in to comment.