Skip to content
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e381d4c
ci: Add tasks for linting with clang-tidy.
davidlion Jun 9, 2025
6032e98
git mistake
davidlion Jun 9, 2025
1caca4b
Add BufferParser.hpp to exclude list for macos.
davidlion Jun 9, 2025
e4efbfa
Remove check-cmake.
davidlion Jun 9, 2025
d1560fb
Update yaml lint naming.
davidlion Jun 9, 2025
3626dbe
Add ReaderParser.hpp to exclude list for macos.
davidlion Jun 9, 2025
7683363
Merge branch 'main' into clang-tidy
davidlion Jun 9, 2025
2b87093
Merge remote-tracking branch 'upstream/main' into lint-cmake
davidlion Jul 11, 2025
9543431
Add fix-cmake.
davidlion Jul 11, 2025
aaa4b04
Merge branch 'main' into clang-tidy
davidlion Jul 11, 2025
13f0bd7
Add more files to exclude.
davidlion Jul 11, 2025
9ab5e16
Merge remote-tracking branch 'upstream/main' into lint-cmake
davidlion Jul 11, 2025
6546ee8
Merge branch 'clang-tidy' into lint-cmake
davidlion Jul 11, 2025
78552d0
Fix merging.
davidlion Jul 11, 2025
3925898
Import deps.yaml.
davidlion Jul 11, 2025
7953b1f
Merge branch 'main' into clang-tidy
davidlion Jul 12, 2025
1d2b8e5
Rename lint.yml to lint.yaml.
davidlion Jul 12, 2025
27f5e32
clang-tidy workaround
davidlion Jul 12, 2025
c8fca75
Add sudo.
davidlion Jul 12, 2025
af32abd
Fix to clang-20.
davidlion Jul 12, 2025
1523731
Merge remote-tracking branch 'upstream/main' into clang-tidy
davidlion Jul 16, 2025
02ad628
Build tasks working. Examples tasks need refactor.
davidlion Jul 18, 2025
49f7c25
Refactor examples.
davidlion Jul 22, 2025
b93fb26
Merge remote-tracking branch 'upstream/main' into clang-tidy
davidlion Jul 31, 2025
9c7c838
Update lint.yaml, running with failures.
davidlion Jul 31, 2025
f331277
Bump dev-utils.
davidlion Jul 31, 2025
dbc6663
Build compile_commands for exampels by default.
davidlion Aug 1, 2025
e7e747f
lint task overhaul.
davidlion Aug 1, 2025
da54c57
Fix common files in examples so clang-tidy doesn't fail with all exam…
davidlion Aug 1, 2025
c8ba98c
Fix check-cpp-static-log-surgeon alias.
davidlion Aug 1, 2025
834aea1
Undo yml rename for this PR.
davidlion Aug 1, 2025
158543d
Remove old script.
davidlion Aug 1, 2025
1753510
add uv to workflows.
davidlion Aug 1, 2025
4428af4
Update readme.
davidlion Aug 1, 2025
802911c
Fix args size.
davidlion Aug 1, 2025
0a0e3de
Fix build issue maybe related to clang 20.1.8 vs 20.1.6.
davidlion Aug 1, 2025
9d07d11
autocomplete too lit.
davidlion Aug 1, 2025
c0f7e66
Merge branch 'clang-tidy' into lint-cmake
davidlion Aug 2, 2025
30308ec
Update lint.yaml cmake code.
davidlion Aug 2, 2025
77a8d8a
Add gersemi config file.
davidlion Aug 2, 2025
e5ba779
Add gersemi fixes.
davidlion Aug 2, 2025
3ba6934
Merge remote-tracking branch 'upstream/main' into clang-tidy
davidlion Aug 2, 2025
621dc69
Merge branch 'clang-tidy' into lint-cmake
davidlion Aug 2, 2025
f25da50
Merge branch 'main' into clang-tidy
davidlion Aug 4, 2025
2698e1d
Fix merge mistake.
davidlion Aug 5, 2025
80e6243
Merge branch 'clang-tidy' into lint-cmake
davidlion Aug 5, 2025
1795542
Merge remote-tracking branch 'upstream/main' into lint-cmake
davidlion Aug 5, 2025
9e9e271
Add check/fix cmake to check/fix tasks.
davidlion Aug 6, 2025
ffab4aa
Merge branch 'main' into lint-cmake
davidlion Aug 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gersemirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# yamllint disable-line rule:line-length
# yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/master/gersemi/configuration.schema.json

