Invert native dependency of new bridge -> old bridge

Reviewed By: mhorowitz

Differential Revision: D3400379

fbshipit-source-id: d641846261977b4f77c2d215bef94e8e676e2c02
This commit is contained in:
Chris Hopman 2016-06-07 16:19:23 -07:00 committed by Facebook Github Bot 5
parent f8cbd9f4f4
commit 0e50373b60
36 changed files with 72 additions and 72 deletions

View File

@ -14,6 +14,10 @@ import com.facebook.soloader.SoLoader;
@DoNotStrip @DoNotStrip
public class JSCJavaScriptExecutor extends JavaScriptExecutor { public class JSCJavaScriptExecutor extends JavaScriptExecutor {
static {
ReactBridge.staticInit();
}
public static class Factory implements JavaScriptExecutor.Factory { public static class Factory implements JavaScriptExecutor.Factory {
@Override @Override
public JavaScriptExecutor create(WritableNativeMap jscConfig) throws Exception { 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) { public JSCJavaScriptExecutor(WritableNativeMap jscConfig) {
initialize(jscConfig); initialize(jscConfig);
} }

View File

@ -19,7 +19,7 @@ import com.facebook.soloader.SoLoader;
@DoNotStrip @DoNotStrip
public abstract class NativeArray { public abstract class NativeArray {
static { static {
SoLoader.loadLibrary(ReactBridge.REACT_NATIVE_LIB); ReactBridge.staticInit();
} }
protected NativeArray(HybridData hybridData) { protected NativeArray(HybridData hybridData) {

View File

@ -19,7 +19,7 @@ import com.facebook.soloader.SoLoader;
@DoNotStrip @DoNotStrip
public abstract class NativeMap { public abstract class NativeMap {
static { static {
SoLoader.loadLibrary(ReactBridge.REACT_NATIVE_LIB); ReactBridge.staticInit();
} }
public NativeMap(HybridData hybridData) { public NativeMap(HybridData hybridData) {

View File

@ -24,6 +24,10 @@ import com.facebook.proguard.annotations.DoNotStrip;
*/ */
@DoNotStrip @DoNotStrip
public class ProxyJavaScriptExecutor extends JavaScriptExecutor { public class ProxyJavaScriptExecutor extends JavaScriptExecutor {
static {
ReactBridge.staticInit();
}
public static class Factory implements JavaScriptExecutor.Factory { public static class Factory implements JavaScriptExecutor.Factory {
private final JavaJSExecutor.Factory mJavaJSExecutorFactory; 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; private @Nullable JavaJSExecutor mJavaJSExecutor;
/** /**

View File

@ -24,16 +24,22 @@ import com.facebook.soloader.SoLoader;
@DoNotStrip @DoNotStrip
public class ReactBridge extends Countable { 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 { static {
SoLoader.loadLibrary(REACT_NATIVE_LIB); staticInit();
} }
private final ReactCallback mCallback; private final ReactCallback mCallback;
private final JavaScriptExecutor mJSExecutor; private final JavaScriptExecutor mJSExecutor;
private final MessageQueueThread mNativeModulesQueueThread; private final MessageQueueThread mNativeModulesQueueThread;
public static void staticInit() {
SoLoader.loadLibrary(REACT_NATIVE_LIB);
SoLoader.loadLibrary(XREACT_NATIVE_LIB);
}
/** /**
* @param jsExecutor the JS executor to use to run JS * @param jsExecutor the JS executor to use to run JS
* @param callback the callback class used to invoke native modules * @param callback the callback class used to invoke native modules

View File

@ -21,9 +21,8 @@ import java.util.ArrayList;
*/ */
@DoNotStrip @DoNotStrip
public class ReadableNativeArray extends NativeArray implements ReadableArray { public class ReadableNativeArray extends NativeArray implements ReadableArray {
static { static {
SoLoader.loadLibrary(ReactBridge.REACT_NATIVE_LIB); ReactBridge.staticInit();
} }
protected ReadableNativeArray(HybridData hybridData) { protected ReadableNativeArray(HybridData hybridData) {

View File

@ -22,9 +22,8 @@ import java.util.HashMap;
*/ */
@DoNotStrip @DoNotStrip
public class ReadableNativeMap extends NativeMap implements ReadableMap { public class ReadableNativeMap extends NativeMap implements ReadableMap {
static { static {
SoLoader.loadLibrary(ReactBridge.REACT_NATIVE_LIB); ReactBridge.staticInit();
} }
protected ReadableNativeMap(HybridData hybridData) { protected ReadableNativeMap(HybridData hybridData) {

View File

@ -21,9 +21,8 @@ import com.facebook.soloader.SoLoader;
*/ */
@DoNotStrip @DoNotStrip
public class WritableNativeArray extends ReadableNativeArray implements WritableArray { public class WritableNativeArray extends ReadableNativeArray implements WritableArray {
static { static {
SoLoader.loadLibrary(ReactBridge.REACT_NATIVE_LIB); ReactBridge.staticInit();
} }
public WritableNativeArray() { public WritableNativeArray() {

View File

@ -22,7 +22,7 @@ import com.facebook.soloader.SoLoader;
@DoNotStrip @DoNotStrip
public class WritableNativeMap extends ReadableNativeMap implements WritableMap { public class WritableNativeMap extends ReadableNativeMap implements WritableMap {
static { static {
SoLoader.loadLibrary(ReactBridge.REACT_NATIVE_LIB); ReactBridge.staticInit();
} }
@Override @Override

View File

@ -11,15 +11,8 @@ LOCAL_SRC_FILES := \
JSLoader.cpp \ JSLoader.cpp \
JSLogging.cpp \ JSLogging.cpp \
JniJSModulesUnbundle.cpp \ JniJSModulesUnbundle.cpp \
NativeArray.cpp \
NativeCommon.cpp \
NativeMap.cpp \
OnLoad.cpp \ OnLoad.cpp \
ProxyExecutor.cpp \ ProxyExecutor.cpp \
ReadableNativeArray.cpp \
ReadableNativeMap.cpp \
WritableNativeArray.cpp \
WritableNativeMap.cpp \
LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../.. $(LOCAL_PATH)/.. LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../.. $(LOCAL_PATH)/..
@ -30,7 +23,7 @@ LOCAL_CFLAGS += $(CXX11_FLAGS)
LOCAL_EXPORT_CPPFLAGS := $(CXX11_FLAGS) LOCAL_EXPORT_CPPFLAGS := $(CXX11_FLAGS)
LOCAL_LDLIBS += -landroid 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 LOCAL_STATIC_LIBRARIES := libreactnative
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
@ -41,3 +34,4 @@ $(call import-module,folly)
$(call import-module,fbgloginit) $(call import-module,fbgloginit)
$(call import-module,fb) $(call import-module,fb)
$(call import-module,jsc) $(call import-module,jsc)
$(call import-module,xreact/jni)

View File

@ -18,6 +18,7 @@ def jni_library(**kwargs):
], ],
deps = DEPS + JSC_DEPS + [ deps = DEPS + JSC_DEPS + [
react_native_target('jni/react:react'), react_native_target('jni/react:react'),
react_native_target('jni/xreact/jni:jni'),
], ],
**kwargs **kwargs
) )
@ -33,15 +34,8 @@ jni_library(
'JSLoader.cpp', 'JSLoader.cpp',
'JSLogging.cpp', 'JSLogging.cpp',
'JniJSModulesUnbundle.cpp', 'JniJSModulesUnbundle.cpp',
'NativeArray.cpp',
'NativeCommon.cpp',
'NativeMap.cpp',
'OnLoad.cpp', 'OnLoad.cpp',
'ProxyExecutor.cpp', 'ProxyExecutor.cpp',
'ReadableNativeArray.cpp',
'ReadableNativeMap.cpp',
'WritableNativeArray.cpp',
'WritableNativeMap.cpp',
], ],
headers = [ headers = [
'JSLoader.h', 'JSLoader.h',
@ -56,13 +50,6 @@ jni_library(
'WebWorkers.h', 'WebWorkers.h',
], ],
exported_headers = [ exported_headers = [
'NativeCommon.h',
'NativeArray.h',
'NativeMap.h',
'ReadableNativeArray.h',
'ReadableNativeMap.h',
'WritableNativeArray.h',
'WritableNativeMap.h',
], ],
preprocessor_flags = [ preprocessor_flags = [
'-DLOG_TAG="ReactNativeJNI"', '-DLOG_TAG="ReactNativeJNI"',

View File

@ -22,8 +22,6 @@
#include "JExecutorTokenFactory.h" #include "JExecutorTokenFactory.h"
#include "JNativeRunnable.h" #include "JNativeRunnable.h"
#include "JSLoader.h" #include "JSLoader.h"
#include "NativeCommon.h"
#include "ReadableNativeArray.h"
#include "ProxyExecutor.h" #include "ProxyExecutor.h"
#include "OnLoad.h" #include "OnLoad.h"
#include "JMessageQueueThread.h" #include "JMessageQueueThread.h"
@ -31,7 +29,9 @@
#include "JSLogging.h" #include "JSLogging.h"
#include "JSCPerfLogging.h" #include "JSCPerfLogging.h"
#include "WebWorkers.h" #include "WebWorkers.h"
#include "WritableNativeMap.h"
#include <xreact/jni/ReadableNativeArray.h>
#include <xreact/jni/WritableNativeMap.h>
#include <algorithm> #include <algorithm>
#ifdef WITH_FBSYSTRACE #ifdef WITH_FBSYSTRACE
@ -456,17 +456,9 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
PerfLogging::installNativeHooks = addNativePerfLoggingHooks; PerfLogging::installNativeHooks = addNativePerfLoggingHooks;
JSLogging::nativeHook = nativeLoggingHook; JSLogging::nativeHook = nativeLoggingHook;
NativeArray::registerNatives();
ReadableNativeArray::registerNatives();
WritableNativeArray::registerNatives();
JNativeRunnable::registerNatives(); JNativeRunnable::registerNatives();
registerJSLoaderNatives(); registerJSLoaderNatives();
NativeMap::registerNatives();
ReadableNativeMap::registerNatives();
WritableNativeMap::registerNatives();
ReadableNativeMapKeySetIterator::registerNatives();
registerNatives("com/facebook/react/bridge/JSCJavaScriptExecutor", { registerNatives("com/facebook/react/bridge/JSCJavaScriptExecutor", {
makeNativeMethod("initialize", executors::createJSCExecutor), makeNativeMethod("initialize", executors::createJSCExecutor),
}); });

View File

@ -9,14 +9,21 @@ LOCAL_SRC_FILES := \
CxxModuleWrapper.cpp \ CxxModuleWrapper.cpp \
JExecutorToken.cpp \ JExecutorToken.cpp \
JMessageQueueThread.cpp \ JMessageQueueThread.cpp \
JniJSModulesUnbundle.cpp \
JSCPerfLogging.cpp \ JSCPerfLogging.cpp \
JSLoader.cpp \ JSLoader.cpp \
JSLogging.cpp \ JSLogging.cpp \
JniJSModulesUnbundle.cpp \
MethodInvoker.cpp \ MethodInvoker.cpp \
ModuleRegistryHolder.cpp \ ModuleRegistryHolder.cpp \
NativeArray.cpp \
NativeCommon.cpp \
NativeMap.cpp \
OnLoad.cpp \ OnLoad.cpp \
ProxyExecutor.cpp \ ProxyExecutor.cpp \
ReadableNativeArray.cpp \
ReadableNativeMap.cpp \
WritableNativeArray.cpp \
WritableNativeMap.cpp \
LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../.. LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../..
@ -27,7 +34,7 @@ LOCAL_CFLAGS += $(CXX11_FLAGS)
LOCAL_EXPORT_CPPFLAGS := $(CXX11_FLAGS) LOCAL_EXPORT_CPPFLAGS := $(CXX11_FLAGS)
LOCAL_LDLIBS += -landroid 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 LOCAL_STATIC_LIBRARIES := libreactnativefb
include $(BUILD_SHARED_LIBRARY) include $(BUILD_SHARED_LIBRARY)
@ -37,4 +44,3 @@ $(call import-module,jsc)
$(call import-module,folly) $(call import-module,folly)
$(call import-module,fbgloginit) $(call import-module,fbgloginit)
$(call import-module,jsc) $(call import-module,jsc)
$(call import-module,react/jni)

View File

@ -5,19 +5,25 @@ SUPPORTED_PLATFORMS = '^android-(armv7|x86)$'
EXPORTED_HEADERS = [ EXPORTED_HEADERS = [
'CxxModuleWrapper.h', 'CxxModuleWrapper.h',
'NativeArray.h',
'NativeCommon.h',
'NativeMap.h',
'ReadableNativeArray.h',
'ReadableNativeMap.h',
'WritableNativeArray.h',
'WritableNativeMap.h',
] ]
cxx_library( cxx_library(
name='jni', name='jni',
soname = 'libreactnativejnifb.so', soname = 'libreactnativejnifb.so',
header_namespace = 'react/jni', header_namespace = 'xreact/jni',
supported_platforms_regex = SUPPORTED_PLATFORMS, supported_platforms_regex = SUPPORTED_PLATFORMS,
deps = JSC_DEPS + [ deps = JSC_DEPS + [
'//native/fb:fb', '//native/fb:fb',
'//native/third-party/android-ndk:android', '//native/third-party/android-ndk:android',
'//xplat/folly:molly', '//xplat/folly:molly',
'//xplat/fbsystrace:fbsystrace', '//xplat/fbsystrace:fbsystrace',
react_native_target('jni/react/jni:jni'),
react_native_xplat_target('cxxreact:bridge'), react_native_xplat_target('cxxreact:bridge'),
react_native_xplat_target('cxxreact:module'), react_native_xplat_target('cxxreact:module'),
], ],

View File

@ -13,8 +13,6 @@
#include <jni/Countable.h> #include <jni/Countable.h>
#include <jni/LocalReference.h> #include <jni/LocalReference.h>
#include <react/jni/NativeArray.h>
#include <cxxreact/Instance.h> #include <cxxreact/Instance.h>
#include <cxxreact/MethodCall.h> #include <cxxreact/MethodCall.h>
#include <cxxreact/ModuleRegistry.h> #include <cxxreact/ModuleRegistry.h>
@ -23,6 +21,7 @@
#include "JavaScriptExecutorHolder.h" #include "JavaScriptExecutorHolder.h"
#include "JniJSModulesUnbundle.h" #include "JniJSModulesUnbundle.h"
#include "ModuleRegistryHolder.h" #include "ModuleRegistryHolder.h"
#include "NativeArray.h"
#include "JNativeRunnable.h" #include "JNativeRunnable.h"
using namespace facebook::jni; using namespace facebook::jni;

View File

@ -2,16 +2,11 @@
#include "CxxModuleWrapper.h" #include "CxxModuleWrapper.h"
#include <react/jni/ReadableNativeArray.h>
#include <fb/fbjni.h> #include <fb/fbjni.h>
#include <fb/Environment.h> #include <fb/Environment.h>
#include <jni/LocalString.h> #include <jni/LocalString.h>
#include <jni/Registration.h> #include <jni/Registration.h>
#include <cxxreact/JsArgumentHelpers.h>
#include <cxxreact/FollySupport.h>
#include <android/log.h> #include <android/log.h>
#include <folly/json.h> #include <folly/json.h>
@ -20,6 +15,12 @@
#include <unordered_set> #include <unordered_set>
#include <dlfcn.h> #include <dlfcn.h>
#include <cxxreact/JsArgumentHelpers.h>
#include <cxxreact/FollySupport.h>
#include "ReadableNativeArray.h"
using namespace facebook::jni; using namespace facebook::jni;
using namespace facebook::xplat::module; using namespace facebook::xplat::module;
using namespace facebook::react; using namespace facebook::react;

View File

@ -7,7 +7,7 @@
#include <folly/dynamic.h> #include <folly/dynamic.h>
#include <fb/fbjni.h> #include <fb/fbjni.h>
#include <react/jni/NativeArray.h> #include "NativeArray.h"
namespace facebook { namespace facebook {
namespace react { namespace react {

View File

@ -2,9 +2,10 @@
#include "JSCPerfLogging.h" #include "JSCPerfLogging.h"
#include <cxxreact/JSCHelpers.h>
#include <fb/log.h> #include <fb/log.h>
#include <fb/fbjni.h> #include <fb/fbjni.h>
#include <react/JSCHelpers.h>
using namespace facebook::jni; using namespace facebook::jni;

View File

@ -4,9 +4,10 @@
#include <android/log.h> #include <android/log.h>
#include <algorithm> #include <algorithm>
#include <react/Value.h>
#include <fb/log.h> #include <fb/log.h>
#include <cxxreact/Value.h>
namespace facebook { namespace facebook {
namespace react { namespace react {

View File

@ -2,7 +2,6 @@
#include "MethodInvoker.h" #include "MethodInvoker.h"
#include <react/jni/ReadableNativeArray.h>
#ifdef WITH_FBSYSTRACE #ifdef WITH_FBSYSTRACE
#include <fbsystrace.h> #include <fbsystrace.h>
#endif #endif
@ -10,6 +9,7 @@
#include "ModuleRegistryHolder.h" #include "ModuleRegistryHolder.h"
#include "JCallback.h" #include "JCallback.h"
#include "JExecutorToken.h" #include "JExecutorToken.h"
#include "ReadableNativeArray.h"
namespace facebook { namespace facebook {
namespace react { namespace react {

View File

@ -10,11 +10,10 @@
#include <cxxreact/Instance.h> #include <cxxreact/Instance.h>
#include <cxxreact/JsArgumentHelpers.h> #include <cxxreact/JsArgumentHelpers.h>
#include <cxxreact/NativeModule.h> #include <cxxreact/NativeModule.h>
#include <react/jni/ReadableNativeArray.h>
#include "MethodInvoker.h"
#include "CatalystInstanceImpl.h" #include "CatalystInstanceImpl.h"
#include "MethodInvoker.h"
#include "ReadableNativeArray.h"
using facebook::xplat::module::CxxModule; using facebook::xplat::module::CxxModule;

View File

@ -7,7 +7,6 @@
#include <cxxreact/JSCExecutor.h> #include <cxxreact/JSCExecutor.h>
#include <cxxreact/Platform.h> #include <cxxreact/Platform.h>
#include <cxxreact/Value.h> #include <cxxreact/Value.h>
#include <react/jni/ReadableNativeArray.h>
#include "CatalystInstanceImpl.h" #include "CatalystInstanceImpl.h"
#include "JavaScriptExecutorHolder.h" #include "JavaScriptExecutorHolder.h"
#include "JSCPerfLogging.h" #include "JSCPerfLogging.h"
@ -17,6 +16,9 @@
#include "WebWorkers.h" #include "WebWorkers.h"
#include "JCallback.h" #include "JCallback.h"
#include "WritableNativeMap.h"
#include "WritableNativeArray.h"
#include <string> #include <string>
using namespace facebook::jni; using namespace facebook::jni;
@ -180,6 +182,14 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
CxxModuleWrapper::registerNatives(); CxxModuleWrapper::registerNatives();
JCallbackImpl::registerNatives(); JCallbackImpl::registerNatives();
registerJSLoaderNatives(); registerJSLoaderNatives();
NativeArray::registerNatives();
ReadableNativeArray::registerNatives();
WritableNativeArray::registerNatives();
NativeMap::registerNatives();
ReadableNativeMap::registerNatives();
WritableNativeMap::registerNatives();
ReadableNativeMapKeySetIterator::registerNatives();
}); });
} }

View File

@ -20,6 +20,7 @@ struct WritableNativeMap : jni::HybridClass<WritableNativeMap, ReadableNativeMap
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jclass>); static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jclass>);
__attribute__((visibility("default")))
folly::dynamic consume(); folly::dynamic consume();
void putNull(std::string key); void putNull(std::string key);