Make custom jsc initialization a link-time replacable function.
Reviewed By: bnham Differential Revision: D3880106 fbshipit-source-id: 2a3c3c8ff120ecc66b31325700c187cbd957f361
This commit is contained in:
parent
fe84362a90
commit
bb933c8ad4
|
@ -49,3 +49,13 @@ typedef struct RCTJSCWrapper {
|
|||
|
||||
RCT_EXTERN RCTJSCWrapper *RCTJSCWrapperCreate(BOOL useCustomJSC);
|
||||
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>
|
||||
|
||||
#if HAS_FBGLOG
|
||||
#import <FBGLog/FBGLogSink.h>
|
||||
|
||||
typedef void (*configureJSCLoggingForIOSFuncType)(int32_t, std::unique_ptr<google::LogSink>, void (*)());
|
||||
#endif
|
||||
void __attribute__((visibility("hidden"),weak)) RCTCustomJSCInit(void *handle) {
|
||||
return;
|
||||
}
|
||||
|
||||
static void *RCTCustomLibraryHandler(void)
|
||||
{
|
||||
|
@ -89,17 +88,10 @@ static void RCTSetUpCustomLibraryPointers(RCTJSCWrapper *wrapper)
|
|||
wrapper->JSValue = (__bridge Class)dlsym(libraryHandle, "OBJC_CLASS_$_JSValue");
|
||||
wrapper->configureJSContextForIOS = (configureJSContextForIOSFuncType)dlsym(libraryHandle, "configureJSContextForIOS");
|
||||
|
||||
#if HAS_FBGLOG
|
||||
static dispatch_once_t once;
|
||||
dispatch_once(&once, ^{
|
||||
void *handle = dlsym(libraryHandle, "configureJSCLoggingForIOS");
|
||||
|
||||
if (handle) {
|
||||
configureJSCLoggingForIOSFuncType logConfigFunc = (configureJSCLoggingForIOSFuncType)handle;
|
||||
logConfigFunc(google::GLOG_INFO, FBGLogSink(), FBGLogFailureFunction);
|
||||
}
|
||||
RCTCustomJSCInit(libraryHandle);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
RCTJSCWrapper *RCTJSCWrapperCreate(BOOL useCustomJSC)
|
||||
|
|
Loading…
Reference in New Issue