Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Split cmake and podspec for worklets #6334

Merged
merged 11 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion apps/fabric-example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,50 @@ PODS:
- ReactCommon/turbomodule/core
- Yoga
- RNReanimated (3.14.0):
- DoubleConversion
- glog
- hermes-engine
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
- React-Codegen
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- RNReanimated/RNReanimatedReanimated (= 3.14.0)
- RNReanimated/RNWorklets (= 3.14.0)
- Yoga
- RNReanimated/RNReanimatedReanimated (3.14.0):
- DoubleConversion
- glog
- hermes-engine
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
- React-Codegen
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNReanimated/RNWorklets (3.14.0):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1757,7 +1801,7 @@ SPEC CHECKSUMS:
RNCPicker: e84f13a98cbc8977870692948ccae15a389461bb
RNFlashList: c52e511c81ede0b8e44d4eb884b8a861976b111d
RNGestureHandler: 156548e18203327173a764c6932a3f52e90cb9cd
RNReanimated: 3ab1513708434e176c54fb5de2518f047765c0cb
RNReanimated: 6460ce8016abfcd2ab4ef4ac99f4ec3f643c78f8
RNScreens: a68878603ae871d339f683bc683803545422986f
RNSVG: 02051bffb0b2fb2166e85009a58211643434ff63
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Expand Down
46 changes: 45 additions & 1 deletion apps/paper-example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,50 @@ PODS:
- ReactCommon/turbomodule/core
- Yoga
- RNReanimated (3.14.0):
- DoubleConversion
- glog
- hermes-engine
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
- React-Codegen
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- RNReanimated/RNReanimatedReanimated (= 3.14.0)
- RNReanimated/RNWorklets (= 3.14.0)
- Yoga
- RNReanimated/RNReanimatedReanimated (3.14.0):
- DoubleConversion
- glog
- hermes-engine
- RCT-Folly (= 2024.01.01.00)
- RCTRequired
- RCTTypeSafety
- React-Codegen
- React-Core
- React-debug
- React-Fabric
- React-featureflags
- React-graphics
- React-ImageManager
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNReanimated/RNWorklets (3.14.0):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1570,7 +1614,7 @@ SPEC CHECKSUMS:
RNCPicker: 3e2c37a8328f368ce14da050cdc8231deb5fc9f9
RNFlashList: e9b57a5553639f9b528cc50ab53f25831722ed62
RNGestureHandler: 2282cfbcf86c360d29f44ace393203afd5c6cff7
RNReanimated: 03a170d6b020e03de41bbc6817c665f8679248f8
RNReanimated: cc80474f6ce28ddaa4c2c0b0aab45ee5a07cedd9
RNScreens: 52f2565581af64b1b410d49784cf8342ed94ca28
RNSVG: 43b64ed39c14ce830d840903774154ca0c1f27ec
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "LayoutAnimationsManager.h"
#include "CollectionUtils.h"
#include "Shareables.h"

#ifndef NDEBUG
#include <utility>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

#include <functional>
#include <iomanip>
#include <memory>
#include <sstream>
#include <string>
#include <thread>
#include <unordered_map>

Expand All @@ -26,7 +24,6 @@
#include "CollectionUtils.h"
#include "EventHandlerRegistry.h"
#include "FeaturesConfig.h"
#include "JSScheduler.h"
#include "ReanimatedHiddenHeaders.h"
#include "Shareables.h"
#include "UIRuntimeDecorator.h"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#ifdef ANDROID
#include "Logger.h"
#include "LoggerInterface.h"
#include "SpeedChecker.h"
#else
#include "Common/cpp/Worklets/hidden_headers/Logger.h"
#include "Common/cpp/Worklets/hidden_headers/LoggerInterface.h"
#include "Common/cpp/Worklets/hidden_headers/SpeedChecker.h"
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifdef ANDROID
#include "Logger.h"
#else
#include "Common/cpp/hidden_headers/Logger.h"
#include "Common/cpp/Worklets/hidden_headers/Logger.h"
#endif

namespace reanimated {
Expand Down
21 changes: 14 additions & 7 deletions packages/react-native-reanimated/RNReanimated.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,21 @@ Pod::Spec.new do |s|
s.platforms = { :ios => ios_min_version, :tvos => "9.0", :osx => "10.14", :visionos => "1.0" }
s.source = { :git => "https://github.com/software-mansion/react-native-reanimated.git", :tag => "#{s.version}" }

s.source_files = [
"apple/**/*.{mm,h,m}",
"Common/cpp/**/*.{cpp,h}"
]
s.subspec "RNReanimatedReanimated" do |ss|
tjzel marked this conversation as resolved.
Show resolved Hide resolved
ss.source_files = [
"apple/**/*.{mm,h,m}",
"Common/cpp/Reanimated/**/*.{cpp,h}",
tjzel marked this conversation as resolved.
Show resolved Hide resolved
]
end

s.preserve_paths = [
"Common/cpp/hidden_headers/**"
]
s.subspec "RNWorklets" do |ss|
tjzel marked this conversation as resolved.
Show resolved Hide resolved
ss.source_files = [
"Common/cpp/Worklets/**/*.{cpp,h}",
tjzel marked this conversation as resolved.
Show resolved Hide resolved
]
ss.preserve_paths = [
"Common/cpp/Worklets/hidden_headers/**"
]
end

gcc_debug_definitions = "$(inherited)"
if $config[:react_native_minor_version] >= 73 || !is_release
Expand Down
152 changes: 13 additions & 139 deletions packages/react-native-reanimated/android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
project(Reanimated)
cmake_minimum_required(VERSION 3.8)

set (CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")

set(CMAKE_VERBOSE_MAKEFILE ON)

if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 73)
set (CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 20)
else()
set (CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 17)
endif()

# default CMAKE_CXX_FLAGS: "-g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-protector-all"

include("${REACT_NATIVE_DIR}/ReactAndroid/cmake-utils/folly-flags.cmake")
add_compile_options(${folly_FLAGS})

Expand All @@ -29,139 +32,10 @@ if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug")
string(APPEND CMAKE_CXX_FLAGS " -DNDEBUG")
endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")

set (PACKAGE_NAME "reanimated")
set (BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
set (SRC_DIR ${CMAKE_SOURCE_DIR}/src)
set (COMMON_SRC_DIR "${CMAKE_SOURCE_DIR}/../Common")

file(GLOB_RECURSE SOURCES_COMMON CONFIGURE_DEPENDS "${COMMON_SRC_DIR}/cpp/**.cpp")
file(GLOB_RECURSE SOURCES_ANDROID CONFIGURE_DEPENDS "${SRC_DIR}/main/cpp/**.cpp")

# Consume shared libraries and headers from prefabs
find_package(fbjni REQUIRED CONFIG)
find_package(ReactAndroid REQUIRED CONFIG)
if(${JS_RUNTIME} STREQUAL "hermes")
find_package(hermes-engine REQUIRED CONFIG)
endif()

add_library(
${PACKAGE_NAME}
SHARED
${SOURCES_COMMON}
${SOURCES_ANDROID}
${INCLUDE_JSI_CPP}
${INCLUDE_JSIDYNAMIC_CPP}
)

# includes

target_include_directories(
${PACKAGE_NAME}
PRIVATE
"${COMMON_SRC_DIR}/cpp/AnimatedSensor"
"${COMMON_SRC_DIR}/cpp/Fabric"
"${COMMON_SRC_DIR}/cpp/hidden_headers"
"${COMMON_SRC_DIR}/cpp/LayoutAnimations"
"${COMMON_SRC_DIR}/cpp/NativeModules"
"${COMMON_SRC_DIR}/cpp/Tools"
"${COMMON_SRC_DIR}/cpp/Worklets/Registries"
"${COMMON_SRC_DIR}/cpp/Worklets/SharedItems"
"${COMMON_SRC_DIR}/cpp/Worklets/Tools"
"${COMMON_SRC_DIR}/cpp/Worklets/WorkletRuntime"
"${SRC_DIR}/main/cpp"
)

target_include_directories(
${PACKAGE_NAME}
PRIVATE
"${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/turbomodule"
"${REACT_NATIVE_DIR}/ReactCommon"
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/graphics/platform/cxx"
"${REACT_NATIVE_DIR}/ReactCommon/runtimeexecutor"
"${REACT_NATIVE_DIR}/ReactCommon/yoga"
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/componentregistry"
"${REACT_NATIVE_DIR}/ReactCommon/react/renderer/core"
)

# build shared lib

set_target_properties(${PACKAGE_NAME} PROPERTIES LINKER_LANGUAGE CXX)

target_link_libraries(
${PACKAGE_NAME}
log
android
)

target_link_libraries(
${PACKAGE_NAME}
ReactAndroid::folly_runtime
ReactAndroid::glog
ReactAndroid::jsi
ReactAndroid::reactnativejni
fbjni::fbjni
)

if(${JS_RUNTIME} STREQUAL "hermes")
string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_HERMES=1")
# From prefab from module `com.facebook.react:hermes-android`
set(HERMES_LIB hermes-engine::libhermes)
target_link_libraries(
${PACKAGE_NAME}
${HERMES_LIB}
)
if (${HERMES_ENABLE_DEBUGGER})
set(HERMES_EXECUTOR_LIB ReactAndroid::hermes_executor)
target_link_libraries(
${PACKAGE_NAME}
${HERMES_EXECUTOR_LIB}
)
endif()
elseif(${JS_RUNTIME} STREQUAL "v8")
string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_V8=1")
target_include_directories(
${PACKAGE_NAME}
PRIVATE
"${JS_RUNTIME_DIR}/src"
)
file (GLOB V8_SO_DIR "${JS_RUNTIME_DIR}/android/build/intermediates/library_jni/*/jni/${ANDROID_ABI}")
find_library(
V8EXECUTOR_LIB
v8executor
PATHS ${V8_SO_DIR}
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH
)
target_link_libraries(
${PACKAGE_NAME}
${V8EXECUTOR_LIB}
)
elseif(${JS_RUNTIME} STREQUAL "jsc")
string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_JSC=1")
set(JSEXECUTOR_LIB ReactAndroid::jscexecutor)
target_link_libraries(${PACKAGE_NAME} ${JSEXECUTOR_LIB})
else()
message(FATAL_ERROR "Unknown JS runtime ${JS_RUNTIME}.")
endif()

if(${IS_NEW_ARCHITECTURE_ENABLED})
target_link_libraries(
${PACKAGE_NAME}
ReactAndroid::fabricjni
ReactAndroid::react_debug
ReactAndroid::react_render_core
ReactAndroid::react_render_mounting
ReactAndroid::react_render_componentregistry
ReactAndroid::react_render_scheduler
ReactAndroid::react_render_uimanager
ReactAndroid::rrc_view
)
endif()
set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build")
set(ANDROID_SRC_DIR "${CMAKE_SOURCE_DIR}/src")
set(WORKLET_COMMON_DIR "${CMAKE_SOURCE_DIR}/../Common/cpp/Worklets")
set(REANIMATED_COMMON_DIR "${CMAKE_SOURCE_DIR}/../Common/cpp/Reanimated")
tjzel marked this conversation as resolved.
Show resolved Hide resolved

# Resolves "CMake Warning: Manually-specified variables were not used by the project"
# when any of the following variables is not used in some build configuration.
set (ignoreMe "${JS_RUNTIME_DIR}")
add_subdirectory(${CMAKE_SOURCE_DIR}/src/main/worklets)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/main/reanimated)
Loading
Loading