File tree Expand file tree Collapse file tree 5 files changed +138
-0
lines changed
packages/create-react-native-library Expand file tree Collapse file tree 5 files changed +138
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,12 @@ const SWIFT_FILES = {
65
65
view_legacy : path . resolve ( __dirname , '../templates/swift-view-legacy' ) ,
66
66
} as const ;
67
67
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
+
68
74
type ArgName =
69
75
| 'slug'
70
76
| 'description'
@@ -682,6 +688,12 @@ async function create(argv: yargs.Arguments<any>) {
682
688
await copyDir ( CPP_FILES , folder ) ;
683
689
await fs . remove ( path . join ( folder , 'ios' , `${ options . project . name } .m` ) ) ;
684
690
}
691
+
692
+ if ( moduleType === 'view' ) {
693
+ if ( arch === 'new' || arch === 'mixed' ) {
694
+ await copyDir ( CPP_VIEW_FILES [ `${ moduleType } _${ arch } ` ] , folder ) ;
695
+ }
696
+ }
685
697
}
686
698
687
699
// Set `react` and `react-native` versions of root `package.json` from example `package.json`
Original file line number Diff line number Diff line change
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 )
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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 )
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments