2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-05-13 09:51:21 +00:00

Windows build fixes

This commit is contained in:
Luke Street 2025-04-04 17:32:05 -06:00
parent 4d9603183a
commit aaf96615cb
12 changed files with 62 additions and 29 deletions

View File

@ -86,14 +86,8 @@ if(APPLE AND NOT CMAKE_OSX_SYSROOT)
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# MSVC has a "latest" flag, which always uses the newest standard
# when available. GCC and Clang posess no such flag, and must be
# manually enforced. CMake, curiously, also doesn't have a "latest"
# standard flag either.
if (NOT MSVC)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Force shared libs off" FORCE)
set(BUILD_STATIC_LIBS ON CACHE BOOL "Force static libs on" FORCE)
@ -131,7 +125,8 @@ if(MSVC)
add_compile_definitions(UNICODE=1 _UNICODE=1 __SSE__=1
_CRT_SECURE_NO_WARNINGS=1 D_SCL_SECURE_NO_WARNINGS=1
_SCL_SECURE_NO_DEPRECATE=1 _CRT_NONSTDC_NO_WARNINGS=1
_ENABLE_EXTENDED_ALIGNED_STORAGE=1 NOMINMAX=1)
_ENABLE_EXTENDED_ALIGNED_STORAGE=1 NOMINMAX=1
_HAS_EXCEPTIONS=0)
add_compile_options(/IGNORE:4221
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4018>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/wd4800>
@ -165,14 +160,14 @@ if(MSVC)
# Reports the proper value for the __cplusplus preprocessor macro.
$<$<COMPILE_LANGUAGE:CXX>:/Zc:__cplusplus>
# Use latest C++ standard.
$<$<COMPILE_LANGUAGE:CXX>:/std:c++latest>
)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# Flags for MSVC (not clang-cl)
add_compile_options(
# Enable standards conforming preprocessor.
$<$<COMPILE_LANGUAGE:CXX>:/Zc:preprocessor>
# Allow constexpr variables to have explicit external linkage.
$<$<COMPILE_LANGUAGE:CXX>:/Zc:externConstexpr>

View File

@ -344,8 +344,8 @@ CNESEmulator::~CNESEmulator() {
}
int CNESEmulator::audioUpdate() {
// int origProcBufs = m_procBufs;
//
int origProcBufs = m_procBufs;
// uint8_t* data = apuGetBuf();
// if (data != NULL && m_procBufs) {
// uint32_t apuBufSz = apuGetMaxBufSize();
@ -370,7 +370,7 @@ int CNESEmulator::audioUpdate() {
// // if (!origProcBufs)
// // printf("OVERRUN\n");
//
// return origProcBufs;
return origProcBufs;
}
static constexpr uint32_t AudioFrameSz = 2 * sizeof(int16_t);

View File

@ -24,6 +24,9 @@
#define _WIN32_IE 0x0400
#endif
#include <ShlObj.h>
#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
#endif
#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
#endif
@ -349,7 +352,7 @@ void CBasics::MakeDir(const char* dir) {
const nowide::wstackstring wdir(dir);
if (!CreateDirectoryW(wdir.get(), NULL))
if ((err = GetLastError()) != ERROR_ALREADY_EXISTS)
LogModule.report(logvisor::Fatal, "MakeDir({})", dir);
spdlog::fatal("MakeDir({})", dir);
#else
if (mkdir(dir, 0755))
if (errno != EEXIST)

View File

@ -21,6 +21,7 @@
#endif
#include <Windows.h>
#include <shellapi.h>
#include <nowide/convert.hpp>
#endif
#include "../version.h"
@ -537,8 +538,8 @@ int main(int argc, char** argv) {
.allowJoystickBackgroundEvents = cvarCmns.getAllowJoystickInBackground(),
.windowPosX = cvarCmns.getWindowPos().x,
.windowPosY = cvarCmns.getWindowPos().y,
.windowWidth = static_cast<uint>(cvarCmns.getWindowSize().x < 0 ? 0 : cvarCmns.getWindowSize().x),
.windowHeight = static_cast<uint>(cvarCmns.getWindowSize().y < 0 ? 0 : cvarCmns.getWindowSize().y),
.windowWidth = static_cast<uint32_t>(cvarCmns.getWindowSize().x < 0 ? 0 : cvarCmns.getWindowSize().x),
.windowHeight = static_cast<uint32_t>(cvarCmns.getWindowSize().y < 0 ? 0 : cvarCmns.getWindowSize().y),
.iconRGBA8 = icon.data.get(),
.iconWidth = icon.width,
.iconHeight = icon.height,

View File

@ -150,7 +150,7 @@ endfunction()
set(RUNTIME_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
set(RUNTIME_LIBRARIES zeus nod NESEmulator libjpeg-turbo jbus kabufuda OptickCore
imgui_support aurora::aurora spdlog::spdlog
imgui_support aurora::aurora spdlog::spdlog $<$<BOOL:${WIN32}>:nowide::nowide>
${ZLIB_LIBRARIES}
)
@ -218,7 +218,7 @@ elseif (UNIX)
set(PLAT_LIBS rt)
endif ()
add_executable(metaforce CMain.cpp ${PLAT_SRCS}
add_executable(metaforce WIN32 CMain.cpp ${PLAT_SRCS}
ImGuiConsole.hpp ImGuiConsole.cpp
ImGuiControllerConfig.hpp ImGuiControllerConfig.cpp
ImGuiEntitySupport.hpp ImGuiEntitySupport.cpp)
@ -228,6 +228,9 @@ if (TARGET nfd)
target_link_libraries(metaforce PRIVATE nfd)
endif()
target_compile_definitions(metaforce PUBLIC "-DMETAFORCE_TARGET_BYTE_ORDER=__BYTE_ORDER__")
if (WIN32)
target_link_options(metaforce PRIVATE /ENTRY:wWinMainCRTStartup)
endif ()
if (APPLE)
if (TVOS)

View File

@ -3,9 +3,12 @@
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/IMain.hpp"
#include "Runtime/CBasics.hpp"
#include "Runtime/Formatting.hpp"
#include <ShlObj.h>
#include <SDL_filesystem.h>
#include <SDL3/SDL_filesystem.h>
#include <nowide/stackstring.hpp>
#include <nowide/convert.hpp>
namespace metaforce {
@ -117,8 +120,8 @@ std::string CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot, bool do
return {};
path += fmt::format("/MemoryCard{}.USA.raw", slot == kabufuda::ECardSlot::SlotA ? 'A' : 'B');
const nowide::wstackstring wpath(path);
FILE* fp = _wfopen(wpath.get(), L"wb");
const auto wpath = nowide::widen(path);
FILE* fp = _wfopen(wpath.c_str(), L"wb");
if (fp == nullptr) {
return {};
}
@ -136,8 +139,8 @@ std::string CMemoryCardSys::_CreateDolphinCard(kabufuda::ECardSlot slot, bool do
}
std::string tmpPath = path.substr(0, path.find_last_of('/'));
CBasics::RecursiveMakeDir(tmpPath.c_str());
const nowide::wstackstring wpath(path);
FILE* fp = _wfopen(wpath.get(), L"wb");
const auto wpath = nowide::widen(path);
FILE* fp = _wfopen(wpath.c_str(), L"wb");
if (fp) {
fclose(fp);
return path;

View File

@ -225,7 +225,14 @@ std::vector<StoreCVar::CVar> CVarManager::loadCVars(const std::string& filename)
if (parts.size() < 2) {
continue;
}
ret.emplace_back(StoreCVar::CVar{CStringExtras::Trim(parts[0]), CStringExtras::Trim(parts[1])});
const auto key = CStringExtras::Trim(parts[0]);
auto value = parts[1];
for (size_t i = 2; i < parts.size(); ++i) {
value += ":";
value += parts[i];
}
value = CStringExtras::Trim(value);
ret.emplace_back(StoreCVar::CVar{key, value});
}
}
}

View File

@ -1955,6 +1955,9 @@ AuroraBackend backend_from_string(const std::string& str) {
if (eq(str, "d3d12"sv) || eq(str, "d3d"sv)) {
return BACKEND_D3D12;
}
if (eq(str, "d3d11")) {
return BACKEND_D3D11;
}
if (eq(str, "metal"sv)) {
return BACKEND_METAL;
}
@ -1982,6 +1985,8 @@ std::string_view backend_to_string(AuroraBackend backend) {
return "auto"sv;
case BACKEND_D3D12:
return "d3d12"sv;
case BACKEND_D3D11:
return "d3d11"sv;
case BACKEND_METAL:
return "metal"sv;
case BACKEND_VULKAN:
@ -2003,6 +2008,8 @@ std::string_view backend_name(AuroraBackend backend) {
return "Auto"sv;
case BACKEND_D3D12:
return "D3D12"sv;
case BACKEND_D3D11:
return "D3D11"sv;
case BACKEND_METAL:
return "Metal"sv;
case BACKEND_VULKAN:

View File

@ -3,7 +3,9 @@ cmake_policy(VERSION 3.15...3.20)
project(bintoc LANGUAGES C)
add_executable(bintoc bintoc.c)
add_subdirectory(../extern/athena/extern/zlib zlib EXCLUDE_FROM_ALL)
find_package(ZLIB REQUIRED)
set(ZLIB_LIBRARIES ZLIB::ZLIB CACHE STRING "zlib libraries" FORCE)
target_link_libraries(bintoc PRIVATE ${ZLIB_LIBRARIES})
install(TARGETS bintoc DESTINATION bin)

12
extern/CMakeLists.txt vendored
View File

@ -14,6 +14,18 @@ if (NOT TARGET spdlog)
add_subdirectory(spdlog EXCLUDE_FROM_ALL)
endif ()
if (WIN32 AND NOT TARGET nowide)
include(FetchContent)
FetchContent_Declare(
nowide
URL https://github.com/boostorg/nowide/releases/download/v11.3.0/nowide_standalone_v11.3.0.tar.gz
URL_HASH SHA256=153ac93173c8de9c08e7701e471fa750f84c27e51fe329570c5aa06016591f8c
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(nowide)
endif ()
add_subdirectory(nod EXCLUDE_FROM_ALL)
add_subdirectory(jbus EXCLUDE_FROM_ALL)
add_subdirectory(kabufuda EXCLUDE_FROM_ALL)

2
extern/aurora vendored

@ -1 +1 @@
Subproject commit 1016fbb36d5479cbad909323d083ed232063a7a5
Subproject commit 5c7ee8b04ab9febc11a6b79cfb54af6803e03c26

2
extern/nod vendored

@ -1 +1 @@
Subproject commit 9584303083c8406a37a7834a443d8dfe34eb0d69
Subproject commit 6febcc2c79c54a964a43ed462312091197d75bb2