Make custom jsc initialization a link-time replacable function.
Reviewed By: bnham Differential Revision: D3880106 fbshipit-source-id: 2a3c3c8ff120ecc66b31325700c187cbd957f361
This commit is contained in:
Родитель
fe84362a90
Коммит
bb933c8ad4
|
@ -49,3 +49,13 @@ typedef struct RCTJSCWrapper {
|
||||||
|
|
||||||
RCT_EXTERN RCTJSCWrapper *RCTJSCWrapperCreate(BOOL useCustomJSC);
|
RCT_EXTERN RCTJSCWrapper *RCTJSCWrapperCreate(BOOL useCustomJSC);
|
||||||
RCT_EXTERN void RCTJSCWrapperRelease(RCTJSCWrapper *wrapper);
|
RCT_EXTERN void RCTJSCWrapperRelease(RCTJSCWrapper *wrapper);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Link time overridable initialization function to execute custom
|
||||||
|
* initialization code when loading custom JSC.
|
||||||
|
*
|
||||||
|
* By default it does nothing.
|
||||||
|
*
|
||||||
|
* @param handle to the dlopen'd JSC library.
|
||||||
|
*/
|
||||||
|
void __attribute__((visibility("hidden"))) RCTCustomJSCInit(void *handle);
|
||||||
|
|
|
@ -16,11 +16,10 @@
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
#if HAS_FBGLOG
|
|
||||||
#import <FBGLog/FBGLogSink.h>
|
|
||||||
|
|
||||||
typedef void (*configureJSCLoggingForIOSFuncType)(int32_t, std::unique_ptr<google::LogSink>, void (*)());
|
void __attribute__((visibility("hidden"),weak)) RCTCustomJSCInit(void *handle) {
|
||||||
#endif
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static void *RCTCustomLibraryHandler(void)
|
static void *RCTCustomLibraryHandler(void)
|
||||||
{
|
{
|
||||||
|
@ -89,17 +88,10 @@ static void RCTSetUpCustomLibraryPointers(RCTJSCWrapper *wrapper)
|
||||||
wrapper->JSValue = (__bridge Class)dlsym(libraryHandle, "OBJC_CLASS_$_JSValue");
|
wrapper->JSValue = (__bridge Class)dlsym(libraryHandle, "OBJC_CLASS_$_JSValue");
|
||||||
wrapper->configureJSContextForIOS = (configureJSContextForIOSFuncType)dlsym(libraryHandle, "configureJSContextForIOS");
|
wrapper->configureJSContextForIOS = (configureJSContextForIOSFuncType)dlsym(libraryHandle, "configureJSContextForIOS");
|
||||||
|
|
||||||
#if HAS_FBGLOG
|
|
||||||
static dispatch_once_t once;
|
static dispatch_once_t once;
|
||||||
dispatch_once(&once, ^{
|
dispatch_once(&once, ^{
|
||||||
void *handle = dlsym(libraryHandle, "configureJSCLoggingForIOS");
|
RCTCustomJSCInit(libraryHandle);
|
||||||
|
|
||||||
if (handle) {
|
|
||||||
configureJSCLoggingForIOSFuncType logConfigFunc = (configureJSCLoggingForIOSFuncType)handle;
|
|
||||||
logConfigFunc(google::GLOG_INFO, FBGLogSink(), FBGLogFailureFunction);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RCTJSCWrapper *RCTJSCWrapperCreate(BOOL useCustomJSC)
|
RCTJSCWrapper *RCTJSCWrapperCreate(BOOL useCustomJSC)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче