[gnome-builder/1200-gvls-provide-meson-build-commands: 2/2] GVls: provide meson build commands



commit 4b0c61c652c8c60f64d178d40a01b04c248ca726
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date:   Tue May 5 00:04:44 2020 -0500

    GVls: provide meson build commands
    
    Fix issue #1200

 build-aux/flatpak/org.gnome.Builder.json |  2 +-
 src/plugins/gvls/gvls_plugin.py          | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/build-aux/flatpak/org.gnome.Builder.json b/build-aux/flatpak/org.gnome.Builder.json
index b418feb4c..9b4b37157 100644
--- a/build-aux/flatpak/org.gnome.Builder.json
+++ b/build-aux/flatpak/org.gnome.Builder.json
@@ -605,7 +605,7 @@
                 {
                     "type" : "git",
                     "url" : "https://gitlab.gnome.org/esodan/gvls.git";,
-                    "branch": "gvls-0.14"
+                    "branch": "master"
                 }
             ]
         },
diff --git a/src/plugins/gvls/gvls_plugin.py b/src/plugins/gvls/gvls_plugin.py
index 1311109ef..5a514cea3 100644
--- a/src/plugins/gvls/gvls_plugin.py
+++ b/src/plugins/gvls/gvls_plugin.py
@@ -55,6 +55,7 @@ class GVlsService(Ide.Object):
     ide_config = None
     source_file = None
     build_monitor = None
+    meson_compile_commands = ""
 
     @classmethod
     def from_context(klass, context):
@@ -174,6 +175,7 @@ class GVlsService(Ide.Object):
             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))
+            b.add_value(self.create_dict_entry_string('mesonCompileCommands', self.meson_compile_commands))
             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))
@@ -201,7 +203,14 @@ class GVlsService(Ide.Object):
             self._notify_change_configuration()
         if event_type == Gio.FileMonitorEvent.DELETED:
             self.build_monitor = None
-            
+
+    def read_meson_compile_commands(self, file):
+        ostream = Gio.MemoryOutputStream.new_resizable()
+        ostream.splice(file.read(), Gio.OutputStreamSpliceFlags.CLOSE_SOURCE, None)
+        ostream.close()
+        b = ostream.steal_as_bytes()
+        self.meson_compile_commands = str(ostream.get_data())
+        Ide.debug (self.meson_compile_commands)
     
     def _parse_build_commands(self):
         try:
@@ -214,6 +223,9 @@ class GVlsService(Ide.Object):
                     bcdir = Gio.File.new_for_path(self.pipeline.get_builddir())
                     if self.meson_build_system:
                         bcf = Gio.File.new_for_uri(bcdir.get_uri()+'/compile_commands.json')
+                        if bcf.query_exists(None):
+                            return
+                        self.read_meson_compile_commands(bcf)
                         if self.build_monitor == None:
                             self.build_monitor = bcf.monitor(Gio.FileMonitorFlags.NONE, None)
                             self.build_monitor.connect('changed', self._build_config_changed)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]