Skip to content

Commit

Permalink
Customize the cmake build. Android now builds that way too. Fixes.
Browse files Browse the repository at this point in the history
Hack around build error

port the last fix to Android.mk

One more attempt

Warning fixes

Oops, forgot a slash
  • Loading branch information
hrydgard committed Sep 29, 2023
1 parent 9e151d0 commit 2f5f9df
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 34 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions UI/RetroAchievementScreens.cpp
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion android/ab.cmd
Expand Up @@ -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 %*
62 changes: 35 additions & 27 deletions android/jni/Android.mk
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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 := \
Expand Down
3 changes: 1 addition & 2 deletions ext/CMakeLists.txt
Expand Up @@ -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)
add_subdirectory(libchdr-build)
38 changes: 38 additions & 0 deletions 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})

0 comments on commit 2f5f9df

Please sign in to comment.