mirror of
https://github.com/libAthena/athena.git
synced 2025-12-08 21:18:02 +00:00
Compare commits
32 Commits
| 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 | |||
| 11b86d7634 | |||
| 7a2a8a79ca |
142
.github/workflows/build.yml
vendored
142
.github/workflows/build.yml
vendored
@@ -4,31 +4,40 @@ on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
BUILDCACHE_VERSION: v0.28.3
|
||||
BUILDCACHE_ACCURACY: STRICT
|
||||
BUILDCACHE_MAX_CACHE_SIZE: 1073741824 # 1GiB
|
||||
|
||||
jobs:
|
||||
build-linux-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:
|
||||
- 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
|
||||
with:
|
||||
fetch-depth: 0
|
||||
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
|
||||
run: |
|
||||
cmake -B build . -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DClang_DIR=/usr/lib/cmake/clang-11 \
|
||||
-DATDNA_DYNAMIC_LLVM=OFF -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
cmake -B build . -GNinja \
|
||||
-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
|
||||
run: cmake --build build --target package --verbose
|
||||
@@ -46,7 +55,12 @@ jobs:
|
||||
|
||||
build-linux-aarch64:
|
||||
name: Build Linux (GCC aarch64)
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
if: 'false'
|
||||
|
||||
env:
|
||||
LLVM_MAJOR: 15
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
@@ -57,16 +71,19 @@ jobs:
|
||||
name: Build & test
|
||||
with:
|
||||
arch: aarch64
|
||||
distro: ubuntu20.04
|
||||
base_image: --platform=linux/arm64/v8 alpine:3.17
|
||||
githubToken: ${{github.token}}
|
||||
dockerRunArgs: |
|
||||
--volume "${PWD}:/workspace"
|
||||
install: |
|
||||
apt-get -y update
|
||||
apt-get -y install build-essential cmake ninja-build llvm-11-dev libclang-11-dev clang-11
|
||||
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
|
||||
run: |
|
||||
cmake -B build . -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DClang_DIR=/usr/lib/cmake/clang-11 -DATDNA_DYNAMIC_LLVM=OFF
|
||||
cmake -B build . -GNinja \
|
||||
-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
|
||||
build/atdna-test
|
||||
|
||||
@@ -79,7 +96,13 @@ jobs:
|
||||
|
||||
build-macos-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:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
@@ -89,26 +112,39 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
brew update
|
||||
brew install ninja ccache
|
||||
# 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 /
|
||||
brew install ninja
|
||||
|
||||
- name: Configure ccache
|
||||
uses: hendrikmuhs/ccache-action@v1
|
||||
# universal clang+llvm from macports
|
||||
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:
|
||||
key: macos-10.15-appleclang
|
||||
max-size: 1G
|
||||
path: ${{env.BUILDCACHE_DIR}}
|
||||
key: buildcache-macos-12
|
||||
|
||||
- name: Configure CMake
|
||||
run: |
|
||||
cmake -B build . -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \
|
||||
-DLLVM_ROOT_DIR=/opt/local/libexec/llvm-11 \
|
||||
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
cmake -B build . -GNinja \
|
||||
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
|
||||
-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
|
||||
run: cmake --build build --target package --verbose
|
||||
|
||||
- name: Print buildcache stats
|
||||
run: buildcache -s
|
||||
|
||||
- name: Test
|
||||
working-directory: build
|
||||
run: ./atdna-test
|
||||
@@ -122,9 +158,12 @@ jobs:
|
||||
|
||||
build-win32-amd64:
|
||||
name: Build Windows (MSVC AMD64)
|
||||
runs-on: windows-2019
|
||||
runs-on: windows-2022
|
||||
|
||||
env:
|
||||
LLVM_VERSION: 10.0.1
|
||||
LLVM_VERSION: 15.0.7
|
||||
BUILDCACHE_DIR: C:\buildcache
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
@@ -133,28 +172,46 @@ jobs:
|
||||
|
||||
- name: Install LLVM
|
||||
run: |
|
||||
$TempDir = "$env:RUNNER_WORKSPACE\temp"
|
||||
$Filename = "LLVM-$env:LLVM_VERSION-win64.exe"
|
||||
$TempDir = "C:\temp" # C: has more space
|
||||
$Filename = "vcpkg-llvm-$env:LLVM_VERSION-full.7z"
|
||||
New-Item -Path "$TempDir" -ItemType Directory -ea 0
|
||||
(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
|
||||
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
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
|
||||
- name: Configure CMake
|
||||
run: |
|
||||
$workspace = $env:RUNNER_WORKSPACE -replace '\\', '/'
|
||||
cmake -B build . -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo `
|
||||
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded `
|
||||
-DLLVM_ROOT_DIR="$workspace/LLVM"
|
||||
cmake -B build . -GNinja `
|
||||
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo `
|
||||
-DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=MultiThreaded `
|
||||
-DCMAKE_TOOLCHAIN_FILE:PATH="C:\temp\vcpkg-llvm-$env:LLVM_VERSION\scripts\buildsystems\vcpkg.cmake" `
|
||||
-DVCPKG_TARGET_TRIPLET:STRING=x64-windows-static
|
||||
|
||||
- name: Build
|
||||
run: cmake --build build --target package --verbose
|
||||
|
||||
- name: Print buildcache stats
|
||||
run: buildcache -s
|
||||
|
||||
- name: Test
|
||||
working-directory: build
|
||||
run: ./atdna-test.exe
|
||||
@@ -169,6 +226,7 @@ jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
if:
|
||||
contains('
|
||||
refs/heads/master
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -21,4 +21,5 @@ PKGBUILD
|
||||
/build
|
||||
/out
|
||||
/cmake-build-*
|
||||
/.idea
|
||||
/.idea
|
||||
/.buildcache
|
||||
|
||||
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,6 +1,6 @@
|
||||
[submodule "extern/lzokay"]
|
||||
path = extern/lzokay
|
||||
url = https://github.com/jackoalan/lzokay.git
|
||||
url = https://github.com/AxioDL/lzokay.git
|
||||
branch = master
|
||||
[submodule "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
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
##################
|
||||
# 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_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_STRIP_TRAILING_WHITESPACE)
|
||||
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_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}
|
||||
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_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_STRIP_TRAILING_WHITESPACE)
|
||||
# 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_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
@@ -35,11 +37,11 @@ if (GIT_FOUND)
|
||||
string(REGEX REPLACE "(-0)?-[^-]+((-dirty)?)$" "\\2" ATHENA_WC_DESCRIBE "${ATHENA_WC_DESCRIBE}")
|
||||
|
||||
# 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_STRIP_TRAILING_WHITESPACE)
|
||||
# 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_STRIP_TRAILING_WHITESPACE)
|
||||
else ()
|
||||
@@ -61,12 +63,17 @@ else ()
|
||||
endif ()
|
||||
|
||||
# Add version information to CI environment variables
|
||||
if(DEFINED ENV{GITHUB_ENV})
|
||||
file(APPEND "$ENV{GITHUB_ENV}" "ATHENA_VERSION=${ATHENA_WC_DESCRIBE}")
|
||||
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 (ATDNA_STATIC)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
add_link_options(-static)
|
||||
endif ()
|
||||
|
||||
if (MSVC)
|
||||
# Shaddup MSVC
|
||||
add_compile_definitions(UNICODE=1 _UNICODE=1 __SSE__=1
|
||||
@@ -222,11 +229,11 @@ 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
|
||||
@@ -332,8 +339,11 @@ endforeach()
|
||||
# Define installs
|
||||
install(DIRECTORY include/athena DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT athena)
|
||||
install(DIRECTORY extern/fmt/include/fmt DESTINATION ${INSTALL_INCLUDE_DIR} COMPONENT athena)
|
||||
install(TARGETS athena-core fmt
|
||||
DESTINATION ${INSTALL_LIB_DIR} EXPORT AthenaTargets COMPONENT athena)
|
||||
if (ATHENA_ZLIB)
|
||||
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)
|
||||
install(FILES Athena.ico DESTINATION ${INSTALL_LIB_DIR} COMPONENT athena)
|
||||
elseif(UNIX)
|
||||
@@ -348,7 +358,7 @@ endif()
|
||||
##################
|
||||
|
||||
# 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
|
||||
# (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)
|
||||
endif()
|
||||
|
||||
list(APPEND CLANG_LIBS clangTooling)
|
||||
set(CLANG_LIBS "")
|
||||
set(LLVM_LIBS "")
|
||||
|
||||
if (ATDNA_DYNAMIC_LLVM)
|
||||
list(APPEND CLANG_LIBS clang-cpp)
|
||||
list(APPEND LLVM_LIBS LLVM)
|
||||
else()
|
||||
function(recursive_remove_library target library)
|
||||
@@ -51,14 +52,34 @@ else()
|
||||
endif()
|
||||
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
|
||||
foreach (lib ${CLANG_LIBS})
|
||||
recursive_remove_library(${lib} LLVM)
|
||||
endforeach ()
|
||||
# Add LLVM static libs
|
||||
list(APPEND LLVM_LIBS LLVMFrontendOpenMP LLVMOption)
|
||||
# Hack around link order issues
|
||||
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()
|
||||
|
||||
# Offer the user the choice of overriding the installation directories
|
||||
@@ -85,20 +106,39 @@ endif()
|
||||
# ATDNA target
|
||||
add_executable(atdna main.cpp test.hpp ${PLAT_SRCS})
|
||||
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
|
||||
INSTALL_PREFIX=${ABS_INSTALL_BIN_DIR}
|
||||
__STDC_LIMIT_MACROS=1
|
||||
__STDC_CONSTANT_MACROS=1
|
||||
ATDNA_ARGV0=clang-tool)
|
||||
ATDNA_ARGV0=${ATDNA_ARGV0})
|
||||
target_include_directories(atdna PRIVATE ${CLANG_INCLUDE_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()
|
||||
if (VCPKG_TOOLCHAIN)
|
||||
# Assumes static build of LLVM
|
||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||
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)
|
||||
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()
|
||||
|
||||
# Define installs
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# - 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")
|
||||
@@ -26,7 +26,9 @@ function(atdna out)
|
||||
get_property(incdirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
|
||||
set(inccli "")
|
||||
foreach(dir ${incdirs})
|
||||
list(APPEND inccli "-I${dir}")
|
||||
if (NOT dir MATCHES ".*emscripten.*")
|
||||
list(APPEND inccli "-I${dir}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Get local defines for atdna
|
||||
|
||||
@@ -92,6 +92,18 @@ function(atdna out incdirs cdefs)
|
||||
list(APPEND ins_impdeps ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
|
||||
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
|
||||
unset(extraargs)
|
||||
if(MSVC)
|
||||
@@ -124,8 +136,7 @@ function(atdna out incdirs cdefs)
|
||||
# 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>>"
|
||||
${inccli} ${cdefcli}
|
||||
"-I${athena_SOURCE_DIR}/include" ${ins}
|
||||
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
|
||||
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
|
||||
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>>"
|
||||
${inccli} ${cdefcli}
|
||||
"-I${athena_SOURCE_DIR}/include" ${ins}
|
||||
DEPENDS atdna ${ins} IMPLICIT_DEPENDS ${ins_impdeps}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
|
||||
116
atdna/main.cpp
116
atdna/main.cpp
@@ -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> 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"));
|
||||
|
||||
@@ -75,6 +76,21 @@ using StreamOut = llvm::raw_pwrite_stream;
|
||||
using StreamOut = llvm::raw_fd_ostream;
|
||||
#endif
|
||||
|
||||
#if LLVM_VERSION_MAJOR >= 12
|
||||
static inline bool GetIntegerConstantExpr(const clang::Expr* expr, llvm::APSInt& out, const clang::ASTContext& ctx) {
|
||||
const auto optional = expr->getIntegerConstantExpr(ctx);
|
||||
if (optional) {
|
||||
out = optional.getValue();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
static inline bool GetIntegerConstantExpr(const clang::Expr* expr, llvm::APSInt& out, const clang::ASTContext& ctx) {
|
||||
return expr->isIntegerConstantExpr(out, ctx);
|
||||
}
|
||||
#endif
|
||||
|
||||
class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||
clang::ASTContext& context;
|
||||
StreamOut& fileOut;
|
||||
@@ -173,7 +189,12 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||
for (clang::Attr* attr : field->attrs()) {
|
||||
if (clang::AnnotateAttr* annot = clang::dyn_cast_or_null<clang::AnnotateAttr>(attr)) {
|
||||
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);
|
||||
std::string tmpS;
|
||||
llvm::raw_string_ostream s(tmpS);
|
||||
@@ -241,7 +262,11 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||
if (needsComma)
|
||||
qualType += ", ";
|
||||
llvm::raw_string_ostream OS(qualType);
|
||||
#if LLVM_VERSION_MAJOR >= 13
|
||||
arg.print(context.getPrintingPolicy(), OS, false);
|
||||
#else
|
||||
arg.print(context.getPrintingPolicy(), OS);
|
||||
#endif
|
||||
needsComma = true;
|
||||
}
|
||||
qualType += '>';
|
||||
@@ -264,7 +289,10 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||
templateStmt += ", ";
|
||||
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();
|
||||
needsComma = true;
|
||||
}
|
||||
@@ -311,7 +339,11 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||
if (needsComma)
|
||||
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);
|
||||
#endif
|
||||
needsComma = true;
|
||||
}
|
||||
specializations.back().first += '>';
|
||||
@@ -327,7 +359,12 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||
for (clang::Attr* attr : rec->attrs()) {
|
||||
if (clang::AnnotateAttr* annot = clang::dyn_cast_or_null<clang::AnnotateAttr>(attr)) {
|
||||
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;
|
||||
textRef.substr(10).split(specParms, ',');
|
||||
int numTuples = int(specParms.size()) / numParms;
|
||||
@@ -595,8 +632,14 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||
argExpr = static_cast<const clang::ParenExpr*>(argExpr)->getSubExpr();
|
||||
llvm::raw_string_ostream strStream(sizeExprStr);
|
||||
argExpr->printPretty(strStream, nullptr, context.getPrintingPolicy());
|
||||
} else if (expr->isIntegerConstantExpr(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);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -637,8 +680,14 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||
argExpr = static_cast<const clang::ParenExpr*>(argExpr)->getSubExpr();
|
||||
llvm::raw_string_ostream strStream2(sizeExprStr);
|
||||
argExpr->printPretty(strStream2, nullptr, context.getPrintingPolicy());
|
||||
} else if (expr->isIntegerConstantExpr(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);
|
||||
#endif
|
||||
}
|
||||
} else if (idx == 1) {
|
||||
defaultEndian = false;
|
||||
@@ -684,8 +733,14 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||
argExpr = static_cast<const clang::ParenExpr*>(argExpr)->getSubExpr();
|
||||
llvm::raw_string_ostream strStream(offsetExprStr);
|
||||
argExpr->printPretty(strStream, nullptr, context.getPrintingPolicy());
|
||||
} else if (expr->isIntegerConstantExpr(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);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
clang::APValue result;
|
||||
@@ -736,7 +791,7 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||
for (const clang::TemplateArgument& arg : *tsType) {
|
||||
if (arg.getKind() == clang::TemplateArgument::Expression) {
|
||||
const clang::Expr* expr = arg.getAsExpr();
|
||||
if (!expr->isIntegerConstantExpr(align, context)) {
|
||||
if (!GetIntegerConstantExpr(expr, align, context)) {
|
||||
clang::DiagnosticBuilder diag = context.getDiagnostics().Report(expr->getExprLoc(), AthenaError);
|
||||
diag.AddString("Unable to use non-constant align expression in Athena");
|
||||
diag.AddSourceRange(clang::CharSourceRange(expr->getSourceRange(), true));
|
||||
@@ -750,8 +805,15 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||
|
||||
const int64_t alignVal = align.getSExtValue();
|
||||
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),
|
||||
"<Op>("s.append(align.toString(10, true)).append(", s)"), false);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
const clang::NamedDecl* nd = tsDecl->getTemplatedDecl();
|
||||
@@ -989,8 +1051,14 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||
argExpr = static_cast<const clang::ParenExpr*>(argExpr)->getSubExpr();
|
||||
llvm::raw_string_ostream strStream(sizeExprStr);
|
||||
argExpr->printPretty(strStream, nullptr, context.getPrintingPolicy());
|
||||
} else if (expr->isIntegerConstantExpr(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);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1032,8 +1100,14 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
|
||||
argExpr = static_cast<const clang::ParenExpr*>(argExpr)->getSubExpr();
|
||||
llvm::raw_string_ostream strStream2(sizeExprStr);
|
||||
argExpr->printPretty(strStream2, nullptr, context.getPrintingPolicy());
|
||||
} else if (expr->isIntegerConstantExpr(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);
|
||||
#endif
|
||||
}
|
||||
} else if (idx == 1) {
|
||||
llvm::raw_string_ostream strStream(endianExprStr);
|
||||
@@ -1231,7 +1305,11 @@ public:
|
||||
std::unique_ptr<StreamOut> fileout;
|
||||
StreamOut* fileoutOld;
|
||||
if (OutputFilename.size())
|
||||
#if LLVM_VERSION_MAJOR >= 12
|
||||
fileout = MakeStreamOut(compiler.createOutputFile(OutputFilename, false, true, true), fileoutOld);
|
||||
#else
|
||||
fileout = MakeStreamOut(compiler.createOutputFile(OutputFilename, false, true, "", "", true), fileoutOld);
|
||||
#endif
|
||||
else
|
||||
fileout = MakeStreamOut(compiler.createDefaultOutputFile(false, "a", "cpp"), fileoutOld);
|
||||
AthenaError =
|
||||
@@ -1247,17 +1325,17 @@ int main(int argc, const char** argv) {
|
||||
llvm::cl::PrintHelpMessage();
|
||||
|
||||
std::vector<std::string> args = {
|
||||
XSTR(ATDNA_ARGV0),
|
||||
"-fsyntax-only",
|
||||
"-std=c++2a",
|
||||
XSTR(ATDNA_ARGV0),
|
||||
"-fsyntax-only",
|
||||
"-std=c++2a",
|
||||
#if __x86_64__
|
||||
"-mno-sse",
|
||||
"-mno-sse",
|
||||
#endif
|
||||
"-D__atdna__=1",
|
||||
"-Wno-expansion-to-defined",
|
||||
"-Wno-nullability-completeness",
|
||||
"-Werror=shadow-field",
|
||||
"-I" XSTR(INSTALL_PREFIX) "/include/Athena",
|
||||
"-D__atdna__=1",
|
||||
"-Wno-expansion-to-defined",
|
||||
"-Wno-nullability-completeness",
|
||||
"-Werror=shadow-field",
|
||||
"-I" XSTR(INSTALL_PREFIX) "/include/Athena",
|
||||
};
|
||||
for (int a = 1; a < argc; ++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)
|
||||
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
|
||||
|
||||
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)
|
||||
# use toolchain zlib
|
||||
find_package(ZLIB REQUIRED)
|
||||
set(ZLIB_LIBRARIES ZLIB::ZLIB)
|
||||
else()
|
||||
if(NOT WIN32 AND NOT NX) # remove WIN32 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 PATHS "${PNG_LIB}/../../include")
|
||||
message(STATUS "Using zlib at ${ZLIB_LIB}, include: ${ZLIB_INCLUDE_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
# 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 ()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -38,6 +38,8 @@ void FileReader::open() {
|
||||
return;
|
||||
}
|
||||
|
||||
m_fileSize = utility::fileSize(m_filename);
|
||||
|
||||
// reset error
|
||||
m_hasError = false;
|
||||
}
|
||||
@@ -112,7 +114,7 @@ atUint64 FileReader::length() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return utility::fileSize(m_filename);
|
||||
return m_fileSize;
|
||||
}
|
||||
|
||||
atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) {
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user