From 5029cef0a99469e37bc2f4d72ca2e1f3d6791511 Mon Sep 17 00:00:00 2001 From: Dmitry Rykun Date: Thu, 16 Nov 2023 03:05:35 -0800 Subject: [PATCH] Do not include two copies of JSI when using hermes-engine (#41499) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/41499 After D48152876 we consume JSI from `ReactCommon/jsi`, and ignore JSI that is distributed with `hermes-engine`. This diff removes `include/jsi` from `source_files` of `hermes-engine` so we don't get two sets of JSI headers - one from `ReactCommon`, and the other one from `hermes-engine`. This diff also fixes accidental breakage of ODR violation. We will no longer compile JSI into `react-native` when linking against `hermes-engine`, which already has JSI in it. Changelog: [iOS][Fixed] - Exclude JSI headers when using hermes-engine prebuilt. Reviewed By: cipolleschi Differential Revision: D51347562 fbshipit-source-id: 6e4b9940c43d74d227a05999926b8752d7685670 --- .../react-native/ReactCommon/jsi/React-jsi.podspec | 10 ++++++++-- .../sdks/hermes-engine/hermes-engine.podspec | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/react-native/ReactCommon/jsi/React-jsi.podspec b/packages/react-native/ReactCommon/jsi/React-jsi.podspec index 973acfe6fa77d6..eadf8b57007201 100644 --- a/packages/react-native/ReactCommon/jsi/React-jsi.podspec +++ b/packages/react-native/ReactCommon/jsi/React-jsi.podspec @@ -46,9 +46,15 @@ Pod::Spec.new do |s| s.dependency "glog" s.source_files = "**/*.{cpp,h}" - s.exclude_files = [ + files_to_exclude = [ "jsi/jsilib-posix.cpp", "jsi/jsilib-windows.cpp", "**/test/*" - ] + ] + if js_engine == :hermes + # JSI is a part of hermes-engine. Including them also in react-native will violate the One Definition Rulle. + files_to_exclude += [ "jsi/jsi.cpp" ] + s.dependency "hermes-engine" + end + s.exclude_files = files_to_exclude end diff --git a/packages/react-native/sdks/hermes-engine/hermes-engine.podspec b/packages/react-native/sdks/hermes-engine/hermes-engine.podspec index c7e22ddf572225..ab678e142c6511 100644 --- a/packages/react-native/sdks/hermes-engine/hermes-engine.podspec +++ b/packages/react-native/sdks/hermes-engine/hermes-engine.podspec @@ -41,7 +41,7 @@ Pod::Spec.new do |spec| spec.subspec 'Pre-built' do |ss| ss.preserve_paths = ["destroot/bin/*"].concat(["**/*.{h,c,cpp}"]) - ss.source_files = "destroot/include/**/*.h" + ss.source_files = "destroot/include/hermes/**/*.h" ss.header_mappings_dir = "destroot/include" ss.ios.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework" ss.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework"