2018-09-12 01:27:47 +03:00
|
|
|
// Copyright (c) Facebook, Inc. and its affiliates.
|
2018-06-01 01:31:03 +03:00
|
|
|
|
|
|
|
// This source code is licensed under the MIT license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree.
|
2015-09-16 20:38:42 +03:00
|
|
|
|
2018-09-14 01:35:32 +03:00
|
|
|
plugins {
|
|
|
|
id("com.android.library")
|
|
|
|
id("maven")
|
2019-05-15 13:25:38 +03:00
|
|
|
id("de.undercouch.download")
|
2018-09-14 01:35:32 +03:00
|
|
|
}
|
2015-09-16 20:38:42 +03:00
|
|
|
|
2019-10-14 09:24:59 +03:00
|
|
|
import java.nio.file.Paths
|
|
|
|
|
2015-09-16 20:38:42 +03:00
|
|
|
import de.undercouch.gradle.tasks.download.Download
|
|
|
|
import org.apache.tools.ant.taskdefs.condition.Os
|
|
|
|
import org.apache.tools.ant.filters.ReplaceTokens
|
|
|
|
|
|
|
|
// We download various C++ open-source dependencies into downloads.
|
2015-09-21 23:30:08 +03:00
|
|
|
// We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk.
|
|
|
|
// After that we build native code from src/main/jni with module path pointing at third-party-ndk.
|
2015-09-16 20:38:42 +03:00
|
|
|
|
2018-03-30 06:59:47 +03:00
|
|
|
def customDownloadsDir = System.getenv("REACT_NATIVE_DOWNLOADS_DIR")
|
|
|
|
def downloadsDir = customDownloadsDir ? new File(customDownloadsDir) : new File("$buildDir/downloads")
|
2015-09-16 20:38:42 +03:00
|
|
|
def thirdPartyNdkDir = new File("$buildDir/third-party-ndk")
|
|
|
|
|
2016-11-30 01:26:01 +03:00
|
|
|
// You need to have following folders in this directory:
|
2017-05-10 15:57:59 +03:00
|
|
|
// - boost_1_63_0
|
2018-06-27 21:42:53 +03:00
|
|
|
// - double-conversion-1.1.6
|
2016-11-30 01:26:01 +03:00
|
|
|
// - folly-deprecate-dynamic-initializer
|
2018-06-27 21:57:41 +03:00
|
|
|
// - glog-0.3.5
|
2016-11-30 01:26:01 +03:00
|
|
|
def dependenciesPath = System.getenv("REACT_NATIVE_DEPENDENCIES")
|
|
|
|
|
2016-04-21 16:47:21 +03:00
|
|
|
// The Boost library is a very large download (>100MB).
|
|
|
|
// If Boost is already present on your system, define the REACT_NATIVE_BOOST_PATH env variable
|
|
|
|
// and the build will use that.
|
2016-11-30 01:26:01 +03:00
|
|
|
def boostPath = dependenciesPath ?: System.getenv("REACT_NATIVE_BOOST_PATH")
|
2016-04-21 16:47:21 +03:00
|
|
|
|
2019-06-04 22:39:41 +03:00
|
|
|
// Setup build type for NDK, supported values: {debug, release}
|
|
|
|
def nativeBuildType = System.getenv("NATIVE_BUILD_TYPE") ?: "release"
|
|
|
|
|
2015-09-16 20:38:42 +03:00
|
|
|
task createNativeDepsDirectories {
|
|
|
|
downloadsDir.mkdirs()
|
|
|
|
thirdPartyNdkDir.mkdirs()
|
|
|
|
}
|
|
|
|
|
|
|
|
task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
|
2019-02-09 21:14:55 +03:00
|
|
|
src("https://github.com/react-native-community/boost-for-react-native/releases/download/v${BOOST_VERSION.replace("_", ".")}-0/boost_${BOOST_VERSION}.tar.gz")
|
|
|
|
onlyIfNewer(true)
|
|
|
|
overwrite(false)
|
|
|
|
dest(new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz"))
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
2016-12-20 00:07:16 +03:00
|
|
|
task prepareBoost(dependsOn: boostPath ? [] : [downloadBoost], type: Copy) {
|
2019-02-09 21:14:55 +03:00
|
|
|
from(boostPath ?: tarTree(resources.gzip(downloadBoost.dest)))
|
|
|
|
from("src/main/jni/third-party/boost/Android.mk")
|
|
|
|
include("Android.mk", "boost_${BOOST_VERSION}/boost/**/*.hpp", "boost/boost/**/*.hpp")
|
2016-12-20 00:07:16 +03:00
|
|
|
includeEmptyDirs = false
|
2019-02-09 21:14:55 +03:00
|
|
|
into("$thirdPartyNdkDir/boost")
|
2017-05-10 15:57:59 +03:00
|
|
|
doLast {
|
2018-09-14 01:35:32 +03:00
|
|
|
file("$thirdPartyNdkDir/boost/boost").renameTo("$thirdPartyNdkDir/boost/boost_${BOOST_VERSION}")
|
2017-05-10 15:57:59 +03:00
|
|
|
}
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
task downloadDoubleConversion(dependsOn: createNativeDepsDirectories, type: Download) {
|
2019-02-09 21:14:55 +03:00
|
|
|
src("https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz")
|
|
|
|
onlyIfNewer(true)
|
|
|
|
overwrite(false)
|
|
|
|
dest(new File(downloadsDir, "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz"))
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
2016-11-30 01:26:01 +03:00
|
|
|
task prepareDoubleConversion(dependsOn: dependenciesPath ? [] : [downloadDoubleConversion], type: Copy) {
|
2019-02-09 21:14:55 +03:00
|
|
|
from(dependenciesPath ?: tarTree(downloadDoubleConversion.dest))
|
|
|
|
from("src/main/jni/third-party/double-conversion/Android.mk")
|
|
|
|
include("double-conversion-${DOUBLE_CONVERSION_VERSION}/src/**/*", "Android.mk")
|
|
|
|
filesMatching("*/src/**/*", { fname -> fname.path = "double-conversion/${fname.name}" })
|
2015-09-16 20:38:42 +03:00
|
|
|
includeEmptyDirs = false
|
2019-02-09 21:14:55 +03:00
|
|
|
into("$thirdPartyNdkDir/double-conversion")
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
task downloadFolly(dependsOn: createNativeDepsDirectories, type: Download) {
|
2019-02-09 21:14:55 +03:00
|
|
|
src("https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz")
|
|
|
|
onlyIfNewer(true)
|
|
|
|
overwrite(false)
|
|
|
|
dest(new File(downloadsDir, "folly-${FOLLY_VERSION}.tar.gz"))
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
2016-11-30 01:26:01 +03:00
|
|
|
task prepareFolly(dependsOn: dependenciesPath ? [] : [downloadFolly], type: Copy) {
|
2019-02-09 21:14:55 +03:00
|
|
|
from(dependenciesPath ?: tarTree(downloadFolly.dest))
|
|
|
|
from("src/main/jni/third-party/folly/Android.mk")
|
|
|
|
include("folly-${FOLLY_VERSION}/folly/**/*", "Android.mk")
|
2018-12-28 01:45:36 +03:00
|
|
|
eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") }
|
2015-09-16 20:38:42 +03:00
|
|
|
includeEmptyDirs = false
|
2019-02-09 21:14:55 +03:00
|
|
|
into("$thirdPartyNdkDir/folly")
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
2019-07-26 08:59:00 +03:00
|
|
|
task prepareHermes() {
|
2019-10-14 09:24:59 +03:00
|
|
|
def hermesPackagePath = findNodeModulePath(projectDir, "hermes-engine")
|
|
|
|
if (!hermesPackagePath) {
|
|
|
|
throw new GradleScriptException("Could not find the hermes-engine npm package")
|
|
|
|
}
|
2019-07-26 08:59:00 +03:00
|
|
|
|
2019-10-14 09:24:59 +03:00
|
|
|
def hermesAAR = file("$hermesPackagePath/android/hermes-debug.aar")
|
|
|
|
if (!hermesAAR.exists()) {
|
|
|
|
throw new GradleScriptException("The hermes-engine npm package is missing \"android/hermes-debug.aar\"")
|
2019-07-26 08:59:00 +03:00
|
|
|
}
|
2019-10-14 09:24:59 +03:00
|
|
|
|
2019-07-26 08:59:00 +03:00
|
|
|
def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" })
|
|
|
|
|
|
|
|
copy {
|
|
|
|
from soFiles
|
|
|
|
from "src/main/jni/first-party/hermes/Android.mk"
|
|
|
|
into "$thirdPartyNdkDir/hermes"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-16 20:38:42 +03:00
|
|
|
task downloadGlog(dependsOn: createNativeDepsDirectories, type: Download) {
|
2019-02-09 21:14:55 +03:00
|
|
|
src("https://github.com/google/glog/archive/v${GLOG_VERSION}.tar.gz")
|
|
|
|
onlyIfNewer(true)
|
|
|
|
overwrite(false)
|
|
|
|
dest(new File(downloadsDir, "glog-${GLOG_VERSION}.tar.gz"))
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
2016-04-21 16:47:21 +03:00
|
|
|
// Prepare glog sources to be compiled, this task will perform steps that normally should've been
|
2015-09-16 20:38:42 +03:00
|
|
|
// executed by automake. This way we can avoid dependencies on make/automake
|
2016-11-30 01:26:01 +03:00
|
|
|
task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy) {
|
2019-02-09 21:14:55 +03:00
|
|
|
from(dependenciesPath ?: tarTree(downloadGlog.dest))
|
|
|
|
from("src/main/jni/third-party/glog/")
|
|
|
|
include("glog-${GLOG_VERSION}/src/**/*", "Android.mk", "config.h")
|
2015-09-16 20:38:42 +03:00
|
|
|
includeEmptyDirs = false
|
2019-02-09 21:14:55 +03:00
|
|
|
filesMatching("**/*.h.in") {
|
2015-09-16 20:38:42 +03:00
|
|
|
filter(ReplaceTokens, tokens: [
|
2019-02-09 21:14:55 +03:00
|
|
|
ac_cv_have_unistd_h : "1",
|
|
|
|
ac_cv_have_stdint_h : "1",
|
|
|
|
ac_cv_have_systypes_h : "1",
|
|
|
|
ac_cv_have_inttypes_h : "1",
|
|
|
|
ac_cv_have_libgflags : "0",
|
|
|
|
ac_google_start_namespace : "namespace google {",
|
|
|
|
ac_cv_have_uint16_t : "1",
|
|
|
|
ac_cv_have_u_int16_t : "1",
|
|
|
|
ac_cv_have___uint16 : "0",
|
|
|
|
ac_google_end_namespace : "}",
|
|
|
|
ac_cv_have___builtin_expect : "1",
|
|
|
|
ac_google_namespace : "google",
|
|
|
|
ac_cv___attribute___noinline : "__attribute__ ((noinline))",
|
|
|
|
ac_cv___attribute___noreturn : "__attribute__ ((noreturn))",
|
|
|
|
ac_cv___attribute___printf_4_5: "__attribute__((__format__ (__printf__, 4, 5)))"
|
2015-09-16 20:38:42 +03:00
|
|
|
])
|
2019-02-09 21:14:55 +03:00
|
|
|
it.path = (it.name - ".in")
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
2019-02-09 21:14:55 +03:00
|
|
|
into("$thirdPartyNdkDir/glog")
|
2018-10-29 22:04:30 +03:00
|
|
|
|
|
|
|
doLast {
|
|
|
|
copy {
|
2019-05-02 04:39:28 +03:00
|
|
|
from(fileTree(dir: "$thirdPartyNdkDir/glog", includes: ["stl_logging.h", "logging.h", "raw_logging.h", "vlog_is_on.h", "**/src/glog/log_severity.h"]).files)
|
2018-10-29 22:04:30 +03:00
|
|
|
includeEmptyDirs = false
|
2019-02-09 21:14:55 +03:00
|
|
|
into("$thirdPartyNdkDir/glog/exported/glog")
|
2018-10-29 22:04:30 +03:00
|
|
|
}
|
|
|
|
}
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
2018-12-28 01:45:36 +03:00
|
|
|
// Create Android.mk library module based on jsc from npm
|
2019-04-05 00:12:44 +03:00
|
|
|
task prepareJSC {
|
- update to gradle 4.10.1 or high (#23103)
Summary:
Add suport to gradle 4.10.1 or high!
The new version of android studio 3.3 recommendete to update gradle project to 4.10.1
> To take advantage of the latest features, improvements, and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.3.0 and Gradle to version 4.10.1. [Release notes ](https://developer.android.com/studio/releases/gradle-plugin)
>Android plugin 3.2.0 and higher now support building the Android App Bundle—a new upload format that defers APK generation and signing to compatible app stores, such as Google Play. With app bundles, you no longer have to build, sign, and manage multiple APKs, and users get smaller, more optimized downloads. [Learn more](https://developer.android.com/guide/app-bundle/?utm_source=android-studio)
but if the upgrade to the new Android gradle many warnings come up, becouse meny things was obsoleted
> WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
> WARNING: API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'.
> WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
> It will be removed at the end of 2019.
> For more information, [see ](https://d.android.com/r/tools/task-configuration-avoidance.)
> To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
Changelog:
----------
[Android] [Deprecated] - fix warinings obsolete to update to gradle 4.10.1 or high
Pull Request resolved: https://github.com/facebook/react-native/pull/23103
Differential Revision: D13817123
Pulled By: cpojer
fbshipit-source-id: 9816e20145a5fded2702cf9317cfb6862f3ebd8b
2019-01-25 14:12:51 +03:00
|
|
|
doLast {
|
2019-10-14 09:24:59 +03:00
|
|
|
def jscPackagePath = findNodeModulePath(projectDir, "jsc-android")
|
|
|
|
if (!jscPackagePath) {
|
|
|
|
throw new GradleScriptException("Could not find the jsc-android npm package")
|
|
|
|
}
|
|
|
|
|
|
|
|
def jscDist = file("$jscPackagePath/dist")
|
|
|
|
if (!jscDist.exists()) {
|
|
|
|
throw new GradleScriptException("The jsc-android npm package is missing its \"dist\" directory")
|
2019-04-23 12:18:58 +03:00
|
|
|
}
|
2019-10-14 09:24:59 +03:00
|
|
|
|
|
|
|
def jscAAR = fileTree(jscDist).matching({ it.include "**/android-jsc/**/*.aar" }).singleFile
|
- update to gradle 4.10.1 or high (#23103)
Summary:
Add suport to gradle 4.10.1 or high!
The new version of android studio 3.3 recommendete to update gradle project to 4.10.1
> To take advantage of the latest features, improvements, and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.3.0 and Gradle to version 4.10.1. [Release notes ](https://developer.android.com/studio/releases/gradle-plugin)
>Android plugin 3.2.0 and higher now support building the Android App Bundle—a new upload format that defers APK generation and signing to compatible app stores, such as Google Play. With app bundles, you no longer have to build, sign, and manage multiple APKs, and users get smaller, more optimized downloads. [Learn more](https://developer.android.com/guide/app-bundle/?utm_source=android-studio)
but if the upgrade to the new Android gradle many warnings come up, becouse meny things was obsoleted
> WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
> WARNING: API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'.
> WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
> It will be removed at the end of 2019.
> For more information, [see ](https://d.android.com/r/tools/task-configuration-avoidance.)
> To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
Changelog:
----------
[Android] [Deprecated] - fix warinings obsolete to update to gradle 4.10.1 or high
Pull Request resolved: https://github.com/facebook/react-native/pull/23103
Differential Revision: D13817123
Pulled By: cpojer
fbshipit-source-id: 9816e20145a5fded2702cf9317cfb6862f3ebd8b
2019-01-25 14:12:51 +03:00
|
|
|
def soFiles = zipTree(jscAAR).matching({ it.include "**/*.so" })
|
2018-12-28 01:45:36 +03:00
|
|
|
|
2019-10-14 09:24:59 +03:00
|
|
|
def headerFiles = fileTree(jscDist).matching({ it.include "**/include/*.h" })
|
2018-12-28 01:45:36 +03:00
|
|
|
|
- update to gradle 4.10.1 or high (#23103)
Summary:
Add suport to gradle 4.10.1 or high!
The new version of android studio 3.3 recommendete to update gradle project to 4.10.1
> To take advantage of the latest features, improvements, and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.3.0 and Gradle to version 4.10.1. [Release notes ](https://developer.android.com/studio/releases/gradle-plugin)
>Android plugin 3.2.0 and higher now support building the Android App Bundle—a new upload format that defers APK generation and signing to compatible app stores, such as Google Play. With app bundles, you no longer have to build, sign, and manage multiple APKs, and users get smaller, more optimized downloads. [Learn more](https://developer.android.com/guide/app-bundle/?utm_source=android-studio)
but if the upgrade to the new Android gradle many warnings come up, becouse meny things was obsoleted
> WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
> WARNING: API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'.
> WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
> It will be removed at the end of 2019.
> For more information, [see ](https://d.android.com/r/tools/task-configuration-avoidance.)
> To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
Changelog:
----------
[Android] [Deprecated] - fix warinings obsolete to update to gradle 4.10.1 or high
Pull Request resolved: https://github.com/facebook/react-native/pull/23103
Differential Revision: D13817123
Pulled By: cpojer
fbshipit-source-id: 9816e20145a5fded2702cf9317cfb6862f3ebd8b
2019-01-25 14:12:51 +03:00
|
|
|
copy {
|
2019-02-09 21:14:55 +03:00
|
|
|
from(soFiles)
|
|
|
|
from(headerFiles)
|
|
|
|
from("src/main/jni/third-party/jsc/Android.mk")
|
2018-12-28 01:45:36 +03:00
|
|
|
|
- update to gradle 4.10.1 or high (#23103)
Summary:
Add suport to gradle 4.10.1 or high!
The new version of android studio 3.3 recommendete to update gradle project to 4.10.1
> To take advantage of the latest features, improvements, and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.3.0 and Gradle to version 4.10.1. [Release notes ](https://developer.android.com/studio/releases/gradle-plugin)
>Android plugin 3.2.0 and higher now support building the Android App Bundle—a new upload format that defers APK generation and signing to compatible app stores, such as Google Play. With app bundles, you no longer have to build, sign, and manage multiple APKs, and users get smaller, more optimized downloads. [Learn more](https://developer.android.com/guide/app-bundle/?utm_source=android-studio)
but if the upgrade to the new Android gradle many warnings come up, becouse meny things was obsoleted
> WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
> WARNING: API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'.
> WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
> It will be removed at the end of 2019.
> For more information, [see ](https://d.android.com/r/tools/task-configuration-avoidance.)
> To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
Changelog:
----------
[Android] [Deprecated] - fix warinings obsolete to update to gradle 4.10.1 or high
Pull Request resolved: https://github.com/facebook/react-native/pull/23103
Differential Revision: D13817123
Pulled By: cpojer
fbshipit-source-id: 9816e20145a5fded2702cf9317cfb6862f3ebd8b
2019-01-25 14:12:51 +03:00
|
|
|
filesMatching("**/*.h", { it.path = "JavaScriptCore/${it.name}" })
|
2018-12-28 01:45:36 +03:00
|
|
|
|
2019-02-09 21:14:55 +03:00
|
|
|
includeEmptyDirs(false)
|
|
|
|
into("$thirdPartyNdkDir/jsc")
|
- update to gradle 4.10.1 or high (#23103)
Summary:
Add suport to gradle 4.10.1 or high!
The new version of android studio 3.3 recommendete to update gradle project to 4.10.1
> To take advantage of the latest features, improvements, and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.3.0 and Gradle to version 4.10.1. [Release notes ](https://developer.android.com/studio/releases/gradle-plugin)
>Android plugin 3.2.0 and higher now support building the Android App Bundle—a new upload format that defers APK generation and signing to compatible app stores, such as Google Play. With app bundles, you no longer have to build, sign, and manage multiple APKs, and users get smaller, more optimized downloads. [Learn more](https://developer.android.com/guide/app-bundle/?utm_source=android-studio)
but if the upgrade to the new Android gradle many warnings come up, becouse meny things was obsoleted
> WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
> WARNING: API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'.
> WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
> It will be removed at the end of 2019.
> For more information, [see ](https://d.android.com/r/tools/task-configuration-avoidance.)
> To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace.
Changelog:
----------
[Android] [Deprecated] - fix warinings obsolete to update to gradle 4.10.1 or high
Pull Request resolved: https://github.com/facebook/react-native/pull/23103
Differential Revision: D13817123
Pulled By: cpojer
fbshipit-source-id: 9816e20145a5fded2702cf9317cfb6862f3ebd8b
2019-01-25 14:12:51 +03:00
|
|
|
}
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
}
|
2018-03-30 06:59:47 +03:00
|
|
|
task downloadNdkBuildDependencies {
|
2018-12-28 01:45:36 +03:00
|
|
|
if (!boostPath) {
|
2019-02-09 21:14:55 +03:00
|
|
|
dependsOn(downloadBoost)
|
2018-12-28 01:45:36 +03:00
|
|
|
}
|
2019-02-09 21:14:55 +03:00
|
|
|
dependsOn(downloadDoubleConversion)
|
|
|
|
dependsOn(downloadFolly)
|
|
|
|
dependsOn(downloadGlog)
|
2018-03-30 06:59:47 +03:00
|
|
|
}
|
|
|
|
|
2019-10-14 09:24:59 +03:00
|
|
|
/**
|
|
|
|
* Finds the path of the installed npm package with the given name using Node's
|
|
|
|
* module resolution algorithm, which searches "node_modules" directories up to
|
|
|
|
* the file system root. This handles various cases, including:
|
|
|
|
*
|
|
|
|
* - Working in the open-source RN repo:
|
|
|
|
* Gradle: /path/to/react-native/ReactAndroid
|
|
|
|
* Node module: /path/to/react-native/node_modules/[package]
|
|
|
|
*
|
|
|
|
* - Installing RN as a dependency of an app and searching for hoisted
|
|
|
|
* dependencies:
|
|
|
|
* Gradle: /path/to/app/node_modules/react-native/ReactAndroid
|
|
|
|
* Node module: /path/to/app/node_modules/[package]
|
|
|
|
*
|
|
|
|
* - Working in a larger repo (e.g., Facebook) that contains RN:
|
|
|
|
* Gradle: /path/to/repo/path/to/react-native/ReactAndroid
|
|
|
|
* Node module: /path/to/repo/node_modules/[package]
|
|
|
|
*
|
|
|
|
* The search begins at the given base directory (a File object). The returned
|
|
|
|
* path is a string.
|
|
|
|
*/
|
|
|
|
def findNodeModulePath(baseDir, packageName) {
|
|
|
|
def basePath = baseDir.toPath().normalize()
|
|
|
|
// Node's module resolution algorithm searches up to the root directory,
|
|
|
|
// after which the base path will be null
|
|
|
|
while (basePath) {
|
|
|
|
def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName)
|
|
|
|
if (candidatePath.toFile().exists()) {
|
|
|
|
return candidatePath.toString()
|
|
|
|
}
|
|
|
|
basePath = basePath.getParent()
|
|
|
|
}
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
2015-09-16 20:38:42 +03:00
|
|
|
def getNdkBuildName() {
|
|
|
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|
|
|
return "ndk-build.cmd"
|
|
|
|
} else {
|
|
|
|
return "ndk-build"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def findNdkBuildFullPath() {
|
|
|
|
// we allow to provide full path to ndk-build tool
|
2019-02-09 21:14:55 +03:00
|
|
|
if (hasProperty("ndk.command")) {
|
|
|
|
return property("ndk.command")
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
// or just a path to the containing directory
|
2019-02-09 21:14:55 +03:00
|
|
|
if (hasProperty("ndk.path")) {
|
|
|
|
def ndkDir = property("ndk.path")
|
2015-09-16 20:38:42 +03:00
|
|
|
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
|
|
|
|
}
|
2019-09-18 12:32:52 +03:00
|
|
|
|
2019-02-09 21:14:55 +03:00
|
|
|
if (System.getenv("ANDROID_NDK") != null) {
|
|
|
|
def ndkDir = System.getenv("ANDROID_NDK")
|
2015-09-16 20:38:42 +03:00
|
|
|
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
|
|
|
|
}
|
2019-09-18 12:32:52 +03:00
|
|
|
|
|
|
|
def ndkDir = android.ndkDirectory ? android.ndkDirectory.absolutePath : null
|
|
|
|
|
2015-09-16 20:38:42 +03:00
|
|
|
if (ndkDir) {
|
|
|
|
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
|
|
|
|
}
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
2019-06-05 16:09:09 +03:00
|
|
|
def reactNativeDevServerPort() {
|
|
|
|
def value = project.getProperties().get("reactNativeDevServerPort")
|
|
|
|
return value != null ? value : "8081"
|
|
|
|
}
|
|
|
|
|
|
|
|
def reactNativeInspectorProxyPort() {
|
|
|
|
def value = project.getProperties().get("reactNativeInspectorProxyPort")
|
|
|
|
return value != null ? value : reactNativeDevServerPort()
|
|
|
|
}
|
|
|
|
|
2015-09-16 20:38:42 +03:00
|
|
|
def getNdkBuildFullPath() {
|
|
|
|
def ndkBuildFullPath = findNdkBuildFullPath()
|
2015-09-23 15:55:42 +03:00
|
|
|
if (ndkBuildFullPath == null) {
|
2015-09-16 20:38:42 +03:00
|
|
|
throw new GradleScriptException(
|
2018-12-28 01:45:36 +03:00
|
|
|
"ndk-build binary cannot be found, check if you've set " +
|
|
|
|
"\$ANDROID_NDK environment variable correctly or if ndk.dir is " +
|
|
|
|
"setup in local.properties",
|
|
|
|
null)
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
2015-09-23 15:55:42 +03:00
|
|
|
if (!new File(ndkBuildFullPath).canExecute()) {
|
|
|
|
throw new GradleScriptException(
|
2018-12-28 01:45:36 +03:00
|
|
|
"ndk-build binary " + ndkBuildFullPath + " doesn't exist or isn't executable.\n" +
|
|
|
|
"Check that the \$ANDROID_NDK environment variable, or ndk.dir in local.properties, is set correctly.\n" +
|
|
|
|
"(On Windows, make sure you escape backslashes in local.properties or use forward slashes, e.g. C:\\\\ndk or C:/ndk rather than C:\\ndk)",
|
|
|
|
null)
|
2015-09-23 15:55:42 +03:00
|
|
|
}
|
2015-09-16 20:38:42 +03:00
|
|
|
return ndkBuildFullPath
|
|
|
|
}
|
|
|
|
|
2019-09-18 12:32:52 +03:00
|
|
|
def buildReactNdkLib = tasks.register("buildReactNdkLib", Exec) {
|
|
|
|
dependsOn(prepareJSC, prepareHermes, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog)
|
2019-05-02 04:39:28 +03:00
|
|
|
inputs.dir("$projectDir/../ReactCommon")
|
|
|
|
inputs.dir("src/main/jni")
|
2019-09-18 14:50:38 +03:00
|
|
|
inputs.dir("src/main/java/com/facebook/react/modules/blob")
|
2015-09-16 20:38:42 +03:00
|
|
|
outputs.dir("$buildDir/react-ndk/all")
|
2019-02-09 21:14:55 +03:00
|
|
|
commandLine(getNdkBuildFullPath(),
|
2019-06-04 22:39:41 +03:00
|
|
|
"NDK_DEBUG=" + (nativeBuildType.equalsIgnoreCase("debug") ? "1" : "0"),
|
2019-02-09 21:14:55 +03:00
|
|
|
"NDK_PROJECT_PATH=null",
|
2015-09-16 20:38:42 +03:00
|
|
|
"NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk",
|
2019-02-09 21:14:55 +03:00
|
|
|
"NDK_OUT=" + temporaryDir,
|
2015-09-16 20:38:42 +03:00
|
|
|
"NDK_LIBS_OUT=$buildDir/react-ndk/all",
|
|
|
|
"THIRD_PARTY_NDK_DIR=$buildDir/third-party-ndk",
|
2016-05-28 02:02:50 +03:00
|
|
|
"REACT_COMMON_DIR=$projectDir/../ReactCommon",
|
2018-10-18 10:47:06 +03:00
|
|
|
"REACT_SRC_DIR=$projectDir/src/main/java/com/facebook/react",
|
2019-02-09 21:14:55 +03:00
|
|
|
"-C", file("src/main/jni/react/jni").absolutePath,
|
|
|
|
"--jobs", project.findProperty("jobs") ?: Runtime.runtime.availableProcessors()
|
|
|
|
)
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
2019-09-18 12:32:52 +03:00
|
|
|
def cleanReactNdkLib = tasks.register("cleanReactNdkLib", Exec) {
|
2019-02-09 21:14:55 +03:00
|
|
|
ignoreExitValue(true)
|
|
|
|
errorOutput(new ByteArrayOutputStream())
|
|
|
|
commandLine(getNdkBuildFullPath(),
|
2016-07-30 03:55:15 +03:00
|
|
|
"NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk",
|
|
|
|
"THIRD_PARTY_NDK_DIR=$buildDir/third-party-ndk",
|
2016-08-27 03:08:21 +03:00
|
|
|
"REACT_COMMON_DIR=$projectDir/../ReactCommon",
|
2019-02-09 21:14:55 +03:00
|
|
|
"-C", file("src/main/jni/react/jni").absolutePath,
|
|
|
|
"clean")
|
2018-12-28 01:45:36 +03:00
|
|
|
doLast {
|
|
|
|
file(AAR_OUTPUT_URL).delete()
|
2019-02-09 21:14:55 +03:00
|
|
|
println("Deleted aar output dir at ${file(AAR_OUTPUT_URL)}")
|
2018-12-28 01:45:36 +03:00
|
|
|
}
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
2019-09-18 12:32:52 +03:00
|
|
|
def packageReactNdkLibs = tasks.register("packageReactNdkLibs", Copy) {
|
|
|
|
dependsOn(buildReactNdkLib)
|
2019-02-09 21:14:55 +03:00
|
|
|
from("$buildDir/react-ndk/all")
|
|
|
|
into("$buildDir/react-ndk/exported")
|
2019-04-05 00:12:44 +03:00
|
|
|
exclude("**/libjsc.so")
|
2019-07-26 08:59:00 +03:00
|
|
|
exclude("**/libhermes.so")
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
2019-09-18 12:32:52 +03:00
|
|
|
def packageReactNdkLibsForBuck = tasks.register("packageReactNdkLibsForBuck", Copy) {
|
|
|
|
dependsOn(packageReactNdkLibs)
|
2019-02-09 21:14:55 +03:00
|
|
|
from("$buildDir/react-ndk/exported")
|
|
|
|
into("src/main/jni/prebuilt/lib")
|
2016-02-26 03:39:29 +03:00
|
|
|
}
|
|
|
|
|
2015-09-16 20:38:42 +03:00
|
|
|
android {
|
2018-12-05 20:01:42 +03:00
|
|
|
compileSdkVersion 28
|
2015-09-16 20:38:42 +03:00
|
|
|
|
2019-02-05 21:14:20 +03:00
|
|
|
compileOptions {
|
2019-02-09 21:14:55 +03:00
|
|
|
sourceCompatibility(JavaVersion.VERSION_1_8)
|
|
|
|
targetCompatibility(JavaVersion.VERSION_1_8)
|
2019-02-05 21:14:20 +03:00
|
|
|
}
|
|
|
|
|
2015-09-16 20:38:42 +03:00
|
|
|
defaultConfig {
|
2019-02-09 21:14:55 +03:00
|
|
|
minSdkVersion(16)
|
2019-02-13 18:08:45 +03:00
|
|
|
targetSdkVersion(28)
|
2019-02-09 21:14:55 +03:00
|
|
|
versionCode(1)
|
|
|
|
versionName("1.0")
|
2015-09-16 20:38:42 +03:00
|
|
|
|
2019-02-09 21:14:55 +03:00
|
|
|
consumerProguardFiles("proguard-rules.pro")
|
2018-04-06 03:26:39 +03:00
|
|
|
|
2015-09-16 20:38:42 +03:00
|
|
|
ndk {
|
2019-02-09 21:14:55 +03:00
|
|
|
moduleName("reactnativejni")
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
2019-02-09 21:14:55 +03:00
|
|
|
buildConfigField("boolean", "IS_INTERNAL_BUILD", "false")
|
|
|
|
buildConfigField("int", "EXOPACKAGE_FLAGS", "0")
|
2019-06-05 16:09:09 +03:00
|
|
|
|
|
|
|
resValue "integer", "react_native_dev_server_port", reactNativeDevServerPort()
|
|
|
|
resValue "integer", "react_native_inspector_proxy_port", reactNativeInspectorProxyPort()
|
|
|
|
|
2019-02-09 21:14:55 +03:00
|
|
|
testApplicationId("com.facebook.react.tests.gradle")
|
2019-03-17 18:03:31 +03:00
|
|
|
testInstrumentationRunner("androidx.test.runner.AndroidJUnitRunner")
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
sourceSets.main {
|
|
|
|
jni.srcDirs = []
|
2019-02-09 21:14:55 +03:00
|
|
|
jniLibs.srcDir("$buildDir/react-ndk/exported")
|
|
|
|
res.srcDirs = ["src/main/res/devsupport", "src/main/res/shell", "src/main/res/views/modal", "src/main/res/views/uimanager"]
|
2016-01-07 14:51:28 +03:00
|
|
|
java {
|
2019-02-09 21:14:55 +03:00
|
|
|
srcDirs = ["src/main/java", "src/main/libraries/soloader/java", "src/main/jni/first-party/fb/jni/java"]
|
|
|
|
exclude("com/facebook/react/processing")
|
|
|
|
exclude("com/facebook/react/module/processing")
|
2016-01-07 14:51:28 +03:00
|
|
|
}
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.withType(JavaCompile) {
|
2019-02-09 21:14:55 +03:00
|
|
|
compileTask -> compileTask.dependsOn(packageReactNdkLibs)
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
2019-02-09 21:14:55 +03:00
|
|
|
clean.dependsOn(cleanReactNdkLib)
|
2015-09-16 20:38:42 +03:00
|
|
|
|
|
|
|
lintOptions {
|
2019-02-09 21:14:55 +03:00
|
|
|
abortOnError(false)
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
2016-06-16 14:04:34 +03:00
|
|
|
packagingOptions {
|
2019-02-09 21:14:55 +03:00
|
|
|
exclude("META-INF/NOTICE")
|
|
|
|
exclude("META-INF/LICENSE")
|
2016-06-16 14:04:34 +03:00
|
|
|
}
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2019-02-09 21:14:55 +03:00
|
|
|
api("com.facebook.infer.annotation:infer-annotation:0.11.2")
|
2019-08-15 16:01:03 +03:00
|
|
|
api("com.facebook.yoga:proguard-annotations:1.14.1")
|
2019-02-09 21:14:55 +03:00
|
|
|
api("javax.inject:javax.inject:1")
|
2019-03-18 23:31:55 +03:00
|
|
|
api("androidx.appcompat:appcompat:1.0.2")
|
2019-02-09 21:14:55 +03:00
|
|
|
api("com.facebook.fresco:fresco:${FRESCO_VERSION}")
|
|
|
|
api("com.facebook.fresco:imagepipeline-okhttp3:${FRESCO_VERSION}")
|
|
|
|
api("com.facebook.soloader:soloader:${SO_LOADER_VERSION}")
|
|
|
|
api("com.google.code.findbugs:jsr305:3.0.2")
|
|
|
|
api("com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}")
|
|
|
|
api("com.squareup.okhttp3:okhttp-urlconnection:${OKHTTP_VERSION}")
|
|
|
|
api("com.squareup.okio:okio:1.15.0")
|
|
|
|
|
|
|
|
testImplementation("junit:junit:${JUNIT_VERSION}")
|
|
|
|
testImplementation("org.powermock:powermock-api-mockito:${POWERMOCK_VERSION}")
|
|
|
|
testImplementation("org.powermock:powermock-module-junit4-rule:${POWERMOCK_VERSION}")
|
|
|
|
testImplementation("org.powermock:powermock-classloading-xstream:${POWERMOCK_VERSION}")
|
|
|
|
testImplementation("org.mockito:mockito-core:${MOCKITO_CORE_VERSION}")
|
|
|
|
testImplementation("org.easytesting:fest-assert-core:${FEST_ASSERT_CORE_VERSION}")
|
|
|
|
testImplementation("org.robolectric:robolectric:${ROBOLECTRIC_VERSION}")
|
|
|
|
|
|
|
|
androidTestImplementation(fileTree(dir: "src/main/third-party/java/buck-android-support/", include: ["*.jar"]))
|
2019-09-20 01:32:47 +03:00
|
|
|
androidTestImplementation("androidx.test:runner:${ANDROIDX_TEST_VERSION}")
|
|
|
|
androidTestImplementation("androidx.test:rules:${ANDROIDX_TEST_VERSION}")
|
2019-02-09 21:14:55 +03:00
|
|
|
androidTestImplementation("org.mockito:mockito-core:${MOCKITO_CORE_VERSION}")
|
2015-09-16 20:38:42 +03:00
|
|
|
}
|
|
|
|
|
2019-02-09 21:14:55 +03:00
|
|
|
apply(from: "release.gradle")
|