From 92cb90f43322e64fb614f43a5073bd3a52f19e89 Mon Sep 17 00:00:00 2001 From: rogerman Date: Thu, 26 Aug 2021 14:32:25 -0700 Subject: [PATCH] Cocoa Port: Fix build errors that can occur when building on Xcode versions later than 10.3. - The script that renames the DeSmuME.app package with the git version now runs as a Build Post-Action script rather than as the last build rule. This is to fix an incompatibility with code signing, which is now forced in Xcode 11 and later. - Update some variables to comply with newer and stricter compiler rules. --- .gitignore | 1 + .../project.pbxproj | 50 +++++-------------- ...eSmuME (OS X App -- Latest Xcode).xcscheme | 28 ++++++++--- ...(OS X App with 32-bit -- Xcode 9).xcscheme | 28 ++++++++--- desmume/src/frontend/cocoa/Info (Debug).plist | 2 +- desmume/src/frontend/cocoa/Info.plist | 2 +- .../src/frontend/cocoa/OGLDisplayOutput.cpp | 6 +-- .../cocoa/userinterface/MacBaseCaptureTool.h | 4 +- .../userinterface/MacScreenshotCaptureTool.mm | 4 +- desmume/src/texcache.cpp | 21 +++++--- 10 files changed, 78 insertions(+), 68 deletions(-) diff --git a/.gitignore b/.gitignore index 5bc2e7ff8..7f7f06262 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,4 @@ xcuserdata/ /.cproject /config.log /.project +.DS_Store diff --git a/desmume/src/frontend/cocoa/DeSmuME (Latest).xcodeproj/project.pbxproj b/desmume/src/frontend/cocoa/DeSmuME (Latest).xcodeproj/project.pbxproj index d53c0e26e..91e8d38d2 100644 --- a/desmume/src/frontend/cocoa/DeSmuME (Latest).xcodeproj/project.pbxproj +++ b/desmume/src/frontend/cocoa/DeSmuME (Latest).xcodeproj/project.pbxproj @@ -4454,7 +4454,6 @@ AB2DF23215E0834E00B4D0BC /* ShellScript */, AB796CEE15CDCBA200C59155 /* Sources */, AB796D6515CDCBA200C59155 /* Frameworks */, - AB8CF4681FBCEA010039C223 /* ShellScript */, ); buildRules = ( ); @@ -4475,7 +4474,6 @@ AB79004B215B84E50082AE82 /* ShellScript */, AB79004C215B84E50082AE82 /* Sources */, AB790128215B84E50082AE82 /* Frameworks */, - AB790139215B84E50082AE82 /* ShellScript */, ); buildRules = ( ); @@ -5260,7 +5258,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "#!/bin/sh\n\n# This script creates an application package that merges the ppc binary of an\n# Xcode 3 PowerPC release build to the i386 and x86_64 binaries of an Xcode 4\n# (or later) release build. It also replaces the .nib files with ones that are\n# created specifically in Xcode 6, which is the last version of Xcode that can\n# compile Leopard-compatible .nib files.\n#\n# Before you use this script, make sure that you already have an existing\n# PowerPC Release build from Xcode 3 in the ${SRCROOT}/build/Release directory,\n# as well as an Xcode 6 .app in the same directory.\n\n# Create the Merged Release directory, plus a working copy of the .app.\nmkdir -p \"${SRCROOT}/build/Merged Release\"\ncd \"${SRCROOT}/build/Merged Release\"\ncp -a \"${TARGET_BUILD_DIR}/${PRODUCT_NAME}.app\" \"./\"\n\nif test -e \"${SRCROOT}/build/Release/DeSmuME (PPC).app/Contents/MacOS/DeSmuME (PPC)\"\nthen\n\ncd \"${TARGET_BUILD_DIR}/${PRODUCT_NAME}.app/Contents/MacOS\"\n\n# Create the temp binaries for Intel.\nlipo \"./${EXECUTABLE_NAME}\" -thin i386 -output \"./${EXECUTABLE_NAME}_i386\"\nlipo \"./${EXECUTABLE_NAME}\" -thin x86_64 -output \"./${EXECUTABLE_NAME}_x86_64\"\n\n# Merge the separate temp binaries into a single binary package.\nrm -f \"${SRCROOT}/build/Merged Release/${PRODUCT_NAME}.app/Contents/MacOS/${EXECUTABLE_NAME}\"\nlipo \"${SRCROOT}/build/Release/DeSmuME (PPC).app/Contents/MacOS/DeSmuME (PPC)\" \"./${EXECUTABLE_NAME}_i386\" \"./${EXECUTABLE_NAME}_x86_64\" -create -output \"${SRCROOT}/build/Merged Release/${PRODUCT_NAME}.app/Contents/MacOS/${EXECUTABLE_NAME}\"\n\n# Remove the temp binaries now that we're done with them.\nrm -f \"./${EXECUTABLE_NAME}_i386\"\nrm -f \"./${EXECUTABLE_NAME}_x86_64\"\n\nfi\n\n# Copy the .nib files from an \"extract NIB\" .app to the Merged Release .app\ncd \"${SRCROOT}/build/Merged Release/${PRODUCT_NAME}.app/Contents/Resources/English.lproj\"\ncp -af \"${SRCROOT}/build/Release/DeSmuME (extract NIB).app/Contents/Resources/English.lproj/MainMenu.nib\" \"./\"\ncp -af \"${SRCROOT}/build/Release/DeSmuME (extract NIB).app/Contents/Resources/English.lproj/DisplayWindow.nib\" \"./\""; + shellScript = "#!/bin/sh\n\n# This script creates an application package that merges the ppc binary of an\n# Xcode 3 PowerPC release build to the i386 and x86_64 binaries of an Xcode 4\n# (or later) release build. It also replaces the .nib files with ones that are\n# created specifically in Xcode 6, which is the last version of Xcode that can\n# compile Leopard-compatible .nib files.\n#\n# Before you use this script, make sure that you already have an existing\n# PowerPC Release build from Xcode 3 in the ${SRCROOT}/build/Release directory,\n# as well as an Xcode 6 .app in the same directory.\n\n# Create the Merged Release directory, plus a working copy of the .app.\nmkdir -p \"${SRCROOT}/build/Merged Release\"\ncd \"${SRCROOT}/build/Merged Release\"\ncp -a \"${TARGET_BUILD_DIR}/${PRODUCT_NAME}.app\" \"./\"\n\nif test -e \"${SRCROOT}/build/Release/DeSmuME (PPC).app/Contents/MacOS/DeSmuME (PPC)\"\nthen\n\ncd \"${TARGET_BUILD_DIR}/${PRODUCT_NAME}.app/Contents/MacOS\"\n\n# Create the temp binaries for Intel.\nlipo \"./${EXECUTABLE_NAME}\" -thin i386 -output \"./${EXECUTABLE_NAME}_i386\"\nlipo \"./${EXECUTABLE_NAME}\" -thin x86_64 -output \"./${EXECUTABLE_NAME}_x86_64\"\n\n# Merge the separate temp binaries into a single binary package.\nrm -f \"${SRCROOT}/build/Merged Release/${PRODUCT_NAME}.app/Contents/MacOS/${EXECUTABLE_NAME}\"\nlipo \"${SRCROOT}/build/Release/DeSmuME (PPC).app/Contents/MacOS/DeSmuME (PPC)\" \"./${EXECUTABLE_NAME}_i386\" \"./${EXECUTABLE_NAME}_x86_64\" -create -output \"${SRCROOT}/build/Merged Release/${PRODUCT_NAME}.app/Contents/MacOS/${EXECUTABLE_NAME}\"\n\n# Remove the temp binaries now that we're done with them.\nrm -f \"./${EXECUTABLE_NAME}_i386\"\nrm -f \"./${EXECUTABLE_NAME}_x86_64\"\n\nfi\n\n# Copy the .nib files from an \"extract NIB\" .app to the Merged Release .app\ncd \"${SRCROOT}/build/Merged Release/${PRODUCT_NAME}.app/Contents/Resources/English.lproj\"\ncp -af \"${SRCROOT}/build/Release/DeSmuME (extract NIB).app/Contents/Resources/English.lproj/MainMenu.nib\" \"./\"\ncp -af \"${SRCROOT}/build/Release/DeSmuME (extract NIB).app/Contents/Resources/English.lproj/DisplayWindow.nib\" \"./\"\n"; }; AB2DF23215E0834E00B4D0BC /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -5274,7 +5272,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "cd \"${SRCROOT}\"\nsh \"git-scmrev.sh\""; + shellScript = "cd \"${SRCROOT}\"\nsh \"git-scmrev.sh\"\n"; }; AB2DF23515E0839D00B4D0BC /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -5302,20 +5300,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "cd \"${SRCROOT}\"\nsh \"git-scmrev.sh\""; - }; - AB790139215B84E50082AE82 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "if test -d \"${TARGET_BUILD_DIR}/DeSmuME.app\" ; then\n\nDESCRIBE=`git describe --always --long --dirty=\"+\"`\nif [ \"$DESCRIBE\" == \"\" ] ; then\nDESCRIBE=\"0\"\nfi\n\nNEWBUILDNAME=\"${PRODUCT_NAME} git#$DESCRIBE.app\"\ncd \"${TARGET_BUILD_DIR}\"\nrm -rf \"$NEWBUILDNAME\"\nmv -f \"${PRODUCT_NAME}.app\" \"$NEWBUILDNAME\"\n\nfi"; + shellScript = "cd \"${SRCROOT}\"\nsh \"git-scmrev.sh\"\n"; }; AB790140215B84F20082AE82 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -5330,7 +5315,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "cd \"${SRCROOT}/translations\"\nibtool --generate-strings-file \"./English.lproj/MainMenu.strings\" \"./English.lproj/MainMenu.xib\""; + shellScript = "cd \"${SRCROOT}/translations\"\nibtool --generate-strings-file \"./English.lproj/MainMenu.strings\" \"./English.lproj/MainMenu.xib\"\n"; }; AB7901A8215B84F20082AE82 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -5344,7 +5329,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "cd \"${SRCROOT}\"\nsh \"git-scmrev.sh\""; + shellScript = "cd \"${SRCROOT}\"\nsh \"git-scmrev.sh\"\n"; }; AB796CA515CDCBA200C59155 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -5359,7 +5344,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "cd \"${SRCROOT}/translations\"\nibtool --generate-strings-file \"./English.lproj/MainMenu.strings\" \"./English.lproj/MainMenu.xib\""; + shellScript = "cd \"${SRCROOT}/translations\"\nibtool --generate-strings-file \"./English.lproj/MainMenu.strings\" \"./English.lproj/MainMenu.xib\"\n"; }; AB79FFE3215B84E50082AE82 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -5374,20 +5359,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "cd \"${SRCROOT}/translations\"\nibtool --generate-strings-file \"./English.lproj/MainMenu.strings\" \"./English.lproj/MainMenu.xib\""; - }; - AB8CF4681FBCEA010039C223 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "if test -d \"${TARGET_BUILD_DIR}/DeSmuME.app\" ; then\n\nDESCRIBE=`git describe --always --long --dirty=\"+\"`\nif [ \"$DESCRIBE\" == \"\" ] ; then\nDESCRIBE=\"0\"\nfi\n\nNEWBUILDNAME=\"${PRODUCT_NAME} git#$DESCRIBE.app\"\ncd \"${TARGET_BUILD_DIR}\"\nrm -rf \"$NEWBUILDNAME\"\nmv -f \"${PRODUCT_NAME}.app\" \"$NEWBUILDNAME\"\n\nfi"; + shellScript = "cd \"${SRCROOT}/translations\"\nibtool --generate-strings-file \"./English.lproj/MainMenu.strings\" \"./English.lproj/MainMenu.xib\"\n"; }; AB8F3C181A53AC2600A80BF6 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -5402,7 +5374,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "cd \"${SRCROOT}/translations\"\nibtool --generate-strings-file \"./English.lproj/MainMenu.strings\" \"./English.lproj/MainMenu.xib\""; + shellScript = "cd \"${SRCROOT}/translations\"\nibtool --generate-strings-file \"./English.lproj/MainMenu.strings\" \"./English.lproj/MainMenu.xib\"\n"; }; AB8F3C721A53AC2600A80BF6 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -5416,7 +5388,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "cd \"${SRCROOT}\"\nsh \"git-scmrev.sh\""; + shellScript = "cd \"${SRCROOT}\"\nsh \"git-scmrev.sh\"\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -7101,7 +7073,9 @@ isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_X86_VECTOR_INSTRUCTIONS = sse4.1; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/openemu\"", @@ -7118,7 +7092,9 @@ isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; + CLANG_X86_VECTOR_INSTRUCTIONS = sse4.1; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/openemu\"", diff --git a/desmume/src/frontend/cocoa/DeSmuME (Latest).xcodeproj/xcshareddata/xcschemes/DeSmuME (OS X App -- Latest Xcode).xcscheme b/desmume/src/frontend/cocoa/DeSmuME (Latest).xcodeproj/xcshareddata/xcschemes/DeSmuME (OS X App -- Latest Xcode).xcscheme index f121f3a2c..dc8d66dde 100644 --- a/desmume/src/frontend/cocoa/DeSmuME (Latest).xcodeproj/xcshareddata/xcschemes/DeSmuME (OS X App -- Latest Xcode).xcscheme +++ b/desmume/src/frontend/cocoa/DeSmuME (Latest).xcodeproj/xcshareddata/xcschemes/DeSmuME (OS X App -- Latest Xcode).xcscheme @@ -1,10 +1,28 @@ + version = "1.7"> + + + + + + + + + + - - - - + + - - + version = "1.7"> + + + + + + + + + + - - - - + + - - CFBundleVersion 0.9.12 LSApplicationCategoryType - public.app-category.entertainment + public.app-category.games LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/desmume/src/frontend/cocoa/Info.plist b/desmume/src/frontend/cocoa/Info.plist index 340e898bb..06bfae9ed 100644 --- a/desmume/src/frontend/cocoa/Info.plist +++ b/desmume/src/frontend/cocoa/Info.plist @@ -246,7 +246,7 @@ CFBundleVersion 0.9.12 LSApplicationCategoryType - public.app-category.entertainment + public.app-category.games LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHumanReadableCopyright diff --git a/desmume/src/frontend/cocoa/OGLDisplayOutput.cpp b/desmume/src/frontend/cocoa/OGLDisplayOutput.cpp index c6e1be493..fc788d37c 100644 --- a/desmume/src/frontend/cocoa/OGLDisplayOutput.cpp +++ b/desmume/src/frontend/cocoa/OGLDisplayOutput.cpp @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2017 DeSmuME team + Copyright (C) 2014-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -7120,8 +7120,8 @@ void OGLDisplayLayer::ProcessOGL() GLuint texMain = (selectedDisplaySource[NDSDisplayID_Main] == NDSDisplayID_Main) ? fetchObj.GetFetchTexture(NDSDisplayID_Main) : fetchObj.GetFetchTexture(NDSDisplayID_Touch); GLuint texTouch = (selectedDisplaySource[NDSDisplayID_Touch] == NDSDisplayID_Touch) ? fetchObj.GetFetchTexture(NDSDisplayID_Touch) : fetchObj.GetFetchTexture(NDSDisplayID_Main); - GLsizei width[2] = { emuDisplayInfo.renderedWidth[selectedDisplaySource[NDSDisplayID_Main]], emuDisplayInfo.renderedWidth[selectedDisplaySource[NDSDisplayID_Touch]] }; - GLsizei height[2] = { emuDisplayInfo.renderedHeight[selectedDisplaySource[NDSDisplayID_Main]], emuDisplayInfo.renderedHeight[selectedDisplaySource[NDSDisplayID_Touch]] }; + GLsizei width[2] = { (GLsizei)emuDisplayInfo.renderedWidth[selectedDisplaySource[NDSDisplayID_Main]], (GLsizei)emuDisplayInfo.renderedWidth[selectedDisplaySource[NDSDisplayID_Touch]] }; + GLsizei height[2] = { (GLsizei)emuDisplayInfo.renderedHeight[selectedDisplaySource[NDSDisplayID_Main]], (GLsizei)emuDisplayInfo.renderedHeight[selectedDisplaySource[NDSDisplayID_Touch]] }; VideoFilter *vfMain = this->_output->GetPixelScalerObject(NDSDisplayID_Main); VideoFilter *vfTouch = this->_output->GetPixelScalerObject(NDSDisplayID_Touch); diff --git a/desmume/src/frontend/cocoa/userinterface/MacBaseCaptureTool.h b/desmume/src/frontend/cocoa/userinterface/MacBaseCaptureTool.h index 544e2d399..ad59e511a 100644 --- a/desmume/src/frontend/cocoa/userinterface/MacBaseCaptureTool.h +++ b/desmume/src/frontend/cocoa/userinterface/MacBaseCaptureTool.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 DeSmuME team + Copyright (C) 2018-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -86,7 +86,7 @@ public: void *refObject; MacClientSharedObject *sharedData; - NSInteger formatID; + NSUInteger formatID; std::string savePath; std::string romName; bool useDeposterize; diff --git a/desmume/src/frontend/cocoa/userinterface/MacScreenshotCaptureTool.mm b/desmume/src/frontend/cocoa/userinterface/MacScreenshotCaptureTool.mm index 96f1eec26..5bd34b76d 100644 --- a/desmume/src/frontend/cocoa/userinterface/MacScreenshotCaptureTool.mm +++ b/desmume/src/frontend/cocoa/userinterface/MacScreenshotCaptureTool.mm @@ -1,5 +1,5 @@ /* - Copyright (C) 2017-2018 DeSmuME team + Copyright (C) 2017-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -292,7 +292,7 @@ static void* RunFileWriteThread(void *arg) NSString *savePath = [NSString stringWithCString:param.savePath.c_str() encoding:NSUTF8StringEncoding]; NSURL *fileURL = [NSURL fileURLWithPath:[savePath stringByAppendingPathComponent:fileName]]; - [CocoaDSFile saveScreenshot:fileURL bitmapData:newImageRep fileType:param.formatID]; + [CocoaDSFile saveScreenshot:fileURL bitmapData:newImageRep fileType:(NSBitmapImageFileType)param.formatID]; // Clean up. delete cdp; diff --git a/desmume/src/texcache.cpp b/desmume/src/texcache.cpp index b449a250c..137fdb289 100644 --- a/desmume/src/texcache.cpp +++ b/desmume/src/texcache.cpp @@ -1,7 +1,7 @@ /* Copyright (C) 2006 yopyop Copyright (C) 2006-2007 shash - Copyright (C) 2008-2017 DeSmuME team + Copyright (C) 2008-2021 DeSmuME team This file is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1156,8 +1156,8 @@ template void NDSTextureUnpack4x4(const size_t srcSize, const u32 *__restrict srcData, const u16 *__restrict srcIndex, const u32 palAddress, const u32 sizeX, const u32 sizeY, u32 *__restrict dstBuffer) { const u32 limit = srcSize * sizeof(u32); - const u16 xTmpSize = sizeX >> 2; - const u16 yTmpSize = sizeY >> 2; + const u32 xTmpSize = sizeX >> 2; + const u32 yTmpSize = sizeY >> 2; //this is flagged whenever a 4x4 overruns its slot. //i am guessing we just generate black in that case @@ -1165,8 +1165,13 @@ void NDSTextureUnpack4x4(const size_t srcSize, const u32 *__restrict srcData, co for (size_t y = 0, d = 0; y < yTmpSize; y++) { - u32 tmpPos[4]={(y<<2)*sizeX,((y<<2)+1)*sizeX, - ((y<<2)+2)*sizeX,((y<<2)+3)*sizeX}; + size_t tmpPos[4] = { + ((y<<2)+0) * sizeX, + ((y<<2)+1) * sizeX, + ((y<<2)+2) * sizeX, + ((y<<2)+3) * sizeX + }; + for (size_t x = 0; x < xTmpSize; x++, d++) { if (d >= limit) @@ -1174,9 +1179,9 @@ void NDSTextureUnpack4x4(const size_t srcSize, const u32 *__restrict srcData, co if (dead) { - for (int sy = 0; sy < 4; sy++) + for (size_t sy = 0; sy < 4; sy++) { - const u32 currentPos = (x<<2) + tmpPos[sy]; + const size_t currentPos = (x<<2) + tmpPos[sy]; dstBuffer[currentPos] = dstBuffer[currentPos+1] = dstBuffer[currentPos+2] = dstBuffer[currentPos+3] = 0; } continue; @@ -1268,7 +1273,7 @@ void NDSTextureUnpack4x4(const size_t srcSize, const u32 *__restrict srcData, co for (size_t sy = 0; sy < 4; sy++) { // Texture offset - const u32 currentPos = (x<<2) + tmpPos[sy]; + const size_t currentPos = (x<<2) + tmpPos[sy]; const u8 currRow = (u8)((currBlock>>(sy<<3))&0xFF); dstBuffer[currentPos ] = tmp_col[ currRow &3];