From 86ffbd0a272703bc143aa2e40d4ffbbccad6dc32 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Mon, 21 Dec 2020 22:41:06 -0800 Subject: [PATCH] RNTester Android: always compile Fabric files Summary: This commit makes both `:ReactAndroid` and `:rn-tester:android:app` always compile in Fabric codegen outputs. However, one may still enable/disable Fabric at runtime by setting `USE_FABRIC` env var (set to 1 or 0, default is 0). Note that we can't register custom components specific to the app, yet, so only the components in react-native github repo is covered by this commit. RNTester doesn't enable Fabric by default yet due to known UI bugs that haven't been addressed yet. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25674311 fbshipit-source-id: 8db660c959319250ebc683c84076677cf6489e94 --- ReactAndroid/build.gradle | 6 ------ ReactAndroid/src/main/jni/react/jni/Android.mk | 5 +---- ReactCommon/jsi/Android.mk | 6 +++--- packages/rn-tester/android/app/build.gradle | 4 ++-- scripts/generate-native-modules-specs-cli.js | 4 +--- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index d5fa04ca000..3b3f973ade2 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -33,11 +33,6 @@ def thirdPartyNdkDir = new File("$buildDir/third-party-ndk") // - glog-0.3.5 def dependenciesPath = System.getenv("REACT_NATIVE_DEPENDENCIES") -// The 'USE_FABRIC' environment variable will build Fabric C++ code into the bundle -// USE_FABRIC=0 will build RN excluding fabric -// USE_FABRIC=1 will build RN including fabric -def enableFabric = (System.getenv('USE_FABRIC') ?: '0').toBoolean() - // The Boost library is a very large download (>100MB). // If Boost is already present on your system, define the REACT_NATIVE_BOOST_PATH env variable // and the build will use that. @@ -318,7 +313,6 @@ def buildReactNdkLib = tasks.register("buildReactNdkLib", Exec) { "REACT_COMMON_DIR=$projectDir/../ReactCommon", "REACT_GENERATED_SRC_DIR=$buildDir/generated/source", "REACT_SRC_DIR=$projectDir/src/main/java/com/facebook/react", - "BUILD_FABRIC=$enableFabric", "-C", file("src/main/jni/react/jni").absolutePath, "--jobs", project.findProperty("jobs") ?: Runtime.runtime.availableProcessors() ) diff --git a/ReactAndroid/src/main/jni/react/jni/Android.mk b/ReactAndroid/src/main/jni/react/jni/Android.mk index 8340d30515c..9831c1aeef2 100644 --- a/ReactAndroid/src/main/jni/react/jni/Android.mk +++ b/ReactAndroid/src/main/jni/react/jni/Android.mk @@ -134,10 +134,7 @@ include $(REACT_SRC_DIR)/reactperflogger/jni/Android.mk # TODO (T48588859): Restructure this target to align with dir structure: "react/nativemodule/..." # Note: Update this only when ready to minimize breaking changes. include $(REACT_SRC_DIR)/turbomodule/core/jni/Android.mk - -ifeq ($(BUILD_FABRIC),true) - include $(REACT_SRC_DIR)/fabric/jni/Android.mk -endif +include $(REACT_SRC_DIR)/fabric/jni/Android.mk # TODO(ramanpreet): # Why doesn't this import-module call generate a jscexecutor.so file? diff --git a/ReactCommon/jsi/Android.mk b/ReactCommon/jsi/Android.mk index 40c7042c16e..6bc98f1b35f 100644 --- a/ReactCommon/jsi/Android.mk +++ b/ReactCommon/jsi/Android.mk @@ -32,8 +32,8 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) LOCAL_CFLAGS := -fexceptions -frtti -O3 LOCAL_SHARED_LIBRARIES := libfolly_json libjsc glog -ifeq ($(BUILD_FABRIC),true) - LOCAL_CFLAGS += -DRN_FABRIC_ENABLED -endif +# TODO: Remove this flag when ready. +# Android has this enabled by default, but the flag is still needed for iOS. +LOCAL_CFLAGS += -DRN_FABRIC_ENABLED include $(BUILD_STATIC_LIBRARY) diff --git a/packages/rn-tester/android/app/build.gradle b/packages/rn-tester/android/app/build.gradle index 13c150cb30d..8855fff3fd2 100644 --- a/packages/rn-tester/android/app/build.gradle +++ b/packages/rn-tester/android/app/build.gradle @@ -66,7 +66,7 @@ plugins { * // Root dir for all JS files for the app. Defaults to `root` above. * jsRootDir: "../..", * - * // Enable Fabric at build time and runtime. + * // Enable Fabric at runtime. * enableFabric: true, * * // Java package name to use for any codegen artifacts produced during build time. @@ -113,7 +113,7 @@ def enableProguardInReleaseBuilds = true def enableCodegen = project.ext.react.enableCodegen /** - * Build and enable Fabric in RN Tester app. + * Enable Fabric in RN Tester app. */ def enableFabric = project.ext.react.enableFabric diff --git a/scripts/generate-native-modules-specs-cli.js b/scripts/generate-native-modules-specs-cli.js index 0412be9340d..600412f3399 100644 --- a/scripts/generate-native-modules-specs-cli.js +++ b/scripts/generate-native-modules-specs-cli.js @@ -26,9 +26,7 @@ const path = require('path'); const USE_FABRIC = process.env.USE_FABRIC != null && !!process.env.USE_FABRIC; const GENERATORS = { - android: USE_FABRIC - ? ['componentsAndroid', 'modulesAndroid'] - : ['modulesAndroid'], + android: ['componentsAndroid', 'modulesAndroid'], ios: ['modulesIOS'], };