From 8d6a8879d4b06e30f317b47d731543cb90a58533 Mon Sep 17 00:00:00 2001 From: Masonlet Date: Tue, 10 Mar 2026 23:59:59 -0400 Subject: [PATCH 1/4] feat: add Meson build support --- .gitignore | 5 ++++ CMakeLists.txt | 4 +-- meson.build | 52 +++++++++++++++++++++++++++++++++ meson.options | 1 + subprojects/gtest.wrap | 16 ++++++++++ subprojects/starlet_logger.wrap | 7 +++++ subprojects/starlet_math.wrap | 7 +++++ tests/meson.build | 16 ++++++++++ 8 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 meson.build create mode 100644 meson.options create mode 100644 subprojects/gtest.wrap create mode 100644 subprojects/starlet_logger.wrap create mode 100644 subprojects/starlet_math.wrap create mode 100644 tests/meson.build 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 3ed3f16..9c7481d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,13 +12,13 @@ if(NOT TARGET ${PROJECT_NAME}) if(NOT TARGET starlet_math) FetchContent_Declare(starlet_math - GIT_REPOSITORY https://github.com/masonlet/starlet-math.git + GIT_REPOSITORY https://github.com/starlet-engine/math.git GIT_TAG main ) endif() if(NOT TARGET starlet_logger) 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 ) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..ee760a3 --- /dev/null +++ b/meson.build @@ -0,0 +1,52 @@ +project('starlet-serializer', 'cpp', + version : '1.0.0', + meson_version : '>=1.1', + default_options : ['cpp_std=c++20'] +) + +inc = include_directories('inc') + +sources = files( + 'src/parser/parser.cpp', + 'src/parser/image_parser.cpp', + 'src/parser/mesh_parser.cpp', + 'src/parser/scene_parser.cpp', + 'src/parser/image/bmp_parser.cpp', + 'src/parser/image/image_parser_base.cpp', + 'src/parser/image/tga_parser.cpp', + 'src/parser/mesh/obj_parser.cpp', + 'src/parser/mesh/ply_parser.cpp', + 'src/parser/scene/camera_parser.cpp', + 'src/parser/scene/colour_parser.cpp', + 'src/parser/scene/grid_parser.cpp', + 'src/parser/scene/light_parser.cpp', + 'src/parser/scene/model_parser.cpp', + 'src/parser/scene/primitive_parser.cpp', + 'src/parser/scene/texture_parser.cpp', + 'src/parser/scene/velocity_parser.cpp', + 'src/writer/scene_writer.cpp', +) + +starlet_math = subproject('starlet_math') +starlet_math_dep = starlet_math.get_variable('starlet_math_dep') + +starlet_logger = subproject('starlet_logger') +starlet_logger_dep = starlet_logger.get_variable('starlet_logger_dep') + +starlet_serializer_lib = static_library('starlet_serializer', sources, + include_directories : inc, + dependencies : [starlet_math_dep, starlet_logger_dep] +) + +starlet_serializer_dep = declare_dependency( + link_with : starlet_serializer_lib, + include_directories : inc, + dependencies : [starlet_math_dep, starlet_logger_dep] +) + +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/subprojects/starlet_math.wrap b/subprojects/starlet_math.wrap new file mode 100644 index 0000000..b87a2c3 --- /dev/null +++ b/subprojects/starlet_math.wrap @@ -0,0 +1,7 @@ +[wrap-git] +url = https://github.com/starlet-engine/math.git +revision = main +depth = 1 + +[provide] +starlet_math = starlet_math_dep diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000..12c7cc9 --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,16 @@ +test_exe = executable('starlet_serializer_tests', + files( + 'image_parser_test.cpp', + 'mesh_parser_test.cpp', + 'parser_test.cpp', + 'scene_parser_test.cpp', + 'test_helpers.hpp', + 'image/bmp_parser_test.cpp', + 'image/tga_parser_test.cpp', + 'mesh/obj_parser_test.cpp', + 'mesh/ply_parser_test.cpp', + ), + dependencies : [starlet_serializer_dep, gtest_dep] +) + +test('starlet-serializer tests', test_exe) From 05f86176eb7749bbfe55f3d8fb72444c6d0a105f Mon Sep 17 00:00:00 2001 From: Masonlet Date: Wed, 11 Mar 2026 00:07:36 -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 afa4676b93c5493c8675ad24d36e23d7f18649be Mon Sep 17 00:00:00 2001 From: Masonlet Date: Wed, 11 Mar 2026 00:13:51 -0400 Subject: [PATCH 3/4] docs: update README with Meson --- README.md | 33 +++++++++++++++++++++++------ subprojects/starlet_serializer.wrap | 7 ++++++ 2 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 subprojects/starlet_serializer.wrap diff --git a/README.md b/README.md index f884402..f466bc9 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,11 @@ A lightweight serialization library for **Starlet** projects to handle both data - Error-safe macros: `STARLET_PARSE_OR`, `STARLET_PARSE_STRING_OR` ## Prerequisites + - C++20 or later -- CMake 3.20+ +- One of the following Build Systems, + - CMake 3.20+ + - Meson 1.1+ - **Dependencies**: - [starlet-math](https://github.com/starlet-engine/math) (auto-fetched) - [starlet-logger](https://github.com/starlet-engine/logger) (auto-fetched) @@ -34,6 +37,8 @@ A lightweight serialization library for **Starlet** projects to handle both data ## Installation ### Using as a Dependency + +#### CMake ```cmake include(FetchContent) @@ -46,19 +51,35 @@ FetchContent_MakeAvailable(starlet_serializer) target_link_libraries(app_name PRIVATE starlet_serializer) ``` -### Building from Source +#### Meson +> **Note:** Meson does not fetch dependencies automatically. Add the [`starlet_serializer.wrap`](./subprojects/starlet_serializer.wrap) file to your project's `subprojects` directory. + +In your `meson.build`: + +```python +starlet_serializer = subproject('starlet_serializer') +starlet_serializer_dep = starlet_serializer.get_variable('starlet_serializer_dep') +executable('app_name', 'main.cpp', dependencies: starlet_serializer_dep) +``` + +### Building and Testing ```bash git clone https://github.com/starlet-engine/serializer.git cd serializer -cmake -B build -cmake --build build ``` -## Testing +#### CMake ```bash cmake -B build -DBUILD_TESTS=ON cmake --build build -ctest --test-dir build --output-on-failure +ctest --test-dir build +``` + +#### Meson +```bash +meson setup build -Dbuild_tests=true +meson compile -C build +meson test -C build ``` ## License diff --git a/subprojects/starlet_serializer.wrap b/subprojects/starlet_serializer.wrap new file mode 100644 index 0000000..8651c49 --- /dev/null +++ b/subprojects/starlet_serializer.wrap @@ -0,0 +1,7 @@ +[wrap-git] +url = https://github.com/starlet-engine/serializer.git +revision = main +depth = 1 + +[provide] +starlet_serializer = starlet_serializer_dep From d93bb33873d5f5f7b11c0a50c2662dfa79c0fb74 Mon Sep 17 00:00:00 2001 From: Masonlet Date: Wed, 11 Mar 2026 00:18:57 -0400 Subject: [PATCH 4/4] build: remove header from Meson sources --- tests/meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/meson.build b/tests/meson.build index 12c7cc9..6dbf370 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -4,7 +4,6 @@ test_exe = executable('starlet_serializer_tests', 'mesh_parser_test.cpp', 'parser_test.cpp', 'scene_parser_test.cpp', - 'test_helpers.hpp', 'image/bmp_parser_test.cpp', 'image/tga_parser_test.cpp', 'mesh/obj_parser_test.cpp',