mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Currently we expose native code (.h, .cpp) inside the src/main/java folder. This is making impossible for users on New Architecture to open the project inside Android Studio. The problem is that the src/main/java is reserved to Java/Kotlin sources only. AGP 7.2 also removed support for mixed source roots: https://developer.android.com/studio/releases/gradle-plugin#duplicate-content-roots This is essentially forcing users to write Java code without any autocompletion as all the React Native Java classes are considered C++ files. I'm addressing this issue folder by folder by moving them from ReactAndroid/src/main/java/com/facebook/... to ReactAndroid/src/main/jni/react/... This is the diff for turbomodule I've also updated all the internal usages and references to the new path. Changelog: [Internal] [Changed] - Do not store .cpp/.h files inside src/main/java - turbomodule Reviewed By: cipolleschi Differential Revision: D38820638 fbshipit-source-id: febb3f8cef18b30e82c3a4776baa85d0c0d19e4b
36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include <ReactCommon/TurboModulePerfLogger.h>
|
|
#include <fbjni/fbjni.h>
|
|
#include <reactperflogger/JNativeModulePerfLogger.h>
|
|
|
|
#include "CompositeTurboModuleManagerDelegate.h"
|
|
#include "TurboModuleManager.h"
|
|
|
|
void jniEnableCppLogging(
|
|
facebook::jni::alias_ref<jclass> cls,
|
|
facebook::jni::alias_ref<
|
|
facebook::react::JNativeModulePerfLogger::javaobject> perfLogger) {
|
|
facebook::react::TurboModulePerfLogger::enableLogging(
|
|
perfLogger->cthis()->get());
|
|
}
|
|
|
|
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
|
|
return facebook::jni::initialize(vm, [] {
|
|
// TODO: dvacca ramanpreet unify this with the way
|
|
// "ComponentDescriptorFactory" is defined in Fabric
|
|
facebook::react::TurboModuleManager::registerNatives();
|
|
|
|
facebook::react::CompositeTurboModuleManagerDelegate::registerNatives();
|
|
|
|
facebook::jni::registerNatives(
|
|
"com/facebook/react/turbomodule/core/TurboModulePerfLogger",
|
|
{makeNativeMethod("jniEnableCppLogging", jniEnableCppLogging)});
|
|
});
|
|
}
|