Skip to content
Merged

Ztd #131

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ Checks: >
modernize-*,
performance-*,
readability-*,

-bugprone-easily-swappable-parameters,
-bugprone-exception-escape,
-bugprone-unchecked-optional-access,
-bugprone-derived-method-shadowing-base-method,
-bugprone-branch-clone,
-bugprone-signed-bitwise,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
Expand All @@ -18,6 +21,7 @@ Checks: >
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-pro-type-static-cast-downcast,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-init-variables,
-modernize-use-trailing-return-type,
-modernize-use-integer-sign-comparison,
-readability-magic-numbers,
Expand All @@ -28,19 +32,22 @@ Checks: >
-readability-else-after-return,
-readability-avoid-nested-conditional-operator,
-readability-math-missing-parentheses,
-readability-redundant-declaration,

-bugprone-macro-parentheses,
-cppcoreguidelines-pro-type-member-init,
-cppcoreguidelines-init-variables,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-prefer-member-initializer,
-cppcoreguidelines-avoid-c-arrays,
-modernize-use-nodiscard,
-modernize-avoid-c-arrays,
-readability-qualified-auto,
-readability-avoid-const-params-in-decls,
-readability-convert-member-functions-to-static,
-readability-trailing-comma,
-performance-enum-size,
-performance-no-int-to-ptr,
-clang-analyzer-optin.performance.Padding
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ add_subdirectory(externals/nx2elf SYSTEM)

# date
set(BUILD_TZ_LIB ON)
set(USE_SYSTEM_TZ_DB ON)
add_subdirectory(externals/date SYSTEM)

