Skip to content

Commit

Permalink
Do not store C++ sources inside src/main/java
Browse files Browse the repository at this point in the history
  • Loading branch information
cortinico committed Aug 3, 2022
1 parent 2fa04be commit 4e9d46a
Show file tree
Hide file tree
Showing 81 changed files with 96 additions and 109 deletions.
3 changes: 1 addition & 2 deletions ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,9 @@ android {
preBuild.dependsOn("generateCodegenArtifactsFromSchema")

sourceSets.main {
jni.srcDirs = []
res.srcDirs = ["src/main/res/devsupport", "src/main/res/shell", "src/main/res/views/modal", "src/main/res/views/uimanager"]
java {
srcDirs = ["src/main/java", "src/main/libraries/soloader/java", "src/main/jni/first-party/fb/jni/java"]
srcDirs += ["src/main/java", "src/main/libraries/soloader/java", "src/main/jni/first-party/fb/jni/java"]
exclude("com/facebook/react/processing")
exclude("com/facebook/react/module/processing")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,3 @@ rn_android_library(
":jni_hermes_samplingprofiler",
],
)

rn_xplat_cxx_library(
name = "jni_hermes_samplingprofiler",
srcs = [
"HermesSamplingProfiler.cpp",
"OnLoad.cpp",
],
headers = ["HermesSamplingProfiler.h"],
header_namespace = "",
compiler_flags_enable_exceptions = True, # TODO: is this necessary?
compiler_flags_enable_rtti = True, # TODO: is this necessary?
fbandroid_allow_jni_merging = True,
labels = [
"pfh:ReactNative_CommonInfrastructurePlaceholder",
"supermodule:xplat/default/public.react_native.infra",
],
platforms = ANDROID,
soname = "libjsijniprofiler.$(ext)",
visibility = [
react_native_dep("java/com/facebook/jsi:jsi"),
],
deps = [
react_native_target("jni/react/jni:jni"),
FBJNI_TARGET,
react_native_xplat_dep("hermes/API:HermesAPI"),
],
)
20 changes: 0 additions & 20 deletions ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,3 @@ rn_android_library(
react_native_target("java/com/facebook/hermes/instrumentation:instrumentation"),
],
)

rn_xplat_cxx_library(
name = "jni-interface",
srcs = [],
header_namespace = "hermes/reactexecutor",
exported_headers = glob(["*.h"]),
visibility = ["PUBLIC"],
)

rn_xplat_cxx_library(
name = "jni",
srcs = ["OnLoad.cpp"],
headers = [],
header_namespace = "",
compiler_flags = ["-fexceptions"],
soname = "libhermes-executor.$(ext)",
visibility = [
react_native_target("java/com/facebook/hermes/reactexecutor:reactexecutor"),
],
)
22 changes: 0 additions & 22 deletions ReactAndroid/src/main/java/com/facebook/react/jscexecutor/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,3 @@ rn_android_library(
react_native_target("java/com/facebook/react/bridge:bridge"),
],
)

rn_xplat_cxx_library(
name = "jni",
srcs = glob(["*.cpp"]),
headers = glob(["*.h"]),
header_namespace = "",
compiler_flags_enable_exceptions = True, # TODO: is this necessary?
compiler_flags_enable_rtti = True, # TODO: is this necessary?
fbandroid_allow_jni_merging = True,
platforms = ANDROID,
soname = "libjscexecutor.$(ext)",
visibility = [
react_native_target("java/com/facebook/react/jscexecutor:jscexecutor"),
],
deps = [
"//xplat/folly:molly",
FBJNI_TARGET,
react_native_target("jni/react/jni:jni"),
react_native_xplat_target("jsi:JSCRuntime"),
react_native_xplat_target("jsiexecutor:jsiexecutor"),
],
)
18 changes: 9 additions & 9 deletions ReactAndroid/src/main/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,18 @@ add_react_common_subdir(react/nativemodule/core)

