Skip to content

Commit 8e42ae9

Browse files
Sunbreaksatya164
authored andcommitted
feat: backport C++ files of new arch view
1 parent da5335e commit 8e42ae9

File tree

5 files changed

+138
-0
lines changed

5 files changed

+138
-0
lines changed

packages/create-react-native-library/src/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ const SWIFT_FILES = {
6565
view_legacy: path.resolve(__dirname, '../templates/swift-view-legacy'),
6666
} as const;
6767

68+
const CPP_VIEW_FILES = {
69+
// view_legacy does NOT need component registration
70+
view_mixed: path.resolve(__dirname, '../templates/cpp-view-mixed'),
71+
view_new: path.resolve(__dirname, '../templates/cpp-view-new'),
72+
} as const;
73+
6874
type ArgName =
6975
| 'slug'
7076
| 'description'
@@ -682,6 +688,12 @@ async function create(argv: yargs.Arguments<any>) {
682688
await copyDir(CPP_FILES, folder);
683689
await fs.remove(path.join(folder, 'ios', `${options.project.name}.m`));
684690
}
691+
692+
if (moduleType === 'view') {
693+
if (arch === 'new' || arch === 'mixed') {
694+
await copyDir(CPP_VIEW_FILES[`${moduleType}_${arch}`], folder);
695+
}
696+
}
685697
}
686698

687699
// Set `react` and `react-native` versions of root `package.json` from example `package.json`
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
THIS_DIR := $(call my-dir)
2+
3+
include $(REACT_ANDROID_DIR)/Android-prebuilt.mk
4+
5+
include ${GENERATED_SRC_DIR}/codegen/jni/Android.mk
6+
7+
include $(CLEAR_VARS)
8+
9+
LOCAL_PATH := $(THIS_DIR)
10+
11+
# Define the library name here.
12+
LOCAL_MODULE := ${CODEGEN_MODULE_NAME}_registration
13+
14+
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
15+
16+
LOCAL_SHARED_LIBRARIES := \
17+
libfabricjni \
18+
libfbjni \
19+
libglog \
20+
libjsi \
21+
libreact_codegen_rncore \
22+
libreact_codegen_${CODEGEN_MODULE_NAME} \
23+
libreact_debug \
24+
libreact_nativemodule_core \
25+
libreact_render_componentregistry \
26+
libreact_render_core \
27+
libreact_render_debug \
28+
libreact_render_graphics \
29+
librrc_view \
30+
libruntimeexecutor \
31+
libturbomodulejsijni \
32+
libyoga
33+
34+
ifneq ($(filter $(call modules-get-list),folly_runtime),)
35+
LOCAL_SHARED_LIBRARIES += libfolly_runtime # since [email protected]
36+
else
37+
LOCAL_SHARED_LIBRARIES += libfolly_futures libfolly_json # [email protected]
38+
endif
39+
40+
LOCAL_CFLAGS := \
41+
-DLOG_TAG=\"ReactNative\" \
42+
-DCODEGEN_COMPONENT_DESCRIPTOR_H="<react/renderer/components/${CODEGEN_MODULE_NAME}/ComponentDescriptors.h>"
43+
LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall
44+
45+
include $(BUILD_SHARED_LIBRARY)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <CoreComponentsRegistry.h>
2+
#include CODEGEN_COMPONENT_DESCRIPTOR_H
3+
4+
namespace facebook {
5+
namespace react {
6+
7+
void registerProviders() {
8+
auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry();
9+
providerRegistry->add(concreteComponentDescriptorProvider<<%- project.name + 'View' -%>ComponentDescriptor>());
10+
}
11+
12+
}
13+
}
14+
15+
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
16+
facebook::react::registerProviders();
17+
return JNI_VERSION_1_6;
18+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
THIS_DIR := $(call my-dir)
2+
3+
include $(REACT_ANDROID_DIR)/Android-prebuilt.mk
4+
5+
include ${GENERATED_SRC_DIR}/codegen/jni/Android.mk
6+
7+
include $(CLEAR_VARS)
8+
9+
LOCAL_PATH := $(THIS_DIR)
10+
11+
# Define the library name here.
12+
LOCAL_MODULE := ${CODEGEN_MODULE_NAME}_registration
13+
14+
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
15+
16+
LOCAL_SHARED_LIBRARIES := \
17+
libfabricjni \
18+
libfbjni \
19+
libglog \
20+
libjsi \
21+
libreact_codegen_rncore \
22+
libreact_codegen_${CODEGEN_MODULE_NAME} \
23+
libreact_debug \
24+
libreact_nativemodule_core \
25+
libreact_render_componentregistry \
26+
libreact_render_core \
27+
libreact_render_debug \
28+
libreact_render_graphics \
29+
librrc_view \
30+
libruntimeexecutor \
31+
libturbomodulejsijni \
32+
libyoga
33+
34+
ifneq ($(filter $(call modules-get-list),folly_runtime),)
35+
LOCAL_SHARED_LIBRARIES += libfolly_runtime # since [email protected]
36+
else
37+
LOCAL_SHARED_LIBRARIES += libfolly_futures libfolly_json # [email protected]
38+
endif
39+
40+
LOCAL_CFLAGS := \
41+
-DLOG_TAG=\"ReactNative\" \
42+
-DCODEGEN_COMPONENT_DESCRIPTOR_H="<react/renderer/components/${CODEGEN_MODULE_NAME}/ComponentDescriptors.h>"
43+
LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall
44+
45+
include $(BUILD_SHARED_LIBRARY)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <CoreComponentsRegistry.h>
2+
#include CODEGEN_COMPONENT_DESCRIPTOR_H
3+
4+
namespace facebook {
5+
namespace react {
6+
7+
void registerProviders() {
8+
auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry();
9+
providerRegistry->add(concreteComponentDescriptorProvider<<%- project.name + 'View' -%>ComponentDescriptor>());
10+
}
11+
12+
}
13+
}
14+
15+
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
16+
facebook::react::registerProviders();
17+
return JNI_VERSION_1_6;
18+
}

0 commit comments

Comments
 (0)