From 8e61a1e4f7263d1cf5f7ebb18d25af2fe429f6ed Mon Sep 17 00:00:00 2001 From: Jacek Pudysz Date: Mon, 4 Dec 2023 14:53:01 +0100 Subject: [PATCH] feat: fix cmake paths --- android/CMakeLists.txt | 7 +++---- android/build.gradle | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/android/CMakeLists.txt b/android/CMakeLists.txt index e8fb53dc..f438e6bb 100644 --- a/android/CMakeLists.txt +++ b/android/CMakeLists.txt @@ -6,14 +6,10 @@ add_library(unistyles SHARED ../cxx/UnistylesRuntime.cpp ./src/main/cxx/cpp-adapter.cpp - ../node_modules/react-native/ReactCommon/jsi/jsi/jsi.cpp ) include_directories( ../cxx - ../node_modules/react-native/React - ../node_modules/react-native/React/Base - ../node_modules/react-native/ReactCommon/jsi ) set_target_properties(unistyles PROPERTIES @@ -23,6 +19,9 @@ set_target_properties(unistyles PROPERTIES POSITION_INDEPENDENT_CODE ON ) +find_package(ReactAndroid REQUIRED CONFIG) + target_link_libraries(unistyles + ReactAndroid::jsi android ) diff --git a/android/build.gradle b/android/build.gradle index 2aa6213d..ce7a7a31 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -15,12 +15,28 @@ buildscript { apply plugin: 'com.android.library' apply plugin: 'org.jetbrains.kotlin.android' +def resolveBuildType() { + Gradle gradle = getGradle() + String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString() + + return tskReqStr.contains('Release') ? 'release' : 'debug' +} + android { compileSdkVersion safeExtGet('compileSdkVersion', 33) namespace "com.unistyles" defaultConfig { minSdkVersion safeExtGet('minSdkVersion', 21) + externalNativeBuild { + cmake { + arguments "-DANDROID_STL=c++_shared" + } + } + } + + buildFeatures { + prefab true } externalNativeBuild { @@ -28,6 +44,16 @@ android { path "CMakeLists.txt" } } + + packagingOptions { + doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : '' + excludes = [ + "META-INF", + "META-INF/**", + "**/libjsi.so", + "**/libc++_shared.so" + ] + } } repositories {