# ReactAndroid JNI targets
add_react_build_subdir(generated/source/codegen/jni)
add_react_android_subdir(src/main/java/com/facebook/hermes/reactexecutor)
add_react_android_subdir(src/main/jni/first-party/fbjni)
add_react_android_subdir(src/main/jni/first-party/fb)
add_react_android_subdir(src/main/jni/first-party/fbgloginit)
add_react_android_subdir(src/main/jni/first-party/yogajni)
add_react_android_subdir(src/main/jni/react/fabricjni)
add_react_android_subdir(src/main/jni/react/hermes/reactexecutor)
add_react_android_subdir(src/main/jni/react/hermes/instrumentation)
add_react_android_subdir(src/main/jni/react/jscexecutor)
add_react_android_subdir(src/main/jni/react/mapbuffer)
add_react_android_subdir(src/main/jni/react/reactperflogger)
add_react_android_subdir(src/main/jni/react/reactnativeblob)
add_react_android_subdir(src/main/jni/react/jni)
add_react_android_subdir(src/main/java/com/facebook/react/reactperflogger/jni)
add_react_android_subdir(src/main/java/com/facebook/react/jscexecutor)
add_react_android_subdir(src/main/java/com/facebook/react/turbomodule/core/jni)
add_react_android_subdir(src/main/java/com/facebook/react/uimanager/jni)
add_react_android_subdir(src/main/java/com/facebook/react/common/mapbuffer/jni)
add_react_android_subdir(src/main/java/com/facebook/react/fabric/jni)
add_react_android_subdir(src/main/java/com/facebook/react/modules/blob/jni)
add_react_android_subdir(src/main/java/com/facebook/hermes/instrumentation/)
add_react_android_subdir(src/main/jni/react/turbomodule)
add_react_android_subdir(src/main/jni/react/uimanager)

Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,6 @@ void Binding::installFabricUIManager(
"MapBufferSerializationEnabled",
getFeatureFlagValue("mapBufferSerializationEnabled"));

contextContainer->insert(
"CalculateTransformedFramesEnabled",
getFeatureFlagValue("calculateTransformedFramesEnabled"));

