From 7357cb03e7ee57efd668b9ddf45befd36e4af52d Mon Sep 17 00:00:00 2001 From: Martin Gerhardy Date: Sun, 23 Jul 2023 12:18:11 +0200 Subject: [PATCH 1/5] CI: added windows and osx builds also store the artifacts of the build for all platforms that way users can easily download the binaries without having to compile the binaries on their own --- .github/workflows/main.yml | 28 +++++++++++++++++++++------- .gitignore | 6 ++++++ CMakeLists.txt | 20 ++++++++++++++++++++ src/ogt_vox.h | 3 +++ 4 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 .gitignore create mode 100644 CMakeLists.txt diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1a2dee9..d1c5d17 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,15 +11,29 @@ on: - master jobs: - linux: - runs-on: ubuntu-latest + build: + runs-on: ${{ matrix.platform.os }} + name: ${{ matrix.platform.name }} steps: - uses: actions/checkout@v3 - - name: Linux + - name: Build run: | - g++ -Wall -Wextra -pedantic apps/vox2fbx.cpp - g++ -Wall -Wextra -pedantic apps/vox2obj.cpp - g++ -Wall -Wextra -pedantic apps/voxmerge.cpp - g++ -Wall -Wextra -pedantic apps/voxseparate.cpp + cmake . + cmake --build . --config Release + cmake --install . --prefix opengametools-install + + - name: Upload the build artifacts + uses: actions/upload-artifact@v3 + with: + name: opengametools-${{ matrix.platform.name }} + path: opengametools-install + + strategy: + fail-fast: false + matrix: + platform: + - { name: Windows, os: windows-2022 } + - { name: Ubuntu, os: ubuntu-latest } + - { name: MacOS, os: macos-latest } diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cfb1c36 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/vox2fbx +/vox2obj +/voxmerge +/voxseparate +/build + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..40b9920 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +project(opengametools CXX) + +set(APPS + vox2fbx + vox2obj + voxmerge + voxseparate +) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED on) + +foreach (app ${APPS}) + add_executable(${app} apps/${app}.cpp) + target_compile_options(${app} PRIVATE + $<$:/W4> + $<$:-Wall -Wextra -Wpedantic> + ) + install(TARGETS ${app} DESTINATION bin) +endforeach() diff --git a/src/ogt_vox.h b/src/ogt_vox.h index de38252..c4f8d15 100644 --- a/src/ogt_vox.h +++ b/src/ogt_vox.h @@ -206,6 +206,9 @@ #include #elif __APPLE__ // general Apple compiler + #include + #include + #include // for size_t #elif defined(__GNUC__) // any GCC* #include From 32ed562cae4ff73df2b29fb66aa2bd88076b8676 Mon Sep 17 00:00:00 2001 From: Martin Gerhardy Date: Sun, 23 Jul 2023 18:04:16 +0200 Subject: [PATCH 2/5] CMAKE: compile the demo, too --- CMakeLists.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40b9920..6a49e88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,20 +1,22 @@ project(opengametools CXX) set(APPS - vox2fbx - vox2obj - voxmerge - voxseparate + apps/vox2fbx.cpp + apps/vox2obj.cpp + apps/voxmerge.cpp + apps/voxseparate.cpp + demo/demo_vox.cpp ) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED on) foreach (app ${APPS}) - add_executable(${app} apps/${app}.cpp) - target_compile_options(${app} PRIVATE + get_filename_component(APP_NAME ${app} NAME_WE) + add_executable(${APP_NAME} ${app}) + target_compile_options(${APP_NAME} PRIVATE $<$:/W4> $<$:-Wall -Wextra -Wpedantic> ) - install(TARGETS ${app} DESTINATION bin) + install(TARGETS ${APP_NAME} DESTINATION bin) endforeach() From 8c31c98ec13e3e08f8bf2f2120b5e0379e0cb37d Mon Sep 17 00:00:00 2001 From: Martin Gerhardy Date: Sun, 23 Jul 2023 18:08:16 +0200 Subject: [PATCH 3/5] DEMO: allow to specify the filename from command line --- demo/demo_vox.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/demo/demo_vox.cpp b/demo/demo_vox.cpp index 5a0b420..35a72cc 100644 --- a/demo/demo_vox.cpp +++ b/demo/demo_vox.cpp @@ -101,9 +101,9 @@ uint32_t count_solid_voxels_in_model(const ogt_vox_model* model) return solid_voxel_count; } -void demo_load_and_save() +bool demo_load_and_save(const char *filename) { - const ogt_vox_scene* scene = load_vox_scene_with_groups("vox/test_groups.vox"); + const ogt_vox_scene* scene = load_vox_scene_with_groups(filename); if (scene) { printf("#layers: %u\n", scene->num_layers); @@ -170,7 +170,10 @@ void demo_load_and_save() save_vox_scene("saved.vox", scene); ogt_vox_destroy_scene(scene); + return true; } + fprintf(stderr, "Failed to load %s\n", filename); + return false; } // demonstrates merging multiple scenes together @@ -216,8 +219,17 @@ void demo_merge_scenes() int main(int argc, char** argv) { - demo_load_and_save(); + const char *filename = "vox/test_groups.vox"; + if (argc == 2) + { + filename = argv[1]; + } + if (!demo_load_and_save(filename)) + { + return 1; + } demo_merge_scenes(); + return 0; } /* ------------------------------------------------------------------------------------------------------------------------------------------------- From 40ca9cbc1e16dfedfd1eaf308b4e9445b210382e Mon Sep 17 00:00:00 2001 From: Martin Gerhardy Date: Sun, 23 Jul 2023 18:11:55 +0200 Subject: [PATCH 4/5] CMAKE: added test by running the demo (see previous commit regarding exit codes) --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a49e88..354ec4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,3 +20,6 @@ foreach (app ${APPS}) ) install(TARGETS ${APP_NAME} DESTINATION bin) endforeach() + +include(CTest) +add_test(NAME test_multiple_model_scene COMMAND $ ${CMAKE_CURRENT_SOURCE_DIR}/demo/vox/test_multiple_model_scene.vox) From 4e72f44a7cbdeef06d2859975fca0c56245c710c Mon Sep 17 00:00:00 2001 From: Martin Gerhardy Date: Sun, 23 Jul 2023 18:13:51 +0200 Subject: [PATCH 5/5] CI: execute the tests also see issue #37 --- .github/workflows/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d1c5d17..3f7f3ff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,6 +24,10 @@ jobs: cmake --build . --config Release cmake --install . --prefix opengametools-install + - name: Test + run: | + ctest -V -C Release . + - name: Upload the build artifacts uses: actions/upload-artifact@v3 with: