From 0416f77ce4a4799d664ce773147f1ae09ed95384 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 7 Aug 2020 19:45:52 -0700 Subject: [PATCH] Extend 'fabric' module to compile in OSS Summary: This diff extends fabric module to compile in OSS NOTE: As a side effect of this diff, Fabric will be included into "reactnativejni" which is used by RN OSS. I'm planning to remove this dependency in the near future - T71320460 changelog: [internal] internal Reviewed By: JoshuaGross Differential Revision: D22991877 fbshipit-source-id: 0ab3ee410dd448bbd87130114bec27c6e6bc65c6 --- .../com/facebook/react/fabric/jni/Android.mk | 54 +++++++++++++ .../com/facebook/react/fabric/jni/Binding.cpp | 2 +- .../src/main/jni/react/jni/Android.mk | 76 +++++++++++++++++++ .../renderer/textlayoutmanager/Android.mk | 2 +- 4 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk new file mode 100644 index 00000000000..efe8660cadb --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk @@ -0,0 +1,54 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := fabricjni + +LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) + +LOCAL_SHARED_LIBRARIES := libreactconfig libyoga libglog libfb libfbjni libglog_init libfolly_json libfolly_futures libreact_render_mounting libreactnativeutilsjni libreact_utils libreact_render_debug libreact_render_graphics libreact_render_core libreact_render_mapbuffer react_render_componentregistry libreact_render_components_view libreact_render_components_view libreact_render_components_unimplementedview libreact_render_components_root libreact_render_components_scrollview libbetter libreact_render_attributedstring libreact_render_uimanager libreact_render_templateprocessor libreact_render_scheduler libreact_render_animations libreact_render_imagemanager libreact_render_textlayoutmanager + +LOCAL_STATIC_LIBRARIES := + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/ + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ + +LOCAL_CFLAGS := \ + -DLOG_TAG=\"Fabric\" + +LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,fbgloginit) +$(call import-module,folly) +$(call import-module,fb) +$(call import-module,fbjni) +$(call import-module,yogajni) +$(call import-module,glog) + +$(call import-module,react/utils) +$(call import-module,react/config) +$(call import-module,react/renderer/animations) +$(call import-module,react/renderer/attributedstring) +$(call import-module,react/renderer/componentregistry) +$(call import-module,react/renderer/core) +$(call import-module,react/renderer/components/root) +$(call import-module,react/renderer/components/scrollview) +$(call import-module,react/renderer/components/unimplementedview) +$(call import-module,react/renderer/components/view) +$(call import-module,react/renderer/debug) +$(call import-module,react/renderer/graphics) +$(call import-module,react/renderer/imagemanager) +$(call import-module,react/renderer/mapbuffer) +$(call import-module,react/renderer/mounting) +$(call import-module,react/renderer/scheduler) +$(call import-module,react/renderer/templateprocessor) +$(call import-module,react/renderer/textlayoutmanager) +$(call import-module,react/renderer/uimanager) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index 1926c956062..3d2d7c3b037 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include using namespace facebook::jni; using namespace facebook::jsi; diff --git a/ReactAndroid/src/main/jni/react/jni/Android.mk b/ReactAndroid/src/main/jni/react/jni/Android.mk index b50eefee9ce..356d67728eb 100644 --- a/ReactAndroid/src/main/jni/react/jni/Android.mk +++ b/ReactAndroid/src/main/jni/react/jni/Android.mk @@ -3,6 +3,11 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. + +########################## +### React Native Utils ### +########################## + LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) @@ -27,6 +32,56 @@ LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libglog_init libyoga # The static libraries (.a files) that this module depends on. LOCAL_STATIC_LIBRARIES := libreactnative libcallinvokerholder libruntimeexecutor +# Name of this module. +# +# Other modules can depend on this one by adding libreactnativejni to their +# LOCAL_SHARED_LIBRARIES variable. +LOCAL_MODULE := reactnativeutilsjni + +# Compile all local c++ files. +LOCAL_SRC_FILES := $(wildcard Cxx*.cpp) $(wildcard J*.cpp) $(wildcard M*.cpp) $(wildcard N*.cpp) $(wildcard P*.cpp) $(wildcard R*.cpp) $(wildcard W*.cpp) + +ifeq ($(APP_OPTIM),debug) + # Keep symbols by overriding the strip command invoked by ndk-build. + # Note that this will apply to all shared libraries, + # i.e. shared libraries will NOT be stripped + # even though we override it in this Android.mk + cmd-strip := +endif + +# Build the files in this directory as a shared library +include $(BUILD_SHARED_LIBRARY) + + + + + +###################### +### reactnativejni ### +###################### + +include $(CLEAR_VARS) + +# Include . in the header search path for all source files in this module. +LOCAL_C_INCLUDES := $(LOCAL_PATH) + +# Include ./../../ in the header search path for modules that depend on +# reactnativejni. This will allow external modules to require this module's +# headers using #include .h>, assuming: +# . == jni +# ./../ == react +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../.. + +LOCAL_CFLAGS += -fexceptions -frtti -Wno-unused-lambda-capture + +LOCAL_LDLIBS += -landroid + +# The dynamic libraries (.so files) that this module depends on. +LOCAL_SHARED_LIBRARIES := libreactnativeutilsjni libfolly_json libfb libfbjni libglog_init libyoga libreact_utils libreact_render_debug libreact_render_graphics libreact_render_core libreact_render_mapbuffer react_render_componentregistry libreact_render_components_view libreact_render_components_view libreact_render_components_unimplementedview libreact_render_components_root libreact_render_components_scrollview libbetter libreact_render_attributedstring libreact_render_uimanager libreact_render_templateprocessor libreact_render_scheduler libreact_render_animations libreact_render_imagemanager libreact_render_textlayoutmanager libfabricjni + +# The static libraries (.a files) that this module depends on. +LOCAL_STATIC_LIBRARIES := libreactnative libcallinvokerholder libruntimeexecutor + # Name of this module. # # Other modules can depend on this one by adding libreactnativejni to their @@ -74,8 +129,29 @@ $(call import-module,reactperflogger) $(call import-module,hermes) $(call import-module,runtimeexecutor) +# Fabric dependencies: +$(call import-module,react/utils) +$(call import-module,react/renderer/animations) +$(call import-module,react/renderer/attributedstring) +$(call import-module,react/renderer/componentregistry) +$(call import-module,react/renderer/core) +$(call import-module,react/renderer/components/root) +$(call import-module,react/renderer/components/scrollview) +$(call import-module,react/renderer/components/unimplementedview) +$(call import-module,react/renderer/components/view) +$(call import-module,react/renderer/debug) +$(call import-module,react/renderer/graphics) +$(call import-module,react/renderer/imagemanager) +$(call import-module,react/renderer/mapbuffer) +$(call import-module,react/renderer/mounting) +$(call import-module,react/renderer/scheduler) +$(call import-module,react/renderer/templateprocessor) +$(call import-module,react/renderer/textlayoutmanager) +$(call import-module,react/renderer/uimanager) + include $(REACT_SRC_DIR)/reactperflogger/jni/Android.mk include $(REACT_SRC_DIR)/turbomodule/core/jni/Android.mk +include $(REACT_SRC_DIR)/fabric/jni/Android.mk # TODO(ramanpreet): # Why doesn't this import-module call generate a jscexecutor.so file? diff --git a/ReactCommon/react/renderer/textlayoutmanager/Android.mk b/ReactCommon/react/renderer/textlayoutmanager/Android.mk index aacae6e76af..8047965fa1c 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/Android.mk +++ b/ReactCommon/react/renderer/textlayoutmanager/Android.mk @@ -11,7 +11,7 @@ LOCAL_MODULE := react_render_textlayoutmanager LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp $(LOCAL_PATH)/platform/android/react/renderer/textlayoutmanager/*.cpp) -LOCAL_SHARED_LIBRARIES := libreactnativejni libreact_utils libfb libfbjni libreact_render_uimanager libreact_render_componentregistry libreact_render_attributedstring libfolly_json libyoga libfolly_json libreact_render_core libreact_render_debug libreact_render_graphics +LOCAL_SHARED_LIBRARIES := libfolly_futures libreactnativeutilsjni libreact_utils libfb libfbjni libreact_render_uimanager libreact_render_componentregistry libreact_render_attributedstring libfolly_json libyoga libfolly_json libreact_render_core libreact_render_debug libreact_render_graphics LOCAL_STATIC_LIBRARIES :=