definitions:
- "build/deps/Catch2-extracted/extras/Catch.cmake"
- "examples/CMakeLists.txt"

line_length: 100
list_expansion: "favour-expansion"
141 changes: 79 additions & 62 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
cmake_minimum_required(VERSION 3.22.1)

project(log_surgeon
project(
log_surgeon
VERSION 0.0.1
DESCRIPTION "log-surgeon: A performant log parsing library"
HOMEPAGE_URL https://github.com/y-scope/log-surgeon
LANGUAGES CXX
)
LANGUAGES
CXX
)

if (POLICY CMP0077)
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()

Expand All @@ -24,7 +26,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS
FORCE
)

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(default_build_type "Release")
message(STATUS "No build type specified. Setting to '${default_build_type}'.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
Expand Down Expand Up @@ -112,105 +114,120 @@ set(SOURCE_FILES
src/log_surgeon/Token.hpp
src/log_surgeon/types.hpp
src/log_surgeon/UniqueIdGenerator.hpp
)
)

set(LOG_SURGEON_INSTALL_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/log_surgeon)
set(LOG_SURGEON_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR})

add_library(log_surgeon ${SOURCE_FILES})
add_library(log_surgeon::log_surgeon ALIAS log_surgeon)

target_link_libraries(log_surgeon
target_link_libraries(
log_surgeon
PUBLIC
fmt::fmt
Microsoft.GSL::GSL
)
fmt::fmt
Microsoft.GSL::GSL
)

target_include_directories(log_surgeon
PUBLIC
target_include_directories(
log_surgeon
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
)

target_compile_features(log_surgeon
PRIVATE cxx_std_20
)
target_compile_features(log_surgeon PRIVATE cxx_std_20)

target_compile_options(log_surgeon PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic -Werror>
)
target_compile_options(
log_surgeon
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4
/WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall
-Wextra
-Wpedantic
-Werror>
)
Comment on lines +143 to +152
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Same generator-expression split here – will break the top-level build

The target_compile_options(log_surgeon …) block contains the identical line-break issue as flagged in examples/CMakeLists.txt. Merge the arguments so each $<…> expression stays contiguous:

-        $<$<CXX_COMPILER_ID:MSVC>:/W4
-        /WX>
-        $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall
-        -Wextra
-        -Wpedantic
-        -Werror>
+        $<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
+        $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic -Werror>

Without this fix, cmake .. fails with “Error evaluating generator expression”.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
target_compile_options(
log_surgeon
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4
/WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall
-Wextra
-Wpedantic
-Werror>
)
target_compile_options(
log_surgeon
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic -Werror>
)
🤖 Prompt for AI Agents
In CMakeLists.txt lines 143 to 152, the target_compile_options call splits
generator expressions across multiple lines, causing CMake to fail with an
"Error evaluating generator expression." Fix this by merging each generator
expression into a single contiguous line without line breaks inside the $<...>
expressions, ensuring the entire expression is continuous and properly parsed by
CMake.


# Disable -Wstringop-overflow to avoid a false positive in the following compiler versions.
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117983
if("GNU" STREQUAL "${CMAKE_CXX_COMPILER_ID}"
AND ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.5)
OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.4)
OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14.3)))
if(
"GNU"
STREQUAL
"${CMAKE_CXX_COMPILER_ID}"
AND (
(
CMAKE_CXX_COMPILER_VERSION
VERSION_GREATER_EQUAL
12
AND CMAKE_CXX_COMPILER_VERSION
VERSION_LESS
12.5
)
OR (
CMAKE_CXX_COMPILER_VERSION
VERSION_GREATER_EQUAL
13
AND CMAKE_CXX_COMPILER_VERSION
VERSION_LESS
13.4
)
OR (
CMAKE_CXX_COMPILER_VERSION
VERSION_GREATER_EQUAL
14
AND CMAKE_CXX_COMPILER_VERSION
VERSION_LESS
14.3
)
)
)
target_compile_options(log_surgeon PRIVATE "-Wno-stringop-overflow")
endif()