set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
Expand Down Expand Up @@ -192,6 +193,7 @@ target_compile_options(hydra_compile_options INTERFACE

# Disabled warnings
-Wno-missing-designated-field-initializers
-Wno-unused-template

# Extensions
-Wno-c99-extensions
Expand Down
2 changes: 1 addition & 1 deletion externals/hatch
2 changes: 1 addition & 1 deletion externals/nx2elf
Submodule nx2elf updated 1 files
+1 −0 src/elf_eh.cpp
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
include_directories(.)

set(ZTD_PRECOMPILE_HEADERS ON)
set(ZTD_CLANG_TIDY_ENABLED ${CLANG_TIDY_ENABLED})
add_subdirectory(ztd)

if (CLANG_TIDY_ENABLED)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-use-color;-extra-arg-before=-Wno-unknown-warning-option")
endif ()
Expand Down
26 changes: 5 additions & 21 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,43 +1,27 @@
add_library(hydra-common
platform.hpp
macros.hpp
type_aliases.hpp
handle.hpp
types.hpp
range.hpp
traits.hpp
functions.hpp
atomic.hpp
literals.hpp
string.hpp
time.hpp
hash.hpp
linked_list.hpp
pool.hpp
static_pool.hpp
dynamic_pool.hpp
small_cache.hpp
filesystem.hpp
log.cpp
log.hpp
lz4.cpp
lz4.hpp
toml_helper.hpp
fmt_helper.hpp
config.cpp
config.hpp
common.hpp
io/stream.hpp
io/continuous_stream.hpp
io/memory_stream.hpp
io/iostream_stream.hpp
io/stream_view.hpp
io/sparse_stream.hpp
)

target_link_libraries(hydra-common PRIVATE hydra_compile_options)
target_link_libraries(hydra-common PUBLIC fmt::fmt toml11::toml11)

target_precompile_headers(hydra-common PUBLIC common.hpp)

target_link_libraries(hydra-common PRIVATE hydra_compile_options)
target_link_libraries(hydra-common PUBLIC fmt::fmt toml11::toml11 ztd::ztd)

if (CMAKE_SYSTEM_NAME STREQUAL "iOS")
set_target_properties(hydra-common PROPERTIES
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${IOS_DEPLOYMENT_TARGET}
Expand Down
5 changes: 4 additions & 1 deletion src/common/atomic.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <atomic>

#include "type_aliases.hpp"

#if __cpp_lib_atomic_ref >= 201806L
Expand Down Expand Up @@ -67,7 +69,8 @@ template <>
inline constexpr bool atomic_supported_size<u128> = true;

template <typename T>
concept valid_atomic = std::is_trivially_copyable_v<T> and atomic_supported_size<T>;
concept valid_atomic =
std::is_trivially_copyable_v<T> and atomic_supported_size<T>;

template <valid_atomic T>
void atomic_store(T* ptr, T value) {
Expand Down
14 changes: 2 additions & 12 deletions src/common/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,13 @@

#include "common/atomic.hpp"
#include "common/config.hpp"
#include "common/dynamic_pool.hpp"
#include "common/filesystem.hpp"
#include "common/fmt_helper.hpp"
#include "common/functions.hpp"
#include "common/hash.hpp"
#include "common/io/iostream_stream.hpp"
#include "common/io/memory_stream.hpp"
#include "common/io/sparse_stream.hpp"
#include "common/io/stream_view.hpp"
#include "common/linked_list.hpp"
#include "common/literals.hpp"
#include "common/handle.hpp"
#include "common/log.hpp"
#include "common/objc.hpp"
#include "common/platform.hpp"
#include "common/range.hpp"
#include "common/small_cache.hpp"
#include "common/static_pool.hpp"
#include "common/string.hpp"
#include "common/time.hpp"
#include "common/toml_helper.hpp"
#include "common/traits.hpp"
8 changes: 4 additions & 4 deletions src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct into<CustomResolution> {
namespace hydra {

Config::Config() {
#ifdef PLATFORM_APPLE
#ifdef ZTD_PLATFORM_APPLE
if (const char* home = std::getenv("HOME")) {
app_data_path =
fmt::format("{}/Library/Application Support/" APP_NAME, home);
Expand All @@ -72,7 +72,7 @@ Config::Config() {
} else {
LOG_FATAL(Other, "Failed to find HOME path");
}
#elifdef PLATFORM_WINDOWS
#elifdef ZTD_PLATFORM_WINDOWS
if (const char* app_data = std::getenv("APPDATA")) {
app_data_path = fmt::format("{}/" APP_NAME, app_data);
logs_path = fmt::format("{}/logs", app_data_path); // TODO
Expand All @@ -85,7 +85,7 @@ Config::Config() {
} else {
LOG_FATAL(Other, "Failed to find USERPROFILE path");
}
#elif defined(PLATFORM_LINUX)
#elifdef ZTD_PLATFORM_LINUX
if (const char* xdg_config = std::getenv("XDG_CONFIG_HOME")) {
app_data_path = fmt::format("{}/" APP_NAME, xdg_config);
logs_path = fmt::format("{}/logs", app_data_path);
Expand All @@ -111,7 +111,7 @@ Config::Config() {
std::filesystem::create_directories(app_data_path);
std::filesystem::create_directories(logs_path);
// HACK
#ifndef PLATFORM_IOS
#ifndef ZTD_PLATFORM_IOS
std::filesystem::create_directories(pictures_path);
#endif

Expand Down
8 changes: 5 additions & 3 deletions src/common/config.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#pragma once

#include <cstdlib>

#include <fmt/ranges.h>

#include "common/fmt_helper.hpp"
#include "common/log.hpp"
#include "common/platform.hpp"
#include "common/types.hpp"

#define CONFIG_INSTANCE Config::GetInstance()
Expand Down Expand Up @@ -104,7 +106,7 @@ class Config {
static std::vector<LoaderPlugin> GetDefaultLoaderPlugins() { return {}; }
static std::vector<std::string> GetDefaultPatchPaths() { return {}; }
static InputBackend GetDefaultInputBackend() {
#ifdef PLATFORM_APPLE
#ifdef ZTD_PLATFORM_APPLE
return InputBackend::AppleGameController;
#else
return InputBackend::Sdl;
Expand All @@ -121,7 +123,7 @@ class Config {
#endif
}
static GpuRenderer GetDefaultGpuRenderer() {
#ifdef PLATFORM_APPLE
#ifdef ZTD_PLATFORM_APPLE
return GpuRenderer::Metal;
#else
return GpuRenderer::Null;
Expand Down
46 changes: 0 additions & 46 deletions src/common/dynamic_pool.hpp

This file was deleted.

4 changes: 2 additions & 2 deletions src/common/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

#include <CoreFoundation/CoreFoundation.h>

#include "common/fmt_helper.hpp"
#include "common/log.hpp"
#include "common/platform.hpp"

namespace hydra {

#ifdef PLATFORM_APPLE
#ifdef ZTD_PLATFORM_APPLE
inline std::string GetBundleResourcePath(const std::string& filename) {
CFBundleRef main_bundle = CFBundleGetMainBundle();
if (main_bundle == nullptr) {
Expand Down
Loading
Loading