Merge remote-tracking branch 'origin/master' into hsh

# Conflicts:
#	atdna/FindLLVM.cmake
#	extern/zlib/CMakeLists.txt
This commit is contained in:
Luke Street 2021-01-06 14:17:43 -05:00
commit 04cbd546b7
7 changed files with 38 additions and 41 deletions

View File

@ -1,4 +1,6 @@
cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17 cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17
# Set MSVC runtime library flags from CMAKE_MSVC_RUNTIME_LIBRARY
cmake_policy(SET CMP0091 NEW)
project(athena) project(athena)
if (NOT MSVC) if (NOT MSVC)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)

View File

@ -10,13 +10,6 @@ get_directory_property(ATDNA_DEFINES COMPILE_DEFINITIONS)
list(REMOVE_ITEM ATDNA_DEFINES _GLIBCXX_DEBUG=1) list(REMOVE_ITEM ATDNA_DEFINES _GLIBCXX_DEBUG=1)
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${ATDNA_DEFINES}") set_directory_properties(PROPERTIES COMPILE_DEFINITIONS "${ATDNA_DEFINES}")
# Force this binary to /MD flags (to make MSVC happy)
if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "/MD /Zi /Ob0 /Od /RTC1")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /O2 /Ob2 /DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "/MD /Zi /O2 /Ob1 /DNDEBUG")
endif()
# Find dependencies # Find dependencies
include(FindLLVM.cmake) include(FindLLVM.cmake)
if(NOT LLVM_FOUND) if(NOT LLVM_FOUND)
@ -32,24 +25,24 @@ endif()
if(ATDNA_DYNAMIC_LLVM) if(ATDNA_DYNAMIC_LLVM)
find_library(CLANGCPP_LIB clang-cpp HINTS "${LLVM_ROOT_DIR}/lib") find_library(CLANGCPP_LIB clang-cpp HINTS "${LLVM_ROOT_DIR}/lib")
if (NOT CLANGCPP_LIB) if (NOT CLANGCPP_LIB)
list(APPEND LLVM_LIBS list(APPEND LLVM_LIBS
clangFrontend clangFrontend
clangTooling clangTooling
clangDriver clangDriver
clangSerialization clangSerialization
clangParse clangParse
clangSema clangSema
clangAnalysis clangAnalysis
clangEdit clangEdit
clangAST clangAST
clangLex clangLex
clangBasic clangBasic
LLVM) LLVM)
else() else()
list(APPEND LLVM_LIBS list(APPEND LLVM_LIBS
clang-cpp clang-cpp
LLVM) LLVM)
endif() endif()
else() else()
find_library(LLVMDEMANGLE_LIB LLVMDemangle HINTS "${LLVM_ROOT_DIR}/lib") find_library(LLVMDEMANGLE_LIB LLVMDemangle HINTS "${LLVM_ROOT_DIR}/lib")
find_library(LLVMBINARYFORMAT_LIB LLVMBinaryFormat HINTS "${LLVM_ROOT_DIR}/lib") find_library(LLVMBINARYFORMAT_LIB LLVMBinaryFormat HINTS "${LLVM_ROOT_DIR}/lib")
@ -90,7 +83,8 @@ else()
LLVMSupport LLVMSupport
LLVMRemarks LLVMRemarks
LLVMBitStreamReader LLVMBitStreamReader
${LLVMDEMANGLE_LIB}) ${LLVMDEMANGLE_LIB}
LLVMFrontendOpenMP)
endif() endif()
string(FIND ${LLVM_VERSION_STRING} "svn" SVN_FILTER_IDX) string(FIND ${LLVM_VERSION_STRING} "svn" SVN_FILTER_IDX)
@ -149,11 +143,14 @@ target_compile_definitions(atdna PRIVATE
ATDNA_ARGV0=${LLVM_ROOT_DIR}/bin/clang-tool) ATDNA_ARGV0=${LLVM_ROOT_DIR}/bin/clang-tool)
target_include_directories(atdna PRIVATE ${LLVM_INCLUDE_DIRS}) target_include_directories(atdna PRIVATE ${LLVM_INCLUDE_DIRS})
target_link_directories(atdna PRIVATE ${LLVM_LIBRARY_DIRS}) target_link_directories(atdna PRIVATE ${LLVM_LIBRARY_DIRS})
# Clang 10.0.x headers currently broken with C++20
set_property(TARGET atdna PROPERTY CXX_STANDARD 17)
if(MSVC) if(MSVC)
target_compile_options(atdna PRIVATE /GR-) # 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() else()
target_compile_options(atdna PRIVATE -fno-rtti -Wno-error) target_compile_options(atdna PRIVATE -fno-rtti -Wno-error)
set_property(TARGET atdna PROPERTY CXX_STANDARD 17)
endif() endif()
# Define installs # Define installs

View File

@ -207,4 +207,3 @@ endif()
find_package_handle_standard_args(LLVM find_package_handle_standard_args(LLVM
REQUIRED_VARS LLVM_ROOT_DIR LLVM_HOST_TARGET REQUIRED_VARS LLVM_ROOT_DIR LLVM_HOST_TARGET
VERSION_VAR LLVM_VERSION_STRING) VERSION_VAR LLVM_VERSION_STRING)

View File

@ -419,7 +419,7 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
regType = regType->getUnqualifiedDesugaredType(); regType = regType->getUnqualifiedDesugaredType();
} }
std::string fieldName = field->getName(); std::string fieldName = field->getName().str();
std::string propIdExpr = GetPropIdExpr(field, fieldName); std::string propIdExpr = GetPropIdExpr(field, fieldName);
if (regType->getTypeClass() == clang::Type::TemplateSpecialization) { if (regType->getTypeClass() == clang::Type::TemplateSpecialization) {
@ -431,6 +431,8 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
llvm::APSInt endian(64, -1); llvm::APSInt endian(64, -1);
std::string endianExprStr; std::string endianExprStr;
bool defaultEndian = true; bool defaultEndian = true;
/* FIXME: The is the following code required? */
#if 0
if (classParms->size() >= 2) { if (classParms->size() >= 2) {
const clang::NamedDecl* endianParm = classParms->getParam(1); const clang::NamedDecl* endianParm = classParms->getParam(1);
if (endianParm->getKind() == clang::Decl::NonTypeTemplateParm) { if (endianParm->getKind() == clang::Decl::NonTypeTemplateParm) {
@ -439,7 +441,7 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
nttParm->print(strStream, context.getPrintingPolicy()); nttParm->print(strStream, context.getPrintingPolicy());
} }
} }
#endif
for (const clang::TemplateArgument& arg : *tsType) { for (const clang::TemplateArgument& arg : *tsType) {
if (arg.getKind() == clang::TemplateArgument::Expression) { if (arg.getKind() == clang::TemplateArgument::Expression) {
const clang::Expr* expr = arg.getAsExpr(); const clang::Expr* expr = arg.getAsExpr();
@ -818,7 +820,7 @@ class ATDNAEmitVisitor : public clang::RecursiveASTVisitor<ATDNAEmitVisitor> {
regType = regType->getUnqualifiedDesugaredType(); regType = regType->getUnqualifiedDesugaredType();
} }
std::string fieldName = field->getName(); std::string fieldName = field->getName().str();
std::string propIdExpr = GetPropIdExpr(field, fieldName); std::string propIdExpr = GetPropIdExpr(field, fieldName);
if (regType->getTypeClass() == clang::Type::TemplateSpecialization) { if (regType->getTypeClass() == clang::Type::TemplateSpecialization) {

View File

@ -1,7 +1,7 @@
if(NOT WIN32 AND NOT NX) if(NOT WIN32 AND NOT NX) # remove when specter/freetype is gone
find_package(ZLIB) find_library(ZLIB_LIB NAMES zlib z)
endif() endif()
if(WIN32 OR NOT ZLIB_FOUND) if(NOT ZLIB_LIB)
message(STATUS "Using Athena's built-in zlib") message(STATUS "Using Athena's built-in zlib")
add_library(z add_library(z
adler32.c adler32.c
@ -35,6 +35,6 @@ endif()
set(ZLIB_LIBRARIES z CACHE PATH "Zlib libraries" FORCE) set(ZLIB_LIBRARIES z CACHE PATH "Zlib libraries" FORCE)
set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "Zlib include path" FORCE) set(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "Zlib include path" FORCE)
else() else()
set(ZLIB_LIBRARIES ${ZLIB_LIBRARIES} CACHE PATH "Zlib libraries" FORCE) set(ZLIB_LIBRARIES ${ZLIB_LIB} CACHE PATH "Zlib libraries" FORCE)
find_path(ZLIB_INCLUDE_DIR zlib.h) find_path(ZLIB_INCLUDE_DIR zlib.h)
endif() endif()

View File

@ -500,7 +500,7 @@ struct Write {
static std::enable_if_t<std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count, static std::enable_if_t<std::is_same_v<T, bool>> Do(const PropId& id, std::vector<T>& vector, const S& count,
StreamT& w) { StreamT& w) {
/* libc++ specializes vector<bool> as a bitstream */ /* libc++ specializes vector<bool> as a bitstream */
for (const T& v : vector) for (const T v : vector)
w.writeBool(v); w.writeBool(v);
} }
static void Do(const PropId& id, std::unique_ptr<atUint8[]>& buf, size_t count, StreamT& w) { static void Do(const PropId& id, std::unique_ptr<atUint8[]>& buf, size_t count, StreamT& w) {
@ -732,7 +732,7 @@ struct WriteYaml {
StreamT& w) { StreamT& w) {
/* libc++ specializes vector<bool> as a bitstream */ /* libc++ specializes vector<bool> as a bitstream */
if (auto __v = w.enterSubVector(id.name)) if (auto __v = w.enterSubVector(id.name))
for (const T& v : vector) for (const T v : vector)
w.writeBool(v); w.writeBool(v);
} }
static void Do(const PropId& id, std::unique_ptr<atUint8[]>& buf, size_t count, StreamT& w) { static void Do(const PropId& id, std::unique_ptr<atUint8[]>& buf, size_t count, StreamT& w) {

View File

@ -441,8 +441,6 @@ bool YAMLDocWriter::finish(athena::io::IStreamWriter* fout) {
return false; return false;
}; };
yaml_event_t event = {};
if (fout) { if (fout) {
yaml_emitter_set_output(&m_emitter, (yaml_write_handler_t*)YAMLAthenaWriter, fout); yaml_emitter_set_output(&m_emitter, (yaml_write_handler_t*)YAMLAthenaWriter, fout);
} }
@ -450,16 +448,15 @@ bool YAMLDocWriter::finish(athena::io::IStreamWriter* fout) {
return error(); return error();
} }
event.type = YAML_DOCUMENT_START_EVENT; yaml_event_t event;
event.data.document_start.implicit = true; yaml_document_start_event_initialize(&event, nullptr, nullptr, nullptr, 1);
if (!yaml_emitter_emit(&m_emitter, &event)) { if (!yaml_emitter_emit(&m_emitter, &event)) {
return error(); return error();
} }
if (!RecursiveFinish(&m_emitter, *m_rootNode)) { if (!RecursiveFinish(&m_emitter, *m_rootNode)) {
return false; return false;
} }
event.type = YAML_DOCUMENT_END_EVENT; yaml_document_end_event_initialize(&event, 1);
event.data.document_end.implicit = true;
if (!yaml_emitter_emit(&m_emitter, &event)) { if (!yaml_emitter_emit(&m_emitter, &event)) {
return error(); return error();
} }