mirror of
https://github.com/libAthena/athena.git
synced 2025-12-08 13:15:05 +00:00
Compare commits
30 Commits
11b86d7634
...
update
| Author | SHA1 | Date | |
|---|---|---|---|
| 67d788ae4e | |||
| 4f8927d95c | |||
| 5c697c006f | |||
| f9545db293 | |||
| cee01a8df1 | |||
| 88b0ed137c | |||
| 50991752f8 | |||
| cce4b5e2c7 | |||
| fa346ace47 | |||
| c6046d9150 | |||
| 01970c7249 | |||
| f27a63f312 | |||
|
e13b498266
|
|||
|
066e3ae109
|
|||
|
644070d5f3
|
|||
| 2aa9a573a0 | |||
| 4bd9dfac61 | |||
| bc2ebaab88 | |||
| 6eec5760b3 | |||
| 96fa2d24ef | |||
| b0daee99fc | |||
| daf8bf0595 | |||
| 2aa5b76732 | |||
| 064839bad6 | |||
| 37206e5301 | |||
| 37c56eec07 | |||
| a4074e1a57 | |||
| da92db7356 | |||
| f02251ebf3 | |||
| 14e4d4e2ea |
142
.github/workflows/build.yml
vendored
142
.github/workflows/build.yml
vendored
@@ -4,31 +4,40 @@ on:
|
|||||||
push:
|
push:
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
|
env:
|
||||||
|
BUILDCACHE_VERSION: v0.28.3
|
||||||
|
BUILDCACHE_ACCURACY: STRICT
|
||||||
|
BUILDCACHE_MAX_CACHE_SIZE: 1073741824 # 1GiB
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-linux-x86_64:
|
build-linux-x86_64:
|
||||||
name: Build Linux (GCC x86_64)
|
name: Build Linux (GCC x86_64)
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: alpine:3.17
|
||||||
|
|
||||||
|
env:
|
||||||
|
LLVM_MAJOR: 15
|
||||||
|
BUILDCACHE_DIR: ${{github.workspace}}/.buildcache
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
apk add --no-cache git cmake ninja clang-dev clang-static llvm-dev llvm-static musl-dev \
|
||||||
|
gcc g++ libxml2-dev libxml2-static zlib-dev zlib-static
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt-get -y update
|
|
||||||
sudo apt-get -y install cmake ninja-build ccache llvm-11-dev libclang-11-dev clang-11
|
|
||||||
|
|
||||||
- name: Configure ccache
|
|
||||||
uses: hendrikmuhs/ccache-action@v1
|
|
||||||
with:
|
|
||||||
key: ubuntu-20.04-gcc
|
|
||||||
max-size: 1G
|
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: |
|
run: |
|
||||||
cmake -B build . -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DClang_DIR=/usr/lib/cmake/clang-11 \
|
cmake -B build . -GNinja \
|
||||||
-DATDNA_DYNAMIC_LLVM=OFF -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
|
||||||
|
-DATDNA_DYNAMIC_LLVM:BOOL=OFF \
|
||||||
|
-DATDNA_STATIC:BOOL=ON \
|
||||||
|
-DCMAKE_CXX_FLAGS:STRING="-I/usr/lib/llvm15/include -Dstat64=stat"
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build build --target package --verbose
|
run: cmake --build build --target package --verbose
|
||||||
@@ -46,7 +55,12 @@ jobs:
|
|||||||
|
|
||||||
build-linux-aarch64:
|
build-linux-aarch64:
|
||||||
name: Build Linux (GCC aarch64)
|
name: Build Linux (GCC aarch64)
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
|
if: 'false'
|
||||||
|
|
||||||
|
env:
|
||||||
|
LLVM_MAJOR: 15
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
@@ -57,16 +71,19 @@ jobs:
|
|||||||
name: Build & test
|
name: Build & test
|
||||||
with:
|
with:
|
||||||
arch: aarch64
|
arch: aarch64
|
||||||
distro: ubuntu20.04
|
base_image: --platform=linux/arm64/v8 alpine:3.17
|
||||||
githubToken: ${{github.token}}
|
githubToken: ${{github.token}}
|
||||||
dockerRunArgs: |
|
dockerRunArgs: |
|
||||||
--volume "${PWD}:/workspace"
|
--volume "${PWD}:/workspace"
|
||||||
install: |
|
install: |
|
||||||
apt-get -y update
|
apk add --no-cache git cmake ninja clang-dev clang-static llvm-dev llvm-static musl-dev \
|
||||||
apt-get -y install build-essential cmake ninja-build llvm-11-dev libclang-11-dev clang-11
|
gcc g++ libxml2-dev libxml2-static zlib-dev zlib-static
|
||||||
run: |
|
run: |
|
||||||
cmake -B build . -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
cmake -B build . -GNinja \
|
||||||
-DClang_DIR=/usr/lib/cmake/clang-11 -DATDNA_DYNAMIC_LLVM=OFF
|
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
|
||||||
|
-DATDNA_DYNAMIC_LLVM:BOOL=OFF \
|
||||||
|
-DATDNA_STATIC:BOOL=ON \
|
||||||
|
-DCMAKE_CXX_FLAGS:STRING="-I/usr/lib/llvm15/include -Dstat64=stat"
|
||||||
cmake --build build --target package --verbose
|
cmake --build build --target package --verbose
|
||||||
build/atdna-test
|
build/atdna-test
|
||||||
|
|
||||||
@@ -79,7 +96,13 @@ jobs:
|
|||||||
|
|
||||||
build-macos-universal:
|
build-macos-universal:
|
||||||
name: Build macOS (AppleClang universal)
|
name: Build macOS (AppleClang universal)
|
||||||
runs-on: macos-10.15
|
runs-on: macos-13
|
||||||
|
|
||||||
|
env:
|
||||||
|
LLVM_MAJOR: 15
|
||||||
|
LLVM_VERSION: 15.0.7_2
|
||||||
|
BUILDCACHE_DIR: ${{github.workspace}}/.buildcache
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
@@ -89,26 +112,39 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
brew update
|
brew update
|
||||||
brew install ninja ccache
|
brew install ninja
|
||||||
# universal clang+llvm from macports
|
|
||||||
curl -LSfs https://axiodl.com/files/clang-11-11.1.0_1.mpkg -o /tmp/clang-11-11.1.0_1.mpkg
|
|
||||||
sudo installer -pkg /tmp/clang-11-11.1.0_1.mpkg -target /
|
|
||||||
|
|
||||||
- name: Configure ccache
|
# universal clang+llvm from macports
|
||||||
uses: hendrikmuhs/ccache-action@v1
|
curl -LSfs https://axiodl.com/files/clang-$LLVM_MAJOR-$LLVM_VERSION.mpkg -o /tmp/clang-$LLVM_MAJOR-$LLVM_VERSION.mpkg
|
||||||
|
sudo installer -pkg /tmp/clang-$LLVM_MAJOR-$LLVM_VERSION.mpkg -target /
|
||||||
|
|
||||||
|
# setup buildcache
|
||||||
|
curl -LSfs https://github.com/mbitsnbites/buildcache/releases/download/$BUILDCACHE_VERSION/buildcache-macos.zip -o /tmp/buildcache-macos.zip
|
||||||
|
unzip /tmp/buildcache-macos.zip -d "$RUNNER_WORKSPACE"
|
||||||
|
echo "$RUNNER_WORKSPACE"/buildcache/bin >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- name: Restore buildcache
|
||||||
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
key: macos-10.15-appleclang
|
path: ${{env.BUILDCACHE_DIR}}
|
||||||
max-size: 1G
|
key: buildcache-macos-12
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: |
|
run: |
|
||||||
cmake -B build . -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \
|
cmake -B build . -GNinja \
|
||||||
-DLLVM_ROOT_DIR=/opt/local/libexec/llvm-11 \
|
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
|
||||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
-DCMAKE_OSX_ARCHITECTURES:STRING="x86_64;arm64" \
|
||||||
|
-DCMAKE_PREFIX_PATH:PATH=/opt/local \
|
||||||
|
-DLLVM_ROOT_DIR:PATH=/opt/local/libexec/llvm-$LLVM_MAJOR \
|
||||||
|
-DCMAKE_C_COMPILER_LAUNCHER:STRING=buildcache \
|
||||||
|
-DCMAKE_CXX_COMPILER_LAUNCHER:STRING=buildcache
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build build --target package --verbose
|
run: cmake --build build --target package --verbose
|
||||||
|
|
||||||
|
- name: Print buildcache stats
|
||||||
|
run: buildcache -s
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
working-directory: build
|
working-directory: build
|
||||||
run: ./atdna-test
|
run: ./atdna-test
|
||||||
@@ -122,9 +158,12 @@ jobs:
|
|||||||
|
|
||||||
build-win32-amd64:
|
build-win32-amd64:
|
||||||
name: Build Windows (MSVC AMD64)
|
name: Build Windows (MSVC AMD64)
|
||||||
runs-on: windows-2019
|
runs-on: windows-2022
|
||||||
|
|
||||||
env:
|
env:
|
||||||
LLVM_VERSION: 10.0.1
|
LLVM_VERSION: 15.0.7
|
||||||
|
BUILDCACHE_DIR: C:\buildcache
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
@@ -133,28 +172,46 @@ jobs:
|
|||||||
|
|
||||||
- name: Install LLVM
|
- name: Install LLVM
|
||||||
run: |
|
run: |
|
||||||
$TempDir = "$env:RUNNER_WORKSPACE\temp"
|
$TempDir = "C:\temp" # C: has more space
|
||||||
$Filename = "LLVM-$env:LLVM_VERSION-win64.exe"
|
$Filename = "vcpkg-llvm-$env:LLVM_VERSION-full.7z"
|
||||||
New-Item -Path "$TempDir" -ItemType Directory -ea 0
|
New-Item -Path "$TempDir" -ItemType Directory -ea 0
|
||||||
(New-Object Net.WebClient).DownloadFile("https://axiodl.com/files/$Filename", "$TempDir\$Filename")
|
(New-Object Net.WebClient).DownloadFile("https://axiodl.com/files/$Filename", "$TempDir\$Filename")
|
||||||
Start-Process "$TempDir\$Filename" -ArgumentList "/S /D=$env:RUNNER_WORKSPACE\LLVM" -Wait
|
7z x "-o$TempDir" -aos "$TempDir\$Filename"
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: choco install ninja
|
run: |
|
||||||
|
choco install ninja
|
||||||
|
|
||||||
|
# set up buildcache
|
||||||
|
$TempDir = "$env:RUNNER_WORKSPACE\temp"
|
||||||
|
New-Item -Path "$TempDir" -ItemType Directory -ea 0
|
||||||
|
(New-Object Net.WebClient).DownloadFile("https://github.com/mbitsnbites/buildcache/releases/download/$env:BUILDCACHE_VERSION/buildcache-windows.zip", "$TempDir\buildcache.zip")
|
||||||
|
Expand-Archive -LiteralPath "$TempDir\buildcache.zip" -DestinationPath "$TempDir"
|
||||||
|
echo "$TempDir\buildcache\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
|
||||||
|
- name: Restore buildcache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ${{env.BUILDCACHE_DIR}}
|
||||||
|
key: buildcache-windows-2019-msvc-amd64
|
||||||
|
|
||||||
- name: Enable Visual Studio environment
|
- name: Enable Visual Studio environment
|
||||||
uses: ilammy/msvc-dev-cmd@v1
|
uses: ilammy/msvc-dev-cmd@v1
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: |
|
run: |
|
||||||
$workspace = $env:RUNNER_WORKSPACE -replace '\\', '/'
|
cmake -B build . -GNinja `
|
||||||
cmake -B build . -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo `
|
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo `
|
||||||
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded `
|
-DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreaded `
|
||||||
-DLLVM_ROOT_DIR="$workspace/LLVM"
|
-DCMAKE_TOOLCHAIN_FILE:PATH="C:\temp\vcpkg-llvm-$env:LLVM_VERSION\scripts\buildsystems\vcpkg.cmake" `
|
||||||
|
-DVCPKG_TARGET_TRIPLET:STRING=x64-windows-static
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build build --target package --verbose
|
run: cmake --build build --target package --verbose
|
||||||
|
|
||||||
|
- name: Print buildcache stats
|
||||||
|
run: buildcache -s
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
working-directory: build
|
working-directory: build
|
||||||
run: ./atdna-test.exe
|
run: ./atdna-test.exe
|
||||||
@@ -169,6 +226,7 @@ jobs:
|
|||||||
release:
|
release:
|
||||||
name: Release
|
name: Release
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
if:
|
if:
|
||||||
contains('
|
contains('
|
||||||
refs/heads/master
|
refs/heads/master
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -21,4 +21,5 @@ PKGBUILD
|
|||||||
/build
|
/build
|
||||||
/out
|
/out
|
||||||
/cmake-build-*
|
/cmake-build-*
|
||||||
/.idea
|
/.idea
|
||||||
|
/.buildcache
|
||||||
|
|||||||
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,6 +1,6 @@
|
|||||||
[submodule "extern/lzokay"]
|
[submodule "extern/lzokay"]
|
||||||
path = extern/lzokay
|
path = extern/lzokay
|
||||||
url = https://github.com/jackoalan/lzokay.git
|
url = https://github.com/AxioDL/lzokay.git
|
||||||
branch = master
|
branch = master
|
||||||
[submodule "extern/fmt"]
|
[submodule "extern/fmt"]
|
||||||
path = extern/fmt
|
path = extern/fmt
|
||||||
|
|||||||
@@ -2,32 +2,34 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17
|
|||||||
# Set MSVC runtime library flags from CMAKE_MSVC_RUNTIME_LIBRARY
|
# Set MSVC runtime library flags from CMAKE_MSVC_RUNTIME_LIBRARY
|
||||||
cmake_policy(SET CMP0091 NEW)
|
cmake_policy(SET CMP0091 NEW)
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# Athena Version #
|
# Athena Version #
|
||||||
##################
|
##################
|
||||||
find_package(Git)
|
find_package(Git)
|
||||||
if (GIT_FOUND)
|
if (GIT_FOUND)
|
||||||
# make sure version information gets re-run when the current Git HEAD changes
|
# make sure version information gets re-run when the current Git HEAD changes
|
||||||
execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --git-path HEAD
|
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --git-path HEAD
|
||||||
OUTPUT_VARIABLE athena_git_head_filename
|
OUTPUT_VARIABLE athena_git_head_filename
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${athena_git_head_filename}")
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${athena_git_head_filename}")
|
||||||
|
|
||||||
execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --symbolic-full-name HEAD
|
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --symbolic-full-name HEAD
|
||||||
OUTPUT_VARIABLE athena_git_head_symbolic
|
OUTPUT_VARIABLE athena_git_head_symbolic
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
COMMAND ${GIT_EXECUTABLE} rev-parse --git-path ${athena_git_head_symbolic}
|
COMMAND ${GIT_EXECUTABLE} rev-parse --git-path ${athena_git_head_symbolic}
|
||||||
OUTPUT_VARIABLE athena_git_head_symbolic_filename
|
OUTPUT_VARIABLE athena_git_head_symbolic_filename
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${athena_git_head_symbolic_filename}")
|
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${athena_git_head_symbolic_filename}")
|
||||||
|
|
||||||
# defines ATHENA_WC_REVISION
|
# defines ATHENA_WC_REVISION
|
||||||
execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
||||||
OUTPUT_VARIABLE ATHENA_WC_REVISION
|
OUTPUT_VARIABLE ATHENA_WC_REVISION
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
# defines ATHENA_WC_DESCRIBE
|
# defines ATHENA_WC_DESCRIBE
|
||||||
execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --tag --long --dirty --exclude latest
|
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} describe --tag --long --dirty --exclude latest
|
||||||
OUTPUT_VARIABLE ATHENA_WC_DESCRIBE
|
OUTPUT_VARIABLE ATHENA_WC_DESCRIBE
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
@@ -35,11 +37,11 @@ if (GIT_FOUND)
|
|||||||
string(REGEX REPLACE "(-0)?-[^-]+((-dirty)?)$" "\\2" ATHENA_WC_DESCRIBE "${ATHENA_WC_DESCRIBE}")
|
string(REGEX REPLACE "(-0)?-[^-]+((-dirty)?)$" "\\2" ATHENA_WC_DESCRIBE "${ATHENA_WC_DESCRIBE}")
|
||||||
|
|
||||||
# defines ATHENA_WC_BRANCH
|
# defines ATHENA_WC_BRANCH
|
||||||
execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
|
||||||
OUTPUT_VARIABLE ATHENA_WC_BRANCH
|
OUTPUT_VARIABLE ATHENA_WC_BRANCH
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
# defines ATHENA_WC_DATE
|
# defines ATHENA_WC_DATE
|
||||||
execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} log -1 --format=%ad
|
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} log -1 --format=%ad
|
||||||
OUTPUT_VARIABLE ATHENA_WC_DATE
|
OUTPUT_VARIABLE ATHENA_WC_DATE
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
else ()
|
else ()
|
||||||
@@ -61,12 +63,17 @@ else ()
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Add version information to CI environment variables
|
# Add version information to CI environment variables
|
||||||
if(DEFINED ENV{GITHUB_ENV})
|
if(DEFINED ENV{GITHUB_ENV} AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||||
file(APPEND "$ENV{GITHUB_ENV}" "ATHENA_VERSION=${ATHENA_WC_DESCRIBE}")
|
file(APPEND "$ENV{GITHUB_ENV}" "ATHENA_VERSION=${ATHENA_WC_DESCRIBE}\n")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(athena VERSION ${ATHENA_VERSION} LANGUAGES C CXX)
|
project(athena VERSION ${ATHENA_VERSION} LANGUAGES C CXX)
|
||||||
|
|
||||||
|
if (ATDNA_STATIC)
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||||
|
add_link_options(-static)
|
||||||
|
endif ()
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
# Shaddup MSVC
|
# Shaddup MSVC
|
||||||
add_compile_definitions(UNICODE=1 _UNICODE=1 __SSE__=1
|
add_compile_definitions(UNICODE=1 _UNICODE=1 __SSE__=1
|
||||||
@@ -222,11 +229,11 @@ endif()
|
|||||||
|
|
||||||
target_include_directories(athena-core PUBLIC
|
target_include_directories(athena-core PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<BUILD_INTERFACE:${ZLIB_INCLUDE_DIR}>
|
|
||||||
)
|
)
|
||||||
target_link_libraries(athena-core PUBLIC
|
target_link_libraries(athena-core PUBLIC
|
||||||
athena-libyaml
|
athena-libyaml
|
||||||
fmt
|
fmt
|
||||||
|
$<BUILD_INTERFACE:${ZLIB_LIBRARIES}>
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(athena-sakura EXCLUDE_FROM_ALL
|
add_library(athena-sakura EXCLUDE_FROM_ALL
|
||||||
@@ -332,8 +339,11 @@ endforeach()
|
|||||||
# Define installs
|
# Define installs
|
||||||
install(DIRECTORY include/athena DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT athena)
|
install(DIRECTORY include/athena DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT athena)
|
||||||
install(DIRECTORY extern/fmt/include/fmt DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT athena)
|
install(DIRECTORY extern/fmt/include/fmt DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT athena)
|
||||||
install(TARGETS athena-core fmt
|
if (ATHENA_ZLIB)
|
||||||
DESTINATION ${INSTALL_LIB_DIR} EXPORT AthenaTargets COMPONENT athena)
|
set(ZLIB_INSTALL ${ZLIB_LIBRARIES})
|
||||||
|
endif ()
|
||||||
|
install(TARGETS athena-core fmt ${ZLIB_INSTALL}
|
||||||
|
DESTINATION ${INSTALL_LIB_DIR} EXPORT AthenaTargets COMPONENT athena)
|
||||||
if(WIN32 AND NOT CYGWIN)
|
if(WIN32 AND NOT CYGWIN)
|
||||||
install(FILES Athena.ico DESTINATION ${INSTALL_LIB_DIR} COMPONENT athena)
|
install(FILES Athena.ico DESTINATION ${INSTALL_LIB_DIR} COMPONENT athena)
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
@@ -348,7 +358,7 @@ endif()
|
|||||||
##################
|
##################
|
||||||
|
|
||||||
# Add all targets to the build-tree export set
|
# Add all targets to the build-tree export set
|
||||||
export(TARGETS athena-core athena-libyaml fmt FILE "${CMAKE_CURRENT_BINARY_DIR}/AthenaTargets.cmake")
|
export(TARGETS athena-core athena-libyaml fmt ${ZLIB_LIBRARIES} FILE "${CMAKE_CURRENT_BINARY_DIR}/AthenaTargets.cmake")
|
||||||
|
|
||||||
# Export the package for use from the build-tree
|
# Export the package for use from the build-tree
|
||||||
# (this registers the build-tree with a global CMake-registry)
|
# (this registers the build-tree with a global CMake-registry)
|
||||||
|
|||||||
@@ -31,10 +31,11 @@ else()
|
|||||||
option(ATDNA_DYNAMIC_LLVM "Use dynamic library targets when linking LLVM" OFF)
|
option(ATDNA_DYNAMIC_LLVM "Use dynamic library targets when linking LLVM" OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND CLANG_LIBS clangTooling)
|
set(CLANG_LIBS "")
|
||||||
set(LLVM_LIBS "")
|
set(LLVM_LIBS "")
|
||||||
|
|
||||||
if (ATDNA_DYNAMIC_LLVM)
|
if (ATDNA_DYNAMIC_LLVM)
|
||||||
|
list(APPEND CLANG_LIBS clang-cpp)
|
||||||
list(APPEND LLVM_LIBS LLVM)
|
list(APPEND LLVM_LIBS LLVM)
|
||||||
else()
|
else()
|
||||||
function(recursive_remove_library target library)
|
function(recursive_remove_library target library)
|
||||||
@@ -51,14 +52,34 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
# Add LLVM static libs
|
||||||
|
list(APPEND CLANG_LIBS clangTooling)
|
||||||
|
list(APPEND LLVM_LIBS LLVMFrontendOpenMP LLVMOption)
|
||||||
|
if (LLVM_VERSION_MAJOR GREATER_EQUAL 15)
|
||||||
|
list(APPEND LLVM_LIBS LLVMWindowsDriver)
|
||||||
|
endif ()
|
||||||
# Remove LLVM dynamic library from Clang dependencies
|
# Remove LLVM dynamic library from Clang dependencies
|
||||||
foreach (lib ${CLANG_LIBS})
|
foreach (lib ${CLANG_LIBS})
|
||||||
recursive_remove_library(${lib} LLVM)
|
recursive_remove_library(${lib} LLVM)
|
||||||
endforeach ()
|
endforeach ()
|
||||||
# Add LLVM static libs
|
|
||||||
list(APPEND LLVM_LIBS LLVMFrontendOpenMP LLVMOption)
|
|
||||||
# Hack around link order issues
|
# Hack around link order issues
|
||||||
target_link_libraries(clangAST INTERFACE LLVMFrontendOpenMP)
|
target_link_libraries(clangAST INTERFACE LLVMFrontendOpenMP)
|
||||||
|
|
||||||
|
# Fix linking diaguids on Windows
|
||||||
|
if (WIN32 AND TARGET LLVMDebugInfoPDB)
|
||||||
|
find_package(DiaSDK REQUIRED)
|
||||||
|
|
||||||
|
get_target_property(target_dependencies LLVMDebugInfoPDB INTERFACE_LINK_LIBRARIES)
|
||||||
|
list(TRANSFORM target_dependencies REPLACE ".*diaguids.*" "${DIASDK_GUIDS_LIBRARY}")
|
||||||
|
set_property(TARGET LLVMDebugInfoPDB PROPERTY INTERFACE_LINK_LIBRARIES "${target_dependencies}")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Allow static linking against zstd
|
||||||
|
if (ATDNA_STATIC)
|
||||||
|
get_target_property(target_dependencies LLVMSupport INTERFACE_LINK_LIBRARIES)
|
||||||
|
list(TRANSFORM target_dependencies REPLACE "zstd::libzstd_shared" "zstd::libzstd_static")
|
||||||
|
set_property(TARGET LLVMSupport PROPERTY INTERFACE_LINK_LIBRARIES "${target_dependencies}")
|
||||||
|
endif ()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Offer the user the choice of overriding the installation directories
|
# Offer the user the choice of overriding the installation directories
|
||||||
@@ -85,20 +106,39 @@ endif()
|
|||||||
# ATDNA target
|
# ATDNA target
|
||||||
add_executable(atdna main.cpp test.hpp ${PLAT_SRCS})
|
add_executable(atdna main.cpp test.hpp ${PLAT_SRCS})
|
||||||
target_link_libraries(atdna ${CLANG_LIBS} ${LLVM_LIBS})
|
target_link_libraries(atdna ${CLANG_LIBS} ${LLVM_LIBS})
|
||||||
|
if (APPLE)
|
||||||
|
set(ATDNA_ARGV0 clang-tool)
|
||||||
|
else ()
|
||||||
|
set(ATDNA_ARGV0 "${LLVM_TOOLS_BINARY_DIR}/clang-tool")
|
||||||
|
endif ()
|
||||||
target_compile_definitions(atdna PRIVATE
|
target_compile_definitions(atdna PRIVATE
|
||||||
INSTALL_PREFIX=${ABS_INSTALL_BIN_DIR}
|
INSTALL_PREFIX=${ABS_INSTALL_BIN_DIR}
|
||||||
__STDC_LIMIT_MACROS=1
|
__STDC_LIMIT_MACROS=1
|
||||||
__STDC_CONSTANT_MACROS=1
|
__STDC_CONSTANT_MACROS=1
|
||||||
ATDNA_ARGV0=clang-tool)
|
ATDNA_ARGV0=${ATDNA_ARGV0})
|
||||||
target_include_directories(atdna PRIVATE ${CLANG_INCLUDE_DIRS})
|
target_include_directories(atdna PRIVATE ${CLANG_INCLUDE_DIRS})
|
||||||
# Clang 10.0.x headers currently broken with C++20
|
# Clang 10.0.x headers currently broken with C++20
|
||||||
set_property(TARGET atdna PROPERTY CXX_STANDARD 17)
|
set_property(TARGET atdna PROPERTY CXX_STANDARD 17)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# Allow linking against release-built LLVM libraries
|
if (VCPKG_TOOLCHAIN)
|
||||||
target_compile_options(atdna PRIVATE /GR- /D_ITERATOR_DEBUG_LEVEL=0)
|
# Assumes static build of LLVM
|
||||||
set_property(TARGET atdna PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
|
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||||
else()
|
set_property(TARGET atdna PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDebug")
|
||||||
|
else ()
|
||||||
|
set_property(TARGET atdna PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded")
|
||||||
|
endif ()
|
||||||
|
else ()
|
||||||
|
# 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")
|
||||||
|
endif ()
|
||||||
|
else ()
|
||||||
target_compile_options(atdna PRIVATE -fno-rtti -fvisibility=hidden -Wno-error)
|
target_compile_options(atdna PRIVATE -fno-rtti -fvisibility=hidden -Wno-error)
|
||||||
|
if (METAFORCE_ASAN AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
# On Linux, we need to compile without ASAN; explicitly disable it here
|
||||||
|
target_compile_options(atdna PRIVATE -stdlib=libstdc++ -fno-sanitize=address)
|
||||||
|
target_link_options(atdna PRIVATE -stdlib=libstdc++ -fno-sanitize=address)
|
||||||
|
endif ()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Define installs
|
# Define installs
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# - Config file for the atdna package
|
# - Config file for the atdna package
|
||||||
|
|
||||||
# Compute paths
|
# Compute paths
|
||||||
get_filename_component(ATDNA_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
get_filename_component(ATDNA_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
|
|
||||||
# Our library dependencies (contains definitions for IMPORTED targets)
|
# Our library dependencies (contains definitions for IMPORTED targets)
|
||||||
if(NOT TARGET atdna AND NOT atdna_BINARY_DIR)
|
if(NOT TARGET atdna AND NOT atdna_BINARY_DIR)
|
||||||
include("${ATDNA_CMAKE_DIR}/atdnaTargets.cmake")
|
include("${ATDNA_CMAKE_DIR}/atdnaTargets.cmake")
|
||||||
@@ -26,7 +26,9 @@ function(atdna out)
|
|||||||
get_property(incdirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
|
get_property(incdirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
|
||||||
set(inccli "")
|
set(inccli "")
|
||||||
foreach(dir ${incdirs})
|
foreach(dir ${incdirs})
|
||||||
list(APPEND inccli "-I${dir}")
|
if (NOT dir MATCHES ".*emscripten.*")
|
||||||
|
list(APPEND inccli "-I${dir}")
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Get local defines for atdna
|
# Get local defines for atdna
|
||||||
|
|||||||
@@ -92,6 +92,18 @@ function(atdna out incdirs cdefs)
|
|||||||
list(APPEND ins_impdeps ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
|
list(APPEND ins_impdeps ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
set(inccli "")
|
||||||
|
foreach(dir ${incdirs})
|
||||||
|
if (NOT dir MATCHES ".*emscripten.*")
|
||||||
|
list(APPEND inccli "-I${dir}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(cdefcli "")
|
||||||
|
foreach(def ${cdefs})
|
||||||
|
list(APPEND cdefcli "-D${def}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
# MS extra
|
# MS extra
|
||||||
unset(extraargs)
|
unset(extraargs)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
@@ -124,8 +136,7 @@ function(atdna out incdirs cdefs)
|
|||||||
# Use Ninja's DEPFILE parser in cooperation with atdna
|
# Use Ninja's DEPFILE parser in cooperation with atdna
|
||||||
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
|
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
|
||||||
ARGS ${extraargs} -o ${out_rel} -MD -MT ${out_rel} -MF ${out_rel}.d
|
ARGS ${extraargs} -o ${out_rel} -MD -MT ${out_rel} -MF ${out_rel}.d
|
||||||
"$<$<BOOL:${incdirs}>:-I$<JOIN:${incdirs},;-I>>"
|
${inccli} ${cdefcli}
|
||||||
"$<$<BOOL:${cdefs}>:-D$<JOIN:${cdefs},;-D>>"
|
|
||||||
"-I${athena_SOURCE_DIR}/include" ${ins}
|
"-I${athena_SOURCE_DIR}/include" ${ins}
|
||||||
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
|
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
|
||||||
DEPFILE "${CMAKE_CURRENT_BINARY_DIR}/${out}.d"
|
DEPFILE "${CMAKE_CURRENT_BINARY_DIR}/${out}.d"
|
||||||
@@ -136,8 +147,7 @@ function(atdna out incdirs cdefs)
|
|||||||
# Use CMake's built-in dependency scanner for makefile targets
|
# Use CMake's built-in dependency scanner for makefile targets
|
||||||
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
|
add_custom_command(OUTPUT ${out} COMMAND $<TARGET_FILE:atdna>
|
||||||
ARGS ${extraargs} -o ${out_rel}
|
ARGS ${extraargs} -o ${out_rel}
|
||||||
"$<$<BOOL:${incdirs}>:-I$<JOIN:${incdirs},;-I>>"
|
${inccli} ${cdefcli}
|
||||||
"$<$<BOOL:${cdefs}>:-D$<JOIN:${cdefs},;-D>>"
|
|
||||||
"-I${athena_SOURCE_DIR}/include" ${ins}
|
"-I${athena_SOURCE_DIR}/include" ${ins}
|
||||||
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
|
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ static llvm::cl::list<std::string> IncludeSearchPaths("I", llvm::cl::desc("Heade
|
|||||||
|
|
||||||
static llvm::cl::list<std::string> SystemIncludeSearchPaths("isystem", llvm::cl::desc("System Header search path"));
|
static llvm::cl::list<std::string> SystemIncludeSearchPaths("isystem", llvm::cl::desc("System Header search path"));
|
||||||
|
|
||||||
static llvm::cl::list<std::string> StandardCXXLibISystem("stdlib++-isystem", llvm::cl::desc("Standard C++ library search path"));
|
static llvm::cl::list<std::string> StandardCXXLibISystem("stdlib++-isystem",
|
||||||
|
llvm::cl::desc("Standard C++ library search path"));
|
||||||
|
|
||||||
static llvm::cl::opt<std::string> StandardCXXLib("stdlib", llvm::cl::desc("Standard C++ library"));
|
static llvm::cl::opt<std::string> StandardCXXLib("stdlib", llvm::cl::desc("Standard C++ library"));
|
||||||
|
|
||||||
@@ -188,7 +189,12 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
|||||||
for (clang::Attr* attr : field->attrs()) {
|
for (clang::Attr* attr : field->attrs()) {
|
||||||
if (clang::AnnotateAttr* annot = clang::dyn_cast_or_null<clang::AnnotateAttr>(attr)) {
|
if (clang::AnnotateAttr* annot = clang::dyn_cast_or_null<clang::AnnotateAttr>(attr)) {
|
||||||
llvm::StringRef textRef = annot->getAnnotation();
|
llvm::StringRef textRef = annot->getAnnotation();
|
||||||
if (textRef.startswith_lower("rcrc32=")) {
|
#if LLVM_VERSION_MAJOR >= 13
|
||||||
|
if (textRef.startswith_insensitive("rcrc32="))
|
||||||
|
#else
|
||||||
|
if (textRef.startswith_lower("rcrc32="))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
unsigned long num = strtoul(textRef.data() + 7, nullptr, 16);
|
unsigned long num = strtoul(textRef.data() + 7, nullptr, 16);
|
||||||
std::string tmpS;
|
std::string tmpS;
|
||||||
llvm::raw_string_ostream s(tmpS);
|
llvm::raw_string_ostream s(tmpS);
|
||||||
@@ -256,7 +262,11 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
|||||||
if (needsComma)
|
if (needsComma)
|
||||||
qualType += ", ";
|
qualType += ", ";
|
||||||
llvm::raw_string_ostream OS(qualType);
|
llvm::raw_string_ostream OS(qualType);
|
||||||
|
#if LLVM_VERSION_MAJOR >= 13
|
||||||
|
arg.print(context.getPrintingPolicy(), OS, false);
|
||||||
|
#else
|
||||||
arg.print(context.getPrintingPolicy(), OS);
|
arg.print(context.getPrintingPolicy(), OS);
|
||||||
|
#endif
|
||||||
needsComma = true;
|
needsComma = true;
|
||||||
}
|
}
|
||||||
qualType += '>';
|
qualType += '>';
|
||||||
@@ -279,7 +289,10 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
|||||||
templateStmt += ", ";
|
templateStmt += ", ";
|
||||||
qualType += ", ";
|
qualType += ", ";
|
||||||
}
|
}
|
||||||
templateStmt += nonTypeParm->getType().getAsString(context.getPrintingPolicy()).append(1, ' ').append(nonTypeParm->getName().str());
|
templateStmt += nonTypeParm->getType()
|
||||||
|
.getAsString(context.getPrintingPolicy())
|
||||||
|
.append(1, ' ')
|
||||||
|
.append(nonTypeParm->getName().str());
|
||||||
qualType += nonTypeParm->getName();
|
qualType += nonTypeParm->getName();
|
||||||
needsComma = true;
|
needsComma = true;
|
||||||
}
|
}
|
||||||
@@ -326,7 +339,11 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
|||||||
if (needsComma)
|
if (needsComma)
|
||||||
specializations.back().first += ", ";
|
specializations.back().first += ", ";
|
||||||
llvm::raw_string_ostream OS(specializations.back().first);
|
llvm::raw_string_ostream OS(specializations.back().first);
|
||||||
|
#if LLVM_VERSION_MAJOR >= 13
|
||||||
|
arg.print(context.getPrintingPolicy(), OS, false);
|
||||||
|
#else
|
||||||
arg.print(context.getPrintingPolicy(), OS);
|
arg.print(context.getPrintingPolicy(), OS);
|
||||||
|
#endif
|
||||||
needsComma = true;
|
needsComma = true;
|
||||||
}
|
}
|
||||||
specializations.back().first += '>';
|
specializations.back().first += '>';
|
||||||
@@ -342,7 +359,12 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
|||||||
for (clang::Attr* attr : rec->attrs()) {
|
for (clang::Attr* attr : rec->attrs()) {
|
||||||
if (clang::AnnotateAttr* annot = clang::dyn_cast_or_null<clang::AnnotateAttr>(attr)) {
|
if (clang::AnnotateAttr* annot = clang::dyn_cast_or_null<clang::AnnotateAttr>(attr)) {
|
||||||
llvm::StringRef textRef = annot->getAnnotation();
|
llvm::StringRef textRef = annot->getAnnotation();
|
||||||
if (textRef.startswith_lower("specparms=")) {
|
#if LLVM_VERSION_MAJOR >= 13
|
||||||
|
if (textRef.startswith_insensitive("specparms="))
|
||||||
|
#else
|
||||||
|
if (textRef.startswith_lower("specparms="))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
llvm::SmallVector<llvm::StringRef, 16> specParms;
|
llvm::SmallVector<llvm::StringRef, 16> specParms;
|
||||||
textRef.substr(10).split(specParms, ',');
|
textRef.substr(10).split(specParms, ',');
|
||||||
int numTuples = int(specParms.size()) / numParms;
|
int numTuples = int(specParms.size()) / numParms;
|
||||||
@@ -611,7 +633,13 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
|||||||
llvm::raw_string_ostream strStream(sizeExprStr);
|
llvm::raw_string_ostream strStream(sizeExprStr);
|
||||||
argExpr->printPretty(strStream, nullptr, context.getPrintingPolicy());
|
argExpr->printPretty(strStream, nullptr, context.getPrintingPolicy());
|
||||||
} else if (GetIntegerConstantExpr(expr, sizeLiteral, context)) {
|
} else if (GetIntegerConstantExpr(expr, sizeLiteral, context)) {
|
||||||
|
#if LLVM_VERSION_MAJOR >= 13
|
||||||
|
llvm::SmallVector<char> strStream;
|
||||||
|
sizeLiteral.toString(strStream, 10);
|
||||||
|
sizeExprStr = std::string(strStream.begin(), strStream.end());
|
||||||
|
#else
|
||||||
sizeExprStr = sizeLiteral.toString(10);
|
sizeExprStr = sizeLiteral.toString(10);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -653,7 +681,13 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
|||||||
llvm::raw_string_ostream strStream2(sizeExprStr);
|
llvm::raw_string_ostream strStream2(sizeExprStr);
|
||||||
argExpr->printPretty(strStream2, nullptr, context.getPrintingPolicy());
|
argExpr->printPretty(strStream2, nullptr, context.getPrintingPolicy());
|
||||||
} else if (GetIntegerConstantExpr(expr, sizeLiteral, context)) {
|
} else if (GetIntegerConstantExpr(expr, sizeLiteral, context)) {
|
||||||
|
#if LLVM_VERSION_MAJOR >= 13
|
||||||
|
llvm::SmallVector<char> strStream;
|
||||||
|
sizeLiteral.toString(strStream, 10);
|
||||||
|
sizeExprStr = std::string(strStream.begin(), strStream.end());
|
||||||
|
#else
|
||||||
sizeExprStr = sizeLiteral.toString(10);
|
sizeExprStr = sizeLiteral.toString(10);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else if (idx == 1) {
|
} else if (idx == 1) {
|
||||||
defaultEndian = false;
|
defaultEndian = false;
|
||||||
@@ -700,7 +734,13 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
|||||||
llvm::raw_string_ostream strStream(offsetExprStr);
|
llvm::raw_string_ostream strStream(offsetExprStr);
|
||||||
argExpr->printPretty(strStream, nullptr, context.getPrintingPolicy());
|
argExpr->printPretty(strStream, nullptr, context.getPrintingPolicy());
|
||||||
} else if (GetIntegerConstantExpr(expr, offsetLiteral, context)) {
|
} else if (GetIntegerConstantExpr(expr, offsetLiteral, context)) {
|
||||||
|
#if LLVM_VERSION_MAJOR >= 13
|
||||||
|
llvm::SmallVector<char> strStream;
|
||||||
|
offsetLiteral.toString(strStream, 10);
|
||||||
|
offsetExprStr = std::string(strStream.begin(), strStream.end());
|
||||||
|
#else
|
||||||
offsetExprStr = offsetLiteral.toString(10);
|
offsetExprStr = offsetLiteral.toString(10);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
clang::APValue result;
|
clang::APValue result;
|
||||||
@@ -765,8 +805,15 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
|||||||
|
|
||||||
const int64_t alignVal = align.getSExtValue();
|
const int64_t alignVal = align.getSExtValue();
|
||||||
if (alignVal) {
|
if (alignVal) {
|
||||||
|
#if LLVM_VERSION_MAJOR >= 13
|
||||||
|
llvm::SmallVector<char> alignStream;
|
||||||
|
align.toString(alignStream, 10, true);
|
||||||
|
outputNodes.emplace_back(NodeType::DoAlign, std::move(fieldName),
|
||||||
|
"<Op>("s.append(alignStream.begin(), alignStream.end()).append(", s)"), false);
|
||||||
|
#else
|
||||||
outputNodes.emplace_back(NodeType::DoAlign, std::move(fieldName),
|
outputNodes.emplace_back(NodeType::DoAlign, std::move(fieldName),
|
||||||
"<Op>("s.append(align.toString(10, true)).append(", s)"), false);
|
"<Op>("s.append(align.toString(10, true)).append(", s)"), false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const clang::NamedDecl* nd = tsDecl->getTemplatedDecl();
|
const clang::NamedDecl* nd = tsDecl->getTemplatedDecl();
|
||||||
@@ -1005,7 +1052,13 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
|||||||
llvm::raw_string_ostream strStream(sizeExprStr);
|
llvm::raw_string_ostream strStream(sizeExprStr);
|
||||||
argExpr->printPretty(strStream, nullptr, context.getPrintingPolicy());
|
argExpr->printPretty(strStream, nullptr, context.getPrintingPolicy());
|
||||||
} else if (GetIntegerConstantExpr(expr, sizeLiteral, context)) {
|
} else if (GetIntegerConstantExpr(expr, sizeLiteral, context)) {
|
||||||
|
#if LLVM_VERSION_MAJOR >= 13
|
||||||
|
llvm::SmallVector<char> strStream;
|
||||||
|
sizeLiteral.toString(strStream, 10);
|
||||||
|
sizeExprStr = std::string(strStream.begin(), strStream.end());
|
||||||
|
#else
|
||||||
sizeExprStr = sizeLiteral.toString(10);
|
sizeExprStr = sizeLiteral.toString(10);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1048,7 +1101,13 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
|||||||
llvm::raw_string_ostream strStream2(sizeExprStr);
|
llvm::raw_string_ostream strStream2(sizeExprStr);
|
||||||
argExpr->printPretty(strStream2, nullptr, context.getPrintingPolicy());
|
argExpr->printPretty(strStream2, nullptr, context.getPrintingPolicy());
|
||||||
} else if (GetIntegerConstantExpr(expr, sizeLiteral, context)) {
|
} else if (GetIntegerConstantExpr(expr, sizeLiteral, context)) {
|
||||||
|
#if LLVM_VERSION_MAJOR >= 13
|
||||||
|
llvm::SmallVector<char> strStream;
|
||||||
|
sizeLiteral.toString(strStream, 10);
|
||||||
|
sizeExprStr = std::string(strStream.begin(), strStream.end());
|
||||||
|
#else
|
||||||
sizeExprStr = sizeLiteral.toString(10);
|
sizeExprStr = sizeLiteral.toString(10);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else if (idx == 1) {
|
} else if (idx == 1) {
|
||||||
llvm::raw_string_ostream strStream(endianExprStr);
|
llvm::raw_string_ostream strStream(endianExprStr);
|
||||||
@@ -1266,17 +1325,17 @@ int main(int argc, const char** argv) {
|
|||||||
llvm::cl::PrintHelpMessage();
|
llvm::cl::PrintHelpMessage();
|
||||||
|
|
||||||
std::vector<std::string> args = {
|
std::vector<std::string> args = {
|
||||||
XSTR(ATDNA_ARGV0),
|
XSTR(ATDNA_ARGV0),
|
||||||
"-fsyntax-only",
|
"-fsyntax-only",
|
||||||
"-std=c++2a",
|
"-std=c++2a",
|
||||||
#if __x86_64__
|
#if __x86_64__
|
||||||
"-mno-sse",
|
"-mno-sse",
|
||||||
#endif
|
#endif
|
||||||
"-D__atdna__=1",
|
"-D__atdna__=1",
|
||||||
"-Wno-expansion-to-defined",
|
"-Wno-expansion-to-defined",
|
||||||
"-Wno-nullability-completeness",
|
"-Wno-nullability-completeness",
|
||||||
"-Werror=shadow-field",
|
"-Werror=shadow-field",
|
||||||
"-I" XSTR(INSTALL_PREFIX) "/include/Athena",
|
"-I" XSTR(INSTALL_PREFIX) "/include/Athena",
|
||||||
};
|
};
|
||||||
for (int a = 1; a < argc; ++a) {
|
for (int a = 1; a < argc; ++a) {
|
||||||
args.emplace_back(argv[a]);
|
args.emplace_back(argv[a]);
|
||||||
|
|||||||
51
cmake/FindDiaSDK.cmake
Normal file
51
cmake/FindDiaSDK.cmake
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# From https://github.com/microsoft/DirectXShaderCompiler/blob/18c9e114f9c314f93e68fbc72ce207d4ed2e65ae/cmake/modules/FindDiaSDK.cmake
|
||||||
|
# This file is distributed under the University of Illinois Open Source
|
||||||
|
|
||||||
|
# Find the DIA SDK path.
|
||||||
|
# It will typically look something like this:
|
||||||
|
# C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\DIA SDK\include
|
||||||
|
|
||||||
|
# CMAKE_GENERATOR_INSTANCE has the location of Visual Studio used
|
||||||
|
# i.e. C:/Program Files (x86)/Microsoft Visual Studio/2019/Community
|
||||||
|
set(VS_PATH ${CMAKE_GENERATOR_INSTANCE})
|
||||||
|
get_filename_component(VS_DIA_INC_PATH "${VS_PATH}/DIA SDK/include" ABSOLUTE CACHE)
|
||||||
|
|
||||||
|
# Starting in VS 15.2, vswhere is included.
|
||||||
|
# Unclear what the right component to search for is, might be Microsoft.VisualStudio.Component.VC.DiagnosticTools
|
||||||
|
# (although the friendly name of that is C++ profiling tools). The toolset is the most likely target.
|
||||||
|
set(PROGRAMFILES_X86 "ProgramFiles(x86)")
|
||||||
|
execute_process(
|
||||||
|
COMMAND "$ENV{${PROGRAMFILES_X86}}/Microsoft Visual Studio/Installer/vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
|
||||||
|
OUTPUT_VARIABLE VSWHERE_LATEST
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
find_path(DIASDK_INCLUDE_DIR # Set variable DIASDK_INCLUDE_DIR
|
||||||
|
dia2.h # Find a path with dia2.h
|
||||||
|
HINTS "${VS_DIA_INC_PATH}"
|
||||||
|
HINTS "${VSWHERE_LATEST}/DIA SDK/include"
|
||||||
|
DOC "path to DIA SDK header files"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if ((CMAKE_GENERATOR_PLATFORM STREQUAL "x64") OR ("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "x64"))
|
||||||
|
find_library(DIASDK_GUIDS_LIBRARY NAMES diaguids.lib HINTS ${DIASDK_INCLUDE_DIR}/../lib/amd64 )
|
||||||
|
elseif ((CMAKE_GENERATOR_PLATFORM STREQUAL "ARM") OR ("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM"))
|
||||||
|
find_library(DIASDK_GUIDS_LIBRARY NAMES diaguids.lib HINTS ${DIASDK_INCLUDE_DIR}/../lib/arm )
|
||||||
|
elseif ((CMAKE_GENERATOR_PLATFORM MATCHES "ARM64.*") OR ("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MATCHES "ARM64.*"))
|
||||||
|
find_library(DIASDK_GUIDS_LIBRARY NAMES diaguids.lib HINTS ${DIASDK_INCLUDE_DIR}/../lib/arm64 )
|
||||||
|
else ((CMAKE_GENERATOR_PLATFORM STREQUAL "x64") OR ("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "x64"))
|
||||||
|
find_library(DIASDK_GUIDS_LIBRARY NAMES diaguids.lib HINTS ${DIASDK_INCLUDE_DIR}/../lib )
|
||||||
|
endif((CMAKE_GENERATOR_PLATFORM STREQUAL "x64") OR ("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "x64"))
|
||||||
|
|
||||||
|
set(DIASDK_LIBRARIES ${DIASDK_GUIDS_LIBRARY})
|
||||||
|
set(DIASDK_INCLUDE_DIRS ${DIASDK_INCLUDE_DIR})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set DIASDK_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args(DiaSDK DEFAULT_MSG
|
||||||
|
DIASDK_LIBRARIES DIASDK_INCLUDE_DIR)
|
||||||
|
|
||||||
|
mark_as_advanced(DIASDK_INCLUDE_DIRS DIASDK_LIBRARIES)
|
||||||
1
extern/CMakeLists.txt
vendored
1
extern/CMakeLists.txt
vendored
@@ -7,7 +7,6 @@ add_subdirectory(yaml)
|
|||||||
if(NOT TARGET fmt)
|
if(NOT TARGET fmt)
|
||||||
add_subdirectory(fmt)
|
add_subdirectory(fmt)
|
||||||
target_compile_definitions(fmt PUBLIC
|
target_compile_definitions(fmt PUBLIC
|
||||||
FMT_STRING_ALIAS=1
|
|
||||||
FMT_ARM_ABI_COMPATIBILITY=1
|
FMT_ARM_ABI_COMPATIBILITY=1
|
||||||
FMT_EXCEPTIONS=0)
|
FMT_EXCEPTIONS=0)
|
||||||
target_compile_definitions(fmt INTERFACE
|
target_compile_definitions(fmt INTERFACE
|
||||||
|
|||||||
2
extern/fmt
vendored
2
extern/fmt
vendored
Submodule extern/fmt updated: 95da484727...9e8b86fd2d
2
extern/lzokay
vendored
2
extern/lzokay
vendored
Submodule extern/lzokay updated: 546a969527...ee8b4c29ad
93
extern/zlib/CMakeLists.txt
vendored
93
extern/zlib/CMakeLists.txt
vendored
@@ -1,47 +1,48 @@
|
|||||||
if (APPLE)
|
if (APPLE)
|
||||||
# use toolchain zlib
|
# always use toolchain zlib
|
||||||
find_package(ZLIB REQUIRED)
|
set(ZLIB_REQUIRED REQUIRED)
|
||||||
set(ZLIB_LIBRARIES ZLIB::ZLIB)
|
endif ()
|
||||||
else()
|
find_package(ZLIB ${ZLIB_REQUIRED})
|
||||||
if(NOT WIN32 AND NOT NX) # remove WIN32 when specter/freetype is gone
|
if (ZLIB_FOUND)
|
||||||
find_library(ZLIB_LIB NAMES zlib z)
|
add_library(z INTERFACE)
|
||||||
endif()
|
target_link_libraries(z INTERFACE ${ZLIB_LIBRARIES})
|
||||||
if(NOT ZLIB_LIB)
|
target_include_directories(z INTERFACE ${ZLIB_INCLUDE_DIRS})
|
||||||
message(STATUS "Using Athena's built-in zlib")
|
set(ZLIB_LIBRARIES z CACHE STRING "zlib libraries" FORCE)
|
||||||
add_library(z
|
set(ATHENA_ZLIB NO CACHE BOOL "Using built-in zlib" FORCE)
|
||||||
adler32.c
|
else ()
|
||||||
compress.c
|
message(STATUS "Using Athena's built-in zlib")
|
||||||
crc32.c
|
add_library(z
|
||||||
deflate.c
|
adler32.c
|
||||||
infback.c
|
compress.c
|
||||||
inffast.c
|
crc32.c
|
||||||
inflate.c
|
deflate.c
|
||||||
inftrees.c
|
infback.c
|
||||||
trees.c
|
inffast.c
|
||||||
uncompr.c
|
inflate.c
|
||||||
zutil.c
|
inftrees.c
|
||||||
crc32.h
|
trees.c
|
||||||
deflate.h
|
uncompr.c
|
||||||
gzguts.h
|
zutil.c
|
||||||
inffast.h
|
include/crc32.h
|
||||||
inffixed.h
|
include/deflate.h
|
||||||
inflate.h
|
include/gzguts.h
|
||||||
inftrees.h
|
include/inffast.h
|
||||||
trees.h
|
include/inffixed.h
|
||||||
zconf.h
|
include/inflate.h
|
||||||
zlib.h
|
include/inftrees.h
|
||||||
zutil.h)
|
include/trees.h
|
||||||
if(WIN32 AND NOT UNIX)
|
include/zconf.h
|
||||||
install(FILES zconf.h zlib.h DESTINATION include COMPONENT zlib)
|
include/zlib.h
|
||||||
install(TARGETS z DESTINATION lib COMPONENT zlib)
|
include/zutil.h)
|
||||||
else()
|
if (WIN32 AND NOT UNIX)
|
||||||
target_compile_options(z PRIVATE -Wno-implicit-fallthrough)
|
install(FILES include/zconf.h include/zlib.h DESTINATION include COMPONENT zlib)
|
||||||
endif()
|
install(TARGETS z DESTINATION lib COMPONENT zlib)
|
||||||
set(ZLIB_LIBRARIES z CACHE PATH "Zlib libraries" FORCE)
|
else ()
|
||||||
set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "Zlib include path" FORCE)
|
target_compile_options(z PRIVATE -Wno-implicit-fallthrough)
|
||||||
else()
|
endif ()
|
||||||
set(ZLIB_LIBRARIES ${ZLIB_LIB} CACHE PATH "Zlib libraries" FORCE)
|
target_include_directories(z PUBLIC
|
||||||
find_path(ZLIB_INCLUDE_DIR zlib.h PATHS "${PNG_LIB}/../../include")
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
message(STATUS "Using zlib at ${ZLIB_LIB}, include: ${ZLIB_INCLUDE_DIR}")
|
$<INSTALL_INTERFACE:include>)
|
||||||
endif()
|
set(ZLIB_LIBRARIES z CACHE STRING "zlib libraries" FORCE)
|
||||||
endif()
|
set(ATHENA_ZLIB YES CACHE BOOL "Using built-in zlib" FORCE)
|
||||||
|
endif ()
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
using mode_t = int;
|
using mode_t = int;
|
||||||
|
#else
|
||||||
|
#include <sys/stat.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace athena {
|
namespace athena {
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if _WIN32
|
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
#else
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -40,8 +32,7 @@ public:
|
|||||||
|
|
||||||
void open();
|
void open();
|
||||||
void close();
|
void close();
|
||||||
bool isOpen() const { return m_fileHandle != 0; }
|
bool isOpen() const { return m_fileHandle != nullptr; }
|
||||||
bool save();
|
|
||||||
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override;
|
void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override;
|
||||||
atUint64 position() const override;
|
atUint64 position() const override;
|
||||||
atUint64 length() const override;
|
atUint64 length() const override;
|
||||||
@@ -50,7 +41,7 @@ public:
|
|||||||
void setCacheSize(const atInt32 blockSize);
|
void setCacheSize(const atInt32 blockSize);
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
using HandleType = HANDLE;
|
using HandleType = void*;
|
||||||
#else
|
#else
|
||||||
using HandleType = FILE*;
|
using HandleType = FILE*;
|
||||||
#endif
|
#endif
|
||||||
@@ -64,6 +55,7 @@ protected:
|
|||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
#endif
|
#endif
|
||||||
HandleType m_fileHandle;
|
HandleType m_fileHandle;
|
||||||
|
atUint64 m_fileSize;
|
||||||
std::unique_ptr<atUint8[]> m_cacheData;
|
std::unique_ptr<atUint8[]> m_cacheData;
|
||||||
atInt32 m_blockSize;
|
atInt32 m_blockSize;
|
||||||
atInt32 m_curBlock;
|
atInt32 m_curBlock;
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
#else
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "athena/IStreamWriter.hpp"
|
#include "athena/IStreamWriter.hpp"
|
||||||
#include "athena/Types.hpp"
|
#include "athena/Types.hpp"
|
||||||
@@ -43,7 +36,7 @@ public:
|
|||||||
void writeUBytes(const atUint8* data, atUint64 len) override;
|
void writeUBytes(const atUint8* data, atUint64 len) override;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
using HandleType = HANDLE;
|
using HandleType = void*;
|
||||||
#else
|
#else
|
||||||
using HandleType = FILE*;
|
using HandleType = FILE*;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
#endif
|
#endif
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#if defined(GEKKO) || defined(__SWITCH__)
|
#if defined(GEKKO) || defined(__SWITCH__) || defined(EMSCRIPTEN)
|
||||||
#include "gekko_support.h"
|
#include "gekko_support.h"
|
||||||
typedef struct stat atStat64_t;
|
typedef struct stat atStat64_t;
|
||||||
#define atStat64 stat
|
#define atStat64 stat
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ void FileReader::open() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_fileSize = utility::fileSize(m_filename);
|
||||||
|
|
||||||
// reset error
|
// reset error
|
||||||
m_hasError = false;
|
m_hasError = false;
|
||||||
}
|
}
|
||||||
@@ -112,7 +114,7 @@ atUint64 FileReader::length() const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return utility::fileSize(m_filename);
|
return m_fileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) {
|
atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) {
|
||||||
@@ -126,11 +128,10 @@ atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) {
|
|||||||
if (m_blockSize <= 0)
|
if (m_blockSize <= 0)
|
||||||
return fread(buf, 1, len, m_fileHandle);
|
return fread(buf, 1, len, m_fileHandle);
|
||||||
else {
|
else {
|
||||||
atUint64 fs = utility::fileSize(m_filename);
|
if (m_offset >= m_fileSize)
|
||||||
if (m_offset >= fs)
|
|
||||||
return 0;
|
return 0;
|
||||||
if (m_offset + len >= fs)
|
if (m_offset + len >= m_fileSize)
|
||||||
len = fs - m_offset;
|
len = m_fileSize - m_offset;
|
||||||
|
|
||||||
size_t block = m_offset / m_blockSize;
|
size_t block = m_offset / m_blockSize;
|
||||||
atUint64 cacheOffset = m_offset % m_blockSize;
|
atUint64 cacheOffset = m_offset % m_blockSize;
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
#include "athena/FileReader.hpp"
|
#include "athena/FileReader.hpp"
|
||||||
|
|
||||||
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#endif
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
#include "win32_largefilewrapper.h"
|
#include "win32_largefilewrapper.h"
|
||||||
|
|
||||||
namespace athena::io {
|
namespace athena::io {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||||
#include "osx_largefilewrapper.h"
|
#include "osx_largefilewrapper.h"
|
||||||
#elif defined(GEKKO) || defined(__SWITCH__)
|
#elif defined(GEKKO) || defined(__SWITCH__)
|
||||||
#include "gekko_support.h"
|
#include "athena/gekko_support.h"
|
||||||
#include "osx_largefilewrapper.h"
|
#include "osx_largefilewrapper.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
#include "athena/FileWriter.hpp"
|
#include "athena/FileWriter.hpp"
|
||||||
|
|
||||||
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#endif
|
||||||
|
#include <windows.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user