Skip to content

Commit

Permalink
more gha fun, start android build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
boorad committed Aug 11, 2024
1 parent 9938341 commit c6db590
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 54 deletions.
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.name = 'QuickCryptoExample'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
includeBuild('../../node_modules/@react-native/gradle-plugin')
3 changes: 0 additions & 3 deletions example/eslint.config.js

This file was deleted.

23 changes: 23 additions & 0 deletions example/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { fixupPluginRules } from '@eslint/compat';
import js from '@eslint/js';
import eslintReactNative from 'eslint-plugin-react-native';
import typescriptEslint from 'typescript-eslint';

export default typescriptEslint.config(
js.configs.recommended,
...typescriptEslint.configs.recommendedTypeChecked,
// react-native
{
name: 'eslint-plugin-react-native',
plugins: {
'react-native': fixupPluginRules({
rules: eslintReactNative.rules,
}),
},
rules: {
...eslintReactNative.configs.all.rules,
'react-native/sort-styles': 'off',
'react-native/no-inline-styles': 'warn',
},
},
);
1 change: 1 addition & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@babel/plugin-transform-class-static-block": "7.24.7",
"@babel/preset-env": "7.25.3",
"@babel/runtime": "7.25.0",
"@eslint/compat": "^1.1.1",
"@react-native/babel-preset": "0.74.86",
"@react-native/eslint-config": "0.74.86",
"@react-native/eslint-plugin": "0.74.86",
Expand Down
35 changes: 7 additions & 28 deletions packages/react-native-quick-crypto/android/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,49 +1,28 @@
project(QuickCrypto)
cmake_minimum_required(VERSION 3.10.2)
cmake_minimum_required(VERSION 3.9.0)

set(PACKAGE_NAME "QuickCrypto")
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)

# set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
# set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
# Add Nitrogen specs :)
include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NitroImage+autolinking.cmake)

# Third party libraries (Prefabs)
find_package(fbjni REQUIRED CONFIG)
find_package(ReactAndroid REQUIRED CONFIG)
find_package(openssl REQUIRED CONFIG)
find_library(LOG_LIB log)

add_library(
${PACKAGE_NAME}
SHARED
"src/main/cpp/cpp-adapter.cpp"
"../cpp/HybridRandom.cpp"
)

target_include_directories(
${PACKAGE_NAME}
PRIVATE
"../cpp"
"src/main/cpp"
"${NODE_MODULES_DIR}/react-native/ReactCommon"
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/react/turbomodule"
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
"${NODE_MODULES_DIR}/react-native/ReactCommon/turbomodule/core"
"${NODE_MODULES_DIR}/react-native/ReactCommon/react/nativemodule/core"
)

#file(GLOB LIBRN_DIR "${BUILD_DIR}/react-native-0*/jni/${ANDROID_ABI}")

# Link all libraries together
target_link_libraries(
${PACKAGE_NAME}
ReactAndroid::turbomodulejsijni
fbjni::fbjni # <-- fbjni
${LOG_LIB} # <-- Logcat logger
ReactAndroid::jsi # <-- RN: JSI
ReactAndroid::reactnativejni # <-- RN: React Native JNI bindings
ReactAndroid::react_nativemodule_core # <-- RN: React Native native module core
android # <-- Android JNI core
android # <-- Android core
openssl::crypto # <-- OpenSSL (Crypto)
)
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
#include <fbjni/fbjni.h>
#include <jni.h>

using namespace facebook;
#include "HybridRandom.hpp"
#include <NitroModules/HybridObjectRegistry.hpp>

class CryptoCppAdapter : public jni::HybridClass<CryptoCppAdapter> {
public:
static auto constexpr kJavaDescriptor = "Lcom/margelo/quickcrypto/QuickCryptoModule;";

static jni::local_ref<jni::HybridClass<CryptoCppAdapter>::jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis) {
return makeCxxInstance();
}

CryptoCppAdapter() {}

static void registerNatives() {
registerHybrid(
{makeNativeMethod("initHybrid", CryptoCppAdapter::initHybrid), makeNativeMethod("nativeInstall", CryptoCppAdapter::nativeInstall)});
}

private:
friend HybridBase;
};
using namespace margelo::nitro::crypto;

JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
return facebook::jni::initialize(vm, [] { CryptoCppAdapter::registerNatives(); });
HybridObjectRegistry::registerHybridObjectConstructor(
"Random", []() -> std::shared_ptr<HybridObject> { return std::make_shared<HybridRandom>(); });

return JNI_VERSION_1_2;
}

0 comments on commit c6db590

Please sign in to comment.