Skip to content

Commit

Permalink
Use reference Yoga CMake build (#37371)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #37371

This makes React Native use `libyogacore` as provided by Yoga's reference CMake build. This in turn matches Yoga in the OSS RN build to the same compilation settings we use internally.

Changelog:
[Android][Changed] - Use reference Yoga CMake Build

Differential Revision: D45764537

fbshipit-source-id: 2da30de434838a155078571496ccdd30eccd75fc
  • Loading branch information
NickGerleman authored and facebook-github-bot committed May 11, 2023
1 parent 7443dab commit c3ee77b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

add_compile_options(
-fvisibility=hidden
-fexceptions
-frtti
-O3)
add_subdirectory(jni)

file(GLOB yoga_SRC CONFIGURE_DEPENDS jni/*.cpp)
add_library(yoga SHARED ${yoga_SRC})

target_include_directories(yoga PUBLIC jni)

target_link_libraries(yoga yogacore fb fbjni log android)
# Yoga by default does not enable optimizations in debug builds. Enable -O2
# for all builds in RN for faster debug app performance (at the cost of not
# being able to debug inside Yoga)
target_compile_options(yogacore PRIVATE -O2)
target_compile_options(yoga PRIVATE -O2)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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.

cmake_minimum_required(VERSION 3.13)
project(yogajni)
set(CMAKE_VERBOSE_MAKEFILE on)

set(YOGA_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
include(${YOGA_ROOT}/cmake/project-defaults.cmake)

add_subdirectory(${YOGA_ROOT}/yoga ${CMAKE_CURRENT_BINARY_DIR}/yoga)

file(GLOB SOURCES CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/jni/*.cpp)
file(GLOB VERSION_SCRIPT CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/yogajni.version)

add_library(yoga SHARED ${SOURCES})
target_link_libraries(yoga yogacore)
target_link_options(yoga PRIVATE -Wl,--version-script=${VERSION_SCRIPT})
18 changes: 5 additions & 13 deletions packages/react-native/ReactCommon/yoga/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,9 @@
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)

add_compile_options(
-fexceptions
-frtti
-O3
-Wall
-Wpedantic
-Wno-gnu-zero-variadic-macro-arguments)
add_subdirectory(yoga)

file(GLOB_RECURSE yogacore_SRC CONFIGURE_DEPENDS yoga/*.cpp)
add_library(yogacore STATIC ${yogacore_SRC})

target_include_directories(yogacore PUBLIC .)

target_link_libraries(yogacore android log)
# Yoga by default does not enable optimizations in debug builds. Enable -O2
# for all builds in RN for faster debug app performance (at the cost of not
# being able to debug inside Yoga)
target_compile_options(yogacore PRIVATE -O2)

0 comments on commit c3ee77b

Please sign in to comment.