# Make off_t 64-bit
target_compile_definitions(log_surgeon
PRIVATE
_FILE_OFFSET_BITS=64
)
target_compile_definitions(log_surgeon PRIVATE _FILE_OFFSET_BITS=64)

install(
TARGETS
log_surgeon
EXPORT
log_surgeon-targets
)
install(TARGETS log_surgeon EXPORT log_surgeon-targets)

install(
EXPORT
log_surgeon-targets
NAMESPACE
log_surgeon::
DESTINATION
${LOG_SURGEON_INSTALL_CONFIG_DIR}
)
EXPORT log_surgeon-targets
NAMESPACE log_surgeon::
DESTINATION ${LOG_SURGEON_INSTALL_CONFIG_DIR}
)

install(
DIRECTORY
"${PROJECT_SOURCE_DIR}/src/log_surgeon"
DESTINATION
"${LOG_SURGEON_INSTALL_INCLUDE_DIR}"
"${PROJECT_SOURCE_DIR}/src/log_surgeon"
DESTINATION "${LOG_SURGEON_INSTALL_INCLUDE_DIR}"
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
PATTERN "*.tpp"
)
)

configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/log_surgeon-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/log_surgeon-config.cmake
INSTALL_DESTINATION
${LOG_SURGEON_INSTALL_CONFIG_DIR}
INSTALL_DESTINATION ${LOG_SURGEON_INSTALL_CONFIG_DIR}
PATH_VARS
LOG_SURGEON_INSTALL_INCLUDE_DIR
)
LOG_SURGEON_INSTALL_INCLUDE_DIR
)

write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/log_surgeon-config-version.cmake
COMPATIBILITY
SameMajorVersion
)
COMPATIBILITY SameMajorVersion
)

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/log_surgeon-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/log_surgeon-config-version.cmake
DESTINATION
${LOG_SURGEON_INSTALL_CONFIG_DIR}
)
${CMAKE_CURRENT_BINARY_DIR}/log_surgeon-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/log_surgeon-config-version.cmake
DESTINATION ${LOG_SURGEON_INSTALL_CONFIG_DIR}
)

if (log_surgeon_ENABLE_TESTS)
if(log_surgeon_ENABLE_TESTS)
add_subdirectory(tests)
endif()
30 changes: 23 additions & 7 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS
FORCE
)

