Skip to content

Commit

Permalink
Merge branch 'main' into cipolleschi/backport_hermes_logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo authored Nov 25, 2022
2 parents 37716fb + 1f8c0c8 commit fc5c8e1
Show file tree
Hide file tree
Showing 49 changed files with 440 additions and 323 deletions.
38 changes: 11 additions & 27 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -710,34 +710,19 @@ jobs:
- checkout
- setup_artifacts
- run_yarn

# Starting emulator in advance as it takes some time to boot.
- run:
name: Create Android Virtual Device
command: source scripts/android-setup.sh && createAVD
- run:
name: Launch Android Virtual Device in Background
command: source scripts/android-setup.sh && launchAVD
background: true

- download_gradle_dependencies

- run:
name: Build & Test React Native using Gradle
command: ./gradlew buildAll

- run:
name: Build RN Tester for Release using Gradle
command: ./gradlew packages:rn-tester:android:app:assembleRelease

# Wait for AVD to finish booting before running tests
- run:
name: Wait for Android Virtual Device
command: source scripts/android-setup.sh && waitForAVD

- report_bundle_size:
platform: android

- store_artifacts:
path: ~/react-native/packages/rn-tester/android/app/build/outputs/apk/
destination: rntester-apk

# Optionally, run disabled tests
- when:
condition: << parameters.run_disabled_tests >>
Expand Down Expand Up @@ -779,10 +764,7 @@ jobs:
command: |
REPO_ROOT=$(pwd)
node ./scripts/set-rn-template-version.js "file:$REPO_ROOT/build/$(cat build/react-native-package-version)"
node cli.js init $PROJECT_NAME --directory "/tmp/$PROJECT_NAME" --template $REPO_ROOT --verbose --skip-install
cd /tmp/$PROJECT_NAME
yarn
node ./scripts/template/initialize.js --reactNativeRootPath $REPO_ROOT --templateName $PROJECT_NAME --templateConfigPath $REPO_ROOT --directory "/tmp/$PROJECT_NAME"
- run:
name: Build the template application for << parameters.flavor >> with Architecture set to << parameters.architecture >>, and using the << parameters.jsengine>> JS engine.
command: |
Expand All @@ -799,6 +781,10 @@ jobs:
fi
./gradlew assemble<< parameters.flavor >> -PREACT_NATIVE_MAVEN_LOCAL_REPO=/root/react-native/maven-local
- store_artifacts:
path: /tmp/$PROJECT_NAME/android/app/build/outputs/apk/
destination: template-apk

# -------------------------
# JOBS: Test iOS Template
# -------------------------
Expand Down Expand Up @@ -862,13 +848,11 @@ jobs:
PACKAGE=$(cat build/react-native-package-version)
PATH_TO_PACKAGE="$REPO_ROOT/build/$PACKAGE"
node ./scripts/set-rn-template-version.js "file:$PATH_TO_PACKAGE"
node cli.js init $PROJECT_NAME --directory "/tmp/$PROJECT_NAME" --template $REPO_ROOT --verbose --skip-install
node ./scripts/template/initialize.js --reactNativeRootPath $REPO_ROOT --templateName $PROJECT_NAME --templateConfigPath $REPO_ROOT --directory "/tmp/$PROJECT_NAME"
- run:
name: Install iOS dependencies - Configuration << parameters.flavor >>; New Architecture << parameters.architecture >>; JS Engine << parameters.jsengine>>; Flipper << parameters.flipper >>
command: |
cd /tmp/$PROJECT_NAME
yarn install
cd ios
cd /tmp/$PROJECT_NAME/ios
bundle install
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ package-lock.json
/sdks/download
/sdks/hermes
/sdks/hermesc
/sdks/hermes-engine/build_host_hermesc

# Visual studio
.vscode
Expand Down
12 changes: 0 additions & 12 deletions Libraries/Animated/useAnimatedProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
): [ReducedProps<TProps>, CallbackRef<TInstance | null>] {
const [, scheduleUpdate] = useReducer<number, void>(count => count + 1, 0);
const onUpdateRef = useRef<?() => void>(null);
const cachedRef = useRef<TInstance | null>(null);

// TODO: Only invalidate `node` if animated props or `style` change. In the
// previous implementation, we permitted `style` to override props with the
Expand Down Expand Up @@ -65,7 +64,6 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
// NOTE: This may be called more often than necessary (e.g. when `props`
// changes), but `setNativeView` already optimizes for that.
node.setNativeView(instance);
cachedRef.current = instance;

// NOTE: This callback is only used by the JavaScript animation driver.
onUpdateRef.current = () => {
Expand Down Expand Up @@ -115,16 +113,6 @@ export default function useAnimatedProps<TProps: {...}, TInstance>(
);
const callbackRef = useRefEffect<TInstance>(refEffect);

useEffect(() => {
// Call `setNativeView` any time `node` changes to make sure
// `AnimatedProps._animatedView` is up to date.
// This would not be necessary in an ideal world.
// In React, anytime identity of function passed to `ref` changes,
// the old function is called with null and the new function is called with value.
// ScrollView does not behave like this and this workaround is necessary.
node.setNativeView(cachedRef.current);
}, [node]);

return [reduceAnimatedProps<TProps>(node), callbackRef];
}

Expand Down
2 changes: 1 addition & 1 deletion Libraries/BatchedBridge/MessageQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class MessageQueue {
});
warnOnce(
'excessive-number-of-pending-callbacks',
`Please report: Excessive number of pending callbacks: ${
`Excessive number of pending callbacks: ${
this._successCallbacks.size
}. Some pending callbacks that might have leaked by never being called from native code: ${stringifySafe(
info,
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Events/EventPolyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class EventPolyfill implements IEvent {
// data with the other in sync.
_syntheticEvent: mixed;

constructor(type: string, eventInitDict?: Event$Init): void {
constructor(type: string, eventInitDict?: Event$Init) {
this.type = type;
this.bubbles = !!(eventInitDict?.bubbles || false);
this.cancelable = !!(eventInitDict?.cancelable || false);
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Lists/FlatList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export interface FlatListProps<ItemT> extends VirtualizedListProps<ItemT> {
* _renderItem = ({item}) => (
* <TouchableOpacity onPress={() => this._onPress(item)}>
* <Text>{item.title}</Text>
* <TouchableOpacity/>
* </TouchableOpacity>
* );
* ...
* <FlatList data={[{title: 'Title Text', key: 'item1'}]} renderItem={this._renderItem} />
Expand Down
70 changes: 49 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,29 @@ final def preparePrefab = tasks.register("preparePrefab", PreparePrefabHeadersTa
"rrc_image",
new Pair("../ReactCommon/react/renderer/components/image/", "react/renderer/components/image/")
),
// This prefab target is used by Expo & Reanimated to load a new instance of Hermes
new PrefabPreprocessingEntry(
"hermes-executor",
// "hermes-executor" is statically linking agaisnt "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(
"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 +429,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 +453,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 +562,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
2 changes: 1 addition & 1 deletion ReactAndroid/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ endif(CCACHE_FOUND)

# Make sure every shared lib includes a .note.gnu.build-id header
add_link_options(-Wl,--build-id)
add_compile_options(-Wall -Werror -std=c++1y)
add_compile_options(-Wall -Werror -std=c++17)

function(add_react_android_subdir relative_path)
add_subdirectory(${REACT_ANDROID_DIR}/${relative_path} ReactAndroid/${relative_path})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +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>
-std=c++17
-fexceptions
)
target_include_directories(${HERMES_TARGET_NAME} PRIVATE .)
target_include_directories(hermes-executor PRIVATE .)
target_link_libraries(
${HERMES_TARGET_NAME}
hermes-executor
hermes-executor-common
jsireact
fb
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/cxxreact/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set(CMAKE_VERBOSE_MAKEFILE on)
add_compile_options(
-fexceptions
-frtti
-std=c++17
-Wno-unused-lambda-capture
-DLOG_TAG=\"ReactNative\")

Expand Down
3 changes: 2 additions & 1 deletion ReactCommon/cxxreact/React-cxxreact.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Pod::Spec.new do |s|
s.source_files = "*.{cpp,h}"
s.exclude_files = "SampleCxxModule.*"
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\"" }
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\"",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17" }
s.header_dir = "cxxreact"

s.dependency "boost", "1.76.0"
Expand Down
3 changes: 2 additions & 1 deletion ReactCommon/hermes/React-hermes.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ Pod::Spec.new do |s|
s.public_header_files = "executor/HermesExecutorFactory.h"
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
s.pod_target_xcconfig = {
"HEADER_SEARCH_PATHS" => "\"${PODS_ROOT}/hermes-engine/destroot/include\" \"$(PODS_TARGET_SRCROOT)/..\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/libevent/include\""
"HEADER_SEARCH_PATHS" => "\"${PODS_ROOT}/hermes-engine/destroot/include\" \"$(PODS_TARGET_SRCROOT)/..\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/libevent/include\"",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
}.merge!(build_type == :debug ? { "GCC_PREPROCESSOR_DEFINITIONS" => "HERMES_ENABLE_DEBUGGER=1" } : {})
s.header_dir = "reacthermes"
s.dependency "React-cxxreact", version
Expand Down
5 changes: 4 additions & 1 deletion ReactCommon/hermes/executor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

add_compile_options(-std=c++17)

file(GLOB_RECURSE hermes_executor_SRC CONFIGURE_DEPENDS *.cpp)
add_library(
hermes-executor-common
Expand All @@ -17,7 +19,8 @@ target_link_libraries(hermes-executor-common
jsireact
hermes-engine::libhermes
jsi
debug hermes-inspector
debug
hermes-inspector
)

if(${CMAKE_BUILD_TYPE} MATCHES Debug)
Expand Down
Loading

0 comments on commit fc5c8e1

Please sign in to comment.