Skip to content

Commit 3a7e950

Browse files
KudoKusStar
authored andcommitted
Upgrade folly to v2018.10.22.00 for Android (facebook#21977)
Summary: Fixes facebook#20302 (For Android) Note: ------ 1. New folly will have build break for a gcc-4.9 and gcc-4.9 seems to be deprecated for latest folly. As we only use partial folly implementations, I just fixed the build break part. To support building RN on Windows, the patches are written by gradle ReplaceTokens. 2. The change for glog copying header into exported/ is to prevent build break for folly. `folly/detail/Demangle.h` will try to use libstdc++'s demangle.h. Unfortunately, glog also has a demangle.h in source code. So I copy exported headers and only search headers in exported/ folder during build. Pull Request resolved: facebook#21977 Reviewed By: hramos Differential Revision: D12818133 Pulled By: fkgozali fbshipit-source-id: 2c1f6f012663204581a86141d0c9ed0eb9d8c698
1 parent b544371 commit 3a7e950

File tree

4 files changed

+39
-16
lines changed

4 files changed

+39
-16
lines changed

ReactAndroid/build.gradle

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ task prepareFolly(dependsOn: dependenciesPath ? [] : [downloadFolly], type: Copy
8989
// Patch for folly build break on gcc 4.9 and could be removed after build by clang
9090
filesMatching('**/container/detail/F14Policy.h') {
9191
filter(ReplaceTokens, tokens: [
92-
'ObjectHolder(Args&&... args) : value_{std::forward<Args>(args)...} {}': 'ObjectHolder(Args&&... args) : value_({std::forward<Args>(args)...}) {}',
93-
'ObjectHolder(Args&&... args) : T{std::forward<Args>(args)...} {}' : 'ObjectHolder(Args&&... args) : T({std::forward<Args>(args)...}) {}',
92+
'ObjectHolder(Args&&... args) : value_{std::forward<Args>(args)...} {}': 'ObjectHolder(Args&&... args) : value_({std::forward<Args>(args)...}) {}',
93+
'ObjectHolder(Args&&... args) : T{std::forward<Args>(args)...} {}': 'ObjectHolder(Args&&... args) : T({std::forward<Args>(args)...}) {}',
9494
],
95-
beginToken: '',
96-
endToken: '')
95+
beginToken: '',
96+
endToken: '')
9797
}
9898

9999
into "$thirdPartyNdkDir/folly"
@@ -134,6 +134,14 @@ task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy)
134134
it.path = (it.name - '.in')
135135
}
136136
into "$thirdPartyNdkDir/glog"
137+
138+
doLast {
139+
copy {
140+
from fileTree(dir: "$thirdPartyNdkDir/glog", includes: ["stl_logging.h", "logging.h", "raw_logging.h", "vlog_is_on.h", "**/glog/log_severity.h"]).files
141+
includeEmptyDirs = false
142+
into "$thirdPartyNdkDir/glog/exported/glog"
143+
}
144+
}
137145
}
138146

139147
task downloadJSC(dependsOn: createNativeDepsDirectories, type: Download) {

ReactAndroid/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ OKHTTP_VERSION=3.10.0
1717

1818
BOOST_VERSION=1_63_0
1919
DOUBLE_CONVERSION_VERSION=1.1.6
20-
FOLLY_VERSION=2016.10.31.00
20+
FOLLY_VERSION=2018.10.22.00
2121
GLOG_VERSION=0.3.5
2222
JSC_VERSION=245459.0.0

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

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,35 @@ LOCAL_PATH:= $(call my-dir)
22
include $(CLEAR_VARS)
33

44
LOCAL_SRC_FILES:= \
5-
folly/json.cpp \
6-
folly/Unicode.cpp \
7-
folly/Conv.cpp \
8-
folly/Demangle.cpp \
9-
folly/detail/MallocImpl.cpp \
10-
folly/StringBase.cpp \
11-
folly/dynamic.cpp \
5+
folly/json.cpp \
6+
folly/Unicode.cpp \
7+
folly/Conv.cpp \
8+
folly/Demangle.cpp \
9+
folly/memory/detail/MallocImpl.cpp \
10+
folly/String.cpp \
11+
folly/dynamic.cpp \
12+
folly/Format.cpp \
13+
folly/json_pointer.cpp \
14+
folly/lang/ColdClass.cpp \
15+
folly/detail/Demangle.cpp \
16+
folly/hash/SpookyHashV2.cpp \
17+
folly/container/detail/F14Table.cpp \
18+
folly/ScopeGuard.cpp \
1219

1320
LOCAL_C_INCLUDES := $(LOCAL_PATH)
1421
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
1522

16-
LOCAL_CFLAGS += -fexceptions -fno-omit-frame-pointer -frtti
23+
LOCAL_CFLAGS += -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare
24+
25+
FOLLY_FLAGS := \
26+
-DFOLLY_NO_CONFIG=1 \
27+
-DFOLLY_HAVE_CLOCK_GETTIME=1 \
28+
-DFOLLY_HAVE_MEMRCHR=1 \
29+
30+
# If APP_PLATFORM in Application.mk targets android-23 above, please comment this line.
31+
# NDK uses GNU style stderror_r() after API 23.
32+
FOLLY_FLAGS += -DFOLLY_HAVE_XSI_STRERROR_R=1
1733

18-
FOLLY_FLAGS := -DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1
1934
LOCAL_CFLAGS += $(FOLLY_FLAGS)
2035

2136
LOCAL_EXPORT_CPPFLAGS := $(FOLLY_FLAGS)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LOCAL_SRC_FILES := \
1313

1414
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/.. $(LOCAL_PATH)/glog-0.3.5/src/
1515

16-
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. $(LOCAL_PATH)/glog-0.3.5/src/
16+
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/exported
1717

1818
LOCAL_CFLAGS += \
1919
-Wwrite-strings \
@@ -28,4 +28,4 @@ LOCAL_CFLAGS += \
2828

2929
LOCAL_MODULE := glog
3030

31-
include $(BUILD_SHARED_LIBRARY)
31+
include $(BUILD_SHARED_LIBRARY)

0 commit comments

Comments
 (0)