Skip to content

Commit

Permalink
feat: added linux ARM64 support (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerson authored Feb 23, 2023
1 parent accda50 commit 3a57800
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.5.6

- Added support to linux ARM64 devices

## 3.5.5

- Removed Hover support
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.5.5"
version: "3.5.6"
ffi:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion example/test/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:fast_rsa/fast_rsa.dart';

void main() {
test('Generate Keypair', () async {
var keyPair = await RSA.generate(2048);
var keyPair = await RSA.generate(1024);
print(keyPair.privateKey);
expect(keyPair.publicKey != "", true);
});
Expand Down
34 changes: 24 additions & 10 deletions lib/bridge/binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:fast_rsa/fast_rsa.dart';
import 'package:ffi/ffi.dart';
import 'package:fast_rsa/bridge/ffi.dart';
import 'package:fast_rsa/bridge/isolate.dart';
import 'package:flutter/foundation.dart';
import 'package:path/path.dart' as Path;

class Binding {
Expand Down Expand Up @@ -112,13 +113,23 @@ class Binding {
Platform.isIOS;
}

void validateTestFFIFile(String path) {
if (!File(path).existsSync()) {
debugPrint('dynamic library not found: $path');
throw Exception(
'''In order to be able to run unit tests, you need to run the project first: "flutter run -d ${Platform.operatingSystem}"''');
}
}

ffi.DynamicLibrary openLib() {
var isFlutterTest = Platform.environment.containsKey('FLUTTER_TEST');

if (Platform.isMacOS || Platform.isIOS) {
if (isFlutterTest) {
return ffi.DynamicLibrary.open('build/macos/Build/Products/Debug'
'/$_packageName/$_packageName.framework/Resources/$_libraryName.dylib');
var ffiFile =
'build/macos/Build/Products/Debug/$_packageName/$_packageName.framework/Resources/$_libraryName.dylib';
validateTestFFIFile(ffiFile);
return ffi.DynamicLibrary.open(ffiFile);
}
if (Platform.isMacOS) {
return ffi.DynamicLibrary.open("$_libraryName.dylib");
Expand All @@ -130,11 +141,12 @@ class Binding {

if (Platform.isAndroid || Platform.isLinux) {
if (isFlutterTest) {
var arch = Platform.resolvedExecutable.contains("linux-arm64")
? "arm64"
: "x64";
return ffi.DynamicLibrary.open(
'build/linux/$arch/debug/bundle/lib/$_libraryName.so');
var arch =
Platform.resolvedExecutable.contains("linux-x64") ? "x64" : "arm64";

var ffiFile = 'build/linux/$arch/debug/bundle/lib/$_libraryName.so';
validateTestFFIFile(ffiFile);
return ffi.DynamicLibrary.open(ffiFile);
}

if (Platform.isLinux) {
Expand All @@ -144,7 +156,7 @@ class Binding {
print(e);
var binary = File("/proc/self/cmdline").readAsStringSync();
var suggestedFile =
Path.join(Path.dirname(binary), "lib", "$_libraryName.so");
Path.join(Path.dirname(binary), "lib", "$_libraryName.so");
return ffi.DynamicLibrary.open(suggestedFile);
}
}
Expand All @@ -169,8 +181,10 @@ class Binding {

if (Platform.isWindows) {
if (isFlutterTest) {
return ffi.DynamicLibrary.open(Path.canonicalize(
Path.join(r'build\windows\runner\Debug', '$_libraryName.dll')));
var ffiFile = Path.canonicalize(
Path.join(r'build\windows\runner\Debug', '$_libraryName.dll'));
validateTestFFIFile(ffiFile);
return ffi.DynamicLibrary.open(ffiFile);
}
return ffi.DynamicLibrary.open("$_libraryName.dll");
}
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: fast_rsa
description: library for use RSA with support for android and ios, macOS, linux, windows and web
version: 3.5.5
version: 3.5.6
homepage: https://github.com/jerson/flutter-rsa

environment:
Expand Down
2 changes: 1 addition & 1 deletion scripts/upgrade_bridge_libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
REPO="jerson/rsa-mobile"
NAME="librsa_bridge"
PLATFORMS=("android" "darwin" "ios" "wasm" "linux" "linux" "windows")
OUTPUT_DIRS=("android/src/main" "macos" "ios" "lib/web/assets" "linux/shared/x86_64" "linux/shared/arm64" "windows/shared")
OUTPUT_DIRS=("android/src/main" "macos" "ios" "lib/web/assets" "linux/shared/x86_64" "linux/shared/aarch64" "windows/shared")
OUTPUT_SUB_DIRS=("" "" "" "" "./amd64" "./arm64" "./amd64")
OUTPUT_STRIP_DIRS=(1 1 1 1 2 2 2)

Expand Down

0 comments on commit 3a57800

Please sign in to comment.