From cc97efe919679a0a94351d299af3dbdcd65577e0 Mon Sep 17 00:00:00 2001 From: light7734 Date: Mon, 30 Jun 2025 22:33:25 +0330 Subject: [PATCH] chore: remove dependencies --- .gitignore | 62 +---------------- CMakeLists.txt | 14 +--- conanfile.py | 58 ---------------- modules/CMakeLists.txt | 4 +- modules/ecs/private/sparse_set.hpp | 6 -- modules/engine/CMakeLists.txt | 2 - modules/engine/private/entrypoint.cpp | 17 ----- modules/lsd/CMakeLists.txt | 5 ++ modules/lsd/private/test.cpp | 4 ++ modules/lsd/public/lsd/float_types.hpp | 11 +++ modules/lsd/public/lsd/int_types.hpp | 28 ++++++++ modules/lsd/public/lsd/numeric_limits.hpp | 36 ++++++++++ modules/lsd/public/lsd/source_location.hpp | 56 +++++++++++++++ modules/pch/CMakeLists.txt | 2 - .../pch/public/pch/error_handling/checks.hpp | 55 --------------- .../pch/public/pch/error_handling/types.hpp | 32 --------- modules/pch/public/pch/module_configs.hpp | 15 ---- modules/pch/public/pch/pch.hpp | 7 -- modules/pch/public/pch/std_headers.hpp | 68 ------------------- modules/renderer/CMakeLists.txt | 0 .../renderer/private/impls/vulkan/context.hpp | 7 -- tools/cmake/module_macros.cmake | 34 ---------- tools/cmake/preliminary.cmake | 10 --- 23 files changed, 143 insertions(+), 390 deletions(-) delete mode 100644 conanfile.py delete mode 100644 modules/ecs/private/sparse_set.hpp delete mode 100644 modules/engine/CMakeLists.txt delete mode 100644 modules/engine/private/entrypoint.cpp create mode 100644 modules/lsd/CMakeLists.txt create mode 100644 modules/lsd/private/test.cpp create mode 100644 modules/lsd/public/lsd/float_types.hpp create mode 100644 modules/lsd/public/lsd/int_types.hpp create mode 100644 modules/lsd/public/lsd/numeric_limits.hpp create mode 100644 modules/lsd/public/lsd/source_location.hpp delete mode 100644 modules/pch/CMakeLists.txt delete mode 100644 modules/pch/public/pch/error_handling/checks.hpp delete mode 100644 modules/pch/public/pch/error_handling/types.hpp delete mode 100644 modules/pch/public/pch/module_configs.hpp delete mode 100644 modules/pch/public/pch/pch.hpp delete mode 100644 modules/pch/public/pch/std_headers.hpp delete mode 100644 modules/renderer/CMakeLists.txt delete mode 100644 modules/renderer/private/impls/vulkan/context.hpp delete mode 100644 tools/cmake/module_macros.cmake delete mode 100644 tools/cmake/preliminary.cmake diff --git a/.gitignore b/.gitignore index 2a32c0c..aa308c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,65 +1,5 @@ build/ .cache/ -# ---> C++ -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - -# ---> Rust -# Generated by Cargo -# will have compiled files and executables -debug/ -target/ - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock - -# These are backup files generated by rustfmt -**/*.rs.bk - -# MSVC Windows builds of rustc generate these, which store debugging information -*.pdb - -# ---> CMake -CMakeLists.txt.user -CMakeCache.txt -CMakeFiles -CMakeScripts -Testing -Makefile -cmake_install.cmake -install_manifest.txt compile_commands.json -CTestTestfile.cmake -_deps + diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bf29bb..8d990d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,21 +1,9 @@ cmake_minimum_required(VERSION 3.16 FATAL_ERROR) project("light" LANGUAGES CXX) -include(tools/cmake/preliminary.cmake) -include(tools/cmake/module_macros.cmake) - set(CMAKE_CXX_STANDARD 26) set(CMAKE_CXX_STANDARD_REQUIRED ON) - -add_option(ENABLE_SANITIZERS "Enables fsan sanitizers") -add_option(ENABLE_STATIC_ANALYSIS "Enables clang-tidy static analysis") - -find_package(benchmark REQUIRED) -find_package(GTest REQUIRED) - -if(ENABLE_STATIC_ANALYSIS) - find_program(CLANG_TIDY_EXE NAMES "clang-tidy" REQUIRED) -endif() +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) add_subdirectory(docs) add_subdirectory(modules) diff --git a/conanfile.py b/conanfile.py deleted file mode 100644 index 56eb828..0000000 --- a/conanfile.py +++ /dev/null @@ -1,58 +0,0 @@ -from conan import ConanFile -from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout -import shutil -import os - -class LightRecipe(ConanFile): - name = "light" - - settings = "os", "compiler", "build_type", "arch" - generators = "CMakeDeps" - - requires = [ - "benchmark/1.8.4", - "gtest/1.14.0", - ] - - tool_requires = [ - "cmake/3.30.0" - ] - - options = { - "enable_static_analysis": [True, False], - "enable_sanitizers": [True, False], - } - - default_options = { - "enable_static_analysis": True, - "enable_sanitizers": False, - } - - def layout(self): - cmake_layout(self) - - def generate(self): - tc = CMakeToolchain(self) - - tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True - tc.cache_variables["ENABLE_SANITIZERS"] = self.options.enable_sanitizers - tc.cache_variables["ENABLE_STATIC_ANALYSIS"] = self.options.enable_static_analysis - - tc.generate() - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - self.copy_compile_commands() - - def copy_compile_commands(self): - build_folder = self.build_folder - source_file = os.path.join(build_folder, "compile_commands.json") - destination_file = os.path.join(self.source_folder, "compile_commands.json") - - if os.path.isfile(source_file): - shutil.copy(source_file, destination_file) - self.output.info(f"Copied compile_commands.json to {destination_file}") - else: - self.output.warn("compile_commands.json not found!") diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 32e8ee6..329e57b 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -1,3 +1 @@ -add_subdirectory(pch) - -add_subdirectory(engine) +add_subdirectory(lsd) diff --git a/modules/ecs/private/sparse_set.hpp b/modules/ecs/private/sparse_set.hpp deleted file mode 100644 index da57c56..0000000 --- a/modules/ecs/private/sparse_set.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -namespace lt::ecs { - - -} diff --git a/modules/engine/CMakeLists.txt b/modules/engine/CMakeLists.txt deleted file mode 100644 index 583ef13..0000000 --- a/modules/engine/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_executable(engine ${CMAKE_CURRENT_SOURCE_DIR}/private/entrypoint.cpp) -target_link_libraries(engine PRIVATE pch) diff --git a/modules/engine/private/entrypoint.cpp b/modules/engine/private/entrypoint.cpp deleted file mode 100644 index 21bc165..0000000 --- a/modules/engine/private/entrypoint.cpp +++ /dev/null @@ -1,17 +0,0 @@ -auto main() -> int32_t -try -{ - std::cout << "Light built and ran fine..."; - - return 0; -} -catch (const std::exception &exp) -{ - std::cout << "\n\nUnhandled std exception: " << exp.what() << std::endl; // NOLINT - return -1; -} -catch (...) -{ - std::cout << "\n\nUnhandled exception" << std::endl; // NOLINT - return -1; -} diff --git a/modules/lsd/CMakeLists.txt b/modules/lsd/CMakeLists.txt new file mode 100644 index 0000000..618cddf --- /dev/null +++ b/modules/lsd/CMakeLists.txt @@ -0,0 +1,5 @@ +add_library( + lsd + ${CMAKE_CURRENT_SOURCE_DIR}/private/test.cpp +) +target_include_directories(lsd PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/public) diff --git a/modules/lsd/private/test.cpp b/modules/lsd/private/test.cpp new file mode 100644 index 0000000..a0abff6 --- /dev/null +++ b/modules/lsd/private/test.cpp @@ -0,0 +1,4 @@ +#include +#include +#include +#include diff --git a/modules/lsd/public/lsd/float_types.hpp b/modules/lsd/public/lsd/float_types.hpp new file mode 100644 index 0000000..02c2a9a --- /dev/null +++ b/modules/lsd/public/lsd/float_types.hpp @@ -0,0 +1,11 @@ +#pragma once + +namespace lsd { + +using float32_t = float; +static_assert(sizeof(float32_t) == 4); + +using float64_t = double; +static_assert(sizeof(float64_t) == 8); + +} // namespace lsd diff --git a/modules/lsd/public/lsd/int_types.hpp b/modules/lsd/public/lsd/int_types.hpp new file mode 100644 index 0000000..d47fd43 --- /dev/null +++ b/modules/lsd/public/lsd/int_types.hpp @@ -0,0 +1,28 @@ +namespace lsd { + +using uint8_t = unsigned char; +static_assert(sizeof(uint8_t) == 1); + +using uint16_t = unsigned short; +static_assert(sizeof(uint16_t) == 2); + +using uint32_t = unsigned int; +static_assert(sizeof(uint32_t) == 4); + +using uint64_t = unsigned long long; +static_assert(sizeof(uint64_t) == 8); + + +using int8_t = signed char; +static_assert(sizeof(int8_t) == 1); + +using int16_t = signed short; +static_assert(sizeof(int16_t) == 2); + +using int32_t = signed int; +static_assert(sizeof(int32_t) == 4); + +using int64_t = signed long long; +static_assert(sizeof(int64_t) == 8); + +} // namespace lsd diff --git a/modules/lsd/public/lsd/numeric_limits.hpp b/modules/lsd/public/lsd/numeric_limits.hpp new file mode 100644 index 0000000..ce863f5 --- /dev/null +++ b/modules/lsd/public/lsd/numeric_limits.hpp @@ -0,0 +1,36 @@ +#include + +namespace lsd { + +template +struct numeric_limits +{ + static_assert(false); +}; + +template<> +struct numeric_limits +{ + static constexpr auto is_signed = true; + + static constexpr auto is_integer = true; + + static constexpr auto digits = 31; + + /** -2147483648 */ + static consteval auto min() noexcept -> int32_t + { + return (-1) << 31; // NOLINT + } + + /** 2147483647 */ + static consteval auto max() noexcept -> int32_t + { + return ~(1 << 31); // NOLINT + } +}; + +static_assert(numeric_limits::min() == -2147483648); +static_assert(numeric_limits::max() == 2147483647); + +} // namespace lsd diff --git a/modules/lsd/public/lsd/source_location.hpp b/modules/lsd/public/lsd/source_location.hpp new file mode 100644 index 0000000..72fe5e7 --- /dev/null +++ b/modules/lsd/public/lsd/source_location.hpp @@ -0,0 +1,56 @@ +#pragma once + +namespace lsd { + +class source_location +{ +public: + constexpr source_location( + const char *file = "NA", + const char *function = "NA", + unsigned line = 0 + ) + : m_file(file) + , m_function(function) + , m_line(line) + { + } + + static constexpr auto current( + const char *file = __builtin_FILE(), + const char *function = __builtin_FUNCTION(), + unsigned line = __builtin_LINE() + + ) noexcept -> source_location + { + return { + file, + function, + line, + }; + } + + [[nodiscard]] constexpr auto file() const -> const char * + { + return m_file; + }; + + [[nodiscard]] constexpr auto function() const -> const char * + { + return m_function; + }; + + [[nodiscard]] constexpr auto line() const -> unsigned + { + return m_line; + } + +private: + const char *m_file {}; + + const char *m_function {}; + + unsigned m_line {}; +}; + +} // namespace lsd diff --git a/modules/pch/CMakeLists.txt b/modules/pch/CMakeLists.txt deleted file mode 100644 index cf130c1..0000000 --- a/modules/pch/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -add_library_module(universal_pch) -target_precompile_headers(universal_pch INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/public/pch/pch.hpp) diff --git a/modules/pch/public/pch/error_handling/checks.hpp b/modules/pch/public/pch/error_handling/checks.hpp deleted file mode 100644 index 6147626..0000000 --- a/modules/pch/public/pch/error_handling/checks.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include -#include - -namespace lt { - -namespace details { - -inline void throw_if_false(bool condition, std::source_location location) -{ - if (!condition) - { - throw Error { "Failed runtime assertion", location }; - } -} - -} // namespace details - -/** Throws lt::Error if \a condition is false, otherwise returns without side-effects. - * - * @throws lt::Error - * - * @note Only runs when LIGHT_ENABLE_CHECK is enabled, which is enabled by default on debug builds. - * - * @warn The successful execution of the contract of the using code should NOT depend on the - * execution of this function as it may or may NOT be executed--based on project configuration. - */ -inline void check(bool condition, std::source_location location = std::source_location::current()) -{ - if constexpr (light_enabled_check) - { - details::throw_if_false(condition, location); - } -} - -/** Throws lt::Error if \a condition is false, otherwise returns without side-effects. - * - * @throws lt::Error - * - * @note Only runs when LIGHT_ENABLE_ENSURE is enabled, which is enabled by default on debug and - * release builds. - * - * @warn The successful execution of the contract of the using code should NOT depend on the - * execution of this function as it may or may NOT be executed--based on project configuration. - */ -inline void ensure(bool condition, std::source_location location = std::source_location::current()) -{ - if constexpr (light_enabled_ensure) - { - details::throw_if_false(condition, location); - } -} - -} // namespace lt diff --git a/modules/pch/public/pch/error_handling/types.hpp b/modules/pch/public/pch/error_handling/types.hpp deleted file mode 100644 index 158e642..0000000 --- a/modules/pch/public/pch/error_handling/types.hpp +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -namespace lt { - -class Error: public std::exception -{ -public: - Error(std::string_view reason, std::source_location location): m_reason(reason) - { - std::ignore = location; - } - - Error(const Error &prev, std::string_view reason, std::source_location location) - : m_reason(reason) - { - std::ignore = location; - std::ignore = prev; - } - - [[nodiscard]] auto what() const noexcept -> const char * override - { - return ""; - } - -private: - std::string m_reason; -}; - -template -using Expected = std::expected; - -} // namespace lt diff --git a/modules/pch/public/pch/module_configs.hpp b/modules/pch/public/pch/module_configs.hpp deleted file mode 100644 index a10766a..0000000 --- a/modules/pch/public/pch/module_configs.hpp +++ /dev/null @@ -1,15 +0,0 @@ -namespace lt { - -#ifdef LIGHT_ENABLE_CHECK -constexpr bool light_enabled_check = true; -#else -constexpr bool light_enabled_check = false; -#endif - -#ifdef LIGHT_ENABLE_ENSURE -constexpr bool light_enabled_ensure = true; -#else -constexpr bool light_enabled_ensure = false; -#endif - -} // namespace lt diff --git a/modules/pch/public/pch/pch.hpp b/modules/pch/public/pch/pch.hpp deleted file mode 100644 index 2f8a0dc..0000000 --- a/modules/pch/public/pch/pch.hpp +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include - -/* error_handling */ -#include -#include diff --git a/modules/pch/public/pch/std_headers.hpp b/modules/pch/public/pch/std_headers.hpp deleted file mode 100644 index ee52730..0000000 --- a/modules/pch/public/pch/std_headers.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// NOLINTBEGIN - -/* utilities */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* numerics */ -#include -#include -#include -#include - -/* containers */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* algorithms */ -#include - -/* input/output */ -#include -#include -#include - -/* regular expression */ -#include - -/* thread support */ -#include -#include -#include -#include -#include - -/* string */ -#include -#include -#include - -/* filesystem */ -#include - -// NOLINTEND diff --git a/modules/renderer/CMakeLists.txt b/modules/renderer/CMakeLists.txt deleted file mode 100644 index e69de29..0000000 diff --git a/modules/renderer/private/impls/vulkan/context.hpp b/modules/renderer/private/impls/vulkan/context.hpp deleted file mode 100644 index 2a747b4..0000000 --- a/modules/renderer/private/impls/vulkan/context.hpp +++ /dev/null @@ -1,7 +0,0 @@ -namespace lt::render::vk { - -struct Context -{ -}; - -} // namespace lt::render::vk diff --git a/tools/cmake/module_macros.cmake b/tools/cmake/module_macros.cmake deleted file mode 100644 index 2c446c0..0000000 --- a/tools/cmake/module_macros.cmake +++ /dev/null @@ -1,34 +0,0 @@ -macro (add_library_module libname) - if ("${ARGN}" STREQUAL "") # Header only library - message("Adding INTERFACE library ${libname}") - add_library(${libname} INTERFACE) - target_include_directories(${libname} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/public) - - # Do not link universal_pch against universal_pch :D - if (NOT ${libname} STREQUAL "universal_pch") - target_link_libraries(${libname} INTERFACE universal_pch) - endif () - - else () # Compiled library - set(source_files) - set(source_directory "${CMAKE_CURRENT_SOURCE_DIR}/private") - foreach (source_file ${ARGN}) - list(APPEND source_files "${source_directory}/${source_file}") - endforeach () - - message("Adding library ${libname} with source files: ${source_files}") - add_library(${libname} ${source_files}) - target_include_directories(${libname} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/public) - target_include_directories(${libname} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/private) - target_compile_options(${libname} PRIVATE ${WARNING_FLAGS}) - - # Do not link universal_pch against universal_pch :D - if (NOT ${libname} STREQUAL "universal_pch") - target_link_libraries(${libname} PUBLIC universal_pch) - endif () - endif () - - if (ENABLE_STATIC_ANALYSIS) - set_target_properties(${libname} PROPERTIES CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}") - endif () -endmacro () diff --git a/tools/cmake/preliminary.cmake b/tools/cmake/preliminary.cmake deleted file mode 100644 index fa40b63..0000000 --- a/tools/cmake/preliminary.cmake +++ /dev/null @@ -1,10 +0,0 @@ -macro(add_option option help) - option(${option} ${help}) - - if(${option}) - message(STATUS "${option}: ON") - add_compile_definitions(${option}=1) - else() - message(STATUS "${option}: OFF") - endif() -endmacro()