From 66404a669fe838dce4df93f2b8986e02f748005e Mon Sep 17 00:00:00 2001 From: Steveice10 <1269164+Steveice10@users.noreply.github.com> Date: Mon, 14 Aug 2023 09:47:17 -0700 Subject: [PATCH] build: Fixes for a few minor issues (#6886) --- externals/CMakeLists.txt | 1 + src/audio_core/CMakeLists.txt | 2 +- src/common/file_util.cpp | 16 +++++++++------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 17f0764a1..44882d6cf 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -97,6 +97,7 @@ set(ENABLE_GLSLANG_BINARIES OFF CACHE BOOL "") set(ENABLE_SPVREMAPPER OFF CACHE BOOL "") set(ENABLE_CTEST OFF CACHE BOOL "") set(ENABLE_HLSL OFF CACHE BOOL "") +set(BUILD_EXTERNAL OFF CACHE BOOL "") add_subdirectory(glslang) # inih diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt index 4385cdf5f..fddcc866d 100644 --- a/src/audio_core/CMakeLists.txt +++ b/src/audio_core/CMakeLists.txt @@ -47,7 +47,7 @@ add_library(audio_core STATIC create_target_directory_groups(audio_core) -target_link_libraries(audio_core PUBLIC citra_common) +target_link_libraries(audio_core PUBLIC citra_common citra_core) target_link_libraries(audio_core PRIVATE SoundTouch teakra) set_target_properties(audio_core PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) add_definitions(-DSOUNDTOUCH_INTEGER_SAMPLES) diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 18e4be629..acbf79bff 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -16,6 +16,7 @@ #include "common/common_paths.h" #include "common/file_util.h" #include "common/logging/log.h" +#include "common/scope_exit.h" #include "common/string_util.h" #ifdef _WIN32 @@ -324,31 +325,32 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { return AndroidStorage::CopyFile(srcFilename, std::string(GetParentPath(destFilename)), std::string(GetFilename(destFilename))); #else - using CFilePointer = std::unique_ptr; // Open input file - CFilePointer input{fopen(srcFilename.c_str(), "rb"), std::fclose}; + FILE* input = fopen(srcFilename.c_str(), "rb"); if (!input) { LOG_ERROR(Common_Filesystem, "opening input failed {} --> {}: {}", srcFilename, destFilename, GetLastErrorMsg()); return false; } + SCOPE_EXIT({ fclose(input); }); // open output file - CFilePointer output{fopen(destFilename.c_str(), "wb"), std::fclose}; + FILE* output = fopen(destFilename.c_str(), "wb"); if (!output) { LOG_ERROR(Common_Filesystem, "opening output failed {} --> {}: {}", srcFilename, destFilename, GetLastErrorMsg()); return false; } + SCOPE_EXIT({ fclose(output); }); // copy loop std::array buffer; - while (!feof(input.get())) { + while (!feof(input)) { // read input - std::size_t rnum = fread(buffer.data(), sizeof(char), buffer.size(), input.get()); + std::size_t rnum = fread(buffer.data(), sizeof(char), buffer.size(), input); if (rnum != buffer.size()) { - if (ferror(input.get()) != 0) { + if (ferror(input) != 0) { LOG_ERROR(Common_Filesystem, "failed reading from source, {} --> {}: {}", srcFilename, destFilename, GetLastErrorMsg()); return false; @@ -356,7 +358,7 @@ bool Copy(const std::string& srcFilename, const std::string& destFilename) { } // write output - std::size_t wnum = fwrite(buffer.data(), sizeof(char), rnum, output.get()); + std::size_t wnum = fwrite(buffer.data(), sizeof(char), rnum, output); if (wnum != rnum) { LOG_ERROR(Common_Filesystem, "failed writing to output, {} --> {}: {}", srcFilename, destFilename, GetLastErrorMsg());