From 5e393b27a49c4cf7b2be12eab6ce05012bbdf524 Mon Sep 17 00:00:00 2001 From: Masonlet Date: Tue, 10 Mar 2026 17:20:19 -0400 Subject: [PATCH 1/4] feat: add Meson build support --- .gitignore | 4 ++++ CMakeLists.txt | 2 +- meson.build | 27 +++++++++++++++++++++++++++ meson.options | 1 + subprojects/gtest.wrap | 16 ++++++++++++++++ tests/meson.build | 9 +++++++++ 6 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 meson.build create mode 100644 meson.options create mode 100644 subprojects/gtest.wrap create mode 100644 tests/meson.build diff --git a/.gitignore b/.gitignore index febab51..6444d3b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,10 @@ build/ +# Meson subproject downloads +subprojects/*/ +subprojects/packagecache/ + # User-specific files *.rsuser *.suo diff --git a/CMakeLists.txt b/CMakeLists.txt index e74e4ec..7ee7946 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ if(BUILD_TESTS) FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG v1.14.0 + GIT_TAG v1.17.0 ) # For Windows: Prevent overriding the parent project's compiler/linker settings diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..e605c9d --- /dev/null +++ b/meson.build @@ -0,0 +1,27 @@ +project('starlet-logger', 'cpp', + version : '1.0.0', + meson_version : '>=1.1', + default_options : ['cpp_std=c++17'] +) + +inc = include_directories('inc') + +sources = files( + 'src/logger.cpp' +) + +starlet_logger_lib = library('starlet_logger', sources, + include_directories : inc +) + +starlet_logger_dep = declare_dependency( + link_with : starlet_logger_lib, + include_directories : inc +) + +if get_option('build_tests') + gtest_dep = dependency('gtest_main', + fallback : ['gtest', 'gtest_main_dep'] + ) + subdir('tests') +endif diff --git a/meson.options b/meson.options new file mode 100644 index 0000000..332f699 --- /dev/null +++ b/meson.options @@ -0,0 +1 @@ +option('build_tests', type : 'boolean', value : false, description : 'Build unit tests') diff --git a/subprojects/gtest.wrap b/subprojects/gtest.wrap new file mode 100644 index 0000000..9902a4f --- /dev/null +++ b/subprojects/gtest.wrap @@ -0,0 +1,16 @@ +[wrap-file] +directory = googletest-1.17.0 +source_url = https://github.com/google/googletest/archive/refs/tags/v1.17.0.tar.gz +source_filename = googletest-1.17.0.tar.gz +source_hash = 65fab701d9829d38cb77c14acdc431d2108bfdbf8979e40eb8ae567edf10b27c +patch_filename = gtest_1.17.0-4_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/gtest_1.17.0-4/get_patch +patch_hash = 3abf7662d09db706453a5b064a1e914678c74b9d9b0b19382747ca561d0d8750 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/gtest_1.17.0-4/googletest-1.17.0.tar.gz +wrapdb_version = 1.17.0-4 + +[provide] +gtest = gtest_dep +gtest_main = gtest_main_dep +gmock = gmock_dep +gmock_main = gmock_main_dep diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000..6929d65 --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,9 @@ +test_exe = executable('starlet_logger_tests', + files( + 'logger_test.cpp', + ), + dependencies : [starlet_logger_dep, gtest_dep] +) + +test('starlet-logger tests', test_exe) + From dec3aa46dbc6eba9b7ddf403569d679c574b281c Mon Sep 17 00:00:00 2001 From: Masonlet Date: Tue, 10 Mar 2026 17:23:43 -0400 Subject: [PATCH 2/4] ci: add Meson test job to GitHub Actions --- .github/workflows/test.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b809b72..ff234fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,13 +7,33 @@ on: branches: [ "main" ] jobs: - test: + test-cmake: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Configure CMake run: cmake -B build -DBUILD_TESTS=ON + - name: Build run: cmake --build build --config Release + - name: Run tests run: ctest --test-dir build -C Release --output-on-failure + + test-meson: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install Meson and Ninja + run: pip install meson ninja + + - name: Configure Meson + run: meson setup build -Dbuild_tests=true + + - name: Build + run: meson compile -C build + + - name: Run tests + run: meson test -C build --verbose From 7e6d15b6163fd2c9832ccdecd72757cf8f942a1a Mon Sep 17 00:00:00 2001 From: Masonlet Date: Tue, 10 Mar 2026 17:59:14 -0400 Subject: [PATCH 3/4] docs: update README with Meson, remove BR and clarify instructions --- README.md | 49 +++++++++++++++++++++------------ subprojects/starlet_logger.wrap | 7 +++++ 2 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 subprojects/starlet_logger.wrap diff --git a/README.md b/README.md index c310e9c..d33a623 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,32 @@ # Starlet Logger -![Tests](https://github.com/masonlet/starlet-logger/actions/workflows/test.yml/badge.svg) -[![C++20](https://img.shields.io/badge/C%2B%2B-17-blue.svg)](https://isocpp.org/std/the-standard) +![Tests](https://github.com/starlet-engine/logger/actions/workflows/test.yml/badge.svg) +[![C++17](https://img.shields.io/badge/C%2B%2B-17-blue.svg)](https://isocpp.org/std/the-standard) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE) A lightweight logging utility for C++ applications. ## Features - Four log levels: Info, Debug, Warning, Error -- Automatic stream routing (stdout for info/debug, stderror for warnings/errors) +- Automatic stream routing (stdout for info/debug, stderr for warnings/errors) - Caller, function, and msg context in every log message - Debug logs compiled out in release builds (NDEBUG) - Custom warning return value for permissible warnings -
- ## Prerequisites - C++17 or later -- CMake 3.20+ +- One of the following Build Systems, + - CMake 3.20+ + - Meson 1.1+ ## Using as a Dependency +### CMake ```cmake include(FetchContent) FetchContent_Declare(starlet_logger - GIT_REPOSITORY https://github.com/masonlet/starlet-logger.git + GIT_REPOSITORY https://github.com/starlet-engine/logger.git GIT_TAG main ) FetchContent_MakeAvailable(starlet_logger) @@ -33,25 +34,37 @@ FetchContent_MakeAvailable(starlet_logger) target_link_libraries(app_name PRIVATE starlet_logger) ``` -
+### Meson +> **Note:** Meson does not fetch dependencies automatically. Add the [`starlet_logger.wrap`](./subprojects/starlet_logger.wrap) file to your project's `subprojects` directory. + +In your `meson.build`: + +```python +starlet_logger = subproject('starlet_logger') +starlet_logger_dep = starlet_logger.get_variable('starlet_logger_dep') +executable('app_name', 'main.cpp', dependencies: starlet_logger_dep) +``` ## Building and Testing ```bash # 1. Clone starlet-logger -git clone https://github.com/masonlet/starlet-logger.git +git clone https://github.com/starlet-engine/logger.git cd starlet-logger +``` -# 2. Create a build directory and generate build files -mkdir build -cd build -cmake -DBUILD_TESTS=ON .. - -# 3. Build and run tests -cmake --build . -ctest +### CMake +```bash +cmake -B build -DBUILD_TESTS=ON +cmake --build build +ctest --test-dir build ``` -
+### Meson +```bash +meson setup build -Dbuild_tests=true +meson compile -C build +meson test -C build +``` ## License MIT License - see [LICENSE](./LICENSE) for details. diff --git a/subprojects/starlet_logger.wrap b/subprojects/starlet_logger.wrap new file mode 100644 index 0000000..9423ff8 --- /dev/null +++ b/subprojects/starlet_logger.wrap @@ -0,0 +1,7 @@ +[wrap-git] +url = https://github.com/starlet-engine/logger.git +revision = main +depth = 1 + +[provide] +starlet_logger = starlet_logger_dep From f2f2e7503b320a5437874d012d0fb174b3f105b6 Mon Sep 17 00:00:00 2001 From: Masonlet Date: Tue, 10 Mar 2026 18:08:33 -0400 Subject: [PATCH 4/4] fix: use static_library --- .gitignore | 1 + meson.build | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6444d3b..670e409 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ build/ # Meson subproject downloads subprojects/*/ subprojects/packagecache/ +subprojects/.wraplock # User-specific files *.rsuser diff --git a/meson.build b/meson.build index e605c9d..4c8d382 100644 --- a/meson.build +++ b/meson.build @@ -10,7 +10,7 @@ sources = files( 'src/logger.cpp' ) -starlet_logger_lib = library('starlet_logger', sources, +starlet_logger_lib = static_library('starlet_logger', sources, include_directories : inc )