Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

build/

# Meson subproject downloads
subprojects/*/
subprojects/packagecache/
subprojects/.wraplock

# User-specific files
*.rsuser
*.suo
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
33 changes: 27 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,20 @@ 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)

## Installation

### Using as a Dependency

#### CMake
```cmake
include(FetchContent)

Expand All @@ -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
Expand Down
52 changes: 52 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
option('build_tests', type : 'boolean', value : false, description : 'Build unit tests')
16 changes: 16 additions & 0 deletions subprojects/gtest.wrap
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions subprojects/starlet_logger.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[wrap-git]
url = https://github.com/starlet-engine/logger.git
revision = main
depth = 1

[provide]
starlet_logger = starlet_logger_dep
7 changes: 7 additions & 0 deletions subprojects/starlet_math.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[wrap-git]
url = https://github.com/starlet-engine/math.git
revision = main
depth = 1

[provide]
starlet_math = starlet_math_dep
7 changes: 7 additions & 0 deletions subprojects/starlet_serializer.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[wrap-git]
url = https://github.com/starlet-engine/serializer.git
revision = main
depth = 1

[provide]
starlet_serializer = starlet_serializer_dep
15 changes: 15 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
test_exe = executable('starlet_serializer_tests',
files(
'image_parser_test.cpp',
'mesh_parser_test.cpp',
'parser_test.cpp',
'scene_parser_test.cpp',
'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)
Loading