From a316dc6ec34655981c0f226186f4fb668e4a01e2 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Mon, 29 Oct 2018 12:04:30 -0700 Subject: [PATCH] Upgrade folly to v2018.10.22.00 for Android (#21977) Summary: Fixes #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: https://github.com/facebook/react-native/pull/21977 Reviewed By: hramos Differential Revision: D12818133 Pulled By: fkgozali fbshipit-source-id: 2c1f6f012663204581a86141d0c9ed0eb9d8c698 --- ReactAndroid/build.gradle | 19 +++++++++++ ReactAndroid/gradle.properties | 2 +- .../src/main/jni/third-party/folly/Android.mk | 33 ++++++++++++++----- .../src/main/jni/third-party/glog/Android.mk | 4 +-- 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index 70a38af77b29f1..a419728d773e9c 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -86,6 +86,17 @@ task prepareFolly(dependsOn: dependenciesPath ? [] : [downloadFolly], type: Copy include "folly-${FOLLY_VERSION}/folly/**/*", 'Android.mk' eachFile {fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/")} includeEmptyDirs = false + + // Patch for folly build break on gcc 4.9 and could be removed after build by clang + filesMatching('**/container/detail/F14Policy.h') { + filter(ReplaceTokens, tokens: [ + 'ObjectHolder(Args&&... args) : value_{std::forward(args)...} {}': 'ObjectHolder(Args&&... args) : value_({std::forward(args)...}) {}', + 'ObjectHolder(Args&&... args) : T{std::forward(args)...} {}': 'ObjectHolder(Args&&... args) : T({std::forward(args)...}) {}', + ], + beginToken: '', + endToken: '') + } + into "$thirdPartyNdkDir/folly" } @@ -124,6 +135,14 @@ task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy) it.path = (it.name - '.in') } into "$thirdPartyNdkDir/glog" + + doLast { + copy { + from fileTree(dir: "$thirdPartyNdkDir/glog", includes: ["stl_logging.h", "logging.h", "raw_logging.h", "vlog_is_on.h", "**/glog/log_severity.h"]).files + includeEmptyDirs = false + into "$thirdPartyNdkDir/glog/exported/glog" + } + } } task downloadJSCHeaders(type: Download) { diff --git a/ReactAndroid/gradle.properties b/ReactAndroid/gradle.properties index 72f09651936936..97551d4f31f376 100644 --- a/ReactAndroid/gradle.properties +++ b/ReactAndroid/gradle.properties @@ -17,5 +17,5 @@ OKHTTP_VERSION=3.11.0 BOOST_VERSION=1_63_0 DOUBLE_CONVERSION_VERSION=1.1.6 -FOLLY_VERSION=2016.10.31.00 +FOLLY_VERSION=2018.10.22.00 GLOG_VERSION=0.3.5 diff --git a/ReactAndroid/src/main/jni/third-party/folly/Android.mk b/ReactAndroid/src/main/jni/third-party/folly/Android.mk index 132a44247c2a6f..4700879022a26d 100644 --- a/ReactAndroid/src/main/jni/third-party/folly/Android.mk +++ b/ReactAndroid/src/main/jni/third-party/folly/Android.mk @@ -2,20 +2,35 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ - folly/json.cpp \ - folly/Unicode.cpp \ - folly/Conv.cpp \ - folly/Demangle.cpp \ - folly/detail/MallocImpl.cpp \ - folly/StringBase.cpp \ - folly/dynamic.cpp \ + folly/json.cpp \ + folly/Unicode.cpp \ + folly/Conv.cpp \ + folly/Demangle.cpp \ + folly/memory/detail/MallocImpl.cpp \ + folly/String.cpp \ + folly/dynamic.cpp \ + folly/Format.cpp \ + folly/json_pointer.cpp \ + folly/lang/ColdClass.cpp \ + folly/detail/Demangle.cpp \ + folly/hash/SpookyHashV2.cpp \ + folly/container/detail/F14Table.cpp \ + folly/ScopeGuard.cpp \ LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) -LOCAL_CFLAGS += -fexceptions -fno-omit-frame-pointer -frtti +LOCAL_CFLAGS += -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare + +FOLLY_FLAGS := \ + -DFOLLY_NO_CONFIG=1 \ + -DFOLLY_HAVE_CLOCK_GETTIME=1 \ + -DFOLLY_HAVE_MEMRCHR=1 \ + +# If APP_PLATFORM in Application.mk targets android-23 above, please comment this line. +# NDK uses GNU style stderror_r() after API 23. +FOLLY_FLAGS += -DFOLLY_HAVE_XSI_STRERROR_R=1 -FOLLY_FLAGS := -DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 LOCAL_CFLAGS += $(FOLLY_FLAGS) LOCAL_EXPORT_CPPFLAGS := $(FOLLY_FLAGS) diff --git a/ReactAndroid/src/main/jni/third-party/glog/Android.mk b/ReactAndroid/src/main/jni/third-party/glog/Android.mk index a352ebd9451c15..1abd09655046d0 100644 --- a/ReactAndroid/src/main/jni/third-party/glog/Android.mk +++ b/ReactAndroid/src/main/jni/third-party/glog/Android.mk @@ -13,7 +13,7 @@ LOCAL_SRC_FILES := \ LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/.. $(LOCAL_PATH)/glog-0.3.5/src/ -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. $(LOCAL_PATH)/glog-0.3.5/src/ +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/exported LOCAL_CFLAGS += \ -Wwrite-strings \ @@ -28,4 +28,4 @@ LOCAL_CFLAGS += \ LOCAL_MODULE := glog -include $(BUILD_SHARED_LIBRARY) \ No newline at end of file +include $(BUILD_SHARED_LIBRARY)