From 2f5f9df6209442ec1cffc54e3ef95a4c103ef8da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 22 Sep 2023 22:14:49 +0200 Subject: [PATCH] Customize the cmake build. Android now builds that way too. Fixes. Hack around build error port the last fix to Android.mk One more attempt Warning fixes Oops, forgot a slash --- CMakeLists.txt | 2 +- UI/RetroAchievementScreens.cpp | 6 ++-- android/ab.cmd | 2 +- android/jni/Android.mk | 62 ++++++++++++++++++-------------- ext/CMakeLists.txt | 3 +- ext/libchdr-build/CMakeLists.txt | 38 ++++++++++++++++++++ 6 files changed, 79 insertions(+), 34 deletions(-) create mode 100644 ext/libchdr-build/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ccd674fd31e..af616d3e2a9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2319,7 +2319,7 @@ endif() include_directories(ext/libchdr/include) -target_link_libraries(${CoreLibName} Common native chdr-static kirk cityhash sfmt19937 xbrz xxhash rcheevos ${GlslangLibs} +target_link_libraries(${CoreLibName} Common native chdr kirk cityhash sfmt19937 xbrz xxhash rcheevos ${GlslangLibs} ${CoreExtraLibs} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${CMAKE_DL_LIBS}) if(NOT HTTPS_NOT_AVAILABLE) diff --git a/UI/RetroAchievementScreens.cpp b/UI/RetroAchievementScreens.cpp index d8ebceb9ffc9..a92663d3f53a 100644 --- a/UI/RetroAchievementScreens.cpp +++ b/UI/RetroAchievementScreens.cpp @@ -516,7 +516,7 @@ void RenderAchievement(UIContext &dc, const rc_client_achievement_t *achievement char cacheKey[256]; snprintf(cacheKey, sizeof(cacheKey), "ai:%s:%s", achievement->badge_name, iconState == RC_CLIENT_ACHIEVEMENT_STATE_UNLOCKED ? "unlocked" : "locked"); if (RC_OK == rc_client_achievement_get_image_url(achievement, iconState, temp, sizeof(temp))) { - Achievements::DownloadImageIfMissing(cacheKey, std::move(std::string(temp))); + Achievements::DownloadImageIfMissing(cacheKey, std::string(temp)); if (g_iconCache.BindIconTexture(&dc, cacheKey)) { dc.Draw()->DrawTexRect(Bounds(bounds.x + padding, bounds.y + padding, iconSpace, iconSpace), 0.0f, 0.0f, 1.0f, 1.0f, whiteAlpha(alpha)); } @@ -560,7 +560,7 @@ void RenderGameAchievementSummary(UIContext &dc, const Bounds &bounds, float alp char cacheKey[256]; snprintf(cacheKey, sizeof(cacheKey), "gi:%s", gameInfo->badge_name); if (RC_OK == rc_client_game_get_image_url(gameInfo, url, sizeof(url))) { - Achievements::DownloadImageIfMissing(cacheKey, std::move(std::string(url))); + Achievements::DownloadImageIfMissing(cacheKey, std::string(url)); if (g_iconCache.BindIconTexture(&dc, cacheKey)) { dc.Draw()->DrawTexRect(Bounds(bounds.x, bounds.y, iconSpace, iconSpace), 0.0f, 0.0f, 1.0f, 1.0f, whiteAlpha(alpha)); } @@ -660,7 +660,7 @@ void RenderLeaderboardEntry(UIContext &dc, const rc_client_leaderboard_entry_t * snprintf(cacheKey, sizeof(cacheKey), "lbe:%s", entry->user); char temp[512]; if (RC_OK == rc_client_leaderboard_entry_get_user_image_url(entry, temp, sizeof(temp))) { - Achievements::DownloadImageIfMissing(cacheKey, std::move(std::string(temp))); + Achievements::DownloadImageIfMissing(cacheKey, std::string(temp)); if (g_iconCache.BindIconTexture(&dc, cacheKey)) { dc.Draw()->DrawTexRect(Bounds(bounds.x + iconLeft, bounds.y + 4.0f, 64.0f, 64.0f), 0.0f, 0.0f, 1.0f, 1.0f, whiteAlpha(alpha)); } diff --git a/android/ab.cmd b/android/ab.cmd index f205269c8b95..412ba8263e09 100644 --- a/android/ab.cmd +++ b/android/ab.cmd @@ -11,5 +11,5 @@ copy ..\assets\*.meta assets\ copy ..\assets\*.wav assets\ SET NDK=C:\Android\sdk\ndk\21.3.6528147 REM SET NDK=C:\Android\ndk -SET NDK_MODULE_PATH=..\ext;..\ext\native\ext +SET NDK_MODULE_PATH=..\ext %NDK%/ndk-build -j32 %* diff --git a/android/jni/Android.mk b/android/jni/Android.mk index d9042822e7e8..c70bba4eb4ce 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -4,6 +4,40 @@ SRC := ../.. include $(CLEAR_VARS) include $(LOCAL_PATH)/Locals.mk +LOCAL_CFLAGS += -D_7ZIP_ST -D__SWITCH__ + +LZMA_FILES := \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/Alloc.c \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/Bcj2.c \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/Bcj2Enc.c \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/Bra.c \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/Bra86.c \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/CpuArch.c \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/Delta.c \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/LzFind.c \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/LzFindOpt.c \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/LzmaDec.c \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/LzmaEnc.c \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/Lzma86Dec.c \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/Lzma86Enc.c \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/LzmaLib.c \ + $(SRC)/ext/libchdr/deps/lzma-22.01/src/Sort.c + +CHDR_FILES := \ + ${LZMA_FILES} \ + $(SRC)/ext/libchdr/src/libchdr_bitstream.c \ + $(SRC)/ext/libchdr/src/libchdr_cdrom.c \ + $(SRC)/ext/libchdr/src/libchdr_chd.c \ + $(SRC)/ext/libchdr/src/libchdr_flac.c \ + $(SRC)/ext/libchdr/src/libchdr_huffman.c + +LOCAL_MODULE := libchdr +LOCAL_SRC_FILES := $(CHDR_FILES) +include $(BUILD_STATIC_LIBRARY) + +include $(CLEAR_VARS) +include $(LOCAL_PATH)/Locals.mk + LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/../../ext/cpu_features/include \ $(LOCAL_PATH)/../../ext/rcheevos/include @@ -113,33 +147,7 @@ VR_FILES := \ $(SRC)/Common/VR/VRMath.cpp \ $(SRC)/Common/VR/VRRenderer.cpp -LZMA_FILES := \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/Alloc.c \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/Bcj2.c \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/Bcj2Enc.c \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/Bra.c \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/Bra86.c \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/CpuArch.c \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/Delta.c \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/LzFind.c \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/LzFindOpt.c \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/LzmaDec.c \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/LzmaEnc.c \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/Lzma86Dec.c \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/Lzma86Enc.c \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/LzmaLib.c \ - $(SRC)/ext/libchdr/deps/lzma-22.01/src/Sort.c - -CHDR_FILES := \ - $(SRC)/ext/libchdr/src/libchdr_bitstream.c \ - $(SRC)/ext/libchdr/src/libchdr_cdrom.c \ - $(SRC)/ext/libchdr/src/libchdr_chd.c \ - $(SRC)/ext/libchdr/src/libchdr_flac.c \ - $(SRC)/ext/libchdr/src/libchdr_huffman.c - EXT_FILES := \ - $(LZMA_FILES) \ - $(CHDR_FILES) \ $(SRC)/ext/cityhash/city.cpp \ $(SRC)/ext/libpng17/png.c \ $(SRC)/ext/libpng17/pngerror.c \ @@ -314,7 +322,7 @@ include $(BUILD_STATIC_LIBRARY) # Next up, Core, GPU, and other core parts shared by headless. include $(CLEAR_VARS) include $(LOCAL_PATH)/Locals.mk -LOCAL_WHOLE_STATIC_LIBRARIES += ppsspp_common +LOCAL_WHOLE_STATIC_LIBRARIES += ppsspp_common libchdr ifeq ($(TARGET_ARCH_ABI),x86_64) ARCH_FILES := \ diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index 10424cf01a1d..1031f6edf91c 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -38,5 +38,4 @@ if(USE_DISCORD AND NOT IOS AND NOT LIBRETRO) add_subdirectory(discord-rpc-build) endif() -set(BUILD_SHARED_LIBS OFF) -add_subdirectory(libchdr) \ No newline at end of file +add_subdirectory(libchdr-build) diff --git a/ext/libchdr-build/CMakeLists.txt b/ext/libchdr-build/CMakeLists.txt new file mode 100644 index 000000000000..8b93aa42fe4d --- /dev/null +++ b/ext/libchdr-build/CMakeLists.txt @@ -0,0 +1,38 @@ +cmake_minimum_required (VERSION 3.2.0) +project (chdr) + +set(LZMA_DIR ../libchdr/deps/lzma-22.01/src) +set(SRC_DIR ../libchdr/src) + +include_directories(../libchdr/deps/lzma-22.01/include) +include_directories(../libchdr/include) + +add_definitions(-D_7ZIP_ST) + +# Hack - CpuArch.c has a workaround that we reuse. +add_definitions(-D__SWITCH__) + +set(ALL_SOURCE_FILES + ${LZMA_DIR}/Alloc.c + ${LZMA_DIR}/Bcj2.c + ${LZMA_DIR}/Bcj2Enc.c + ${LZMA_DIR}/Bra.c + ${LZMA_DIR}/Bra86.c + ${LZMA_DIR}/CpuArch.c + ${LZMA_DIR}/Delta.c + ${LZMA_DIR}/LzFind.c + ${LZMA_DIR}/LzFindOpt.c + ${LZMA_DIR}/LzmaDec.c + ${LZMA_DIR}/LzmaEnc.c + ${LZMA_DIR}/Lzma86Dec.c + ${LZMA_DIR}/Lzma86Enc.c + ${LZMA_DIR}/LzmaLib.c + ${LZMA_DIR}/Sort.c + ${SRC_DIR}/libchdr_bitstream.c + ${SRC_DIR}/libchdr_cdrom.c + ${SRC_DIR}/libchdr_chd.c + ${SRC_DIR}/libchdr_flac.c + ${SRC_DIR}/libchdr_huffman.c + ) + +add_library(chdr STATIC ${ALL_SOURCE_FILES})