-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
117 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# For more information about using CMake with Android Studio, read the | ||
# documentation: https://d.android.com/studio/projects/add-native-code.html | ||
|
||
# Sets the minimum version of CMake required to build the native library. | ||
|
||
cmake_minimum_required(VERSION 3.4.1) | ||
|
||
# Creates and names a library, sets it as either STATIC | ||
# or SHARED, and provides the relative paths to its source code. | ||
# You can define multiple libraries, and CMake builds them for you. | ||
# Gradle automatically packages shared libraries with your APK. | ||
|
||
# Needed to locate double-conversion src correctly for folly includes | ||
|
||
include_directories( | ||
../../node_modules/react-native/React | ||
../../node_modules/react-native/React/Base | ||
../../node_modules/react-native/ReactCommon/jsi | ||
../../ios/Pods/Folly | ||
../../ios/Pods/DoubleConversion | ||
../../ios/Pods/boost-for-react-native | ||
../../ios/Pods/glog/src | ||
) | ||
|
||
add_definitions( | ||
-DFOLLY_USE_LIBCPP=1 | ||
-DFOLLY_NO_CONFIG=1 | ||
-DFOLLY_HAVE_MEMRCHR=1 | ||
) | ||
|
||
add_library( # Sets the name of the library. | ||
cpp_module_jni | ||
|
||
# Sets the library as a shared library. | ||
SHARED | ||
|
||
# Provides a relative path to your source file(s). | ||
../../node_modules/react-native/ReactCommon/jsi/jsi/jsi.cpp | ||
../src/Test.cpp | ||
TestBinding.cpp | ||
jni.cpp) | ||
|
||
target_link_libraries(cpp_module_jni | ||
android | ||
log) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <jni.h> | ||
#include <jsi/jsi.h> | ||
#include "TestBinding.h" | ||
|
||
extern "C" | ||
{ | ||
JNIEXPORT void JNICALL | ||
Java_com_reactnativecppdemo_MainActivity_install(JNIEnv* env, jobject thiz, jlong runtimePtr) | ||
{ | ||
auto test = std::make_unique<example::Test>(); | ||
auto testBinding = std::make_shared<example::TestBinding>(std::move(test)); | ||
jsi::Runtime* runtime = (jsi::Runtime*)runtimePtr; | ||
|
||
example::TestBinding::install(*runtime, testBinding); | ||
} | ||
} |