Various NX build fixes

This commit is contained in:
Phillip Stephens 2018-09-23 19:12:29 -07:00
parent 5306525029
commit 80c283736e
3 changed files with 16 additions and 8 deletions

View File

@ -123,11 +123,11 @@ function(add_nro_target target)
endif () endif ()
if (NOT APP_ICON) if (NOT APP_ICON)
if (EXISTS ${target}.png) if (EXISTS ${target}.png)
set(APP_ICON ${target}.png) set(APP_ICON ${target}.jpg)
elseif (EXISTS icon.png) elseif (EXISTS icon.jpg)
set(APP_ICON icon.png) set(APP_ICON icon.jpg)
elseif (NX) elseif (NX)
set(APP_ICON ${DEVKITPRO}/libnx/default_icon.png) set(APP_ICON ${DEVKITPRO}/libnx/default_icon.jpg)
else () else ()
message(FATAL_ERROR "No icon found ! Please use NO_SMDH or provide some icon.") message(FATAL_ERROR "No icon found ! Please use NO_SMDH or provide some icon.")
endif () endif ()
@ -137,13 +137,14 @@ function(add_nro_target target)
endif () endif ()
if (CMAKE_RUNTIME_OUTPUT_DIRECTORY) if (CMAKE_RUNTIME_OUTPUT_DIRECTORY)
add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.nro add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.nro
COMMAND ${ELF2NRO} $<TARGET_FILE:${target}> --icon=${APP_ICON} --nacp=${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.nro COMMAND ${ELF2NRO} $<TARGET_FILE:${target}> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target_we}.nro --icon=${APP_ICON} --nacp=${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp
DEPENDS ${target} ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp DEPENDS ${target} ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp
VERBATIM VERBATIM
) )
else () else ()
message("${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp")
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nro add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nro
COMMAND ${ELF2NRO} $<TARGET_FILE:${target}> --icon=${APP_ICON} --nacp=${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nro COMMAND ${ELF2NRO} $<TARGET_FILE:${target}> ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nro --icon=${APP_ICON} --nacp=${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp
DEPENDS ${target} ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp DEPENDS ${target} ${CMAKE_CURRENT_BINARY_DIR}/${target_we}.nacp
VERBATIM VERBATIM
) )

View File

@ -30,7 +30,7 @@ else()
endif() endif()
set(PKG_CONFIG "${DEVKITPRO}/portlibs/bin/aarch64-none-elf-pkg-config" CACHE STRING "") set(PKG_CONFIG "${DEVKITPRO}/portlibs/bin/aarch64-none-elf-pkg-config" CACHE STRING "")
set(CPPFLAGS "-D__SWITCH__ -D__USE_LARGEFILE64=1 -D__USE_LARGEOFFSET64=1 -I${DEVKITPRO}/libnx/include -I${DEVKITPRO}/portlibs/switch/include") set(CPPFLAGS "-D__SWITCH__ -I${DEVKITPRO}/libnx/include -I${DEVKITPRO}/portlibs/switch/include")
set(CMAKE_C_FLAGS "${CPPFLAGS} -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIC -ffunction-sections" CACHE STRING "C flags") set(CMAKE_C_FLAGS "${CPPFLAGS} -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIC -ffunction-sections" CACHE STRING "C flags")
set(CMAKE_CXX_FLAGS "${CPPFLAGS} ${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions -std=gnu++11" CACHE STRING "C++ flags") set(CMAKE_CXX_FLAGS "${CPPFLAGS} ${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions -std=gnu++11" CACHE STRING "C++ flags")
@ -45,7 +45,8 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
#set(CMAKE_STATIC_LINKER_FLAGS_INIT "-march=armv8-a -mtune=cortex-a57 -mtp=soft -L${DEVKITPRO}/libnx/lib -L${DEVKITPRO}/portlibs/switch/lib") #set(CMAKE_STATIC_LINKER_FLAGS_INIT "-march=armv8-a -mtune=cortex-a57 -mtp=soft -L${DEVKITPRO}/libnx/lib -L${DEVKITPRO}/portlibs/switch/lib")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-specs=${DEVKITPRO}/libnx/switch.specs -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -L${DEVKITPRO}/libnx/lib -L${DEVKITPRO}/portlibs/switch/lib") set(CMAKE_EXE_LINKER_FLAGS "-specs=${DEVKITPRO}/libnx/switch.specs -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -L${DEVKITPRO}/libnx/lib -L${DEVKITPRO}/portlibs/switch/lib")
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Shared libs not available") set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Shared libs not available")
set(CMAKE_INSTALL_PREFIX ${DEVKITPRO}/portlibs/switch) set(CMAKE_INSTALL_PREFIX ${DEVKITPRO}/portlibs/switch)

View File

@ -7,6 +7,8 @@
#include "osx_largefilewrapper.h" #include "osx_largefilewrapper.h"
#endif #endif
#include <unistd.h>
namespace athena::io namespace athena::io
{ {
FileWriter::FileWriter(std::string_view filename, bool overwrite, bool globalErr) FileWriter::FileWriter(std::string_view filename, bool overwrite, bool globalErr)
@ -82,6 +84,10 @@ void FileWriter::close()
m_fileHandle = NULL; m_fileHandle = NULL;
std::string tmpFilename = m_filename + '~'; std::string tmpFilename = m_filename + '~';
#ifdef __SWITCH__
/* Due to Horizon not being a fully POSIX compatible OS, we need to make sure the file *does not* exist before attempting to rename */
unlink(m_filename.c_str());
#endif
rename(tmpFilename.c_str(), m_filename.c_str()); rename(tmpFilename.c_str(), m_filename.c_str());
} }