diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt index 551d8e7..4969887 100644 --- a/editor/CMakeLists.txt +++ b/editor/CMakeLists.txt @@ -11,54 +11,63 @@ set(TEMPEH_ENGINE_EDITOR_HEADERS "src/renderer/gui_renderer.hpp" "src/renderer/editor_camera.hpp" "src/window/keycode_glfw.hpp" - "src/renderer/gui_imgui_renderer.cpp") + "src/filesystem/filetree.hpp" + ) set(TEMPEH_ENGINE_EDITOR_SOURCES - "${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_wgpu.cpp" - "${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_glfw.cpp" - - "src/main.cpp" - "${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_wgpu.cpp" - "${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_glfw.cpp" "src/core/application.cpp" "src/renderer/render_context.cpp" - + "src/renderer/gui_imgui_renderer.cpp" + "src/window/window_glfw.cpp" "src/window/input_manager.cpp" - - "${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_wgpu.cpp" - "${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_glfw.cpp") + "src/filesystem/filetree.cpp" + ) + +add_library( + "tempeh_engine_editor_lib" + "${TEMPEH_ENGINE_EDITOR_HEADERS}" + "${TEMPEH_ENGINE_EDITOR_SOURCES}") + +target_link_libraries("tempeh_engine_editor_lib" + PUBLIC "glfw" + PUBLIC "boost_predef" + PUBLIC "tempeh_common" + PUBLIC "tempeh_core" + PUBLIC "tempeh_log" + PUBLIC "tempeh_math" + PUBLIC "spdlog::spdlog" + #PUBLIC "sentry::sentry" + PUBLIC "webgpu_dawn" + PUBLIC "dawn_native" + PUBLIC "dawn_utils" + PUBLIC "dawn_proc" + PUBLIC "dawncpp" + PUBLIC "dawncpp_headers" + PUBLIC "imgui" + ) add_executable("tempeh_engine_editor" - ${TEMPEH_ENGINE_EDITOR_SOURCES} - ${TEMPEH_ENGINE_EDITOR_HEADERS}) + "src/main.cpp" + "${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_wgpu.cpp" + "${CMAKE_SOURCE_DIR}/external/imgui/backends/imgui_impl_glfw.cpp" + ) target_compile_definitions("tempeh_engine_editor" - PUBLIC SENTRY_DSN="https://8e07fe63b9c94200a0926d0d28b54ad2@o1113293.ingest.sentry.io/6143604") + PUBLIC SENTRY_DSN="https://8e07fe63b9c94200a0926d0d28b54ad2@o1113293.ingest.sentry.io/6143604" + ) target_include_directories("tempeh_engine_editor" #PUBLIC "../common" PUBLIC "${CMAKE_SOURCE_DIR}/external/dawn/src/utils" PUBLIC "$ENV{MONO_INCLUDE_DIR}" - PUBLIC ${TEMPEH_COMMON_INCLUDE}) - + PUBLIC ${TEMPEH_COMMON_INCLUDE} + ) + target_link_libraries("tempeh_engine_editor" # Private, because anyone ain't gonna touch the editor - PRIVATE "glfw" - PRIVATE "boost_predef" - PRIVATE "tempeh_common" - PRIVATE "tempeh_core" - PRIVATE "tempeh_log" - PRIVATE "tempeh_math" - PRIVATE "spdlog::spdlog" - #PUBLIC "sentry::sentry" - PRIVATE "webgpu_dawn" - PRIVATE "dawn_native" - PRIVATE "dawn_utils" - PRIVATE "dawn_proc" - PRIVATE "dawncpp" - PRIVATE "dawncpp_headers" - PRIVATE "imgui") + PRIVATE "tempeh_engine_editor_lib" + ) add_dependencies(tempeh_engine_editor webgpu_headers_gen) \ No newline at end of file diff --git a/editor/src/core/application.hpp b/editor/src/core/application.hpp index 327e523..6580199 100644 --- a/editor/src/core/application.hpp +++ b/editor/src/core/application.hpp @@ -7,6 +7,7 @@ #include "../window/window.hpp" #include "../renderer/render_context.hpp" #include "../renderer/gui.hpp" +#include "../filesystem/filetree.hpp" namespace TempehEditor::Core { diff --git a/editor/src/filesystem/filetree.cpp b/editor/src/filesystem/filetree.cpp new file mode 100644 index 0000000..5df5539 --- /dev/null +++ b/editor/src/filesystem/filetree.cpp @@ -0,0 +1,49 @@ +#include "filetree.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace TempehEditor::FileSystem { + + FileTree::FileTree() + { + } + + FileTree::FileTree(const std::filesystem::path& path) : + m_path(path) + { + std::deque> queue; + + queue.emplace_back(m_path, m_path); + + while (!queue.empty()) { + auto [current, current_map] = queue.back(); + queue.pop_back(); + + for (const auto& entry : std::filesystem::directory_iterator{ current }) { + std::filesystem::path p = entry.path(); + std::shared_ptr dir; + + if (std::filesystem::is_directory(p)) { + dir = std::make_shared(); + queue.emplace_back(p, dir->m_path); + } + + current_map.insert_or_assign(p, dir); + } + } + } + + // TODO + void FileTree::traversal(std::function f) + { + + } + +} \ No newline at end of file diff --git a/editor/src/filesystem/filetree.hpp b/editor/src/filesystem/filetree.hpp new file mode 100644 index 0000000..acfa50b --- /dev/null +++ b/editor/src/filesystem/filetree.hpp @@ -0,0 +1,36 @@ +#ifndef _TEMPEH_FILE_FILETREE_HPP +#define _TEMPEH_FILE_FILETREE_HPP + +#include +#include +#include +#include +#include +#include + +namespace TempehEditor::FileSystem +{ + struct FileMetaData + { + std::filesystem::path name; + u32 size; + }; + + class FileTree + { + private: + using FileTreeMap = std::map>; + + std::filesystem::path m_path; + FileTreeMap m_file_map; + + public: + FileTree(); + FileTree(const std::filesystem::path& path); + + // Implemented as BFS + void traversal(std::function f); + }; +} + +#endif //_TEMPEH_FILE_FILETREE_HPP diff --git a/editor/src/renderer/render_context.cpp b/editor/src/renderer/render_context.cpp index 700da50..9f5c15b 100644 --- a/editor/src/renderer/render_context.cpp +++ b/editor/src/renderer/render_context.cpp @@ -5,7 +5,6 @@ #include #include #include -#include //#include #if defined(WIN32) # define GLFW_EXPOSE_NATIVE_WIN32 diff --git a/engine/core/CMakeLists.txt b/engine/core/CMakeLists.txt index 0f3e6ef..14d6771 100644 --- a/engine/core/CMakeLists.txt +++ b/engine/core/CMakeLists.txt @@ -22,14 +22,15 @@ add_library("tempeh_core" STATIC "include/tempeh/renderer/orthogonal_camera.hpp" "include/tempeh/renderer/perspective_camera.hpp" "src/renderer/orthogonal_camera.cpp" - "src/renderer/perspective_camera.cpp") + "src/renderer/perspective_camera.cpp" + ) target_include_directories("tempeh_core" PUBLIC $ PUBLIC "$ENV{MONO_INCLUDE_DIR}" PUBLIC "${CMAKE_SOURCE_DIR}/external/glad/include" PUBLIC "${CMAKE_SOURCE_DIR}/engine/core/include" - PUBLIC "${CMAKE_SOURCE_DIR}/engine/common" + PUBLIC "${CMAKE_SOURCE_DIR}/engine/common/include" PUBLIC "${Vulkan_INCLUDE_DIRS}" ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7e3b21b..a2d8354 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -5,11 +5,33 @@ "tempeh_core_test" "core/main.cpp" ) + target_link_libraries( - "tempeh_core_test" - PUBLIC "gtest_main" + "tempeh_core_test" + PUBLIC "gtest_main" + ) + + add_executable( + "tempeh_editor_test" + "editor/filesystem.cpp" + ) + + target_include_directories("tempeh_editor_test" + PUBLIC "${CMAKE_SOURCE_DIR}/editor/src" + PUBLIC "${CMAKE_SOURCE_DIR}/external/dawn/src/utils" + PUBLIC "${CMAKE_SOURCE_DIR}/external/predef/include" + PUBLIC "$ENV{MONO_INCLUDE_DIR}" + PUBLIC ${TEMPEH_COMMON_INCLUDE} + ) + + target_link_libraries( + "tempeh_editor_test" + PRIVATE "tempeh_engine_editor_lib" + PUBLIC "gtest_main" ) include(GoogleTest) gtest_discover_tests(tempeh_core_test) + gtest_discover_tests(tempeh_editor_test) + endif() diff --git a/test/editor/filesystem.cpp b/test/editor/filesystem.cpp new file mode 100644 index 0000000..9175bfe --- /dev/null +++ b/test/editor/filesystem.cpp @@ -0,0 +1,25 @@ +#include + +#include +#include + +TEST(FileSystem, FileTree_ObjectCreation) +{ + // For debugging purpose + std::filesystem::path p = std::filesystem::current_path() / "../../../../test/testfile/dummy-dir"; + TempehEditor::FileSystem::FileTree test_obj(p.generic_string()); + +// ASSERT_DEATH({ +// TempehEditor::FileSystem::FileTree test_obj(std::string("/blah")); +// }, "Path did not exists"); +// +//#ifdef BOOST_OS_WINDOWS +// ASSERT_NO_FATAL_FAILURE({ +// // Uhhh... is C:\\ is not a `standard`? +// TempehEditor::FileSystem::FileTree test_obj(std::string("C:\\Windows")); +// }); +//#elif BOOST_OS_LINUX +// // TODO linux +//#endif + +} diff --git a/test/testfile/dummy-dir/1.txt b/test/testfile/dummy-dir/1.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/testfile/dummy-dir/2.txt b/test/testfile/dummy-dir/2.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/testfile/dummy-dir/dummy-dir-2/3.txt b/test/testfile/dummy-dir/dummy-dir-2/3.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/testfile/dummy-dir/dummy-dir-2/4.txt b/test/testfile/dummy-dir/dummy-dir-2/4.txt new file mode 100644 index 0000000..e69de29