Skip to content

Commit a316dc6

Browse files
Kudofacebook-github-bot
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 1eedf05 commit a316dc6

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-12
lines changed

ReactAndroid/build.gradle

+19
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ task prepareFolly(dependsOn: dependenciesPath ? [] : [downloadFolly], type: Copy
8686
include "folly-${FOLLY_VERSION}/folly/**/*", 'Android.mk'
8787
eachFile {fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/")}
8888
includeEmptyDirs = false
89+
90+
// Patch for folly build break on gcc 4.9 and could be removed after build by clang
91+
filesMatching('**/container/detail/F14Policy.h') {
92+
filter(ReplaceTokens, tokens: [
93+
'ObjectHolder(Args&&... args) : value_{std::forward<Args>(args)...} {}': 'ObjectHolder(Args&&... args) : value_({std::forward<Args>(args)...}) {}',
94+
'ObjectHolder(Args&&... args) : T{std::forward<Args>(args)...} {}': 'ObjectHolder(Args&&... args) : T({std::forward<Args>(args)...}) {}',
95+
],
96+
beginToken: '',
97+
endToken: '')
98+
}
99+
89100
into "$thirdPartyNdkDir/folly"
90101
}
91102

@@ -124,6 +135,14 @@ task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy)
124135
it.path = (it.name - '.in')
125136
}
126137
into "$thirdPartyNdkDir/glog"
138+
139+
doLast {
140+
copy {
141+
from fileTree(dir: "$thirdPartyNdkDir/glog", includes: ["stl_logging.h", "logging.h", "raw_logging.h", "vlog_is_on.h", "**/glog/log_severity.h"]).files
142+
includeEmptyDirs = false
143+
into "$thirdPartyNdkDir/glog/exported/glog"
144+
}
145+
}
127146
}
128147

129148
task downloadJSCHeaders(type: Download) {

ReactAndroid/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ OKHTTP_VERSION=3.11.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

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

+24-9
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

+2-2
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)