Skip to content

Commit

Permalink
Fix gersemi (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
egecetin authored Dec 25, 2024
1 parent 447bae5 commit a2c67d1
Show file tree
Hide file tree
Showing 12 changed files with 354 additions and 247 deletions.
3 changes: 3 additions & 0 deletions .gersemirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
indent: 2
line_length: 120
warn_about_unknown_commands: false
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
rev: 0.17.1
hooks:
- id: gersemi
args: ['--line-length', '120']
args: ['-c']
- repo: https://github.com/lovesegfault/beautysh
rev: v6.2.1
hooks:
Expand Down
102 changes: 56 additions & 46 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ set(SENTRY_BACKEND none) # Disable backend to manually use crashpad
configure_file(Version.h.in "Version.h")

# Define sources
file(GLOB ProjectSources
file(
GLOB ProjectSources
${PROJECT_SOURCE_DIR}/src/connection/Http.cpp
${PROJECT_SOURCE_DIR}/src/connection/RawSocket.cpp
${PROJECT_SOURCE_DIR}/src/logging/Logger.cpp
Expand Down Expand Up @@ -105,34 +106,37 @@ include_directories(${PROJECT_SOURCE_DIR}/thirdparty/sentry/external/crashpad/th

# Add breakpad to compile dump_syms and minidump_stackwalk
if(XXX_ENABLE_SYMBOL_GENERATION)
file(COPY ${PROJECT_SOURCE_DIR}/thirdparty/sentry/external/third_party
DESTINATION ${PROJECT_SOURCE_DIR}/thirdparty/sentry/external/breakpad/src/)
file(
COPY ${PROJECT_SOURCE_DIR}/thirdparty/sentry/external/third_party
DESTINATION ${PROJECT_SOURCE_DIR}/thirdparty/sentry/external/breakpad/src/
)

ExternalProject_Add(breakpad
ExternalProject_Add(
breakpad
SOURCE_DIR ${PROJECT_SOURCE_DIR}/thirdparty/sentry/external/breakpad
BINARY_DIR ${CMAKE_BINARY_DIR}/breakpad_bin
CONFIGURE_COMMAND "<SOURCE_DIR>/configure"
BUILD_COMMAND make -j2 # Prevent OOM for the virtual machines when parallel compilation invoked
INSTALL_COMMAND "")
BUILD_COMMAND
make -j2 # Prevent OOM for the virtual machines when parallel compilation invoked
INSTALL_COMMAND ""
)
endif()

# Set Targets
add_library(${PROJECT_NAME}-lib SHARED ${ProjectSources})
set_target_properties(
${PROJECT_NAME}-lib
PROPERTIES OUTPUT_NAME ${PROJECT_NAME}
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
SOVERSION ${PROJECT_VERSION_MAJOR})
PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
SOVERSION ${PROJECT_VERSION_MAJOR}
)
target_compile_options(${PROJECT_NAME}-lib PRIVATE -Wall -Wextra -g -Wl,--build-id)
target_include_directories(${PROJECT_NAME}-lib PRIVATE ${PROJECT_BINARY_DIR})
target_link_libraries(
${PROJECT_NAME}-lib PUBLIC
cppzmq
crashpad::client
CURL::libcurl
prometheus-cpp::pull
sentry::sentry
spdlog::spdlog)
${PROJECT_NAME}-lib
PUBLIC cppzmq crashpad::client CURL::libcurl prometheus-cpp::pull sentry::sentry spdlog::spdlog
)
enable_security_flags_for_target(${PROJECT_NAME}-lib)

if(XXX_ENABLE_SYMBOL_GENERATION)
Expand Down Expand Up @@ -176,9 +180,12 @@ if(XXX_ENABLE_PACKAGING)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.service DESTINATION /etc/systemd/system)

set(CPACK_PACKAGE_CONTACT "Ege Cetin <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION "C++ Application Template. It has already integrated a Telnet and ZeroMQ server to \
set(
CPACK_PACKAGE_DESCRIPTION
"C++ Application Template. It has already integrated a Telnet and ZeroMQ server to \
receive commands, Crashpad handler to generate minidump, a Prometheus server to broadcast performance metrics. \
Also, it can send logs to syslog using Spdlog, to a Sentry server and Grafana Loki instance")
Also, it can send logs to syslog using Spdlog, to a Sentry server and Grafana Loki instance"
)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Repository template for C++ applications")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_RELEASE 1)
Expand Down Expand Up @@ -209,8 +216,9 @@ Also, it can send logs to syslog using Spdlog, to a Sentry server and Grafana Lo
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E tar cfvz ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}-syms.tar.gz
--format=gnutar ${CMAKE_BINARY_DIR}/syms
COMMAND
${CMAKE_COMMAND} -E tar cfvz ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}-syms.tar.gz --format=gnutar
${CMAKE_BINARY_DIR}/syms
COMMENT "Creating tar gz archive from ${CMAKE_BINARY_DIR}/syms"
)
endif()
Expand All @@ -232,33 +240,35 @@ if(XXX_BUILD_TESTS)

if(XXX_ENABLE_COVERAGE)
setup_target_for_coverage_gcovr_html(
NAME
coverage
EXECUTABLE
${TestExecutables}
DEPENDENCIES
${TestExecutables}
EXCLUDE
"${PROJECT_SOURCE_DIR}/src/main.cpp"
"${PROJECT_SOURCE_DIR}/thirdparty/*"
"${PROJECT_SOURCE_DIR}/build/*"
"${PROJECT_SOURCE_DIR}/tests/gtest/*"
"${PROJECT_SOURCE_DIR}/tests/unittests/*"
"${PROJECT_SOURCE_DIR}/tests/fuzztests/*")
NAME
coverage
EXECUTABLE
${TestExecutables}
DEPENDENCIES
${TestExecutables}
EXCLUDE
"${PROJECT_SOURCE_DIR}/src/main.cpp"
"${PROJECT_SOURCE_DIR}/thirdparty/*"
"${PROJECT_SOURCE_DIR}/build/*"
"${PROJECT_SOURCE_DIR}/tests/gtest/*"
"${PROJECT_SOURCE_DIR}/tests/unittests/*"
"${PROJECT_SOURCE_DIR}/tests/fuzztests/*"
)

setup_target_for_coverage_gcovr_xml(
NAME
coverage-xml
EXECUTABLE
${TestExecutables}
DEPENDENCIES
${TestExecutables}
EXCLUDE
"${PROJECT_SOURCE_DIR}/src/main.cpp"
"${PROJECT_SOURCE_DIR}/thirdparty/*"
"${PROJECT_SOURCE_DIR}/build/*"
"${PROJECT_SOURCE_DIR}/tests/gtest/*"
"${PROJECT_SOURCE_DIR}/tests/unittests/*"
"${PROJECT_SOURCE_DIR}/tests/fuzztests/*")
NAME
coverage-xml
EXECUTABLE
${TestExecutables}
DEPENDENCIES
${TestExecutables}
EXCLUDE
"${PROJECT_SOURCE_DIR}/src/main.cpp"
"${PROJECT_SOURCE_DIR}/thirdparty/*"
"${PROJECT_SOURCE_DIR}/build/*"
"${PROJECT_SOURCE_DIR}/tests/gtest/*"
"${PROJECT_SOURCE_DIR}/tests/unittests/*"
"${PROJECT_SOURCE_DIR}/tests/fuzztests/*"
)
endif()
endif()
Loading

0 comments on commit a2c67d1

Please sign in to comment.