Skip to content

Commit ffeb39e

Browse files
committed
Merge branch 'desktop-possibilities' of https://github.com/abner/flutter_js into desktop-possibilities
2 parents 3d57131 + 90cad63 commit ffeb39e

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

linux/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,18 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
3636

3737
# List of absolute paths to libraries that should be bundled with the plugin
3838
set(flutter_qjs_bundled_libraries
39-
""
39+
"$<TARGET_FILE:libquickjs_c_bridge_plugin.so>"
4040
PARENT_SCOPE
4141
)
4242

43+
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/shared/libquickjs_c_bridge_plugin.so")
44+
4345
set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle")
4446
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
4547
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
4648
endif()
4749
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
50+
4851
set(QUICKJSC_BRIDGE "libquickjs_c_bridge_plugin.so")
4952
set(QUICKJSC_BRIDGE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/shared/${QUICKJSC_BRIDGE}")
5053
install(CODE "file(REMOVE_RECURSE \"${INSTALL_BUNDLE_LIB_DIR}/${QUICKJSC_BRIDGE}\")" COMPONENT Runtime)

linux/flutter_js_plugin.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <flutter_linux/flutter_linux.h>
44
#include <gtk/gtk.h>
55
#include <sys/utsname.h>
6+
#include <glib.h>
67

78
#include <cstring>
89

@@ -53,6 +54,25 @@ static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call,
5354
flutter_js_plugin_handle_method_call(plugin, method_call);
5455
}
5556

57+
// Gets the directory the current executable is in, borrowed from:
58+
// https://github.com/flutter/engine/blob/master/shell/platform/linux/fl_dart_project.cc#L27
59+
//
60+
// Copyright 2013 The Flutter Authors. All rights reserved.
61+
// Use of this source code is governed by a BSD-style license that can be
62+
// found in https://github.com/flutter/engine/blob/master/LICENSE.
63+
static gchar* get_executable_dir() {
64+
g_autoptr(GError) error = nullptr;
65+
g_autofree gchar* exe_path = g_file_read_link("/proc/self/exe", &error);
66+
if (exe_path == nullptr) {
67+
g_critical("Failed to determine location of executable: %s",
68+
error->message);
69+
return nullptr;
70+
}
71+
72+
return g_path_get_dirname(exe_path);
73+
}
74+
75+
5676
void flutter_js_plugin_register_with_registrar(FlPluginRegistrar* registrar) {
5777
FlutterJsPlugin* plugin = FLUTTER_JS_PLUGIN(
5878
g_object_new(flutter_js_plugin_get_type(), nullptr));
@@ -67,4 +87,10 @@ void flutter_js_plugin_register_with_registrar(FlPluginRegistrar* registrar) {
6787
g_object_unref);
6888

6989
g_object_unref(plugin);
90+
91+
g_autofree gchar* executable_dir = get_executable_dir();
92+
g_autofree gchar* lib_path =
93+
g_build_filename(executable_dir, "lib", "libquickjs_c_bridge_plugin.so", nullptr);
94+
setenv("LIBQUICKJSC_PATH", lib_path, 0);
7095
}
96+

linux/shared/libquickjs.a

-1.08 MB
Binary file not shown.
914 KB
Binary file not shown.

0 commit comments

Comments
 (0)