From 7b12ce6e9fa3e558883bde01022fc2183967042a Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Fri, 21 Feb 2020 01:05:39 +0100 Subject: [PATCH] disabled unlinked utf8 functions for android, chaged libs to static --- src/CMakeLists.txt | 4 +- src/currency_core/currency_format_utils.h | 2 + src/currency_core/offers_services_helpers.cpp | 4 + src/currency_core/offers_services_helpers.h | 17 +++- utils/build_android_libs.sh | 78 +++++++++++++++++++ 5 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 utils/build_android_libs.sh diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9c60eaf0..d7ff6954 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -103,7 +103,7 @@ add_dependencies(currency_core version ${PCH_LIB_NAME}) ENABLE_SHARED_PCH(CURRENCY_CORE) if(CMAKE_SYSTEM_NAME STREQUAL "Android" ) - add_library(wallet SHARED ${WALLET}) + add_library(wallet ${WALLET}) add_dependencies(wallet version ${PCH_LIB_NAME}) target_link_libraries(wallet currency_core crypto common zlibstatic ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) else() @@ -122,7 +122,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "iOS") message("Generating install for iOS") return() elseif(CMAKE_SYSTEM_NAME STREQUAL "Android") - install(TARGETS wallet DESTINATION "${CMAKE_ANDROID_ARCH_ABI}/lib") + install(TARGETS wallet currency_core crypto common zlibstatic DESTINATION "${CMAKE_ANDROID_ARCH_ABI}/lib") message("Generating install for Android") return() endif() diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 547c939c..01d08170 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -595,9 +595,11 @@ namespace currency //--------------------------------------------------------------- std::ostream& operator <<(std::ostream& o, const ref_by_id& r); //--------------------------------------------------------------- +#ifndef ANDROID_BUILD std::string utf8_to_upper(const std::string& s); std::string utf8_to_lower(const std::string& s); bool utf8_substring_test_case_insensitive(const std::string& match, const std::string& s); // Returns true is 's' contains 'match' (case-insensitive) +#endif struct difficulties { diff --git a/src/currency_core/offers_services_helpers.cpp b/src/currency_core/offers_services_helpers.cpp index 3be77927..09669340 100644 --- a/src/currency_core/offers_services_helpers.cpp +++ b/src/currency_core/offers_services_helpers.cpp @@ -56,7 +56,11 @@ namespace bc_services //------------------------------------------------------------------ bool order_offers_by_name(const offer_details_ex* a, const offer_details_ex* b) { +#ifndef ANDROID_BUILD return currency::utf8_to_lower(a->target) < currency::utf8_to_lower(b->target); +#else + return false; +#endif } //------------------------------------------------------------------ std::vector gsort_offers_predicates; diff --git a/src/currency_core/offers_services_helpers.h b/src/currency_core/offers_services_helpers.h index a6182d11..fc2203fb 100644 --- a/src/currency_core/offers_services_helpers.h +++ b/src/currency_core/offers_services_helpers.h @@ -191,8 +191,21 @@ namespace bc_services inline double extract_rate(const odeh& v) { return calculate_offer_rate(v); } inline size_t extract_payment_types(const odeh& v) { return v.payment_types.size(); } inline std::string extract_contacts(const odeh& v) { return v.contacts; } - inline std::string extract_location(const odeh& v) { return currency::utf8_to_lower(v.location_country + v.location_city); } - inline std::string extract_name(const odeh& v) { return currency::utf8_to_lower(v.target); } + inline std::string extract_location(const odeh& v) { + +#ifndef ANDROID_BUILD + return currency::utf8_to_lower(v.location_country + v.location_city); +#else + return "UNSUPORTED"; +#endif + } + inline std::string extract_name(const odeh& v) { +#ifndef ANDROID_BUILD + return currency::utf8_to_lower(v.target); +#else + return "UNSUPORTED"; +#endif + } template struct sort_id_to_type diff --git a/utils/build_android_libs.sh b/utils/build_android_libs.sh new file mode 100644 index 00000000..bde6a849 --- /dev/null +++ b/utils/build_android_libs.sh @@ -0,0 +1,78 @@ +set -x #echo on +cd .. +rm -r _builds +cmake -S. -B_builds -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=28 -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_ANDROID_NDK=/Users/roky/Library/Android/sdk/ndk/18.1.5063045 -DCMAKE_ANDROID_STL_TYPE=c++_static -DCMAKE_INSTALL_PREFIX=`pwd`/_install +if [ $? -ne 0 ]; then + echo "Failed to perform command" + exit 1 +fi + +cmake --build _builds --config Release --target install +if [ $? -ne 0 ]; then + echo "Failed to perform command" + exit 1 +fi + +rm -r _builds +if [ $? -ne 0 ]; then + echo "Failed to perform command" + exit 1 +fi + +cmake -S. -B_builds -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=28 -DCMAKE_ANDROID_ARCH_ABI=x86 -DCMAKE_ANDROID_NDK=/Users/roky/Library/Android/sdk/ndk/18.1.5063045 -DCMAKE_ANDROID_STL_TYPE=c++_static -DCMAKE_INSTALL_PREFIX=`pwd`/_install +if [ $? -ne 0 ]; then + echo "Failed to perform command" + exit 1 +fi + +cmake --build _builds --config Release --target install +if [ $? -ne 0 ]; then + echo "Failed to perform command" + exit 1 +fi + +rm -r _builds +if [ $? -ne 0 ]; then + echo "Failed to perform command" + exit 1 +fi + + +cmake -S. -B_builds -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=28 -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_ANDROID_NDK=/Users/roky/Library/Android/sdk/ndk/18.1.5063045 -DCMAKE_ANDROID_STL_TYPE=c++_static -DCMAKE_INSTALL_PREFIX=`pwd`/_install +if [ $? -ne 0 ]; then + echo "Failed to perform command" + exit 1 +fi + +cmake --build _builds --config Release --target install +if [ $? -ne 0 ]; then + echo "Failed to perform command" + exit 1 +fi + +rm -r _builds +if [ $? -ne 0 ]; then + echo "Failed to perform command" + exit 1 +fi + + +cmake -S. -B_builds -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=28 -DCMAKE_ANDROID_ARCH_ABI=x86_64 -DCMAKE_ANDROID_NDK=/Users/roky/Library/Android/sdk/ndk/18.1.5063045 -DCMAKE_ANDROID_STL_TYPE=c++_static -DCMAKE_INSTALL_PREFIX=`pwd`/_install +if [ $? -ne 0 ]; then + echo "Failed to perform command" + exit 1 +fi + +cmake --build _builds --config Release --target install +if [ $? -ne 0 ]; then + echo "Failed to perform command" + exit 1 +fi + +rm -r _builds +if [ $? -ne 0 ]; then + echo "Failed to perform command" + exit 1 +fi + +