mirror of
https://github.com/libAthena/athena.git
synced 2025-12-08 13:15:05 +00:00
Compare commits
49 Commits
a87e8bb39f
...
latest
| Author | SHA1 | Date | |
|---|---|---|---|
| e1cac75d80 | |||
| b8a46a5ee6 | |||
| f7c1cd8f59 | |||
| fa346ace47 | |||
| c6046d9150 | |||
| 01970c7249 | |||
| f27a63f312 | |||
|
e13b498266
|
|||
|
066e3ae109
|
|||
|
644070d5f3
|
|||
| 2aa9a573a0 | |||
| 4bd9dfac61 | |||
| bc2ebaab88 | |||
| 6eec5760b3 | |||
| 96fa2d24ef | |||
| b0daee99fc | |||
| daf8bf0595 | |||
| 2aa5b76732 | |||
| 064839bad6 | |||
| 37206e5301 | |||
| 37c56eec07 | |||
| a4074e1a57 | |||
| da92db7356 | |||
| f02251ebf3 | |||
| 14e4d4e2ea | |||
| 11b86d7634 | |||
| 7a2a8a79ca | |||
| 991ffede79 | |||
| 4fa2335258 | |||
| ec43f653a7 | |||
| 2604243293 | |||
| 8558ca1b51 | |||
| b67f6dc231 | |||
| b3a274fcd8 | |||
| a36e589129 | |||
| 42d777bc1c | |||
| bbf8923a09 | |||
| 3ca375d030 | |||
| e2af6e5c79 | |||
| c53c9560fd | |||
| ec2675f130 | |||
| 79515ed6db | |||
| 144e14f2f5 | |||
| 85a16c7f45 | |||
| 5358d195bb | |||
| 608d675d9c | |||
| 666dea48ae | |||
|
|
25d3ed0f33 | ||
|
|
f5ad22ecf4 |
29
.clang-format
Normal file
29
.clang-format
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
BasedOnStyle: LLVM
|
||||
ColumnLimit: 120
|
||||
UseTab: Never
|
||||
TabWidth: 2
|
||||
---
|
||||
Language: Cpp
|
||||
DerivePointerAlignment: false
|
||||
PointerAlignment: Left
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
IndentCaseLabels: false
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BreakConstructorInitializersBeforeComma: true
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
Cpp11BracedListStyle: true
|
||||
NamespaceIndentation: None
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
SortIncludes: false
|
||||
AccessModifierOffset: -2
|
||||
ConstructorInitializerIndentWidth: 0
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
1
.clang-tidy
Normal file
1
.clang-tidy
Normal file
@@ -0,0 +1 @@
|
||||
Checks: '*,-misc-unused-parameters,-modernize-use-trailing-return-type,-readability-named-parameter,-readability-convert-member-functions-to-static,-readability-uppercase-literal-suffix,-readability-magic-numbers,-hicpp-uppercase-literal-suffix,-hicpp-signed-bitwise,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-non-private-member-variables-in-classes,-fuchsia-*,-google-runtime-references,-llvmlibc-*'
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -18,4 +18,8 @@ PKGBUILD
|
||||
**/doc
|
||||
**/obj
|
||||
**/Makefile
|
||||
|
||||
/build
|
||||
/out
|
||||
/cmake-build-*
|
||||
/.idea
|
||||
/.buildcache
|
||||
|
||||
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -1,8 +1,4 @@
|
||||
[submodule "extern/lzokay"]
|
||||
path = extern/lzokay
|
||||
url = https://github.com/jackoalan/lzokay.git
|
||||
branch = master
|
||||
[submodule "extern/fmt"]
|
||||
path = extern/fmt
|
||||
url = https://github.com/fmtlib/fmt
|
||||
url = https://github.com/AxioDL/lzokay.git
|
||||
branch = master
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
set(PACKAGE_VERSION "@ATHENA_VERSION@")
|
||||
set(PACKAGE_VERSION "@ATHENA_VERSION_STRING@")
|
||||
|
||||
# Check whether the requested PACKAGE_FIND_VERSION is compatible
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
|
||||
|
||||
238
CMakeLists.txt
238
CMakeLists.txt
@@ -1,21 +1,138 @@
|
||||
cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17
|
||||
# Set MSVC runtime library flags from CMAKE_MSVC_RUNTIME_LIBRARY
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
project(athena)
|
||||
if (NOT MSVC)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
endif()
|
||||
|
||||
##################
|
||||
# Athena Version #
|
||||
##################
|
||||
find_package(Git)
|
||||
if (GIT_FOUND)
|
||||
# make sure version information gets re-run when the current Git HEAD changes
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --git-path HEAD
|
||||
OUTPUT_VARIABLE athena_git_head_filename
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${athena_git_head_filename}")
|
||||
|
||||
set(ATHENA_MAJOR_VERSION 2)
|
||||
set(ATHENA_MINOR_VERSION 3)
|
||||
set(ATHENA_PATCH_VERSION 0)
|
||||
set(ATHENA_VERSION
|
||||
${ATHENA_MAJOR_VERSION}.${ATHENA_MINOR_VERSION}.${ATHENA_PATCH_VERSION})
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --symbolic-full-name HEAD
|
||||
OUTPUT_VARIABLE athena_git_head_symbolic
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${GIT_EXECUTABLE} rev-parse --git-path ${athena_git_head_symbolic}
|
||||
OUTPUT_VARIABLE athena_git_head_symbolic_filename
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${athena_git_head_symbolic_filename}")
|
||||
|
||||
# defines ATHENA_WC_REVISION
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
||||
OUTPUT_VARIABLE ATHENA_WC_REVISION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
# defines ATHENA_WC_DESCRIBE
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --tag --long --dirty --exclude latest
|
||||
OUTPUT_VARIABLE ATHENA_WC_DESCRIBE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# remove hash (and trailing "-0" if needed) from description
|
||||
string(REGEX REPLACE "(-0)?-[^-]+((-dirty)?)$" "\\2" ATHENA_WC_DESCRIBE "${ATHENA_WC_DESCRIBE}")
|
||||
|
||||
# defines ATHENA_WC_BRANCH
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
||||
OUTPUT_VARIABLE ATHENA_WC_BRANCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
# defines ATHENA_WC_DATE
|
||||
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} log -1 --format=%ad
|
||||
OUTPUT_VARIABLE ATHENA_WC_DATE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
else ()
|
||||
message(STATUS "Unable to find git, commit information will not be available")
|
||||
endif ()
|
||||
|
||||
if (ATHENA_WC_DESCRIBE)
|
||||
string(REGEX REPLACE "v?([0-9]+)\.([0-9]+)\.([0-9]+)\-([0-9]+).*" "\\1.\\2.\\3.\\4" ATHENA_VERSION_STRING "${ATHENA_WC_DESCRIBE}")
|
||||
string(REGEX REPLACE "v?([0-9]+)\.([0-9]+)\.([0-9]+).*" "\\1.\\2.\\3" ATHENA_VERSION "${ATHENA_VERSION_STRING}")
|
||||
string(REGEX REPLACE "v?([0-9]+)\.([0-9]+)\.([0-9]+).*" "\\1" ATHENA_MAJOR_VERSION "${ATHENA_VERSION_STRING}")
|
||||
string(REGEX REPLACE "v?([0-9]+)\.([0-9]+)\.([0-9]+).*" "\\2" ATHENA_MINOR_VERSION "${ATHENA_VERSION_STRING}")
|
||||
string(REGEX REPLACE "v?([0-9]+)\.([0-9]+)\.([0-9]+).*" "\\3" ATHENA_PATCH_VERSION "${ATHENA_VERSION_STRING}")
|
||||
else ()
|
||||
set(ATHENA_WC_DESCRIBE "UNKNOWN-VERSION")
|
||||
set(ATHENA_VERSION "0.0.0")
|
||||
set(ATHENA_MAJOR_VERSION "0")
|
||||
set(ATHENA_MINOR_VERSION "0")
|
||||
set(ATHENA_PATCH_VERSION "0")
|
||||
endif ()
|
||||
|
||||
# Add version information to CI environment variables
|
||||
if(DEFINED ENV{GITHUB_ENV} AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
file(APPEND "$ENV{GITHUB_ENV}" "ATHENA_VERSION=${ATHENA_WC_DESCRIBE}\n")
|
||||
endif()
|
||||
|
||||
project(athena VERSION ${ATHENA_VERSION} LANGUAGES C CXX)
|
||||
|
||||
if (MSVC)
|
||||
# Shaddup MSVC
|
||||
add_compile_definitions(UNICODE=1 _UNICODE=1 __SSE__=1
|
||||
_CRT_SECURE_NO_WARNINGS=1 D_SCL_SECURE_NO_WARNINGS=1
|
||||
_SCL_SECURE_NO_DEPRECATE=1 _CRT_NONSTDC_NO_WARNINGS=1
|
||||
_ENABLE_EXTENDED_ALIGNED_STORAGE=1 NOMINMAX=1)
|
||||
add_compile_options(/IGNORE:4221
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4018>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4800>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4005>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4311>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4068>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4267>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4244>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4200>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4305>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4067>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4146>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4309>
|
||||
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4805>
|
||||
${VS_OPTIONS})
|
||||
|
||||
string(REPLACE "/GR " "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE " /EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
add_compile_options(
|
||||
# Disable exceptions
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/EHsc->
|
||||
|
||||
# Disable RTTI
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/GR->
|
||||
|
||||
# Enforce various standards compliant behavior.
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/permissive->
|
||||
|
||||
# Enable standard volatile semantics.
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/volatile:iso>
|
||||
|
||||
# Reports the proper value for the __cplusplus preprocessor macro.
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/Zc:__cplusplus>
|
||||
|
||||
# Use latest C++ standard.
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/std:c++latest>
|
||||
)
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
# Flags for MSVC (not clang-cl)
|
||||
add_compile_options(
|
||||
# Allow constexpr variables to have explicit external linkage.
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/Zc:externConstexpr>
|
||||
|
||||
# Assume that new throws exceptions, allowing better code generation.
|
||||
$<$<COMPILE_LANGUAGE:CXX>:/Zc:throwingNew>
|
||||
|
||||
# Link-time Code Generation for Release builds
|
||||
$<$<CONFIG:Release>:/GL>
|
||||
)
|
||||
|
||||
# Link-time Code Generation for Release builds
|
||||
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "/LTCG")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup")
|
||||
endif ()
|
||||
else ()
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
endif ()
|
||||
|
||||
################
|
||||
# Athena Build #
|
||||
@@ -39,7 +156,7 @@ add_library(athena-core
|
||||
src/LZ77/LZBase.cpp
|
||||
src/athena/FileInfo.cpp
|
||||
src/athena/Dir.cpp
|
||||
src/athena/DNAYaml.cpp
|
||||
src/sha1.cpp
|
||||
|
||||
include/athena/IStream.hpp
|
||||
include/athena/IStreamReader.hpp
|
||||
@@ -62,14 +179,12 @@ add_library(athena-core
|
||||
include/LZ77/LZType11.hpp
|
||||
include/athena/FileInfo.hpp
|
||||
include/athena/Dir.hpp
|
||||
include/athena/DNA.hpp
|
||||
include/athena/DNAYaml.hpp
|
||||
include/athena/DNAOp.hpp
|
||||
include/athena/YAMLCommon.hpp
|
||||
include/athena/YAMLDocReader.hpp
|
||||
include/athena/YAMLDocWriter.hpp
|
||||
include/yaml.h
|
||||
include/utf8proc.h
|
||||
include/athena/yaml.h
|
||||
include/athena/utf8proc.h
|
||||
include/sha1.h
|
||||
)
|
||||
if(WIN32)
|
||||
target_sources(athena-core PRIVATE
|
||||
@@ -97,7 +212,7 @@ else()
|
||||
if(GEKKO OR NX)
|
||||
target_sources(athena-core PRIVATE
|
||||
src/gekko_support.c
|
||||
include/gekko_support.h
|
||||
include/athena/gekko_support.h
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
@@ -105,11 +220,10 @@ endif()
|
||||
|
||||
target_include_directories(athena-core PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<BUILD_INTERFACE:${ZLIB_INCLUDE_DIR}>
|
||||
)
|
||||
target_link_libraries(athena-core PUBLIC
|
||||
athena-libyaml
|
||||
fmt
|
||||
$<BUILD_INTERFACE:${ZLIB_LIBRARIES}>
|
||||
)
|
||||
|
||||
add_library(athena-sakura EXCLUDE_FROM_ALL
|
||||
@@ -128,6 +242,9 @@ add_library(athena-sakura EXCLUDE_FROM_ALL
|
||||
include/athena/SpriteFrame.hpp
|
||||
include/athena/SpritePart.hpp
|
||||
)
|
||||
target_include_directories(athena-sakura PUBLIC
|
||||
include
|
||||
)
|
||||
|
||||
add_library(athena-wiisave EXCLUDE_FROM_ALL
|
||||
src/athena/WiiBanner.cpp
|
||||
@@ -139,7 +256,6 @@ add_library(athena-wiisave EXCLUDE_FROM_ALL
|
||||
src/bn.cpp
|
||||
src/ec.cpp
|
||||
src/md5.cpp
|
||||
src/sha1.cpp
|
||||
src/aes.cpp
|
||||
|
||||
include/athena/WiiBanner.hpp
|
||||
@@ -152,7 +268,9 @@ add_library(athena-wiisave EXCLUDE_FROM_ALL
|
||||
include/bn.hpp
|
||||
include/ec.hpp
|
||||
include/md5.h
|
||||
include/sha1.h
|
||||
)
|
||||
target_include_directories(athena-wiisave PUBLIC
|
||||
include
|
||||
)
|
||||
if(NOT MSVC AND ${CMAKE_SYSTEM_PROCESSOR} STREQUAL x86_64)
|
||||
set_source_files_properties(src/aes.cpp PROPERTIES COMPILE_FLAGS -maes)
|
||||
@@ -193,18 +311,16 @@ add_library(athena-zelda EXCLUDE_FROM_ALL
|
||||
include/athena/ZQuestFileReader.hpp
|
||||
include/athena/ZQuestFileWriter.hpp
|
||||
)
|
||||
|
||||
target_include_directories(athena-zelda PUBLIC
|
||||
include
|
||||
)
|
||||
# Icon
|
||||
set(ATHENA_ICO ${CMAKE_CURRENT_SOURCE_DIR}/Athena.ico)
|
||||
|
||||
# Offer the user the choice of overriding the installation directories
|
||||
set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
|
||||
set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
set(INSTALL_CMAKE_DIR cmake)
|
||||
else()
|
||||
set(INSTALL_CMAKE_DIR lib/cmake/athena)
|
||||
endif()
|
||||
set(INSTALL_CMAKE_DIR lib/cmake/athena)
|
||||
|
||||
# Make relative paths absolute (needed later on)
|
||||
foreach(p LIB INCLUDE CMAKE)
|
||||
@@ -217,10 +333,10 @@ foreach(p LIB INCLUDE CMAKE)
|
||||
endforeach()
|
||||
|
||||
# Define installs
|
||||
install(DIRECTORY include DESTINATION ${INSTALL_INCLUDE_DIR}/athena COMPONENT athena)
|
||||
install(DIRECTORY extern/fmt/include DESTINATION ${INSTALL_INCLUDE_DIR}/fmt COMPONENT athena)
|
||||
install(TARGETS athena-core fmt
|
||||
DESTINATION ${INSTALL_LIB_DIR} EXPORT AthenaTargets COMPONENT athena)
|
||||
install(DIRECTORY include/athena DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT athena)
|
||||
if (ATHENA_ZLIB)
|
||||
set(ZLIB_INSTALL ${ZLIB_LIBRARIES})
|
||||
endif ()
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
install(FILES Athena.ico DESTINATION ${INSTALL_LIB_DIR} COMPONENT athena)
|
||||
elseif(UNIX)
|
||||
@@ -234,9 +350,6 @@ endif()
|
||||
# Package Export #
|
||||
##################
|
||||
|
||||
# Add all targets to the build-tree export set
|
||||
export(TARGETS athena-core athena-libyaml fmt FILE "${CMAKE_CURRENT_BINARY_DIR}/AthenaTargets.cmake")
|
||||
|
||||
# Export the package for use from the build-tree
|
||||
# (this registers the build-tree with a global CMake-registry)
|
||||
export(PACKAGE athena)
|
||||
@@ -264,48 +377,43 @@ install(FILES
|
||||
# Install the export set for use with the install-tree
|
||||
install(EXPORT AthenaTargets DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT athena)
|
||||
|
||||
################
|
||||
# atdna import #
|
||||
################
|
||||
|
||||
add_subdirectory(atdna)
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
# Test target
|
||||
add_executable(atdna-test atdna/test.cpp atdna/test.hpp)
|
||||
target_atdna(atdna-test atdna_test.cpp atdna/test.hpp)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Switch")
|
||||
set_target_properties(atdna-test PROPERTIES SUFFIX ".elf")
|
||||
target_link_libraries(atdna-test athena-core nx)
|
||||
else()
|
||||
target_link_libraries(atdna-test athena-core)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#########
|
||||
# CPack #
|
||||
#########
|
||||
|
||||
include(InstallRequiredSystemLibraries)
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Athena")
|
||||
set(CPACK_PACKAGE_VENDOR "Antidote / Jackoalan")
|
||||
set(CPACK_PACKAGE_VENDOR "AxioDL Team")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${ATHENA_MAJOR_VERSION})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${ATHENA_MINOR_VERSION})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${ATHENA_PATCH_VERSION})
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "athena")
|
||||
if(WIN32 AND NOT UNIX)
|
||||
# There is a bug in NSI that does not handle full unix paths properly. Make
|
||||
# sure there is at least one set of four (4) backlasshes.
|
||||
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "athena")
|
||||
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\AthenaNSIS.bmp")
|
||||
set(CPACK_NSIS_MODIFY_PATH ON)
|
||||
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\Athena.ico")
|
||||
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\Athena.ico")
|
||||
set(CPACK_NSIS_INSTALLED_ICON_NAME "Uninstall.exe")
|
||||
set(CPACK_NSIS_DISPLAY_NAME "Athena")
|
||||
set(CPACK_NSIS_URL_INFO_ABOUT "http://libathena.github.io")
|
||||
set(CPACK_NSIS_CONTACT "antidote.crk@gmail.com")
|
||||
endif()
|
||||
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
|
||||
|
||||
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ARCHITECTURE_NAME)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL Windows)
|
||||
set(SYSTEM_NAME win32)
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
|
||||
set(SYSTEM_NAME macos)
|
||||
list(LENGTH CMAKE_OSX_ARCHITECTURES num_archs)
|
||||
if (num_archs GREATER 1)
|
||||
set(ARCHITECTURE_NAME universal)
|
||||
elseif(num_archs EQUAL 1)
|
||||
set(ARCHITECTURE_NAME ${CMAKE_OSX_ARCHITECTURES})
|
||||
endif()
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL Linux)
|
||||
set(SYSTEM_NAME linux)
|
||||
else ()
|
||||
set(SYSTEM_NAME "${CMAKE_SYSTEM_NAME}")
|
||||
endif ()
|
||||
set(CPACK_PACKAGE_FILE_NAME "athena-${SYSTEM_NAME}-${ARCHITECTURE_NAME}")
|
||||
|
||||
if (WIN32)
|
||||
set(CPACK_GENERATOR 7Z)
|
||||
else ()
|
||||
set(CPACK_GENERATOR TGZ)
|
||||
endif ()
|
||||
include(CPack)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# PKGBUILD for libAthena
|
||||
_pkgname=libathena
|
||||
pkgname=$_pkgname-git
|
||||
pkgver=@ATHENA_VERSION@
|
||||
pkgver=@ATHENA_VERSION_STRING@
|
||||
pkgrel=1
|
||||
pkgdesc="Basic cross platform IO library"
|
||||
arch=('i686' 'x86_64')
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
###############
|
||||
# ATDNA Build #
|
||||
###############
|
||||
|
||||
if(NOT CMAKE_CROSSCOMPILING)
|
||||
|
||||
string(REPLACE -stdlib=libc++ "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
get_directory_property(ATDNA_DEFINES COMPILE_DEFINITIONS)
|
||||
list(REMOVE_ITEM ATDNA_DEFINES _GLIBCXX_DEBUG=1)
|
||||
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${ATDNA_DEFINES}")
|
||||
|
||||
# Find dependencies
|
||||
include(FindLLVM.cmake)
|
||||
if(NOT LLVM_FOUND)
|
||||
message(STATUS "Unable to locate LLVM installation; skipping atdna")
|
||||
else()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
option(ATDNA_DYNAMIC_LLVM "Use dynamic library targets when linking LLVM" ON)
|
||||
else()
|
||||
option(ATDNA_DYNAMIC_LLVM "Use dynamic library targets when linking LLVM" OFF)
|
||||
endif()
|
||||
|
||||
if(ATDNA_DYNAMIC_LLVM)
|
||||
find_library(CLANGCPP_LIB clang-cpp HINTS "${LLVM_ROOT_DIR}/lib")
|
||||
if (NOT CLANGCPP_LIB)
|
||||
list(APPEND LLVM_LIBS
|
||||
clangFrontend
|
||||
clangTooling
|
||||
clangDriver
|
||||
clangSerialization
|
||||
clangParse
|
||||
clangSema
|
||||
clangAnalysis
|
||||
clangEdit
|
||||
clangAST
|
||||
clangLex
|
||||
clangBasic
|
||||
LLVM)
|
||||
else()
|
||||
list(APPEND LLVM_LIBS
|
||||
clang-cpp
|
||||
LLVM)
|
||||
endif()
|
||||
else()
|
||||
find_library(LLVMDEMANGLE_LIB LLVMDemangle HINTS "${LLVM_ROOT_DIR}/lib")
|
||||
find_library(LLVMBINARYFORMAT_LIB LLVMBinaryFormat HINTS "${LLVM_ROOT_DIR}/lib")
|
||||
if (NOT LLVMDEMANGLE_LIB)
|
||||
set(LLVMDEMANGLE_LIB "")
|
||||
endif()
|
||||
if (NOT LLVMBINARYFORMAT_LIB)
|
||||
set(LLVMBINARYFORMAT_LIB "")
|
||||
endif()
|
||||
find_library(CLANG_CPP_LIB clang-cpp HINTS "${LLVM_ROOT_DIR}/lib")
|
||||
if (NOT CLANG_CPP_LIB)
|
||||
list(APPEND CLANG_LIBS
|
||||
clangFrontend
|
||||
clangTooling
|
||||
clangDriver
|
||||
clangSerialization
|
||||
clangParse
|
||||
clangSema
|
||||
clangAnalysis
|
||||
clangEdit
|
||||
clangAST
|
||||
clangLex
|
||||
clangBasic)
|
||||
else()
|
||||
list(APPEND CLANG_LIBS
|
||||
clang-cpp)
|
||||
endif()
|
||||
|
||||
list(APPEND LLVM_LIBS
|
||||
${CLANG_LIBS}
|
||||
LLVMCore
|
||||
LLVMOption
|
||||
LLVMMCParser
|
||||
LLVMBitReader
|
||||
${LLVMBINARYFORMAT_LIB}
|
||||
LLVMMC
|
||||
LLVMProfileData
|
||||
LLVMSupport
|
||||
LLVMRemarks
|
||||
LLVMBitStreamReader
|
||||
${LLVMDEMANGLE_LIB}
|
||||
LLVMFrontendOpenMP)
|
||||
endif()
|
||||
|
||||
string(FIND ${LLVM_VERSION_STRING} "svn" SVN_FILTER_IDX)
|
||||
if(NOT SVN_FILTER_IDX EQUAL -1)
|
||||
string(SUBSTRING ${LLVM_VERSION_STRING} 0 ${SVN_FILTER_IDX} LLVM_VERSION_BASE)
|
||||
else()
|
||||
set(LLVM_VERSION_BASE ${LLVM_VERSION_STRING})
|
||||
endif()
|
||||
|
||||
set(CLANG_INCLUDE_DIR ${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_BASE}/include
|
||||
CACHE PATH "Clang include dir" FORCE)
|
||||
|
||||
if(UNIX)
|
||||
list(APPEND PLAT_LIBS z pthread curses)
|
||||
if (APPLE)
|
||||
list(APPEND PLAT_LIBS dl)
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
list(APPEND PLAT_LIBS dl tinfo)
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
list(APPEND PLAT_LIBS Version)
|
||||
endif()
|
||||
|
||||
# Offer the user the choice of overriding the installation directories
|
||||
set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
|
||||
set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
set(INSTALL_CMAKE_DIR cmake)
|
||||
else()
|
||||
set(INSTALL_CMAKE_DIR lib/cmake/atdna)
|
||||
endif()
|
||||
|
||||
# Make relative paths absolute (needed later on)
|
||||
foreach(p BIN INCLUDE CMAKE)
|
||||
set(var INSTALL_${p}_DIR)
|
||||
if(NOT IS_ABSOLUTE "${${var}}")
|
||||
set(ABS_${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
|
||||
else()
|
||||
set(ABS_${var} "${${var}}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Windows resource
|
||||
if(WIN32)
|
||||
configure_file(main.rc.in main.rc @ONLY)
|
||||
set(PLAT_SRCS ${CMAKE_CURRENT_BINARY_DIR}/main.rc)
|
||||
endif()
|
||||
|
||||
# ATDNA target
|
||||
add_executable(atdna main.cpp test.hpp ${PLAT_SRCS})
|
||||
target_link_libraries(atdna ${LLVM_LIBS} ${PLAT_LIBS})
|
||||
target_compile_definitions(atdna PRIVATE
|
||||
INSTALL_PREFIX=${ABS_INSTALL_BIN_DIR}
|
||||
__STDC_LIMIT_MACROS=1
|
||||
__STDC_CONSTANT_MACROS=1
|
||||
ATDNA_ARGV0=${LLVM_ROOT_DIR}/bin/clang-tool)
|
||||
target_include_directories(atdna PRIVATE ${LLVM_INCLUDE_DIRS})
|
||||
target_link_directories(atdna PRIVATE ${LLVM_LIBRARY_DIRS})
|
||||
# Clang 10.0.x headers currently broken with C++20
|
||||
set_property(TARGET atdna PROPERTY CXX_STANDARD 17)
|
||||
if(MSVC)
|
||||
# Allow linking against release-built LLVM libraries
|
||||
target_compile_options(atdna PRIVATE /GR- /D_ITERATOR_DEBUG_LEVEL=0)
|
||||
set_property(TARGET atdna PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
|
||||
else()
|
||||
target_compile_options(atdna PRIVATE -fno-rtti -Wno-error)
|
||||
endif()
|
||||
|
||||
# Define installs
|
||||
install(TARGETS atdna DESTINATION ${INSTALL_BIN_DIR} EXPORT atdnaTargets COMPONENT atdna)
|
||||
install(DIRECTORY ${CLANG_INCLUDE_DIR}/ DESTINATION ${INSTALL_INCLUDE_DIR}/athena/clang COMPONENT atdna)
|
||||
|
||||
##################
|
||||
# Package Export #
|
||||
##################
|
||||
|
||||
# Add all targets to the build-tree export set
|
||||
export(TARGETS atdna FILE "${CMAKE_CURRENT_BINARY_DIR}/atdnaTargets.cmake")
|
||||
|
||||
# Export the package for use from the build-tree
|
||||
# (this registers the build-tree with a global CMake-registry)
|
||||
export(PACKAGE atdna)
|
||||
|
||||
# Create the atdnaConfig.cmake
|
||||
# ... for the build tree
|
||||
configure_file(atdnaConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/atdnaConfig.cmake" @ONLY)
|
||||
# ... for the install tree
|
||||
configure_file(atdnaConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/atdnaConfig.cmake" @ONLY)
|
||||
# ... for both
|
||||
configure_file(atdnaConfigVersion.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/atdnaConfigVersion.cmake" @ONLY)
|
||||
|
||||
# Install atdnaConfig.cmake
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/atdnaConfig.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/atdnaConfigVersion.cmake"
|
||||
DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT atdna)
|
||||
|
||||
# Install the export set for use with the install-tree
|
||||
install(EXPORT atdnaTargets DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT atdna)
|
||||
|
||||
#########
|
||||
# CTest #
|
||||
#########
|
||||
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
enable_testing()
|
||||
add_test(NAME test-dna COMMAND $<TARGET_FILE:atdna> -o test.cpp
|
||||
"-I${ATHENA_INCLUDE_DIR}" ${CMAKE_SOURCE_DIR}/test.hpp)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
include(atdnaHelpers.cmake)
|
||||
|
||||
endif()
|
||||
@@ -1,216 +0,0 @@
|
||||
# - Find LLVM headers and libraries.
|
||||
# This module locates LLVM and adapts the llvm-config output for use with
|
||||
# CMake.
|
||||
#
|
||||
# A given list of COMPONENTS is passed to llvm-config.
|
||||
#
|
||||
# The following variables are defined:
|
||||
# LLVM_FOUND - true if LLVM was found
|
||||
# LLVM_CXXFLAGS - C++ compiler flags for files that include LLVM headers.
|
||||
# LLVM_HOST_TARGET - Target triple used to configure LLVM.
|
||||
# LLVM_INCLUDE_DIRS - Directory containing LLVM include files.
|
||||
# LLVM_LDFLAGS - Linker flags to add when linking against LLVM
|
||||
# (includes -LLLVM_LIBRARY_DIRS).
|
||||
# LLVM_LIBRARIES - Full paths to the library files to link against.
|
||||
# LLVM_LIBRARY_DIRS - Directory containing LLVM libraries.
|
||||
# LLVM_ROOT_DIR - The root directory of the LLVM installation.
|
||||
# llvm-config is searched for in ${LLVM_ROOT_DIR}/bin.
|
||||
# LLVM_VERSION_MAJOR - Major version of LLVM.
|
||||
# LLVM_VERSION_MINOR - Minor version of LLVM.
|
||||
# LLVM_VERSION_STRING - Full LLVM version string (e.g. 2.9).
|
||||
#
|
||||
# Note: The variable names were chosen in conformance with the offical CMake
|
||||
# guidelines, see ${CMAKE_ROOT}/Modules/readme.txt.
|
||||
|
||||
# Try suffixed versions to pick up the newest LLVM install available on Debian
|
||||
# derivatives.
|
||||
# We also want an user-specified LLVM_ROOT_DIR to take precedence over the
|
||||
# system default locations such as /usr/local/bin. Executing find_program()
|
||||
# multiples times is the approach recommended in the docs.
|
||||
set(LLVM_ROOT_DIR "" CACHE PATH "Location of LLVM development root")
|
||||
set(LLVM_FIND_COMPONENTS "")
|
||||
if(WIN32)
|
||||
get_filename_component(LLVM_ROOT_DIR [HKEY_LOCAL_MACHINE\\Software\\LLVM\\LLVM] ABSOLUTE)
|
||||
endif()
|
||||
|
||||
set(llvm_config_names llvm-config-3.9 llvm-config39
|
||||
llvm-config-3.8 llvm-config38
|
||||
llvm-config-3.7 llvm-config37
|
||||
llvm-config-3.6 llvm-config36
|
||||
llvm-config-3.5 llvm-config35
|
||||
llvm-config-3.4 llvm-config34
|
||||
llvm-config-3.3 llvm-config33
|
||||
llvm-config-3.2 llvm-config32
|
||||
llvm-config-3.1 llvm-config31 llvm-config)
|
||||
if(APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
|
||||
set(LLVM_HOMEBREW_PATH /usr/local/opt/llvm/bin)
|
||||
elseif(APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
|
||||
set(LLVM_HOMEBREW_PATH /opt/homebrew/opt/llvm/bin)
|
||||
else()
|
||||
set(LLVM_HOMEBREW_PATH "")
|
||||
endif()
|
||||
find_program(LLVM_CONFIG
|
||||
NAMES ${llvm_config_names}
|
||||
PATHS ${LLVM_ROOT_DIR}/bin ${LLVM_HOMEBREW_PATH} NO_DEFAULT_PATH
|
||||
DOC "Path to llvm-config tool.")
|
||||
find_program(LLVM_CONFIG NAMES ${llvm_config_names})
|
||||
|
||||
if ((WIN32 AND NOT(MINGW OR CYGWIN)) OR NOT LLVM_CONFIG)
|
||||
if (WIN32)
|
||||
# A bit of a sanity check:
|
||||
if( NOT EXISTS ${LLVM_ROOT_DIR}/include/llvm )
|
||||
message(FATAL_ERROR "LLVM_ROOT_DIR (${LLVM_ROOT_DIR}) is not a valid LLVM install")
|
||||
endif()
|
||||
# We incorporate the CMake features provided by LLVM:
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
|
||||
"${LLVM_ROOT_DIR}/share/llvm/cmake"
|
||||
"${LLVM_ROOT_DIR}/lib/cmake/llvm")
|
||||
include(LLVMConfig)
|
||||
# Set properties
|
||||
set(LLVM_HOST_TARGET ${TARGET_TRIPLE})
|
||||
set(LLVM_VERSION_STRING ${LLVM_PACKAGE_VERSION})
|
||||
set(LLVM_CXXFLAGS ${LLVM_DEFINITIONS})
|
||||
set(LLVM_LDFLAGS "")
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "all-targets" index)
|
||||
list(APPEND LLVM_FIND_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
|
||||
# Work around LLVM bug 21016
|
||||
list(FIND LLVM_TARGETS_TO_BUILD "X86" TARGET_X86)
|
||||
if(TARGET_X86 GREATER -1)
|
||||
list(APPEND LLVM_FIND_COMPONENTS x86utils)
|
||||
endif()
|
||||
# Similar to the work around above, but for AArch64
|
||||
list(FIND LLVM_TARGETS_TO_BUILD "AArch64" TARGET_AArch64)
|
||||
if(TARGET_AArch64 GREATER -1)
|
||||
list(APPEND LLVM_FIND_COMPONENTS AArch64Utils)
|
||||
endif()
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "backend" index)
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-2][\\.0-9A-Za-z]*")
|
||||
# Versions below 3.3 do not support components objcarcopts, option
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "objcarcopts" index)
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "option" index)
|
||||
endif()
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-4][\\.0-9A-Za-z]*")
|
||||
# Versions below 3.5 do not support components lto, profiledata
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "lto" index)
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "profiledata" index)
|
||||
endif()
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-6][\\.0-9A-Za-z]*")
|
||||
# Versions below 3.7 do not support components debuginfodwarf
|
||||
# Only debuginfo is available
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "debuginfodwarf" index)
|
||||
list(APPEND LLVM_FIND_COMPONENTS "debuginfo")
|
||||
endif()
|
||||
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-4][\\.0-9A-Za-z]*")
|
||||
llvm_map_components_to_libraries(tmplibs ${LLVM_FIND_COMPONENTS})
|
||||
else()
|
||||
llvm_map_components_to_libnames(tmplibs ${LLVM_FIND_COMPONENTS})
|
||||
endif()
|
||||
if(MSVC)
|
||||
foreach(lib ${tmplibs})
|
||||
list(APPEND LLVM_LIBRARIES "${LLVM_LIBRARY_DIRS}/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
endforeach()
|
||||
else()
|
||||
# Rely on the library search path being set correctly via -L on
|
||||
# MinGW and others, as the library list returned by
|
||||
# llvm_map_components_to_libraries also includes imagehlp and psapi.
|
||||
set(LLVM_LDFLAGS "-L${LLVM_LIBRARY_DIRS}")
|
||||
set(LLVM_LIBRARIES ${tmplibs})
|
||||
endif()
|
||||
|
||||
# When using the CMake LLVM module, LLVM_DEFINITIONS is a list
|
||||
# instead of a string. Later, the list seperators would entirely
|
||||
# disappear, replace them by spaces instead. A better fix would be
|
||||
# to switch to add_definitions() instead of throwing strings around.
|
||||
string(REPLACE ";" " " LLVM_CXXFLAGS "${LLVM_CXXFLAGS}")
|
||||
else()
|
||||
if (NOT FIND_LLVM_QUIETLY)
|
||||
message(WARNING "Could not find llvm-config. Try manually setting LLVM_ROOT_DIR to the prebuilt LLVM prefix to use.")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
macro(llvm_set var flag)
|
||||
if(LLVM_FIND_QUIETLY)
|
||||
set(_quiet_arg ERROR_QUIET)
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG} --${flag}
|
||||
OUTPUT_VARIABLE LLVM_${var}
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
${_quiet_arg}
|
||||
)
|
||||
if(${ARGV2})
|
||||
file(TO_CMAKE_PATH "${LLVM_${var}}" LLVM_${var})
|
||||
endif()
|
||||
endmacro()
|
||||
macro(llvm_set_libs var flag prefix)
|
||||
if(LLVM_FIND_QUIETLY)
|
||||
set(_quiet_arg ERROR_QUIET)
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND ${LLVM_CONFIG} --${flag} ${LLVM_FIND_COMPONENTS}
|
||||
OUTPUT_VARIABLE tmplibs
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
${_quiet_arg}
|
||||
)
|
||||
file(TO_CMAKE_PATH "${tmplibs}" tmplibs)
|
||||
string(REGEX REPLACE "([$^.[|*+?()]|])" "\\\\\\1" pattern "${prefix}/")
|
||||
string(REGEX MATCHALL "${pattern}[^ ]+" "LLVM_${var}" "${tmplibs}")
|
||||
endmacro()
|
||||
|
||||
llvm_set(VERSION_STRING version)
|
||||
llvm_set(CXXFLAGS cxxflags)
|
||||
llvm_set(HOST_TARGET host-target)
|
||||
llvm_set(INCLUDE_DIRS includedir true)
|
||||
llvm_set(ROOT_DIR prefix true)
|
||||
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-2][\\.0-9A-Za-z]*")
|
||||
# Versions below 3.3 do not support components objcarcopts, option
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "objcarcopts" index)
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "option" index)
|
||||
endif()
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-4][\\.0-9A-Za-z]*")
|
||||
# Versions below 3.5 do not support components lto, profiledata
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "lto" index)
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "profiledata" index)
|
||||
endif()
|
||||
if(${LLVM_VERSION_STRING} MATCHES "^3\\.[0-6][\\.0-9A-Za-z]*")
|
||||
# Versions below 3.7 do not support components debuginfodwarf
|
||||
# Only debuginfo is available
|
||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "debuginfodwarf" index)
|
||||
list(APPEND LLVM_FIND_COMPONENTS "debuginfo")
|
||||
endif()
|
||||
|
||||
llvm_set(LDFLAGS ldflags)
|
||||
if(NOT ${LLVM_VERSION_STRING} MATCHES "^3\\.[0-4][\\.0-9A-Za-z]*")
|
||||
# In LLVM 3.5+, the system library dependencies (e.g. "-lz") are accessed
|
||||
# using the separate "--system-libs" flag.
|
||||
llvm_set(SYSTEM_LIBS system-libs)
|
||||
string(REPLACE "\n" " " LLVM_LDFLAGS "${LLVM_LDFLAGS} ${LLVM_SYSTEM_LIBS}")
|
||||
endif()
|
||||
llvm_set(LIBRARY_DIRS libdir true)
|
||||
llvm_set_libs(LIBRARIES libfiles "${LLVM_LIBRARY_DIRS}")
|
||||
endif()
|
||||
|
||||
# On CMake builds of LLVM, the output of llvm-config --cxxflags does not
|
||||
# include -fno-rtti, leading to linker errors. Be sure to add it.
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))
|
||||
if(NOT ${LLVM_CXXFLAGS} MATCHES "-fno-rtti")
|
||||
set(LLVM_CXXFLAGS "${LLVM_CXXFLAGS} -fno-rtti")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
string(REGEX REPLACE "([0-9]+).*" "\\1" LLVM_VERSION_MAJOR "${LLVM_VERSION_STRING}" )
|
||||
string(REGEX REPLACE "[0-9]+\\.([0-9]+).*[A-Za-z]*" "\\1" LLVM_VERSION_MINOR "${LLVM_VERSION_STRING}" )
|
||||
|
||||
# Use the default CMake facilities for handling QUIET/REQUIRED.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if(${CMAKE_VERSION} VERSION_LESS "2.8.4")
|
||||
# The VERSION_VAR argument is not supported on pre-2.8.4, work around this.
|
||||
set(VERSION_VAR dummy)
|
||||
endif()
|
||||
|
||||
find_package_handle_standard_args(LLVM
|
||||
REQUIRED_VARS LLVM_ROOT_DIR LLVM_HOST_TARGET
|
||||
VERSION_VAR LLVM_VERSION_STRING)
|
||||
@@ -1,3 +0,0 @@
|
||||
# atdna
|
||||
[User Overview](http://libAthena.github.io/doc/atdna.html)
|
||||
[DNA Record Reference](http://libAthena.github.io/doc/atdna-ref.html)
|
||||
@@ -1,84 +0,0 @@
|
||||
# - Config file for the atdna package
|
||||
|
||||
# Compute paths
|
||||
get_filename_component(ATDNA_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
|
||||
# Our library dependencies (contains definitions for IMPORTED targets)
|
||||
if(NOT TARGET atdna AND NOT atdna_BINARY_DIR)
|
||||
include("${ATDNA_CMAKE_DIR}/atdnaTargets.cmake")
|
||||
endif()
|
||||
|
||||
# Super handy macro for adding atdna target
|
||||
function(atdna out)
|
||||
# Ninja wants invocations in root binary dir for DEPFILE application
|
||||
file(RELATIVE_PATH out_rel ${CMAKE_BINARY_DIR} "${CMAKE_CURRENT_BINARY_DIR}/${out}")
|
||||
|
||||
# Make input files source-relative
|
||||
set(ins "")
|
||||
set(ins_impdeps "")
|
||||
foreach(arg ${ARGN})
|
||||
list(APPEND ins ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
|
||||
list(APPEND ins_impdeps CXX)
|
||||
list(APPEND ins_impdeps ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
|
||||
endforeach()
|
||||
|
||||
# Get local include directories for atdna
|
||||
get_property(incdirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
|
||||
set(inccli "")
|
||||
foreach(dir ${incdirs})
|
||||
list(APPEND inccli "-I${dir}")
|
||||
endforeach()
|
||||
|
||||
# Get local defines for atdna
|
||||
get_property(cdefs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS)
|
||||
set(cdefcli "")
|
||||
foreach(def ${cdefs})
|
||||
list(APPEND cdefcli "-D${def}")
|
||||
endforeach()
|
||||
|
||||
# MS extra
|
||||
unset(extraargs)
|
||||
if(MSVC)
|
||||
list(APPEND extraargs -fms-compatibility -fexceptions)
|
||||
if(MSVC_VERSION EQUAL 1800)
|
||||
list(APPEND extraargs -fms-compatibility-version=18.00)
|
||||
elseif(MSVC_VERSION EQUAL 1900)
|
||||
list(APPEND extraargs -fms-compatibility-version=19.00)
|
||||
elseif(MSVC_VERSION EQUAL 1910)
|
||||
list(APPEND extraargs -fms-compatibility-version=19.10)
|
||||
elseif(MSVC_VERSION EQUAL 1911)
|
||||
list(APPEND extraargs -fms-compatibility-version=19.11)
|
||||
endif()
|
||||
|
||||
# OSX Extra
|
||||
elseif(APPLE)
|
||||
get_filename_component(COMPILER_DIR "${CMAKE_CXX_COMPILER}" DIRECTORY)
|
||||
if (NOT EXISTS "${CMAKE_OSX_SYSROOT}")
|
||||
message(FATAL_ERROR "CMAKE_OSX_SYSROOT not set")
|
||||
endif()
|
||||
list(APPEND extraargs
|
||||
-isysroot ${CMAKE_OSX_SYSROOT}
|
||||
-stdlib++-isystem "${COMPILER_DIR}/../include/c++/v1")
|
||||
endif()
|
||||
|
||||
# Make target
|
||||
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
|
||||
# Use Ninja's DEPFILE parser in cooperation with atdna
|
||||
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
|
||||
ARGS ${extraargs} -o ${out_rel} -MD -MT ${out_rel} -MF ${out_rel}.d ${cdefcli} ${inccli}
|
||||
"-I${ATHENA_INCLUDE_DIR}" ${ins}
|
||||
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
|
||||
DEPFILE "${CMAKE_CURRENT_BINARY_DIR}/${out}.d"
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Generating DNA ${out_rel}")
|
||||
else()
|
||||
# Use CMake's built-in dependency scanner for makefile targets
|
||||
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
|
||||
ARGS ${extraargs} -o ${out_rel} ${cdefcli} ${inccli}
|
||||
"-I${ATHENA_INCLUDE_DIR}" ${ins}
|
||||
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Generating DNA ${out_rel}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
set(PACKAGE_VERSION "@ATHENA_VERSION@")
|
||||
|
||||
# Check whether the requested PACKAGE_FIND_VERSION is compatible
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
#
|
||||
# gather_include_directories recursively builds a list of include directories
|
||||
# across all dependencies.
|
||||
#
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.20")
|
||||
# Don't transform add_custom_command DEPFILE for Ninja
|
||||
cmake_policy(SET CMP0116 OLD)
|
||||
endif ()
|
||||
|
||||
function(_atdna_gather_include_directories_impl target_name)
|
||||
get_target_property(target_dependencies ${target_name} INTERFACE_LINK_LIBRARIES)
|
||||
foreach(dep ${target_dependencies})
|
||||
if(TARGET ${dep})
|
||||
get_target_property(dep_includes ${dep} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if(dep_includes)
|
||||
list(APPEND target_includes ${dep_includes})
|
||||
endif()
|
||||
_atdna_gather_include_directories_impl(${dep})
|
||||
endif()
|
||||
endforeach()
|
||||
set(target_includes ${target_includes} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(atdna_gather_include_directories var target_name)
|
||||
unset(target_includes)
|
||||
get_directory_property(dir_includes INCLUDE_DIRECTORIES)
|
||||
if(dir_includes)
|
||||
list(APPEND target_includes ${dir_includes})
|
||||
endif()
|
||||
get_target_property(target_includes1 ${target_name} INCLUDE_DIRECTORIES)
|
||||
if(target_includes1)
|
||||
list(APPEND target_includes ${target_includes1})
|
||||
endif()
|
||||
get_target_property(target_includes2 ${target_name} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if(target_includes2)
|
||||
list(APPEND target_includes ${target_includes2})
|
||||
endif()
|
||||
_atdna_gather_include_directories_impl(${target_name})
|
||||
list(REMOVE_DUPLICATES target_includes)
|
||||
set(${var} ${target_includes} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(_atdna_gather_compile_definitions_impl target_name)
|
||||
get_target_property(target_dependencies ${target_name} INTERFACE_LINK_LIBRARIES)
|
||||
foreach(dep ${target_dependencies})
|
||||
if(TARGET ${dep})
|
||||
get_target_property(dep_defines ${dep} INTERFACE_COMPILE_DEFINITIONS)
|
||||
if(dep_defines)
|
||||
list(APPEND target_defines ${dep_defines})
|
||||
endif()
|
||||
_atdna_gather_compile_definitions_impl(${dep})
|
||||
endif()
|
||||
endforeach()
|
||||
set(target_defines ${target_defines} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(atdna_gather_compile_definitions var target_name)
|
||||
unset(target_defines)
|
||||
get_directory_property(dir_defines COMPILE_DEFINITIONS)
|
||||
if(dir_defines)
|
||||
list(APPEND target_defines ${dir_defines})
|
||||
endif()
|
||||
get_target_property(target_defines1 ${target_name} COMPILE_DEFINITIONS)
|
||||
if(target_defines1)
|
||||
list(APPEND target_defines ${target_defines1})
|
||||
endif()
|
||||
get_target_property(target_defines2 ${target_name} INTERFACE_COMPILE_DEFINITIONS)
|
||||
if(target_defines2)
|
||||
list(APPEND target_defines ${target_defines2})
|
||||
endif()
|
||||
_atdna_gather_compile_definitions_impl(${target_name})
|
||||
list(REMOVE_DUPLICATES target_defines)
|
||||
set(${var} ${target_defines} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
#######################
|
||||
# In-tree atdna macro #
|
||||
#######################
|
||||
|
||||
# Super handy macro for adding atdna target
|
||||
function(atdna out incdirs cdefs)
|
||||
# Ninja wants invocations in root binary dir for DEPFILE application
|
||||
file(RELATIVE_PATH out_rel ${CMAKE_BINARY_DIR} "${CMAKE_CURRENT_BINARY_DIR}/${out}")
|
||||
|
||||
# Make input files source-relative
|
||||
unset(ins)
|
||||
unset(ins_impdeps)
|
||||
foreach(arg ${ARGN})
|
||||
list(APPEND ins ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
|
||||
list(APPEND ins_impdeps CXX)
|
||||
list(APPEND ins_impdeps ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
|
||||
endforeach()
|
||||
|
||||
# MS extra
|
||||
unset(extraargs)
|
||||
if(MSVC)
|
||||
list(APPEND extraargs -fms-compatibility -fexceptions)
|
||||
if(MSVC_VERSION EQUAL 1800)
|
||||
list(APPEND extraargs -fms-compatibility-version=18.00)
|
||||
elseif(MSVC_VERSION EQUAL 1900)
|
||||
list(APPEND extraargs -fms-compatibility-version=19.00)
|
||||
elseif(MSVC_VERSION EQUAL 1910)
|
||||
list(APPEND extraargs -fms-compatibility-version=19.10)
|
||||
elseif(MSVC_VERSION EQUAL 1911)
|
||||
list(APPEND extraargs -fms-compatibility-version=19.11)
|
||||
endif()
|
||||
|
||||
# OSX Extra
|
||||
elseif(APPLE)
|
||||
get_filename_component(COMPILER_DIR "${CMAKE_CXX_COMPILER}" DIRECTORY)
|
||||
if (NOT EXISTS "${CMAKE_OSX_SYSROOT}")
|
||||
message(FATAL_ERROR "CMAKE_OSX_SYSROOT not set")
|
||||
endif()
|
||||
list(APPEND extraargs
|
||||
-isysroot ${CMAKE_OSX_SYSROOT}
|
||||
-stdlib++-isystem "${COMPILER_DIR}/../include/c++/v1")
|
||||
endif()
|
||||
|
||||
# Make target
|
||||
if(${CMAKE_GENERATOR} STREQUAL "Ninja")
|
||||
# Use Ninja's DEPFILE parser in cooperation with atdna
|
||||
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
|
||||
ARGS ${extraargs} -o ${out_rel} -MD -MT ${out_rel} -MF ${out_rel}.d
|
||||
"$<$<BOOL:${incdirs}>:-I$<JOIN:${incdirs},;-I>>"
|
||||
"$<$<BOOL:${cdefs}>:-D$<JOIN:${cdefs},;-D>>"
|
||||
"-I${athena_SOURCE_DIR}/include" ${ins}
|
||||
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
|
||||
DEPFILE "${CMAKE_CURRENT_BINARY_DIR}/${out}.d"
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Generating DNA ${out_rel}"
|
||||
COMMAND_EXPAND_LISTS)
|
||||
else()
|
||||
# Use CMake's built-in dependency scanner for makefile targets
|
||||
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
|
||||
ARGS ${extraargs} -o ${out_rel}
|
||||
"$<$<BOOL:${incdirs}>:-I$<JOIN:${incdirs},;-I>>"
|
||||
"$<$<BOOL:${cdefs}>:-D$<JOIN:${cdefs},;-D>>"
|
||||
"-I${athena_SOURCE_DIR}/include" ${ins}
|
||||
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Generating DNA ${out_rel}"
|
||||
COMMAND_EXPAND_LISTS)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(target_atdna target out)
|
||||
atdna_gather_include_directories(include_list ${target})
|
||||
atdna_gather_compile_definitions(define_list ${target})
|
||||
atdna(${out} "${include_list}" "${define_list}" ${ARGN})
|
||||
target_sources(${target} PRIVATE ${out} ${ARGN})
|
||||
endfunction()
|
||||
1273
atdna/main.cpp
1273
atdna/main.cpp
File diff suppressed because it is too large
Load Diff
@@ -1,32 +0,0 @@
|
||||
#include "winver.h"
|
||||
|
||||
IDI_ICON1 ICON DISCARDABLE "@ATHENA_ICO@"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION @ATHENA_MAJOR_VERSION@,@ATHENA_MINOR_VERSION@,@ATHENA_PATCH_VERSION@,0
|
||||
PRODUCTVERSION @ATHENA_MAJOR_VERSION@,@ATHENA_MINOR_VERSION@,@ATHENA_PATCH_VERSION@,0
|
||||
FILEFLAGS 0x0L
|
||||
FILEFLAGSMASK 0x3fL
|
||||
FILEOS 0x00040004L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "000004b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Jackoalan / Antidote"
|
||||
VALUE "FileDescription", "ATDNA"
|
||||
VALUE "FileVersion", "@ATHENA_MAJOR_VERSION@.@ATHENA_MINOR_VERSION@.@ATHENA_PATCH_VERSION@"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2016 Jackoalan / Antidote"
|
||||
VALUE "InternalName", "atdna"
|
||||
VALUE "OriginalFilename", "atdna.exe"
|
||||
VALUE "ProductName", "ATDNA"
|
||||
VALUE "ProductVersion", "@ATHENA_MAJOR_VERSION@.@ATHENA_MINOR_VERSION@.@ATHENA_PATCH_VERSION@"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x0, 1200
|
||||
END
|
||||
END
|
||||
@@ -1,28 +0,0 @@
|
||||
#include "test.hpp"
|
||||
|
||||
#include <athena/MemoryWriter.hpp>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#define EXPECTED_BYTES 281
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
TESTFile<atUint32, 2> file = {};
|
||||
file.arrCount[0] = 2;
|
||||
file.array.push_back(42);
|
||||
file.array.push_back(64);
|
||||
size_t binSize = 0;
|
||||
file.binarySize(binSize);
|
||||
athena::io::MemoryCopyWriter w(nullptr, binSize);
|
||||
atInt64 pos = w.position();
|
||||
file.write(w);
|
||||
|
||||
const bool pass = !w.hasError() && w.position() - pos == binSize && binSize == EXPECTED_BYTES;
|
||||
if (pass) {
|
||||
fmt::print(FMT_STRING("[PASS] {} bytes written\n"), size_t(w.position() - pos));
|
||||
} else {
|
||||
fmt::print(FMT_STRING("[FAIL] {} bytes written; {} bytes sized; {} bytes expected\n"), size_t(w.position() - pos), binSize,
|
||||
EXPECTED_BYTES);
|
||||
}
|
||||
|
||||
return pass ? 0 : 1;
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
#include <athena/DNAYaml.hpp>
|
||||
|
||||
using namespace athena;
|
||||
typedef io::DNA<Endian::Big> BigDNA;
|
||||
|
||||
enum ETest : atUint8 { ZERO, ONE, TWO, THREE };
|
||||
|
||||
template <ETest EVal>
|
||||
struct AT_SPECIALIZE_PARMS(ETest::ZERO, ETest::ONE, ETest::TWO, ETest::THREE) TESTSubFile : public BigDNA {
|
||||
AT_DECL_DNA
|
||||
Value<ETest> varE = EVal;
|
||||
Value<atUint32> sub1;
|
||||
Value<atUint32> sub2;
|
||||
};
|
||||
|
||||
struct TESTSubClassFile : public TESTSubFile<ETest::ONE> {
|
||||
AT_DECL_DNA
|
||||
Value<atUint32> sub3;
|
||||
Value<atUint16> sub4;
|
||||
};
|
||||
|
||||
struct TESTSubSubClassFile : public TESTSubClassFile {
|
||||
AT_DECL_DNA
|
||||
Value<atUint32> sub5;
|
||||
Value<atUint32> sub6;
|
||||
};
|
||||
|
||||
template <class Var32Tp, int Var32Val>
|
||||
struct AT_SPECIALIZE_PARMS(atUint16, 42, atUint32, 87, atUint32, 2) TESTFile : public BigDNA {
|
||||
AT_DECL_DNA
|
||||
Value<bool> varBool;
|
||||
AT_OVERRIDE_RCRC32(12345678) Value<Var32Tp> x4_var32 = Var32Val;
|
||||
AT_OVERRIDE_RCRC32(deadbabe) Value<atUint16> x8_var16;
|
||||
Value<atVec3f> vec3;
|
||||
Value<atVec4f> vec4;
|
||||
|
||||
struct TESTNestedSubFile : public BigDNA {
|
||||
AT_DECL_DNA
|
||||
Value<atUint32> nestSub1;
|
||||
Value<atUint32> nestSub2;
|
||||
} nestedSubFile;
|
||||
|
||||
using TESTSubFileUsing = TESTSubFile<ETest::TWO>;
|
||||
TESTSubFileUsing subFile;
|
||||
|
||||
Align<4> align;
|
||||
|
||||
template <class NestedTp, int NestedVal>
|
||||
struct AT_SPECIALIZE_PARMS(atInt32, 36, atInt64, 96) TESTTemplateSubFile : public BigDNA {
|
||||
AT_DECL_DNA
|
||||
Value<NestedTp> explSub1 = NestedVal;
|
||||
Value<Var32Tp> explSub2 = Var32Val;
|
||||
};
|
||||
Value<TESTTemplateSubFile<atInt32, 36>> nestedTemplate1;
|
||||
Value<TESTTemplateSubFile<atInt64, 96>> nestedTemplate2;
|
||||
|
||||
Value<atUint32, Endian::Little> arrCount[2];
|
||||
Vector<atUint32, AT_DNA_COUNT(arrCount[0])> array;
|
||||
|
||||
Value<atUint32> arrAltCount;
|
||||
Vector<atUint32, AT_DNA_COUNT(arrAltCount)> arrayAlt;
|
||||
|
||||
Seek<21, SeekOrigin::Current> seek;
|
||||
|
||||
Value<atUint32> arrCount2;
|
||||
Vector<TESTSubFile<ETest::ZERO>, AT_DNA_COUNT(arrCount[1] + arrCount2)> array2;
|
||||
|
||||
Value<atUint32> bufSz;
|
||||
Buffer<AT_DNA_COUNT(bufSz)> buf;
|
||||
|
||||
String<32> str;
|
||||
WString<64> wstr;
|
||||
};
|
||||
19
extern/CMakeLists.txt
vendored
19
extern/CMakeLists.txt
vendored
@@ -1,15 +1,8 @@
|
||||
add_subdirectory(lzokay)
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(lzokay PRIVATE -Wno-maybe-uninitialized)
|
||||
if (EXISTS ${CMAKE_SOURCE_DIR}/extern/lzokay)
|
||||
add_subdirectory(lzokay)
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(lzokay PRIVATE -Wno-maybe-uninitialized)
|
||||
endif ()
|
||||
endif ()
|
||||
add_subdirectory(zlib)
|
||||
add_subdirectory(yaml)
|
||||
if(NOT TARGET fmt)
|
||||
add_subdirectory(fmt)
|
||||
target_compile_definitions(fmt PUBLIC
|
||||
FMT_STRING_ALIAS=1
|
||||
FMT_ARM_ABI_COMPATIBILITY=1
|
||||
FMT_EXCEPTIONS=0)
|
||||
target_compile_definitions(fmt INTERFACE
|
||||
FMT_ENFORCE_COMPILE_STRING=1)
|
||||
endif()
|
||||
add_subdirectory(yaml)
|
||||
1
extern/fmt
vendored
1
extern/fmt
vendored
Submodule extern/fmt deleted from 95da484727
2
extern/lzokay
vendored
2
extern/lzokay
vendored
Submodule extern/lzokay updated: 546a969527...db2df1fcbe
2
extern/yaml/src/yaml_private.h
vendored
2
extern/yaml/src/yaml_private.h
vendored
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <yaml.h>
|
||||
#include <athena/yaml.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
88
extern/zlib/CMakeLists.txt
vendored
88
extern/zlib/CMakeLists.txt
vendored
@@ -1,40 +1,48 @@
|
||||
if(NOT WIN32 AND NOT NX) # remove when specter/freetype is gone
|
||||
find_library(ZLIB_LIB NAMES zlib z)
|
||||
endif()
|
||||
if(NOT ZLIB_LIB)
|
||||
message(STATUS "Using Athena's built-in zlib")
|
||||
add_library(z
|
||||
adler32.c
|
||||
compress.c
|
||||
crc32.c
|
||||
deflate.c
|
||||
infback.c
|
||||
inffast.c
|
||||
inflate.c
|
||||
inftrees.c
|
||||
trees.c
|
||||
uncompr.c
|
||||
zutil.c
|
||||
crc32.h
|
||||
deflate.h
|
||||
gzguts.h
|
||||
inffast.h
|
||||
inffixed.h
|
||||
inflate.h
|
||||
inftrees.h
|
||||
trees.h
|
||||
zconf.h
|
||||
zlib.h
|
||||
zutil.h)
|
||||
if(WIN32 AND NOT UNIX)
|
||||
install(FILES zconf.h zlib.h DESTINATION include COMPONENT zlib)
|
||||
install(TARGETS z DESTINATION lib COMPONENT zlib)
|
||||
else()
|
||||
target_compile_options(z PRIVATE -Wno-implicit-fallthrough)
|
||||
endif()
|
||||
set(ZLIB_LIBRARIES z CACHE PATH "Zlib libraries" FORCE)
|
||||
set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "Zlib include path" FORCE)
|
||||
else()
|
||||
set(ZLIB_LIBRARIES ${ZLIB_LIB} CACHE PATH "Zlib libraries" FORCE)
|
||||
find_path(ZLIB_INCLUDE_DIR zlib.h)
|
||||
endif()
|
||||
if (APPLE)
|
||||
# always use toolchain zlib
|
||||
set(ZLIB_REQUIRED REQUIRED)
|
||||
endif ()
|
||||
find_package(ZLIB ${ZLIB_REQUIRED})
|
||||
if (ZLIB_FOUND)
|
||||
add_library(z INTERFACE)
|
||||
target_link_libraries(z INTERFACE ${ZLIB_LIBRARIES})
|
||||
target_include_directories(z INTERFACE ${ZLIB_INCLUDE_DIRS})
|
||||
set(ZLIB_LIBRARIES z CACHE STRING "zlib libraries" FORCE)
|
||||
set(ATHENA_ZLIB NO CACHE BOOL "Using built-in zlib" FORCE)
|
||||
else ()
|
||||
message(STATUS "Using Athena's built-in zlib")
|
||||
add_library(z
|
||||
adler32.c
|
||||
compress.c
|
||||
crc32.c
|
||||
deflate.c
|
||||
infback.c
|
||||
inffast.c
|
||||
inflate.c
|
||||
inftrees.c
|
||||
trees.c
|
||||
uncompr.c
|
||||
zutil.c
|
||||
include/crc32.h
|
||||
include/deflate.h
|
||||
include/gzguts.h
|
||||
include/inffast.h
|
||||
include/inffixed.h
|
||||
include/inflate.h
|
||||
include/inftrees.h
|
||||
include/trees.h
|
||||
include/zconf.h
|
||||
include/zlib.h
|
||||
include/zutil.h)
|
||||
if (WIN32 AND NOT UNIX)
|
||||
install(FILES include/zconf.h include/zlib.h DESTINATION include COMPONENT zlib)
|
||||
install(TARGETS z DESTINATION lib COMPONENT zlib)
|
||||
else ()
|
||||
target_compile_options(z PRIVATE -Wno-implicit-fallthrough)
|
||||
endif ()
|
||||
target_include_directories(z PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>)
|
||||
set(ZLIB_LIBRARIES z CACHE STRING "zlib libraries" FORCE)
|
||||
set(ATHENA_ZLIB YES CACHE BOOL "Using built-in zlib" FORCE)
|
||||
endif ()
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/* BIG FAT WARNING!!!
|
||||
*
|
||||
* The type-structure of this file is expected to remain consistent for 'atdna'
|
||||
* Any changes to the types or namespacing must be reflected in 'atdna/main.cpp'
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "athena/DNAOp.hpp"
|
||||
#include "athena/Global.hpp"
|
||||
#include "athena/IStreamReader.hpp"
|
||||
#include "athena/IStreamWriter.hpp"
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
namespace athena::io {
|
||||
|
||||
/**
|
||||
* @brief Base DNA class used against 'atdna'
|
||||
* @tparam DNAE Default-endianness for contained DNA values
|
||||
*
|
||||
* Athena bundles a build-tool called 'atdna'. This tool functions
|
||||
* just like the 'clang' compiler, except it emits a full .cpp implementation
|
||||
* with all read/write calls necessary to marshal the DNA structure to/from
|
||||
* a streamed medium
|
||||
*/
|
||||
template <Endian DNAE>
|
||||
struct DNA {
|
||||
/**
|
||||
* @brief Designated byte-order used for serializing fields
|
||||
*/
|
||||
static constexpr Endian DNAEndian = DNAE;
|
||||
|
||||
/**
|
||||
* @brief Template type signaling atdna to capture the value where it's used
|
||||
* @tparam T The type of the value. Can be any numeric type or atVec* type
|
||||
* @tparam VE Endianness of the value
|
||||
*/
|
||||
template <typename T, Endian VE = DNAE>
|
||||
using Value = T;
|
||||
|
||||
/**
|
||||
* @brief Template type wrapping std::vector and signaling atdna to manipulate it where it's used
|
||||
* @tparam T The type of contained elements. Can be any numeric type, atVec* type, or another DNA subclass
|
||||
* @tparam cntVar C++ expression wrapped in DNA_COUNT macro to determine number of elements for vector
|
||||
* @tparam VE Endianness of the contained values
|
||||
*/
|
||||
template <typename T, size_t cntVar, Endian VE = DNAE>
|
||||
using Vector = std::vector<T>;
|
||||
|
||||
/**
|
||||
* @brief Template type wrapping std::unique_ptr<atUint8[]> and signaling atdna to read a
|
||||
* raw byte-buffer where it's used
|
||||
* @tparam sizeVar C++ expression wrapped in DNA_COUNT macro to determine number of bytes for buffer
|
||||
*/
|
||||
template <size_t sizeVar>
|
||||
using Buffer = std::unique_ptr<atUint8[]>;
|
||||
|
||||
/**
|
||||
* @brief Template type wrapping std::string and signaling atdna to read string data where it's used
|
||||
* @tparam sizeVar C++ expression wrapped in DNA_COUNT macro to determine number of characters for string
|
||||
* -1 literal indicates null-terminated string
|
||||
*/
|
||||
template <atInt32 sizeVar = -1>
|
||||
using String = std::string;
|
||||
|
||||
/**
|
||||
* @brief Template type wrapping std::wstring and signaling atdna to read wstring data where it's used
|
||||
* @tparam sizeVar C++ expression wrapped in DNA_COUNT macro to determine number of characters for wstring
|
||||
* -1 literal indicates null-terminated wstring
|
||||
*/
|
||||
template <atInt32 sizeVar = -1, Endian VE = DNAE>
|
||||
using WString = std::wstring;
|
||||
|
||||
/**
|
||||
* @brief Meta Template signaling atdna to insert a stream seek where it's used
|
||||
* @tparam offset C++ expression wrapped in DNA_COUNT macro to determine number of bytes to seek
|
||||
* @tparam direction SeekOrigin to seek relative to
|
||||
*/
|
||||
template <off_t offset, SeekOrigin direction>
|
||||
struct Seek {};
|
||||
|
||||
/**
|
||||
* @brief Meta Template signaling atdna to insert an aligning stream seek where it's used
|
||||
* @tparam align Number of bytes to align to
|
||||
*/
|
||||
template <size_t align>
|
||||
struct Align {};
|
||||
|
||||
/**
|
||||
* @brief Meta Template preventing atdna from emitting read/write implementations
|
||||
*/
|
||||
struct Delete {};
|
||||
|
||||
/* Bring fundamental operations into DNA subclasses for easier per-op overrides */
|
||||
using Read = athena::io::Read<PropType::None>;
|
||||
using Write = athena::io::Write<PropType::None>;
|
||||
using BinarySize = athena::io::BinarySize<PropType::None>;
|
||||
using PropCount = athena::io::PropCount<PropType::None>;
|
||||
using ReadYaml = athena::io::ReadYaml<PropType::None>;
|
||||
using WriteYaml = athena::io::WriteYaml<PropType::None>;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Virtual DNA wrapper for subclasses that utilize virtual method calls
|
||||
* @tparam DNAE Default-endianness for contained DNA values
|
||||
*
|
||||
* Typically, static template-based DNA resolution is sufficient; however, formats
|
||||
* with a tree of variously-typed data structures would benefit from having a vtable.
|
||||
*
|
||||
* Note: It's not recommended to implement these directly. Instead, use the AT_DECL_DNA or
|
||||
* AT_DECL_EXPLCIT_DNA macro in the subclasses. Specializing the Enumerate method
|
||||
* is the proper way to override individual I/O operations. Owners of the virtualized
|
||||
* subclass will typically use a unique_ptr to reference the data; specializing their own
|
||||
* Enumerate methods as such:
|
||||
*
|
||||
* template <> void MySubclass::Enumerate<Read>(typename Read::StreamT& r)
|
||||
* { (Do stuff with `r`) }
|
||||
*/
|
||||
template <Endian DNAE>
|
||||
struct DNAV : DNA<DNAE> {
|
||||
virtual ~DNAV() = default;
|
||||
virtual void read(athena::io::IStreamReader& r) = 0;
|
||||
virtual void write(athena::io::IStreamWriter& w) const = 0;
|
||||
virtual void binarySize(size_t& s) const = 0;
|
||||
virtual std::string_view DNATypeV() const = 0;
|
||||
};
|
||||
|
||||
template <Endian DNAE>
|
||||
struct DNAVYaml : DNAV<DNAE> {
|
||||
virtual ~DNAVYaml() = default;
|
||||
void read(athena::io::IStreamReader& r) override = 0;
|
||||
void write(athena::io::IStreamWriter& w) const override = 0;
|
||||
void binarySize(size_t& s) const override = 0;
|
||||
virtual void read(athena::io::YAMLDocReader& r) = 0;
|
||||
virtual void write(athena::io::YAMLDocWriter& w) const = 0;
|
||||
};
|
||||
|
||||
/** Macro to supply count variable to atdna and mute it for other compilers */
|
||||
#ifdef __clang__
|
||||
#define AT_DNA_COUNT(...) sizeof(__VA_ARGS__)
|
||||
#else
|
||||
#define AT_DNA_COUNT(...) 0
|
||||
#endif
|
||||
|
||||
} // namespace athena::io
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,121 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "athena/DNA.hpp"
|
||||
#include "athena/FileReader.hpp"
|
||||
#include "athena/FileWriter.hpp"
|
||||
#include "athena/YAMLDocReader.hpp"
|
||||
#include "athena/YAMLDocWriter.hpp"
|
||||
|
||||
namespace athena::io {
|
||||
|
||||
template <class T>
|
||||
std::string_view __GetDNAName(const T& dna) {
|
||||
if constexpr (__IsDNAVRecord_v<T>) {
|
||||
return dna.DNATypeV();
|
||||
} else {
|
||||
return dna.DNAType();
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::string ToYAMLString(const T& dna) {
|
||||
YAMLDocWriter docWriter(__GetDNAName(dna));
|
||||
|
||||
std::string res;
|
||||
yaml_emitter_set_output(docWriter.getEmitter(), (yaml_write_handler_t*)YAMLStdStringWriter, &res);
|
||||
yaml_emitter_set_unicode(docWriter.getEmitter(), true);
|
||||
yaml_emitter_set_width(docWriter.getEmitter(), -1);
|
||||
|
||||
dna.write(docWriter);
|
||||
if (!docWriter.finish(nullptr))
|
||||
return std::string();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool FromYAMLString(T& dna, std::string_view str) {
|
||||
YAMLStdStringViewReaderState reader(str);
|
||||
YAMLDocReader docReader;
|
||||
yaml_parser_set_input(docReader.getParser(), (yaml_read_handler_t*)YAMLStdStringReader, &reader);
|
||||
if (!docReader.parse(nullptr))
|
||||
return false;
|
||||
dna.read(docReader);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class DNASubtype>
|
||||
bool ValidateFromYAMLString(std::string_view str) {
|
||||
YAMLStdStringViewReaderState reader(str);
|
||||
YAMLDocReader docReader;
|
||||
yaml_parser_set_input(docReader.getParser(), (yaml_read_handler_t*)YAMLStdStringReader, &reader);
|
||||
bool retval = docReader.ValidateClassType(DNASubtype::DNAType());
|
||||
return retval;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool ToYAMLStream(const T& dna, athena::io::IStreamWriter& fout) {
|
||||
YAMLDocWriter docWriter(__GetDNAName(dna));
|
||||
|
||||
yaml_emitter_set_unicode(docWriter.getEmitter(), true);
|
||||
yaml_emitter_set_width(docWriter.getEmitter(), -1);
|
||||
|
||||
dna.write(docWriter);
|
||||
return docWriter.finish(&fout);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool ToYAMLStream(const T& dna, athena::io::IStreamWriter& fout, void (T::*fn)(YAMLDocWriter& out) const) {
|
||||
YAMLDocWriter docWriter(__GetDNAName(dna));
|
||||
|
||||
yaml_emitter_set_unicode(docWriter.getEmitter(), true);
|
||||
yaml_emitter_set_width(docWriter.getEmitter(), -1);
|
||||
|
||||
(dna.*fn)(docWriter);
|
||||
return docWriter.finish(&fout);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool FromYAMLStream(T& dna, athena::io::IStreamReader& fin) {
|
||||
YAMLDocReader docReader;
|
||||
if (!docReader.parse(&fin))
|
||||
return false;
|
||||
dna.read(docReader);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool FromYAMLStream(T& dna, athena::io::IStreamReader& fin, void (T::*fn)(YAMLDocReader& in)) {
|
||||
YAMLDocReader docReader;
|
||||
if (!docReader.parse(&fin))
|
||||
return false;
|
||||
(dna.*fn)(docReader);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class T, typename NameT>
|
||||
bool MergeToYAMLFile(const T& dna, const NameT& filename) {
|
||||
athena::io::FileReader r(filename);
|
||||
YAMLDocWriter docWriter(__GetDNAName(dna), r.isOpen() ? &r : nullptr);
|
||||
r.close();
|
||||
|
||||
dna.write(docWriter);
|
||||
athena::io::FileWriter w(filename);
|
||||
if (!w.isOpen())
|
||||
return false;
|
||||
return docWriter.finish(&w);
|
||||
}
|
||||
|
||||
template <class DNASubtype>
|
||||
bool ValidateFromYAMLStream(athena::io::IStreamReader& fin) {
|
||||
YAMLDocReader reader;
|
||||
atUint64 pos = fin.position();
|
||||
yaml_parser_set_input(reader.getParser(), (yaml_read_handler_t*)YAMLAthenaReader, &fin);
|
||||
bool retval = reader.ValidateClassType(DNASubtype::DNAType());
|
||||
fin.seek(pos, athena::SeekOrigin::Begin);
|
||||
return retval;
|
||||
}
|
||||
|
||||
} // namespace athena::io
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#if _WIN32
|
||||
using mode_t = int;
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
namespace athena {
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#if _WIN32
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -40,8 +32,7 @@ public:
|
||||
|
||||
void open();
|
||||
void close();
|
||||
bool isOpen() const { return m_fileHandle != 0; }
|
||||
bool save();
|
||||
bool isOpen() const { return m_fileHandle != nullptr; }
|
||||
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override;
|
||||
atUint64 position() const override;
|
||||
atUint64 length() const override;
|
||||
@@ -50,7 +41,7 @@ public:
|
||||
void setCacheSize(const atInt32 blockSize);
|
||||
|
||||
#if _WIN32
|
||||
using HandleType = HANDLE;
|
||||
using HandleType = void*;
|
||||
#else
|
||||
using HandleType = FILE*;
|
||||
#endif
|
||||
@@ -64,6 +55,7 @@ protected:
|
||||
std::string m_filename;
|
||||
#endif
|
||||
HandleType m_fileHandle;
|
||||
atUint64 m_fileSize;
|
||||
std::unique_ptr<atUint8[]> m_cacheData;
|
||||
atInt32 m_blockSize;
|
||||
atInt32 m_curBlock;
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
#include "athena/IStreamWriter.hpp"
|
||||
#include "athena/Types.hpp"
|
||||
@@ -43,7 +36,7 @@ public:
|
||||
void writeUBytes(const atUint8* data, atUint64 len) override;
|
||||
|
||||
#ifdef _WIN32
|
||||
using HandleType = HANDLE;
|
||||
using HandleType = void*;
|
||||
#else
|
||||
using HandleType = FILE*;
|
||||
#endif
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <ostream>
|
||||
#include "athena/Types.hpp"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <format>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4996)
|
||||
@@ -17,11 +17,11 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
|
||||
#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#endif
|
||||
|
||||
#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
|
||||
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
#if !defined(S_ISLNK)
|
||||
@@ -47,7 +47,7 @@
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
#if defined(GEKKO) || defined(__SWITCH__)
|
||||
#if defined(GEKKO) || defined(__SWITCH__) || defined(EMSCRIPTEN)
|
||||
#include "gekko_support.h"
|
||||
typedef struct stat atStat64_t;
|
||||
#define atStat64 stat
|
||||
@@ -118,27 +118,10 @@ enum class SeekOrigin { Begin, Current, End };
|
||||
|
||||
enum class Endian { Little, Big };
|
||||
|
||||
namespace io {
|
||||
template <Endian DNAE>
|
||||
struct DNA;
|
||||
template <Endian DNAE>
|
||||
struct DNAV;
|
||||
|
||||
template <class T>
|
||||
using __IsDNARecord = std::disjunction<std::is_base_of<DNA<Endian::Big>, T>, std::is_base_of<DNA<Endian::Little>, T>>;
|
||||
template <class T>
|
||||
constexpr bool __IsDNARecord_v = __IsDNARecord<T>::value;
|
||||
|
||||
template <class T>
|
||||
using __IsDNAVRecord =
|
||||
std::disjunction<std::is_base_of<DNAV<Endian::Big>, T>, std::is_base_of<DNAV<Endian::Little>, T>>;
|
||||
template <class T>
|
||||
constexpr bool __IsDNAVRecord_v = __IsDNAVRecord<T>::value;
|
||||
} // namespace io
|
||||
} // namespace athena
|
||||
|
||||
typedef void (*atEXCEPTION_HANDLER)(athena::error::Level level, const char* /*file*/, const char*, int /*line*/,
|
||||
fmt::string_view fmt, fmt::format_args args);
|
||||
std::string_view fmt, std::format_args args);
|
||||
|
||||
atEXCEPTION_HANDLER atGetExceptionHandler();
|
||||
/**
|
||||
@@ -150,54 +133,47 @@ void atSetExceptionHandler(atEXCEPTION_HANDLER func);
|
||||
std::ostream& operator<<(std::ostream& os, const athena::SeekOrigin& origin);
|
||||
std::ostream& operator<<(std::ostream& os, const athena::Endian& endian);
|
||||
|
||||
template <typename First, typename... Rest>
|
||||
constexpr auto __FIRST_ARG__(First first, Rest...) { return first; }
|
||||
template <typename S, typename... Args>
|
||||
auto __make_args_checked__(const S& format_str, Args&&... args) {
|
||||
return fmt::make_args_checked<Args...>(format_str, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define atDebug(...) \
|
||||
#define atDebug(fmt, ...) \
|
||||
do { \
|
||||
atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \
|
||||
if (__handler) \
|
||||
__handler(athena::error::Level::Message, __FILE__, AT_PRETTY_FUNCTION, __LINE__, __FIRST_ARG__(__VA_ARGS__), \
|
||||
__make_args_checked__(__VA_ARGS__)); \
|
||||
__handler(athena::error::Level::Message, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, \
|
||||
std::make_format_args(__VA_ARGS__)); \
|
||||
} while (0)
|
||||
#else
|
||||
#define atDebug(...)
|
||||
#endif
|
||||
|
||||
#define atMessage(...) \
|
||||
#define atMessage(fmt, ...) \
|
||||
do { \
|
||||
atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \
|
||||
if (__handler) \
|
||||
__handler(athena::error::Level::Message, __FILE__, AT_PRETTY_FUNCTION, __LINE__, __FIRST_ARG__(__VA_ARGS__), \
|
||||
__make_args_checked__(__VA_ARGS__)); \
|
||||
__handler(athena::error::Level::Message, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, \
|
||||
std::make_format_args(__VA_ARGS__)); \
|
||||
} while (0)
|
||||
|
||||
#define atWarning(...) \
|
||||
#define atWarning(fmt, ...) \
|
||||
do { \
|
||||
atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \
|
||||
if (__handler) { \
|
||||
__handler(athena::error::Level::Warning, __FILE__, AT_PRETTY_FUNCTION, __LINE__, __FIRST_ARG__(__VA_ARGS__), \
|
||||
__make_args_checked__(__VA_ARGS__)); \
|
||||
__handler(athena::error::Level::Warning, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, \
|
||||
std::make_format_args(__VA_ARGS__)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define atError(...) \
|
||||
#define atError(fmt, ...) \
|
||||
do { \
|
||||
atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \
|
||||
if (__handler) \
|
||||
__handler(athena::error::Level::Error, __FILE__, AT_PRETTY_FUNCTION, __LINE__, __FIRST_ARG__(__VA_ARGS__), \
|
||||
__make_args_checked__(__VA_ARGS__)); \
|
||||
__handler(athena::error::Level::Error, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, \
|
||||
std::make_format_args(__VA_ARGS__)); \
|
||||
} while (0)
|
||||
|
||||
#define atFatal(...) \
|
||||
#define atFatal(fmt, ...) \
|
||||
do { \
|
||||
atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \
|
||||
if (__handler) \
|
||||
__handler(athena::error::Level::Fatal, __FILE__, AT_PRETTY_FUNCTION, __LINE__, __FIRST_ARG__(__VA_ARGS__), \
|
||||
__make_args_checked__(__VA_ARGS__)); \
|
||||
__handler(athena::error::Level::Fatal, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, \
|
||||
std::make_format_args(__VA_ARGS__)); \
|
||||
} while (0)
|
||||
|
||||
@@ -661,7 +661,7 @@ public:
|
||||
utf8proc_int32_t wc;
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||
atWarning("invalid UTF-8 character while decoding");
|
||||
return;
|
||||
}
|
||||
buf += len;
|
||||
@@ -675,7 +675,7 @@ public:
|
||||
if (*buf) {
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||
atWarning("invalid UTF-8 character while decoding");
|
||||
return;
|
||||
}
|
||||
buf += len;
|
||||
@@ -709,7 +709,7 @@ public:
|
||||
utf8proc_int32_t wc;
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||
atWarning("invalid UTF-8 character while decoding");
|
||||
return;
|
||||
}
|
||||
buf += len;
|
||||
@@ -723,7 +723,7 @@ public:
|
||||
if (*buf) {
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||
atWarning("invalid UTF-8 character while decoding");
|
||||
return;
|
||||
}
|
||||
buf += len;
|
||||
@@ -758,7 +758,7 @@ public:
|
||||
utf8proc_int32_t wc;
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||
atWarning("invalid UTF-8 character while decoding");
|
||||
return;
|
||||
}
|
||||
buf += len;
|
||||
@@ -772,7 +772,7 @@ public:
|
||||
if (*buf) {
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||
atWarning("invalid UTF-8 character while decoding");
|
||||
return;
|
||||
}
|
||||
buf += len;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <yaml.h>
|
||||
#include "yaml.h"
|
||||
|
||||
#include "athena/Types.hpp"
|
||||
|
||||
|
||||
@@ -61,12 +61,6 @@ public:
|
||||
|
||||
RecordRAII enterSubRecord(std::string_view name = {});
|
||||
|
||||
template <class T>
|
||||
void enumerate(std::string_view name, T& record, std::enable_if_t<__IsDNARecord_v<T>>* = nullptr) {
|
||||
if (auto rec = enterSubRecord(name))
|
||||
record.read(*this);
|
||||
}
|
||||
|
||||
class VectorRAII {
|
||||
friend class YAMLDocReader;
|
||||
YAMLDocReader* m_r = nullptr;
|
||||
|
||||
@@ -47,12 +47,6 @@ public:
|
||||
|
||||
RecordRAII enterSubRecord(std::string_view name = {});
|
||||
|
||||
template <class T>
|
||||
void enumerate(std::string_view name, T& record, std::enable_if_t<__IsDNARecord_v<T>>* = nullptr) {
|
||||
if (auto rec = enterSubRecord(name))
|
||||
record.write(*this);
|
||||
}
|
||||
|
||||
class VectorRAII {
|
||||
friend class YAMLDocWriter;
|
||||
YAMLDocWriter* m_w = nullptr;
|
||||
|
||||
@@ -1518,6 +1518,11 @@ public:
|
||||
const __simd_storage<_Up, __simd_abi<_StorageKind::_Array, __Unum_element>>& other) {
|
||||
std::copy(other.__native().begin(), other.__native().end(), __storage_.begin());
|
||||
}
|
||||
template <typename... _T2, std::enable_if_t<(... && std::is_convertible_v<_T2, _Tp>), bool> = true,
|
||||
std::enable_if_t<sizeof...(_T2) == __num_element, bool> = true>
|
||||
constexpr __simd_storage(_T2... values) : __storage_{values...} {}
|
||||
template <std::enable_if_t<__num_element == 4, bool> = true>
|
||||
constexpr __simd_storage(_Tp __rv) : __storage_{__rv, __rv, __rv, __rv} {}
|
||||
constexpr const storage_type& __native() const { return __storage_; }
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ using namespace std;
|
||||
#elif __ARM_NEON
|
||||
#include "simd_neon.hpp"
|
||||
#else
|
||||
namespace simd_abi {
|
||||
namespace athena::_simd::simd_abi {
|
||||
template <typename T>
|
||||
struct athena_native {};
|
||||
template <>
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
using storage_type = __m128;
|
||||
storage_type __storage_{};
|
||||
[[nodiscard]] inline float __get(size_t __index) const noexcept {
|
||||
#if _MSC_VER && !defined(__clang__)
|
||||
#if _MSC_VER
|
||||
alignas(16) std::array<float, 4> sse_data;
|
||||
_mm_store_ps(sse_data.data(), __storage_);
|
||||
return sse_data[__index];
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
inline void __set(size_t __index, float __val) noexcept {
|
||||
#if _MSC_VER && !defined(__clang__)
|
||||
#if _MSC_VER
|
||||
alignas(16) std::array<float, 4> sse_data;
|
||||
_mm_store_ps(sse_data.data(), __storage_);
|
||||
sse_data[__index] = __val;
|
||||
@@ -210,7 +210,7 @@ public:
|
||||
using storage_type = std::array<__m128d, 2>;
|
||||
storage_type __storage_{};
|
||||
[[nodiscard]] inline double __get(size_t __index) const noexcept {
|
||||
#if _MSC_VER && !defined(__clang__)
|
||||
#if _MSC_VER
|
||||
alignas(16) std::array<double, 2> sse_data;
|
||||
_mm_store_pd(sse_data.data(), __storage_[__index / 2]);
|
||||
return sse_data[__index % 2];
|
||||
@@ -219,13 +219,13 @@ public:
|
||||
#endif
|
||||
}
|
||||
inline void __set(size_t __index, double __val) noexcept {
|
||||
#if _MSC_VER && !defined(__clang__)
|
||||
#if _MSC_VER
|
||||
alignas(16) std::array<double, 2> sse_data;
|
||||
_mm_store_pd(sse_data.data(), __storage_[__index / 2]);
|
||||
sse_data[__index % 2] = __val;
|
||||
__storage_[__index / 2] = _mm_load_pd(sse_data.data());
|
||||
#else
|
||||
__storage_[__index / 2][__index % 2] = __val;
|
||||
__storage_[__index / 2][__index % 2] = __val;
|
||||
#endif
|
||||
}
|
||||
// Make GCC happy
|
||||
|
||||
@@ -4,7 +4,7 @@ libdir=${prefix}/lib
|
||||
|
||||
Name: libAthena
|
||||
Description: Basic cross platform IO library
|
||||
Version: @ATHENA_VERSION@
|
||||
Version: @ATHENA_VERSION_STRING@
|
||||
Cflags: -I${includedir}/Athena
|
||||
Libs: -L${libdir} -lathena-core -lathena-sakura -lathena-zelda -lathena-wiiSave
|
||||
Requires: zlib
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,7 +51,7 @@ bool Dir::rm(std::string_view path) { return !(remove((m_path + "/" + path.data(
|
||||
bool Dir::touch() {
|
||||
std::srand(std::time(nullptr));
|
||||
atUint64 tmp = utility::rand64();
|
||||
std::string tmpFile = fmt::format(FMT_STRING("{:016X}.tmp"), tmp);
|
||||
std::string tmpFile = std::format("{:016X}.tmp", tmp);
|
||||
bool ret = FileInfo(m_path + "/" + tmpFile).touch();
|
||||
if (ret)
|
||||
return rm(tmpFile);
|
||||
|
||||
@@ -33,11 +33,13 @@ void FileReader::open() {
|
||||
if (!m_fileHandle) {
|
||||
std::string _filename = filename();
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("File not found '{}'"), _filename);
|
||||
atError("File not found '{}'", _filename);
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
|
||||
m_fileSize = utility::fileSize(m_filename);
|
||||
|
||||
// reset error
|
||||
m_hasError = false;
|
||||
}
|
||||
@@ -45,7 +47,7 @@ void FileReader::open() {
|
||||
void FileReader::close() {
|
||||
if (!m_fileHandle) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("Cannot close an unopened stream"));
|
||||
atError("Cannot close an unopened stream");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -74,7 +76,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) {
|
||||
}
|
||||
if (m_offset > length()) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("Unable to seek in file"));
|
||||
atError("Unable to seek in file");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -87,7 +89,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) {
|
||||
}
|
||||
} else if (fseeko64(m_fileHandle, pos, int(origin)) != 0) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("Unable to seek in file"));
|
||||
atError("Unable to seek in file");
|
||||
setError();
|
||||
}
|
||||
}
|
||||
@@ -95,7 +97,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) {
|
||||
atUint64 FileReader::position() const {
|
||||
if (!isOpen()) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("File not open"));
|
||||
atError("File not open");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -108,17 +110,17 @@ atUint64 FileReader::position() const {
|
||||
atUint64 FileReader::length() const {
|
||||
if (!isOpen()) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("File not open"));
|
||||
atError("File not open");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return utility::fileSize(m_filename);
|
||||
return m_fileSize;
|
||||
}
|
||||
|
||||
atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) {
|
||||
if (!isOpen()) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("File not open for reading"));
|
||||
atError("File not open for reading");
|
||||
setError();
|
||||
return 0;
|
||||
}
|
||||
@@ -126,11 +128,10 @@ atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) {
|
||||
if (m_blockSize <= 0)
|
||||
return fread(buf, 1, len, m_fileHandle);
|
||||
else {
|
||||
atUint64 fs = utility::fileSize(m_filename);
|
||||
if (m_offset >= fs)
|
||||
if (m_offset >= m_fileSize)
|
||||
return 0;
|
||||
if (m_offset + len >= fs)
|
||||
len = fs - m_offset;
|
||||
if (m_offset + len >= m_fileSize)
|
||||
len = m_fileSize - m_offset;
|
||||
|
||||
size_t block = m_offset / m_blockSize;
|
||||
atUint64 cacheOffset = m_offset % m_blockSize;
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
#include "athena/FileReader.hpp"
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
|
||||
#include "win32_largefilewrapper.h"
|
||||
|
||||
namespace athena::io {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
#include "osx_largefilewrapper.h"
|
||||
#elif defined(GEKKO) || defined(__SWITCH__)
|
||||
#include "gekko_support.h"
|
||||
#include "athena/gekko_support.h"
|
||||
#include "osx_largefilewrapper.h"
|
||||
#endif
|
||||
|
||||
@@ -48,8 +48,9 @@ void FileWriter::open(bool overwrite) {
|
||||
}
|
||||
|
||||
if (!m_fileHandle) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("Unable to open file '%s'"), filename().c_str());
|
||||
if (m_globalErr) {
|
||||
atError("Unable to open file '{}'", m_filename);
|
||||
}
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -61,7 +62,7 @@ void FileWriter::open(bool overwrite) {
|
||||
void FileWriter::close() {
|
||||
if (!m_fileHandle) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("Cannot close an unopened stream"));
|
||||
atError("Cannot close an unopened stream");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -81,14 +82,14 @@ void FileWriter::close() {
|
||||
void FileWriter::seek(atInt64 pos, SeekOrigin origin) {
|
||||
if (!isOpen()) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("Unable to seek in file, not open"));
|
||||
atError("Unable to seek in file, not open");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (fseeko64(m_fileHandle, pos, int(origin)) != 0) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("Unable to seek in file"));
|
||||
atError("Unable to seek in file");
|
||||
setError();
|
||||
}
|
||||
}
|
||||
@@ -100,14 +101,14 @@ atUint64 FileWriter::length() const { return utility::fileSize(m_filename); }
|
||||
void FileWriter::writeUBytes(const atUint8* data, atUint64 len) {
|
||||
if (!isOpen()) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("File not open for writing"));
|
||||
atError("File not open for writing");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (fwrite(data, 1, len, m_fileHandle) != len) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("Unable to write to stream"));
|
||||
atError("Unable to write to stream");
|
||||
setError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#include "athena/FileWriter.hpp"
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ std::ostream& operator<<(std::ostream& os, const athena::Endian& endian) {
|
||||
}
|
||||
|
||||
static void __defaultExceptionHandler(athena::error::Level level, const char* file, const char* function, int line,
|
||||
fmt::string_view fmt, fmt::format_args args) {
|
||||
std::string_view fmt, std::format_args args) {
|
||||
std::string levelStr;
|
||||
switch (level) {
|
||||
case athena::error::Level::Warning:
|
||||
@@ -51,7 +51,7 @@ static void __defaultExceptionHandler(athena::error::Level level, const char* fi
|
||||
break;
|
||||
}
|
||||
|
||||
std::string msg = fmt::vformat(fmt, args);
|
||||
std::string msg = std::vformat(fmt, args);
|
||||
std::cerr << levelStr << " " << file << " " << function << "(" << line << "): " << msg << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ MemoryReader::MemoryReader(const void* data, atUint64 length, bool takeOwnership
|
||||
: m_data(data), m_length(length), m_position(0), m_owns(takeOwnership), m_globalErr(globalErr) {
|
||||
if (!data) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("data cannot be NULL"));
|
||||
atError("data cannot be NULL");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -21,13 +21,13 @@ MemoryReader::MemoryReader(const void* data, atUint64 length, bool takeOwnership
|
||||
|
||||
MemoryReader::~MemoryReader() {
|
||||
if (m_owns)
|
||||
delete[] reinterpret_cast<const atUint8*>(m_data);
|
||||
delete[] static_cast<const atUint8*>(m_data);
|
||||
}
|
||||
|
||||
MemoryCopyReader::MemoryCopyReader(const void* data, atUint64 length) : MemoryReader(data, length, false) {
|
||||
if (!data) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("data cannot be NULL"));
|
||||
atError("data cannot be NULL");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin) {
|
||||
case SeekOrigin::Begin:
|
||||
if ((position < 0 || atInt64(position) > atInt64(m_length))) {
|
||||
if (m_globalErr)
|
||||
atFatal(FMT_STRING("Position {:08X} outside stream bounds "), position);
|
||||
atFatal("Position {:08X} outside stream bounds ", position);
|
||||
m_position = m_length;
|
||||
setError();
|
||||
return;
|
||||
@@ -54,7 +54,7 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin) {
|
||||
case SeekOrigin::Current:
|
||||
if (((atInt64(m_position) + position) < 0 || (m_position + atUint64(position)) > m_length)) {
|
||||
if (m_globalErr)
|
||||
atFatal(FMT_STRING("Position {:08X} outside stream bounds "), position);
|
||||
atFatal("Position {:08X} outside stream bounds ", position);
|
||||
m_position = (position < 0 ? 0 : m_length);
|
||||
setError();
|
||||
return;
|
||||
@@ -66,7 +66,7 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin) {
|
||||
case SeekOrigin::End:
|
||||
if ((((atInt64)m_length - position < 0) || (m_length - position) > m_length)) {
|
||||
if (m_globalErr)
|
||||
atFatal(FMT_STRING("Position {:08X} outside stream bounds "), position);
|
||||
atFatal("Position {:08X} outside stream bounds ", position);
|
||||
m_position = m_length;
|
||||
setError();
|
||||
return;
|
||||
@@ -104,14 +104,14 @@ atUint8* MemoryReader::data() const {
|
||||
atUint64 MemoryReader::readUBytesToBuf(void* buf, atUint64 length) {
|
||||
if (m_position >= m_length) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("Position {:08X} outside stream bounds "), m_position);
|
||||
atError("Position {:08X} outside stream bounds ", m_position);
|
||||
m_position = m_length;
|
||||
setError();
|
||||
return 0;
|
||||
}
|
||||
|
||||
length = std::min(length, m_length - m_position);
|
||||
memmove(buf, reinterpret_cast<const atUint8*>(m_data) + m_position, length);
|
||||
memmove(buf, static_cast<const atUint8*>(m_data) + m_position, length);
|
||||
m_position += length;
|
||||
return length;
|
||||
}
|
||||
@@ -123,7 +123,7 @@ void MemoryCopyReader::loadData() {
|
||||
|
||||
if (!in) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("Unable to open file '%s'"), m_filepath);
|
||||
atError("Unable to open file '%s'", m_filepath);
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ void MemoryCopyReader::loadData() {
|
||||
|
||||
if (ret < 0) {
|
||||
if (m_globalErr)
|
||||
atError(FMT_STRING("Error reading data from disk"));
|
||||
atError("Error reading data from disk");
|
||||
setError();
|
||||
return;
|
||||
} else if (ret == 0)
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace athena::io {
|
||||
MemoryWriter::MemoryWriter(atUint8* data, atUint64 length, bool takeOwnership)
|
||||
: m_data(data), m_length(length), m_bufferOwned(takeOwnership) {
|
||||
if (!data) {
|
||||
atError(FMT_STRING("data cannot be NULL"));
|
||||
atError("data cannot be NULL");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ MemoryCopyWriter::MemoryCopyWriter(atUint8* data, atUint64 length) {
|
||||
m_bufferOwned = false;
|
||||
|
||||
if (length == 0) {
|
||||
atError(FMT_STRING("length cannot be 0"));
|
||||
atError("length cannot be 0");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ MemoryCopyWriter::MemoryCopyWriter(std::string_view filename) {
|
||||
m_bufferOwned = false;
|
||||
|
||||
if (!m_data) {
|
||||
atError(FMT_STRING("Could not allocate memory!"));
|
||||
atError("Could not allocate memory!");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -61,13 +61,13 @@ void MemoryWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||
switch (origin) {
|
||||
case SeekOrigin::Begin:
|
||||
if (position < 0) {
|
||||
atError(FMT_STRING("Position outside stream bounds"));
|
||||
atError("Position outside stream bounds");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((atUint64)position > m_length) {
|
||||
atError(FMT_STRING("data exceeds available buffer space"));
|
||||
atError("data exceeds available buffer space");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -77,13 +77,13 @@ void MemoryWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||
|
||||
case SeekOrigin::Current:
|
||||
if ((((atInt64)m_position + position) < 0)) {
|
||||
atError(FMT_STRING("Position outside stream bounds"));
|
||||
atError("Position outside stream bounds");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_position + position > m_length) {
|
||||
atError(FMT_STRING("data exceeds available buffer space"));
|
||||
atError("data exceeds available buffer space");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -93,13 +93,13 @@ void MemoryWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||
|
||||
case SeekOrigin::End:
|
||||
if (((atInt64)m_length - position) < 0) {
|
||||
atError(FMT_STRING("Position outside stream bounds"));
|
||||
atError("Position outside stream bounds");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((atUint64)position > m_length) {
|
||||
atError(FMT_STRING("data exceeds available buffer space"));
|
||||
atError("data exceeds available buffer space");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ void MemoryCopyWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||
switch (origin) {
|
||||
case SeekOrigin::Begin:
|
||||
if (position < 0) {
|
||||
atError(FMT_STRING("Position outside stream bounds"));
|
||||
atError("Position outside stream bounds");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ void MemoryCopyWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||
|
||||
case SeekOrigin::Current:
|
||||
if ((((atInt64)m_position + position) < 0)) {
|
||||
atError(FMT_STRING("Position outside stream bounds"));
|
||||
atError("Position outside stream bounds");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ void MemoryCopyWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||
|
||||
case SeekOrigin::End:
|
||||
if (((atInt64)m_length - position) < 0) {
|
||||
atError(FMT_STRING("Position outside stream bounds"));
|
||||
atError("Position outside stream bounds");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -180,7 +180,7 @@ atUint8* MemoryWriter::data() const {
|
||||
|
||||
void MemoryWriter::save(std::string_view filename) {
|
||||
if (filename.empty() && m_filepath.empty()) {
|
||||
atError(FMT_STRING("No file specified, cannot save."));
|
||||
atError("No file specified, cannot save.");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ void MemoryWriter::save(std::string_view filename) {
|
||||
|
||||
std::unique_ptr<FILE, decltype(&std::fclose)> out{std::fopen(m_filepath.c_str(), "wb"), std::fclose};
|
||||
if (!out) {
|
||||
atError(FMT_STRING("Unable to open file '{}'"), m_filepath);
|
||||
atError("Unable to open file '{}'", m_filepath);
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -207,7 +207,7 @@ void MemoryWriter::save(std::string_view filename) {
|
||||
const atInt64 ret = std::fwrite(m_data + done, 1, blocksize, out.get());
|
||||
|
||||
if (ret < 0) {
|
||||
atError(FMT_STRING("Error writing data to disk"));
|
||||
atError("Error writing data to disk");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -222,25 +222,25 @@ void MemoryWriter::save(std::string_view filename) {
|
||||
|
||||
void MemoryWriter::writeUBytes(const atUint8* data, atUint64 length) {
|
||||
if (!data) {
|
||||
atError(FMT_STRING("data cannnot be NULL"));
|
||||
atError("data cannnot be NULL");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_position + length > m_length) {
|
||||
atError(FMT_STRING("data length exceeds available buffer space"));
|
||||
atError("data length exceeds available buffer space");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
|
||||
memmove(reinterpret_cast<atInt8*>(m_data + m_position), data, length);
|
||||
memmove(m_data + m_position, data, length);
|
||||
|
||||
m_position += length;
|
||||
}
|
||||
|
||||
void MemoryCopyWriter::writeUBytes(const atUint8* data, atUint64 length) {
|
||||
if (!data) {
|
||||
atError(FMT_STRING("data cannnot be NULL"));
|
||||
atError("data cannnot be NULL");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -248,14 +248,14 @@ void MemoryCopyWriter::writeUBytes(const atUint8* data, atUint64 length) {
|
||||
if (m_position + length > m_length)
|
||||
resize(m_position + length);
|
||||
|
||||
memmove(reinterpret_cast<atInt8*>(m_data + m_position), data, length);
|
||||
memmove(m_data + m_position, data, length);
|
||||
|
||||
m_position += length;
|
||||
}
|
||||
|
||||
void MemoryCopyWriter::resize(atUint64 newSize) {
|
||||
if (newSize < m_length) {
|
||||
atError(FMT_STRING("New size cannot be less to the old size."));
|
||||
atError("New size cannot be less to the old size.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "athena/SkywardSwordQuest.hpp"
|
||||
#include "athena/Checksums.hpp"
|
||||
#include "athena/Utility.hpp"
|
||||
#include "utf8proc.h"
|
||||
#include "athena/utf8proc.h"
|
||||
#include <sstream>
|
||||
|
||||
namespace athena {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#endif
|
||||
|
||||
#include "athena/Global.hpp"
|
||||
#include <string.h>
|
||||
|
||||
namespace athena::net {
|
||||
|
||||
@@ -84,7 +85,7 @@ bool Socket::openSocket() {
|
||||
|
||||
m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (m_socket == -1) {
|
||||
atError(FMT_STRING("Can't allocate socket"));
|
||||
atError("Can't allocate socket");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -138,13 +139,13 @@ bool Socket::openAndListen(const IPAddress& address, uint32_t port) {
|
||||
sockaddr_in addr = createAddress(address.toInteger(), port);
|
||||
if (bind(m_socket, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) == -1) {
|
||||
/* Not likely to happen, but... */
|
||||
atError(FMT_STRING("Failed to bind listener socket to port {}"), port);
|
||||
atError("Failed to bind listener socket to port {}", port);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (::listen(m_socket, 0) == -1) {
|
||||
/* Oops, socket is deaf */
|
||||
atError(FMT_STRING("Failed to listen to port {}"), port);
|
||||
atError("Failed to listen to port {}", port);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -163,8 +164,10 @@ Socket::EResult Socket::accept(Socket& remoteSocketOut, sockaddr_in& fromAddress
|
||||
if (remoteSocket == -1) {
|
||||
#ifndef _WIN32
|
||||
EResult res = (errno == EAGAIN) ? EResult::Busy : EResult::Error;
|
||||
if (res == EResult::Error)
|
||||
atError(FMT_STRING("Failed to accept incoming connection: {}"), strerror(errno));
|
||||
if (res == EResult::Error) {
|
||||
auto err = strerror(errno);
|
||||
atError("Failed to accept incoming connection: {}", err);
|
||||
}
|
||||
#else
|
||||
EResult res = LastWSAError();
|
||||
if (res == EResult::Error)
|
||||
|
||||
@@ -51,7 +51,6 @@ Sakura::SpriteFile* SpriteFileReader::readFile() {
|
||||
// which require data to be 32 byte aligned, or it causes some issues.
|
||||
// It's also convenient to have this, for later expansion.
|
||||
atUint32 reserved = readUint32();
|
||||
UNUSED(reserved);
|
||||
|
||||
// Next we have to load the textures
|
||||
// If we tried to add them one at a time to the sprite container
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include "utf8proc.h"
|
||||
#include "athena/utf8proc.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <functional>
|
||||
@@ -167,7 +167,7 @@ std::string wideToUtf8(std::wstring_view src) {
|
||||
utf8proc_uint8_t mb[4];
|
||||
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
||||
if (c < 0) {
|
||||
atWarning(FMT_STRING("invalid UTF-8 character while encoding"));
|
||||
atWarning("invalid UTF-8 character while encoding");
|
||||
return retval;
|
||||
}
|
||||
retval.append(reinterpret_cast<char*>(mb), c);
|
||||
@@ -183,7 +183,7 @@ std::wstring utf8ToWide(std::string_view src) {
|
||||
utf8proc_int32_t wc;
|
||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||
if (len < 0) {
|
||||
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||
atWarning("invalid UTF-8 character while decoding");
|
||||
return retval;
|
||||
}
|
||||
buf += len;
|
||||
|
||||
@@ -10,7 +10,7 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||
switch (origin) {
|
||||
case SeekOrigin::Begin:
|
||||
if (position < 0) {
|
||||
atError(FMT_STRING("Position outside stream bounds"));
|
||||
atError("Position outside stream bounds");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||
|
||||
case SeekOrigin::Current:
|
||||
if ((((atInt64)m_position + position) < 0)) {
|
||||
atError(FMT_STRING("Position outside stream bounds"));
|
||||
atError("Position outside stream bounds");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -36,13 +36,13 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||
|
||||
case SeekOrigin::End:
|
||||
if (((atInt64)m_data.size() - position) < 0) {
|
||||
atError(FMT_STRING("Position outside stream bounds"));
|
||||
atError("Position outside stream bounds");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((atUint64)position > m_data.size()) {
|
||||
atError(FMT_STRING("data exceeds vector size"));
|
||||
atError("data exceeds vector size");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||
|
||||
void VectorWriter::writeUBytes(const atUint8* data, atUint64 length) {
|
||||
if (!data) {
|
||||
atError(FMT_STRING("data cannnot be NULL"));
|
||||
atError("data cannnot be NULL");
|
||||
setError();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ bool WiiFile::isFile() const { return (m_type == WiiFile::File); }
|
||||
|
||||
void WiiFile::addChild(WiiFile* file) {
|
||||
if (!isDirectory()) {
|
||||
atWarning("{} is not a directory", filename());
|
||||
atWarning("{} is not a directory", m_filename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ static void square(atUint8* d, const atUint8* a) {
|
||||
|
||||
static void itInvert(atUint8* d, const atUint8* a, const atUint8* b, atUint32 j) {
|
||||
atUint8 t[30];
|
||||
memcpy(t, a, 32);
|
||||
memcpy(t, a, 30);
|
||||
while (j--) {
|
||||
square(d, t);
|
||||
memcpy(t, d, 30);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#if defined(GEKKO) || defined(__SWITCH__)
|
||||
#include "gekko_support.h"
|
||||
#include "athena/gekko_support.h"
|
||||
#define SYMLOOP_MAX 8
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
Reference in New Issue
Block a user