Properly set REACTNATIVE_MERGED_SO for autolinked libraries. (#46606)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46606

This fixes this issue reported here:
https://github.com/react-native-community/discussions-and-proposals/discussions/816#discussioncomment-10673136

reported by both SWM and Expo.

The problem is that `REACTNATIVE_MERGED_SO` is not properly set for autolinked libraries so they can't access it
to understand if the version of ReactNative has merged so libraries or not.
This fixes it, I've tested against
https://github.com/tomekzaw/repro-reactnative-merged-so
reproducer provided by tomekzaw

Changelog:
[Android] [Fixed] - Properly set `REACTNATIVE_MERGED_SO` for autolinked libraries

Reviewed By: rubennorte

Differential Revision: D63262687

fbshipit-source-id: c505dce9036bb4cd0366b7ab99412368963273af
This commit is contained in:
Nicola Corti
2024-09-30 14:26:41 +01:00
committed by Blake Friedman
parent d334f4d77e
commit cffeb603de
2 changed files with 12 additions and 0 deletions
@@ -166,6 +166,10 @@ abstract class GenerateAutolinkingNewArchitecturesFileTask : DefaultTask() {
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)
# We set REACTNATIVE_MERGED_SO so libraries/apps can selectively decide to depend on either libreactnative.so
# or link against a old prefab target (this is needed for React Native 0.76 on).
set(REACTNATIVE_MERGED_SO true)
{{ libraryIncludes }}
set(AUTOLINKED_LIBRARIES
@@ -115,6 +115,10 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)
# We set REACTNATIVE_MERGED_SO so libraries/apps can selectively decide to depend on either libreactnative.so
# or link against a old prefab target (this is needed for React Native 0.76 on).
set(REACTNATIVE_MERGED_SO true)
set(AUTOLINKED_LIBRARIES
@@ -137,6 +141,10 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)
# We set REACTNATIVE_MERGED_SO so libraries/apps can selectively decide to depend on either libreactnative.so
# or link against a old prefab target (this is needed for React Native 0.76 on).
set(REACTNATIVE_MERGED_SO true)
add_subdirectory(./a/directory/ aPackage_autolinked_build)
add_subdirectory(./another/directory/ anotherPackage_autolinked_build)
add_subdirectory(./another/directory/cxx/ anotherPackage_cxxmodule_autolinked_build)