[gnome-builder] meson: Try to handle running installed scripts if no binaries found



commit 7feffd017e9e3b0d47b535fa08bfa92b134282b8
Author: Patrick Griffis <tingping tingping se>
Date:   Sun Dec 18 02:34:43 2016 -0500

    meson: Try to handle running installed scripts if no binaries found
    
    This only works on meson 0.37.0 and makes even more assumptions but
    it works in the common case.

 plugins/meson/meson_plugin/__init__.py |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/plugins/meson/meson_plugin/__init__.py b/plugins/meson/meson_plugin/__init__.py
index 19f8494..ea7ba04 100644
--- a/plugins/meson/meson_plugin/__init__.py
+++ b/plugins/meson/meson_plugin/__init__.py
@@ -242,6 +242,24 @@ class MesonBuilder(Ide.Builder):
                 else:
                     targets.append(ide_target)
 
+            # It is possible the program installs a script not a binary
+            if not targets or targets[0].install_directory.get_path() != bindir:
+                try:
+                    # This is a new feature in Meson 0.37.0
+                    ret = subprocess.check_output(['mesonintrospect', '--installed',
+                                                   self._get_build_dir().get_path()])
+                    installed = json.loads(ret.decode('utf-8'))
+                    for f in installed.values():
+                        install_dir = path.dirname(f)
+                        if install_dir == bindir:
+                            # FIXME: This isn't a real target but builder doesn't
+                            # actually use it as such anyway.
+                            ide_target = MesonBuildTarget(install_dir, name=path.basename(f))
+                            targets.insert(0, ide_target)
+                            break # Only need one
+                except (subprocess.CalledProcessError, json.JSONDecodeError, UnicodeDecodeError):
+                    pass
+
             task.build_targets = targets
             task.return_boolean(True)
 


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