From 5ef97ca444356c151deb4fdd2209259cbd31305d Mon Sep 17 00:00:00 2001 From: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Date: Mon, 4 Mar 2024 01:08:51 +0100 Subject: [PATCH] Compile OpenSSL libraries during build --- .../app/src/main/cpp/CMakeLists.txt | 5 +++ src/RyujinxAndroid/libryujinx/README.md | 12 +++++++ .../libryujinx/libs/OpenSSL.cmake | 31 +++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/RyujinxAndroid/libryujinx/README.md create mode 100644 src/RyujinxAndroid/libryujinx/libs/OpenSSL.cmake diff --git a/src/RyujinxAndroid/app/src/main/cpp/CMakeLists.txt b/src/RyujinxAndroid/app/src/main/cpp/CMakeLists.txt index 6cc2621c4..8700f6d9f 100644 --- a/src/RyujinxAndroid/app/src/main/cpp/CMakeLists.txt +++ b/src/RyujinxAndroid/app/src/main/cpp/CMakeLists.txt @@ -14,6 +14,9 @@ project("ryujinxjni") set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) +# libssl.so and libcrypto.so +include(../../../../libryujinx/libs/OpenSSL.cmake) + FetchContent_Declare( adrenotools GIT_REPOSITORY https://github.com/bylaws/libadrenotools.git @@ -38,6 +41,8 @@ add_library( # Sets the name of the library. string_helper.cpp ryujinx.cpp) +add_dependencies(ryujinxjni openssl) + # Searches for a specified prebuilt library and stores the path as a # variable. Because CMake includes system libraries in the search path by # default, you only need to specify the name of the public NDK library diff --git a/src/RyujinxAndroid/libryujinx/README.md b/src/RyujinxAndroid/libryujinx/README.md new file mode 100644 index 000000000..c2c6be71c --- /dev/null +++ b/src/RyujinxAndroid/libryujinx/README.md @@ -0,0 +1,12 @@ +# LibRyujinx Gradle project + +## Libraries + +The following native libraries will be compiled for this project. + +### OpenSSL + +Version: `3.2.1` + +Make sure all the prerequisites are available on your system. +You can read more about them [here](https://github.com/openssl/openssl/blob/openssl-3.2.1/INSTALL.md#prerequisites). diff --git a/src/RyujinxAndroid/libryujinx/libs/OpenSSL.cmake b/src/RyujinxAndroid/libryujinx/libs/OpenSSL.cmake new file mode 100644 index 000000000..f0809cbc2 --- /dev/null +++ b/src/RyujinxAndroid/libryujinx/libs/OpenSSL.cmake @@ -0,0 +1,31 @@ +include(ExternalProject) + +find_program(MAKE_COMMAND NAMES nmake make) + +set(PROJECT_ENV "ANDROID_NDK_ROOT=${CMAKE_ANDROID_NDK}") + +if (CMAKE_HOST_WIN32) + find_program(PERL_COMMAND NAMES perl) + set(PROJECT_CFG_PREFIX ${PERL_COMMAND}) + list(APPEND PROJECT_ENV "Path=${ANDROID_TOOLCHAIN_ROOT}\\bin;$ENV{Path}") +elseif (CMAKE_HOST_UNIX) + list(APPEND PROJECT_ENV "PATH=${ANDROID_TOOLCHAIN_ROOT}/bin:$ENV{PATH}") +else () + message(WARNING "Host system (${CMAKE_HOST_SYSTEM_NAME}) not supported. Treating as unix.") + list(APPEND PROJECT_ENV "PATH=${ANDROID_TOOLCHAIN_ROOT}/bin:$ENV{PATH}") +endif () + +ExternalProject_Add( + openssl + GIT_REPOSITORY https://github.com/openssl/openssl.git + GIT_TAG a7e992847de83aa36be0c399c89db3fb827b0be2 # openssl-3.2.1 + CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${PROJECT_ENV} + ${PROJECT_CFG_PREFIX} /Configure + android-${CMAKE_ANDROID_ARCH} + -D__ANDROID_API_=${CMAKE_SYSTEM_VERSION} + --prefix=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + --libdir="" + BUILD_COMMAND ${CMAKE_COMMAND} -E env ${PROJECT_ENV} + ${MAKE_COMMAND} + INSTALL_COMMAND ${MAKE_COMMAND} install_runtime_libs +)