mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-06 07:06:11 +00:00
Most of Android changes for Fabric and bump of FabricExample to RN 0.69.2. iOS and JS changes are available in #1821. The most notable change on Android is adding methods to components that accept String values of each NumberProp instead of Dynamic. Another change is changed structure of RenderableViewManager.java since we needed to abstract methods that belong only to components inheriting from VirtualView in order to be able to properly override them in their children.
131 lines
4.5 KiB
Groovy
131 lines
4.5 KiB
Groovy
buildscript {
|
|
// The Android Gradle plugin is only required when opening the android folder stand-alone.
|
|
// This avoids unnecessary downloads and potential conflicts when the library is included as a
|
|
// module dependency in an application project.
|
|
if (project == rootProject) {
|
|
repositories {
|
|
mavenCentral()
|
|
google()
|
|
}
|
|
|
|
dependencies {
|
|
classpath("com.android.tools.build:gradle:3.6.1")
|
|
}
|
|
}
|
|
}
|
|
|
|
def isNewArchitectureEnabled() {
|
|
// To opt-in for the New Architecture, you can either:
|
|
// - Set `newArchEnabled` to true inside the `gradle.properties` file
|
|
// - Invoke gradle with `-newArchEnabled=true`
|
|
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
|
|
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
}
|
|
|
|
if (isNewArchitectureEnabled()) {
|
|
apply plugin: "com.facebook.react"
|
|
}
|
|
|
|
apply plugin: 'com.android.library'
|
|
|
|
def safeExtGet(prop, fallback) {
|
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
}
|
|
|
|
android {
|
|
compileSdkVersion safeExtGet('compileSdkVersion', 28)
|
|
|
|
// Used to override the NDK path/version on internal CI or by allowing
|
|
// users to customize the NDK path/version from their root project (e.g. for M1 support)
|
|
if (rootProject.hasProperty("ndkPath")) {
|
|
ndkPath rootProject.ext.ndkPath
|
|
}
|
|
if (rootProject.hasProperty("ndkVersion")) {
|
|
ndkVersion rootProject.ext.ndkVersion
|
|
}
|
|
|
|
defaultConfig {
|
|
minSdkVersion safeExtGet('minSdkVersion', 16)
|
|
//noinspection OldTargetApi
|
|
targetSdkVersion safeExtGet('targetSdkVersion', 28)
|
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
if (isNewArchitectureEnabled()) {
|
|
var appProject = rootProject.allprojects.find {it.plugins.hasPlugin('com.android.application')}
|
|
externalNativeBuild {
|
|
ndkBuild {
|
|
arguments "APP_PLATFORM=android-21",
|
|
"APP_STL=c++_shared",
|
|
"NDK_TOOLCHAIN_VERSION=clang",
|
|
"GENERATED_SRC_DIR=${appProject.buildDir}/generated/source",
|
|
"PROJECT_BUILD_DIR=${appProject.buildDir}",
|
|
"REACT_ANDROID_DIR=${appProject.rootDir}/../node_modules/react-native/ReactAndroid",
|
|
"REACT_ANDROID_BUILD_DIR=${appProject.rootDir}/../node_modules/react-native/ReactAndroid/build"
|
|
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
|
|
cppFlags "-std=c++17"
|
|
targets "rnsvg_modules"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
lintOptions {
|
|
abortOnError false
|
|
}
|
|
|
|
if (isNewArchitectureEnabled()) {
|
|
externalNativeBuild {
|
|
ndkBuild {
|
|
path "src/main/jni/Android.mk"
|
|
}
|
|
}
|
|
}
|
|
packagingOptions {
|
|
// For some reason gradle only complains about the duplicated version of libreact_render libraries
|
|
// while there are more libraries copied in intermediates folder of the lib build directory, we exlude
|
|
// only the ones that make the build fail (ideally we should only include librnscreens_modules but we
|
|
// are only allowed to specify exlude patterns)
|
|
exclude "**/libreact_render*.so"
|
|
}
|
|
|
|
sourceSets.main {
|
|
java {
|
|
if (isNewArchitectureEnabled()) {
|
|
srcDirs += [
|
|
"src/fabric/java",
|
|
]
|
|
} else {
|
|
srcDirs += [
|
|
"src/paper/java",
|
|
"build/generated/source/codegen/java"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
mavenLocal()
|
|
google()
|
|
maven {
|
|
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
url "$rootDir/../node_modules/react-native/android"
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
if (isNewArchitectureEnabled()) {
|
|
implementation project(":ReactAndroid")
|
|
} else {
|
|
implementation 'com.facebook.react:react-native:+'
|
|
}
|
|
}
|
|
|
|
if (isNewArchitectureEnabled()) {
|
|
react {
|
|
reactRoot = rootProject.file("../node_modules/react-native/")
|
|
jsRootDir = file("../src/fabric/")
|
|
codegenDir = rootProject.file("../node_modules/react-native-codegen/")
|
|
libraryName = "rnsvg"
|
|
codegenJavaPackageName = "com.horcrux.rnsvg"
|
|
}
|
|
} |