Skip to content

Commit

Permalink
refactor: Split Java and ObjC code into Reanimated and Worklets dirs (#…
Browse files Browse the repository at this point in the history
…6366)

## Summary

This PR is the continuation of the code split made in common C++ layer.
All of the files currently go to `reanimated` directory, moving some of
them to `worklets` will happen in follow-up PRs.

Requires #6357.

## Test plan

- [ ] CI passes.
  • Loading branch information
tjzel authored Aug 12, 2024
1 parent dda25d6 commit 2a8ff37
Show file tree
Hide file tree
Showing 72 changed files with 40 additions and 42 deletions.
8 changes: 4 additions & 4 deletions apps/fabric-example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2125,10 +2125,10 @@ SPEC CHECKSUMS:
boost: 4cb898d0bf20404aab1850c656dcea009429d6c1
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
FBLazyVector: d08b51db67e61e1adaed7aefdb43b43f247ee46a
fmt: 8083860262b879fc92bca720969c91bdb88ada93
glog: 79d13cd7c34b5d0cea5f4ca72c0e6b462ef8fb4d
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
glog: 69ef571f3de08433d766d614c73a9838a06bf7eb
hermes-engine: b205fccb3c7b52031e5bdb458a40f85f806bb7e8
RCT-Folly: 62f9775ef5ef5819714c7923b4b3a3eb5bf32dab
RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740
RCTDeprecation: 8c3d64b4ab77cf28adefa261e04fd205c2715607
RCTRequired: 70f9b55e176be07e234e2efe43b31de14d7cd5ba
RCTTypeSafety: 570d25d58d8795b1a146f5dee4965a05b6fdf8ac
Expand Down Expand Up @@ -2191,7 +2191,7 @@ SPEC CHECKSUMS:
RNCPicker: 7973f617de8809ab9e7577b93ce23d3449fb1ec7
RNFlashList: 2381687e1305c20b7e173e9a980e2b9a7a3973f5
RNGestureHandler: 8781e2529230a1bc3ea8d75e5c3cd071b6c6aed7
RNReanimated: 1ccd1c76398c3c599cf12ad152e8ef2b920aa6b9
RNReanimated: 43e063cf135eb457f105c7e48d1f735fee39ec5b
RNScreens: de6e57426ba0e6cbc3fb5b4f496e7f08cb2773c2
RNSVG: 6b65086b51556fd9723d5570a3455e865e1304a3
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Expand Down
2 changes: 1 addition & 1 deletion apps/macos-example/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ SPEC CHECKSUMS:
RNCAsyncStorage: 826b603ae9c0f88b5ac4e956801f755109fa4d5c
RNCPicker: 3e2c37a8328f368ce14da050cdc8231deb5fc9f9
RNGestureHandler: f203fa4755a75b02d45a299b07d7ed878f636705
RNReanimated: b40f25f1e59b7071a7c699c99527137c2a0ddc09
RNReanimated: f27c64c70e04681e8c6e202442bce8db03fc27cd
RNSVG: cb24fb322de8c1ebf59904e7aca0447bb8dbed5a
SocketRocket: f6c6249082c011e6de2de60ed641ef8bbe0cfac9
Yoga: dd0f2dde9c2bf2398b406740154bd99d5293aed8
Expand Down
8 changes: 4 additions & 4 deletions apps/paper-example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1915,10 +1915,10 @@ SPEC CHECKSUMS:
boost: 4cb898d0bf20404aab1850c656dcea009429d6c1
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
FBLazyVector: d08b51db67e61e1adaed7aefdb43b43f247ee46a
fmt: 8083860262b879fc92bca720969c91bdb88ada93
glog: 79d13cd7c34b5d0cea5f4ca72c0e6b462ef8fb4d
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
glog: 69ef571f3de08433d766d614c73a9838a06bf7eb
hermes-engine: b205fccb3c7b52031e5bdb458a40f85f806bb7e8
RCT-Folly: 62f9775ef5ef5819714c7923b4b3a3eb5bf32dab
RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740
RCTDeprecation: 8c3d64b4ab77cf28adefa261e04fd205c2715607
RCTRequired: 70f9b55e176be07e234e2efe43b31de14d7cd5ba
RCTTypeSafety: 570d25d58d8795b1a146f5dee4965a05b6fdf8ac
Expand Down Expand Up @@ -1981,7 +1981,7 @@ SPEC CHECKSUMS:
RNCPicker: 3e2c37a8328f368ce14da050cdc8231deb5fc9f9
RNFlashList: 2a5ca82c4998952060b77fa9a1eb05f7ed8783b6
RNGestureHandler: 79789b93c9a67c553ecdfb4121e8c267cba12447
RNReanimated: 3daa2123ef575afadd66cd8a6b809129acbd4a47
RNReanimated: 2141ea09c132fb9d4b58f9dbab31f901119f0302
RNScreens: 19719a9c326e925498ac3b2d35c4e50fe87afc06
RNSVG: cb24fb322de8c1ebf59904e7aca0447bb8dbed5a
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Expand Down
2 changes: 1 addition & 1 deletion apps/tvos-example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ SPEC CHECKSUMS:
React-runtimescheduler: 20b2202e3396589a71069d12ae9f328949c7c7b8
React-utils: 0307d396f233e47a167b5aaf045b0e4e1dc19d74
ReactCommon: 17891ca337bfa5a7263649b09f27a8c664537bf2
RNReanimated: 3cc4305aa879359f791b4e95a5c2d60a0c2051fe
RNReanimated: d2471e47c524529201ef0a5e4dde0e525b3f3260
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: ab50eb8f7fcf1b36aad1801b5687b66b2c0aa000

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void RNRuntimeDecorator::decorate(

rnRuntime.global().setProperty(
rnRuntime,
jsi::PropNameID::forAscii(rnRuntime, "__reanimatedModuleProxy"),
"__reanimatedModuleProxy",
jsi::Object::createFromHostObject(rnRuntime, nativeReanimatedModule));
}

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-reanimated/RNReanimated.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Pod::Spec.new do |s|

s.subspec "reanimated" do |ss|
ss.source_files = [
"apple/**/*.{mm,h,m}",
"apple/reanimated/**/*.{mm,h,m}",
"Common/cpp/reanimated/**/*.{cpp,h}",
]
end
Expand Down
13 changes: 6 additions & 7 deletions packages/react-native-reanimated/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ cmake_minimum_required(VERSION 3.8)
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)
else()
Expand Down Expand Up @@ -48,9 +46,10 @@ endif()
set(ignoreMe "${JS_RUNTIME_DIR}")

set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build")
set(ANDROID_SRC_DIR "${CMAKE_SOURCE_DIR}/src")
set(WORKLETS_COMMON_DIR "${CMAKE_SOURCE_DIR}/../Common/cpp/worklets")
set(REANIMATED_COMMON_DIR "${CMAKE_SOURCE_DIR}/../Common/cpp/reanimated")
set(WORKLETS_ANDROID_CPP_DIR "${CMAKE_SOURCE_DIR}/src/main/cpp/worklets")
set(WORKLETS_COMMON_CPP_DIR "${CMAKE_SOURCE_DIR}/../Common/cpp/worklets")
set(REANIMATED_ANDROID_CPP_DIR "${CMAKE_SOURCE_DIR}/src/main/cpp/reanimated")
set(REANIMATED_COMMON_CPP_DIR "${CMAKE_SOURCE_DIR}/../Common/cpp/reanimated")

add_subdirectory(${CMAKE_SOURCE_DIR}/src/main/worklets)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/main/reanimated)
add_subdirectory(${WORKLETS_ANDROID_CPP_DIR})
add_subdirectory(${REANIMATED_ANDROID_CPP_DIR})
4 changes: 3 additions & 1 deletion packages/react-native-reanimated/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,13 @@ def assertMinimalReactNativeVersion = task assertMinimalReactNativeVersionTask {
}

