Invert native dependency of new bridge -> old bridge
Reviewed By: mhorowitz Differential Revision: D3374937 fbshipit-source-id: 58b082bba727e33a3b08361be3630d669fc8dc5b
This commit is contained in:
parent
26a92220c2
commit
bf010a4c17
|
@ -14,6 +14,10 @@ import com.facebook.soloader.SoLoader;
|
|||
|
||||
@DoNotStrip
|
||||
public class JSCJavaScriptExecutor extends JavaScriptExecutor {
|
||||
static {
|
||||
ReactBridge.staticInit();
|
||||
}
|
||||
|
||||
public static class Factory implements JavaScriptExecutor.Factory {
|
||||
@Override
|
||||
public JavaScriptExecutor create(WritableNativeMap jscConfig) throws Exception {
|
||||
|
@ -21,10 +25,6 @@ public class JSCJavaScriptExecutor extends JavaScriptExecutor {
|
|||
}
|
||||
}
|
||||
|
||||
static {
|
||||
SoLoader.loadLibrary(ReactBridge.REACT_NATIVE_LIB);
|
||||
}
|
||||
|
||||
public JSCJavaScriptExecutor(WritableNativeMap jscConfig) {
|
||||
initialize(jscConfig);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import com.facebook.soloader.SoLoader;
|
|||
@DoNotStrip
|
||||
public abstract class NativeArray {
|
||||
static {
|
||||
SoLoader.loadLibrary(ReactBridge.REACT_NATIVE_LIB);
|
||||
ReactBridge.staticInit();
|
||||
}
|
||||
|
||||
protected NativeArray(HybridData hybridData) {
|
||||
|
|
|
@ -19,7 +19,7 @@ import com.facebook.soloader.SoLoader;
|
|||
@DoNotStrip
|
||||
public abstract class NativeMap {
|
||||
static {
|
||||
SoLoader.loadLibrary(ReactBridge.REACT_NATIVE_LIB);
|
||||
ReactBridge.staticInit();
|
||||
}
|
||||
|
||||
public NativeMap(HybridData hybridData) {
|
||||
|
|
|
@ -24,6 +24,10 @@ import com.facebook.proguard.annotations.DoNotStrip;
|
|||
*/
|
||||
@DoNotStrip
|
||||
public class ProxyJavaScriptExecutor extends JavaScriptExecutor {
|
||||
static {
|
||||
ReactBridge.staticInit();
|
||||
}
|
||||
|
||||
public static class Factory implements JavaScriptExecutor.Factory {
|
||||
private final JavaJSExecutor.Factory mJavaJSExecutorFactory;
|
||||
|
||||
|
@ -37,10 +41,6 @@ public class ProxyJavaScriptExecutor extends JavaScriptExecutor {
|
|||
}
|
||||
}
|
||||
|
||||
static {
|
||||
SoLoader.loadLibrary(ReactBridge.REACT_NATIVE_LIB);
|
||||
}
|
||||
|
||||
private @Nullable JavaJSExecutor mJavaJSExecutor;
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,16 +24,22 @@ import com.facebook.soloader.SoLoader;
|
|||
@DoNotStrip
|
||||
public class ReactBridge extends Countable {
|
||||
|
||||
/* package */ static final String REACT_NATIVE_LIB = "reactnativejni";
|
||||
private static final String REACT_NATIVE_LIB = "reactnativejni";
|
||||
private static final String XREACT_NATIVE_LIB = "reactnativejnifb";
|
||||
|
||||
static {
|
||||
SoLoader.loadLibrary(REACT_NATIVE_LIB);
|
||||
SoLoader.loadLibrary(XREACT_NATIVE_LIB);
|
||||
}
|
||||
|
||||
private final ReactCallback mCallback;
|
||||
private final JavaScriptExecutor mJSExecutor;
|
||||
private final MessageQueueThread mNativeModulesQueueThread;
|
||||
|
||||
public static void staticInit() {
|
||||
// This is just called to ensure that ReactBridge's static initialization has taken place.
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jsExecutor the JS executor to use to run JS
|
||||
* @param callback the callback class used to invoke native modules
|
||||
|
|
|
@ -21,9 +21,8 @@ import java.util.ArrayList;
|
|||
*/
|
||||
@DoNotStrip
|
||||
public class ReadableNativeArray extends NativeArray implements ReadableArray {
|
||||
|
||||
static {
|
||||
SoLoader.loadLibrary(ReactBridge.REACT_NATIVE_LIB);
|
||||
ReactBridge.staticInit();
|
||||
}
|
||||
|
||||
protected ReadableNativeArray(HybridData hybridData) {
|
||||
|
|
|
@ -22,9 +22,8 @@ import java.util.HashMap;
|
|||
*/
|
||||
@DoNotStrip
|
||||
public class ReadableNativeMap extends NativeMap implements ReadableMap {
|
||||
|
||||
static {
|
||||
SoLoader.loadLibrary(ReactBridge.REACT_NATIVE_LIB);
|
||||
ReactBridge.staticInit();
|
||||
}
|
||||
|
||||
protected ReadableNativeMap(HybridData hybridData) {
|
||||
|
|
|
@ -21,9 +21,8 @@ import com.facebook.soloader.SoLoader;
|
|||
*/
|
||||
@DoNotStrip
|
||||
public class WritableNativeArray extends ReadableNativeArray implements WritableArray {
|
||||
|
||||
static {
|
||||
SoLoader.loadLibrary(ReactBridge.REACT_NATIVE_LIB);
|
||||
ReactBridge.staticInit();
|
||||
}
|
||||
|
||||
public WritableNativeArray() {
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.facebook.soloader.SoLoader;
|
|||
@DoNotStrip
|
||||
public class WritableNativeMap extends ReadableNativeMap implements WritableMap {
|
||||
static {
|
||||
SoLoader.loadLibrary(ReactBridge.REACT_NATIVE_LIB);
|
||||
ReactBridge.staticInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,15 +11,8 @@ LOCAL_SRC_FILES := \
|
|||
JSLoader.cpp \
|
||||
JSLogging.cpp \
|
||||
JniJSModulesUnbundle.cpp \
|
||||
NativeArray.cpp \
|
||||
NativeCommon.cpp \
|
||||
NativeMap.cpp \
|
||||
OnLoad.cpp \
|
||||
ProxyExecutor.cpp \
|
||||
ReadableNativeArray.cpp \
|
||||
ReadableNativeMap.cpp \
|
||||
WritableNativeArray.cpp \
|
||||
WritableNativeMap.cpp \
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../.. $(LOCAL_PATH)/..
|
||||
|
@ -30,7 +23,7 @@ LOCAL_CFLAGS += $(CXX11_FLAGS)
|
|||
LOCAL_EXPORT_CPPFLAGS := $(CXX11_FLAGS)
|
||||
|
||||
LOCAL_LDLIBS += -landroid
|
||||
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libjsc libglog_init
|
||||
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libjsc libglog_init libreactnativejnifb
|
||||
LOCAL_STATIC_LIBRARIES := libreactnative
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
@ -41,3 +34,4 @@ $(call import-module,folly)
|
|||
$(call import-module,fbgloginit)
|
||||
$(call import-module,fb)
|
||||
$(call import-module,jsc)
|
||||
$(call import-module,xreact/jni)
|
||||
|
|
|
@ -18,6 +18,7 @@ def jni_library(**kwargs):
|
|||
],
|
||||
deps = DEPS + JSC_DEPS + [
|
||||
react_native_target('jni/react:react'),
|
||||
react_native_target('jni/xreact/jni:jni'),
|
||||
],
|
||||
**kwargs
|
||||
)
|
||||
|
@ -33,15 +34,8 @@ jni_library(
|
|||
'JSLoader.cpp',
|
||||
'JSLogging.cpp',
|
||||
'JniJSModulesUnbundle.cpp',
|
||||
'NativeArray.cpp',
|
||||
'NativeCommon.cpp',
|
||||
'NativeMap.cpp',
|
||||
'OnLoad.cpp',
|
||||
'ProxyExecutor.cpp',
|
||||
'ReadableNativeArray.cpp',
|
||||
'ReadableNativeMap.cpp',
|
||||
'WritableNativeArray.cpp',
|
||||
'WritableNativeMap.cpp',
|
||||
],
|
||||
headers = [
|
||||
'JSLoader.h',
|
||||
|
@ -56,13 +50,6 @@ jni_library(
|
|||
'WebWorkers.h',
|
||||
],
|
||||
exported_headers = [
|
||||
'NativeCommon.h',
|
||||
'NativeArray.h',
|
||||
'NativeMap.h',
|
||||
'ReadableNativeArray.h',
|
||||
'ReadableNativeMap.h',
|
||||
'WritableNativeArray.h',
|
||||
'WritableNativeMap.h',
|
||||
],
|
||||
preprocessor_flags = [
|
||||
'-DLOG_TAG="ReactNativeJNI"',
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
#include "JExecutorTokenFactory.h"
|
||||
#include "JNativeRunnable.h"
|
||||
#include "JSLoader.h"
|
||||
#include "NativeCommon.h"
|
||||
#include "ReadableNativeArray.h"
|
||||
#include "ProxyExecutor.h"
|
||||
#include "OnLoad.h"
|
||||
#include "JMessageQueueThread.h"
|
||||
|
@ -31,7 +29,9 @@
|
|||
#include "JSLogging.h"
|
||||
#include "JSCPerfLogging.h"
|
||||
#include "WebWorkers.h"
|
||||
#include "WritableNativeMap.h"
|
||||
|
||||
#include <xreact/jni/ReadableNativeArray.h>
|
||||
#include <xreact/jni/WritableNativeMap.h>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef WITH_FBSYSTRACE
|
||||
|
@ -456,17 +456,9 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
|||
PerfLogging::installNativeHooks = addNativePerfLoggingHooks;
|
||||
JSLogging::nativeHook = nativeLoggingHook;
|
||||
|
||||
NativeArray::registerNatives();
|
||||
ReadableNativeArray::registerNatives();
|
||||
WritableNativeArray::registerNatives();
|
||||
JNativeRunnable::registerNatives();
|
||||
registerJSLoaderNatives();
|
||||
|
||||
NativeMap::registerNatives();
|
||||
ReadableNativeMap::registerNatives();
|
||||
WritableNativeMap::registerNatives();
|
||||
ReadableNativeMapKeySetIterator::registerNatives();
|
||||
|
||||
registerNatives("com/facebook/react/bridge/JSCJavaScriptExecutor", {
|
||||
makeNativeMethod("initialize", executors::createJSCExecutor),
|
||||
});
|
||||
|
|
|
@ -9,14 +9,21 @@ LOCAL_SRC_FILES := \
|
|||
CxxModuleWrapper.cpp \
|
||||
JExecutorToken.cpp \
|
||||
JMessageQueueThread.cpp \
|
||||
JniJSModulesUnbundle.cpp \
|
||||
JSCPerfLogging.cpp \
|
||||
JSLoader.cpp \
|
||||
JSLogging.cpp \
|
||||
JniJSModulesUnbundle.cpp \
|
||||
MethodInvoker.cpp \
|
||||
ModuleRegistryHolder.cpp \
|
||||
NativeArray.cpp \
|
||||
NativeCommon.cpp \
|
||||
NativeMap.cpp \
|
||||
OnLoad.cpp \
|
||||
ProxyExecutor.cpp \
|
||||
ReadableNativeArray.cpp \
|
||||
ReadableNativeMap.cpp \
|
||||
WritableNativeArray.cpp \
|
||||
WritableNativeMap.cpp \
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../..
|
||||
|
@ -27,7 +34,7 @@ LOCAL_CFLAGS += $(CXX11_FLAGS)
|
|||
LOCAL_EXPORT_CPPFLAGS := $(CXX11_FLAGS)
|
||||
|
||||
LOCAL_LDLIBS += -landroid
|
||||
LOCAL_SHARED_LIBRARIES := libfolly_json libfbjni libjsc libglog_init libreactnativejni
|
||||
LOCAL_SHARED_LIBRARIES := libfolly_json libfbjni libjsc libglog_init
|
||||
LOCAL_STATIC_LIBRARIES := libreactnativefb
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
@ -37,4 +44,3 @@ $(call import-module,jsc)
|
|||
$(call import-module,folly)
|
||||
$(call import-module,fbgloginit)
|
||||
$(call import-module,jsc)
|
||||
$(call import-module,react/jni)
|
||||
|
|
|
@ -5,19 +5,25 @@ SUPPORTED_PLATFORMS = '^android-(armv7|x86)$'
|
|||
|
||||
EXPORTED_HEADERS = [
|
||||
'CxxModuleWrapper.h',
|
||||
'NativeArray.h',
|
||||
'NativeCommon.h',
|
||||
'NativeMap.h',
|
||||
'ReadableNativeArray.h',
|
||||
'ReadableNativeMap.h',
|
||||
'WritableNativeArray.h',
|
||||
'WritableNativeMap.h',
|
||||
]
|
||||
|
||||
cxx_library(
|
||||
name='jni',
|
||||
soname = 'libreactnativejnifb.so',
|
||||
header_namespace = 'react/jni',
|
||||
header_namespace = 'xreact/jni',
|
||||
supported_platforms_regex = SUPPORTED_PLATFORMS,
|
||||
deps = JSC_DEPS + [
|
||||
'//native/fb:fb',
|
||||
'//native/third-party/android-ndk:android',
|
||||
'//xplat/folly:molly',
|
||||
'//xplat/fbsystrace:fbsystrace',
|
||||
react_native_target('jni/react/jni:jni'),
|
||||
react_native_xplat_target('cxxreact:bridge'),
|
||||
react_native_xplat_target('cxxreact:module'),
|
||||
],
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
#include <jni/Countable.h>
|
||||
#include <jni/LocalReference.h>
|
||||
|
||||
#include <react/jni/NativeArray.h>
|
||||
|
||||
#include <cxxreact/Instance.h>
|
||||
#include <cxxreact/MethodCall.h>
|
||||
#include <cxxreact/ModuleRegistry.h>
|
||||
|
@ -23,6 +21,7 @@
|
|||
#include "JavaScriptExecutorHolder.h"
|
||||
#include "JniJSModulesUnbundle.h"
|
||||
#include "ModuleRegistryHolder.h"
|
||||
#include "NativeArray.h"
|
||||
#include "JNativeRunnable.h"
|
||||
|
||||
using namespace facebook::jni;
|
||||
|
|
|
@ -2,16 +2,11 @@
|
|||
|
||||
#include "CxxModuleWrapper.h"
|
||||
|
||||
#include <react/jni/ReadableNativeArray.h>
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fb/Environment.h>
|
||||
#include <jni/LocalString.h>
|
||||
#include <jni/Registration.h>
|
||||
|
||||
#include <cxxreact/JsArgumentHelpers.h>
|
||||
#include <cxxreact/FollySupport.h>
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#include <folly/json.h>
|
||||
|
@ -20,6 +15,12 @@
|
|||
#include <unordered_set>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <cxxreact/JsArgumentHelpers.h>
|
||||
#include <cxxreact/FollySupport.h>
|
||||
|
||||
#include "ReadableNativeArray.h"
|
||||
|
||||
|
||||
using namespace facebook::jni;
|
||||
using namespace facebook::xplat::module;
|
||||
using namespace facebook::react;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <folly/dynamic.h>
|
||||
#include <fb/fbjni.h>
|
||||
|
||||
#include <react/jni/NativeArray.h>
|
||||
#include "NativeArray.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
#include "JSCPerfLogging.h"
|
||||
|
||||
#include <cxxreact/JSCHelpers.h>
|
||||
|
||||
#include <fb/log.h>
|
||||
#include <fb/fbjni.h>
|
||||
#include <react/JSCHelpers.h>
|
||||
|
||||
using namespace facebook::jni;
|
||||
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
|
||||
#include <android/log.h>
|
||||
#include <algorithm>
|
||||
#include <react/Value.h>
|
||||
#include <fb/log.h>
|
||||
|
||||
#include <cxxreact/Value.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "MethodInvoker.h"
|
||||
|
||||
#include <react/jni/ReadableNativeArray.h>
|
||||
#ifdef WITH_FBSYSTRACE
|
||||
#include <fbsystrace.h>
|
||||
#endif
|
||||
|
@ -10,6 +9,7 @@
|
|||
#include "ModuleRegistryHolder.h"
|
||||
#include "JCallback.h"
|
||||
#include "JExecutorToken.h"
|
||||
#include "ReadableNativeArray.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
|
|
@ -10,11 +10,10 @@
|
|||
#include <cxxreact/Instance.h>
|
||||
#include <cxxreact/JsArgumentHelpers.h>
|
||||
#include <cxxreact/NativeModule.h>
|
||||
#include <react/jni/ReadableNativeArray.h>
|
||||
|
||||
#include "MethodInvoker.h"
|
||||
|
||||
#include "CatalystInstanceImpl.h"
|
||||
#include "MethodInvoker.h"
|
||||
#include "ReadableNativeArray.h"
|
||||
|
||||
using facebook::xplat::module::CxxModule;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <cxxreact/JSCExecutor.h>
|
||||
#include <cxxreact/Platform.h>
|
||||
#include <cxxreact/Value.h>
|
||||
#include <react/jni/ReadableNativeArray.h>
|
||||
#include "CatalystInstanceImpl.h"
|
||||
#include "JavaScriptExecutorHolder.h"
|
||||
#include "JSCPerfLogging.h"
|
||||
|
@ -17,6 +16,9 @@
|
|||
#include "WebWorkers.h"
|
||||
#include "JCallback.h"
|
||||
|
||||
#include "WritableNativeMap.h"
|
||||
#include "WritableNativeArray.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace facebook::jni;
|
||||
|
@ -180,6 +182,14 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
|||
CxxModuleWrapper::registerNatives();
|
||||
JCallbackImpl::registerNatives();
|
||||
registerJSLoaderNatives();
|
||||
|
||||
NativeArray::registerNatives();
|
||||
ReadableNativeArray::registerNatives();
|
||||
WritableNativeArray::registerNatives();
|
||||
NativeMap::registerNatives();
|
||||
ReadableNativeMap::registerNatives();
|
||||
WritableNativeMap::registerNatives();
|
||||
ReadableNativeMapKeySetIterator::registerNatives();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ struct WritableNativeMap : jni::HybridClass<WritableNativeMap, ReadableNativeMap
|
|||
|
||||
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jclass>);
|
||||
|
||||
__attribute__((visibility("default")))
|
||||
folly::dynamic consume();
|
||||
|
||||
void putNull(std::string key);
|
Loading…
Reference in New Issue