[gnome-builder/1151-vala-pass-dependencies-to-lsp] New GObject Introspection frienly method ide_subprocess_launcher_set_args()
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/1151-vala-pass-dependencies-to-lsp] New GObject Introspection frienly method ide_subprocess_launcher_set_args()
- Date: Fri, 6 Mar 2020 19:54:07 +0000 (UTC)
commit 0c4892b25396a5e1904c74bf1b7d7aaaf01fb677
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date: Thu Mar 5 09:31:31 2020 -0600
New GObject Introspection frienly method ide_subprocess_launcher_set_args()
GVls: implement runtime configuration notification
Plugin now takes current runtime to know vala API
version and use 'pkg-config' to find libvala's VAPI
directory and generic VAPI at ${datadir}/vala/vapi,
both are provided to the server to find packages
in use for current runtime
Plugin now report the Vala API version in use
New GObject Introspection frienly method
ide_subprocess_launcher_set_args()
src/libide/threading/ide-subprocess-launcher.c | 35 +++++++++++--
src/libide/threading/ide-subprocess-launcher.h | 3 ++
src/plugins/gvls/gvls_plugin.py | 72 +++++++++++++++++++++++++-
3 files changed, 105 insertions(+), 5 deletions(-)
---
diff --git a/src/libide/threading/ide-subprocess-launcher.c b/src/libide/threading/ide-subprocess-launcher.c
index b692e16fc..60fefe1d1 100644
--- a/src/libide/threading/ide-subprocess-launcher.c
+++ b/src/libide/threading/ide-subprocess-launcher.c
@@ -966,9 +966,38 @@ ide_subprocess_launcher_take_stderr_fd (IdeSubprocessLauncher *self,
}
}
+/**
+ * ide_subprocess_launcher_set_argv:
+ * @self: an #IdeSubprocessLauncher
+ * @argv: (array zero-terminated=1) (element-type utf8): an array of arguments to pass to the subprocess
+ */
void
ide_subprocess_launcher_set_argv (IdeSubprocessLauncher *self,
- const gchar * const *args)
+ const gchar * const *argv)
+{
+ IdeSubprocessLauncherPrivate *priv = ide_subprocess_launcher_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_SUBPROCESS_LAUNCHER (self));
+
+ g_ptr_array_remove_range (priv->argv, 0, priv->argv->len);
+
+ if (argv != NULL)
+ {
+ for (guint i = 0; argv[i] != NULL; i++)
+ g_ptr_array_add (priv->argv, g_strdup (argv[i]));
+ }
+
+ g_ptr_array_add (priv->argv, NULL);
+}
+
+/**
+ * ide_subprocess_launcher_set_args:
+ * @self: an #IdeSubprocessLauncher
+ * @args: (element-type utf8): a list of arguments to pass to the subprocess
+ */
+void
+ide_subprocess_launcher_set_args (IdeSubprocessLauncher *self,
+ GList *args)
{
IdeSubprocessLauncherPrivate *priv = ide_subprocess_launcher_get_instance_private (self);
@@ -978,8 +1007,8 @@ ide_subprocess_launcher_set_argv (IdeSubprocessLauncher *self,
if (args != NULL)
{
- for (guint i = 0; args[i] != NULL; i++)
- g_ptr_array_add (priv->argv, g_strdup (args[i]));
+ for (GList* list = args; list; list = list->next)
+ g_ptr_array_add (priv->argv, g_strdup ((const gchar*) list->data));
}
g_ptr_array_add (priv->argv, NULL);
diff --git a/src/libide/threading/ide-subprocess-launcher.h b/src/libide/threading/ide-subprocess-launcher.h
index 1567ff271..7f41f2066 100644
--- a/src/libide/threading/ide-subprocess-launcher.h
+++ b/src/libide/threading/ide-subprocess-launcher.h
@@ -114,6 +114,9 @@ gchar *ide_subprocess_launcher_pop_argv (IdeSubproce
IDE_AVAILABLE_IN_3_32
void ide_subprocess_launcher_set_argv (IdeSubprocessLauncher *self,
const gchar * const *argv);
+IDE_AVAILABLE_IN_3_36
+void ide_subprocess_launcher_set_args (IdeSubprocessLauncher *self,
+ GList *args);
IDE_AVAILABLE_IN_3_32
IdeSubprocess *ide_subprocess_launcher_spawn (IdeSubprocessLauncher *self,
GCancellable *cancellable,
diff --git a/src/plugins/gvls/gvls_plugin.py b/src/plugins/gvls/gvls_plugin.py
index df8f47030..bc5d0e0c3 100644
--- a/src/plugins/gvls/gvls_plugin.py
+++ b/src/plugins/gvls/gvls_plugin.py
@@ -1,3 +1,4 @@
+
#!/usr/bin/env python
# gvls_plugin.py
@@ -35,7 +36,6 @@ from gi.repository import Ide
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import GtkSource
-from gi.repository import Json
DEV_MODE = True
@@ -50,10 +50,13 @@ class GVlsService(Ide.Object):
default_vapi_dirs = True
scan_work_space = True
add_using_namespaces = True
+ library_vapidir = ""
+ system_vapidir = ""
files = []
packages = []
vala_args = {}
options = []
+ vala_api_version = ""
build_system = None
pipeline = None
build_args = None
@@ -166,6 +169,11 @@ class GVlsService(Ide.Object):
vv = GLib.Variant.new_variant(GLib.Variant.new_boolean(val))
return GLib.Variant.new_dict_entry(vk, vv)
+ def create_dict_entry_string(self, key, val):
+ vk = GLib.Variant.new_string (key)
+ vv = GLib.Variant.new_variant(GLib.Variant.new_string(val))
+ return GLib.Variant.new_dict_entry(vk, vv)
+
def create_configuration_variant(self):
try:
b = GLib.VariantBuilder(GLib.VariantType.new('a{sv}'))
@@ -175,6 +183,9 @@ class GVlsService(Ide.Object):
b.add_value(self.create_dict_entry_boolean('scanWorkspace', self.scan_work_space))
b.add_value(self.create_dict_entry_boolean('addUsingNamespaces', self.add_using_namespaces))
b.add_value(self.create_dict_entry_boolean('mesonBuildSystem', self.meson_build_system))
+ b.add_value(self.create_dict_entry_string('libraryVapi', self.library_vapidir))
+ b.add_value(self.create_dict_entry_string('systemVapi', self.system_vapidir))
+ b.add_value(self.create_dict_entry_string('valaApiVersion', self.vala_api_version))
ad = GLib.Variant.new_string ('valaArgs')
vadi = self.dict_to_array_variant(self.vala_args)
adi = GLib.Variant.new_dict_entry(ad, GLib.Variant.new_variant (vadi))
@@ -389,7 +400,61 @@ class GVlsService(Ide.Object):
print('\n\nOn Pipeline Loaded start get build flags error:\n')
print(exc.args)
print('\n\n\n')
-
+
+ def _update_config_from_runtime(self):
+ try:
+ if (self.pipeline == None):
+ return
+
+ rt = self.pipeline.get_runtime()
+
+ if (rt == None):
+ return
+
+ flags = Gio.SubprocessFlags.STDOUT_PIPE
+ launcher = rt.create_launcher()
+ if (launcher == None):
+ return
+ launcher.set_cwd(GLib.get_home_dir())
+ launcher.set_args (['valac','--api-version'])
+ valacp = launcher.spawn(None)
+ valacp.wait_async(None)
+ vstdio = valacp.get_stdout_pipe()
+ dp = Gio.DataInputStream.new(vstdio)
+ l = dp.read_line()
+ self.vala_api_version = str(l[0])
+ print ("Vala library name: libvala-"+self.vala_api_version)
+ launcher.set_args (['pkg-config','--variable','vapidir','libvala-'+self.vala_api_version])
+ vpkgp = launcher.spawn(None)
+ vpkgp.wait(None)
+ vpstdio = vpkgp.get_stdout_pipe()
+ dpp = Gio.DataInputStream.new(vpstdio)
+ lp = dpp.read_line()
+ flvapi = Gio.File.new_for_path(lp[0])
+ self.library_vapidir = flvapi.get_uri()
+ launcher.set_args (['pkg-config','--variable','datadir','libvala-'+self.vala_api_version])
+ vdp = launcher.spawn(None)
+ vdp.wait(None)
+ vdpio = vdp.get_stdout_pipe()
+ ddpp = Gio.DataInputStream.new(vdpio)
+ ldp = ddpp.read_line()
+ fgdvapi = Gio.File.new_for_path(ldp[0])
+ self.system_vapidir = fgdvapi.get_uri() + "/vala/vapi"
+ except BaseException as exc:
+ print('\n\nOn Update Runtime Configuration:\n')
+ print(str(exc))
+ print('\n\n\n')
+
+ def on_config_changed_cb(self, data):
+ try:
+ buildmgr = Ide.BuildManager.from_context (ctx)
+ self.pipeline = buildmgr.get_pipeline ()
+ self.pipeline.connect('diagnostic', self._on_pipeline_diagnostic)
+ except BaseException as exc:
+ print('\n\nOn Config Changed CB:\n')
+ print(str(exc))
+ print('\n\n\n')
+
def _gvls_spawned(self, supervisor, subprocess):
"""
This callback is executed when the `org.gnome.gvls.stdio.Server` process is spawned.
@@ -420,6 +485,9 @@ class GVlsService(Ide.Object):
buildmgr = Ide.BuildManager.from_context (ctx)
self.pipeline = buildmgr.get_pipeline ()
self.pipeline.connect('diagnostic', self._on_pipeline_diagnostic)
+ cfgmgr = Ide.ConfigManager.from_context(ctx)
+ cfgmgr.connect('notify::current', self.on_config_changed_cb)
+ self._update_config_from_runtime()
except BaseException as exc:
print('\n\n\n Exception Arguments: \n')
print(exc.args)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]