Skip to content

Commit

Permalink
Merge pull request #35510 from facebook/nc/71rc3-pick-requests
Browse files Browse the repository at this point in the history
  • Loading branch information
kelset authored Nov 30, 2022
2 parents 38465f2 + e108e9e commit 4ba52ac
Show file tree
Hide file tree
Showing 38 changed files with 449 additions and 261 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ buck-out
.gradle
local.properties
*.iml
/android/
/android/*
!/android/README.md

# Node
node_modules
Expand Down
2 changes: 1 addition & 1 deletion BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ rn_xplat_cxx_library2(
react_native_root_target("React/CoreModules:CoreModules"),
react_native_xplat_target("cxxreact:bridge"),
react_native_xplat_target("cxxreact:jsbigstring"),
react_native_xplat_target("jsi:JSCRuntime"),
react_native_xplat_target("jsc:JSCRuntime"),
react_native_xplat_target("jsiexecutor:jsiexecutor"),
react_native_xplat_target("reactperflogger:reactperflogger"),
],
Expand Down
2 changes: 1 addition & 1 deletion React/CxxBridge/JSCExecutorFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "JSCExecutorFactory.h"

#import <jsi/JSCRuntime.h>
#import <jsc/JSCRuntime.h>

#import <memory>

Expand Down
76 changes: 55 additions & 21 deletions ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ final def preparePrefab = tasks.register("preparePrefab", PreparePrefabHeadersTa
new Pair(new File(buildDir, "third-party-ndk/boost/boost_1_76_0/").absolutePath, ""),
new Pair(new File(buildDir, "third-party-ndk/double-conversion/").absolutePath, ""),
new Pair(new File(buildDir, "third-party-ndk/folly/").absolutePath, ""),
new Pair(new File(buildDir, "third-party-ndk/glog/exported/").absolutePath, ""),
new Pair("../ReactCommon/butter/", "butter/"),
new Pair("../ReactCommon/callinvoker/", ""),
new Pair("../ReactCommon/react/bridging/", "react/bridging/"),
Expand All @@ -152,13 +153,16 @@ final def preparePrefab = tasks.register("preparePrefab", PreparePrefabHeadersTa
new Pair("../ReactCommon/react/nativemodule/core/platform/android/", ""),
new Pair("../ReactCommon/react/renderer/componentregistry/", "react/renderer/componentregistry/"),
new Pair("../ReactCommon/react/renderer/components/root/", "react/renderer/components/root/"),
new Pair("../ReactCommon/react/renderer/core/", "react/renderer/core/"),
new Pair("../ReactCommon/react/renderer/debug/", "react/renderer/debug/"),
new Pair("../ReactCommon/react/renderer/leakchecker/", "react/renderer/leakchecker/"),
new Pair("../ReactCommon/react/renderer/mapbuffer/", "react/renderer/mapbuffer/"),
new Pair("../ReactCommon/react/renderer/mounting/", "react/renderer/mounting/"),
new Pair("../ReactCommon/react/renderer/runtimescheduler/", "react/renderer/runtimescheduler/"),
new Pair("../ReactCommon/react/renderer/scheduler/", "react/renderer/scheduler/"),
new Pair("../ReactCommon/react/renderer/telemetry/", "react/renderer/telemetry/"),
new Pair("../ReactCommon/react/renderer/uimanager/", "react/renderer/uimanager/"),
new Pair("../ReactCommon/react/debug/", "react/debug/"),
new Pair("../ReactCommon/react/utils/", "react/utils/"),
new Pair("src/main/jni/react/jni", "react/jni/"),
]
Expand All @@ -174,6 +178,35 @@ final def preparePrefab = tasks.register("preparePrefab", PreparePrefabHeadersTa
"rrc_image",
new Pair("../ReactCommon/react/renderer/components/image/", "react/renderer/components/image/")
),
// These prefab targets are used by Expo & Reanimated
new PrefabPreprocessingEntry(
"hermes_executor",
// "hermes_executor" is statically linking against "hermes_executor_common"
// and "hermes_inspector". Here we expose only the headers that we know are needed.
new Pair("../ReactCommon/hermes/inspector/", "hermes/inspector/")
),
new PrefabPreprocessingEntry(
"jscexecutor",
// "jscexecutor" is statically linking against "jscruntime"
// Here we expose only the headers that we know are needed.
new Pair("../ReactCommon/jsc/", "jsc/")
),
new PrefabPreprocessingEntry(
"react_render_uimanager",
new Pair("../ReactCommon/react/renderer/uimanager/", "react/renderer/uimanager/"),
),
new PrefabPreprocessingEntry(
"react_render_scheduler",
new Pair("../ReactCommon/react/renderer/scheduler/", "react/renderer/scheduler/"),
),
new PrefabPreprocessingEntry(
"react_render_mounting",
new Pair("../ReactCommon/react/renderer/mounting/", "react/renderer/mounting/"),
),
new PrefabPreprocessingEntry(
"reactnativejni",
new Pair("src/main/jni/react/jni", "react/jni/"),
),
]
)
it.outputDir.set(prefabHeadersDir)
Expand Down Expand Up @@ -402,12 +435,12 @@ android {
"-DANDROID_TOOLCHAIN=clang",
"-DANDROID_PLATFORM=android-21"

targets "reactnativejni",
"jscexecutor",
targets "jscexecutor",
"jsijniprofiler",
"reactnativeblob",
"reactperfloggerjni",
// prefab targets
"reactnativejni",
"react_render_debug",
"turbomodulejsijni",
"runtimeexecutor",
Expand All @@ -426,32 +459,18 @@ android {
"yoga",
"folly_runtime",
"react_nativemodule_core",
"react_render_imagemanager"
"react_render_imagemanager",
"react_render_uimanager",
"react_render_scheduler",
"react_render_mounting",
"hermes_executor"
}
}
ndk {
abiFilters(*reactNativeArchitectures())
}
}

buildTypes {
debug {
externalNativeBuild {
cmake {
targets "hermes-executor-debug"
}
}
}

release {
externalNativeBuild {
cmake {
targets "hermes-executor-release"
}
}
}
}

externalNativeBuild {
cmake {
path "src/main/jni/CMakeLists.txt"
Expand Down Expand Up @@ -549,6 +568,21 @@ android {
react_render_imagemanager {
headers(new File(prefabHeadersDir, "react_render_imagemanager").absolutePath)
}
react_render_uimanager {
headers(new File(prefabHeadersDir, "react_render_uimanager").absolutePath)
}
react_render_scheduler {
headers(new File(prefabHeadersDir, "react_render_scheduler").absolutePath)
}
react_render_mounting {
headers(new File(prefabHeadersDir, "react_render_mounting").absolutePath)
}
reactnativejni {
headers(new File(prefabHeadersDir, "reactnativejni").absolutePath)
}
hermes_executor {
headers(new File(prefabHeadersDir, "hermes_executor").absolutePath)
}
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ rn_android_library(
react_native_target("java/com/facebook/hermes/instrumentation:instrumentation"),
react_native_target("java/com/facebook/hermes/instrumentation:hermes_samplingprofiler"),
react_native_target("java/com/facebook/react/bridge:bridge"),
react_native_target("java/com/facebook/react/common:common"),
react_native_target("jni/react/hermes/reactexecutor:jni"),
":runtimeconfig",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.facebook.jni.HybridData;
import com.facebook.react.bridge.JavaScriptExecutor;
import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.soloader.SoLoader;
import javax.annotation.Nullable;

Expand All @@ -23,11 +24,11 @@ public static void loadLibrary() throws UnsatisfiedLinkError {
if (mode_ == null) {
// libhermes must be loaded explicitly to invoke its JNI_OnLoad.
SoLoader.loadLibrary("hermes");
try {
SoLoader.loadLibrary("hermes-executor-debug");
SoLoader.loadLibrary("hermes_executor");
// libhermes_executor is built differently for Debug & Release so we load the proper mode.
if (ReactBuildConfig.DEBUG == true) {
mode_ = "Debug";
} catch (UnsatisfiedLinkError e) {
SoLoader.loadLibrary("hermes-executor-release");
} else {
mode_ = "Release";
}
}
Expand Down
1 change: 1 addition & 0 deletions ReactAndroid/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ add_react_common_subdir(reactperflogger)
add_react_common_subdir(logger)
add_react_common_subdir(jsiexecutor)
add_react_common_subdir(cxxreact)
add_react_common_subdir(jsc)
add_react_common_subdir(jsi)
add_react_common_subdir(butter)
add_react_common_subdir(callinvoker)
Expand Down
2 changes: 1 addition & 1 deletion ReactAndroid/src/main/jni/react/hermes/reactexecutor/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ rn_xplat_cxx_library(
headers = [],
header_namespace = "",
compiler_flags = ["-fexceptions"],
soname = "libhermes-executor.$(ext)",
soname = "libhermes_executor.$(ext)",
visibility = ["PUBLIC"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,20 @@ set(CMAKE_VERBOSE_MAKEFILE on)

file(GLOB_RECURSE hermes_executor_SRC CONFIGURE_DEPENDS *.cpp)

if(${CMAKE_BUILD_TYPE} MATCHES Debug)
set(HERMES_TARGET_SUFFIX debug)
else()
set(HERMES_TARGET_SUFFIX release)
endif()

set(HERMES_TARGET_NAME hermes-executor-${HERMES_TARGET_SUFFIX})

add_library(
${HERMES_TARGET_NAME}
add_library(hermes_executor
SHARED
${hermes_executor_SRC}
)
target_compile_options(
${HERMES_TARGET_NAME}
hermes_executor
PRIVATE
$<$<CONFIG:Debug>:-DHERMES_ENABLE_DEBUGGER=1>
-fexceptions
)
target_include_directories(${HERMES_TARGET_NAME} PRIVATE .)
target_include_directories(hermes_executor PRIVATE .)
target_link_libraries(
${HERMES_TARGET_NAME}
hermes-executor-common
hermes_executor
hermes_executor_common
jsireact
fb
fbjni
Expand Down
2 changes: 1 addition & 1 deletion ReactAndroid/src/main/jni/react/jscexecutor/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rn_xplat_cxx_library(
deps = [
FBJNI_TARGET,
react_native_target("jni/react/jni:jni"),
react_native_xplat_target("jsi:JSCRuntime"),
react_native_xplat_target("jsc:JSCRuntime"),
react_native_xplat_target("jsiexecutor:jsiexecutor"),
],
)
2 changes: 1 addition & 1 deletion ReactAndroid/src/main/jni/react/jscexecutor/OnLoad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

#include <fbjni/fbjni.h>
#include <jsi/JSCRuntime.h>
#include <jsc/JSCRuntime.h>
#include <jsireact/JSIExecutor.h>
#include <react/jni/JReactMarker.h>
#include <react/jni/JSLogging.h>
Expand Down
11 changes: 6 additions & 5 deletions ReactCommon/hermes/executor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ set(CMAKE_VERBOSE_MAKEFILE on)

file(GLOB_RECURSE hermes_executor_SRC CONFIGURE_DEPENDS *.cpp)
add_library(
hermes-executor-common
hermes_executor_common
STATIC
${hermes_executor_SRC}
)
target_include_directories(hermes-executor-common PUBLIC .)
target_link_libraries(hermes-executor-common
target_include_directories(hermes_executor_common PUBLIC .)
target_link_libraries(hermes_executor_common
jsireact
hermes-engine::libhermes
jsi
debug hermes-inspector
debug
hermes_inspector
)

if(${CMAKE_BUILD_TYPE} MATCHES Debug)
target_compile_options(
hermes-executor-common
hermes_executor_common
PRIVATE
-DHERMES_ENABLE_DEBUGGER=1
)
Expand Down
8 changes: 4 additions & 4 deletions ReactCommon/hermes/inspector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ set(CMAKE_VERBOSE_MAKEFILE on)

file(GLOB hermesinspector_SRC CONFIGURE_DEPENDS *.cpp detail/*.cpp chrome/*.cpp)

add_library(hermes-inspector
add_library(hermes_inspector
STATIC
${hermesinspector_SRC})

target_compile_options(
hermes-inspector
hermes_inspector
PRIVATE
-DHERMES_ENABLE_DEBUGGER=1
-DHERMES_INSPECTOR_FOLLY_KLUDGE=1
-fexceptions
)

target_include_directories(hermes-inspector PUBLIC ${REACT_COMMON_DIR})
target_link_libraries(hermes-inspector
target_include_directories(hermes_inspector PUBLIC ${REACT_COMMON_DIR})
target_link_libraries(hermes_inspector
jsinspector
fb
fbjni
Expand Down
6 changes: 6 additions & 0 deletions ReactCommon/jsc/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
Checks: '>
clang-diagnostic-*,
'
InheritParentConfig: true
...
34 changes: 34 additions & 0 deletions ReactCommon/jsc/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("//tools/build_defs/oss:rn_defs.bzl", "APPLE", "IOS", "MACOSX", "get_apple_compiler_flags", "get_apple_inspector_flags", "get_preprocessor_flags_for_build_mode", "react_native_xplat_dep", "rn_xplat_cxx_library")

APPLE_COMPILER_FLAGS = get_apple_compiler_flags()

rn_xplat_cxx_library(
name = "JSCRuntime",
srcs = [
"JSCRuntime.cpp",
],
header_namespace = "jsc",
exported_headers = [
"JSCRuntime.h",
],
apple_sdks = (IOS, MACOSX),
compiler_flags_pedantic = True,
fbobjc_compiler_flags = APPLE_COMPILER_FLAGS + [
"-Os",
],
fbobjc_frameworks = [
"$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework",
],
fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
labels = [
"pfh:ReactNative_CommonInfrastructurePlaceholder",
],
platforms = APPLE,
visibility = ["PUBLIC"],
xplat_mangled_args = {
"soname": "libjscjsi.$(ext)",
},
exported_deps = [
react_native_xplat_dep("jsi:jsi"),
],
)
35 changes: 35 additions & 0 deletions ReactCommon/jsc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

##################
### jscruntime ###
##################

cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

add_compile_options(
-fexceptions
-frtti
-O3
-Wno-unused-lambda-capture
-DLOG_TAG=\"ReactNative\")

add_library(jscruntime
STATIC
JSCRuntime.h
JSCRuntime.cpp)

target_include_directories(jscruntime PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(jscruntime
folly_runtime
jsc
jsi
glog)

# TODO: Remove this flag when ready.
# Android has this enabled by default, but the flag is still needed for iOS.
target_compile_options(jscruntime PRIVATE -DRN_FABRIC_ENABLED)
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 4ba52ac

Please sign in to comment.