Skip to content

Commit

Permalink
Do not store .cpp/.h files inside src/main/java - turbomodule - take 2
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cortinico authored and facebook-github-bot committed Aug 18, 2022
1 parent 33bd2f6 commit ba2dae3
Show file tree
Hide file tree
Showing 14 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ReactAndroid/cmake-utils/Android-prebuilt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ set_target_properties(turbomodulejsijni
${REACT_NDK_EXPORT_DIR}/${ANDROID_ABI}/libturbomodulejsijni.so)
target_include_directories(turbomodulejsijni
INTERFACE
${REACT_ANDROID_SRC_DIR}/java/com/facebook/react/turbomodule/core/jni)
${REACT_ANDROID_SRC_DIR}/jni/react/turbomodule)

## react_render_core
add_library(react_render_core SHARED IMPORTED GLOBAL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ rn_android_library(
react_native_dep("third-party/java/jsr-305:jsr-305"),
react_native_target("java/com/facebook/react/common:common"),
react_native_target("java/com/facebook/react/reactperflogger:reactperflogger"),
react_native_target("java/com/facebook/react/turbomodule/core/jni:jni"),
react_native_target("java/com/facebook/debug/holder:holder"),
react_native_target("java/com/facebook/react/bridge:interfaces"),
react_native_target("java/com/facebook/react/bridge:bridge"),
react_native_target("java/com/facebook/react/config:config"),
react_native_target("java/com/facebook/react/module/model:model"),
react_native_target("jni/react/turbomodule:jni"),
":callinvokerholder",
],
exported_deps = [
Expand Down
2 changes: 1 addition & 1 deletion ReactAndroid/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ add_react_android_subdir(src/main/jni/first-party/yogajni)
add_react_android_subdir(src/main/jni/react/jni)
add_react_android_subdir(src/main/jni/react/reactperflogger)
add_react_android_subdir(src/main/jni/react/jscexecutor)
add_react_android_subdir(src/main/java/com/facebook/react/turbomodule/core/jni)
add_react_android_subdir(src/main/jni/react/turbomodule)
add_react_android_subdir(src/main/jni/react/uimanager)
add_react_android_subdir(src/main/jni/react/mapbuffer)
add_react_android_subdir(src/main/jni/react/reactnativeblob)
Expand Down
2 changes: 1 addition & 1 deletion ReactAndroid/src/main/jni/react/jni/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ rn_xplat_cxx_library(
"//xplat/folly:json",
"//fbandroid/xplat/fbgloginit:fbgloginit",
"//xplat/fbsystrace:fbsystrace",
react_native_target("java/com/facebook/react/turbomodule/core/jni:callinvokerholder"),
react_native_target("jni/react/turbomodule:callinvokerholder"),
react_native_xplat_target("cxxreact:bridge"),
react_native_xplat_target("cxxreact:jsbigstring"),
react_native_xplat_target("cxxreact:module"),
Expand Down

0 comments on commit ba2dae3

Please sign in to comment.