Compare commits
2 commits
b01213c9ea
...
cc97efe919
Author | SHA1 | Date | |
---|---|---|---|
cc97efe919 | |||
92977d5d53 |
24 changed files with 146 additions and 391 deletions
62
.gitignore
vendored
62
.gitignore
vendored
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# light
|
||||
|
||||
Monorepo for a cross-platform, cross-graphics-api, high-performance, modular, and modern game-engine.
|
||||
Dependency-free game engine for the developer to figure out how EVERYTHING works!
|
||||
|
||||
May not be the best, but makes me lock in and learn so much ^^
|
||||
|
|
58
conanfile.py
58
conanfile.py
|
@ -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!")
|
|
@ -1,3 +1 @@
|
|||
add_subdirectory(pch)
|
||||
|
||||
add_subdirectory(engine)
|
||||
add_subdirectory(lsd)
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
namespace lt::ecs {
|
||||
|
||||
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
add_executable(engine ${CMAKE_CURRENT_SOURCE_DIR}/private/entrypoint.cpp)
|
||||
target_link_libraries(engine PRIVATE pch)
|
|
@ -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;
|
||||
}
|
5
modules/lsd/CMakeLists.txt
Normal file
5
modules/lsd/CMakeLists.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
add_library(
|
||||
lsd
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/private/test.cpp
|
||||
)
|
||||
target_include_directories(lsd PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/public)
|
4
modules/lsd/private/test.cpp
Normal file
4
modules/lsd/private/test.cpp
Normal file
|
@ -0,0 +1,4 @@
|
|||
#include <lsd/float_types.hpp>
|
||||
#include <lsd/int_types.hpp>
|
||||
#include <lsd/numeric_limits.hpp>
|
||||
#include <lsd/source_location.hpp>
|
11
modules/lsd/public/lsd/float_types.hpp
Normal file
11
modules/lsd/public/lsd/float_types.hpp
Normal file
|
@ -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
|
28
modules/lsd/public/lsd/int_types.hpp
Normal file
28
modules/lsd/public/lsd/int_types.hpp
Normal file
|
@ -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
|
36
modules/lsd/public/lsd/numeric_limits.hpp
Normal file
36
modules/lsd/public/lsd/numeric_limits.hpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
#include <lsd/int_types.hpp>
|
||||
|
||||
namespace lsd {
|
||||
|
||||
template<typename T>
|
||||
struct numeric_limits
|
||||
{
|
||||
static_assert(false);
|
||||
};
|
||||
|
||||
template<>
|
||||
struct numeric_limits<int32_t>
|
||||
{
|
||||
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<int32_t>::min() == -2147483648);
|
||||
static_assert(numeric_limits<int32_t>::max() == 2147483647);
|
||||
|
||||
} // namespace lsd
|
56
modules/lsd/public/lsd/source_location.hpp
Normal file
56
modules/lsd/public/lsd/source_location.hpp
Normal file
|
@ -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
|
|
@ -1,2 +0,0 @@
|
|||
add_library_module(universal_pch)
|
||||
target_precompile_headers(universal_pch INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/public/pch/pch.hpp)
|
|
@ -1,55 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <pch/error_handling/types.hpp>
|
||||
#include <pch/module_configs.hpp>
|
||||
|
||||
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
|
|
@ -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<typename T>
|
||||
using Expected = std::expected<T, Error>;
|
||||
|
||||
} // namespace lt
|
|
@ -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
|
|
@ -1,7 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <pch/std_headers.hpp>
|
||||
|
||||
/* error_handling */
|
||||
#include <pch/error_handling/checks.hpp>
|
||||
#include <pch/error_handling/types.hpp>
|
|
@ -1,68 +0,0 @@
|
|||
// NOLINTBEGIN
|
||||
|
||||
/* utilities */
|
||||
#include <any>
|
||||
#include <chrono>
|
||||
#include <cinttypes>
|
||||
#include <csignal>
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <exception>
|
||||
#include <expected>
|
||||
#include <format>
|
||||
#include <functional>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <numbers>
|
||||
#include <optional>
|
||||
#include <source_location>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
|
||||
/* numerics */
|
||||
#include <bit>
|
||||
#include <cmath>
|
||||
#include <random>
|
||||
#include <ratio>
|
||||
|
||||
/* containers */
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <set>
|
||||
#include <span>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
/* algorithms */
|
||||
#include <algorithm>
|
||||
|
||||
/* input/output */
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
/* regular expression */
|
||||
#include <regex>
|
||||
|
||||
/* thread support */
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <execution>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
/* string */
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
/* filesystem */
|
||||
#include <filesystem>
|
||||
|
||||
// NOLINTEND
|
|
@ -1,7 +0,0 @@
|
|||
namespace lt::render::vk {
|
||||
|
||||
struct Context
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace lt::render::vk
|
|
@ -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 ()
|
|
@ -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()
|
Loading…
Add table
Reference in a new issue