Skip to content

Commit d2eca58

Browse files
zeyapmeta-codesync[bot]
authored andcommitted
use processor flag -DRN_USE_ANIMATION_BACKEND to gate animation backend dep (#54091)
Summary: Pull Request resolved: #54091 ## Changelog: [Internal] [Changed] - use processor flag -DRN_USE_ANIMATION_BACKEND to gate animation backend dep So it's only enabled for catalyst and fantom when building with BUCK while gated from other meta apps, and enabled by default in oss version Reviewed By: sammy-SC Differential Revision: D84157729 fbshipit-source-id: e822f11c4b64b77b17a698bf3b60b5c5a4faf4f4
1 parent e8988e9 commit d2eca58

6 files changed

Lines changed: 25 additions & 1 deletion

File tree

packages/react-native/ReactCommon/react/renderer/animated/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ target_link_libraries(react_renderer_animated
3232
)
3333
target_compile_reactnative_options(react_renderer_animated PRIVATE)
3434
target_compile_options(react_renderer_animated PRIVATE -Wpedantic)
35+
target_compile_definitions(react_renderer_animated PRIVATE RN_USE_ANIMATION_BACKEND)

packages/react-native/ReactCommon/react/renderer/animated/NativeAnimatedNodesManager.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@
3333
#include <react/renderer/animated/nodes/TrackingAnimatedNode.h>
3434
#include <react/renderer/animated/nodes/TransformAnimatedNode.h>
3535
#include <react/renderer/animated/nodes/ValueAnimatedNode.h>
36-
#include <react/renderer/animationbackend/AnimatedPropsBuilder.h>
3736
#include <react/renderer/core/EventEmitter.h>
3837

38+
#ifdef RN_USE_ANIMATION_BACKEND
39+
#include <react/renderer/animationbackend/AnimatedPropsBuilder.h>
40+
#endif
41+
3942
namespace facebook::react {
4043

4144
// Global function pointer for getting current time. Current time
@@ -515,11 +518,13 @@ NativeAnimatedNodesManager::ensureEventEmitterListener() noexcept {
515518

516519
void NativeAnimatedNodesManager::startRenderCallbackIfNeeded() {
517520
if (ReactNativeFeatureFlags::useSharedAnimatedBackend()) {
521+
#ifdef RN_USE_ANIMATION_BACKEND
518522
if (auto animationBackend =
519523
std::static_pointer_cast<AnimationBackend>(animationBackend_)) {
520524
animationBackend->start(
521525
[this](float /*f*/) { return pullAnimationMutations(); });
522526
}
527+
#endif
523528

524529
return;
525530
}
@@ -887,6 +892,7 @@ void NativeAnimatedNodesManager::schedulePropsCommit(
887892
}
888893
}
889894

895+
#ifdef RN_USE_ANIMATION_BACKEND
890896
AnimationMutations NativeAnimatedNodesManager::pullAnimationMutations() {
891897
if (!ReactNativeFeatureFlags::useSharedAnimatedBackend()) {
892898
return {};
@@ -1005,6 +1011,7 @@ AnimationMutations NativeAnimatedNodesManager::pullAnimationMutations() {
10051011
}
10061012
return mutations;
10071013
}
1014+
#endif
10081015

10091016
void NativeAnimatedNodesManager::onRender() {
10101017
if (ReactNativeFeatureFlags::useSharedAnimatedBackend()) {

packages/react-native/ReactCommon/react/renderer/animated/NativeAnimatedNodesManager.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
#include <react/debug/flags.h>
1818
#include <react/renderer/animated/EventEmitterListener.h>
1919
#include <react/renderer/animated/event_drivers/EventAnimationDriver.h>
20+
#ifdef RN_USE_ANIMATION_BACKEND
2021
#include <react/renderer/animationbackend/AnimationBackend.h>
22+
#endif
2123
#include <react/renderer/core/ReactPrimitives.h>
2224
#include <react/renderer/uimanager/UIManagerAnimationBackend.h>
2325
#include <chrono>
@@ -114,7 +116,9 @@ class NativeAnimatedNodesManager {
114116

115117
void setAnimatedNodeOffset(Tag tag, double offset);
116118

119+
#ifdef RN_USE_ANIMATION_BACKEND
117120
AnimationMutations pullAnimationMutations();
121+
#endif
118122

119123
#pragma mark - Drivers
120124

packages/react-native/ReactCommon/react/renderer/animated/NativeAnimatedNodesManagerProvider.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#include <react/featureflags/ReactNativeFeatureFlags.h>
1212
#include <react/renderer/animated/MergedValueDispatcher.h>
1313
#include <react/renderer/animated/internal/AnimatedMountingOverrideDelegate.h>
14+
#ifdef RN_USE_ANIMATION_BACKEND
1415
#include <react/renderer/animationbackend/AnimationBackend.h>
16+
#endif
1517
#include <react/renderer/uimanager/UIManagerBinding.h>
1618

1719
namespace facebook::react {
@@ -66,6 +68,7 @@ NativeAnimatedNodesManagerProvider::getOrCreate(
6668
};
6769

6870
if (ReactNativeFeatureFlags::useSharedAnimatedBackend()) {
71+
#ifdef RN_USE_ANIMATION_BACKEND
6972
// TODO: this should be initialized outside of animated, but for now it
7073
// was convenient to do it here
7174
animationBackend_ = std::make_shared<AnimationBackend>(
@@ -74,6 +77,7 @@ NativeAnimatedNodesManagerProvider::getOrCreate(
7477
std::move(directManipulationCallback),
7578
std::move(fabricCommitCallback),
7679
uiManager);
80+
#endif
7781

7882
nativeAnimatedNodesManager_ =
7983
std::make_shared<NativeAnimatedNodesManager>(animationBackend_);

private/react-native-fantom/runner/executables/tester.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {NATIVE_BUILD_OUTPUT_PATH} from '../paths';
1515
import {
1616
getBuckModesForPlatform,
1717
getBuckOptionsForHermes,
18+
getConfigForAnimationBackend,
1819
getDebugInfoFromCommandResult,
1920
runBuck2,
2021
runBuck2Sync,
@@ -54,6 +55,7 @@ export function build(options: TesterOptions): void {
5455
'build',
5556
...getBuckModesForPlatform(options.isOptimizedMode),
5657
...getBuckOptionsForHermes(options.hermesVariant),
58+
...getConfigForAnimationBackend(),
5759
FANTOM_TESTER_BUCK_TARGET,
5860
'--out',
5961
tmpPath,
@@ -94,6 +96,7 @@ export function run(
9496
'run',
9597
...getBuckModesForPlatform(options.isOptimizedMode),
9698
...getBuckOptionsForHermes(options.hermesVariant),
99+
...getConfigForAnimationBackend(),
97100
FANTOM_TESTER_BUCK_TARGET,
98101
'--',
99102
...args,

private/react-native-fantom/runner/utils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ export function getBuckModesForPlatform(
104104
return ['@//xplat/mode/react-native/granite', osPlatform];
105105
}
106106

107+
// TODO: T240293839 Remove when we get rid of RN_USE_ANIMATION_BACKEND preprocessor flag
108+
export function getConfigForAnimationBackend(): $ReadOnlyArray<string> {
109+
return ['-c rn.use_animationbackend=true'];
110+
}
111+
107112
export type AsyncCommandResult = {
108113
originalCommand: string,
109114
childProcess: ReturnType<typeof spawn>,

0 commit comments

Comments
 (0)