task prepareHeadersForPrefab(type: Copy) {
from("$projectDir/src/main/cpp")
from("$projectDir/src/main/cpp/reanimated")
from("$projectDir/../Common/cpp/reanimated/AnimatedSensor")
from("$projectDir/../Common/cpp/reanimated/Fabric")
from("$projectDir/../Common/cpp/reanimated/LayoutAnimations")
from("$projectDir/../Common/cpp/reanimated/NativeModules")
from("$projectDir/../Common/cpp/reanimated/RuntimeDecorators")
from("$projectDir/../Common/cpp/reanimated/Tools")
from("$projectDir/../Common/cpp/worklets/Registries")
from("$projectDir/../Common/cpp/worklets/SharedItems")
from("$projectDir/../Common/cpp/worklets/Tools")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
cmake_minimum_required(VERSION 3.8)

file(GLOB_RECURSE REANIMATED_COMMON_SOURCES CONFIGURE_DEPENDS "${REANIMATED_COMMON_DIR}/*.cpp")
file(GLOB_RECURSE SOURCES_ANDROID CONFIGURE_DEPENDS "${ANDROID_SRC_DIR}/main/cpp/*.cpp")
file(GLOB_RECURSE REANIMATED_COMMON_CPP_SOURCES CONFIGURE_DEPENDS "${REANIMATED_COMMON_CPP_DIR}/*.cpp")
file(GLOB_RECURSE REANIMATED_ANDROID_CPP_SOURCES CONFIGURE_DEPENDS "${REANIMATED_ANDROID_CPP_DIR}/*.cpp")

add_library(
reanimated
SHARED
${REANIMATED_COMMON_SOURCES}
${SOURCES_ANDROID}
"${ANDROID_SRC_DIR}/main/cpp/PlatformLogger.cpp"
${REANIMATED_COMMON_CPP_SOURCES}
${REANIMATED_ANDROID_CPP_SOURCES}
)

target_include_directories(
reanimated
PRIVATE
"${REANIMATED_COMMON_DIR}/AnimatedSensor"
"${REANIMATED_COMMON_DIR}/Fabric"
"${REANIMATED_COMMON_DIR}/LayoutAnimations"
"${REANIMATED_COMMON_DIR}/NativeModules"
"${REANIMATED_COMMON_DIR}/Tools"
"${REANIMATED_COMMON_DIR}/RuntimeDecorators"
"${REANIMATED_COMMON_CPP_DIR}/AnimatedSensor"
"${REANIMATED_COMMON_CPP_DIR}/Fabric"
"${REANIMATED_COMMON_CPP_DIR}/LayoutAnimations"
"${REANIMATED_COMMON_CPP_DIR}/NativeModules"
"${REANIMATED_COMMON_CPP_DIR}/Tools"
"${REANIMATED_COMMON_CPP_DIR}/RuntimeDecorators"
)

target_include_directories(
reanimated
PRIVATE
"${ANDROID_SRC_DIR}/main/cpp"
"${REANIMATED_ANDROID_CPP_DIR}"
)

target_include_directories(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.8)

file(GLOB_RECURSE WORKLETS_COMMON_SOURCES CONFIGURE_DEPENDS "${WORKLETS_COMMON_DIR}/*.cpp")
file(GLOB_RECURSE WORKLETS_COMMON_CPP_SOURCES CONFIGURE_DEPENDS "${WORKLETS_COMMON_CPP_DIR}/*.cpp")

# Consume shared libraries and headers from prefabs
find_package(fbjni REQUIRED CONFIG)
Expand All @@ -13,17 +13,17 @@ endif()
add_library(
worklets
SHARED
${WORKLETS_COMMON_SOURCES}
${WORKLETS_COMMON_CPP_SOURCES}
)

# includes
target_include_directories(
worklets
PUBLIC
"${WORKLETS_COMMON_DIR}/Registries"
"${WORKLETS_COMMON_DIR}/SharedItems"
"${WORKLETS_COMMON_DIR}/Tools"
"${WORKLETS_COMMON_DIR}/WorkletRuntime"
"${WORKLETS_COMMON_CPP_DIR}/Registries"
"${WORKLETS_COMMON_CPP_DIR}/SharedItems"
"${WORKLETS_COMMON_CPP_DIR}/Tools"
"${WORKLETS_COMMON_CPP_DIR}/WorkletRuntime"
)

target_include_directories(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ static inline bool getIsReducedMotion()
std::shared_ptr<UIScheduler> uiScheduler = std::make_shared<REAIOSUIScheduler>();
std::shared_ptr<JSScheduler> jsScheduler = std::make_shared<JSScheduler>(rnRuntime, jsInvoker);
constexpr auto isBridgeless = false;
const auto isReducedMotion = getIsReducedMotion();

auto nativeReanimatedModule = std::make_shared<NativeReanimatedModule>(
rnRuntime,
Expand All @@ -83,7 +82,7 @@ static inline bool getIsReducedMotion()
platformDepMethodsHolder,
valueUnpackerCode,
isBridgeless,
isReducedMotion);
getIsReducedMotion());

commonInit(reaModule, nativeReanimatedModule);
// Layout Animation callbacks setup
Expand Down Expand Up @@ -119,7 +118,6 @@ static inline bool getIsReducedMotion()
auto uiScheduler = std::make_shared<REAIOSUIScheduler>();
auto jsScheduler = std::make_shared<JSScheduler>(runtime, runtimeExecutor);
constexpr auto isBridgeless = true;
const auto isReducedMotion = getIsReducedMotion();

auto nativeReanimatedModule = std::make_shared<NativeReanimatedModule>(
runtime,
Expand All @@ -129,7 +127,7 @@ static inline bool getIsReducedMotion()
platformDepMethodsHolder,
valueUnpackerCode,
isBridgeless,
isReducedMotion);
getIsReducedMotion());

commonInit(reaModule, nativeReanimatedModule);

Expand Down

0 comments on commit 2a8ff37

Please sign in to comment.