Skip to content

Commit

Permalink
Introduce new BuildConfig to determine if the new architecture is ful…
Browse files Browse the repository at this point in the history
…ly enabled into an Android app (#49283)

Summary:
Pull Request resolved: #49283

In this diff I'm introducing a new BuildConfig called UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE to determine if the new architecture is fully enabled into an Android app at build time, fully enabled means:
- no interop
- all view managers migrated to new API
- all native modules migrated to new API
- legacy architecture can be stripped

This BuildConfig is different from ReactNativeFeatureFlags.enableBridgelessArchitecture() because the latter is controlled at runtime, BuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE is used at the build system level and it can be accessed from proguard to optimize code that's unused when the app is fully running in the new architecture. Additionally we will use the BuildConfig to assert that some classes and methods are not loaded or executed.

changelog: [Android][Changed] Introduces BuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE to determine if the new architecture is fully enabled into an Android app

Reviewed By: cortinico

Differential Revision: D69206248

fbshipit-source-id: f60a059be8333d3051eb7d2efac79939a479f6f8
  • Loading branch information
mdvacca authored and facebook-github-bot committed Feb 9, 2025
1 parent 7b7c450 commit b45a3e5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -1874,6 +1874,7 @@ public final class com/facebook/react/common/build/ReactBuildConfig {
public static final field INSTANCE Lcom/facebook/react/common/build/ReactBuildConfig;
public static final field IS_INTERNAL_BUILD Z
public static final field UNSTABLE_ENABLE_FUSEBOX_RELEASE Z
public static final field UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE Z
}

public abstract interface class com/facebook/react/common/mapbuffer/MapBuffer : java/lang/Iterable, kotlin/jvm/internal/markers/KMappedMarker {
Expand Down
1 change: 1 addition & 0 deletions packages/react-native/ReactAndroid/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ android {
buildConfigField("int", "EXOPACKAGE_FLAGS", "0")
buildConfigField("boolean", "UNSTABLE_ENABLE_FUSEBOX_RELEASE", "false")
buildConfigField("boolean", "ENABLE_PERFETTO", "false")
buildConfigField("boolean", "UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE", "false")

resValue("integer", "react_native_dev_server_port", reactNativeDevServerPort())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ public object ReactBuildConfig {
/** [Experimental] Enable React Native DevTools in release builds. */
@JvmField
public val UNSTABLE_ENABLE_FUSEBOX_RELEASE: Boolean = BuildConfig.UNSTABLE_ENABLE_FUSEBOX_RELEASE

@JvmField
public val UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE: Boolean =
BuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE
}

0 comments on commit b45a3e5

Please sign in to comment.