Skip to content

Commit

Permalink
Make libpng optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHX committed Nov 17, 2019
1 parent 1214616 commit a48aca3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ cmake_minimum_required (VERSION 2.6)

project(mcpelauncher-client LANGUAGES CXX ASM)

find_package(PNG)

git_commit_hash(${CMAKE_CURRENT_SOURCE_DIR} CLIENT_GIT_COMMIT_HASH)
configure_file(src/build_info.h.in ${CMAKE_CURRENT_BINARY_DIR}/build_info/build_info.h)

Expand All @@ -20,5 +22,11 @@ else()
target_sources(mcpelauncher-client PRIVATE src/cpuid.cpp src/cpuid.h src/xbox_shutdown_patch.cpp src/xbox_shutdown_patch.h src/xbox_shutdown_patch.s src/texel_aa_patch.cpp src/texel_aa_patch.h)
endif()

if (PNG_FOUND)
target_compile_definitions(mcpelauncher-client PRIVATE HAS_LIBPNG)
target_include_directories(mcpelauncher-client PRIVATE ${PNG_INCLUDE_DIRS})
target_link_libraries(mcpelauncher-client ${PNG_LIBRARIES})
endif()

install(TARGETS mcpelauncher-client RUNTIME COMPONENT mcpelauncher-client DESTINATION bin)
include(CPackSettings.cmake)
10 changes: 10 additions & 0 deletions src/JNIBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include "client_app_platform.h"
#include "xbox_live_game_interface.h"
#include "xbox_live_helper.h"
#ifdef HAS_LIBPNG
#include <png.h>
#endif
#include <file_picker_factory.h>
#include <hybris/dlfcn.h>

Expand Down Expand Up @@ -362,6 +364,7 @@ void com::mojang::minecraftpe::MainActivity::postScreenshotToFacebook(JNIEnv *en
}

jnivm::Array<jint>* com::mojang::minecraftpe::MainActivity::getImageData(JNIEnv *env, jnivm::Object<java::lang::String>* arg0) {
#ifdef HAS_LIBPNG
uint8_t header[8];
FILE *fp = fopen(arg0->value->str.data(), "rb");
if(fp) {
Expand Down Expand Up @@ -399,6 +402,13 @@ jnivm::Array<jint>* com::mojang::minecraftpe::MainActivity::getImageData(JNIEnv
ret->length = 2;
return ret;
}
#else
auto ret = new jnivm::Array<jint>();
ret->cl = 0;
ret->value = new jint[20] { 0 };
ret->length = 2;
return ret;
#endif
}

jnivm::Array<jbyte>* com::mojang::minecraftpe::MainActivity::getFileDataBytes(JNIEnv *env, jnivm::Object<java::lang::String>* arg0) {
Expand Down

0 comments on commit a48aca3

Please sign in to comment.