Summary:
`CatalystInstanceImpl.cpp` now depends on `JSCallInvoker` and `JavaJSCallInvokerHolder`. Therefore, we need to correctly adjust the OSS builds to include these dependencies into the `libreactnativejni.so` file.

I made `ReactCommon/turbomodule/jscallinvoker` a static library `libjscallinvoker.a`. I then made `ReactAndroid/src/main/jni/react/jni`'s `libreactnativejni.so` depend on that static library. Also, because the Android NDK build system doesn't support header namespaces, I had to use the filesystem to simulate them. This is why all the `.cpp` and `.h` files for `JSCallInvoker` were moved to a `jsireact` folder.

Reviewed By: mdvacca

Differential Revision: D15194821

fbshipit-source-id: 0cee682e41db53d0619f56ad017d5882f6d554aa
This commit is contained in:
Ramanpreet Nara 2019-05-03 13:25:56 -07:00 коммит произвёл Facebook Github Bot
Родитель cba205b82c
Коммит d77adcadbe
14 изменённых файлов: 74 добавлений и 18 удалений

Просмотреть файл

@ -0,0 +1,29 @@
# 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)
# Header search path for all source files in this module.
LOCAL_C_INCLUDES := $(LOCAL_PATH)/jsireact
# Header search path for modules that depend on this module
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall
LOCAL_STATIC_LIBRARIES = libjscallinvoker
LOCAL_SHARED_LIBRARIES = libfb
# Name of this module.
LOCAL_MODULE := jscallinvokerholder
# Compile all local c++ files under ./platform/android/jsireact
LOCAL_SRC_FILES := $(LOCAL_PATH)/jsireact/JSCallInvokerHolder.cpp
# Build the files in this directory as a shared library
include $(BUILD_STATIC_LIBRARY)

Просмотреть файл

@ -3,13 +3,13 @@ load("@fbsource//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "FBJNI_TARGET", "
rn_xplat_cxx_library(
name = "jni",
srcs = [
"OnLoad.cpp",
"TurboModuleManager.cpp",
"jsireact/OnLoad.cpp",
"jsireact/TurboModuleManager.cpp",
],
header_namespace = "",
exported_headers = {
"jsireact/TurboModuleManager.h": "TurboModuleManager.h",
"jsireact/TurboModuleManagerDelegate.h": "TurboModuleManagerDelegate.h",
"jsireact/TurboModuleManager.h": "jsireact/TurboModuleManager.h",
"jsireact/TurboModuleManagerDelegate.h": "jsireact/TurboModuleManagerDelegate.h",
},
compiler_flags = [
"-fexceptions",
@ -39,11 +39,11 @@ rn_xplat_cxx_library(
rn_xplat_cxx_library(
name = "jscallinvokerholder",
srcs = [
"JSCallInvokerHolder.cpp",
"jsireact/JSCallInvokerHolder.cpp",
],
header_namespace = "",
exported_headers = {
"jsireact/JSCallInvokerHolder.h": "JSCallInvokerHolder.h",
"jsireact/JSCallInvokerHolder.h": "jsireact/JSCallInvokerHolder.h",
},
compiler_flags = [
"-fexceptions",

Просмотреть файл

@ -25,7 +25,7 @@ LOCAL_LDLIBS += -landroid
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libglog_init libyoga
# The static libraries (.a files) that this module depends on.
LOCAL_STATIC_LIBRARIES := libreactnative
LOCAL_STATIC_LIBRARIES := libreactnative libjscallinvokerholder
# Name of this module.
#
@ -59,6 +59,9 @@ $(call import-module,yogajni)
$(call import-module,cxxreact)
$(call import-module,jsi)
$(call import-module,jsiexecutor)
$(call import-module,jscallinvoker)
include $(REACT_SRC_DIR)/turbomodule/core/jni/Android.mk
# TODO(ramanpreet):
# Why doesn't this import-module call generate a jscexecutor.so file?

Просмотреть файл

@ -267,7 +267,7 @@ void CatalystInstanceImpl::handleMemoryPressure(int pressureLevel) {
}
jni::alias_ref<JSCallInvokerHolder::javaobject> CatalystInstanceImpl::getJSCallInvokerHolder() {
if (javaInstanceHolder_ == nullptr) {
if (!javaInstanceHolder_) {
jsCallInvoker_ = std::make_shared<JSCallInvoker>(instance_);
javaInstanceHolder_ = jni::make_global(JSCallInvokerHolder::newObjectCxxArgs(jsCallInvoker_));
}

Просмотреть файл

@ -0,0 +1,27 @@
# 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)
# Header search path for all source files in this module.
LOCAL_C_INCLUDES := $(LOCAL_PATH)/jsireact
# Header search path for modules that depend on this module
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall
LOCAL_STATIC_LIBRARIES = libreactnative
# Name of this module.
LOCAL_MODULE := jscallinvoker
# Compile all local c++ files under ./jsireact
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/jsireact/*.cpp)
# Build the files in this directory as a shared library
include $(BUILD_STATIC_LIBRARY)

Просмотреть файл

@ -1,17 +1,14 @@
load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "react_native_xplat_target", "rn_xplat_cxx_library", "subdir_glob")
load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "react_native_xplat_target", "rn_xplat_cxx_library")
rn_xplat_cxx_library(
name = "jscallinvoker",
srcs = glob(
["*.cpp"],
),
srcs = [
"jsireact/JSCallInvoker.cpp",
],
header_namespace = "",
exported_headers = subdir_glob(
[
("", "*.h"),
],
prefix = "jsireact",
),
exported_headers = {
"jsireact/JSCallInvoker.h": "jsireact/JSCallInvoker.h",
},
compiler_flags = [
"-fexceptions",
"-frtti",