disablePreallocateViews_ = reactNativeConfig_->getBool(
"react_fabric:disabled_view_preallocation_android");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ CppMountItem CppMountItem::UpdatePropsMountItem(
CppMountItem CppMountItem::UpdateStateMountItem(ShadowView const &shadowView) {
return {CppMountItem::Type::UpdateState, {}, {}, shadowView, -1};
}
CppMountItem CppMountItem::UpdateLayoutMountItem(
ShadowView const &shadowView,
ShadowView const &parentView) {
return {CppMountItem::Type::UpdateLayout, parentView, {}, shadowView, -1};
CppMountItem CppMountItem::UpdateLayoutMountItem(ShadowView const &shadowView) {
return {CppMountItem::Type::UpdateLayout, {}, {}, shadowView, -1};
}
CppMountItem CppMountItem::UpdateEventEmitterMountItem(
ShadowView const &shadowView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ struct CppMountItem final {

static CppMountItem UpdateStateMountItem(ShadowView const &shadowView);

static CppMountItem UpdateLayoutMountItem(
ShadowView const &shadowView,
ShadowView const &parentView);
static CppMountItem UpdateLayoutMountItem(ShadowView const &shadowView);

static CppMountItem UpdateEventEmitterMountItem(ShadowView const &shadowView);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static inline int getIntBufferSizeForType(CppMountItem::Type mountItemType) {
case CppMountItem::Type::UpdatePadding:
return 5; // tag, top, left, bottom, right
case CppMountItem::Type::UpdateLayout:
return 7; // tag, parentTag, x, y, w, h, DisplayType
return 6; // tag, x, y, w, h, DisplayType
case CppMountItem::Type::UpdateOverflowInset:
return 5; // tag, left, top, right, bottom
case CppMountItem::Undefined:
Expand Down Expand Up @@ -381,7 +381,7 @@ void FabricMountingManager::executeMount(
newChildShadowView.layoutMetrics) {
cppUpdateLayoutMountItems.push_back(
CppMountItem::UpdateLayoutMountItem(
mutation.newChildShadowView, parentShadowView));
mutation.newChildShadowView));
}

// OverflowInset: This is the values indicating boundaries including
Expand Down Expand Up @@ -441,8 +441,7 @@ void FabricMountingManager::executeMount(

// Layout
cppUpdateLayoutMountItems.push_back(
CppMountItem::UpdateLayoutMountItem(
newChildShadowView, parentShadowView));
CppMountItem::UpdateLayoutMountItem(newChildShadowView));

// OverflowInset: This is the values indicating boundaries including
// children of the current view. The layout of current view may not
Expand Down Expand Up @@ -549,7 +548,7 @@ void FabricMountingManager::executeMount(
int intBufferPosition = 0;
int objBufferPosition = 0;
int prevMountItemType = -1;
jint temp[7];
jint temp[6];
for (int i = 0; i < cppCommonMountItems.size(); i++) {
const auto &mountItem = cppCommonMountItems[i];
const auto &mountItemType = mountItem.type;
Expand Down Expand Up @@ -724,14 +723,13 @@ void FabricMountingManager::executeMount(
toInt(mountItem.newChildShadowView.layoutMetrics.displayType);

temp[0] = mountItem.newChildShadowView.tag;
temp[1] = mountItem.parentShadowView.tag;
temp[2] = x;
temp[3] = y;
temp[4] = w;
temp[5] = h;
temp[6] = displayType;
env->SetIntArrayRegion(intBufferArray, intBufferPosition, 7, temp);
intBufferPosition += 7;
temp[1] = x;
temp[2] = y;
temp[3] = w;
temp[4] = h;
temp[5] = displayType;
env->SetIntArrayRegion(intBufferArray, intBufferPosition, 6, temp);
intBufferPosition += 6;
}
}
if (!cppUpdateOverflowInsetMountItems.empty()) {
Expand Down
28 changes: 28 additions & 0 deletions ReactAndroid/src/main/jni/react/hermes/instrumentation/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "FBJNI_TARGET", "react_native_dep", "react_native_target", "react_native_xplat_dep", "rn_xplat_cxx_library")

rn_xplat_cxx_library(
name = "jni_hermes_samplingprofiler",
srcs = [
"HermesSamplingProfiler.cpp",
"OnLoad.cpp",
],
headers = ["HermesSamplingProfiler.h"],
header_namespace = "",
compiler_flags_enable_exceptions = True, # TODO: is this necessary?
compiler_flags_enable_rtti = True, # TODO: is this necessary?
fbandroid_allow_jni_merging = True,
labels = [
"pfh:ReactNative_CommonInfrastructurePlaceholder",
"supermodule:xplat/default/public.react_native.infra",
],
platforms = ANDROID,
soname = "libjsijniprofiler.$(ext)",
visibility = [
react_native_dep("java/com/facebook/jsi:jsi"),
],
deps = [
react_native_target("jni/react/jni:jni"),
FBJNI_TARGET,
react_native_xplat_dep("hermes/API:HermesAPI"),
],
)
21 changes: 21 additions & 0 deletions ReactAndroid/src/main/jni/react/hermes/reactexecutor/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_target", "rn_android_library", "rn_xplat_cxx_library")

rn_xplat_cxx_library(
name = "jni-interface",
srcs = [],
header_namespace = "hermes/reactexecutor",
exported_headers = glob(["*.h"]),
visibility = ["PUBLIC"],
)

rn_xplat_cxx_library(
name = "jni",
srcs = ["OnLoad.cpp"],
headers = [],
header_namespace = "",
compiler_flags = ["-fexceptions"],
soname = "libhermes-executor.$(ext)",
visibility = [
react_native_target("java/com/facebook/hermes/reactexecutor:reactexecutor"),
],
)
5 changes: 0 additions & 5 deletions ReactAndroid/src/main/jni/react/jni/.clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
---
Checks: '>
clang-diagnostic-*,
'
...
23 changes: 23 additions & 0 deletions ReactAndroid/src/main/jni/react/jscexecutor/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "FBJNI_TARGET", "react_native_dep", "react_native_target", "react_native_xplat_target", "rn_android_library", "rn_xplat_cxx_library")

rn_xplat_cxx_library(
name = "jni",
srcs = glob(["*.cpp"]),
headers = glob(["*.h"]),
header_namespace = "",
compiler_flags_enable_exceptions = True, # TODO: is this necessary?
compiler_flags_enable_rtti = True, # TODO: is this necessary?
fbandroid_allow_jni_merging = True,
platforms = ANDROID,
soname = "libjscexecutor.$(ext)",
visibility = [
react_native_target("java/com/facebook/react/jscexecutor:jscexecutor"),
],
deps = [
"//xplat/folly:molly",
FBJNI_TARGET,
react_native_target("jni/react/jni:jni"),
react_native_xplat_target("jsi:JSCRuntime"),
react_native_xplat_target("jsiexecutor:jsiexecutor"),
],
)

0 comments on commit 4e9d46a

Please sign in to comment.