Skip to content

Commit

Permalink
cxxreact: executors: insert ID of segment reliably into the bundle path
Browse files Browse the repository at this point in the history
Reviewed By: fromcelticpark

Differential Revision: D7623232

fbshipit-source-id: df833d18f0445d52e3098b58aac347a2e9aa0040
  • Loading branch information
Jean Lauliac authored and facebook-github-bot committed Apr 20, 2018
1 parent 2e7dfd5 commit 5fd92f9
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 3 deletions.
4 changes: 4 additions & 0 deletions React/React.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,7 @@
CF2731C11E7B8DE40044CA4F /* RCTDeviceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = CF2731BF1E7B8DE40044CA4F /* RCTDeviceInfo.m */; };
CF2731C21E7B8DEF0044CA4F /* RCTDeviceInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = CF2731BE1E7B8DE40044CA4F /* RCTDeviceInfo.h */; };
CF2731C31E7B8DF30044CA4F /* RCTDeviceInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = CF2731BF1E7B8DE40044CA4F /* RCTDeviceInfo.m */; };
E223624420875A8000108244 /* JSExecutor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E223624320875A8000108244 /* JSExecutor.cpp */; };
E9B20B7B1B500126007A2DA7 /* RCTAccessibilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E9B20B7A1B500126007A2DA7 /* RCTAccessibilityManager.m */; };
EBF21BBC1FC498270052F4D5 /* InspectorInterfaces.h in Headers */ = {isa = PBXBuildFile; fileRef = EBF21BBA1FC498270052F4D5 /* InspectorInterfaces.h */; };
EBF21BBD1FC498270052F4D5 /* InspectorInterfaces.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EBF21BBB1FC498270052F4D5 /* InspectorInterfaces.cpp */; };
Expand Down Expand Up @@ -2305,6 +2306,7 @@
C6D380191F71D75B00621378 /* RAMBundleRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RAMBundleRegistry.cpp; sourceTree = "<group>"; };
CF2731BE1E7B8DE40044CA4F /* RCTDeviceInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDeviceInfo.h; sourceTree = "<group>"; };
CF2731BF1E7B8DE40044CA4F /* RCTDeviceInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDeviceInfo.m; sourceTree = "<group>"; };
E223624320875A8000108244 /* JSExecutor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSExecutor.cpp; sourceTree = "<group>"; };
E3BBC8EB1ADE6F47001BBD81 /* RCTTextDecorationLineType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTTextDecorationLineType.h; sourceTree = "<group>"; };
E9B20B791B500126007A2DA7 /* RCTAccessibilityManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAccessibilityManager.h; sourceTree = "<group>"; };
E9B20B7A1B500126007A2DA7 /* RCTAccessibilityManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTAccessibilityManager.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3034,6 +3036,7 @@
AC70D2EA1DE489FC002E6351 /* cxxreact */ = {
isa = PBXGroup;
children = (
E223624320875A8000108244 /* JSExecutor.cpp */,
3D92B0A71E03699D0018521A /* CxxModule.h */,
3D92B0A81E03699D0018521A /* CxxNativeModule.cpp */,
3D92B0A91E03699D0018521A /* CxxNativeModule.h */,
Expand Down Expand Up @@ -4440,6 +4443,7 @@
buildActionMask = 2147483647;
files = (
13134C9A1E296B2A00B9F3CB /* RCTCxxMethod.mm in Sources */,
E223624420875A8000108244 /* JSExecutor.cpp in Sources */,
59500D451F71C63F00B122B7 /* RCTUIManagerUtils.m in Sources */,
597633361F4E021D005BE8A4 /* RCTShadowView+Internal.m in Sources */,
13723B501A82FD3C00F88898 /* RCTStatusBarManager.m in Sources */,
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/cxxreact/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ LOCAL_SRC_FILES := \
JSCSamplingProfiler.cpp \
JSCTracing.cpp \
JSCUtils.cpp \
JSExecutor.cpp \
JSIndexedRAMBundle.cpp \
MethodCall.cpp \
ModuleRegistry.cpp \
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/cxxreact/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ CXXREACT_PUBLIC_HEADERS = [
"JSExecutor.h",
"JSCExecutor.h",
"JSCNativeModules.h",
"JSCUtils.h",
"JSIndexedRAMBundle.h",
"JSModulesUnbundle.h",
"MessageQueueThread.h",
Expand Down
9 changes: 6 additions & 3 deletions ReactCommon/cxxreact/JSCExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,16 @@ namespace facebook {
m_bundleRegistry = std::move(bundleRegistry);
}

void JSCExecutor::registerBundle(uint32_t bundleId, const std::string& bundlePath) {
void JSCExecutor::registerBundle(
uint32_t bundleId,
const std::string& bundlePath) {
if (m_bundleRegistry) {
m_bundleRegistry->registerBundle(bundleId, bundlePath);
} else {
auto sourceUrl = String(m_context, bundlePath.c_str());
auto stPath = JSCExecutor::getSyntheticBundlePath(bundleId, bundlePath);
auto sourceUrlStr = String(m_context, stPath.c_str());
auto source = adoptString(JSBigFileString::fromPath(bundlePath));
evaluateScript(m_context, source, sourceUrl);
evaluateScript(m_context, source, sourceUrlStr);
}
}

Expand Down
2 changes: 2 additions & 0 deletions ReactCommon/cxxreact/JSCUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "JSCUtils.h"

#include "RAMBundleRegistry.h"

#include <folly/Conv.h>

namespace facebook {
Expand Down
22 changes: 22 additions & 0 deletions ReactCommon/cxxreact/JSExecutor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2004-present Facebook. All Rights Reserved.

#include "JSExecutor.h"

#include "RAMBundleRegistry.h"

#include <folly/Conv.h>

namespace facebook {
namespace react {

std::string JSExecutor::getSyntheticBundlePath(
uint32_t bundleId,
const std::string& bundlePath) {
if (bundleId == RAMBundleRegistry::MAIN_BUNDLE_ID) {
return bundlePath;
}
return folly::to<std::string>("seg-", bundleId, ".js");
}

}
}
4 changes: 4 additions & 0 deletions ReactCommon/cxxreact/JSExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ class JSExecutor {

virtual void destroy() {}
virtual ~JSExecutor() {}

static std::string getSyntheticBundlePath(
uint32_t bundleId,
const std::string& bundlePath);
};

} }

0 comments on commit 5fd92f9

Please sign in to comment.