From bf8eb1194dac5ac3a2efdbfc29e15d687c14bfca Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Thu, 13 Apr 2023 02:36:03 -0700 Subject: [PATCH] Allow to disable the New Architecture inside RN Tester (#36895) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36895 Currently RN-Tester build with the New Architecture hardcoded to true. For testing is convenient to disable it at times so we can test how the app behaves in the old arch. Changelog: [Internal] [Changed] - Allow to disable the New Architecture inside RN Tester Reviewed By: cipolleschi Differential Revision: D44917566 fbshipit-source-id: f1e6393e37bf6702677157b9577a26f0c4da0b86 --- packages/rn-tester/android/app/build.gradle | 14 +++++++++----- .../facebook/react/uiapp/RNTesterApplication.java | 6 ++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/rn-tester/android/app/build.gradle b/packages/rn-tester/android/app/build.gradle index f71bcddfa3f166..b597120366fa47 100644 --- a/packages/rn-tester/android/app/build.gradle +++ b/packages/rn-tester/android/app/build.gradle @@ -189,7 +189,9 @@ android { cmake { // RN Tester is doing custom linking of C++ libraries therefore needs // a dedicated CMakeLists.txt file. - path "src/main/jni/CMakeLists.txt" + if (project.property("newArchEnabled") == "true") { + path("src/main/jni/CMakeLists.txt") + } } } } @@ -202,8 +204,10 @@ afterEvaluate { // As we're building 4 native flavors in parallel, there is clash on the `.cxx/Debug` and // `.cxx/Release` folder where the CMake intermediates are stored. // We fixing this by instructing Gradle to always mergeLibs after they've been built. - mergeHermesDebugNativeLibs.mustRunAfter(externalNativeBuildJscDebug) - mergeHermesReleaseNativeLibs.mustRunAfter(externalNativeBuildJscRelease) - mergeJscDebugNativeLibs.mustRunAfter(externalNativeBuildHermesDebug) - mergeJscReleaseNativeLibs.mustRunAfter(externalNativeBuildHermesRelease) + if (project.property("newArchEnabled") == "true") { + mergeHermesDebugNativeLibs.mustRunAfter(externalNativeBuildJscDebug) + mergeHermesReleaseNativeLibs.mustRunAfter(externalNativeBuildJscRelease) + mergeJscDebugNativeLibs.mustRunAfter(externalNativeBuildHermesDebug) + mergeJscReleaseNativeLibs.mustRunAfter(externalNativeBuildHermesRelease) + } } diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java index 1657cdc08894fb..cb00882bbed8fb 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java @@ -118,7 +118,7 @@ public List createViewManagers( @Override protected boolean isNewArchEnabled() { - return true; + return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; } @Override @@ -132,7 +132,9 @@ public void onCreate() { ReactFontManager.getInstance().addCustomFont(this, "Rubik", R.font.rubik); super.onCreate(); SoLoader.init(this, /* native exopackage */ false); - DefaultNewArchitectureEntryPoint.load(); + if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { + DefaultNewArchitectureEntryPoint.load(); + } ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); }