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 Java and ObjC code into Reanimated and Worklets dirs #6366

Merged
merged 17 commits into from
Aug 12, 2024
Merged
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
8 changes: 3 additions & 5 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,9 @@ endif()
set(ignoreMe "${JS_RUNTIME_DIR}")

set(BUILD_DIR "${CMAKE_SOURCE_DIR}/build")
set(ANDROID_SRC_DIR "${CMAKE_SOURCE_DIR}/src")
set(REANIMATED_ANDROID_DIR "${CMAKE_SOURCE_DIR}/src/main/cpp/reanimated")
set(WORKLETS_COMMON_DIR "${CMAKE_SOURCE_DIR}/../Common/cpp/worklets")
set(REANIMATED_COMMON_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(${CMAKE_SOURCE_DIR}/src/main/cpp/worklets)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/main/cpp/reanimated)
39 changes: 20 additions & 19 deletions packages/react-native-reanimated/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -349,63 +349,63 @@ android {
sourceSets.main {
java {
if (IS_NEW_ARCHITECTURE_ENABLED) {
srcDirs += "src/fabric/java"
srcDirs += "src/fabric/reanimated/java"
tjzel marked this conversation as resolved.
Show resolved Hide resolved
} else {
srcDirs += "src/paper/java"
srcDirs += "src/paper/reanimated/java"
}

// messageQueueThread
if (REANIMATED_MAJOR_VERSION > 2) {
if (REACT_NATIVE_MINOR_VERSION <= 72) {
srcDirs += "src/reactNativeVersionPatch/messageQueueThread/72"
srcDirs += "src/reactNativeVersionPatch/reanimated/messageQueueThread/72"
} else {
srcDirs += "src/reactNativeVersionPatch/messageQueueThread/latest"
srcDirs += "src/reactNativeVersionPatch/reanimated/messageQueueThread/latest"
}
}

// ReanimatedUIManager & ReanimatedUIImplementation
if (REACT_NATIVE_MINOR_VERSION <= 73) {
srcDirs += "src/reactNativeVersionPatch/ReanimatedUIManager/73"
srcDirs += "src/reactNativeVersionPatch/reanimated/ReanimatedUIManager/73"
} else if (REACT_NATIVE_MINOR_VERSION <= 74) {
srcDirs += "src/reactNativeVersionPatch/ReanimatedUIManager/74"
srcDirs += "src/reactNativeVersionPatch/reanimated/ReanimatedUIManager/74"
} else {
srcDirs += "src/reactNativeVersionPatch/ReanimatedUIManager/latest"
srcDirs += "src/reactNativeVersionPatch/reanimated/ReanimatedUIManager/latest"
}

// ReactHost
if (REACT_NATIVE_MINOR_VERSION <= 72) {
srcDirs += "src/reactNativeVersionPatch/ReactHost/72"
srcDirs += "src/reactNativeVersionPatch/reanimated/ReactHost/72"
} else {
srcDirs += "src/reactNativeVersionPatch/ReactHost/latest"
srcDirs += "src/reactNativeVersionPatch/reanimated/ReactHost/latest"
}

// ReactFeatureFlags
if (IS_NEW_ARCHITECTURE_ENABLED) {
if (REACT_NATIVE_MINOR_VERSION <= 72) {
srcDirs += "src/reactNativeVersionPatch/ReactFeatureFlagsWrapper/72"
srcDirs += "src/reactNativeVersionPatch/reanimated/ReactFeatureFlagsWrapper/72"
} else if (REACT_NATIVE_MINOR_VERSION <= 74) {
srcDirs += "src/reactNativeVersionPatch/ReactFeatureFlagsWrapper/74"
srcDirs += "src/reactNativeVersionPatch/reanimated/ReactFeatureFlagsWrapper/74"
} else {
srcDirs += "src/reactNativeVersionPatch/ReactFeatureFlagsWrapper/latest"
srcDirs += "src/reactNativeVersionPatch/reanimated/ReactFeatureFlagsWrapper/latest"
}
}

// RuntimeExecutor
if (IS_NEW_ARCHITECTURE_ENABLED) {
if (REACT_NATIVE_MINOR_VERSION <= 73) {
srcDirs += "src/reactNativeVersionPatch/RuntimeExecutor/73"
srcDirs += "src/reactNativeVersionPatch/reanimated/RuntimeExecutor/73"
} else if (REACT_NATIVE_MINOR_VERSION <= 74) {
srcDirs += "src/reactNativeVersionPatch/RuntimeExecutor/74"
srcDirs += "src/reactNativeVersionPatch/reanimated/RuntimeExecutor/74"
} else {
srcDirs += "src/reactNativeVersionPatch/RuntimeExecutor/latest"
srcDirs += "src/reactNativeVersionPatch/reanimated/RuntimeExecutor/latest"
}
}

// BorderRadiiDrawableUtils
if (REACT_NATIVE_MINOR_VERSION <= 74) {
srcDirs += "src/reactNativeVersionPatch/BorderRadiiDrawableUtils/74"
srcDirs += "src/reactNativeVersionPatch/reanimated/BorderRadiiDrawableUtils/74"
} else {
srcDirs += "src/reactNativeVersionPatch/BorderRadiiDrawableUtils/latest"
srcDirs += "src/reactNativeVersionPatch/reanimated/BorderRadiiDrawableUtils/latest"
}
}
}
Expand All @@ -430,15 +430,16 @@ 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/Tools")
from("$projectDir/../Common/cpp/worklets/ReanimatedRuntime")
tjzel marked this conversation as resolved.
Show resolved Hide resolved
from("$projectDir/../Common/cpp/worklets/Registries")
from("$projectDir/../Common/cpp/worklets/SharedItems")
from("$projectDir/../Common/cpp/worklets/Tools")
from("$projectDir/../Common/cpp/worklets/WorkletRuntime")
include("*.h")
into(prefabHeadersDir)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
cmake_minimum_required(VERSION 3.8)

file(GLOB_RECURSE REANIMATED_COMMON_SOURCES CONFIGURE_DEPENDS "${REANIMATED_COMMON_DIR}/*.cpp")
tjzel marked this conversation as resolved.
Show resolved Hide resolved
file(GLOB_RECURSE SOURCES_ANDROID CONFIGURE_DEPENDS "${ANDROID_SRC_DIR}/main/cpp/*.cpp")
file(GLOB_RECURSE SOURCES_ANDROID CONFIGURE_DEPENDS "${REANIMATED_ANDROID_DIR}/*.cpp")
tjzel marked this conversation as resolved.
Show resolved Hide resolved

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

target_include_directories(
Expand All @@ -25,7 +25,7 @@ target_include_directories(
target_include_directories(
reanimated
PRIVATE
"${ANDROID_SRC_DIR}/main/cpp"
"${REANIMATED_ANDROID_DIR}"
)

target_include_directories(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ - (void)commonInit:(std::shared_ptr<NativeReanimatedModule>)nativeReanimatedModu
withRnRuntime:(jsi::Runtime &)rnRuntime
{
WorkletRuntimeCollector::install(rnRuntime);

tjzel marked this conversation as resolved.
Show resolved Hide resolved
RNRuntimeDecorator::decorate(rnRuntime, nativeReanimatedModule);
#ifdef RCT_NEW_ARCH_ENABLED
weakNativeReanimatedModule_ = nativeReanimatedModule;
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());
tjzel marked this conversation as resolved.
Show resolved Hide resolved

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
Loading