Compare commits
No commits in common. "ca91c5c1d12773699b1ad0df7d6e129e8e980277" and "154d6eacf4a1b5362171035372811053f5709baf" have entirely different histories.
ca91c5c1d1
...
154d6eacf4
12 changed files with 123 additions and 62 deletions
|
|
@ -5,8 +5,8 @@ add_subdirectory(./logger)
|
||||||
add_subdirectory(./debug)
|
add_subdirectory(./debug)
|
||||||
add_subdirectory(./math)
|
add_subdirectory(./math)
|
||||||
#
|
#
|
||||||
# add_subdirectory(./asset_baker)
|
add_subdirectory(./asset_baker)
|
||||||
# add_subdirectory(./asset_parser)
|
add_subdirectory(./asset_parser)
|
||||||
# add_subdirectory(./asset_manager)
|
# add_subdirectory(./asset_manager)
|
||||||
#
|
#
|
||||||
add_subdirectory(./camera)
|
add_subdirectory(./camera)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ using lt::test::expect_unreachable;
|
||||||
using lt::test::Suite;
|
using lt::test::Suite;
|
||||||
|
|
||||||
using lt::test::expect_eq;
|
using lt::test::expect_eq;
|
||||||
|
using lt::test::expect_ne;
|
||||||
|
using lt::test::expect_throw;
|
||||||
|
|
||||||
using lt::test::expect_false;
|
using lt::test::expect_false;
|
||||||
using lt::test::expect_true;
|
using lt::test::expect_true;
|
||||||
|
|
@ -17,7 +19,7 @@ using lt::ecs::Registry;
|
||||||
|
|
||||||
struct Component
|
struct Component
|
||||||
{
|
{
|
||||||
int m_int {};
|
int m_int;
|
||||||
std::string m_string;
|
std::string m_string;
|
||||||
|
|
||||||
[[nodiscard]] friend auto operator==(const Component &lhs, const Component &rhs) -> bool
|
[[nodiscard]] friend auto operator==(const Component &lhs, const Component &rhs) -> bool
|
||||||
|
|
@ -41,7 +43,7 @@ struct std::formatter<Component>
|
||||||
|
|
||||||
struct Component_B
|
struct Component_B
|
||||||
{
|
{
|
||||||
float m_float {};
|
float m_float;
|
||||||
|
|
||||||
[[nodiscard]] friend auto operator==(const Component_B lhs, const Component_B &rhs) -> bool
|
[[nodiscard]] friend auto operator==(const Component_B lhs, const Component_B &rhs) -> bool
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@ namespace lt::ecs {
|
||||||
|
|
||||||
using Entity = uint32_t;
|
using Entity = uint32_t;
|
||||||
|
|
||||||
constexpr auto null_entity = std::numeric_limits<Entity>::max();
|
|
||||||
|
|
||||||
/** A registry of components, the heart of an ECS architecture.
|
/** A registry of components, the heart of an ECS architecture.
|
||||||
*
|
*
|
||||||
* @todo(Light): Implement grouping
|
* @todo(Light): Implement grouping
|
||||||
|
|
|
||||||
|
|
@ -150,11 +150,6 @@ public:
|
||||||
return m_sparse.capacity();
|
return m_sparse.capacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto is_empty() const noexcept -> bool
|
|
||||||
{
|
|
||||||
return m_dense.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Dense_T> m_dense;
|
std::vector<Dense_T> m_dense;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,13 +35,13 @@ public:
|
||||||
void static show_imgui_window();
|
void static show_imgui_window();
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void static log(LogLvl lvl, std::format_string<Args...> fmt, Args &&...args) noexcept
|
void static log(LogLvl lvl, std::format_string<Args...> fmt, Args &&...args)
|
||||||
{
|
{
|
||||||
std::ignore = lvl;
|
std::ignore = lvl;
|
||||||
std::println(fmt, std::forward<Args>(args)...);
|
std::println(fmt, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
void static log(LogLvl lvl, const char *message) noexcept
|
void static log(LogLvl lvl, const char *message)
|
||||||
{
|
{
|
||||||
std::ignore = lvl;
|
std::ignore = lvl;
|
||||||
std::println("{}", message);
|
std::println("{}", message);
|
||||||
|
|
@ -53,37 +53,37 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void log_trc(std::format_string<Args...> fmt, Args &&...args) noexcept
|
void log_trc(std::format_string<Args...> fmt, Args &&...args)
|
||||||
{
|
{
|
||||||
Logger::log(LogLvl::trace, fmt, std::forward<Args>(args)...);
|
Logger::log(LogLvl::trace, fmt, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void log_dbg(std::format_string<Args...> fmt, Args &&...args) noexcept
|
void log_dbg(std::format_string<Args...> fmt, Args &&...args)
|
||||||
{
|
{
|
||||||
Logger::log(LogLvl::debug, fmt, std::forward<Args>(args)...);
|
Logger::log(LogLvl::debug, fmt, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void log_inf(std::format_string<Args...> fmt, Args &&...args) noexcept
|
void log_inf(std::format_string<Args...> fmt, Args &&...args)
|
||||||
{
|
{
|
||||||
Logger::log(LogLvl::info, fmt, std::forward<Args>(args)...);
|
Logger::log(LogLvl::info, fmt, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void log_wrn(std::format_string<Args...> fmt, Args &&...args) noexcept
|
void log_wrn(std::format_string<Args...> fmt, Args &&...args)
|
||||||
{
|
{
|
||||||
Logger::log(LogLvl::warn, fmt, std::forward<Args>(args)...);
|
Logger::log(LogLvl::warn, fmt, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void log_err(std::format_string<Args...> fmt, Args &&...args) noexcept
|
void log_err(std::format_string<Args...> fmt, Args &&...args)
|
||||||
{
|
{
|
||||||
Logger::log(LogLvl::error, fmt, std::forward<Args>(args)...);
|
Logger::log(LogLvl::error, fmt, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void log_crt(std::format_string<Args...> fmt, Args &&...args) noexcept
|
void log_crt(std::format_string<Args...> fmt, Args &&...args)
|
||||||
{
|
{
|
||||||
Logger::log(LogLvl::critical, fmt, std::forward<Args>(args)...);
|
Logger::log(LogLvl::critical, fmt, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ private:
|
||||||
|
|
||||||
Ref<MirrorSystem> m_mirror_system;
|
Ref<MirrorSystem> m_mirror_system;
|
||||||
|
|
||||||
lt::ecs::Entity m_window = lt::ecs::null_entity;
|
lt::ecs::Entity m_window;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto app::create_application() -> Scope<app::Application>
|
auto app::create_application() -> Scope<app::Application>
|
||||||
|
|
|
||||||
|
|
@ -57,8 +57,6 @@ System::System(Ref<ecs::Registry> registry): m_registry(std::move(registry))
|
||||||
}
|
}
|
||||||
|
|
||||||
System::~System()
|
System::~System()
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
// TODO(Light): make registry.remove not validate iterators
|
// TODO(Light): make registry.remove not validate iterators
|
||||||
auto entities_to_remove = std::vector<ecs::Entity> {};
|
auto entities_to_remove = std::vector<ecs::Entity> {};
|
||||||
|
|
@ -75,12 +73,6 @@ System::~System()
|
||||||
m_registry->disconnect_on_construct<SurfaceComponent>();
|
m_registry->disconnect_on_construct<SurfaceComponent>();
|
||||||
m_registry->disconnect_on_destruct<SurfaceComponent>();
|
m_registry->disconnect_on_destruct<SurfaceComponent>();
|
||||||
}
|
}
|
||||||
catch (const std::exception &exp)
|
|
||||||
{
|
|
||||||
log_err("Uncaught exception in surface::~System:");
|
|
||||||
log_err("\twhat: {}", exp.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void System::on_register()
|
void System::on_register()
|
||||||
{
|
{
|
||||||
|
|
@ -149,8 +141,8 @@ void System::on_surface_construct(ecs::Registry ®istry, ecs::Entity entity)
|
||||||
XSetWMProtocols(display, main_window, &surface.m_native_data.wm_delete_message, 1);
|
XSetWMProtocols(display, main_window, &surface.m_native_data.wm_delete_message, 1);
|
||||||
|
|
||||||
// code to remove decoration
|
// code to remove decoration
|
||||||
auto hints = std::array<unsigned char, 5> { 2, 0, 0, 0, 0 };
|
long hints[5] = { 2, 0, 0, 0, 0 };
|
||||||
const auto motif_hints = XInternAtom(display, "_MOTIF_WM_HINTS", False);
|
Atom motif_hints = XInternAtom(display, "_MOTIF_WM_HINTS", False);
|
||||||
|
|
||||||
XChangeProperty(
|
XChangeProperty(
|
||||||
display,
|
display,
|
||||||
|
|
@ -159,7 +151,7 @@ void System::on_surface_construct(ecs::Registry ®istry, ecs::Entity entity)
|
||||||
motif_hints,
|
motif_hints,
|
||||||
32,
|
32,
|
||||||
PropModeReplace,
|
PropModeReplace,
|
||||||
hints.data(),
|
(unsigned char *)&hints,
|
||||||
5
|
5
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -291,7 +283,28 @@ void System::handle_events(SurfaceComponent &surface)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: break; /* pass */
|
case Expose: break;
|
||||||
|
case GraphicsExpose: break;
|
||||||
|
case NoExpose: break;
|
||||||
|
case CirculateRequest: break;
|
||||||
|
case ConfigureRequest: break;
|
||||||
|
case MapRequest: break;
|
||||||
|
case ResizeRequest: break;
|
||||||
|
case CirculateNotify: break;
|
||||||
|
case CreateNotify: break;
|
||||||
|
case DestroyNotify: break;
|
||||||
|
case GravityNotify: break;
|
||||||
|
case MapNotify: break;
|
||||||
|
case MappingNotify: break;
|
||||||
|
case ReparentNotify: break;
|
||||||
|
case UnmapNotify: break;
|
||||||
|
case VisibilityNotify: break;
|
||||||
|
case ColormapNotify: break;
|
||||||
|
case PropertyNotify: break;
|
||||||
|
case SelectionClear: break;
|
||||||
|
case SelectionNotify: break;
|
||||||
|
case SelectionRequest: break;
|
||||||
|
default: log_inf("Unknown X Event");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,7 @@ void create_surface_component(test::FuzzDataProvider &provider, ecs::Registry &r
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto entity = registry.create_entity();
|
registry.create_entity("").add_component<surface::SurfaceComponent>(
|
||||||
registry.add<surface::SurfaceComponent>(
|
|
||||||
entity,
|
|
||||||
surface::SurfaceComponent::CreateInfo {
|
surface::SurfaceComponent::CreateInfo {
|
||||||
.title = std::move(title),
|
.title = std::move(title),
|
||||||
.resolution = resolution,
|
.resolution = resolution,
|
||||||
|
|
@ -66,11 +64,11 @@ void create_surface_component(test::FuzzDataProvider &provider, ecs::Registry &r
|
||||||
|
|
||||||
void remove_surface_component(ecs::Registry ®istry)
|
void remove_surface_component(ecs::Registry ®istry)
|
||||||
{
|
{
|
||||||
const auto view = registry.view<SurfaceComponent>();
|
const auto view = registry.get_entt_registry().view<SurfaceComponent>();
|
||||||
|
|
||||||
if (!view.is_empty())
|
if (!view->empty())
|
||||||
{
|
{
|
||||||
registry.remove<SurfaceComponent>(view[0].first);
|
registry.get_entt_registry().remove<SurfaceComponent>(*view.begin());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,7 +102,8 @@ test::FuzzHarness harness = [](const uint8_t *data, size_t size) {
|
||||||
case FuzzAction::create_entity:
|
case FuzzAction::create_entity:
|
||||||
{
|
{
|
||||||
const auto length = std::min(provider.consume<uint32_t>().value_or(16), 255u);
|
const auto length = std::min(provider.consume<uint32_t>().value_or(16), 255u);
|
||||||
registry->create_entity();
|
const auto tag = provider.consume_string(length).value_or("");
|
||||||
|
registry->create_entity(tag);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -120,15 +119,15 @@ test::FuzzHarness harness = [](const uint8_t *data, size_t size) {
|
||||||
}
|
}
|
||||||
case FuzzAction::push_event:
|
case FuzzAction::push_event:
|
||||||
{
|
{
|
||||||
auto view = registry->view<SurfaceComponent>();
|
const auto view = registry->get_entt_registry().view<SurfaceComponent>();
|
||||||
|
|
||||||
if (!view.is_empty())
|
if (!view->empty())
|
||||||
{
|
|
||||||
for (auto &[entity, component] : view)
|
|
||||||
{
|
{
|
||||||
|
view.each([&](auto entity, SurfaceComponent &surface) {
|
||||||
provider.consume<uint8_t>().value_or(0);
|
provider.consume<uint8_t>().value_or(0);
|
||||||
// @TODO(Light): push some event
|
});
|
||||||
}
|
|
||||||
|
registry->get_entt_registry().remove<SurfaceComponent>(*view.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -137,7 +136,6 @@ test::FuzzHarness harness = [](const uint8_t *data, size_t size) {
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FuzzAction::count:
|
|
||||||
case FuzzAction::tick_system:
|
case FuzzAction::tick_system:
|
||||||
{
|
{
|
||||||
system.tick();
|
system.tick();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
cd $(git rev-parse --show-toplevel)/
|
cd $(git rev-parse --show-toplevel)/
|
||||||
rm -rf ./build && mkdir build/ && cd build
|
rm -rf ./build
|
||||||
|
mkdir build/ && cd build
|
||||||
|
|
||||||
Xvfb :99 -screen 0 1024x768x16 &
|
Xvfb :99 -screen 0 1024x768x16 &
|
||||||
export CXX=$(which g++)
|
export CXX=$(which g++)
|
||||||
|
|
|
||||||
9
tools/ci/static_analysis/clang_format.dockerfile
Normal file
9
tools/ci/static_analysis/clang_format.dockerfile
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
bash \
|
||||||
|
curl \
|
||||||
|
findutils \
|
||||||
|
git \
|
||||||
|
libc6-compat \
|
||||||
|
clang-extra-tools
|
||||||
42
tools/ci/static_analysis/clang_tidy.dockerfile
Normal file
42
tools/ci/static_analysis/clang_tidy.dockerfile
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
FROM alpine:latest
|
||||||
|
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
bash \
|
||||||
|
clang \
|
||||||
|
llvm \
|
||||||
|
cmake \
|
||||||
|
git \
|
||||||
|
make \
|
||||||
|
g++ \
|
||||||
|
python3 \
|
||||||
|
py3-pip \
|
||||||
|
mesa-dev \
|
||||||
|
mesa-gl \
|
||||||
|
pkgconf \
|
||||||
|
clang-extra-tools \
|
||||||
|
mold \
|
||||||
|
ninja
|
||||||
|
|
||||||
|
RUN pip install --no-cache-dir --break-system-packages conan gitpython \
|
||||||
|
&& conan profile detect
|
||||||
|
|
||||||
|
RUN clang --version \
|
||||||
|
&& conan --version \
|
||||||
|
&& pip --version \
|
||||||
|
&& cmake --version \
|
||||||
|
&& g++ --version \
|
||||||
|
&& clang --version \
|
||||||
|
&& clang-tidy --version \
|
||||||
|
&& ninja --version \
|
||||||
|
&& mold --version
|
||||||
|
|
||||||
|
|
||||||
|
RUN git clone 'https://git.light7734.com/light7734/light.git' \
|
||||||
|
&& cd light \
|
||||||
|
&& conan install . \
|
||||||
|
-c tools.system.package_manager:mode=install \
|
||||||
|
-c tools.cmake.cmaketoolchain:generator=Ninja \
|
||||||
|
-s build_type=Release \
|
||||||
|
-o enable_static_analysis=True \
|
||||||
|
-o use_mold=True \
|
||||||
|
--build=missing
|
||||||
|
|
@ -2,16 +2,19 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
cd $(git rev-parse --show-toplevel)/
|
cd $(git rev-parse --show-toplevel)/
|
||||||
rm -rf ./build && mkdir build/ && cd build
|
rm -rf ./build
|
||||||
|
|
||||||
export CC=$(which clang)
|
echo 'Static analysis is currently disabled as code is filled with failing clang-tidy checks'
|
||||||
export CXX=$(which clang++)
|
echo 'Runng this would be a waste of CPU cycles and electricty'
|
||||||
|
echo 'Fix the checks before removing these lines'
|
||||||
|
exit 0
|
||||||
|
|
||||||
cmake .. \
|
cmake .. \
|
||||||
-G Ninja \
|
-G Ninja \
|
||||||
-DCMAKE_LINKER_TYPE=MOLD \
|
-DCMAKE_LINKER_TYPE=MOLD \
|
||||||
-DENABLE_UNIT_TESTS=ON \
|
-DENABLE_UNIT_TESTS=ON \
|
||||||
-DENABLE_STATIC_ANALYSIS=ON \
|
-DENABLE_FUZZ_TESTS=ON \
|
||||||
|
-CMAKE_CXX_CLANG_TIDY=ON \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
-DCMAKE_CXX_FLAGS="-std=c++23 -stdlib=libc++" \
|
-DCMAKE_CXX_FLAGS="-std=c++23 -stdlib=libc++ -g -fno-omit-frame-pointer" \
|
||||||
&& cmake --build . -j `nproc`
|
&& cmake --build . -j `nproc`
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue