mirror of
https://github.com/zoriya/nitro.git
synced 2026-10-13 00:05:23 +00:00
132 lines
3.0 KiB
Groovy
132 lines
3.0 KiB
Groovy
buildscript {
|
|
repositories {
|
|
google()
|
|
mavenCentral()
|
|
}
|
|
|
|
dependencies {
|
|
classpath "com.android.tools.build:gradle:7.2.1"
|
|
}
|
|
}
|
|
|
|
def reactNativeArchitectures() {
|
|
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
}
|
|
|
|
def isNewArchitectureEnabled() {
|
|
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
}
|
|
|
|
apply plugin: "com.android.library"
|
|
apply plugin: 'org.jetbrains.kotlin.android'
|
|
|
|
if (isNewArchitectureEnabled()) {
|
|
apply plugin: "com.facebook.react"
|
|
}
|
|
|
|
def getExtOrDefault(name) {
|
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Nitro_" + name]
|
|
}
|
|
|
|
def getExtOrIntegerDefault(name) {
|
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Nitro_" + name]).toInteger()
|
|
}
|
|
|
|
android {
|
|
namespace "com.margelo.nitro"
|
|
|
|
ndkVersion getExtOrDefault("ndkVersion")
|
|
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
|
|
defaultConfig {
|
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
|
|
externalNativeBuild {
|
|
cmake {
|
|
cppFlags "-O2 -frtti -fexceptions -Wall -fstack-protector-all"
|
|
arguments "-DANDROID_STL=c++_shared"
|
|
abiFilters (*reactNativeArchitectures())
|
|
}
|
|
}
|
|
}
|
|
|
|
externalNativeBuild {
|
|
cmake {
|
|
path "CMakeLists.txt"
|
|
}
|
|
}
|
|
|
|
buildFeatures {
|
|
buildConfig true
|
|
prefab true
|
|
prefabPublishing true
|
|
}
|
|
|
|
prefab {
|
|
NitroModules {
|
|
headers "${project.buildDir}/headers/nitromodules/"
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled false
|
|
}
|
|
}
|
|
|
|
lintOptions {
|
|
disable "GradleCompatible"
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
if (isNewArchitectureEnabled()) {
|
|
java.srcDirs += [
|
|
// React Codegen files
|
|
"${project.buildDir}/generated/source/codegen/java"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
google()
|
|
}
|
|
|
|
|
|
dependencies {
|
|
// For < 0.71, this will be from the local maven repo
|
|
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
//noinspection GradleDynamicVersion
|
|
implementation "com.facebook.react:react-native:+"
|
|
}
|
|
|
|
if (isNewArchitectureEnabled()) {
|
|
react {
|
|
jsRootDir = file("../src/")
|
|
libraryName = "NitroModules"
|
|
codegenJavaPackageName = "com.margelo.nitro"
|
|
}
|
|
}
|
|
|
|
|
|
task prepareHeaders(type: Copy) {
|
|
from fileTree('./src/main/cpp').filter { it.isFile() }
|
|
from fileTree('../cpp/').filter { it.isFile() }
|
|
include "*.hpp"
|
|
into "${project.buildDir}/headers/nitromodules/NitroModules/"
|
|
includeEmptyDirs = false
|
|
}
|
|
|
|
preBuild.dependsOn(prepareHeaders)
|