From 2761ed759a06a7e83abb1ebb9013e755c40fa10a Mon Sep 17 00:00:00 2001 From: Muhammad Abdulfattah Date: Wed, 11 Dec 2024 19:58:00 +0200 Subject: [PATCH 01/24] Add base64 to modules. (#35) --- .github/workflows/main.yml | 3 +- CMakeLists.txt | 7 +++- core/CMakeLists.txt | 13 ++++++- core/{base64.cpp => base64.cppm} | 56 +++++++++++++++++++++++++--- core/base64.h | 48 ------------------------ core/serialization/json_serializer.h | 3 +- unittest/src/unittest_core.cpp | 3 +- 7 files changed, 73 insertions(+), 60 deletions(-) rename core/{base64.cpp => base64.cppm} (52%) delete mode 100644 core/base64.h diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dd03e8d0..25e5b62c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,8 @@ jobs: strategy: fail-fast: true matrix: - os: [windows-latest, ubuntu-latest, macos-latest] + # os: [windows-latest, ubuntu-latest, macos-latest] // TODO: + os: [windows-latest] build-variant: [Debug, Release] steps: - uses: actions/checkout@v4 diff --git a/CMakeLists.txt b/CMakeLists.txt index d89b002a..933f4cc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.28.2) project(core VERSION 0.0.1) @@ -18,6 +18,7 @@ set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$") +set(PREBUILT_MODULE_PATH "${CMAKE_BINARY_DIR}/bin/$") # Global compile definitions. set(GLOBAL_COMPILE_DEFINITIONS @@ -34,9 +35,11 @@ set(GLOBAL_COMPILE_DEFINITIONS $<$:PLATFORM_MACOS=1> ) +set(CMAKE_CXX_STANDARD 20) + # Global compile options. if(MSVC) - set(GLOBAL_COMPILE_OPTIONS -W4 -WX -std:c++20 -Zc:preprocessor -wd5105) + set(GLOBAL_COMPILE_OPTIONS -W4 -WX -std:c++20 -Zc:preprocessor -wd5105 -wd4273) else() # TODO: -Wno-deprecated-declarations is due to doctest.h sprintf() function. set(GLOBAL_COMPILE_OPTIONS -Wall -Wextra -pedantic -Werror -std=c++2b -fno-exceptions -Wno-invalid-offsetof -Wno-nested-anon-types -Wno-c++11-narrowing -Wno-gnu-zero-variadic-macro-arguments -Wno-deprecated-declarations -Wno-enum-constexpr-conversion -Wno-unknown-warning-option diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 298f1276..2b8fda2c 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -1,5 +1,4 @@ set(HEADER_FILES - base64.h defer.h defines.h ecs.h @@ -26,7 +25,6 @@ set(HEADER_FILES ) set(SOURCE_FILES - base64.cpp ecs.cpp formatter.cpp json.cpp @@ -76,6 +74,17 @@ if(${CORE_BUILD_STATIC}) set(BUILD_TYPE STATIC) endif() add_library(core ${BUILD_TYPE} ${HEADER_FILES} ${SOURCE_FILES}) + +# TODO: +target_sources(core + PUBLIC + FILE_SET all_my_modules TYPE CXX_MODULES + BASE_DIRS + ${PROJECT_SOURCE_DIR} + FILES + base64.cppm +) + target_link_libraries(core PUBLIC ${LIBS}) target_compile_options(core PRIVATE ${GLOBAL_COMPILE_OPTIONS}) target_compile_definitions(core PRIVATE ${GLOBAL_COMPILE_DEFINITIONS}) diff --git a/core/base64.cpp b/core/base64.cppm similarity index 52% rename from core/base64.cpp rename to core/base64.cppm index 1dd6ef63..e00b51b4 100644 --- a/core/base64.cpp +++ b/core/base64.cppm @@ -1,9 +1,25 @@ -#include "core/base64.h" +module; + +#pragma once + +#include "core/export.h" +#include "core/defines.h" +#include "core/export.h" +#include "core/memory/memory.h" +#include "core/containers/string.h" + +export module base64; + +/* + TODO: + - [ ] Should decode return a String or an Array? + - [ ] Should use Result? +*/ inline static constexpr const char *BASE64_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -String -base64_encode(const u8 *data, u64 size, memory::Allocator *allocator) +export CORE_API String +base64_encode(const u8 *data, u64 size, memory::Allocator *allocator = memory::heap_allocator()) { String out = string_init(allocator); @@ -30,8 +46,8 @@ base64_encode(const u8 *data, u64 size, memory::Allocator *allocator) return out; } -String -base64_decode(const String &data, memory::Allocator *allocator) +export CORE_API String +base64_decode(const String &data, memory::Allocator *allocator = memory::heap_allocator()) { constexpr auto index = [](const String &data, char c) -> u8 { for (u8 i = 0; i < data.count; ++i) @@ -81,4 +97,34 @@ base64_decode(const String &data, memory::Allocator *allocator) } return out; +} + +export inline String +base64_encode(const Block &data, memory::Allocator *allocator = memory::heap_allocator()) +{ + return base64_encode((const u8 *)data.data, data.size, allocator); +} + +export inline String +base64_encode(const Array &data, memory::Allocator *allocator = memory::heap_allocator()) +{ + return base64_encode(data.data, data.count, allocator); +} + +export inline String +base64_encode(const String &data, memory::Allocator *allocator = memory::heap_allocator()) +{ + return base64_encode((const u8 *)data.data, data.count, allocator); +} + +export inline String +base64_encode(const char *data, memory::Allocator *allocator = memory::heap_allocator()) +{ + return base64_encode(string_literal(data), allocator); +} + +export inline String +base64_decode(const char *data, memory::Allocator *allocator = memory::heap_allocator()) +{ + return base64_decode(string_literal(data), allocator); } \ No newline at end of file diff --git a/core/base64.h b/core/base64.h deleted file mode 100644 index 0d24c9d6..00000000 --- a/core/base64.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once - -#include "core/defines.h" -#include "core/export.h" -#include "core/memory/memory.h" -#include "core/containers/string.h" - -/* - TODO: - - [ ] Should decode return a String or an Array? - - [ ] Should use Result? -*/ - -CORE_API String -base64_encode(const u8 *data, u64 size, memory::Allocator *allocator = memory::heap_allocator()); - -inline static String -base64_encode(const Block &data, memory::Allocator *allocator = memory::heap_allocator()) -{ - return base64_encode((const u8 *)data.data, data.size, allocator); -} - -inline static String -base64_encode(const Array &data, memory::Allocator *allocator = memory::heap_allocator()) -{ - return base64_encode(data.data, data.count, allocator); -} - -inline static String -base64_encode(const String &data, memory::Allocator *allocator = memory::heap_allocator()) -{ - return base64_encode((const u8 *)data.data, data.count, allocator); -} - -inline static String -base64_encode(const char *data, memory::Allocator *allocator = memory::heap_allocator()) -{ - return base64_encode(string_literal(data), allocator); -} - -CORE_API String -base64_decode(const String &data, memory::Allocator *allocator = memory::heap_allocator()); - -inline static String -base64_decode(const char *data, memory::Allocator *allocator = memory::heap_allocator()) -{ - return base64_decode(string_literal(data), allocator); -} \ No newline at end of file diff --git a/core/serialization/json_serializer.h b/core/serialization/json_serializer.h index 6e3b6a8d..1a018479 100644 --- a/core/serialization/json_serializer.h +++ b/core/serialization/json_serializer.h @@ -4,11 +4,12 @@ #include "core/defines.h" #include "core/json.h" #include "core/log.h" -#include "core/base64.h" #include "core/containers/array.h" #include "core/containers/string.h" #include "core/containers/hash_table.h" +import base64; + struct Json_Serializer { memory::Allocator *allocator; diff --git a/unittest/src/unittest_core.cpp b/unittest/src/unittest_core.cpp index a4aa205d..16e77981 100644 --- a/unittest/src/unittest_core.cpp +++ b/unittest/src/unittest_core.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -8,6 +7,8 @@ #include #include +import base64; + #include TEST_CASE("[CORE]: Arena_Allocator") From f6415a5c5aba04d1dde9a7ff2f5a6afd60c952de Mon Sep 17 00:00:00 2001 From: Muhammad Abdulfattah Date: Thu, 12 Dec 2024 00:11:49 +0200 Subject: [PATCH 02/24] Add ECS to modules. (#37) --- core/CMakeLists.txt | 3 +-- core/ecs.cpp | 13 --------- core/{ecs.h => ecs.cppm} | 51 ++++++++++++++++++++--------------- core/hash.h | 32 +++++++++++----------- core/memory/memory.h | 28 +++++++++---------- core/utils.h | 2 +- unittest/CMakeLists.txt | 1 + unittest/src/unittest_ecs.cpp | 38 ++++++++++++++++++++++++++ 8 files changed, 101 insertions(+), 67 deletions(-) delete mode 100644 core/ecs.cpp rename core/{ecs.h => ecs.cppm} (86%) create mode 100644 unittest/src/unittest_ecs.cpp diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 2b8fda2c..fae5a380 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -1,7 +1,6 @@ set(HEADER_FILES defer.h defines.h - ecs.h formatter.h hash.h json.h @@ -25,7 +24,6 @@ set(HEADER_FILES ) set(SOURCE_FILES - ecs.cpp formatter.cpp json.cpp log.cpp @@ -83,6 +81,7 @@ target_sources(core ${PROJECT_SOURCE_DIR} FILES base64.cppm + ecs.cppm ) target_link_libraries(core PUBLIC ${LIBS}) diff --git a/core/ecs.cpp b/core/ecs.cpp deleted file mode 100644 index 8009a9a3..00000000 --- a/core/ecs.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "ecs.h" - -#include - -namespace ecs -{ - Entity - entity_new() - { - static std::atomic id = 0; - return Entity{id.fetch_add(1)}; - } -} \ No newline at end of file diff --git a/core/ecs.h b/core/ecs.cppm similarity index 86% rename from core/ecs.h rename to core/ecs.cppm index 6aa0c5dc..ab7c297d 100644 --- a/core/ecs.h +++ b/core/ecs.cppm @@ -1,4 +1,4 @@ -#pragma once +module; #include "core/export.h" #include "core/defines.h" @@ -8,10 +8,13 @@ #include #include #include +#include + +export module ecs; namespace ecs { - struct Entity + export struct Entity { u64 id = U64_MAX; @@ -28,9 +31,6 @@ namespace ecs } }; - CORE_API Entity - entity_new(); - typedef u64 Component_Hash; struct IComponent_Table @@ -121,7 +121,7 @@ namespace ecs } }; - struct ECS + export struct ECS { Hash_Table component_tables; @@ -186,13 +186,13 @@ namespace ecs } }; - inline static ECS + export inline ECS ecs_new() { return {hash_table_init()}; } - inline static void + export inline void ecs_free(ECS &self) { for (auto &[_, v] : self.component_tables) @@ -201,50 +201,59 @@ namespace ecs hash_table_deinit(self.component_tables); } - template - inline static void + export template + inline void ecs_add_table(ECS &self) { - hash_table_insert(self.component_tables, (u64)typeid(T).hash_code(), (IComponent_Table *)memory::allocate_and_call_constructor>()); + const std::type_info &info = typeid(T); + hash_table_insert(self.component_tables, (u64)info.hash_code(), (IComponent_Table *)memory::allocate_and_call_constructor>()); } - template - inline static const T * + export template + inline const T * ecs_component_read(ECS &self, Entity e) { return self.read(e); } - template - inline static T * + export template + inline T * ecs_component_write(ECS &self, Entity e) { return self.write(e); } - template - inline static void + export template + inline void ecs_component_remove(ECS &self, Entity e) { self.remove(e); } - template - inline static Array + export template + inline Array ecs_entity_list(ECS &self) { return self.list(); } // TODO: Test this. - inline static void + export inline void ecs_reload(ECS &self) { self.reload(); } + export CORE_API Entity + entity_new() + { + static std::atomic id = 0; + return Entity{id.fetch_add(1)}; + } + // TODO: Rename this to ecs_entity_remove()? - inline static void + // TODO: Should set the id of the removed entity to U64_MAX? + export inline void ecs_entity_free(ECS &self, Entity e) { self.entity_free(e); diff --git a/core/hash.h b/core/hash.h index 2c19a67e..8a1ef754 100644 --- a/core/hash.h +++ b/core/hash.h @@ -3,7 +3,7 @@ #include "core/defines.h" // 32 bit Fowler-Noll-Vo hash. -inline static u64 +inline u64 hash_fnv_x32(const void *key, u64 key_length) { const u32 p = 16777619U; @@ -22,7 +22,7 @@ hash_fnv_x32(const void *key, u64 key_length) } template -inline static u64 +inline u64 hash(const T &) { static_assert(sizeof(T) == 0, "There is no 'u64 hash(const T &)' function overload defined for this type."); @@ -30,86 +30,86 @@ hash(const T &) } template -inline static u64 +inline u64 hash(T *key) { return u64(key); }; template -inline static u64 +inline u64 hash(const T *key) { return u64(key); }; -inline static u64 +inline u64 hash(bool key) { return u64(key); } -inline static u64 +inline u64 hash(char key) { return u64(key); } -inline static u64 +inline u64 hash(i8 key) { return u64(key); } -inline static u64 +inline u64 hash(i16 key) { return u64(key); } -inline static u64 +inline u64 hash(i32 key) { return u64(key); } -inline static u64 +inline u64 hash(i64 key) { return u64(key); } -inline static u64 +inline u64 hash(u8 key) { return u64(key); } -inline static u64 +inline u64 hash(u16 key) { return u64(key); } -inline static u64 +inline u64 hash(u32 key) { return u64(key); } -inline static u64 +inline u64 hash(u64 key) { return u64(key); } -inline static u64 +inline u64 hash(f32 key) { return hash_fnv_x32(&key, sizeof(f32)); } -inline static u64 +inline u64 hash(f64 key) { return hash_fnv_x32(&key, sizeof(f64)); diff --git a/core/memory/memory.h b/core/memory/memory.h index 16d99294..4e26ce99 100644 --- a/core/memory/memory.h +++ b/core/memory/memory.h @@ -37,35 +37,35 @@ namespace memory CORE_API Allocator * temp_allocator(); - inline static void * + inline void * allocate(u64 size) { auto allocator = heap_allocator(); return allocator->allocate(size); } - inline static void * + inline void * allocate(Allocator *allocator, u64 size) { return allocator->allocate(size); } template - inline static T * + inline T * allocate() { return (T *)allocate(sizeof(T)); } template - inline static T * + inline T * allocate(Allocator *allocator) { return (T *)allocate(allocator, sizeof(T)); } template - inline static T * + inline T * allocate_and_call_constructor(TArgs &&...args) { T *data = allocate(); @@ -74,7 +74,7 @@ namespace memory } template - inline static T * + inline T * allocate_and_call_constructor(Allocator *allocator, TArgs &&...args) { T *data = allocate(allocator); @@ -82,7 +82,7 @@ namespace memory return data; } - inline static void * + inline void * allocate_zeroed(u64 size) { void *data = allocate(size); @@ -90,7 +90,7 @@ namespace memory return data; } - inline static void * + inline void * allocate_zeroed(Allocator *allocator, u64 size) { void *data = allocate(allocator, size); @@ -99,34 +99,34 @@ namespace memory } template - inline static T * + inline T * allocate_zeroed() { return (T *)allocate_zeroed(sizeof(T)); } template - inline static T * + inline T * allocate_zeroed(Allocator *allocator) { return (T *)allocate_zeroed(allocator, sizeof(T)); } - inline static void + inline void deallocate(void *data) { auto allocator = heap_allocator(); allocator->deallocate(data); } - inline static void + inline void deallocate(Allocator *allocator, void *data) { allocator->deallocate(data); } template - inline static void + inline void deallocate_and_call_destructor(T *data) { data->~T(); @@ -134,7 +134,7 @@ namespace memory } template - inline static void + inline void deallocate_and_call_destructor(Allocator *allocator, T *data) { data->~T(); diff --git a/core/utils.h b/core/utils.h index aa42597e..113ed3da 100644 --- a/core/utils.h +++ b/core/utils.h @@ -2,7 +2,7 @@ #include "core/defines.h" -inline static u64 +inline u64 next_power_of_two(i32 value) { --value; diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index abd393d9..5ac782bd 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -16,6 +16,7 @@ set(HEADER_FILES set(SOURCE_FILES src/unittest.cpp src/unittest_core.cpp + src/unittest_ecs.cpp src/unittest_containers.cpp src/unittest_platform.cpp src/unittest_reflect.cpp diff --git a/unittest/src/unittest_ecs.cpp b/unittest/src/unittest_ecs.cpp new file mode 100644 index 00000000..18437027 --- /dev/null +++ b/unittest/src/unittest_ecs.cpp @@ -0,0 +1,38 @@ +#include +#include + +import ecs; + +#include + +struct Position +{ + f32 x, y; +}; + +TEST_CASE("[ECS]") +{ + ecs::ECS world = ecs::ecs_new(); + DEFER(ecs::ecs_free(world)); + + ecs::ecs_add_table(world); + + ecs::Entity entity1 = ecs::entity_new(); + DEFER(ecs::ecs_entity_free(world, entity1)); + CHECK(entity1.id == 0); + + auto *position_read = ecs::ecs_component_read(world, entity1); + CHECK(position_read == nullptr); + + auto &position1 = *ecs::ecs_component_write(world, entity1); + position1 = Position{1.0f, 1.0f}; + + position_read = ecs::ecs_component_read(world, entity1); + CHECK(position_read != nullptr); + CHECK(position_read->x == 1.0f); + CHECK(position_read->y == 1.0f); + + ecs::Entity entity2 = ecs::entity_new(); + CHECK(entity2.id == 1); + DEFER(ecs::ecs_entity_free(world, entity2)); +} \ No newline at end of file From eec6a7a3d42406e28e88a714dc75d11366412a15 Mon Sep 17 00:00:00 2001 From: Muhammad Abdulfattah Date: Thu, 12 Dec 2024 05:29:35 +0200 Subject: [PATCH 03/24] Try and compile modules on GCC. (#38) --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 25e5b62c..480db19b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ jobs: fail-fast: true matrix: # os: [windows-latest, ubuntu-latest, macos-latest] // TODO: - os: [windows-latest] + os: [windows-latest, ubuntu-24.04] build-variant: [Debug, Release] steps: - uses: actions/checkout@v4 From 407e7bec05eb52943958b17095f0b36a9014c746 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 04:37:13 +0100 Subject: [PATCH 04/24] Try and add ninja generator to Ubuntu build. --- .github/workflows/main.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 480db19b..2f09cce0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,22 +25,33 @@ jobs: - uses: actions/checkout@v4 # TODO: Install GCC without using a script. - - if: matrix.os == 'ubuntu-latest' + - if: matrix.os == 'ubuntu-24.04' name: Installing GCC uses: egor-tensin/setup-gcc@v1 with: version: 12 + - if: matrix.os == 'ubuntu-24.04' + name: Setup Ninja + uses: ashutoshvarma/setup-ninja@master + with: + version: 1.12.1 - - if: matrix.os == 'ubuntu-latest' + - if: matrix.os == 'ubuntu-24.04' name: Installing Linux dependencies run: | sudo apt update sudo apt-get install -y libx11-dev libxkbcommon-x11-dev libx11-xcb-dev - - name: Configuring + - if: matrix.os == 'ubuntu-24.04' + name: Configuring + run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=${{matrix.build-variant}} -DCORE_BUILD_UNITY=OFF # TODO: Re-enable unity build. + + - if: matrix.os != 'ubuntu-24.04' + name: Configuring run: cmake -B build -DCMAKE_BUILD_TYPE=${{matrix.build-variant}} -DCORE_BUILD_UNITY=OFF # TODO: Re-enable unity build. - - name: Building + - if: matrix.os != 'ubuntu-24.04' + name: Building run: cmake --build build --clean-first --config ${{matrix.build-variant}} -j - name: Running tests From f4e7d2ca413c990ec887df33883e556f3cba2a41 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 04:42:50 +0100 Subject: [PATCH 05/24] Another attempt. --- .github/workflows/main.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2f09cce0..7e3720a6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,11 +25,18 @@ jobs: - uses: actions/checkout@v4 # TODO: Install GCC without using a script. + # - if: matrix.os == 'ubuntu-24.04' + # name: Installing GCC + # uses: egor-tensin/setup-gcc@v1 + # with: + # version: 14 - if: matrix.os == 'ubuntu-24.04' name: Installing GCC - uses: egor-tensin/setup-gcc@v1 - with: - version: 12 + run: | + sudo apt update + sudo apt install build-essential + sudo apt install gcc-14 g++14 + - if: matrix.os == 'ubuntu-24.04' name: Setup Ninja uses: ashutoshvarma/setup-ninja@master From c37da21b21cdb8c4461ffd631b72147791a3e9c6 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 04:45:16 +0100 Subject: [PATCH 06/24] Another attempt. --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7e3720a6..cd14fb73 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,7 +33,8 @@ jobs: - if: matrix.os == 'ubuntu-24.04' name: Installing GCC run: | - sudo apt update + sudo add-apt-repository universe + sudo apt-get update sudo apt install build-essential sudo apt install gcc-14 g++14 From 1216b9d359360ffbd3962d530f7bac6f0f33d43f Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 04:46:45 +0100 Subject: [PATCH 07/24] Another attempt. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cd14fb73..a1b1fe51 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: sudo add-apt-repository universe sudo apt-get update sudo apt install build-essential - sudo apt install gcc-14 g++14 + sudo apt install gcc-14 g++-14 - if: matrix.os == 'ubuntu-24.04' name: Setup Ninja From 52b5770a6e367b61b4427347354235a68eba8a5e Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 04:50:42 +0100 Subject: [PATCH 08/24] Another attempt. --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a1b1fe51..a6f333a3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,6 +37,8 @@ jobs: sudo apt-get update sudo apt install build-essential sudo apt install gcc-14 g++-14 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-14.2.0/bin/g++14.2.0 14 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-14.2.0/bin/gcc14.2.0 14 - if: matrix.os == 'ubuntu-24.04' name: Setup Ninja From e1e2dcaa6351b187c8a3d35606ad8081eeb5c1eb Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 04:51:56 +0100 Subject: [PATCH 09/24] Another attempt. --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a6f333a3..6dc38640 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,8 +37,8 @@ jobs: sudo apt-get update sudo apt install build-essential sudo apt install gcc-14 g++-14 - sudo update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-14.2.0/bin/g++14.2.0 14 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-14.2.0/bin/gcc14.2.0 14 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-14.2.0-4ubuntu2~24.04/bin/g++14.2.0-4ubuntu2~24.04 14 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-14.2.0-4ubuntu2~24.04/bin/gcc14.2.0-4ubuntu2~24.04 14 - if: matrix.os == 'ubuntu-24.04' name: Setup Ninja From ea3c4a729c2332bc8dac4cb771b468f13a83c721 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 04:55:48 +0100 Subject: [PATCH 10/24] Another attempt. --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6dc38640..fcb2073f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,8 +37,9 @@ jobs: sudo apt-get update sudo apt install build-essential sudo apt install gcc-14 g++-14 - sudo update-alternatives --install /usr/bin/g++ g++ /usr/local/gcc-14.2.0-4ubuntu2~24.04/bin/g++14.2.0-4ubuntu2~24.04 14 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/local/gcc-14.2.0-4ubuntu2~24.04/bin/gcc14.2.0-4ubuntu2~24.04 14 + update-alternatives --query gcc + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++14.2.0 14 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc14.2.0 14 - if: matrix.os == 'ubuntu-24.04' name: Setup Ninja From 18fe79a8b62dc85006ebe33fdf5b901e21b442e6 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 04:58:15 +0100 Subject: [PATCH 11/24] Another attempt. --- .github/workflows/main.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fcb2073f..515cf1b3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,9 +37,7 @@ jobs: sudo apt-get update sudo apt install build-essential sudo apt install gcc-14 g++-14 - update-alternatives --query gcc - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++14.2.0 14 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc14.2.0 14 + which g++ - if: matrix.os == 'ubuntu-24.04' name: Setup Ninja From 38e3db220562e074e32d2ae27c1263682a1b0a01 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 05:01:03 +0100 Subject: [PATCH 12/24] Another attempt. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 515cf1b3..af9a3b7c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,7 +38,7 @@ jobs: sudo apt install build-essential sudo apt install gcc-14 g++-14 which g++ - + g++ --version - if: matrix.os == 'ubuntu-24.04' name: Setup Ninja uses: ashutoshvarma/setup-ninja@master From e2a9de725d7de5fadd334ef9b1ca54d4f1870843 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 05:06:43 +0100 Subject: [PATCH 13/24] Another attempt. --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index af9a3b7c..699c5c0e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,12 +33,11 @@ jobs: - if: matrix.os == 'ubuntu-24.04' name: Installing GCC run: | - sudo add-apt-repository universe - sudo apt-get update - sudo apt install build-essential sudo apt install gcc-14 g++-14 which g++ g++ --version + sudo update-alternatives --install /usr/bin/gcc gcc user/bin/g++-14.2.0-4ubuntu2~24.04 14 + sudo update-alternatives --config g++ - if: matrix.os == 'ubuntu-24.04' name: Setup Ninja uses: ashutoshvarma/setup-ninja@master From 4b9eaa7983d676924a4c383eaa6b72a3baa21196 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 05:08:30 +0100 Subject: [PATCH 14/24] Another attempt. --- .github/workflows/main.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 699c5c0e..83a48d29 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,11 +33,9 @@ jobs: - if: matrix.os == 'ubuntu-24.04' name: Installing GCC run: | + sudo apt-get autoremove g++ + sudo apt-get autoremove gcc sudo apt install gcc-14 g++-14 - which g++ - g++ --version - sudo update-alternatives --install /usr/bin/gcc gcc user/bin/g++-14.2.0-4ubuntu2~24.04 14 - sudo update-alternatives --config g++ - if: matrix.os == 'ubuntu-24.04' name: Setup Ninja uses: ashutoshvarma/setup-ninja@master From dc24280fbef7cf085614294d7e5b11c8e4726e50 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 05:10:39 +0100 Subject: [PATCH 15/24] Another attempt. --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 83a48d29..251e367a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,8 +56,7 @@ jobs: name: Configuring run: cmake -B build -DCMAKE_BUILD_TYPE=${{matrix.build-variant}} -DCORE_BUILD_UNITY=OFF # TODO: Re-enable unity build. - - if: matrix.os != 'ubuntu-24.04' - name: Building + - name: Building run: cmake --build build --clean-first --config ${{matrix.build-variant}} -j - name: Running tests From ef4e20655c91bd93487b652f4afd8e6f9f630ee0 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 05:14:02 +0100 Subject: [PATCH 16/24] Use c++20 instead of c++2b flag on Clang. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 933f4cc7..6bbdb809 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ if(MSVC) set(GLOBAL_COMPILE_OPTIONS -W4 -WX -std:c++20 -Zc:preprocessor -wd5105 -wd4273) else() # TODO: -Wno-deprecated-declarations is due to doctest.h sprintf() function. - set(GLOBAL_COMPILE_OPTIONS -Wall -Wextra -pedantic -Werror -std=c++2b -fno-exceptions -Wno-invalid-offsetof -Wno-nested-anon-types -Wno-c++11-narrowing -Wno-gnu-zero-variadic-macro-arguments -Wno-deprecated-declarations -Wno-enum-constexpr-conversion -Wno-unknown-warning-option + set(GLOBAL_COMPILE_OPTIONS -Wall -Wextra -pedantic -Werror -std=c++20 -fno-exceptions -Wno-invalid-offsetof -Wno-nested-anon-types -Wno-c++11-narrowing -Wno-gnu-zero-variadic-macro-arguments -Wno-deprecated-declarations -Wno-enum-constexpr-conversion -Wno-unknown-warning-option ) endif() From f0cf28787dbb05a68e3517b39de82d097b01ffae Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 05:15:45 +0100 Subject: [PATCH 17/24] ffffffffffffffffffffff --- .github/workflows/main.yml | 1 + CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 251e367a..e334fb72 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,6 +35,7 @@ jobs: run: | sudo apt-get autoremove g++ sudo apt-get autoremove gcc + sudo apt-get autoremove clang sudo apt install gcc-14 g++-14 - if: matrix.os == 'ubuntu-24.04' name: Setup Ninja diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bbdb809..933f4cc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ if(MSVC) set(GLOBAL_COMPILE_OPTIONS -W4 -WX -std:c++20 -Zc:preprocessor -wd5105 -wd4273) else() # TODO: -Wno-deprecated-declarations is due to doctest.h sprintf() function. - set(GLOBAL_COMPILE_OPTIONS -Wall -Wextra -pedantic -Werror -std=c++20 -fno-exceptions -Wno-invalid-offsetof -Wno-nested-anon-types -Wno-c++11-narrowing -Wno-gnu-zero-variadic-macro-arguments -Wno-deprecated-declarations -Wno-enum-constexpr-conversion -Wno-unknown-warning-option + set(GLOBAL_COMPILE_OPTIONS -Wall -Wextra -pedantic -Werror -std=c++2b -fno-exceptions -Wno-invalid-offsetof -Wno-nested-anon-types -Wno-c++11-narrowing -Wno-gnu-zero-variadic-macro-arguments -Wno-deprecated-declarations -Wno-enum-constexpr-conversion -Wno-unknown-warning-option ) endif() From 7bd15bb9f11e71a5ff358025945bb11eb1205b27 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 10:27:32 +0100 Subject: [PATCH 18/24] Try again with GCC. --- .github/workflows/main.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e334fb72..8237c020 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,10 +33,17 @@ jobs: - if: matrix.os == 'ubuntu-24.04' name: Installing GCC run: | - sudo apt-get autoremove g++ - sudo apt-get autoremove gcc - sudo apt-get autoremove clang - sudo apt install gcc-14 g++-14 + sudo update-alternatives --remove-all gcc + sudo update-alternatives --remove-all g++ + sudo apt-get install gcc-14.2.0 g++-14.2.0 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14.2.0 20 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14.2.0 20 + sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30 + sudo update-alternatives --set cc /usr/bin/gcc + sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 + sudo update-alternatives --set c++ /usr/bin/g++ + sudo update-alternatives --config gcc + sudo update-alternatives --config g++ - if: matrix.os == 'ubuntu-24.04' name: Setup Ninja uses: ashutoshvarma/setup-ninja@master From 3d7f281e512bebf9d646d07010d3242423510ef6 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 10:29:14 +0100 Subject: [PATCH 19/24] ffff --- .github/workflows/main.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8237c020..2ad41c57 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,16 +33,11 @@ jobs: - if: matrix.os == 'ubuntu-24.04' name: Installing GCC run: | - sudo update-alternatives --remove-all gcc sudo update-alternatives --remove-all g++ sudo apt-get install gcc-14.2.0 g++-14.2.0 - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14.2.0 20 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14.2.0 20 - sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30 - sudo update-alternatives --set cc /usr/bin/gcc sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 sudo update-alternatives --set c++ /usr/bin/g++ - sudo update-alternatives --config gcc sudo update-alternatives --config g++ - if: matrix.os == 'ubuntu-24.04' name: Setup Ninja From 7da2bbf4730a9b8d8a14d9a27ea739c12e66a72d Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 10:34:32 +0100 Subject: [PATCH 20/24] fff --- .github/workflows/main.yml | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2ad41c57..4306b830 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,25 +25,23 @@ jobs: - uses: actions/checkout@v4 # TODO: Install GCC without using a script. - # - if: matrix.os == 'ubuntu-24.04' - # name: Installing GCC - # uses: egor-tensin/setup-gcc@v1 - # with: - # version: 14 - if: matrix.os == 'ubuntu-24.04' name: Installing GCC - run: | - sudo update-alternatives --remove-all g++ - sudo apt-get install gcc-14.2.0 g++-14.2.0 - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14.2.0 20 - sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 - sudo update-alternatives --set c++ /usr/bin/g++ - sudo update-alternatives --config g++ - - if: matrix.os == 'ubuntu-24.04' - name: Setup Ninja - uses: ashutoshvarma/setup-ninja@master + uses: egor-tensin/setup-gcc@v1 with: - version: 1.12.1 + version: 14 + + # - if: matrix.os == 'ubuntu-24.04' + # name: Installing GCC + # run: | + # sudo apt-get install gcc-14.2.0 g++-14.2.0 + # echo "gcc=$gcc" >> $env:GITHUB_OUTPUT + # echo "gxx=$gxx" >> $env:GITHUB_OUTPUT + # - if: matrix.os == 'ubuntu-24.04' + # name: Setup Ninja + # uses: ashutoshvarma/setup-ninja@master + # with: + # version: 1.12.1 - if: matrix.os == 'ubuntu-24.04' name: Installing Linux dependencies From b3fb5341e4bdd8498fee0df4ffcb5a01992f2170 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 10:36:13 +0100 Subject: [PATCH 21/24] Enable ninja generator for Linux. --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4306b830..b8b42731 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,11 +37,11 @@ jobs: # sudo apt-get install gcc-14.2.0 g++-14.2.0 # echo "gcc=$gcc" >> $env:GITHUB_OUTPUT # echo "gxx=$gxx" >> $env:GITHUB_OUTPUT - # - if: matrix.os == 'ubuntu-24.04' - # name: Setup Ninja - # uses: ashutoshvarma/setup-ninja@master - # with: - # version: 1.12.1 + - if: matrix.os == 'ubuntu-24.04' + name: Setup Ninja + uses: ashutoshvarma/setup-ninja@master + with: + version: 1.12.1 - if: matrix.os == 'ubuntu-24.04' name: Installing Linux dependencies From fa99ac5be371d1b2762c0b83efcf05ca7966aa37 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 10:39:16 +0100 Subject: [PATCH 22/24] Remove #pragma once directive from cpp module. --- core/base64.cppm | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/base64.cppm b/core/base64.cppm index e00b51b4..ad159ded 100644 --- a/core/base64.cppm +++ b/core/base64.cppm @@ -1,7 +1,5 @@ module; -#pragma once - #include "core/export.h" #include "core/defines.h" #include "core/export.h" From 38b6a6e93933bbaad8450a1f1d5996428e3380ee Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 10:43:02 +0100 Subject: [PATCH 23/24] Fix include errors on GCC. --- core/json.cpp | 1 + core/memory/heap_allocator.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/core/json.cpp b/core/json.cpp index 8ea42bd9..7e9da69b 100644 --- a/core/json.cpp +++ b/core/json.cpp @@ -2,6 +2,7 @@ #include "core/platform/platform.h" +#include #include struct JSON_Parser diff --git a/core/memory/heap_allocator.cpp b/core/memory/heap_allocator.cpp index d011e22c..7aff51c9 100644 --- a/core/memory/heap_allocator.cpp +++ b/core/memory/heap_allocator.cpp @@ -3,6 +3,7 @@ #include "core/log.h" #include "core/platform/platform.h" +#include #include #include #if DEBUG From 8ebde466f064e888071757a7e9f9d3cc819626e5 Mon Sep 17 00:00:00 2001 From: M-Fatah Date: Thu, 12 Dec 2024 10:45:33 +0100 Subject: [PATCH 24/24] Another attempt at fixing include files. --- core/platform/platform_linux.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/core/platform/platform_linux.cpp b/core/platform/platform_linux.cpp index 248c89e9..86754593 100644 --- a/core/platform/platform_linux.cpp +++ b/core/platform/platform_linux.cpp @@ -20,6 +20,7 @@ #include #include #include +#include static char current_executable_directory[PATH_MAX] = {};