Skip to content

Commit

Permalink
chore: android setup
Browse files Browse the repository at this point in the history
  • Loading branch information
anday013 committed Aug 5, 2024
1 parent 647cab5 commit 3e8fb2f
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 50 deletions.
24 changes: 17 additions & 7 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@ cmake_minimum_required(VERSION 3.4.1)
project(BcryptCpp)

set (CMAKE_VERBOSE_MAKEFILE ON)
set (CMAKE_CXX_STANDARD 14)

add_library(react-native-bcrypt-cpp SHARED
../cpp/react-native-bcrypt-cpp.cpp
cpp-adapter.cpp
add_compile_options(
-fexceptions
-frtti
-std=c++17
)

# Specifies a path to native header files.
include_directories(
../cpp
add_library(react-native-bcrypt-cpp STATIC
../cpp/NativeBcryptCppTurboModule.cpp
)

target_include_directories(react-native-bcrypt-cpp
PUBLIC
../cpp
)

target_link_libraries(react-native-bcrypt-cpp
jsi
react_nativemodule_core
react_codegen_RNBcryptCppSpec
)
3 changes: 0 additions & 3 deletions android/src/main/AndroidManifest.xml

This file was deleted.

2 changes: 0 additions & 2 deletions android/src/main/AndroidManifestNew.xml

This file was deleted.

23 changes: 0 additions & 23 deletions android/src/main/java/com/bcryptcpp/BcryptCppModule.kt

This file was deleted.

18 changes: 3 additions & 15 deletions android/src/main/java/com/bcryptcpp/BcryptCppPackage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,17 @@ import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.model.ReactModuleInfo
import com.facebook.react.module.model.ReactModuleInfoProvider
import java.util.Collections
import java.util.HashMap

class BcryptCppPackage : TurboReactPackage() {
class CryptoCppPackage : TurboReactPackage() {
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
return if (name == BcryptCppModule.NAME) {
BcryptCppModule(reactContext)
} else {
null
}
return null;
}

override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
return ReactModuleInfoProvider {
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
moduleInfos[BcryptCppModule.NAME] = ReactModuleInfo(
BcryptCppModule.NAME,
BcryptCppModule.NAME,
false, // canOverrideExistingModule
false, // needsEagerInit
true, // hasConstants
false, // isCxxModule
true // isTurboModule
)
moduleInfos
}
}
Expand Down
4 changes: 4 additions & 0 deletions cpp/NativeBcryptCppTurboModule.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#if __has_include(<React-Codegen/RNBcryptCppSpecJSI.h>)
#include <React-Codegen/RNBcryptCppSpecJSI.h>
#elif __has_include("RNBcryptCppSpecJSI.h")
#include "RNBcryptCppSpecJSI.h"
#endif


namespace facebook::react {
Expand Down
11 changes: 11 additions & 0 deletions react-native.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
dependency: {
platforms: {
android: {
cxxModuleCMakeListsModuleName: 'react-native-bcrypt-cpp',
cxxModuleCMakeListsPath: 'CMakeLists.txt',
cxxModuleHeaderName: 'NativeBcryptCppTurboModule',
},
},
},
};

0 comments on commit 3e8fb2f

Please sign in to comment.