if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(default_build_type "Release")
message(STATUS "No build type specified. Setting to '${default_build_type}'.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
Expand All @@ -27,16 +27,32 @@ message(STATUS "Found log_surgeon ${log_surgeon_VERSION}.")
function(add_to_target target libraries)
target_link_libraries(${target} ${libraries})
target_compile_features(${target} PRIVATE cxx_std_20)
target_compile_options(${target} PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic -Werror>
)
target_compile_options(
${target}
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4
/WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall
-Wextra
-Wpedantic
-Werror>
)
Comment on lines +30 to +39
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Broken generator expression – will fail CMake configure

target_compile_options splits each generator expression across two arguments:

$<$<CXX_COMPILER_ID:MSVC>:/W4
/WX>

CMake treats a generator expression as a single, unbroken argument; splitting it inserts an unintended line break that terminates the expression early and produces a “syntax error in generator expression” at configure time.

-    target_compile_options(
-        ${target}
-        PRIVATE
-            $<$<CXX_COMPILER_ID:MSVC>:/W4
-            /WX>
-            $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall
-            -Wextra
-            -Wpedantic
-            -Werror>
-    )
+    target_compile_options(
+        ${target}
+        PRIVATE
+            $<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
+            $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic -Werror>
+    )

The same pattern recurs in the root CMakeLists.txt; please fix there as well.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
target_compile_options(
${target}
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4
/WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall
-Wextra
-Wpedantic
-Werror>
)
target_compile_options(
${target}
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic -Werror>
)
🤖 Prompt for AI Agents
In examples/CMakeLists.txt around lines 30 to 39, the generator expressions in
target_compile_options are split across multiple lines, causing CMake to treat
them as separate arguments and resulting in a syntax error. To fix this, rewrite
each generator expression as a single continuous string without line breaks,
ensuring the entire expression is passed as one argument. Also, apply the same
fix to the root CMakeLists.txt where this pattern occurs.

endfunction()

add_library(common OBJECT common.cpp common.hpp)
add_library(
common
OBJECT
common.cpp
common.hpp
)
add_to_target(common log_surgeon::log_surgeon)

list(APPEND libraries log_surgeon::log_surgeon common)
list(
APPEND
libraries
log_surgeon::log_surgeon
common
)

add_executable(buffer-parser buffer-parser.cpp)
add_to_target(buffer-parser "${libraries}")
Expand Down
1 change: 1 addition & 0 deletions lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
clang-format>=20.1
clang-tidy>=20.1
gersemi>=0.16.2
yamllint>=1.35.1
40 changes: 39 additions & 1 deletion taskfiles/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
version: "3"

includes:
deps:
internal: true
taskfile: "deps.yaml"
examples:
internal: true
taskfile: "examples.yaml"
Expand All @@ -14,7 +17,11 @@ includes:
vars:
# General linting variables
G_LINT_VENV_DIR: "{{.G_BUILD_DIR}}/lint-venv"
G_UTILS_CONFIGS_DIR: "{{.ROOT_DIR}}/tools/yscope-dev-utils/exports/lint-configs"

# Utils directories
G_UTILS_EXPORTS_DIR: "{{.ROOT_DIR}}/tools/yscope-dev-utils/exports"
G_UTILS_CONFIGS_DIR: "{{.G_UTILS_EXPORTS_DIR}}/lint-configs"
G_UTILS_YSTDLIB_PY_DIR: "{{.G_UTILS_EXPORTS_DIR}}/ystdlib-py"

# Root paths for source files
G_LOG_SURGEON_ROOT_PATHS:
Expand Down Expand Up @@ -42,6 +49,12 @@ tasks:
- task: "check-cpp"
- task: "check-yaml"

check-cmake:
cmds:
- task: "gersemi"
vars:
FLAGS: "--check"

check-cpp:
cmds:
- task: "check-cpp-format-examples"
Expand Down Expand Up @@ -182,6 +195,12 @@ tasks:
- task: "fix-cpp"
- task: "fix-yaml"

fix-cmake:
cmds:
- task: "gersemi"
vars:
FLAGS: "--in-place"

fix-cpp:
cmds:
- task: "fix-cpp-format-examples"
Expand Down Expand Up @@ -247,6 +266,25 @@ tasks:
ref: ".G_LOG_SURGEON_ROOT_PATHS"
VENV_DIR: "{{.G_LINT_VENV_DIR}}"

gersemi:
internal: true
label: "{{.TASK}}:{{.FLAGS}}"
requires:
vars:
- "FLAGS"
deps:
- "deps:install-all"
- "venv"
cmd: |-
. "{{.G_LINT_VENV_DIR}}/bin/activate"
uv run --project "{{.G_UTILS_YSTDLIB_PY_DIR}}" pyfind \
"{{.ROOT_DIR}}" \
--exclude "build/**/*" \
--exclude "tools/**/*" \
--filename "CMakeLists.txt" \
--filename "*.cmake" \
| xargs gersemi {{.FLAGS}}

venv:
internal: true
vars:
Expand Down
26 changes: 16 additions & 10 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
add_executable(unit-test)
target_sources(unit-test
target_sources(
unit-test
PRIVATE
test-buffer-parser.cpp
test-capture.cpp
test-dfa.cpp
test-nfa.cpp
test-prefix-tree.cpp
test-regex-ast.cpp
test-register-handler.cpp
test-schema.cpp
test-buffer-parser.cpp
test-capture.cpp
test-dfa.cpp
test-nfa.cpp
test-prefix-tree.cpp
test-regex-ast.cpp
test-register-handler.cpp
test-schema.cpp
)

target_link_libraries(unit-test PRIVATE Catch2::Catch2WithMain log_surgeon::log_surgeon)
target_link_libraries(
unit-test
PRIVATE
Catch2::Catch2WithMain
log_surgeon::log_surgeon
)
target_compile_features(unit-test PRIVATE cxx_std_20)

catch_discover_tests(unit-test)
Loading