Skip to content

Commit

Permalink
External dependencies cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mattparks committed Sep 20, 2023
1 parent 6c71e6f commit 310f56e
Show file tree
Hide file tree
Showing 37 changed files with 102 additions and 85 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ jobs:
submodules: recursive
- name: Download Vulkan
run: |
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.2.189.0/windows/VulkanSDK-1.2.189.0-Installer.exe" -OutFile vulkan-sdk.exe
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.3.261.1/windows/VulkanSDK-1.3.261.1-Installer.exe" -OutFile vulkan-sdk.exe
$installer = Start-Process -FilePath vulkan-sdk.exe -Wait -PassThru -ArgumentList @("/S");
$installer.WaitForExit();
- name: Download OpenAL
run: |
Invoke-WebRequest -Uri "https://openal-soft.org/openal-binaries/openal-soft-1.22.2-bin.zip" -OutFile openal-soft.zip
Invoke-WebRequest -Uri "https://openal-soft.org/openal-binaries/openal-soft-1.23.1-bin.zip" -OutFile openal-soft.zip
Expand-Archive -Path openal-soft.zip -DestinationPath C:\\
- name: Build
env:
VULKAN_SDK: "C:\\VulkanSDK\\1.2.189.0"
OPENALDIR: "C:\\openal-soft-1.22.2-bin"
VULKAN_SDK: "C:\\VulkanSDK\\1.3.261.1"
OPENALDIR: "C:\\openal-soft-1.23.1-bin"
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
Expand Down Expand Up @@ -80,17 +80,17 @@ jobs:
run: echo "${{ runner.temp }}/msys64/mingw64/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Download Vulkan
run: |
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.2.189.0/windows/VulkanSDK-1.2.189.0-Installer.exe" -OutFile vulkan-sdk.exe
Invoke-WebRequest -Uri "https://sdk.lunarg.com/sdk/download/1.3.261.1/windows/VulkanSDK-1.3.261.1-Installer.exe" -OutFile vulkan-sdk.exe
$installer = Start-Process -FilePath vulkan-sdk.exe -Wait -PassThru -ArgumentList @("/S");
$installer.WaitForExit();
- name: Download OpenAL
run: |
Invoke-WebRequest -Uri "https://openal-soft.org/openal-binaries/openal-soft-1.22.2-bin.zip" -OutFile openal-soft.zip
Invoke-WebRequest -Uri "https://openal-soft.org/openal-binaries/openal-soft-1.23.1-bin.zip" -OutFile openal-soft.zip
Expand-Archive -Path openal-soft.zip -DestinationPath C:\\
- name: Build
env:
VULKAN_SDK: "C:\\VulkanSDK\\1.2.189.0"
OPENALDIR: "C:\\openal-soft-1.22.2-bin"
VULKAN_SDK: "C:\\VulkanSDK\\1.3.261.1"
OPENALDIR: "C:\\openal-soft-1.23.1-bin"
shell: cmd
run: |
cmake --version
Expand Down
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
.vs/*
.vscode/*
.idea/*
.cache/*
cmake-build-debug/*
cmake-build-release/*
Build/*
Resources/Sounds/Music/Hiitori-Bocchi.wav
Resources/Sounds/Music/Hiitori-Bocchi.mp3
Resources/Sounds/Music/Hiitori-Bocchi.flac
Resources/Sounds/Music/Hiitori-Bocchi.aiff
.DS_Store
19 changes: 8 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,18 @@ endforeach()

# Add property to allow making project folders in IDEs
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_DISABLE_SOURCE_CHANGES ON CACHE BOOL "")
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON CACHE BOOL "")
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "Whether to create a position-independent target")
if(BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON CACHE BOOL "Export all symbols")
endif()
# Under some compilers CMAKE_DEBUG_POSTFIX is set to "d", removed to clean dll names
set(CMAKE_DEBUG_POSTFIX "" CACHE STRING "Set Debug library postfix")
set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "Set Release library postfix")
set(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "Set RelWithDebInfo library postfix")
set(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "Set MinsizeRel library postfix")
# Removes any dll prefix name on windows, unix will keep a prefix set as "lib"
set(CMAKE_DEBUG_POSTFIX "" CACHE STRING "")
set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "")
set(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "")
set(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "")
if(WIN32)
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON CACHE BOOL "")
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "")
set(CMAKE_DISABLE_SOURCE_CHANGES ON CACHE BOOL "")
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON CACHE BOOL "")

# Multithreaded MSVC builds
if(MSVC_VERSION GREATER 1500 AND ${CMAKE_VERSION} VERSION_GREATER "2.8.6")
Expand Down
2 changes: 1 addition & 1 deletion Editor/Plugins.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace test {
* Module used for managing the world.
*/
class Plugins : public Module::Registrar<Plugins>, public rocket::trackable {
inline static const bool Registered = Register(Stage::Always, Requires<Files>());
inline static const bool Registered = Register(Stage::Always, Require<Files>());
public:
Plugins();
~Plugins();
Expand Down
2 changes: 1 addition & 1 deletion Engine/Animation/Animations/Skin/VertexWeights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace acid {
void VertexWeights::AddJointEffect(uint32_t jointId, float jointWeight) {
for (auto &&[i, weight] : Enumerate(weights)) {
for (auto [i, weight] : Enumerate(weights)) {
if (jointWeight > weight) {
jointIds[i] = jointId;
weight = jointWeight;
Expand Down
9 changes: 8 additions & 1 deletion Engine/Context/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ if(NOT TARGET glfw)

set_target_properties(glfw PROPERTIES FOLDER "External/glfw")
set_target_properties(update_mappings PROPERTIES FOLDER "External/glfw")

set(GLFW3_LIBRARIES glfw)
endif()

target_compile_features(${_component_library} PUBLIC c_std_11 cxx_std_17)
Expand All @@ -124,13 +126,15 @@ target_include_directories(${_component_library}
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/third_party/stb>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/third_party/tinydng>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/third_party/tinyexr>
PRIVATE
$<BUILD_INTERFACE:$<$<BOOL:${GLFW3_INCLUDE_DIRS}>:${GLFW3_INCLUDE_DIRS}>>
)
target_link_libraries(${_component_library}
PUBLIC
Acid::Core
Vulkan::Vulkan
PRIVATE
glfw
${GLFW3_LIBRARIES}
)
set_target_properties(${_component_library}
PROPERTIES
Expand All @@ -147,5 +151,8 @@ source_group(TREE "${THIRD_PARTY_SOURCE_DIR}" PREFIX "ThirdParty" FILES ${_compo
install_headers_with_dir("${_component_name}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_component_headers}")
install_headers_with_dir("${_component_name}" "${CMAKE_CURRENT_BINARY_DIR}/include" "${_component_generated_headers}")
install_headers_with_dir("third_party" "${THIRD_PARTY_SOURCE_DIR}" "${_component_third_party_headers}")
if(NOT BUILD_SHARED_LIBS)
install(TARGETS ${GLFW3_LIBRARIES} EXPORT AcidTargets)
endif()

set(ACID_LIBRARIES "${ACID_LIBRARIES};${_component_library}" CACHE INTERNAL "")
2 changes: 1 addition & 1 deletion Engine/Context/Devices/Joysticks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class ACID_CONTEXT_EXPORT Joystick {
* @brief Module used for the creation, updating and destruction of the joysticks.
*/
class ACID_CONTEXT_EXPORT Joysticks : public Module::Registrar<Joysticks> {
inline static const bool Registered = Register(Stage::Pre, Requires<Windows>());
inline static const bool Registered = Register(Stage::Pre, Require<Windows>());
public:
Joysticks();

Expand Down
2 changes: 1 addition & 1 deletion Engine/Context/Inputs/Inputs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace acid {
* @brief Module used for managing abstract inputs organized in schemes.
*/
class ACID_CONTEXT_EXPORT Inputs : public Module::Registrar<Inputs> {
inline static const bool Registered = Register(Stage::Pre, Requires<Windows, Joysticks>());
inline static const bool Registered = Register(Stage::Pre, Require<Windows, Joysticks>());
public:
Inputs();

Expand Down
8 changes: 6 additions & 2 deletions Engine/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ target_compile_definitions(${_component_library}
# 64-bit
$<$<EQUAL:8,${CMAKE_SIZEOF_VOID_P}>:ACID_BUILD_64BIT>
# Windows
$<$<PLATFORM_ID:Windows>:ACID_BUILD_WINDOWS WIN32_LEAN_AND_MEAN NOMINMAX>
$<$<PLATFORM_ID:Windows>:ACID_BUILD_WINDOWS _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS WIN32_LEAN_AND_MEAN NOMINMAX>
# Linux
$<$<PLATFORM_ID:Linux>:ACID_BUILD_LINUX>
# macOS
$<$<PLATFORM_ID:Darwin>:ACID_BUILD_MACOS>
# MSVC
$<$<CXX_COMPILER_ID:MSVC>:ACID_BUILD_MSVC _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS>
$<$<CXX_COMPILER_ID:MSVC>:ACID_BUILD_MSVC>
# Clang/AppleClang
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:ACID_BUILD_CLANG>
# GNU/GCC
Expand All @@ -161,6 +161,7 @@ target_compile_options(${_component_library}
PUBLIC
# Disables symbol warnings.
$<$<CXX_COMPILER_ID:MSVC>:/wd4018 /wd4067 /wd4244 /wd4251 /wd4267 /wd4275 /wd4996>
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Wno-undefined-var-template>
# Enabled SSE2 for MSVC for 32-bit.
$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<EQUAL:4,${CMAKE_SIZEOF_VOID_P}>>:/arch:SSE2>
# Enables SSE4.1, it is also possible to use SSE2 with -msse2
Expand Down Expand Up @@ -206,5 +207,8 @@ source_group(TREE "${THIRD_PARTY_SOURCE_DIR}" PREFIX "ThirdParty" FILES ${_compo
install_headers_with_dir("${_component_name}" "${CMAKE_CURRENT_SOURCE_DIR}" "${_component_headers}")
install_headers_with_dir("${_component_name}" "${CMAKE_CURRENT_BINARY_DIR}/include" "${_component_generated_headers}")
install_headers_with_dir("third_party" "${THIRD_PARTY_SOURCE_DIR}" "${_component_third_party_headers}")
if(NOT BUILD_SHARED_LIBS)
install(TARGETS ${PHYSFS_LIBRARY} EXPORT AcidTargets)
endif()

set(ACID_LIBRARIES "${_component_library}" CACHE INTERNAL "")
6 changes: 2 additions & 4 deletions Engine/Core/Engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include "CoreConfig.hpp"

namespace acid {
Engine *Engine::Instance = nullptr;

Engine::Engine(std::string argv0, ModuleFilter &&moduleFilter) :
argv0(std::move(argv0)),
version{ACID_VERSION_MAJOR, ACID_VERSION_MINOR, ACID_VERSION_PATCH},
Expand Down Expand Up @@ -94,7 +92,7 @@ void Engine::CreateModule(Module::TRegistryMap::const_iterator it, const ModuleF
return;

// TODO: Prevent circular dependencies.
for (auto requireId : it->second.requires)
for (auto requireId : it->second.require)
CreateModule(Module::Registry().find(requireId), filter);

auto &&module = it->second.create();
Expand All @@ -108,7 +106,7 @@ void Engine::DestroyModule(TypeId id) {

// Destroy all module dependencies first.
for (const auto &[registrarId, registrar] : Module::Registry()) {
if (std::find(registrar.requires.begin(), registrar.requires.end(), id) != registrar.requires.end())
if (std::find(registrar.require.begin(), registrar.require.end(), id) != registrar.require.end())
DestroyModule(registrarId);
}

Expand Down
4 changes: 2 additions & 2 deletions Engine/Core/Engine/Engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ class ACID_CORE_EXPORT Engine : NonCopyable {
void CreateModule(Module::TRegistryMap::const_iterator it, const ModuleFilter &filter);
void DestroyModule(TypeId id);
void UpdateStage(Module::Stage stage);
static Engine *Instance;

inline static Engine *Instance = nullptr;

std::string argv0;
Version version;
Expand Down
3 changes: 0 additions & 3 deletions Engine/Core/Engine/Log.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#include "Log.hpp"

namespace acid {
std::mutex Log::WriteMutex;
std::ofstream Log::FileStream;

void Log::OpenLog(const std::filesystem::path &filepath) {
//std::unique_lock<std::mutex> lock(WriteMutex);
if (auto parentPath = filepath.parent_path(); !parentPath.empty())
Expand Down
4 changes: 2 additions & 2 deletions Engine/Core/Engine/Log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ class ACID_CORE_EXPORT Log {

private:
// TODO: Only use mutex in synced writes (where output order must be the same).
static std::mutex WriteMutex;
static std::ofstream FileStream;
inline static std::mutex WriteMutex;
inline static std::ofstream FileStream;

/**
* A internal method used to write values to the out stream and to a file.
Expand Down
14 changes: 7 additions & 7 deletions Engine/Core/Engine/Module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ModuleFactory {
public:
std::function<std::unique_ptr<Base>()> create;
typename Base::Stage stage;
std::vector<TypeId> requires;
std::vector<TypeId> require;
};
using TRegistryMap = std::unordered_map<TypeId, TCreateValue>;

Expand All @@ -28,12 +28,12 @@ class ModuleFactory {
}

template<typename ... Args>
class Requires {
class Require {
public:
std::vector<TypeId> Get() const {
std::vector<TypeId> requires;
(requires.emplace_back(TypeInfo<Base>::template GetTypeId<Args>()), ...);
return requires;
std::vector<TypeId> require;
(require.emplace_back(TypeInfo<Base>::template GetTypeId<Args>()), ...);
return require;
}
};

Expand Down Expand Up @@ -61,12 +61,12 @@ class ModuleFactory {
* @return A dummy value in static initialization.
*/
template<typename ... Args>
static bool Register(typename Base::Stage stage, Requires<Args...> &&requires = {}) {
static bool Register(typename Base::Stage stage, Require<Args...> &&require = {}) {
ModuleFactory::Registry()[TypeInfo<Base>::template GetTypeId<T>()] = {[]() {
moduleInstance = new T();
// The registrar does not own the instance, the engine does, we just hold a raw pointer for convenience.
return std::unique_ptr<Base>(moduleInstance);
}, stage, requires.Get()};
}, stage, require.Get()};
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions Engine/Core/Files/Json/Json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ void Json::Load(Node &node, std::string_view string) {
}
}

if (tokens.empty())
throw std::runtime_error("No tokens found in document");
//if (tokens.empty())
// throw std::runtime_error("No tokens found in document");

// Converts the tokens into nodes.
int32_t k = 0;
Expand Down
8 changes: 7 additions & 1 deletion Engine/Core/Files/Node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ class ACID_CORE_EXPORT Node final {
template<typename T, typename = std::enable_if_t<std::is_convertible_v<T *, NodeFormat *>>>
void WriteStream(std::ostream &stream, NodeFormat::Format format = NodeFormat::Minified) const;

template<typename T, typename _Elem = char, typename = std::enable_if_t<std::is_convertible_v<T *, NodeFormat *>>>
template<typename T, typename _Elem = char, typename = std::enable_if_t<
std::is_convertible_v<T *, NodeFormat *>
#ifndef ACID_BUILD_MSVC
// Cannot dynamicly parse wide streams on GCC or Clang
&& std::is_same_v<_Elem, char>
#endif
>>
void ParseStream(std::basic_istream<_Elem> &stream);
template<typename T, typename _Elem = char, typename = std::enable_if_t<std::is_convertible_v<T *, NodeFormat *>>>
std::basic_string<_Elem> WriteString(NodeFormat::Format format = NodeFormat::Minified) const;
Expand Down
7 changes: 1 addition & 6 deletions Engine/Core/Files/Node.inl
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,8 @@ void Node::WriteStream(std::ostream &stream, NodeFormat::Format format) const {
template<typename T, typename _Elem, typename>
void Node::ParseStream(std::basic_istream<_Elem> &stream) {
// We must read as UTF8 chars.
if constexpr (!std::is_same_v<_Elem, char>) {
#ifndef _MSC_VER
throw std::runtime_error("Cannot dynamicly parse wide streams on GCC or Clang");
#else
if constexpr (!std::is_same_v<_Elem, char>)
stream.imbue(std::locale(stream.getloc(), new std::codecvt_utf8<char>));
#endif
}

// Reading into a string before iterating is much faster.
std::string s(std::istreambuf_iterator<_Elem>(stream), {});
Expand Down
14 changes: 7 additions & 7 deletions Engine/Core/Files/NodeFormat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ class ACID_CORE_EXPORT NodeFormat {
virtual void WriteStream(const Node &node, std::ostream &stream, Format format = Minified) const = 0;

// TODO: Duplicate ParseStream/WriteString templates from Node.
template<typename _Elem = char>
template<typename _Elem = char
#ifndef ACID_BUILD_MSVC
// Cannot dynamicly parse wide streams on GCC or Clang
, typename = std::enable_if_t<std::is_same_v<_Elem, char>>
#endif
>
void ParseStream(Node &node, std::basic_istream<_Elem> &stream) {
// We must read as UTF8 chars.
if constexpr (!std::is_same_v<_Elem, char>) {
#ifndef ACID_BUILD_MSVC
throw std::runtime_error("Cannot dynamicly parse wide streams on GCC or Clang");
#else
if constexpr (!std::is_same_v<_Elem, char>)
stream.imbue(std::locale(stream.getloc(), new std::codecvt_utf8<char>));
#endif
}

// Reading into a string before iterating is much faster.
std::string s(std::istreambuf_iterator<_Elem>(stream), {});
Expand Down
4 changes: 2 additions & 2 deletions Engine/Core/Files/Xml/Xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ void Xml::Load(Node &node, std::string_view string) {
}
}

if (tokens.empty())
throw std::runtime_error("No tokens found in document");
//if (tokens.empty())
// throw std::runtime_error("No tokens found in document");

// Converts the tokens into nodes.
int32_t k = 0;
Expand Down
3 changes: 2 additions & 1 deletion Engine/Core/Maths/Vector2.inl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include "Vector2.hpp"

#include "Files/Node.hpp"
#include "Maths.hpp"
#include "Vector2.hpp"

namespace acid {
template<typename T>
Expand Down
3 changes: 2 additions & 1 deletion Engine/Core/Maths/Vector3.inl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include "Vector3.hpp"

#include "Files/Node.hpp"
#include "Maths.hpp"
#include "Vector3.hpp"

namespace acid {
template<typename T>
Expand Down
3 changes: 2 additions & 1 deletion Engine/Core/Maths/Vector4.inl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once

#include "Vector4.hpp"

#include "Files/Node.hpp"
#include "Maths.hpp"
#include "Vector4.hpp"

namespace acid {
template<typename T>
Expand Down
Loading

0 comments on commit 310f56e

Please sign in to comment.