From a4823f3887ae273fe57ae8d8604137597a626409 Mon Sep 17 00:00:00 2001 From: S David <2100425+s-daveb@users.noreply.github.com> Date: Wed, 17 Apr 2024 00:17:53 -0400 Subject: [PATCH] Restructure project directories --- {apps/editors => .vim}/.keep | 0 {editorconfig => .vim}/local.vimrc | 0 Apps/CMakeLists.txt | 3 + {data => Apps/Demos}/.keep | 0 {demo => Apps/Demos}/CMakeLists.txt | 0 {demo => Apps/Demos}/phong/CMakeLists.txt | 0 {demo => Apps/Demos}/phong/GameSettings.hpp | 0 {demo => Apps/Demos}/phong/Phong.cpp | 0 {demo => Apps/Demos}/phong/Phong.hpp | 0 {demo => Apps/Demos}/phong/main.cpp | 0 {demo => Apps/Editors}/.keep | 0 {cmake => CMake}/BuildProperties.cmake | 0 {cmake => CMake}/CPM.cmake | 0 CMakeLists.txt | 22 +-- Modules/CMakeLists.txt | 1 + {src => Modules/elemental}/CMakeLists.txt | 12 +- {src => Modules/elemental}/JsonConfigFile.cpp | 0 {src => Modules/elemental}/LoopRegulator.cpp | 0 {src => Modules/elemental}/Observable.cpp | 0 {src => Modules/elemental}/SdlEventSource.cpp | 0 {src => Modules/elemental}/SdlRenderer.cpp | 0 .../elemental/include}/.keep | 0 .../elemental/include}/Component.hpp | 0 .../elemental/include}/ComponentFactory.hpp | 0 .../elemental/include}/IDrawable.hpp | 0 .../elemental/include}/IEventSource.hpp | 0 .../elemental/include}/INonCopyable.hpp | 0 .../elemental/include}/IObserver.hpp | 0 .../elemental/include}/IRenderer.hpp | 0 .../elemental/include}/JsonConfigFile.hpp | 0 .../elemental/include}/LoopRegulator.hpp | 0 .../elemental/include}/Observable.hpp | 0 .../elemental/include}/SDL_Memory.hpp | 0 .../elemental/include}/SdlEventSource.hpp | 0 .../elemental/include}/SdlRenderer.hpp | 0 .../elemental/include}/Singleton.hpp | 0 .../details/ComponentFactory.impl.hpp | 0 .../elemental/include/sys}/.keep | 0 .../elemental/include}/sys/debuginfo.hpp | 0 .../elemental/include}/sys/paths.hpp | 0 .../elemental/include}/sys/platform.hpp | 0 .../elemental/include}/types.hpp | 0 .../elemental/include}/types/errors.hpp | 0 .../elemental/include}/types/input.hpp | 0 .../elemental/include}/types/pointers.hpp | 0 .../elemental/include}/types/rendering.hpp | 0 .../elemental/include}/types/units.hpp | 0 .../elemental/include}/util/bitwise.hpp | 0 .../elemental/include}/util/debug.hpp | 0 .../elemental/include}/util/serialization.hpp | 0 .../elemental/include}/util/testing.hpp | 0 {src => Modules/elemental}/paths.cpp | 0 {tests => Tests}/CMakeLists.txt | 21 ++- {tests => Tests}/IRenderer.test.cpp | 0 {tests => Tests}/JsonConfigFile.test.cpp | 0 {tests => Tests}/LoopRegulator.test.cpp | 0 {tests => Tests}/Observable.test.cpp | 0 {tests => Tests}/SDL_Memory.test.cpp | 0 {tests => Tests}/Singleton.template.test.cpp | 0 {data/tests => Tests/data}/test-skull.png | Bin .../data}/test-skull.png.license | 0 {data/tests => Tests/data}/winter_map.jpg | Bin .../data}/winter_map.jpg.license | 0 {tests => Tests}/paths.test.cpp | 0 {tests => Tests}/runtime.test.cpp | 0 {tests => Tests}/sdl/CMakeLists.txt | 0 {tests => Tests}/sdl/SdlEventSource.test.cpp | 0 {tests => Tests}/sdl/SdlMain.cpp | 0 {tests => Tests}/sdl/SdlRenderer.test.cpp | 0 {tests => Tests}/test-utils/SdlHelpers.hpp | 0 {tests => Tests}/test-utils/common.hpp | 0 {scripts => Util}/fswatch-build.env | 0 {scripts => Util}/fswatch-build.sh | 0 {scripts => Util}/fswatch-docs.sh | 0 {scripts => Util}/run-clang-tidy.sh | 0 apps/CMakeLists.txt | 5 - apps/game/CMakeLists.txt | 22 --- apps/game/ElementalGame.cpp | 131 ------------------ apps/game/ElementalGame.hpp | 60 -------- apps/game/main.cpp | 37 ----- include/sys/.keep | 0 81 files changed, 28 insertions(+), 286 deletions(-) rename {apps/editors => .vim}/.keep (100%) rename {editorconfig => .vim}/local.vimrc (100%) create mode 100644 Apps/CMakeLists.txt rename {data => Apps/Demos}/.keep (100%) rename {demo => Apps/Demos}/CMakeLists.txt (100%) rename {demo => Apps/Demos}/phong/CMakeLists.txt (100%) rename {demo => Apps/Demos}/phong/GameSettings.hpp (100%) rename {demo => Apps/Demos}/phong/Phong.cpp (100%) rename {demo => Apps/Demos}/phong/Phong.hpp (100%) rename {demo => Apps/Demos}/phong/main.cpp (100%) rename {demo => Apps/Editors}/.keep (100%) rename {cmake => CMake}/BuildProperties.cmake (100%) rename {cmake => CMake}/CPM.cmake (100%) create mode 100644 Modules/CMakeLists.txt rename {src => Modules/elemental}/CMakeLists.txt (75%) rename {src => Modules/elemental}/JsonConfigFile.cpp (100%) rename {src => Modules/elemental}/LoopRegulator.cpp (100%) rename {src => Modules/elemental}/Observable.cpp (100%) rename {src => Modules/elemental}/SdlEventSource.cpp (100%) rename {src => Modules/elemental}/SdlRenderer.cpp (100%) rename {editorconfig => Modules/elemental/include}/.keep (100%) rename {include => Modules/elemental/include}/Component.hpp (100%) rename {include => Modules/elemental/include}/ComponentFactory.hpp (100%) rename {include => Modules/elemental/include}/IDrawable.hpp (100%) rename {include => Modules/elemental/include}/IEventSource.hpp (100%) rename {include => Modules/elemental/include}/INonCopyable.hpp (100%) rename {include => Modules/elemental/include}/IObserver.hpp (100%) rename {include => Modules/elemental/include}/IRenderer.hpp (100%) rename {include => Modules/elemental/include}/JsonConfigFile.hpp (100%) rename {include => Modules/elemental/include}/LoopRegulator.hpp (100%) rename {include => Modules/elemental/include}/Observable.hpp (100%) rename {include => Modules/elemental/include}/SDL_Memory.hpp (100%) rename {include => Modules/elemental/include}/SdlEventSource.hpp (100%) rename {include => Modules/elemental/include}/SdlRenderer.hpp (100%) rename {include => Modules/elemental/include}/Singleton.hpp (100%) rename {include => Modules/elemental/include}/details/ComponentFactory.impl.hpp (100%) rename {include => Modules/elemental/include/sys}/.keep (100%) rename {include => Modules/elemental/include}/sys/debuginfo.hpp (100%) rename {include => Modules/elemental/include}/sys/paths.hpp (100%) rename {include => Modules/elemental/include}/sys/platform.hpp (100%) rename {include => Modules/elemental/include}/types.hpp (100%) rename {include => Modules/elemental/include}/types/errors.hpp (100%) rename {include => Modules/elemental/include}/types/input.hpp (100%) rename {include => Modules/elemental/include}/types/pointers.hpp (100%) rename {include => Modules/elemental/include}/types/rendering.hpp (100%) rename {include => Modules/elemental/include}/types/units.hpp (100%) rename {include => Modules/elemental/include}/util/bitwise.hpp (100%) rename {include => Modules/elemental/include}/util/debug.hpp (100%) rename {include => Modules/elemental/include}/util/serialization.hpp (100%) rename {include => Modules/elemental/include}/util/testing.hpp (100%) rename {src => Modules/elemental}/paths.cpp (100%) rename {tests => Tests}/CMakeLists.txt (78%) rename {tests => Tests}/IRenderer.test.cpp (100%) rename {tests => Tests}/JsonConfigFile.test.cpp (100%) rename {tests => Tests}/LoopRegulator.test.cpp (100%) rename {tests => Tests}/Observable.test.cpp (100%) rename {tests => Tests}/SDL_Memory.test.cpp (100%) rename {tests => Tests}/Singleton.template.test.cpp (100%) rename {data/tests => Tests/data}/test-skull.png (100%) rename {data/tests => Tests/data}/test-skull.png.license (100%) rename {data/tests => Tests/data}/winter_map.jpg (100%) rename {data/tests => Tests/data}/winter_map.jpg.license (100%) rename {tests => Tests}/paths.test.cpp (100%) rename {tests => Tests}/runtime.test.cpp (100%) rename {tests => Tests}/sdl/CMakeLists.txt (100%) rename {tests => Tests}/sdl/SdlEventSource.test.cpp (100%) rename {tests => Tests}/sdl/SdlMain.cpp (100%) rename {tests => Tests}/sdl/SdlRenderer.test.cpp (100%) rename {tests => Tests}/test-utils/SdlHelpers.hpp (100%) rename {tests => Tests}/test-utils/common.hpp (100%) rename {scripts => Util}/fswatch-build.env (100%) rename {scripts => Util}/fswatch-build.sh (100%) rename {scripts => Util}/fswatch-docs.sh (100%) rename {scripts => Util}/run-clang-tidy.sh (100%) delete mode 100644 apps/CMakeLists.txt delete mode 100644 apps/game/CMakeLists.txt delete mode 100644 apps/game/ElementalGame.cpp delete mode 100644 apps/game/ElementalGame.hpp delete mode 100644 apps/game/main.cpp delete mode 100644 include/sys/.keep diff --git a/apps/editors/.keep b/.vim/.keep similarity index 100% rename from apps/editors/.keep rename to .vim/.keep diff --git a/editorconfig/local.vimrc b/.vim/local.vimrc similarity index 100% rename from editorconfig/local.vimrc rename to .vim/local.vimrc diff --git a/Apps/CMakeLists.txt b/Apps/CMakeLists.txt new file mode 100644 index 0000000..f8b5e3e --- /dev/null +++ b/Apps/CMakeLists.txt @@ -0,0 +1,3 @@ + +add_subdirectory(Demos) +#add_subdirectory(Editors) diff --git a/data/.keep b/Apps/Demos/.keep similarity index 100% rename from data/.keep rename to Apps/Demos/.keep diff --git a/demo/CMakeLists.txt b/Apps/Demos/CMakeLists.txt similarity index 100% rename from demo/CMakeLists.txt rename to Apps/Demos/CMakeLists.txt diff --git a/demo/phong/CMakeLists.txt b/Apps/Demos/phong/CMakeLists.txt similarity index 100% rename from demo/phong/CMakeLists.txt rename to Apps/Demos/phong/CMakeLists.txt diff --git a/demo/phong/GameSettings.hpp b/Apps/Demos/phong/GameSettings.hpp similarity index 100% rename from demo/phong/GameSettings.hpp rename to Apps/Demos/phong/GameSettings.hpp diff --git a/demo/phong/Phong.cpp b/Apps/Demos/phong/Phong.cpp similarity index 100% rename from demo/phong/Phong.cpp rename to Apps/Demos/phong/Phong.cpp diff --git a/demo/phong/Phong.hpp b/Apps/Demos/phong/Phong.hpp similarity index 100% rename from demo/phong/Phong.hpp rename to Apps/Demos/phong/Phong.hpp diff --git a/demo/phong/main.cpp b/Apps/Demos/phong/main.cpp similarity index 100% rename from demo/phong/main.cpp rename to Apps/Demos/phong/main.cpp diff --git a/demo/.keep b/Apps/Editors/.keep similarity index 100% rename from demo/.keep rename to Apps/Editors/.keep diff --git a/cmake/BuildProperties.cmake b/CMake/BuildProperties.cmake similarity index 100% rename from cmake/BuildProperties.cmake rename to CMake/BuildProperties.cmake diff --git a/cmake/CPM.cmake b/CMake/CPM.cmake similarity index 100% rename from cmake/CPM.cmake rename to CMake/CPM.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 06e1166..717dc65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.26) # Additional paths to search for custom and third-party CMake modules -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake) include(BuildProperties) @@ -24,7 +24,6 @@ project(Elemental include(CPM) SET(${PROJECT_NAME}_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -SET(${PROJECT_NAME}_INCLUDE_DIRS ${IOCore_CMAKE_SOURCE_DIR}/include) option(CI_BUILD "Mark this as a CI/CD system build. Defines a C++ preprocessor macro CI_BUILD=1.") if (CI_BUILD) @@ -40,7 +39,7 @@ ON # enable compile_commands.json generation for clangd set(CMAKE_EXPORT_COMPILE_COMMANDS On) -IF( NOT CMAKE_BUILD_TYPE ) +IF(NOT CMAKE_BUILD_TYPE) SET( CMAKE_BUILD_TYPE Debug ) ENDIF() @@ -149,22 +148,13 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug") add_compile_definitions(-DDEBUG=1) endif() -# Include directories -include_directories(${Elemental_CMAKE_SOURCE_DIR}/include) - -# Add a target to copy application resource files to the build dir -add_custom_target(copy_assets - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/data ${Elemental_ARTIFACT_DIR}/share/data - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/data ${CMAKE_BINARY_DIR}/tests/data -) - # Add subdirectories -add_subdirectory(src) -add_subdirectory(demo) -#add_subdirectory(apps) +add_subdirectory(Modules) if(BUILD_TESTING) - add_subdirectory(tests) + add_subdirectory(Tests) endif() +add_subdirectory(Apps) + # vim: ts=2 sw=2 noet foldmethod=indent : diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt new file mode 100644 index 0000000..0d55df7 --- /dev/null +++ b/Modules/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(elemental) diff --git a/src/CMakeLists.txt b/Modules/elemental/CMakeLists.txt similarity index 75% rename from src/CMakeLists.txt rename to Modules/elemental/CMakeLists.txt index 78a91c9..11e7842 100644 --- a/src/CMakeLists.txt +++ b/Modules/elemental/CMakeLists.txt @@ -15,9 +15,13 @@ target_include_directories(elemental SYSTEM BEFORE PUBLIC ${NLOHMANN_JSON_INCLUDE_DIRS} ) +target_include_directories(elemental BEFORE + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include +) + # Add a target to copy this project's header files to the build dir add_custom_target(include_files - COMMAND ${CMAKE_COMMAND} -E copy_directory ${Elemental_CMAKE_SOURCE_DIR}/include ${Elemental_ARTIFACT_DIR}/include + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include ${Elemental_ARTIFACT_DIR}/include ) add_dependencies(elemental include_files) @@ -30,9 +34,9 @@ set(ELEMENTAL_LINK_DEPS ) # Add additional link options for boost::stacktrace -if (USE_BOOST_STACKTRACE) - target_link_options(elemental PUBLIC -rdynamic) -endif() +#if (USE_BOOST_STACKTRACE) +# target_link_options(elemental PUBLIC -rdynamic) +#endif() # Link the library dependencies publicly so that that users of this library # Also get the same dependencies. diff --git a/src/JsonConfigFile.cpp b/Modules/elemental/JsonConfigFile.cpp similarity index 100% rename from src/JsonConfigFile.cpp rename to Modules/elemental/JsonConfigFile.cpp diff --git a/src/LoopRegulator.cpp b/Modules/elemental/LoopRegulator.cpp similarity index 100% rename from src/LoopRegulator.cpp rename to Modules/elemental/LoopRegulator.cpp diff --git a/src/Observable.cpp b/Modules/elemental/Observable.cpp similarity index 100% rename from src/Observable.cpp rename to Modules/elemental/Observable.cpp diff --git a/src/SdlEventSource.cpp b/Modules/elemental/SdlEventSource.cpp similarity index 100% rename from src/SdlEventSource.cpp rename to Modules/elemental/SdlEventSource.cpp diff --git a/src/SdlRenderer.cpp b/Modules/elemental/SdlRenderer.cpp similarity index 100% rename from src/SdlRenderer.cpp rename to Modules/elemental/SdlRenderer.cpp diff --git a/editorconfig/.keep b/Modules/elemental/include/.keep similarity index 100% rename from editorconfig/.keep rename to Modules/elemental/include/.keep diff --git a/include/Component.hpp b/Modules/elemental/include/Component.hpp similarity index 100% rename from include/Component.hpp rename to Modules/elemental/include/Component.hpp diff --git a/include/ComponentFactory.hpp b/Modules/elemental/include/ComponentFactory.hpp similarity index 100% rename from include/ComponentFactory.hpp rename to Modules/elemental/include/ComponentFactory.hpp diff --git a/include/IDrawable.hpp b/Modules/elemental/include/IDrawable.hpp similarity index 100% rename from include/IDrawable.hpp rename to Modules/elemental/include/IDrawable.hpp diff --git a/include/IEventSource.hpp b/Modules/elemental/include/IEventSource.hpp similarity index 100% rename from include/IEventSource.hpp rename to Modules/elemental/include/IEventSource.hpp diff --git a/include/INonCopyable.hpp b/Modules/elemental/include/INonCopyable.hpp similarity index 100% rename from include/INonCopyable.hpp rename to Modules/elemental/include/INonCopyable.hpp diff --git a/include/IObserver.hpp b/Modules/elemental/include/IObserver.hpp similarity index 100% rename from include/IObserver.hpp rename to Modules/elemental/include/IObserver.hpp diff --git a/include/IRenderer.hpp b/Modules/elemental/include/IRenderer.hpp similarity index 100% rename from include/IRenderer.hpp rename to Modules/elemental/include/IRenderer.hpp diff --git a/include/JsonConfigFile.hpp b/Modules/elemental/include/JsonConfigFile.hpp similarity index 100% rename from include/JsonConfigFile.hpp rename to Modules/elemental/include/JsonConfigFile.hpp diff --git a/include/LoopRegulator.hpp b/Modules/elemental/include/LoopRegulator.hpp similarity index 100% rename from include/LoopRegulator.hpp rename to Modules/elemental/include/LoopRegulator.hpp diff --git a/include/Observable.hpp b/Modules/elemental/include/Observable.hpp similarity index 100% rename from include/Observable.hpp rename to Modules/elemental/include/Observable.hpp diff --git a/include/SDL_Memory.hpp b/Modules/elemental/include/SDL_Memory.hpp similarity index 100% rename from include/SDL_Memory.hpp rename to Modules/elemental/include/SDL_Memory.hpp diff --git a/include/SdlEventSource.hpp b/Modules/elemental/include/SdlEventSource.hpp similarity index 100% rename from include/SdlEventSource.hpp rename to Modules/elemental/include/SdlEventSource.hpp diff --git a/include/SdlRenderer.hpp b/Modules/elemental/include/SdlRenderer.hpp similarity index 100% rename from include/SdlRenderer.hpp rename to Modules/elemental/include/SdlRenderer.hpp diff --git a/include/Singleton.hpp b/Modules/elemental/include/Singleton.hpp similarity index 100% rename from include/Singleton.hpp rename to Modules/elemental/include/Singleton.hpp diff --git a/include/details/ComponentFactory.impl.hpp b/Modules/elemental/include/details/ComponentFactory.impl.hpp similarity index 100% rename from include/details/ComponentFactory.impl.hpp rename to Modules/elemental/include/details/ComponentFactory.impl.hpp diff --git a/include/.keep b/Modules/elemental/include/sys/.keep similarity index 100% rename from include/.keep rename to Modules/elemental/include/sys/.keep diff --git a/include/sys/debuginfo.hpp b/Modules/elemental/include/sys/debuginfo.hpp similarity index 100% rename from include/sys/debuginfo.hpp rename to Modules/elemental/include/sys/debuginfo.hpp diff --git a/include/sys/paths.hpp b/Modules/elemental/include/sys/paths.hpp similarity index 100% rename from include/sys/paths.hpp rename to Modules/elemental/include/sys/paths.hpp diff --git a/include/sys/platform.hpp b/Modules/elemental/include/sys/platform.hpp similarity index 100% rename from include/sys/platform.hpp rename to Modules/elemental/include/sys/platform.hpp diff --git a/include/types.hpp b/Modules/elemental/include/types.hpp similarity index 100% rename from include/types.hpp rename to Modules/elemental/include/types.hpp diff --git a/include/types/errors.hpp b/Modules/elemental/include/types/errors.hpp similarity index 100% rename from include/types/errors.hpp rename to Modules/elemental/include/types/errors.hpp diff --git a/include/types/input.hpp b/Modules/elemental/include/types/input.hpp similarity index 100% rename from include/types/input.hpp rename to Modules/elemental/include/types/input.hpp diff --git a/include/types/pointers.hpp b/Modules/elemental/include/types/pointers.hpp similarity index 100% rename from include/types/pointers.hpp rename to Modules/elemental/include/types/pointers.hpp diff --git a/include/types/rendering.hpp b/Modules/elemental/include/types/rendering.hpp similarity index 100% rename from include/types/rendering.hpp rename to Modules/elemental/include/types/rendering.hpp diff --git a/include/types/units.hpp b/Modules/elemental/include/types/units.hpp similarity index 100% rename from include/types/units.hpp rename to Modules/elemental/include/types/units.hpp diff --git a/include/util/bitwise.hpp b/Modules/elemental/include/util/bitwise.hpp similarity index 100% rename from include/util/bitwise.hpp rename to Modules/elemental/include/util/bitwise.hpp diff --git a/include/util/debug.hpp b/Modules/elemental/include/util/debug.hpp similarity index 100% rename from include/util/debug.hpp rename to Modules/elemental/include/util/debug.hpp diff --git a/include/util/serialization.hpp b/Modules/elemental/include/util/serialization.hpp similarity index 100% rename from include/util/serialization.hpp rename to Modules/elemental/include/util/serialization.hpp diff --git a/include/util/testing.hpp b/Modules/elemental/include/util/testing.hpp similarity index 100% rename from include/util/testing.hpp rename to Modules/elemental/include/util/testing.hpp diff --git a/src/paths.cpp b/Modules/elemental/paths.cpp similarity index 100% rename from src/paths.cpp rename to Modules/elemental/paths.cpp diff --git a/tests/CMakeLists.txt b/Tests/CMakeLists.txt similarity index 78% rename from tests/CMakeLists.txt rename to Tests/CMakeLists.txt index e33d20b..71d3bd6 100644 --- a/tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1,6 +1,6 @@ # Define the executable 'test-runner' -set(test-runner_SOURCES - runtime.test.cpp +add_executable(test-runner +runtime.test.cpp Singleton.template.test.cpp IRenderer.test.cpp LoopRegulator.test.cpp @@ -10,10 +10,7 @@ set(test-runner_SOURCES SDL_Memory.test.cpp JsonConfigFile.test.cpp paths.test.cpp -) -add_executable(test-runner - ${test-runner_SOURCES} ) set_target_properties(test-runner PROPERTIES EXCLUDE_FROM_ALL 1) @@ -38,8 +35,8 @@ target_include_directories(test-runner SYSTEM BEFORE ) target_include_directories(test-runner - PRIVATE ${CMAKE_SOURCE_DIR}/include - PRIVATE ${CMAKE_SOURCE_DIR}/tests + #PRIVATE ${CMAKE_CURRENTSOURCE_DIR}/include + PRIVATE ${CMAKE_SOURCE_DIR}/Tests ) target_link_directories(test-runner PRIVATE @@ -53,7 +50,7 @@ PRIVATE # Set output directories for build targets set_target_properties(test-runner PROPERTIES - RUNTIME_OUTPUT_DIRECTORY "${Elemental_ARTIFACT_DIR}/tests" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/Tests" ) add_custom_target(test_bin) @@ -61,7 +58,6 @@ add_dependencies(test_bin test-runner ) - # extras: catch2 ctest integration. # add catch2's ctest cmake module and register the tests defined by mdml-tests # using catch_discover_tests @@ -72,12 +68,15 @@ catch_discover_tests(test-runner) # bonus: add a custom ctest target to the build system, to run tests in the # correct directory add_custom_target(ctest - COMMAND ctest -c $configuration --test-dir . --allow-running-no-tests --output-on-failure + COMMAND ctest -c $configuration --test-dir ${CMAKE_BINARY_DIR}/Tests --allow-running-no-tests --output-on-failure +) +add_custom_target(copy_test_assets + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/data ${CMAKE_BINARY_DIR}/tests/data ) set_target_properties(ctest PROPERTIES EXCLUDE_FROM_ALL 1) add_dependencies(ctest test_bin - copy_assets + copy_test_assets ) add_subdirectory(sdl) diff --git a/tests/IRenderer.test.cpp b/Tests/IRenderer.test.cpp similarity index 100% rename from tests/IRenderer.test.cpp rename to Tests/IRenderer.test.cpp diff --git a/tests/JsonConfigFile.test.cpp b/Tests/JsonConfigFile.test.cpp similarity index 100% rename from tests/JsonConfigFile.test.cpp rename to Tests/JsonConfigFile.test.cpp diff --git a/tests/LoopRegulator.test.cpp b/Tests/LoopRegulator.test.cpp similarity index 100% rename from tests/LoopRegulator.test.cpp rename to Tests/LoopRegulator.test.cpp diff --git a/tests/Observable.test.cpp b/Tests/Observable.test.cpp similarity index 100% rename from tests/Observable.test.cpp rename to Tests/Observable.test.cpp diff --git a/tests/SDL_Memory.test.cpp b/Tests/SDL_Memory.test.cpp similarity index 100% rename from tests/SDL_Memory.test.cpp rename to Tests/SDL_Memory.test.cpp diff --git a/tests/Singleton.template.test.cpp b/Tests/Singleton.template.test.cpp similarity index 100% rename from tests/Singleton.template.test.cpp rename to Tests/Singleton.template.test.cpp diff --git a/data/tests/test-skull.png b/Tests/data/test-skull.png similarity index 100% rename from data/tests/test-skull.png rename to Tests/data/test-skull.png diff --git a/data/tests/test-skull.png.license b/Tests/data/test-skull.png.license similarity index 100% rename from data/tests/test-skull.png.license rename to Tests/data/test-skull.png.license diff --git a/data/tests/winter_map.jpg b/Tests/data/winter_map.jpg similarity index 100% rename from data/tests/winter_map.jpg rename to Tests/data/winter_map.jpg diff --git a/data/tests/winter_map.jpg.license b/Tests/data/winter_map.jpg.license similarity index 100% rename from data/tests/winter_map.jpg.license rename to Tests/data/winter_map.jpg.license diff --git a/tests/paths.test.cpp b/Tests/paths.test.cpp similarity index 100% rename from tests/paths.test.cpp rename to Tests/paths.test.cpp diff --git a/tests/runtime.test.cpp b/Tests/runtime.test.cpp similarity index 100% rename from tests/runtime.test.cpp rename to Tests/runtime.test.cpp diff --git a/tests/sdl/CMakeLists.txt b/Tests/sdl/CMakeLists.txt similarity index 100% rename from tests/sdl/CMakeLists.txt rename to Tests/sdl/CMakeLists.txt diff --git a/tests/sdl/SdlEventSource.test.cpp b/Tests/sdl/SdlEventSource.test.cpp similarity index 100% rename from tests/sdl/SdlEventSource.test.cpp rename to Tests/sdl/SdlEventSource.test.cpp diff --git a/tests/sdl/SdlMain.cpp b/Tests/sdl/SdlMain.cpp similarity index 100% rename from tests/sdl/SdlMain.cpp rename to Tests/sdl/SdlMain.cpp diff --git a/tests/sdl/SdlRenderer.test.cpp b/Tests/sdl/SdlRenderer.test.cpp similarity index 100% rename from tests/sdl/SdlRenderer.test.cpp rename to Tests/sdl/SdlRenderer.test.cpp diff --git a/tests/test-utils/SdlHelpers.hpp b/Tests/test-utils/SdlHelpers.hpp similarity index 100% rename from tests/test-utils/SdlHelpers.hpp rename to Tests/test-utils/SdlHelpers.hpp diff --git a/tests/test-utils/common.hpp b/Tests/test-utils/common.hpp similarity index 100% rename from tests/test-utils/common.hpp rename to Tests/test-utils/common.hpp diff --git a/scripts/fswatch-build.env b/Util/fswatch-build.env similarity index 100% rename from scripts/fswatch-build.env rename to Util/fswatch-build.env diff --git a/scripts/fswatch-build.sh b/Util/fswatch-build.sh similarity index 100% rename from scripts/fswatch-build.sh rename to Util/fswatch-build.sh diff --git a/scripts/fswatch-docs.sh b/Util/fswatch-docs.sh similarity index 100% rename from scripts/fswatch-docs.sh rename to Util/fswatch-docs.sh diff --git a/scripts/run-clang-tidy.sh b/Util/run-clang-tidy.sh similarity index 100% rename from scripts/run-clang-tidy.sh rename to Util/run-clang-tidy.sh diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt deleted file mode 100644 index 1fbb27c..0000000 --- a/apps/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ - -#add_subdirectory(game) - -#add_subdirectory(editors/sprite) -#add_subdirectory(editors/level) diff --git a/apps/game/CMakeLists.txt b/apps/game/CMakeLists.txt deleted file mode 100644 index 29708ff..0000000 --- a/apps/game/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ - -set(game_SOURCES - main.cpp - ElementalGame.cpp -) - -add_executable(game - ${game_SOURCES} -) - -#target_include_directories(app PRIVATE -# ${CMAKE_SOURCE_DIR}/src/ -#) - -target_link_libraries(game PRIVATE - elemental -) - -# Manually adds a predefined target as a dependency -add_dependencies(game copy_assets) - -# vim: ts=2 sw=2 noet foldmethod=indent : diff --git a/apps/game/ElementalGame.cpp b/apps/game/ElementalGame.cpp deleted file mode 100644 index 49d39fc..0000000 --- a/apps/game/ElementalGame.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* ElementalGame.cpp - * Copyright © 2023 Saul D. Beniquez - * License: Mozilla Public License v. 2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v.2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at https://mozilla.org/MPL/2.0/. - */ - -#include "./ElementalGame.hpp" - -#include "Singleton.hpp" - -#include "Exception.hpp" -#include "IRenderer.hpp" -#include "LoopRegulator.hpp" -#include "SdlRenderer.hpp" - -#include "util/debug.hpp" - -#include "SdlEventSource.hpp" - -#include -#include -#include - -using namespace elemental; - -/**! \name Helper Functions */ -/// \{ -void -print_cycle_rate(milliseconds& cycle_length, - c::const_string label = "cycle_length") -{ - DBG_PRINT(label << cycle_length.count() << "ms."); -} -/// \} - -ElementalGame::~ElementalGame() -{ - video_renderer.deactivate(); -} - -auto -ElementalGame::run() -> int -{ - try { - LoopRegulator frame_regulator(60_Hz); - - this->is_running = true; - this->running_threads["simulation_thread"] = - std::thread([this]() { this->simulation_thread_loop(); }); - - while (this->is_running) { - frame_regulator.startUpdate(); - this->video_renderer.clearScreen(); - - this->event_emitter.pollEvents(); - - auto cycle_delay_ms = frame_regulator.delay(); - print_cycle_rate(cycle_delay_ms, "frame delay"); - video_renderer.flip(); - } - - this->is_running = false; - - /* threading clean-up: - * wait for all child threads to finish */ - for (auto& [key, values] : this->running_threads) { - values.join(); - } - return kSUCCESS; - } catch (Exception& exc) { - throw; - } catch (std::exception& excp) { - throw Exception(excp); - } - return kERROR; -} - -void -ElementalGame::recieveMessage(const Observable& sender, std::any message) -{ - ASSERT(message.has_value()); - auto event = std::any_cast(message); - if (event.type == SDL_QUIT) { - this->is_running = false; - } -} - -ElementalGame::ElementalGame() - : Application() - , IObserver() - , video_renderer(IRenderer::GetInstance()) - , event_emitter(Singleton::getReference()) -{ - RendererSettings renderer_settings = { - { "Test", - WindowMode::Windowed, // mode - WindowPlacement::Centered, // placement - { 0, 0 }, // window.pos - { 1024_px, 768_px } }, // window.size - { 1024_px, 768_px } // internal resolution - }; - - // Set up video renderer - video_renderer.init(renderer_settings); - - // Initialize event_emitter - event_emitter.registerObserver(*this); - -#ifdef __APPLE__ - event_emitter.pollEvents(); -#endif -} - -void -ElementalGame::simulation_thread_loop() -{ - LoopRegulator loop_regulator(30_Hz); - do { - loop_regulator.startUpdate(); - this->event_emitter.transmitEvents(); - // Scene.Update() - - auto cycle_delay_ms = loop_regulator.delay(); - print_cycle_rate(cycle_delay_ms); - } while (this->is_running); -} -// clang-format off -// vim: set foldmethod=syntax textwidth=80 ts=8 sts=0 sw=8 noexpandtab ft=cpp.doxygen : diff --git a/apps/game/ElementalGame.hpp b/apps/game/ElementalGame.hpp deleted file mode 100644 index bebe4e8..0000000 --- a/apps/game/ElementalGame.hpp +++ /dev/null @@ -1,60 +0,0 @@ -/* ElementalGame.hpp - * Copyright © 2023 Saul D. Beniquez - * License: Mozilla Public License v. 2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v.2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at https://mozilla.org/MPL/2.0/. - */ - -#pragma once - -#include "IApplication.hpp" -#include "IObserver.hpp" -#include "IRenderer.hpp" - -#include "Application.hpp" -#include "LoopRegulator.hpp" - -#include "Singleton.hpp" -#include "types.hpp" - -#include -#include -#include - -namespace elemental { - -// Forward declarations -class IRenderer; -class IInputDriver; -class SdlEventSource; - -class ElementalGame - : public Application - , public IObserver -{ - public: - friend class Singleton; - - ~ElementalGame() override; - - auto run() -> int override; - void recieveMessage(const Observable& sender, - std::any message = std::any()) override; - - protected: - ElementalGame(); - void simulation_thread_loop(); - - Dictionary running_threads; - bool is_running{ false }; - - IRenderer& video_renderer; - SdlEventSource& event_emitter; -}; - -} // namespace elemental - -// clang-format off -// vim: set foldmethod=syntax textwidth=80 ts=8 sts=0 sw=8 noexpandtab ft=cpp.doxygen : diff --git a/apps/game/main.cpp b/apps/game/main.cpp deleted file mode 100644 index ac8be21..0000000 --- a/apps/game/main.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* main.cpp - * Copyright © 2023 Saul D. Beniquez - * License: Mozilla Public License v. 2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v.2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at https://mozilla.org/MPL/2.0/. - */ - -#include - -#include "ElementalGame.hpp" -#include "Exception.hpp" -#include "IApplication.hpp" -#include "Singleton.hpp" - -using namespace elemental; - -auto -main(int argc, c::const_string argv[], c::const_string envp[]) -> int -{ - try { - auto& game_instance = Singleton::getReference(); - game_instance.init(argc, argv, envp); - - return game_instance.run(); - } catch (elemental::Exception& custom_exception) { - std::cerr << custom_exception.what() << std::endl; - return 1; - } catch (std::exception& stl_exception) { - std::cerr << stl_exception.what() << std::endl; - return -1; - } -} - -// clang-format off -// vim: set foldmethod=syntax textwidth=80 ts=8 sts=0 sw=8 noexpandtab ft=cpp.doxygen : diff --git a/include/sys/.keep b/include/sys/.keep deleted file mode 100644 index e69de29..0000000