Skip to content

Commit 0e8aa05

Browse files
Add rn-tester Android BUCK configuration (#39987)
Summary: Changelog: [Internal] Differential Revision: D49983211
1 parent 60f5a80 commit 0e8aa05

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

packages/react-native/ReactAndroid/src/main/jni/react/newarchdefaults/DefaultTurboModuleManagerDelegate.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
#include "DefaultTurboModuleManagerDelegate.h"
99

10-
#include <rncore.h>
11-
1210
namespace facebook::react {
1311

1412
std::function<std::shared_ptr<TurboModule>(
@@ -52,7 +50,7 @@ std::shared_ptr<TurboModule> DefaultTurboModuleManagerDelegate::getTurboModule(
5250
return resolvedModule;
5351
}
5452
}
55-
return rncore_ModuleProvider(name, params);
53+
return nullptr;
5654
}
5755

5856
} // namespace facebook::react

packages/rn-tester/android/app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ android {
146146
versionName "1.0"
147147
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
148148
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
149+
buildConfigField("String", "JS_MAIN_MODULE_NAME", "\"\"")
150+
buildConfigField("String", "BUNDLE_ASSET_NAME", "\"\"")
149151
}
150152
externalNativeBuild {
151153
cmake {

packages/rn-tester/android/app/src/main/AndroidManifest.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest
3+
package="com.facebook.react.uiapp"
34
xmlns:android="http://schemas.android.com/apk/res/android">
45

56
<uses-feature
@@ -15,6 +16,10 @@
1516
android:name="android.hardware.camera"
1617
android:required="false" />
1718

19+
<uses-sdk
20+
android:minSdkVersion="23"
21+
android:targetSdkVersion="33" />
22+
1823
<uses-permission android:name="android.permission.INTERNET" />
1924
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
2025
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,15 @@ class RNTesterApplication : Application(), ReactApplication {
4343
throw RuntimeException("Should not use ReactNativeHost when Bridgeless enabled")
4444
}
4545
object : DefaultReactNativeHost(this) {
46-
public override fun getJSMainModuleName(): String = "js/RNTesterApp.android"
46+
public override fun getJSMainModuleName(): String {
47+
return if (BuildConfig.JS_MAIN_MODULE_NAME.isEmpty()) "js/RNTesterApp.android"
48+
else BuildConfig.JS_MAIN_MODULE_NAME
49+
}
4750

48-
public override fun getBundleAssetName(): String = "RNTesterApp.android.bundle"
51+
public override fun getBundleAssetName(): String {
52+
return if (BuildConfig.BUNDLE_ASSET_NAME.isEmpty()) "RNTesterApp.android.bundle"
53+
else BuildConfig.BUNDLE_ASSET_NAME
54+
}
4955

5056
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
5157

packages/rn-tester/android/app/src/main/jni/OnLoad.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
#if RN_DISABLE_OSS_PLUGIN_HEADER
9+
#include <AppSpecs/AppSpecs.h>
10+
#else
811
#include <AppSpecs.h>
12+
#endif
913
#include <DefaultComponentsRegistry.h>
1014
#include <DefaultTurboModuleManagerDelegate.h>
1115
#include <NativeCxxModuleExample.h>
@@ -14,7 +18,11 @@
1418
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
1519
#include <react/renderer/components/AppSpecs/ComponentDescriptors.h>
1620
#include <react/renderer/components/legacyviewmanagerinterop/UnstableLegacyViewManagerInteropComponentDescriptor.h>
21+
#if RN_DISABLE_OSS_PLUGIN_HEADER
22+
#include <RNTesterTurboModuleManagerDelegateProvider/TMProvider.h>
23+
#else
1724
#include <rncore.h>
25+
#endif
1826

1927
namespace facebook {
2028
namespace react {
@@ -33,9 +41,11 @@ void registerComponents(
3341
std::shared_ptr<TurboModule> cxxModuleProvider(
3442
const std::string& name,
3543
const std::shared_ptr<CallInvoker>& jsInvoker) {
44+
#ifndef RN_DISABLE_OSS_PLUGIN_HEADER
3645
if (name == NativeCxxModuleExample::kModuleName) {
3746
return std::make_shared<NativeCxxModuleExample>(jsInvoker);
3847
}
48+
#endif
3949
return nullptr;
4050
}
4151

@@ -50,7 +60,12 @@ std::shared_ptr<TurboModule> javaModuleProvider(
5060
if (module != nullptr) {
5161
return module;
5262
};
63+
#if RN_DISABLE_OSS_PLUGIN_HEADER
64+
return RNTesterTurboModuleManagerDelegateProvider::getTurboModule(
65+
name, params);
66+
#else
5367
return rncore_ModuleProvider(name, params);
68+
#endif
5469
}
5570

5671
} // namespace react

0 commit comments

Comments
 (0)