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
diff --git a/.gitignore b/.gitignore
index febab51..670e409 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,11 @@
build/
+# Meson subproject downloads
+subprojects/*/
+subprojects/packagecache/
+subprojects/.wraplock
+
# 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/README.md b/README.md
index c310e9c..d33a623 100644
--- a/README.md
+++ b/README.md
@@ -1,31 +1,32 @@
# Starlet Logger
-
-[](https://isocpp.org/std/the-standard)
+
+[](https://isocpp.org/std/the-standard)
[](./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/meson.build b/meson.build
new file mode 100644
index 0000000..4c8d382
--- /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 = static_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/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
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)
+