Skip to content

Commit e3070b4

Browse files
DanielZlotinfacebook-github-bot
authored andcommitted
Update gradle and mk files (#22231)
Summary: Pull Request resolved: #22231 - Use clang instead of the deprecated gcc - Use libc++ instead of the deprecated gnustl - Updated gradle and android plugin version - Fixed missing arch in local-cli template - `clean` task should now always succeed - `clean` task deletes build artifacts - No need to specify buildToolsVersion. It's derived. - Elvis operator for more readable code Differential Revision: D13004499 fbshipit-source-id: 5c46afd51fdfaae84f25a05faa1f5cba9e6988fe
1 parent de60e86 commit e3070b4

File tree

15 files changed

+29
-26
lines changed

15 files changed

+29
-26
lines changed

RNTester/android/app/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ def enableProguardInReleaseBuilds = true
9292

9393
android {
9494
compileSdkVersion 27
95-
buildToolsVersion "27.0.3"
9695

9796
defaultConfig {
9897
applicationId "com.facebook.react.uiapp"

ReactAndroid/build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,22 @@ task buildReactNdkLib(dependsOn: [prepareJSC, prepareBoost, prepareDoubleConvers
242242
"REACT_COMMON_DIR=$projectDir/../ReactCommon",
243243
"REACT_SRC_DIR=$projectDir/src/main/java/com/facebook/react",
244244
'-C', file('src/main/jni/react/jni').absolutePath,
245-
'--jobs', project.hasProperty("jobs") ? project.property("jobs") : Runtime.runtime.availableProcessors()
245+
'--jobs', project.findProperty("jobs") ?: Runtime.runtime.availableProcessors()
246246
}
247247

248248
task cleanReactNdkLib(type: Exec) {
249+
ignoreExitValue true
250+
errorOutput new ByteArrayOutputStream()
249251
commandLine getNdkBuildFullPath(),
250252
"NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk",
251253
"THIRD_PARTY_NDK_DIR=$buildDir/third-party-ndk",
252254
"REACT_COMMON_DIR=$projectDir/../ReactCommon",
253255
'-C', file('src/main/jni/react/jni').absolutePath,
254256
'clean'
257+
doLast {
258+
file(AAR_OUTPUT_URL).delete()
259+
println "Deleted aar output dir at ${file(AAR_OUTPUT_URL)}"
260+
}
255261
}
256262

257263
task packageReactNdkLibs(dependsOn: buildReactNdkLib, type: Copy) {
@@ -267,7 +273,6 @@ task packageReactNdkLibsForBuck(dependsOn: packageReactNdkLibs, type: Copy) {
267273

268274
android {
269275
compileSdkVersion 27
270-
buildToolsVersion "27.0.3"
271276

272277
defaultConfig {
273278
minSdkVersion 16

ReactAndroid/release.gradle

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
apply plugin: 'maven'
77
apply plugin: 'signing'
88

9+
ext {
10+
AAR_OUTPUT_URL = "file://${projectDir}/../android"
11+
}
12+
913
// Gradle tasks for publishing to maven
1014
// 1) To install in local maven repo use :installArchives task
1115
// 2) To upload artifact to maven central use: :uploadArchives (you'd need to have the permission to do that)
@@ -15,15 +19,15 @@ def isReleaseBuild() {
1519
}
1620

1721
def getRepositoryUrl() {
18-
return project.hasProperty('repositoryUrl') ? property('repositoryUrl') : 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
22+
return project.findProperty('repositoryUrl') ?: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
1923
}
2024

2125
def getRepositoryUsername() {
22-
return project.hasProperty('repositoryUsername') ? property('repositoryUsername') : ''
26+
return project.findProperty('repositoryUsername') ?: ''
2327
}
2428

2529
def getRepositoryPassword() {
26-
return project.hasProperty('repositoryPassword') ? property('repositoryPassword') : ''
30+
return project.findProperty('repositoryPassword') ?: ''
2731
}
2832

2933
def configureReactNativePom(def pom) {
@@ -128,7 +132,7 @@ afterEvaluate { project ->
128132
configuration = configurations.archives
129133
repositories.mavenDeployer {
130134
// Deploy to react-native/android, ready to publish to npm
131-
repository url: "file://${projectDir}/../android"
135+
repository url: AAR_OUTPUT_URL
132136

133137
configureReactNativePom pom
134138
}

ReactAndroid/src/main/jni/Application.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ APP_MK_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
2424
# etc.) are defined inside build.gradle.
2525
NDK_MODULE_PATH := $(APP_MK_DIR)$(HOST_DIRSEP)$(THIRD_PARTY_NDK_DIR)$(HOST_DIRSEP)$(REACT_COMMON_DIR)$(HOST_DIRSEP)$(APP_MK_DIR)first-party$(HOST_DIRSEP)$(REACT_SRC_DIR)
2626

27-
APP_STL := gnustl_shared
27+
APP_STL := c++_shared
2828

2929
# Make sure every shared lib includes a .note.gnu.build-id header
3030
APP_CFLAGS := -Wall -Werror
3131
APP_CPPFLAGS := -std=c++1y
3232
APP_LDFLAGS := -Wl,--build-id
3333

34-
NDK_TOOLCHAIN_VERSION := 4.9
34+
NDK_TOOLCHAIN_VERSION := clang

ReactAndroid/src/main/jni/react/jni/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)
1717
# ./../ == react
1818
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../..
1919

20-
LOCAL_CFLAGS += -fexceptions -frtti
20+
LOCAL_CFLAGS += -fexceptions -frtti -Wno-unused-lambda-capture
2121

2222
LOCAL_LDLIBS += -landroid
2323

ReactAndroid/src/main/jni/third-party/folly/Android.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ FOLLY_FLAGS := \
2626
-DFOLLY_NO_CONFIG=1 \
2727
-DFOLLY_HAVE_CLOCK_GETTIME=1 \
2828
-DFOLLY_HAVE_MEMRCHR=1 \
29+
-DFOLLY_USE_LIBCPP=1
2930

3031
# If APP_PLATFORM in Application.mk targets android-23 above, please comment this line.
3132
# NDK uses GNU style stderror_r() after API 23.

ReactAndroid/src/main/jni/third-party/glog/Android.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ LOCAL_CFLAGS += \
2323
-g \
2424
-O2 \
2525
-D_START_GOOGLE_NAMESPACE_="namespace google {" \
26-
-D_END_GOOGLE_NAMESPACE_="}"
26+
-D_END_GOOGLE_NAMESPACE_="}" \
27+
-DHAVE_PREAD=1
2728

2829

2930
LOCAL_MODULE := glog

ReactCommon/cxxreact/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
1717
LOCAL_CFLAGS := \
1818
-DLOG_TAG=\"ReactNative\"
1919

20-
LOCAL_CFLAGS += -fexceptions -frtti
20+
LOCAL_CFLAGS += -fexceptions -frtti -Wno-unused-lambda-capture
2121

2222
LOCAL_STATIC_LIBRARIES := boost
2323
LOCAL_SHARED_LIBRARIES := jsinspector libfolly_json glog

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010
jcenter()
1111
}
1212
dependencies {
13-
classpath 'com.android.tools.build:gradle:3.1.4'
13+
classpath 'com.android.tools.build:gradle:3.2.1'
1414
classpath 'de.undercouch:gradle-download-task:3.4.3'
1515

1616
// NOTE: Do not place your application dependencies here; they belong
@@ -32,6 +32,6 @@ allprojects {
3232
}
3333

3434
task wrapper(type: Wrapper) {
35-
gradleVersion = '4.4'
35+
gradleVersion = '4.10.2'
3636
distributionUrl = distributionUrl.replace("bin", "all")
3737
}

gradle/wrapper/gradle-wrapper.jar

1.8 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
34
zipStoreBase=GRADLE_USER_HOME
45
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

gradlew.bat

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
:: Copyright (c) 2015-present, Facebook, Inc.
2-
::
3-
:: This source code is licensed under the MIT license found in the
4-
:: LICENSE file in the root directory of this source tree.
5-
61
@if "%DEBUG%" == "" @echo off
72
@rem ##########################################################################
83
@rem

local-cli/templates/HelloWorld/android/app/build.gradle

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def enableProguardInReleaseBuilds = false
9595

9696
android {
9797
compileSdkVersion rootProject.ext.compileSdkVersion
98-
buildToolsVersion rootProject.ext.buildToolsVersion
9998

10099
defaultConfig {
101100
applicationId "com.helloworld"
@@ -109,7 +108,7 @@ android {
109108
reset()
110109
enable enableSeparateBuildPerCPUArchitecture
111110
universalApk false // If true, also generate a universal APK
112-
include "armeabi-v7a", "x86", "arm64-v8a"
111+
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
113112
}
114113
}
115114
buildTypes {
@@ -123,7 +122,7 @@ android {
123122
variant.outputs.each { output ->
124123
// For each separate APK per architecture, set a unique version code as described here:
125124
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
126-
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3]
125+
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
127126
def abi = output.getFilter(OutputFile.ABI)
128127
if (abi != null) { // null for the universal-debug, universal-release variants
129128
output.versionCodeOverride =

local-cli/templates/HelloWorld/android/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
buildscript {
44
ext {
5-
buildToolsVersion = "27.0.3"
65
minSdkVersion = 16
76
compileSdkVersion = 27
87
targetSdkVersion = 27
@@ -13,7 +12,7 @@ buildscript {
1312
jcenter()
1413
}
1514
dependencies {
16-
classpath 'com.android.tools.build:gradle:3.1.4'
15+
classpath 'com.android.tools.build:gradle:3.2.1'
1716

1817
// NOTE: Do not place your application dependencies here; they belong
1918
// in the individual module build.gradle files

local-cli/templates/HelloWorld/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

0 commit comments

Comments
 (0)