From 6a4df5c9be18996954dbe88a97e15826bf051660 Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Fri, 21 Aug 2020 14:56:29 -0700 Subject: [PATCH] Re-add changes to RNTester Summary: D23034761 (https://github.com/facebook/react-native/commit/63992c0b96ec45e4dfb37eaea8535c06833ab298) had a bad rebase and we lost some changes from the past week. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D23249804 fbshipit-source-id: 7433e1b7673bb6ec8c10fd33a34e94b0998b06d6 --- packages/rn-tester/android/app/build.gradle | 31 ++++++++++++------- .../react/uiapp/RNTesterApplication.java | 4 +-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/packages/rn-tester/android/app/build.gradle b/packages/rn-tester/android/app/build.gradle index 38df57f3c66..3bad38b8dc3 100644 --- a/packages/rn-tester/android/app/build.gradle +++ b/packages/rn-tester/android/app/build.gradle @@ -66,8 +66,8 @@ plugins { * // Root dir for all JS files for the app. Defaults to `root` above. * jsRootDir: "../..", * - * // Enable react-native-codegen during build time. - * enableCodegen: true, + * // Enable Fabric at build time and runtime. + * enableFabric: true, * * // Java package name to use for any codegen artifacts produced during build time. * // Defaults to "com.facebook.fbreact.specs". @@ -85,7 +85,7 @@ project.ext.react = [ hermesCommand: "$rootDir/node_modules/hermes-engine/%OS-BIN%/hermesc", enableHermesForVariant: { def v -> v.name.contains("hermes") }, jsRootDir: "$rootDir/RNTester", - enableCodegen: System.getenv('USE_CODEGEN'), + enableFabric: (System.getenv('USE_FABRIC') ?: '0').toBoolean(), ] apply from: "../../../../react.gradle" @@ -106,6 +106,11 @@ def enableSeparateBuildPerCPUArchitecture = true */ def enableProguardInReleaseBuilds = true +/** + * Build and enable Fabric in RN Tester app. + */ +def enableFabric = project.ext.react.enableFabric + /** * Use the international variant of JavaScriptCore * This variant includes the ICU i18n library to make APIs like `Date.toLocaleString` @@ -121,7 +126,9 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - + dexOptions { + javaMaxHeapSize "4g" + } flavorDimensions "vm" productFlavors { hermes { @@ -130,10 +137,6 @@ android { jsc { dimension "vm" } - fabric { - // TODO T71370706 - Create a different dimension to build fabric - dimension "vm" - } } defaultConfig { @@ -144,6 +147,7 @@ android { versionName "1.0" testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' + buildConfigField("boolean", "ENABLE_FABRIC", "$enableFabric") } signingConfigs { release { @@ -178,8 +182,6 @@ android { configurations { hermesDebugImplementation {} hermesReleaseImplementation {} - fabricDebugImplementation {} - fabricReleaseImplementation {} } dependencies { @@ -192,9 +194,7 @@ dependencies { def hermesPath = '$projectDir/../../../../../node_modules/hermes-engine/android/' hermesDebugImplementation files(hermesPath + "hermes-debug.aar") - fabricDebugImplementation files(hermesPath + "hermes-debug.aar") hermesReleaseImplementation files(hermesPath + "hermes-release.aar") - fabricReleaseImplementation files(hermesPath + "hermes-release.aar") debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group:'com.facebook.fbjni' @@ -218,3 +218,10 @@ dependencies { androidTestImplementation('com.wix:detox:+') { transitive = true } androidTestImplementation 'junit:junit:4.12' } + +react { + enableCodegen = System.getenv("USE_CODEGEN") ?: false + jsRootDir = file("$rootDir/packages/rn-tester") + reactNativeRootDir = file("$rootDir") + useJavaGenerator = System.getenv("USE_CODEGEN_JAVAPOET") ?: false +} 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 a225306ddf1..e9a946ee224 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 @@ -7,7 +7,7 @@ package com.facebook.react.uiapp; -import static com.facebook.react.uiapp.BuildConfig.FLAVOR; +import static com.facebook.react.uiapp.BuildConfig.ENABLE_FABRIC; import android.app.Application; import android.content.Context; @@ -38,7 +38,7 @@ import java.util.List; public class RNTesterApplication extends Application implements ReactApplication { - static final boolean IS_FABRIC_ENABLED = FLAVOR.contains("fabric"); + static final boolean IS_FABRIC_ENABLED = ENABLE_FABRIC; private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {