Skip to content

Commit 27a6917

Browse files
committed
add theoretical support for the desktop platforms
1 parent a559c6f commit 27a6917

File tree

7 files changed

+57
-7
lines changed

7 files changed

+57
-7
lines changed

.idea/workspace.xml

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dargon2_flutter/dargon2_flutter_desktop/lib/src/native/desktop_lib_loader.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class DesktopLibLoader implements LibLoader {
3030
/// of a Flutter plugin as macOS is already handled with the .process()
3131
@override
3232
String getPath() =>
33-
Platform.isLinux ? "libargon2.so" : "libargon2.dll";
33+
Platform.isLinux ? Platform.environment['LIBFOO_PATH'] ?? "libargon2.so"
34+
: "libargon2.dll";
3435

3536
}

dargon2_flutter/dargon2_flutter_desktop/linux/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
2020

2121
# List of absolute paths to libraries that should be bundled with the plugin
2222
set(dargon2_flutter_desktop_bundled_libraries
23-
""
23+
"$<TARGET_FILE:argon2>"
2424
PARENT_SCOPE
2525
)
26+
27+
add_subdirectory(../native)
28+
29+

dargon2_flutter/dargon2_flutter_desktop/linux/dargon2_flutter_desktop_plugin.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010
(G_TYPE_CHECK_INSTANCE_CAST((obj), dargon2_flutter_desktop_plugin_get_type(), \
1111
Dargon2FlutterDesktopPlugin))
1212

13+
static gchar* get_executable_dir() {
14+
g_autoptr(GError) error = nullptr;
15+
g_autofree gchar* exe_path = g_file_read_link("/proc/self/exe", &error);
16+
if (exe_path == nullptr) {
17+
g_critical("Failed to determine location of executable: %s",
18+
error->message);
19+
return nullptr;
20+
}
21+
22+
return g_path_get_dirname(exe_path);
23+
}
24+
1325
struct _Dargon2FlutterDesktopPlugin {
1426
GObject parent_instance;
1527
};
@@ -57,6 +69,11 @@ void dargon2_flutter_desktop_plugin_register_with_registrar(FlPluginRegistrar* r
5769
Dargon2FlutterDesktopPlugin* plugin = DARGON2_FLUTTER_DESKTOP_PLUGIN(
5870
g_object_new(dargon2_flutter_desktop_plugin_get_type(), nullptr));
5971

72+
g_autofree gchar* executable_dir = get_executable_dir();
73+
g_autofree gchar* libfoo_path =
74+
g_build_filename(self_exe, "lib", "libfoo.so", nullptr);
75+
setenv("LIBFOO_PATH", libfoo_path, 0);
76+
6077
g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
6178
g_autoptr(FlMethodChannel) channel =
6279
fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar),

dargon2_flutter/dargon2_flutter_desktop/macos/dargon2_flutter_desktop.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dargon2_flutter's desktop implementation
1515
s.source = { :path => '.' }
1616
s.source_files = 'Classes/**/*'
1717
s.dependency 'FlutterMacOS'
18+
s.dependency 'Argon2Swift'
1819

1920
s.platform = :osx, '10.11'
2021
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2020 Tejas Mehta <[email protected]>
2+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
4+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5+
6+
cmake_minimum_required(VERSION 3.6.0)
7+
8+
# CMake Instructions for Argon2's build for Android's NDK
9+
10+
project(argon2 C CXX)
11+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os")
12+
13+
file(GLOB argon2_SOURCES
14+
./argon2/src/blake2/blake2b.c
15+
./argon2/src/argon2.c
16+
./argon2/src/core.c
17+
./argon2/src/encoding.c
18+
./argon2/src/ref.c
19+
./argon2/src/thread.c
20+
)
21+
22+
add_library(argon2 SHARED ${argon2_SOURCES})
23+
target_compile_options(argon2 PRIVATE)
24+
target_include_directories(argon2 PUBLIC ./Argon2/include/)

dargon2_flutter/dargon2_flutter_desktop/windows/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
1919

2020
# List of absolute paths to libraries that should be bundled with the plugin
2121
set(dargon2_flutter_desktop_bundled_libraries
22-
""
22+
"$<TARGET_FILE:argon2>"
2323
PARENT_SCOPE
2424
)
25+
26+
add_subdirectory(../native)

0 commit comments

Comments
 (0)