diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..fdb91d61 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "vendor/boost/Boost-for-Android"] + path = vendor/boost/Boost-for-Android + url = https://github.com/moritz-wundke/Boost-for-Android.git +[submodule "vendor/spdlog"] + path = vendor/spdlog + url = https://github.com/gabime/spdlog.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ded7ea1..9a0b6858 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,19 +7,19 @@ cmake_policy(SET CMP0065 OLD) # - try if setting CRYPTOPP_NATIVE_ARCH=ON and adding -march=native to the compile commands for cryfs source files makes a difference # -> if yes, offer a cmake option to enable both of these -#set(ANDROID_ABI arm64-v8a) -#set(ANDROID_NDK /sdk/ndk/24.0.8215888/) -#set(ANDROID_PLATFORM android-21) -#set(ANDROID_TOOLCHAIN clang) -# -#set(CMAKE_SYSTEM_NAME Android) -#set(CMAKE_SYSTEM_VERSION 21) -#set(CMAKE_ANDROID_ARCH_ABI arm64-v8a) -#set(CMAKE_ANDROID_NDK ${ANDROID_NDK}) -#set(CMAKE_ANDROID_STL_TYPE c++_static) -# -#set(CMAKE_TOOLCHAIN_FILE ${CMAKE_ANDROID_NDK}/build/cmake/android.toolchain.cmake) -#set(ANDROID TRUE) # Current toolchain file doesn't set this variable which is needed by spdlog +set(ANDROID_ABI arm64-v8a) +set(ANDROID_NDK /ndk/23.1.7779620/) +set(ANDROID_PLATFORM android-21) +set(ANDROID_TOOLCHAIN clang) + +set(CMAKE_SYSTEM_NAME Android) +set(CMAKE_SYSTEM_VERSION 21) +set(CMAKE_ANDROID_ARCH_ABI arm64-v8a) +set(CMAKE_ANDROID_NDK ${ANDROID_NDK}) +set(CMAKE_ANDROID_STL_TYPE c++_static) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_ANDROID_NDK}/build/cmake/android.toolchain.cmake) +set(ANDROID TRUE) # Current toolchain file doesn't set this variable which is needed by spdlog project(cryfs) diff --git a/vendor/boost/Boost-for-Android b/vendor/boost/Boost-for-Android new file mode 160000 index 00000000..0e12fbd3 --- /dev/null +++ b/vendor/boost/Boost-for-Android @@ -0,0 +1 @@ +Subproject commit 0e12fbd30cb70b668a117c0913a303acfdaae04f diff --git a/vendor/boost/CMakeLists.txt b/vendor/boost/CMakeLists.txt index b67558f4..2a1b986b 100644 --- a/vendor/boost/CMakeLists.txt +++ b/vendor/boost/CMakeLists.txt @@ -1,7 +1,12 @@ project(libboost) add_library(boost INTERFACE) -target_include_directories(boost SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_ANDROID_ARCH_ABI}/include/boost-1_76) - -file(GLOB BOOST_STATIC_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/${ANDROID_ABI}/lib/libboost_*.a) -target_link_libraries(boost INTERFACE ${BOOST_STATIC_LIBS}) +add_custom_target( + vendor_boost + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/android-build.sh ${CMAKE_ANDROID_NDK} ${CMAKE_ANDROID_ARCH_ABI} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) +set(BOOST_OUTPUT "Boost-for-Android/build/out/${CMAKE_ANDROID_ARCH_ABI}") +file(GLOB BOOST_STATIC_LIBS ${BOOST_OUTPUT}/lib/libboost_*.a) +target_include_directories(boost SYSTEM INTERFACE ${BOOST_OUTPUT}/include/boost-1_76) +target_link_libraries(boost INTERFACE vendor_boost ${BOOST_STATIC_LIBS}) diff --git a/vendor/boost/android-build.sh b/vendor/boost/android-build.sh new file mode 100755 index 00000000..01aa236c --- /dev/null +++ b/vendor/boost/android-build.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +BOOST_TAR=boost_1_76_0.tar.bz2 + +cd Boost-for-Android || exit 1 + +if [ ! -f $BOOST_TAR ]; then + wget -O $BOOST_TAR https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2 || exit 1 +fi + +sha256sum -c ../checksum.txt && \ +./build-android.sh --boost=1.76.0 --arch=$2 --target-version=21 \ + --with-libraries=atomic,chrono,container,date_time,exception,filesystem,serialization,system,thread \ + $1 diff --git a/vendor/boost/checksum.txt b/vendor/boost/checksum.txt new file mode 100644 index 00000000..9af1426b --- /dev/null +++ b/vendor/boost/checksum.txt @@ -0,0 +1 @@ +f0397ba6e982c4450f27bf32a2a83292aba035b827a5623a14636ea583318c41 boost_1_76_0.tar.bz2 diff --git a/vendor/cryptopp/CMakeLists.txt b/vendor/cryptopp/CMakeLists.txt index e1bc9102..761c9458 100644 --- a/vendor/cryptopp/CMakeLists.txt +++ b/vendor/cryptopp/CMakeLists.txt @@ -18,6 +18,6 @@ set(BUILD_STATIC ON CACHE BOOL "") set(USE_INTERMEDIATE_OBJECTS_TARGET OFF CACHE BOOL "") set(cryptocpp_DISPLAY_CMAKE_SUPPORT_WARNING OFF CACHE BOOL "") -add_library(vendor_cryptopp STATIC IMPORTED) -set_target_properties(vendor_cryptopp PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/vendor_cryptopp/libcryptopp.a) -target_link_libraries(cryptopp INTERFACE vendor_cryptopp) +set(LIBCRYPTOPP_A "${CMAKE_CURRENT_SOURCE_DIR}/vendor_cryptopp/build/${CMAKE_ANDROID_ARCH_ABI}/libcryptopp.a") +add_custom_command(OUTPUT ${LIBCRYPTOPP_A} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/android-build.sh ${CMAKE_ANDROID_ARCH_ABI}) +target_link_libraries(cryptopp INTERFACE ${LIBCRYPTOPP_A}) diff --git a/vendor/cryptopp/android-build.sh b/vendor/cryptopp/android-build.sh new file mode 100755 index 00000000..b1a4b0a3 --- /dev/null +++ b/vendor/cryptopp/android-build.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +cd vendor_cryptopp && \ + mkdir -p build/$1 && \ + TestScripts/setenv-android.sh 21 $1 && \ + make -f GNUmakefile-cross static && \ + mv libcryptopp.a build/$1 diff --git a/vendor/cryptopp/vendor_cryptopp/TestScripts/setenv-android.sh b/vendor/cryptopp/vendor_cryptopp/TestScripts/setenv-android.sh index 4e9b9630..e0e73bd6 100755 --- a/vendor/cryptopp/vendor_cryptopp/TestScripts/setenv-android.sh +++ b/vendor/cryptopp/vendor_cryptopp/TestScripts/setenv-android.sh @@ -146,16 +146,8 @@ if [ ! -d "${ANDROID_NDK_ROOT}" ]; then [ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1 fi -# Error checking -if [ ! -d "${ANDROID_SDK_ROOT}" ]; then - echo "ERROR: ANDROID_SDK_ROOT is not a valid path for ${USER}. Please set it." - echo "ANDROID_SDK_ROOT is '${ANDROID_SDK_ROOT}'" - [ "$0" = "${BASH_SOURCE[0]}" ] && exit 1 || return 1 -fi - # User feedback #echo "ANDROID_NDK_ROOT is '${ANDROID_NDK_ROOT}'" -#echo "ANDROID_SDK_ROOT is '${ANDROID_SDK_ROOT}'" ##################################################################### @@ -200,10 +192,7 @@ case "$ANDROID_CPU" in armv7*|armeabi*) CC="armv7a-linux-androideabi${ANDROID_API}-clang" CXX="armv7a-linux-androideabi${ANDROID_API}-clang++" - LD="arm-linux-androideabi-ld" - AS="arm-linux-androideabi-as" AR="arm-linux-androideabi-ar" - RANLIB="arm-linux-androideabi-ranlib" STRIP="arm-linux-androideabi-strip" OBJDUMP="arm-linux-androideabi-objdump" @@ -226,10 +215,7 @@ case "$ANDROID_CPU" in armv8*|aarch64|arm64*) CC="aarch64-linux-android${ANDROID_API}-clang" CXX="aarch64-linux-android${ANDROID_API}-clang++" - LD="aarch64-linux-android-ld" - AS="aarch64-linux-android-as" AR="aarch64-linux-android-ar" - RANLIB="aarch64-linux-android-ranlib" STRIP="aarch64-linux-android-strip" OBJDUMP="aarch64-linux-android-objdump" @@ -249,10 +235,7 @@ case "$ANDROID_CPU" in i686|x86) CC="i686-linux-android${ANDROID_API}-clang" CXX="i686-linux-android${ANDROID_API}-clang++" - LD="i686-linux-android-ld" - AS="i686-linux-android-as" AR="i686-linux-android-ar" - RANLIB="i686-linux-android-ranlib" STRIP="i686-linux-android-strip" OBJDUMP="i686-linux-android-objdump" @@ -274,10 +257,7 @@ case "$ANDROID_CPU" in x86_64|x64) CC="x86_64-linux-android${ANDROID_API}-clang" CXX="x86_64-linux-android${ANDROID_API}-clang++" - LD="x86_64-linux-android-ld" - AS="x86_64-linux-android-as" AR="x86_64-linux-android-ar" - RANLIB="x86_64-linux-android-ranlib" STRIP="x86_64-linux-android-strip" OBJDUMP="x86_64-linux-android-objdump" @@ -301,6 +281,10 @@ case "$ANDROID_CPU" in ;; esac +LD=$CC +AS="llvm-as" +RANLIB="llvm-ranlib" + echo "Configuring for Android API ${ANDROID_API} ($ANDROID_CPU)" ##################################################################### diff --git a/vendor/spdlog b/vendor/spdlog new file mode 160000 index 00000000..a26e174b --- /dev/null +++ b/vendor/spdlog @@ -0,0 +1 @@ +Subproject commit a26e174b367a60a51f0be83a81d6d066330cdd8f