From e381d4ce7ec10d78a51303dd940671b40e527c6f Mon Sep 17 00:00:00 2001 From: davidlion Date: Sun, 8 Jun 2025 23:51:10 -0400 Subject: [PATCH 01/27] ci: Add tasks for linting with clang-tidy. --- .clang-format | 161 ----------------------------------- lint-requirements.txt | 2 + taskfiles/build.yaml | 24 ++++-- taskfiles/lint.yaml | 193 ++++++++++++++++++++++++++++++++++-------- 4 files changed, 177 insertions(+), 203 deletions(-) delete mode 100644 .clang-format diff --git a/.clang-format b/.clang-format deleted file mode 100644 index b4723621..00000000 --- a/.clang-format +++ /dev/null @@ -1,161 +0,0 @@ -# yamllint disable-line rule:document-start ---- -ColumnLimit: 100 -IndentWidth: 4 -# yamllint disable-line rule:document-start ---- -Language: "Cpp" -AccessModifierOffset: -4 -AlignAfterOpenBracket: "BlockIndent" -AlignArrayOfStructures: "None" -AlignConsecutiveAssignments: "None" -AlignConsecutiveBitFields: "None" -AlignConsecutiveDeclarations: "None" -AlignConsecutiveMacros: "None" -AlignEscapedNewlines: "DontAlign" -AlignOperands: "Align" -AlignTrailingComments: - Kind: "Never" -AllowAllArgumentsOnNextLine: false -AllowAllParametersOfDeclarationOnNextLine: false -AllowBreakBeforeNoexceptSpecifier: "OnlyWithParen" -AllowShortBlocksOnASingleLine: "Always" -AllowShortCaseLabelsOnASingleLine: false -AllowShortCompoundRequirementOnASingleLine: true -AllowShortEnumsOnASingleLine: false -AllowShortFunctionsOnASingleLine: "Inline" -AllowShortIfStatementsOnASingleLine: "Never" -AllowShortLambdasOnASingleLine: "All" -AllowShortLoopsOnASingleLine: false -AllowShortNamespacesOnASingleLine: false -AlwaysBreakBeforeMultilineStrings: false -BinPackArguments: false -BinPackParameters: false -BitFieldColonSpacing: "Both" -BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterControlStatement: "MultiLine" - AfterEnum: false - AfterFunction: false - AfterNamespace: false - AfterExternBlock: false - AfterStruct: false - AfterUnion: false - BeforeCatch: false - BeforeElse: false - BeforeLambdaBody: false - BeforeWhile: false - IndentBraces: false - SplitEmptyFunction: false - SplitEmptyNamespace: false - SplitEmptyRecord: false -BreakAfterAttributes: "Never" -BreakAfterReturnType: "Automatic" -BreakBeforeBinaryOperators: "All" -BreakBeforeBraces: "Custom" -BreakBeforeConceptDeclarations: "Always" -BreakBeforeInlineASMColon: "OnlyMultiline" -BreakBeforeTernaryOperators: true -BreakBinaryOperations: "Never" -BreakConstructorInitializers: "BeforeColon" -BreakFunctionDefinitionParameters: false -BreakInheritanceList: "BeforeColon" -BreakStringLiterals: true -BreakTemplateDeclarations: "Yes" -CompactNamespaces: true -ConstructorInitializerIndentWidth: 8 -ContinuationIndentWidth: 8 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -EmptyLineAfterAccessModifier: "Never" -EmptyLineBeforeAccessModifier: "LogicalBlock" -FixNamespaceComments: true -IncludeBlocks: "Regroup" -IndentAccessModifiers: false -IndentCaseBlocks: false -IndentCaseLabels: true -IndentExportBlock: true -IndentExternBlock: "Indent" -IndentGotoLabels: false -IndentPPDirectives: "BeforeHash" -IndentRequiresClause: false -IndentWrappedFunctionNames: false -InsertBraces: true -InsertNewlineAtEOF: true -IntegerLiteralSeparator: - Binary: 4 - BinaryMinDigits: 4 - Decimal: 3 - DecimalMinDigits: 5 - Hex: 4 - HexMinDigits: 4 -KeepEmptyLines: - AtEndOfFile: true - AtStartOfBlock: false - AtStartOfFile: false -KeepFormFeed: false -LambdaBodyIndentation: "Signature" -LineEnding: "LF" -MainIncludeChar: "Quote" -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: "None" -PPIndentWidth: -1 -PackConstructorInitializers: "CurrentLine" -PenaltyBreakOpenParenthesis: 25 -PenaltyBreakBeforeFirstCallParameter: 25 -PenaltyReturnTypeOnItsOwnLine: 100 -PointerAlignment: "Left" -QualifierAlignment: "Custom" -QualifierOrder: - - "static" - - "friend" - - "inline" - # constexpr west as explained in https://www.youtube.com/watch?v=z6s6bacI424 - - "constexpr" - - "type" - - "const" - - "volatile" -ReferenceAlignment: "Pointer" -ReflowComments: "Always" -RemoveBracesLLVM: false -RemoveEmptyLinesInUnwrappedLines: true -RemoveSemicolon: true -RequiresClausePosition: "OwnLine" -RequiresExpressionIndentation: "OuterScope" -SeparateDefinitionBlocks: "Always" -ShortNamespaceLines: 0 -SortIncludes: "CaseInsensitive" -SortUsingDeclarations: "Lexicographic" -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: true -SpaceAroundPointerQualifiers: "Default" -SpaceBeforeAssignmentOperators: true -SpaceBeforeCaseColon: false -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: "ControlStatements" -SpaceBeforeRangeBasedForLoopColon: true -SpaceBeforeSquareBrackets: false -SpaceInEmptyBlock: false -SpacesBeforeTrailingComments: 2 -SpacesInAngles: false -SpacesInContainerLiterals: false -SpacesInLineCommentPrefix: - Minimum: 1 - Maximum: -1 -SpacesInParens: "Custom" -SpacesInParensOptions: - ExceptDoubleParentheses: false - InConditionalStatements: false - InCStyleCasts: false - InEmptyParentheses: false - Other: false -SpacesInSquareBrackets: false -Standard: "Latest" -TabWidth: 4 -UseTab: "Never" -WrapNamespaceBodyWithEmptyLines: "Never" diff --git a/lint-requirements.txt b/lint-requirements.txt index c2fcb6f6..dbf21dec 100644 --- a/lint-requirements.txt +++ b/lint-requirements.txt @@ -1,2 +1,4 @@ clang-format>=20.1 +clang-tidy>=20.1 +gersemi>=0.16.2 yamllint>=1.35.1 diff --git a/taskfiles/build.yaml b/taskfiles/build.yaml index e294f03e..23a8232b 100644 --- a/taskfiles/build.yaml +++ b/taskfiles/build.yaml @@ -80,14 +80,10 @@ tasks: requires: vars: ["BUILD_TYPE"] deps: - - "deps:all" - cmds: - - task: "utils:cmake:generate" + - task: "generate" vars: - BUILD_DIR: "{{.G_LOG_SURGEON_BUILD_DIR}}/{{.BUILD_TYPE}}" - EXTRA_ARGS: - - "-DCMAKE_BUILD_TYPE={{.BUILD_TYPE}}" - SOURCE_DIR: "{{.ROOT_DIR}}" + BUILD_TYPE: "{{.BUILD_TYPE}}" + cmds: - task: "utils:cmake:build" vars: BUILD_DIR: "{{.G_LOG_SURGEON_BUILD_DIR}}/{{.BUILD_TYPE}}" @@ -115,6 +111,20 @@ tasks: vars: BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/{{.BUILD_TYPE}}" + generate: + internal: true + requires: + vars: ["BUILD_TYPE"] + deps: + - "deps:all" + cmds: + - task: "utils:cmake:generate" + vars: + BUILD_DIR: "{{.G_LOG_SURGEON_BUILD_DIR}}/{{.BUILD_TYPE}}" + EXTRA_ARGS: + - "-DCMAKE_BUILD_TYPE={{.BUILD_TYPE}}" + SOURCE_DIR: "{{.ROOT_DIR}}" + install: internal: true requires: diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index 60bd3228..0f43215a 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -1,57 +1,173 @@ version: "3" includes: + build: + internal: true + taskfile: "./build.yaml" utils: internal: true taskfile: "../tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml" vars: G_LINT_VENV_DIR: "{{.G_BUILD_DIR}}/lint-venv" + G_UTILS_CONFIGS_DIR: "{{.ROOT_DIR}}/tools/yscope-dev-utils/exports/lint-configs" tasks: check: cmds: - - task: "cpp-check" + - task: "check-cpp-full" - task: "yaml-check" - fix: + check-cmake: cmds: - - task: "cpp-fix" - - task: "yaml-fix" + - task: "gersemi" + vars: + FLAGS: "--check" - cpp-check: + check-cpp-diff: + cmds: + - task: "check-cpp-format" + - task: "check-cpp-static-diff" + + check-cpp-full: + cmds: + - task: "check-cpp-format" + - task: "check-cpp-static-full" + + check-cpp-format: sources: &cpp_source_files + - "{{.ROOT_DIR}}/.clang-format" + - "{{.ROOT_DIR}}/.clang-tidy" + - "{{.ROOT_DIR}}/examples/**/*" + - "{{.ROOT_DIR}}/src/**/*" + - "{{.ROOT_DIR}}/tests/**/*" - "{{.TASKFILE}}" - - ".clang-format" - - "examples/**/*.cpp" - - "examples/**/*.h" - - "examples/**/*.hpp" - - "examples/**/*.tpp" - - "src/**/*.cpp" - - "src/**/*.h" - - "src/**/*.hpp" - - "src/**/*.tpp" - - "tests/**/*.cpp" - - "tests/**/*.h" - - "tests/**/*.hpp" - - "tests/**/*.tpp" + deps: + - "cpp-lint-configs" + - "venv" + cmds: + - task: "utils:cpp-lint:clang-format" + vars: + FLAGS: ["--dry-run"] + INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.tpp"] + ROOT_PATHS: *cpp_source_files + VENV_DIR: "{{.G_LINT_VENV_DIR}}" + + check-cpp-static-diff: + # NOTE: We alias the fix task until we determine which clang-tidy fixes can be applied safely. + aliases: ["fix-cpp-static-diff"] + sources: *cpp_source_files + deps: + - task: "build:generate" + vars: + BUILD_TYPE: "debug" + - "cpp-lint-configs" + - "venv" + cmds: + - task: "utils:cpp-lint:clang-tidy-diff" + vars: + FLAGS: + - "--config-file '{{.G_UTILS_CONFIGS_DIR}}/.clang-tidy'" + - "-p '{{.G_LOG_SURGEON_BUILD_DIR}}/debug'" + INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.tpp"] + OUTPUT_DIR: "{{.G_BUILD_DIR}}/lint-clang-tidy" + VENV_DIR: "{{.G_LINT_VENV_DIR}}" + + check-cpp-static-full: + # NOTE: We alias the fix task until we determine which clang-tidy fixes can be applied safely. + aliases: ["fix-cpp-static-full"] + deps: + - task: "build:generate" + vars: + BUILD_TYPE: "debug" + - "cpp-lint-configs" + - "venv" cmds: - - task: "cpp" + - task: "utils:cpp-lint:clang-tidy-find" vars: - FLAGS: "--dry-run" + EXCLUDE_PATTERNS: + - "{{.ROOT_DIR}}/src/log_surgeon/Buffer.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/BufferParser.cpp" + - "{{.ROOT_DIR}}/src/log_surgeon/Constants.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/FileReader.cpp" + - "{{.ROOT_DIR}}/src/log_surgeon/FileReader.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/DfaState.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/Nfa.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/RegexAST.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/RegisterOperation.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/UnicodeIntervalTree.tpp" + - "{{.ROOT_DIR}}/src/log_surgeon/Lalr1Parser.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/Lalr1Parser.tpp" + - "{{.ROOT_DIR}}/src/log_surgeon/Lexer.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/Lexer.tpp" + - "{{.ROOT_DIR}}/src/log_surgeon/LogEvent.cpp" + - "{{.ROOT_DIR}}/src/log_surgeon/LogEvent.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/LogParser.cpp" + - "{{.ROOT_DIR}}/src/log_surgeon/LogParser.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/LogParserOutputBuffer.cpp" + - "{{.ROOT_DIR}}/src/log_surgeon/Parser.tpp" + - "{{.ROOT_DIR}}/src/log_surgeon/parser_types.cpp" + - "{{.ROOT_DIR}}/src/log_surgeon/parser_types.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/ParserAst.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/ParserInputBuffer.cpp" + - "{{.ROOT_DIR}}/src/log_surgeon/ParserInputBuffer.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/Reader.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/ReaderParser.cpp" + - "{{.ROOT_DIR}}/src/log_surgeon/SchemaParser.cpp" + - "{{.ROOT_DIR}}/src/log_surgeon/SchemaParser.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/Token.cpp" + - "{{.ROOT_DIR}}/src/log_surgeon/Token.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/utils.hpp" + - "{{.ROOT_DIR}}/tests/CMakeLists.txt" + - "{{.ROOT_DIR}}/tests/test-dfa.cpp" + - "{{.ROOT_DIR}}/tests/test-lexer.cpp" + - "{{.ROOT_DIR}}/tests/test-nfa.cpp" + FLAGS: + - "--config-file '{{.G_UTILS_CONFIGS_DIR}}/.clang-tidy'" + - "-p '{{.G_LOG_SURGEON_BUILD_DIR}}/debug'" + INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.tpp"] + INCLUDE_PATTERNS: + - "{{.ROOT_DIR}}/examples/**/*" + - "{{.ROOT_DIR}}/src/**/*" + - "{{.ROOT_DIR}}/tests/**/*" + OUTPUT_DIR: "{{.G_BUILD_DIR}}/lint-clang-tidy" + ROOT_PATHS: ["{{.ROOT_DIR}}"] + VENV_DIR: "{{.G_LINT_VENV_DIR}}" + + fix: + cmds: + - task: "fix-cpp-full" + - task: "yaml-fix" + + fix-cpp-diff: + cmds: + - task: "fix-cpp-format" + - task: "fix-cpp-static-diff" + + fix-cpp-full: + cmds: + - task: "fix-cpp-format" + - task: "fix-cpp-static-full" - cpp-fix: + fix-cpp-format: sources: *cpp_source_files + deps: + - "cpp-lint-configs" + - "venv" cmds: - - task: "cpp" + - task: "utils:cpp-lint:clang-format" vars: - FLAGS: "-i" + FLAGS: ["-i"] + INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.tpp"] + ROOT_PATHS: *cpp_source_files + VENV_DIR: "{{.G_LINT_VENV_DIR}}" yaml: aliases: - "yaml-check" - "yaml-fix" - deps: ["venv"] + deps: + - "venv" cmds: - |- . "{{.G_LINT_VENV_DIR}}/bin/activate" @@ -64,20 +180,27 @@ tasks: taskfile.yaml \ {{.TASKFILE}} - cpp: + cpp-lint-configs: + internal: true + cmd: "{{.ROOT_DIR}}/tools/yscope-dev-utils/exports/lint-configs/symlink-cpp-lint-configs.sh" + + gersemi: internal: true requires: vars: ["FLAGS"] - deps: ["venv"] - cmds: - - |- - . "{{.G_LINT_VENV_DIR}}/bin/activate" - find src examples tests \ - -type f \ - \( -iname "*.cpp" -o -iname "*.h" -o -iname "*.hpp" -o -iname "*.tpp" \) \ - ! -path "examples/*build*/*" \ - -print0 | \ - xargs -0 clang-format {{.FLAGS}} -Werror + deps: + - "deps:all" + - "venv" + cmd: |- + . "{{.G_LINT_VENV_DIR}}/bin/activate" + "{{.G_UTILS_SCRIPTS_DIR}}/find.py" \ + "{{.ROOT_DIR}}" \ + --exclude "build/**/*" \ + --exclude "tools/**/*" \ + --file-name "CMakeLists.txt" \ + --file-name "*.cmake" \ + --file-name "*.cmake.in" \ + | xargs gersemi {{.FLAGS}} venv: internal: true From 6032e98f1a640fea438db6956656a8059ca9bcdb Mon Sep 17 00:00:00 2001 From: davidlion Date: Sun, 8 Jun 2025 23:57:54 -0400 Subject: [PATCH 02/27] git mistake --- lint-requirements.txt | 1 - taskfiles/lint.yaml | 18 ------------------ 2 files changed, 19 deletions(-) diff --git a/lint-requirements.txt b/lint-requirements.txt index dbf21dec..e812cd91 100644 --- a/lint-requirements.txt +++ b/lint-requirements.txt @@ -1,4 +1,3 @@ clang-format>=20.1 clang-tidy>=20.1 -gersemi>=0.16.2 yamllint>=1.35.1 diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index 0f43215a..26c89f10 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -184,24 +184,6 @@ tasks: internal: true cmd: "{{.ROOT_DIR}}/tools/yscope-dev-utils/exports/lint-configs/symlink-cpp-lint-configs.sh" - gersemi: - internal: true - requires: - vars: ["FLAGS"] - deps: - - "deps:all" - - "venv" - cmd: |- - . "{{.G_LINT_VENV_DIR}}/bin/activate" - "{{.G_UTILS_SCRIPTS_DIR}}/find.py" \ - "{{.ROOT_DIR}}" \ - --exclude "build/**/*" \ - --exclude "tools/**/*" \ - --file-name "CMakeLists.txt" \ - --file-name "*.cmake" \ - --file-name "*.cmake.in" \ - | xargs gersemi {{.FLAGS}} - venv: internal: true vars: From 1caca4bbdccf41d9f75fbdd22dae7a63ed7ae3d7 Mon Sep 17 00:00:00 2001 From: davidlion Date: Mon, 9 Jun 2025 00:06:08 -0400 Subject: [PATCH 03/27] Add BufferParser.hpp to exclude list for macos. --- taskfiles/lint.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index 26c89f10..444e0848 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -88,6 +88,7 @@ tasks: EXCLUDE_PATTERNS: - "{{.ROOT_DIR}}/src/log_surgeon/Buffer.hpp" - "{{.ROOT_DIR}}/src/log_surgeon/BufferParser.cpp" + - "{{.ROOT_DIR}}/src/log_surgeon/BufferParser.hpp" - "{{.ROOT_DIR}}/src/log_surgeon/Constants.hpp" - "{{.ROOT_DIR}}/src/log_surgeon/FileReader.cpp" - "{{.ROOT_DIR}}/src/log_surgeon/FileReader.hpp" From e4efbfa0e67917e65efd9164451cbaac7bbb02e5 Mon Sep 17 00:00:00 2001 From: davidlion Date: Mon, 9 Jun 2025 00:09:36 -0400 Subject: [PATCH 04/27] Remove check-cmake. --- taskfiles/lint.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index 444e0848..350e530d 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -18,12 +18,6 @@ tasks: - task: "check-cpp-full" - task: "yaml-check" - check-cmake: - cmds: - - task: "gersemi" - vars: - FLAGS: "--check" - check-cpp-diff: cmds: - task: "check-cpp-format" From d1560fbca3c75bd16eb047f875a169a32c6fc3c7 Mon Sep 17 00:00:00 2001 From: davidlion Date: Mon, 9 Jun 2025 00:20:36 -0400 Subject: [PATCH 05/27] Update yaml lint naming. --- taskfiles/lint.yaml | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index 350e530d..e6005de8 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -16,7 +16,7 @@ tasks: check: cmds: - task: "check-cpp-full" - - task: "yaml-check" + - task: "check-yaml" check-cpp-diff: cmds: @@ -129,10 +129,27 @@ tasks: ROOT_PATHS: ["{{.ROOT_DIR}}"] VENV_DIR: "{{.G_LINT_VENV_DIR}}" + check-yaml: + aliases: + - "fix-yaml" + deps: + - "venv" + cmds: + - |- + . "{{.G_LINT_VENV_DIR}}/bin/activate" + yamllint \ + --config-file "{{.ROOT_DIR}}/tools/yscope-dev-utils/exports/lint-configs/.yamllint.yml" \ + --strict \ + .coderabbit.yaml \ + .github \ + .clang-format \ + taskfile.yaml \ + {{.TASKFILE}} + fix: cmds: - task: "fix-cpp-full" - - task: "yaml-fix" + - task: "fix-yaml" fix-cpp-diff: cmds: @@ -157,24 +174,6 @@ tasks: ROOT_PATHS: *cpp_source_files VENV_DIR: "{{.G_LINT_VENV_DIR}}" - yaml: - aliases: - - "yaml-check" - - "yaml-fix" - deps: - - "venv" - cmds: - - |- - . "{{.G_LINT_VENV_DIR}}/bin/activate" - yamllint \ - --config-file "{{.ROOT_DIR}}/tools/yscope-dev-utils/exports/lint-configs/.yamllint.yml" \ - --strict \ - .coderabbit.yaml \ - .github \ - .clang-format \ - taskfile.yaml \ - {{.TASKFILE}} - cpp-lint-configs: internal: true cmd: "{{.ROOT_DIR}}/tools/yscope-dev-utils/exports/lint-configs/symlink-cpp-lint-configs.sh" From 3626dbeb9a71edcc22a870113c57e669643450e1 Mon Sep 17 00:00:00 2001 From: davidlion Date: Mon, 9 Jun 2025 00:21:24 -0400 Subject: [PATCH 06/27] Add ReaderParser.hpp to exclude list for macos. --- taskfiles/lint.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index e6005de8..eb09353d 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -108,6 +108,7 @@ tasks: - "{{.ROOT_DIR}}/src/log_surgeon/ParserInputBuffer.hpp" - "{{.ROOT_DIR}}/src/log_surgeon/Reader.hpp" - "{{.ROOT_DIR}}/src/log_surgeon/ReaderParser.cpp" + - "{{.ROOT_DIR}}/src/log_surgeon/ReaderParser.hpp" - "{{.ROOT_DIR}}/src/log_surgeon/SchemaParser.cpp" - "{{.ROOT_DIR}}/src/log_surgeon/SchemaParser.hpp" - "{{.ROOT_DIR}}/src/log_surgeon/Token.cpp" From 13f0bd7fd74d253b6bb4b6d9f78b61f03eb547a7 Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 11 Jul 2025 18:27:33 -0400 Subject: [PATCH 07/27] Add more files to exclude. --- taskfiles/lint.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index 93079b39..febf01e7 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -86,6 +86,7 @@ tasks: - "{{.ROOT_DIR}}/src/log_surgeon/Constants.hpp" - "{{.ROOT_DIR}}/src/log_surgeon/FileReader.cpp" - "{{.ROOT_DIR}}/src/log_surgeon/FileReader.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/Dfa.hpp" - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/DfaState.hpp" - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/Nfa.hpp" - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/RegexAST.hpp" @@ -109,6 +110,7 @@ tasks: - "{{.ROOT_DIR}}/src/log_surgeon/Reader.hpp" - "{{.ROOT_DIR}}/src/log_surgeon/ReaderParser.cpp" - "{{.ROOT_DIR}}/src/log_surgeon/ReaderParser.hpp" + - "{{.ROOT_DIR}}/src/log_surgeon/Schema.cpp" - "{{.ROOT_DIR}}/src/log_surgeon/SchemaParser.cpp" - "{{.ROOT_DIR}}/src/log_surgeon/SchemaParser.hpp" - "{{.ROOT_DIR}}/src/log_surgeon/Token.cpp" From 1d2b8e5fa43335d42236242dfd3723d9ae9a3968 Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 11 Jul 2025 21:51:37 -0400 Subject: [PATCH 08/27] Rename lint.yml to lint.yaml. --- .github/workflows/{lint.yml => lint.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{lint.yml => lint.yaml} (100%) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yaml similarity index 100% rename from .github/workflows/lint.yml rename to .github/workflows/lint.yaml From 27f5e32db5ca1d334d5f0170bc2b973b9ad7fc8d Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 11 Jul 2025 22:00:28 -0400 Subject: [PATCH 09/27] clang-tidy workaround --- .github/workflows/lint.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 92af0af1..f7f49e9a 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -37,5 +37,14 @@ jobs: name: "Install coreutils (for md5sum)" run: "brew install coreutils" + # We use clang for linting so CMake doesn't generate compile_commands.json with any gcc + # specific flags that would confuse clang-tidy. + - if: "matrix.os == 'ubuntu-24.04'" + name: "Install clang." + run: |- + curl https://apt.llvm.org/llvm.sh | bash -s + ln -s /usr/bin/clang-20 /usr/local/bin/cc + ln -s /usr/bin/clang++-20 /usr/local/bin/c++ + - name: "Run lint task" run: "task lint:check" From c8fca75d77de96086f6153258e0a640d8028665b Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 11 Jul 2025 22:03:12 -0400 Subject: [PATCH 10/27] Add sudo. --- .github/workflows/lint.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index f7f49e9a..112aadcf 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -42,9 +42,9 @@ jobs: - if: "matrix.os == 'ubuntu-24.04'" name: "Install clang." run: |- - curl https://apt.llvm.org/llvm.sh | bash -s - ln -s /usr/bin/clang-20 /usr/local/bin/cc - ln -s /usr/bin/clang++-20 /usr/local/bin/c++ + curl https://apt.llvm.org/llvm.sh | sudo bash -s + sudo ln -s /usr/bin/clang-20 /usr/local/bin/cc + sudo ln -s /usr/bin/clang++-20 /usr/local/bin/c++ - name: "Run lint task" run: "task lint:check" From af32abd78184163356f207320da78ca1e04b0f65 Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 11 Jul 2025 22:08:07 -0400 Subject: [PATCH 11/27] Fix to clang-20. --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 112aadcf..ab8aa639 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -42,7 +42,7 @@ jobs: - if: "matrix.os == 'ubuntu-24.04'" name: "Install clang." run: |- - curl https://apt.llvm.org/llvm.sh | sudo bash -s + curl https://apt.llvm.org/llvm.sh | sudo bash -s -- 20 sudo ln -s /usr/bin/clang-20 /usr/local/bin/cc sudo ln -s /usr/bin/clang++-20 /usr/local/bin/c++ From 02ad6284ecf29a8201d71717891b9c75c84c6e1b Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 18 Jul 2025 11:05:37 -0400 Subject: [PATCH 12/27] Build tasks working. Examples tasks need refactor. --- examples/CMakeLists.txt | 2 +- taskfile.yaml | 9 ++- taskfiles/examples.yaml | 84 ++++++++++++++++++++++ taskfiles/{build.yaml => log-surgeon.yaml} | 67 +++++------------ taskfiles/test.yaml | 6 +- 5 files changed, 114 insertions(+), 54 deletions(-) create mode 100644 taskfiles/examples.yaml rename taskfiles/{build.yaml => log-surgeon.yaml} (59%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b8a1e204..9b8eb5d5 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,7 +11,7 @@ if(log-surgeon-examples_IS_TOP_LEVEL) # Include dependency settings if the project isn't being included as a subproject. # NOTE: We mark the file optional because if the user happens to have the dependencies # installed, this file is not necessary. - include("${CMAKE_SOURCE_DIR}/../build/deps/cmake-settings/all.cmake" OPTIONAL) + include("${CMAKE_SOURCE_DIR}/../build/examples/deps/cmake-settings/all.cmake" OPTIONAL) endif() find_package(log_surgeon REQUIRED) diff --git a/taskfile.yaml b/taskfile.yaml index a899437b..609d8177 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -4,16 +4,21 @@ set: ["u", "pipefail"] shopt: ["globstar"] includes: - build: "taskfiles/build.yaml" deps: "taskfiles/deps.yaml" docs: "taskfiles/docs.yaml" + examples: "taskfiles/examples.yaml" lint: "taskfiles/lint.yaml" + log-surgeon: "taskfiles/log-surgeon.yaml" test: "taskfiles/test.yaml" vars: + # This must match the package name in CMakeLists.txt. + G_CMAKE_PACKAGE_NAME: "log_surgeon" + + # Build directories G_BUILD_DIR: "{{.ROOT_DIR}}/build" G_EXAMPLES_BUILD_DIR: "{{.G_BUILD_DIR}}/examples" - G_LOG_SURGEON_BUILD_DIR: "{{.G_BUILD_DIR}}/log-surgeon" + G_LOG_SURGEON_BUILD_DIR: "{{.G_BUILD_DIR}}/{{.G_CMAKE_PACKAGE_NAME}}" tasks: clean: "rm -rf '{{.G_BUILD_DIR}}'" diff --git a/taskfiles/examples.yaml b/taskfiles/examples.yaml new file mode 100644 index 00000000..3c7fb49c --- /dev/null +++ b/taskfiles/examples.yaml @@ -0,0 +1,84 @@ +version: "3" + +includes: + log-surgeon: + internal: true + taskfile: "log-surgeon.yaml" + utils: + internal: true + taskfile: "../tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml" + +tasks: + build-debug: + cmds: + - task: "build" + vars: + BUILD_TYPE: "debug" + + build-release: + cmds: + - task: "build" + vars: + BUILD_TYPE: "release" + + clean-debug: + cmds: + - task: "clean" + vars: + BUILD_TYPE: "debug" + + clean-release: + cmds: + - task: "clean" + vars: + BUILD_TYPE: "release" + + build: + internal: true + requires: + vars: ["BUILD_TYPE"] + deps: + - task: "generate" + vars: + BUILD_TYPE: "{{.BUILD_TYPE}}" + cmds: + - task: "utils:cmake:build" + vars: + BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/{{.BUILD_TYPE}}" + + clean: + internal: true + requires: + vars: ["BUILD_TYPE"] + cmds: + - task: "utils:cmake:clean" + vars: + BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/{{.BUILD_TYPE}}" + + generate: + internal: true + requires: + vars: ["BUILD_TYPE"] + vars: + EXAMPLES_DEPS_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/deps" + CMAKE_SETTINGS_DIR: "{{.EXAMPLES_DEPS_DIR}}/cmake-settings" + CMAKE_SETTINGS_FILE: "{{.CMAKE_SETTINGS_DIR}}/all.cmake" + INSTALL_PREFIX: "{{.EXAMPLES_DEPS_DIR}}/{{.G_CMAKE_PACKAGE_NAME}}/{{.BUILD_TYPE}}" + cmds: + - "mkdir -p '{{.INSTALL_PREFIX}}'" + - "mkdir -p '{{.CMAKE_SETTINGS_DIR}}'" + - task: "log-surgeon:install-{{.BUILD_TYPE}}" + vars: + INSTALL_PREFIX: "{{.INSTALL_PREFIX}}" + - >- + echo "include(\"{{.G_DEPS_CMAKE_SETTINGS_DIR}}/all.cmake\")" > "{{.CMAKE_SETTINGS_FILE}}"; + echo "set({{.G_CMAKE_PACKAGE_NAME}}_ROOT \"{{.INSTALL_PREFIX}}\" + CACHE PATH + \"Package root for {{.G_CMAKE_PACKAGE_NAME}}.\" + )" >> "{{.CMAKE_SETTINGS_FILE}}" + - task: "utils:cmake:generate" + vars: + BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/{{.BUILD_TYPE}}" + EXTRA_ARGS: + - "-DCMAKE_BUILD_TYPE={{.BUILD_TYPE}}" + SOURCE_DIR: "{{.ROOT_DIR}}/examples" diff --git a/taskfiles/build.yaml b/taskfiles/log-surgeon.yaml similarity index 59% rename from taskfiles/build.yaml rename to taskfiles/log-surgeon.yaml index 23a8232b..f104c6c5 100644 --- a/taskfiles/build.yaml +++ b/taskfiles/log-surgeon.yaml @@ -9,55 +9,33 @@ includes: taskfile: "../tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml" tasks: - debug: + build-debug: cmds: - task: "build" vars: BUILD_TYPE: "debug" - release: + build-release: cmds: - task: "build" vars: BUILD_TYPE: "release" clean-debug: - deps: - - task: "utils:cmake:clean" - vars: - BUILD_DIR: "{{.G_LOG_SURGEON_BUILD_DIR}}/debug" - - clean-release: - deps: - - task: "utils:cmake:clean" - vars: - BUILD_DIR: "{{.G_LOG_SURGEON_BUILD_DIR}}/release" - - examples-debug: cmds: - - task: "examples" + - task: "clean" vars: BUILD_TYPE: "debug" - examples-release: + clean-release: cmds: - - task: "examples" + - task: "clean" vars: BUILD_TYPE: "release" - examples-clean-debug: - deps: - - task: "utils:cmake:clean" - vars: - BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/debug" - - examples-clean-release: - deps: - - task: "utils:cmake:clean" - vars: - BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/release" - install-debug: + desc: >- + install-debug INSTALL_PREFIX="": Install the debug build into . requires: vars: ["INSTALL_PREFIX"] cmds: @@ -67,6 +45,8 @@ tasks: INSTALL_PREFIX: "{{.INSTALL_PREFIX}}" install-release: + desc: >- + install-release INSTALL_PREFIX="": Install the release build into . requires: vars: ["INSTALL_PREFIX"] cmds: @@ -88,28 +68,14 @@ tasks: vars: BUILD_DIR: "{{.G_LOG_SURGEON_BUILD_DIR}}/{{.BUILD_TYPE}}" - examples: + clean: internal: true requires: vars: ["BUILD_TYPE"] - vars: - INSTALL_PREFIX: "{{.G_EXAMPLES_BUILD_DIR}}/deps/log_surgeon/{{.BUILD_TYPE}}" - deps: - - "{{.BUILD_TYPE}}" cmds: - - task: "install-{{.BUILD_TYPE}}" - vars: - INSTALL_PREFIX: "{{.INSTALL_PREFIX}}" - - task: "utils:cmake:generate" - vars: - BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/{{.BUILD_TYPE}}" - EXTRA_ARGS: - - "-DCMAKE_BUILD_TYPE={{.BUILD_TYPE}}" - - "-Dlog_surgeon_ROOT={{.INSTALL_PREFIX}}" - SOURCE_DIR: "{{.ROOT_DIR}}/examples" - - task: "utils:cmake:build" + - task: "utils:cmake:clean" vars: - BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/{{.BUILD_TYPE}}" + BUILD_DIR: "{{.G_LOG_SURGEON_BUILD_DIR}}/{{.BUILD_TYPE}}" generate: internal: true @@ -127,12 +93,17 @@ tasks: install: internal: true + vars: + ABSOLUTE_INSTALL_PREFIX: + sh: "realpath '{{.INSTALL_PREFIX}}'" requires: vars: ["BUILD_TYPE", "INSTALL_PREFIX"] deps: - - "{{.BUILD_TYPE}}" + - task: "build" + vars: + BUILD_TYPE: "{{.BUILD_TYPE}}" cmds: - task: "utils:cmake:install" vars: BUILD_DIR: "{{.G_LOG_SURGEON_BUILD_DIR}}/{{.BUILD_TYPE}}" - INSTALL_PREFIX: "{{.INSTALL_PREFIX}}" + INSTALL_PREFIX: "{{.ABSOLUTE_INSTALL_PREFIX}}" diff --git a/taskfiles/test.yaml b/taskfiles/test.yaml index 1de5f83a..d0a9abd9 100644 --- a/taskfiles/test.yaml +++ b/taskfiles/test.yaml @@ -1,9 +1,9 @@ version: "3" includes: - build: + log-surgeon: internal: true - taskfile: "build.yaml" + taskfile: "log-surgeon.yaml" tasks: debug: @@ -21,5 +21,5 @@ tasks: unit-test: internal: true deps: - - "build:{{.BUILD_TYPE}}" + - "log-surgeon:build-{{.BUILD_TYPE}}" cmd: "{{.G_LOG_SURGEON_BUILD_DIR}}/{{.BUILD_TYPE}}/tests/unit-test" From 49f7c253acb38acbf90036554bea11ff44b88217 Mon Sep 17 00:00:00 2001 From: davidlion Date: Mon, 21 Jul 2025 21:10:44 -0400 Subject: [PATCH 13/27] Refactor examples. --- examples/CMakeLists.txt | 2 +- taskfile.yaml | 3 +- taskfiles/examples.yaml | 20 ++--- taskfiles/lint.yaml | 172 +++++++++++++++++++++++++------------ taskfiles/log-surgeon.yaml | 8 +- 5 files changed, 131 insertions(+), 74 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9b8eb5d5..b8a1e204 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -11,7 +11,7 @@ if(log-surgeon-examples_IS_TOP_LEVEL) # Include dependency settings if the project isn't being included as a subproject. # NOTE: We mark the file optional because if the user happens to have the dependencies # installed, this file is not necessary. - include("${CMAKE_SOURCE_DIR}/../build/examples/deps/cmake-settings/all.cmake" OPTIONAL) + include("${CMAKE_SOURCE_DIR}/../build/deps/cmake-settings/all.cmake" OPTIONAL) endif() find_package(log_surgeon REQUIRED) diff --git a/taskfile.yaml b/taskfile.yaml index 609d8177..c0ce52be 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -12,10 +12,11 @@ includes: test: "taskfiles/test.yaml" vars: + # General variables # This must match the package name in CMakeLists.txt. G_CMAKE_PACKAGE_NAME: "log_surgeon" - # Build directories + # Build variables G_BUILD_DIR: "{{.ROOT_DIR}}/build" G_EXAMPLES_BUILD_DIR: "{{.G_BUILD_DIR}}/examples" G_LOG_SURGEON_BUILD_DIR: "{{.G_BUILD_DIR}}/{{.G_CMAKE_PACKAGE_NAME}}" diff --git a/taskfiles/examples.yaml b/taskfiles/examples.yaml index 3c7fb49c..ab7ec994 100644 --- a/taskfiles/examples.yaml +++ b/taskfiles/examples.yaml @@ -60,25 +60,17 @@ tasks: requires: vars: ["BUILD_TYPE"] vars: - EXAMPLES_DEPS_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/deps" - CMAKE_SETTINGS_DIR: "{{.EXAMPLES_DEPS_DIR}}/cmake-settings" - CMAKE_SETTINGS_FILE: "{{.CMAKE_SETTINGS_DIR}}/all.cmake" - INSTALL_PREFIX: "{{.EXAMPLES_DEPS_DIR}}/{{.G_CMAKE_PACKAGE_NAME}}/{{.BUILD_TYPE}}" - cmds: - - "mkdir -p '{{.INSTALL_PREFIX}}'" - - "mkdir -p '{{.CMAKE_SETTINGS_DIR}}'" + LOG_SURGEON_INSTALL_PREFIX: >- + {{.G_EXAMPLES_BUILD_DIR}}/deps/{{.G_CMAKE_PACKAGE_NAME}}/{{.BUILD_TYPE}} + deps: - task: "log-surgeon:install-{{.BUILD_TYPE}}" vars: - INSTALL_PREFIX: "{{.INSTALL_PREFIX}}" - - >- - echo "include(\"{{.G_DEPS_CMAKE_SETTINGS_DIR}}/all.cmake\")" > "{{.CMAKE_SETTINGS_FILE}}"; - echo "set({{.G_CMAKE_PACKAGE_NAME}}_ROOT \"{{.INSTALL_PREFIX}}\" - CACHE PATH - \"Package root for {{.G_CMAKE_PACKAGE_NAME}}.\" - )" >> "{{.CMAKE_SETTINGS_FILE}}" + INSTALL_PREFIX: "{{.LOG_SURGEON_INSTALL_PREFIX}}" + cmds: - task: "utils:cmake:generate" vars: BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/{{.BUILD_TYPE}}" EXTRA_ARGS: - "-DCMAKE_BUILD_TYPE={{.BUILD_TYPE}}" + - "-D{{.G_CMAKE_PACKAGE_NAME}}_ROOT={{.LOG_SURGEON_INSTALL_PREFIX}}" SOURCE_DIR: "{{.ROOT_DIR}}/examples" diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index febf01e7..6558a2ae 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -1,77 +1,107 @@ version: "3" includes: - build: + examples: internal: true - taskfile: "./build.yaml" + taskfile: "examples.yaml" + log-surgeon: + internal: true + taskfile: "log-surgeon.yaml" utils: internal: true taskfile: "../tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml" 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" + # Root paths for source files + G_LOG_SURGEON_ROOT_PATHS: + - "{{.ROOT_DIR}}/src" + - "{{.ROOT_DIR}}/tests" + G_EXAMPLES_ROOT_PATHS: + - "{{.ROOT_DIR}}/examples" + + # yaml anchors for `sources` fields + G_EXAMPLES_SOURCES: &examples_sources + - "{{.ROOT_DIR}}/.clang-tidy" + - "{{.ROOT_DIR}}/examples/.clang-format" + - "{{.ROOT_DIR}}/examples/**/*" + - "{{.TASKFILE}}" + G_LOG_SURGEON_SOURCES: &log_surgeon_sources + - "{{.ROOT_DIR}}/.clang-format" + - "{{.ROOT_DIR}}/.clang-tidy" + - "{{.ROOT_DIR}}/src/**/*" + - "{{.ROOT_DIR}}/tests/**/*" + - "{{.TASKFILE}}" + tasks: check: cmds: - - task: "check-cpp-full" + - task: "check-cpp" - task: "check-yaml" - check-cpp-diff: + check-cpp: cmds: - - task: "check-cpp-format" - - task: "check-cpp-static-diff" + - task: "check-examples-cpp-format" + - task: "check-examples-cpp-static" + - task: "check-log-surgeon-cpp-format" + - task: "check-log-surgeon-cpp-static" - check-cpp-full: + check-examples-cpp-format: cmds: - - task: "check-cpp-format" - - task: "check-cpp-static-full" - - check-cpp-format: - sources: &cpp_source_files - - "{{.ROOT_DIR}}/.clang-format" - - "{{.ROOT_DIR}}/.clang-tidy" - - "{{.ROOT_DIR}}/examples/**/*" - - "{{.ROOT_DIR}}/src/**/*" - - "{{.ROOT_DIR}}/tests/**/*" - - "{{.TASKFILE}}" - deps: - - "cpp-lint-configs" - - "venv" - cmds: - - task: "utils:cpp-lint:clang-format" + - task: "examples-cpp-format" vars: FLAGS: ["--dry-run"] - INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.tpp"] - ROOT_PATHS: *cpp_source_files - VENV_DIR: "{{.G_LINT_VENV_DIR}}" - check-cpp-static-diff: + check-examples-cpp-static: # NOTE: We alias the fix task until we determine which clang-tidy fixes can be applied safely. - aliases: ["fix-cpp-static-diff"] - sources: *cpp_source_files + aliases: ["fix-cpp-static-examples"] + sources: *examples_sources deps: - - task: "build:generate" + - task: "examples:generate" vars: BUILD_TYPE: "debug" - "cpp-lint-configs" - "venv" cmds: - - task: "utils:cpp-lint:clang-tidy-diff" + - task: "utils:cpp-lint:clang-tidy-find" vars: FLAGS: - "--config-file '{{.G_UTILS_CONFIGS_DIR}}/.clang-tidy'" - - "-p '{{.G_LOG_SURGEON_BUILD_DIR}}/debug'" - INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.tpp"] + - "-p '{{.G_EXAMPLES_BUILD_DIR}}/debug'" OUTPUT_DIR: "{{.G_BUILD_DIR}}/lint-clang-tidy" + ROOT_PATHS: + ref: ".G_EXAMPLES_ROOT_PATHS" VENV_DIR: "{{.G_LINT_VENV_DIR}}" - check-cpp-static-full: + check-log-surgeon-cpp-format: + sources: *log_surgeon_sources + deps: + - "cpp-lint-configs" + - "venv" + cmds: + - task: "utils:cpp-lint:clang-format" + vars: + FLAGS: ["--dry-run"] + INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.tpp"] + ROOT_PATHS: + ref: ".G_LOG_SURGEON_ROOT_PATHS" + VENV_DIR: "{{.G_LINT_VENV_DIR}}" + + check-log-surgeon-cpp-format: + cmds: + - task: "log-surgeon-cpp-format" + vars: + FLAGS: ["--dry-run"] + + check-log-surgeon-cpp-static: # NOTE: We alias the fix task until we determine which clang-tidy fixes can be applied safely. - aliases: ["fix-cpp-static-full"] + aliases: ["fix-cpp-static"] + sources: *log_surgeon_sources deps: - - task: "build:generate" + - task: "log-surgeon:generate" vars: BUILD_TYPE: "debug" - "cpp-lint-configs" @@ -124,12 +154,9 @@ tasks: - "--config-file '{{.G_UTILS_CONFIGS_DIR}}/.clang-tidy'" - "-p '{{.G_LOG_SURGEON_BUILD_DIR}}/debug'" INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.tpp"] - INCLUDE_PATTERNS: - - "{{.ROOT_DIR}}/examples/**/*" - - "{{.ROOT_DIR}}/src/**/*" - - "{{.ROOT_DIR}}/tests/**/*" OUTPUT_DIR: "{{.G_BUILD_DIR}}/lint-clang-tidy" - ROOT_PATHS: ["{{.ROOT_DIR}}"] + ROOT_PATHS: + ref: ".G_LOG_SURGEON_ROOT_PATHS" VENV_DIR: "{{.G_LINT_VENV_DIR}}" check-yaml: @@ -152,35 +179,68 @@ tasks: fix: cmds: - - task: "fix-cpp-full" + - task: "fix-cpp" - task: "fix-yaml" - fix-cpp-diff: + fix-cpp: + cmds: + - task: "fix-examples-cpp-format" + - task: "fix-examples-cpp-static" + - task: "fix-log-surgeon-cpp-format" + - task: "fix-log-surgeon-cpp-static" + + fix-examples-cpp-format: cmds: - - task: "fix-cpp-format" - - task: "fix-cpp-static-diff" + - task: "examples-cpp-format" + vars: + FLAGS: ["-i"] - fix-cpp-full: + fix-log-surgeon-cpp-format: cmds: - - task: "fix-cpp-format" - - task: "fix-cpp-static-full" + - task: "log-surgeon-cpp-format" + vars: + FLAGS: ["-i"] + + cpp-lint-configs: + internal: true + cmd: "{{.ROOT_DIR}}/tools/yscope-dev-utils/exports/lint-configs/symlink-cpp-lint-configs.sh" - fix-cpp-format: - sources: *cpp_source_files + examples-cpp-format: + internal: true + label: "{{.TASK}}:{{.FLAGS}}" + requires: + vars: ["FLAGS"] + sources: *examples_sources deps: - "cpp-lint-configs" - "venv" cmds: - task: "utils:cpp-lint:clang-format" vars: - FLAGS: ["-i"] - INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.tpp"] - ROOT_PATHS: *cpp_source_files + FLAGS: + ref: ".FLAGS" + ROOT_PATHS: + ref: ".G_EXAMPLES_ROOT_PATHS" VENV_DIR: "{{.G_LINT_VENV_DIR}}" - cpp-lint-configs: + log-surgeon-cpp-format: internal: true - cmd: "{{.ROOT_DIR}}/tools/yscope-dev-utils/exports/lint-configs/symlink-cpp-lint-configs.sh" + label: "{{.TASK}}:{{.FLAGS}}" + requires: + vars: ["FLAGS"] + sources: *log_surgeon_sources + deps: + - "cpp-lint-configs" + - "venv" + cmds: + - task: "utils:cpp-lint:clang-format" + vars: + FLAGS: + ref: ".FLAGS" + INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.tpp"] + ROOT_PATHS: + ref: ".G_LOG_SURGEON_ROOT_PATHS" + VENV_DIR: "{{.G_LINT_VENV_DIR}}" venv: internal: true @@ -188,9 +248,9 @@ tasks: CHECKSUM_FILE: "{{.G_BUILD_DIR}}/{{.TASK | replace \":\" \"#\"}}.md5" OUTPUT_DIR: "{{.G_LINT_VENV_DIR}}" sources: + - "{{.ROOT_DIR}}/lint-requirements.txt" - "{{.ROOT_DIR}}/taskfile.yaml" - "{{.TASKFILE}}" - - "{{.ROOT_DIR}}/lint-requirements.txt" generates: ["{{.CHECKSUM_FILE}}"] run: "once" deps: diff --git a/taskfiles/log-surgeon.yaml b/taskfiles/log-surgeon.yaml index f104c6c5..42fcaaab 100644 --- a/taskfiles/log-surgeon.yaml +++ b/taskfiles/log-surgeon.yaml @@ -94,8 +94,12 @@ tasks: install: internal: true vars: - ABSOLUTE_INSTALL_PREFIX: - sh: "realpath '{{.INSTALL_PREFIX}}'" + ABSOLUTE_INSTALL_PREFIX: >- + {{- if osIsAbs .INSTALL_PREFIX -}} + {{.INSTALL_PREFIX}} + {{- else -}} + {{.USER_WORKING_DIR}}/{{.INSTALL_PREFIX}} + {{- end}} requires: vars: ["BUILD_TYPE", "INSTALL_PREFIX"] deps: From 9c7c838d4a9b5d1824d5e76aa9d708c12ff257cf Mon Sep 17 00:00:00 2001 From: davidlion Date: Thu, 31 Jul 2025 11:46:38 -0400 Subject: [PATCH 14/27] Update lint.yaml, running with failures. --- taskfiles/lint.yaml | 109 ++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 55 deletions(-) diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index 6558a2ae..532f52dd 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -23,18 +23,18 @@ vars: G_EXAMPLES_ROOT_PATHS: - "{{.ROOT_DIR}}/examples" - # yaml anchors for `sources` fields + # Anchors for `sources` fields G_EXAMPLES_SOURCES: &examples_sources - "{{.ROOT_DIR}}/.clang-tidy" - "{{.ROOT_DIR}}/examples/.clang-format" - "{{.ROOT_DIR}}/examples/**/*" - "{{.TASKFILE}}" G_LOG_SURGEON_SOURCES: &log_surgeon_sources - - "{{.ROOT_DIR}}/.clang-format" - - "{{.ROOT_DIR}}/.clang-tidy" - - "{{.ROOT_DIR}}/src/**/*" - - "{{.ROOT_DIR}}/tests/**/*" - - "{{.TASKFILE}}" + - "{{.ROOT_DIR}}/.clang-format" + - "{{.ROOT_DIR}}/.clang-tidy" + - "{{.ROOT_DIR}}/src/**/*" + - "{{.ROOT_DIR}}/tests/**/*" + - "{{.TASKFILE}}" tasks: check: @@ -44,67 +44,59 @@ tasks: check-cpp: cmds: - - task: "check-examples-cpp-format" - - task: "check-examples-cpp-static" - - task: "check-log-surgeon-cpp-format" - - task: "check-log-surgeon-cpp-static" + - task: "check-cpp-format-examples" + - task: "check-cpp-format-log-surgeon" + - task: "check-cpp-static-examples" + - task: "check-cpp-static-log-surgeon" + + check-cpp-format-examples: + cmds: + - task: "cpp-format-examples" + vars: + FLAGS: ["--dry-run"] - check-examples-cpp-format: + check-cpp-format-log-surgeon: cmds: - - task: "examples-cpp-format" + - task: "cpp-format-log-surgeon" vars: FLAGS: ["--dry-run"] - check-examples-cpp-static: + check-cpp-static-examples: # NOTE: We alias the fix task until we determine which clang-tidy fixes can be applied safely. aliases: ["fix-cpp-static-examples"] + vars: + BUILD_DIR: "{{.G_EXAMPLES_DEBUG_BUILD_DIR}}" sources: *examples_sources deps: + - "cpp-lint-configs" - task: "examples:generate" vars: + BUILD_DIR: "{{.BUILD_DIR}}" BUILD_TYPE: "debug" - - "cpp-lint-configs" - "venv" cmds: - task: "utils:cpp-lint:clang-tidy-find" vars: FLAGS: - "--config-file '{{.G_UTILS_CONFIGS_DIR}}/.clang-tidy'" - - "-p '{{.G_EXAMPLES_BUILD_DIR}}/debug'" + - "-p '{{.BUILD_DIR}}'" OUTPUT_DIR: "{{.G_BUILD_DIR}}/lint-clang-tidy" ROOT_PATHS: ref: ".G_EXAMPLES_ROOT_PATHS" VENV_DIR: "{{.G_LINT_VENV_DIR}}" - check-log-surgeon-cpp-format: - sources: *log_surgeon_sources - deps: - - "cpp-lint-configs" - - "venv" - cmds: - - task: "utils:cpp-lint:clang-format" - vars: - FLAGS: ["--dry-run"] - INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.tpp"] - ROOT_PATHS: - ref: ".G_LOG_SURGEON_ROOT_PATHS" - VENV_DIR: "{{.G_LINT_VENV_DIR}}" - - check-log-surgeon-cpp-format: - cmds: - - task: "log-surgeon-cpp-format" - vars: - FLAGS: ["--dry-run"] - - check-log-surgeon-cpp-static: + check-cpp-static-log-surgeon: # NOTE: We alias the fix task until we determine which clang-tidy fixes can be applied safely. aliases: ["fix-cpp-static"] + vars: + BUILD_DIR: "{{.G_LOG_SURGEON_DEBUG_BUILD_DIR}}" sources: *log_surgeon_sources deps: + - "cpp-lint-configs" - task: "log-surgeon:generate" vars: + BUILD_DIR: "{{.BUILD_DIR}}" BUILD_TYPE: "debug" - - "cpp-lint-configs" - "venv" cmds: - task: "utils:cpp-lint:clang-tidy-find" @@ -152,18 +144,20 @@ tasks: - "{{.ROOT_DIR}}/tests/test-nfa.cpp" FLAGS: - "--config-file '{{.G_UTILS_CONFIGS_DIR}}/.clang-tidy'" - - "-p '{{.G_LOG_SURGEON_BUILD_DIR}}/debug'" - INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.tpp"] + - "-p '{{.BUILD_DIR}}'" + INCLUDE_FILENAME_PATTERNS: + - "*.cpp" + - "*.h" + - "*.hpp" + - "*.tpp" OUTPUT_DIR: "{{.G_BUILD_DIR}}/lint-clang-tidy" ROOT_PATHS: ref: ".G_LOG_SURGEON_ROOT_PATHS" VENV_DIR: "{{.G_LINT_VENV_DIR}}" check-yaml: - aliases: - - "fix-yaml" - deps: - - "venv" + aliases: ["fix-yaml"] + deps: ["venv"] cmds: - |- . "{{.G_LINT_VENV_DIR}}/bin/activate" @@ -184,20 +178,20 @@ tasks: fix-cpp: cmds: - - task: "fix-examples-cpp-format" - - task: "fix-examples-cpp-static" - - task: "fix-log-surgeon-cpp-format" - - task: "fix-log-surgeon-cpp-static" + - task: "fix-cpp-format-examples" + - task: "fix-cpp-format-log-surgeon" + - task: "fix-cpp-static-examples" + - task: "fix-cpp-static-log-surgeon" - fix-examples-cpp-format: + fix-cpp-format-examples: cmds: - - task: "examples-cpp-format" + - task: "cpp-format-examples" vars: FLAGS: ["-i"] - fix-log-surgeon-cpp-format: + fix-cpp-format-log-surgeon: cmds: - - task: "log-surgeon-cpp-format" + - task: "cpp-format-log-surgeon" vars: FLAGS: ["-i"] @@ -205,7 +199,7 @@ tasks: internal: true cmd: "{{.ROOT_DIR}}/tools/yscope-dev-utils/exports/lint-configs/symlink-cpp-lint-configs.sh" - examples-cpp-format: + cpp-format-examples: internal: true label: "{{.TASK}}:{{.FLAGS}}" requires: @@ -223,11 +217,12 @@ tasks: ref: ".G_EXAMPLES_ROOT_PATHS" VENV_DIR: "{{.G_LINT_VENV_DIR}}" - log-surgeon-cpp-format: + cpp-format-log-surgeon: internal: true label: "{{.TASK}}:{{.FLAGS}}" requires: - vars: ["FLAGS"] + vars: + - "FLAGS" sources: *log_surgeon_sources deps: - "cpp-lint-configs" @@ -237,7 +232,11 @@ tasks: vars: FLAGS: ref: ".FLAGS" - INCLUDE_FILENAME_PATTERNS: ["*.cpp", "*.h", "*.hpp", "*.tpp"] + INCLUDE_FILENAME_PATTERNS: + - "*.cpp" + - "*.h" + - "*.hpp" + - "*.tpp" ROOT_PATHS: ref: ".G_LOG_SURGEON_ROOT_PATHS" VENV_DIR: "{{.G_LINT_VENV_DIR}}" From f3312771242e671a847ebed68c63f314e0493929 Mon Sep 17 00:00:00 2001 From: davidlion Date: Thu, 31 Jul 2025 11:47:01 -0400 Subject: [PATCH 15/27] Bump dev-utils. --- tools/yscope-dev-utils | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/yscope-dev-utils b/tools/yscope-dev-utils index 76aecbd6..b965f19f 160000 --- a/tools/yscope-dev-utils +++ b/tools/yscope-dev-utils @@ -1 +1 @@ -Subproject commit 76aecbd6d0db6e2078005431946b5c2e716c4291 +Subproject commit b965f19f3e11c548f32bf7ab8e28ff38906be018 From dbc66635986cdbbd011bf9642fe5db1def371a80 Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 1 Aug 2025 10:22:50 -0400 Subject: [PATCH 16/27] Build compile_commands for exampels by default. --- examples/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index b8a1e204..05b9cd31 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,6 +1,13 @@ cmake_minimum_required(VERSION 3.22.1) project(log-surgeon-examples) +set(CMAKE_EXPORT_COMPILE_COMMANDS + ON + CACHE BOOL + "Enable/Disable output of compile commands during generation." + FORCE +) + 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}'.") From e7e747f332ee7a76d41993ef81920fbc1b42c359 Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 1 Aug 2025 10:23:23 -0400 Subject: [PATCH 17/27] lint task overhaul. --- taskfiles/lint.yaml | 86 ++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index 532f52dd..3df2dcaf 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -77,6 +77,10 @@ tasks: cmds: - task: "utils:cpp-lint:clang-tidy-find" vars: + EXCLUDE_PATTERNS: + - "buffer-parser.cpp" + - "intersect-test.cpp" + - "reader-parser.cpp" FLAGS: - "--config-file '{{.G_UTILS_CONFIGS_DIR}}/.clang-tidy'" - "-p '{{.BUILD_DIR}}'" @@ -102,46 +106,48 @@ tasks: - task: "utils:cpp-lint:clang-tidy-find" vars: EXCLUDE_PATTERNS: - - "{{.ROOT_DIR}}/src/log_surgeon/Buffer.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/BufferParser.cpp" - - "{{.ROOT_DIR}}/src/log_surgeon/BufferParser.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/Constants.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/FileReader.cpp" - - "{{.ROOT_DIR}}/src/log_surgeon/FileReader.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/Dfa.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/DfaState.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/Nfa.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/RegexAST.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/RegisterOperation.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/finite_automata/UnicodeIntervalTree.tpp" - - "{{.ROOT_DIR}}/src/log_surgeon/Lalr1Parser.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/Lalr1Parser.tpp" - - "{{.ROOT_DIR}}/src/log_surgeon/Lexer.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/Lexer.tpp" - - "{{.ROOT_DIR}}/src/log_surgeon/LogEvent.cpp" - - "{{.ROOT_DIR}}/src/log_surgeon/LogEvent.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/LogParser.cpp" - - "{{.ROOT_DIR}}/src/log_surgeon/LogParser.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/LogParserOutputBuffer.cpp" - - "{{.ROOT_DIR}}/src/log_surgeon/Parser.tpp" - - "{{.ROOT_DIR}}/src/log_surgeon/parser_types.cpp" - - "{{.ROOT_DIR}}/src/log_surgeon/parser_types.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/ParserAst.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/ParserInputBuffer.cpp" - - "{{.ROOT_DIR}}/src/log_surgeon/ParserInputBuffer.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/Reader.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/ReaderParser.cpp" - - "{{.ROOT_DIR}}/src/log_surgeon/ReaderParser.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/Schema.cpp" - - "{{.ROOT_DIR}}/src/log_surgeon/SchemaParser.cpp" - - "{{.ROOT_DIR}}/src/log_surgeon/SchemaParser.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/Token.cpp" - - "{{.ROOT_DIR}}/src/log_surgeon/Token.hpp" - - "{{.ROOT_DIR}}/src/log_surgeon/utils.hpp" - - "{{.ROOT_DIR}}/tests/CMakeLists.txt" - - "{{.ROOT_DIR}}/tests/test-dfa.cpp" - - "{{.ROOT_DIR}}/tests/test-lexer.cpp" - - "{{.ROOT_DIR}}/tests/test-nfa.cpp" + - "log_surgeon/Buffer.hpp" + - "log_surgeon/BufferParser.cpp" + - "log_surgeon/BufferParser.hpp" + - "log_surgeon/Constants.hpp" + - "log_surgeon/FileReader.cpp" + - "log_surgeon/FileReader.hpp" + - "log_surgeon/finite_automata/Dfa.hpp" + - "log_surgeon/finite_automata/DfaState.hpp" + - "log_surgeon/finite_automata/Nfa.hpp" + - "log_surgeon/finite_automata/RegexAST.hpp" + - "log_surgeon/finite_automata/RegisterOperation.hpp" + - "log_surgeon/finite_automata/UnicodeIntervalTree.tpp" + - "log_surgeon/Lalr1Parser.hpp" + - "log_surgeon/Lalr1Parser.tpp" + - "log_surgeon/Lexer.hpp" + - "log_surgeon/Lexer.tpp" + - "log_surgeon/LogEvent.cpp" + - "log_surgeon/LogEvent.hpp" + - "log_surgeon/LogParser.cpp" + - "log_surgeon/LogParser.hpp" + - "log_surgeon/LogParserOutputBuffer.cpp" + - "log_surgeon/Parser.tpp" + - "log_surgeon/parser_types.cpp" + - "log_surgeon/parser_types.hpp" + - "log_surgeon/ParserAst.hpp" + - "log_surgeon/ParserInputBuffer.cpp" + - "log_surgeon/ParserInputBuffer.hpp" + - "log_surgeon/Reader.hpp" + - "log_surgeon/ReaderParser.cpp" + - "log_surgeon/ReaderParser.hpp" + - "log_surgeon/Schema.cpp" + - "log_surgeon/SchemaParser.cpp" + - "log_surgeon/SchemaParser.hpp" + - "log_surgeon/Token.cpp" + - "log_surgeon/Token.hpp" + - "log_surgeon/utils.hpp" + - "test-buffer-parser.cpp" + - "test-dfa.cpp" + - "test-lexer.cpp" + - "test-nfa.cpp" + - "test-regex-ast.cpp" + - "test-schema.cpp" FLAGS: - "--config-file '{{.G_UTILS_CONFIGS_DIR}}/.clang-tidy'" - "-p '{{.BUILD_DIR}}'" From da54c5740d0c9ba44af7fb06d6bdb090287870f9 Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 1 Aug 2025 10:24:42 -0400 Subject: [PATCH 18/27] Fix common files in examples so clang-tidy doesn't fail with all examples files excluded. --- examples/buffer-parser.cpp | 9 ++++----- examples/common.cpp | 21 +++++++++++---------- examples/common.hpp | 3 ++- examples/reader-parser.cpp | 9 ++++----- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/buffer-parser.cpp b/examples/buffer-parser.cpp index fc2ce987..d6e7fe12 100644 --- a/examples/buffer-parser.cpp +++ b/examples/buffer-parser.cpp @@ -14,7 +14,7 @@ using namespace std; using namespace log_surgeon; -auto process_logs(string& schema_path, string const& input_path) -> void { +auto process_logs(string const& schema_path, string const& input_path) -> void { BufferParser parser{schema_path}; optional loglevel_id{parser.get_variable_id("loglevel")}; if (false == loglevel_id.has_value()) { @@ -91,11 +91,10 @@ auto process_logs(string& schema_path, string const& input_path) -> void { } auto main(int argc, char* argv[]) -> int { - if (int err{check_input(argc, argv)}; 0 != err) { + std::vector const args(argv + 1, argv + argc); + if (int const err{check_input(args)}; 0 != err) { return err; } - string schema_path{argv[1]}; - string input_path{argv[2]}; - process_logs(schema_path, input_path); + process_logs(args[0], args[1]); return 0; } diff --git a/examples/common.cpp b/examples/common.cpp index adb3cbb6..0403e997 100644 --- a/examples/common.cpp +++ b/examples/common.cpp @@ -1,30 +1,31 @@ #include "common.hpp" +#include #include -#include #include #include #include #include +#include using namespace std; using namespace log_surgeon; -auto check_input(int argc, char* argv[]) -> int { +auto check_input(std::vector const& args) -> int { int ret{0}; - if (3 != argc) { + if (3 != args.size()) { ret = 1; - cout << "Not enough arguments." << endl; - } else if (filesystem::path f{argv[1]}; false == filesystem::exists(f)) { + cout << "Not enough arguments.\n"; + } else if (filesystem::path const f{args[0]}; false == filesystem::exists(f)) { ret = 2; - cout << "Schema file does not exist." << endl; - } else if (filesystem::path f{argv[2]}; false == filesystem::exists(f)) { + cout << "Schema file does not exist.\n"; + } else if (filesystem::path const f{args[1]}; false == filesystem::exists(f)) { ret = 3; - cout << "Input file does not exist." << endl; + cout << "Input file does not exist.\n"; } if (0 != ret) { - cout << "usage: " << endl; + cout << "usage: \n"; } return ret; } @@ -45,5 +46,5 @@ auto print_timestamp_loglevel(LogEventView const& event, uint32_t loglevel_id) - cout << ", loglevel:"; cout << loglevel->to_string_view(); } - cout << endl; + cout << "\n"; } diff --git a/examples/common.hpp b/examples/common.hpp index 69e0468f..f66a5cb5 100644 --- a/examples/common.hpp +++ b/examples/common.hpp @@ -1,12 +1,13 @@ #ifndef COMMON_HPP #define COMMON_HPP +#include #include #include #include -auto check_input(int argc, char* argv[]) -> int; +auto check_input(std::vector const& args) -> int; auto print_timestamp_loglevel(log_surgeon::LogEventView const& event, uint32_t loglevel_id) -> void; diff --git a/examples/reader-parser.cpp b/examples/reader-parser.cpp index 71a5a3da..5f896e9a 100644 --- a/examples/reader-parser.cpp +++ b/examples/reader-parser.cpp @@ -13,7 +13,7 @@ using namespace std; using namespace log_surgeon; -auto process_logs(string& schema_path, string const& input_path) -> void { +auto process_logs(string const& schema_path, string const& input_path) -> void { ReaderParser parser{schema_path}; optional loglevel_id{parser.get_variable_id("loglevel")}; if (false == loglevel_id.has_value()) { @@ -60,11 +60,10 @@ auto process_logs(string& schema_path, string const& input_path) -> void { } auto main(int argc, char* argv[]) -> int { - if (int err{check_input(argc, argv)}; 0 != err) { + std::vector const args(argv + 1, argv + argc); + if (int const err{check_input(args)}; 0 != err) { return err; } - string schema_path{argv[1]}; - string input_path{argv[2]}; - process_logs(schema_path, input_path); + process_logs(args[0], args[1]); return 0; } From c8ba98c940768488483309470f54238e3c3b8899 Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 1 Aug 2025 10:44:12 -0400 Subject: [PATCH 19/27] Fix check-cpp-static-log-surgeon alias. --- taskfiles/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index 3df2dcaf..ed17b635 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -91,7 +91,7 @@ tasks: check-cpp-static-log-surgeon: # NOTE: We alias the fix task until we determine which clang-tidy fixes can be applied safely. - aliases: ["fix-cpp-static"] + aliases: ["fix-cpp-static-log-surgeon"] vars: BUILD_DIR: "{{.G_LOG_SURGEON_DEBUG_BUILD_DIR}}" sources: *log_surgeon_sources From 834aea1aa9febce30e20511e4d8f3a6b65f1727c Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 1 Aug 2025 10:44:25 -0400 Subject: [PATCH 20/27] Undo yml rename for this PR. --- .github/workflows/{lint.yaml => lint.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{lint.yaml => lint.yml} (100%) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yml similarity index 100% rename from .github/workflows/lint.yaml rename to .github/workflows/lint.yml From 158543dc00854d92c54c5a88b3addcd96b7fb476 Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 1 Aug 2025 10:52:31 -0400 Subject: [PATCH 21/27] Remove old script. --- tools/init.sh | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100755 tools/init.sh diff --git a/tools/init.sh b/tools/init.sh deleted file mode 100755 index d22bf78b..00000000 --- a/tools/init.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -# Exit on any error -set -e - -# Error on undefined variable -set -u - -repo_dir="$(git rev-parse --show-toplevel)" -clang_tidy_config_src_relative_to_repo="tools/yscope-dev-utils/lint-configs/.clang-tidy" - -clang_tidy_config_src="${repo_dir}/${clang_tidy_config_src_relative_to_repo}" -clang_tidy_config_dst="${repo_dir}/.clang-tidy" -if [ ! -e "$clang_tidy_config_dst" ]; then - ln -s "$clang_tidy_config_src_relative_to_repo" "$clang_tidy_config_dst" -else - if [ "$(readlink -f "$clang_tidy_config_dst")" != "$(readlink -f "$clang_tidy_config_src")" ]; - then - echo "Unexpected clang-tidy config at $clang_tidy_config_dst" - fi -fi From 1753510757ff1543a245d105531b3a9c164a134d Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 1 Aug 2025 10:56:53 -0400 Subject: [PATCH 22/27] add uv to workflows. --- .github/workflows/build.yaml | 11 +++++++++++ .github/workflows/lint.yml | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9eaf2550..33b14307 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -49,6 +49,17 @@ jobs: shell: "bash" run: "npm install -g @go-task/cli" + - name: "Install uv" + shell: "bash" + run: |- + curl \ + --fail \ + --location \ + --silent \ + --show-error \ + https://astral.sh/uv/0.8.4/install.sh \ + | sh + - name: "Build and run unit tests" run: "task test:run-${{matrix.build_type}}" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ab8aa639..fae47d4a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -33,6 +33,17 @@ jobs: - name: "Install task" run: "npm install -g @go-task/cli" + - name: "Install uv" + shell: "bash" + run: |- + curl \ + --fail \ + --location \ + --silent \ + --show-error \ + https://astral.sh/uv/0.8.4/install.sh \ + | sh + - if: "matrix.os == 'macos-15'" name: "Install coreutils (for md5sum)" run: "brew install coreutils" From 4428af41e3e2c5798dbcfefd6d6d8d4a71050364 Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 1 Aug 2025 10:56:59 -0400 Subject: [PATCH 23/27] Update readme. --- README.md | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index ab5a1ed4..946c74c4 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ Requirements: * [fmt] >= 8.0.1 * [GSL] >= 4.0.0 * [Task] >= 3.38 +* [uv] >= 0.7.10 To build and install the project to `$HOME/.local`: @@ -153,45 +154,15 @@ is set to true and unit tests are built. Before submitting a PR, ensure you've run our linting tools and either fixed any violations or suppressed the warning. -### Requirements - -We currently support running our linting tools on Linux and macOS. If you're developing on another -OS, you can submit a [feature request][feature-req]. If you can't run the linting workflows -locally, you can enable and run the [lint] workflow in your fork. - -To run the linting tools, besides commonly installed tools like `tar`, you'll need: - -* [clang-tidy] -* `md5sum` -* Python 3.8 or newer -* python3-venv -* [Task] - -### Setup - -```shell -./tools/init.sh -``` - ### Running the linters -Currently, `clang-tidy` has to be run manually: - -```shell -find src tests \ - -type f \ - \( -iname "*.cpp" -o -iname "*.hpp" \) \ - -print0 | \ - xargs -0 clang-tidy --config-file .clang-tidy -p build -``` - -To report all errors run: +To report all errors, run: ```shell task lint:check ``` -To fix cpp errors, and report yml errors, run: +To automatically fix any supported format or linting errors, run: ```shell task lint:fix @@ -217,9 +188,8 @@ The following are issues we're aware of and working on: * Support for submatch extraction will be coming in a future release. [Catch2]: https://github.com/catchorg/Catch2/tree/devel -[clang-tidy]: https://clang.llvm.org/extra/clang-tidy/ [feature-req]: https://github.com/y-scope/log-surgeon/issues/new?assignees=&labels=enhancement&template=feature-request.yml [fmt]: https://github.com/fmtlib/fmt [GSL]: https://github.com/microsoft/GSL -[lint]: https://github.com/y-scope/log-surgeon/blob/main/.github/workflows/lint.yml [Task]: https://taskfile.dev/ +[uv]: https://docs.astral.sh/uv From 802911cb8bbe0ae17137bffa73caea83466b3f01 Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 1 Aug 2025 11:18:50 -0400 Subject: [PATCH 24/27] Fix args size. --- examples/common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/common.cpp b/examples/common.cpp index 0403e997..094762b5 100644 --- a/examples/common.cpp +++ b/examples/common.cpp @@ -14,7 +14,7 @@ using namespace log_surgeon; auto check_input(std::vector const& args) -> int { int ret{0}; - if (3 != args.size()) { + if (2 != args.size()) { ret = 1; cout << "Not enough arguments.\n"; } else if (filesystem::path const f{args[0]}; false == filesystem::exists(f)) { From 0a0e3de283b680f22b71c0409f50587e7ec493e0 Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 1 Aug 2025 11:26:04 -0400 Subject: [PATCH 25/27] Fix build issue maybe related to clang 20.1.8 vs 20.1.6. --- src/log_surgeon/Token.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/log_surgeon/Token.cpp b/src/log_surgeon/Token.cpp index f0a8ae68..136f8217 100644 --- a/src/log_surgeon/Token.cpp +++ b/src/log_surgeon/Token.cpp @@ -1,5 +1,6 @@ #include "Token.hpp" +#include > #include #include From 9d07d1101a01f322168938ce9555a35b14ce5463 Mon Sep 17 00:00:00 2001 From: davidlion Date: Fri, 1 Aug 2025 11:31:26 -0400 Subject: [PATCH 26/27] autocomplete too lit. --- src/log_surgeon/Token.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/log_surgeon/Token.cpp b/src/log_surgeon/Token.cpp index 136f8217..e8966412 100644 --- a/src/log_surgeon/Token.cpp +++ b/src/log_surgeon/Token.cpp @@ -1,6 +1,6 @@ #include "Token.hpp" -#include > +#include #include #include From 2698e1d37b9f00e6b7239af87b0531b334a182e8 Mon Sep 17 00:00:00 2001 From: davidlion Date: Mon, 4 Aug 2025 21:19:16 -0400 Subject: [PATCH 27/27] Fix merge mistake. --- .github/workflows/lint.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index fae47d4a..b4353cac 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -44,10 +44,6 @@ jobs: https://astral.sh/uv/0.8.4/install.sh \ | sh - - if: "matrix.os == 'macos-15'" - name: "Install coreutils (for md5sum)" - run: "brew install coreutils" - # We use clang for linting so CMake doesn't generate compile_commands.json with any gcc # specific flags that would confuse clang-tidy. - if: "matrix.os == 'ubuntu-24.04'"