diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b53a9184..59e7fb83 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,4 +1,4 @@ -name: "Build" +name: "build" on: pull_request: @@ -7,16 +7,18 @@ on: - "CMakeLists.txt" - "examples/**/*" - "src/**/*" + - "taskfile.yaml" + - "taskfiles/**/*" - "tests/**/*" - - "tools/deps-install/ubuntu/**/*" push: paths: - ".github/workflows/build.yaml" - "CMakeLists.txt" - "examples/**/*" - "src/**/*" + - "taskfile.yaml" + - "taskfiles/**/*" - "tests/**/*" - - "tools/deps-install/ubuntu/**/*" workflow_call: concurrency: @@ -28,31 +30,32 @@ jobs: build: strategy: matrix: - os: ["macos-latest", "ubuntu-22.04"] - build_type: ["Debug", "Release"] + os: + - "macos-15" + - "ubuntu-22.04" + build_type: + - "debug" + - "release" runs-on: "${{matrix.os}}" steps: - uses: "actions/checkout@v4" + with: + submodules: "recursive" - - name: "Install Catch2 on macOS" - if: "matrix.os == 'macos-latest'" - run: "brew install catch2" + - name: "Install task" + shell: "bash" + run: "npm install -g @go-task/cli" - - name: "Install Catch2 on Ubuntu" - if: "matrix.os == 'ubuntu-22.04'" - run: "./tools/deps-install/ubuntu/install-catch2.sh 3.6.0" - - - name: "Build Executables" - run: |- - cmake -B ./build -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=${{matrix.build_type}} - cmake --build ./build --config ${{matrix.build_type}} - cmake --install ./build --prefix ./install - cmake -S examples -B ./examples/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} - cmake --build ./examples/build --config ${{matrix.build_type}} - - - name: "Run Unit Tests" - run: "ctest --test-dir ./build" + - name: "Build and run unit tests" + run: "task test:${{matrix.build_type}}" - name: "Print test log on failure" if: "failure()" - run: "cat ./build/Testing/Temporary/LastTest.log" + run: "cat ./build/log-surgeon/Testing/Temporary/LastTest.log" + + - name: "Build and run examples" + run: |- + task build:examples-${{matrix.build_type}} + ./build/examples/${{matrix.build_type}}/buffer-parser ./examples/schema.txt README.md + ./build/examples/${{matrix.build_type}}/reader-parser ./examples/schema.txt README.md + ./build/examples/${{matrix.build_type}}/intersect-test diff --git a/.gitignore b/.gitignore index 567609b1..09944214 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +.task/ build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 9742746a..035b5b91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,10 +13,10 @@ endif() include(CMakePackageConfigHelpers) include(GNUInstallDirs) -include(FetchContent) option(BUILD_SHARED_LIBS "Build using shared libraries" OFF) option(log_surgeon_BUILD_TESTING "Build the testing tree." ON) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL @@ -31,6 +31,11 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) endif() if(log_surgeon_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) + # If previously undefined, `BUILD_TESTING` will be set to ON. include(CTest) endif() @@ -39,46 +44,19 @@ if(BUILD_TESTING AND log_surgeon_BUILD_TESTING) set(log_surgeon_ENABLE_TESTS ON) endif() -list(APPEND DEPS_TO_FETCH "") - # Use as is unsupported in gcc-10. -find_package(fmt 8.0.1 QUIET) -if(fmt_FOUND) - message(STATUS "Found fmt ${fmt_VERSION}.") -else() - FetchContent_Declare(fmt - GIT_REPOSITORY https://github.com/fmtlib/fmt - GIT_TAG "8.0.1" - GIT_SHALLOW ON - ) - # Force fmt to generate install rules - set(FMT_INSTALL ON CACHE BOOL "Enable installation for fmt." FORCE) - list(APPEND DEPS_TO_FETCH fmt) -endif() +find_package(fmt 8.0.1 REQUIRED) +message(STATUS "Found fmt ${fmt_VERSION}.") -find_package(Microsoft.GSL QUIET) -if(Microsoft.GSL_FOUND) - message(STATUS "Found Microsoft.GSL ${Microsoft.GSL_VERSION}.") -else() - FetchContent_Declare(GSL - GIT_REPOSITORY "https://github.com/microsoft/GSL" - GIT_TAG "v4.0.0" - GIT_SHALLOW ON - ) - list(APPEND DEPS_TO_FETCH GSL) -endif() +find_package(Microsoft.GSL 4.0.0 REQUIRED) +message(STATUS "Found Microsoft.GSL ${Microsoft.GSL_VERSION}.") if(log_surgeon_ENABLE_TESTS) - find_package(Catch2 3 REQUIRED) - if(Catch2_FOUND) - message(STATUS "Found Catch2 ${Catch2_VERSION}.") - endif() + find_package(Catch2 3.8.1 REQUIRED) + message(STATUS "Found Catch2 ${Catch2_VERSION}.") include(Catch) endif() -# Declare the details of all fetched content before making them available. -FetchContent_MakeAvailable("${DEPS_TO_FETCH}") - set(SOURCE_FILES src/log_surgeon/Buffer.hpp src/log_surgeon/BufferParser.cpp @@ -138,31 +116,15 @@ set(SOURCE_FILES set(LOG_SURGEON_INSTALL_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/log_surgeon) set(LOG_SURGEON_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}) -# Directory for installing third-party includes that the user doesn't have installed. -set(LOG_SURGEON_THIRD_PARTY_INCLUDE_DIR "${LOG_SURGEON_INSTALL_INCLUDE_DIR}/log_surgeon/third_party_include") add_library(log_surgeon ${SOURCE_FILES}) add_library(log_surgeon::log_surgeon ALIAS log_surgeon) -if (Microsoft.GSL_FOUND) - target_link_libraries(log_surgeon - PUBLIC - Microsoft.GSL::GSL - ) -else() - # Since the user doesn't have GSL installed, use the GSL headers directly. - # NOTE: - # - We can't link against the `Microsoft.GSL::GSL` target since that would require adding `GSL` - # to the `install` command and force the user to have GSL installed when using log-surgeon. - # - At install time, we'll copy GSL into log-surgeon's third-party includes directory. - target_include_directories(log_surgeon - PUBLIC - $ - $ - ) -endif() - -target_link_libraries(log_surgeon PUBLIC fmt::fmt) +target_link_libraries(log_surgeon + PUBLIC + fmt::fmt + Microsoft.GSL::GSL + ) target_include_directories(log_surgeon PUBLIC @@ -213,16 +175,6 @@ install( PATTERN "*.hpp" PATTERN "*.tpp" ) -if (NOT Microsoft.GSL_FOUND) - install( - DIRECTORY - # NOTE: We don't include a trailing slash so that the gsl directory is copied rather than - # its contents. - "${GSL_SOURCE_DIR}/include/gsl" - DESTINATION - "${LOG_SURGEON_THIRD_PARTY_INCLUDE_DIR}" - ) -endif () configure_package_config_file( ${CMAKE_CURRENT_LIST_DIR}/cmake/log_surgeon-config.cmake.in diff --git a/README.md b/README.md index 2739c2aa..b5a304f0 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ constraints](docs/parsing-constraints.md) on how log events can be parsed. ## Motivating example Let's say we want to parse and inspect multi-line log events like this: + ``` 2023-02-23T18:10:14-0500 DEBUG task_123 crashed. Dumping stacktrace: #0 0x000000000040110e in bar () at example.cpp:6 @@ -29,6 +30,7 @@ Let's say we want to parse and inspect multi-line log events like this: ``` Using the [example schema file](examples/schema.txt) which includes these rules: + ``` timestamp:\d{4}\-\d{2}\-\d{2}T\d{2}:\d{2}:\d{2}\-\d{4} ... @@ -36,6 +38,7 @@ loglevel:INFO|DEBUG|WARN|ERROR ``` We can parse and inspect the events as follows: + ```cpp // Define a reader to read from your data source Reader reader{/* */}; @@ -81,35 +84,30 @@ For advanced uses, `log-surgeon` also has a Requirements: -* CMake +* CMake >= 3.22.1 * GCC >= 10 or Clang >= 7 -* [Catch2] >= 3 - * On Ubuntu <= 20.04, you can install it using: - ```shell - sudo tools/deps-install/ubuntu/install-catch2.sh 3.6.0 - ``` - * On Ubuntu >= 22.04, you can install it using: - ```shell - sudo apt-get update - sudo apt-get install catch2 - ``` - * On macOS, you can install it using: - ```shell - brew install catch2 - ``` - -From the repo's root, run: +* [Catch2] >= 3.8.1 +* [fmt] >= 8.0.1 +* [GSL] >= 4.0.0 +* [Task] >= 3.38 + +To build and install the project to `~/.local`: + +```shell +task install:release INSTALL_PREFIX="~/.local" +``` + +Or to only build the project: + ```shell -# Generate the CMake project -cmake -S . -B build -DBUILD_TESTING=OFF -# Build the project -cmake --build ./build -j -# Install the project to ~/.local -cmake --install ./build --prefix ~/.local +task build:release ``` -To build the debug version and tests replace the first command with: -`cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON` +To build the debug version: + +```shell +task build:debug +``` ## Documentation and examples @@ -121,9 +119,10 @@ To build the debug version and tests replace the first command with: ## Testing -To run unit tests, run: +To build and run all unit tests: + ```shell -cmake --build ./build --target test +task test:debug ``` When generating targets, the CMake variable `BUILD_TESTING` is followed (unless overruled by setting @@ -158,6 +157,7 @@ To run the linting tools, besides commonly installed tools like `tar`, you'll ne ### Running the linters Currently, `clang-tidy` has to be run manually: + ```shell find src tests \ -type f \ @@ -200,5 +200,7 @@ The following are issues we're aware of and working on: [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/ diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 4caa7375..b8a1e204 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.22.1) project(log-surgeon-examples) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) @@ -7,13 +7,16 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) endif() -find_package(log_surgeon QUIET) -if(log_surgeon_FOUND) - message(STATUS "Found log_surgeon ${log_surgeon_VERSION}.") -else() - add_subdirectory(.. log-surgeon-build EXCLUDE_FROM_ALL) +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) endif() +find_package(log_surgeon REQUIRED) +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) diff --git a/examples/README.md b/examples/README.md index ed00dd7e..b9b0380e 100644 --- a/examples/README.md +++ b/examples/README.md @@ -11,13 +11,10 @@ the intersection between a schema DFA and a search query DFA. ## Building First, ensure you've built and installed the library by following -[these steps][2]. Then run the following commands (from the repo's root): +[these steps][2]. Then run the following command: ```shell -# Generate the CMake project -cmake -S examples -B examples/build -# Build the project -cmake --build examples/build -j +task build:examples-debug ``` ## Running @@ -25,9 +22,9 @@ cmake --build examples/build -j The example programs can be run as follows: ```shell -./examples/build/buffer-parser ./examples/schema.txt log.txt -./examples/build/reader-parser ./examples/schema.txt log.txt -./examples/build/intersect-test +./build/examples/debug/buffer-parser ./examples/schema.txt log.txt +./build/examples/debug/reader-parser ./examples/schema.txt log.txt +./build/examples/debug/intersect-test ``` where: diff --git a/taskfile.yaml b/taskfile.yaml index 45d2f368..378d598c 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -1,11 +1,18 @@ version: "3" +set: ["u", "pipefail"] +shopt: ["globstar"] + includes: + build: "taskfiles/build.yaml" + deps: "taskfiles/deps.yaml" lint: "taskfiles/lint.yaml" - utils: "tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml" + test: "taskfiles/test.yaml" vars: G_BUILD_DIR: "{{.ROOT_DIR}}/build" + G_EXAMPLES_BUILD_DIR: "{{.G_BUILD_DIR}}/examples" + G_LOG_SURGEON_BUILD_DIR: "{{.G_BUILD_DIR}}/log-surgeon" tasks: clean: "rm -rf '{{.G_BUILD_DIR}}'" diff --git a/taskfiles/build.yaml b/taskfiles/build.yaml new file mode 100644 index 00000000..e294f03e --- /dev/null +++ b/taskfiles/build.yaml @@ -0,0 +1,128 @@ +version: "3" + +includes: + deps: + internal: true + taskfile: "deps.yaml" + utils: + internal: true + taskfile: "../tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml" + +tasks: + debug: + cmds: + - task: "build" + vars: + BUILD_TYPE: "debug" + + 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" + vars: + BUILD_TYPE: "debug" + + examples-release: + cmds: + - task: "examples" + 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: + requires: + vars: ["INSTALL_PREFIX"] + cmds: + - task: "install" + vars: + BUILD_TYPE: "debug" + INSTALL_PREFIX: "{{.INSTALL_PREFIX}}" + + install-release: + requires: + vars: ["INSTALL_PREFIX"] + cmds: + - task: "install" + vars: + BUILD_TYPE: "release" + INSTALL_PREFIX: "{{.INSTALL_PREFIX}}" + + build: + 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}}" + - task: "utils:cmake:build" + vars: + BUILD_DIR: "{{.G_LOG_SURGEON_BUILD_DIR}}/{{.BUILD_TYPE}}" + + examples: + 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" + vars: + BUILD_DIR: "{{.G_EXAMPLES_BUILD_DIR}}/{{.BUILD_TYPE}}" + + install: + internal: true + requires: + vars: ["BUILD_TYPE", "INSTALL_PREFIX"] + deps: + - "{{.BUILD_TYPE}}" + cmds: + - task: "utils:cmake:install" + vars: + BUILD_DIR: "{{.G_LOG_SURGEON_BUILD_DIR}}/{{.BUILD_TYPE}}" + INSTALL_PREFIX: "{{.INSTALL_PREFIX}}" diff --git a/taskfiles/deps.yaml b/taskfiles/deps.yaml new file mode 100644 index 00000000..719986c8 --- /dev/null +++ b/taskfiles/deps.yaml @@ -0,0 +1,82 @@ +version: "3" + +includes: + utils: + internal: true + taskfile: "../tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml" + +vars: + G_DEPS_DIR: "{{.G_BUILD_DIR}}/deps" + + # This path must be kept in-sync with its usage in CMakeLists.txt and examples/CMakeLists.txt. + G_DEPS_CMAKE_SETTINGS_DIR: "{{.G_DEPS_DIR}}/cmake-settings" + +tasks: + default: + deps: + - "all" + + all: + run: "once" + cmds: + - task: "utils:cmake:install-deps-and-generate-settings" + vars: + CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" + DEP_TASK: "all-parallel" + + all-parallel: + internal: true + run: "once" + deps: + - "Catch2" + - "fmt" + - "Microsoft.GSL" + + Catch2: + internal: true + run: "once" + cmds: + - task: "utils:cmake:install-remote-tar" + vars: + CMAKE_GEN_ARGS: + - "-DCMAKE_BUILD_TYPE=Release" + - "-DCMAKE_CXX_STANDARD=20" + - "-DCMAKE_INSTALL_MESSAGE=LAZY" + CMAKE_PACKAGE_NAME: "Catch2" + CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" + TAR_SHA256: "18b3f70ac80fccc340d8c6ff0f339b2ae64944782f8d2fca2bd705cf47cadb79" + TAR_URL: "https://github.com/catchorg/Catch2/archive/refs/tags/v3.8.1.tar.gz" + WORK_DIR: "{{.G_DEPS_DIR}}" + + fmt: + internal: true + run: "once" + cmds: + - task: "utils:cmake:install-remote-tar" + vars: + CMAKE_GEN_ARGS: + - "-DCMAKE_BUILD_TYPE=Release" + - "-DCMAKE_INSTALL_MESSAGE=LAZY" + - "-DFMT_DOC=OFF" + - "-DFMT_TEST=OFF" + CMAKE_PACKAGE_NAME: "fmt" + CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" + TAR_SHA256: "b06ca3130158c625848f3fb7418f235155a4d389b2abc3a6245fb01cb0eb1e01" + TAR_URL: "https://github.com/fmtlib/fmt/archive/refs/tags/8.0.1.tar.gz" + WORK_DIR: "{{.G_DEPS_DIR}}" + + Microsoft.GSL: + internal: true + run: "once" + cmds: + - task: "utils:cmake:install-remote-tar" + vars: + CMAKE_GEN_ARGS: + - "-DCMAKE_BUILD_TYPE=Release" + - "-DCMAKE_INSTALL_MESSAGE=LAZY" + - "-DGSL_TEST=OFF" + CMAKE_PACKAGE_NAME: "Microsoft.GSL" + CMAKE_SETTINGS_DIR: "{{.G_DEPS_CMAKE_SETTINGS_DIR}}" + TAR_SHA256: "f0e32cb10654fea91ad56bde89170d78cfbf4363ee0b01d8f097de2ba49f6ce9" + TAR_URL: "https://github.com/microsoft/GSL/archive/refs/tags/v4.0.0.tar.gz" + WORK_DIR: "{{.G_DEPS_DIR}}" diff --git a/taskfiles/lint.yaml b/taskfiles/lint.yaml index 851cc1f1..60bd3228 100644 --- a/taskfiles/lint.yaml +++ b/taskfiles/lint.yaml @@ -1,5 +1,10 @@ version: "3" +includes: + utils: + internal: true + taskfile: "../tools/yscope-dev-utils/exports/taskfiles/utils/utils.yaml" + vars: G_LINT_VENV_DIR: "{{.G_BUILD_DIR}}/lint-venv" @@ -87,18 +92,18 @@ tasks: run: "once" deps: - ":init" - - task: ":utils:checksum:validate" + - task: "utils:checksum:validate" vars: CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"] cmds: - - task: ":utils:misc:create-venv" + - task: "utils:misc:create-venv" vars: LABEL: "lint" OUTPUT_DIR: "{{.OUTPUT_DIR}}" REQUIREMENTS_FILE: "{{.ROOT_DIR}}/lint-requirements.txt" # This command must be last - - task: ":utils:checksum:compute" + - task: "utils:checksum:compute" vars: CHECKSUM_FILE: "{{.CHECKSUM_FILE}}" INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"] diff --git a/taskfiles/test.yaml b/taskfiles/test.yaml new file mode 100644 index 00000000..1de5f83a --- /dev/null +++ b/taskfiles/test.yaml @@ -0,0 +1,25 @@ +version: "3" + +includes: + build: + internal: true + taskfile: "build.yaml" + +tasks: + debug: + cmds: + - task: "unit-test" + vars: + BUILD_TYPE: "debug" + + release: + cmds: + - task: "unit-test" + vars: + BUILD_TYPE: "release" + + unit-test: + internal: true + deps: + - "build:{{.BUILD_TYPE}}" + cmd: "{{.G_LOG_SURGEON_BUILD_DIR}}/{{.BUILD_TYPE}}/tests/unit-test" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 12d0be83..33e766c8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,53 +1,14 @@ -set( - SOURCES_LOG_SURGEON - ../src/log_surgeon/FileReader.cpp - ../src/log_surgeon/FileReader.hpp - ../src/log_surgeon/finite_automata/Capture.hpp - ../src/log_surgeon/finite_automata/DeterminizationConfiguration.hpp - ../src/log_surgeon/finite_automata/Dfa.hpp - ../src/log_surgeon/finite_automata/DfaState.hpp - ../src/log_surgeon/finite_automata/DfaTransition.hpp - ../src/log_surgeon/finite_automata/Nfa.hpp - ../src/log_surgeon/finite_automata/NfaSpontaneousTransition.hpp - ../src/log_surgeon/finite_automata/NfaState.hpp - ../src/log_surgeon/finite_automata/PrefixTree.cpp - ../src/log_surgeon/finite_automata/PrefixTree.hpp - ../src/log_surgeon/finite_automata/RegexAST.hpp - ../src/log_surgeon/finite_automata/RegisterHandler.hpp - ../src/log_surgeon/finite_automata/RegisterOperation.hpp - ../src/log_surgeon/finite_automata/StateType.hpp - ../src/log_surgeon/finite_automata/TagOperation.hpp - ../src/log_surgeon/Lalr1Parser.hpp - ../src/log_surgeon/Lalr1Parser.tpp - ../src/log_surgeon/ParserAst.cpp - ../src/log_surgeon/ParserAst.hpp - ../src/log_surgeon/parser_types.cpp - ../src/log_surgeon/parser_types.hpp - ../src/log_surgeon/ParserInputBuffer.hpp - ../src/log_surgeon/ParserInputBuffer.cpp - ../src/log_surgeon/Schema.hpp - ../src/log_surgeon/Schema.cpp - ../src/log_surgeon/SchemaParser.cpp - ../src/log_surgeon/SchemaParser.hpp - ../src/log_surgeon/Token.cpp - ../src/log_surgeon/Token.hpp - ../src/log_surgeon/types.hpp - ../src/log_surgeon/UniqueIdGenerator.hpp +add_executable(unit-test) +target_sources(unit-test + PRIVATE + test-capture.cpp + test-dfa.cpp + test-lexer.cpp + test-nfa.cpp + test-prefix-tree.cpp + test-register-handler.cpp ) - -set( - SOURCES_TESTS - test-capture.cpp - test-dfa.cpp - test-lexer.cpp - test-nfa.cpp - test-prefix-tree.cpp - test-register-handler.cpp -) - -add_executable(unit-test ${SOURCES_LOG_SURGEON} ${SOURCES_TESTS}) target_link_libraries(unit-test PRIVATE Catch2::Catch2WithMain log_surgeon::log_surgeon) -target_include_directories(unit-test PRIVATE ${CMAKE_SOURCE_DIR}/src) target_compile_features(unit-test PRIVATE cxx_std_20) catch_discover_tests(unit-test) diff --git a/tools/deps-install/ubuntu/install-catch2.sh b/tools/deps-install/ubuntu/install-catch2.sh deleted file mode 100755 index aa063d72..00000000 --- a/tools/deps-install/ubuntu/install-catch2.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env bash - -# Dependencies: -# - cmake -# - curl -# - g++ -# NOTE: Dependencies should be installed outside the script to allow the script to be largely -# distro-agnostic - -# Exit on any error -set -e - -# Error on undefined variable -set -u - -cUsage="Usage: ${BASH_SOURCE[0]} [ <.deb output directory>]" -if [ "$#" -lt 1 ]; then - echo "$cUsage" - exit -fi -version=$1 - -package_name=catch2 -temp_dir="/tmp/${package_name}-installation" -deb_output_dir="$temp_dir" -if [[ "$#" -gt 1 ]]; then - deb_output_dir="$(readlink -f "$2")" - if [ ! -d "$deb_output_dir" ]; then - echo "$deb_output_dir does not exist or is not a directory" - exit - fi -fi - -# Check if already installed -set +e -dpkg -l ${package_name} | grep "$version" -installed=$? -set -e -if [ $installed -eq 0 ]; then - # Nothing to do - exit -fi - -echo "Checking for elevated privileges..." -install_cmd_args=() -if [ ${EUID:-$(id -u)} -ne 0 ]; then - sudo echo "Script can elevate privileges." - install_cmd_args+=("sudo") -fi - -# Get number of cpu cores -num_cpus=$(grep -c ^processor /proc/cpuinfo) - -# Download -mkdir -p "$temp_dir" -cd "$temp_dir" -extracted_dir="${temp_dir}/Catch2-${version}" -if [ ! -e "${extracted_dir}" ]; then - tar_filename="v${version}.tar.gz" - if [ ! -e "${tar_filename}" ]; then - curl \ - -fsSL \ - "https://github.com/catchorg/Catch2/archive/refs/tags/${tar_filename}" \ - -o "${tar_filename}" - fi - - tar -xf "${tar_filename}" -fi - -# Build -cd "$extracted_dir" -cmake -B build -S . -DBUILD_TESTING=OFF -DCMAKE_CXX_STANDARD=17 -cmake --build build --parallel "$num_cpus" - -# Check if checkinstall is installed -set +e -command -v checkinstall -checkinstall_installed=$? -set -e - -# Install -if [ $checkinstall_installed -eq 0 ]; then - install_cmd_args+=( - checkinstall - --pkgname "$package_name" - --pkgversion "$version" - --provides "$package_name" - --nodoc - -y - --pakdir "$deb_output_dir" - ) -fi -install_cmd_args+=( - cmake --install build -) -"${install_cmd_args[@]}" - -# Clean up -rm -rf "$temp_dir" diff --git a/tools/yscope-dev-utils b/tools/yscope-dev-utils index d22183ff..76aecbd6 160000 --- a/tools/yscope-dev-utils +++ b/tools/yscope-dev-utils @@ -1 +1 @@ -Subproject commit d22183ffa3fb95745b012eb38a6e13b7e5f06fca +Subproject commit 76aecbd6d0db6e2078005431946b5c2e716c4291