[gnome-builder/wip/beniofel/meson: 19/20] Add meson build system



commit 0ab185914d466227a23290927b9c942274c965d2
Author: Ben Iofel <iofelben gmail com>
Date:   Wed Feb 24 00:38:05 2016 -0500

    Add meson build system
    
    It's not async yet, still need to make it work

 configure.ac                 |    2 +
 plugins/Makefile.am          |    1 +
 plugins/meson/Makefile.am    |   12 ++++++++
 plugins/meson/configure.ac   |    9 ++++++
 plugins/meson/meson.plugin   |   10 ++++++
 plugins/meson/meson_build.py |   64 ++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 98 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index dbf1b21..8b65870 100644
--- a/configure.ac
+++ b/configure.ac
@@ -252,6 +252,7 @@ m4_include([plugins/html-preview/configure.ac])
 m4_include([plugins/jedi/configure.ac])
 m4_include([plugins/jhbuild/configure.ac])
 m4_include([plugins/library-template/configure.ac])
+m4_include([plugins/meson/configure.ac])
 m4_include([plugins/mingw/configure.ac])
 m4_include([plugins/project-tree/configure.ac])
 m4_include([plugins/python-gi-imports-completion/configure.ac])
@@ -495,6 +496,7 @@ echo "  GNOME Code Assistance ................ : ${enable_gnome_code_assistance_
 echo "  HTML Autocompletion .................. : ${enable_html_completion_plugin}"
 echo "  HTML and Markdown Preview ............ : ${enable_html_preview_plugin}"
 echo "  JHBuild .............................. : ${enable_jhbuild_plugin}"
+echo "  Meson ................................ : ${enable_meson_plugin}"
 echo "  MinGW ................................ : ${enable_mingw_plugin}"
 echo "  Project Creation ..................... : ${enable_create_project_plugin}"
 echo "  Project Tree ......................... : ${enable_project_tree_plugin}"
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 7ccd8fe..ca8be5c 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -21,6 +21,7 @@ SUBDIRS = \
        library-template \
        project-tree \
        python-gi-imports-completion \
+       meson \
        mingw \
        python-pack \
        support \
diff --git a/plugins/meson/Makefile.am b/plugins/meson/Makefile.am
new file mode 100644
index 0000000..85500ed
--- /dev/null
+++ b/plugins/meson/Makefile.am
@@ -0,0 +1,12 @@
+if ENABLE_MESON_PLUGIN
+
+EXTRA_DIST = $(plugin_DATA)
+
+plugindir = $(libdir)/gnome-builder/plugins
+dist_plugin_DATA = \
+    meson_build.py \
+    meson.plugin
+
+endif
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/meson/configure.ac b/plugins/meson/configure.ac
new file mode 100644
index 0000000..cee1278
--- /dev/null
+++ b/plugins/meson/configure.ac
@@ -0,0 +1,9 @@
+AC_ARG_ENABLE([meson-plugin],
+              [AS_HELP_STRING([--enable-meson-plugin=@<:@yes/no@:>@],
+                              [Build with support for the Meson build system])],
+              [enable_meson_plugin=$enableval],
+              [enable_meson_plugin=yes])
+
+AM_CONDITIONAL(ENABLE_MESON_PLUGIN, test x$enable_meson_plugin != xno)
+
+AC_CONFIG_FILES([plugins/meson/Makefile])
diff --git a/plugins/meson/meson.plugin b/plugins/meson/meson.plugin
new file mode 100644
index 0000000..8310610
--- /dev/null
+++ b/plugins/meson/meson.plugin
@@ -0,0 +1,10 @@
+[Plugin]
+Name=Meson
+Description=Meson build system support
+Authors=Ben Iofel <iofelben gmail com>
+Copyright=Copyright © 2016 Ben Iofel
+Builtin=true
+Loader=python3
+Module=meson_build
+X-Project-File-Filter-Pattern=meson.build
+X-Project-File-Filter-Name=Meson Project (meson.build)
diff --git a/plugins/meson/meson_build.py b/plugins/meson/meson_build.py
new file mode 100644
index 0000000..cf7ba32
--- /dev/null
+++ b/plugins/meson/meson_build.py
@@ -0,0 +1,64 @@
+from gi.repository import GLib
+from gi.repository import Gio
+from gi.repository import GObject
+from gi.repository import Ide
+
+class MesonBuildSystem(Ide.Object, Ide.BuildSystem, Gio.AsyncInitable):
+    context = GObject.Property(type=Ide.Context, 
flags=GObject.ParamFlags.CONSTRUCT_ONLY|GObject.ParamFlags.READWRITE)
+    project_file = GObject.Property(type=Gio.File, 
flags=GObject.ParamFlags.CONSTRUCT_ONLY|GObject.ParamFlags.READWRITE)
+
+    def do_init_async(self, priority, cancellable, callback, userdata):
+        print("async init")
+        task = Gio.Task.new(self, cancellable, callback)
+        task.return_boolean(True)
+
+    def do_init_finish(self, result):
+        return result.propagate_boolean()
+
+    def do_get_priority(self):
+        return -100
+
+    def do_get_builder(self, config):
+        return MesonBuilder(context=self.get_context())
+
+    def do_get_build_flags_async(self, file, cancel, callback, userdata):
+        pass
+
+    def do_get_build_flags_finish(self, result, error):
+        return [None]
+
+
+class MesonBuilder(Ide.Builder):
+    def do_build_async(self, flags, result, cancellable, callback, userdata=None):
+        # it's all synchronous for now, we'll make it async when it works
+        workdir = self.get_context().get_vcs().get_working_directory()
+        print("working in " + workdir.get_path())
+        builddir = workdir.get_child("build")
+        if not builddir.query_exists():
+            builddir.make_directory()
+        if not builddir.get_child("build.ninja").query_exists():
+            launcher = Ide.SubprocessLauncher(Gio.SubprocessFlags.NONE)
+            launcher.set_cwd(builddir.get_path())
+            launcher.push_args(["meson", workdir.get_path(), None])
+            subproc = launcher.spawn_sync()
+            print("running meson")
+            subproc.wait()
+
+        launcher = Ide.SubprocessLauncher(Gio.SubprocessFlags.NONE)
+        launcher.set_cwd(builddir.get_path())
+        launcher.push_args(["ninja"])
+        subproc = launcher.spawn_sync()
+        print("running ninja")
+        subproc.wait()
+
+        res = MesonBuildResult()
+        task = Gio.Task(self, cancellable, callback)
+        task.return_pointer(res)
+
+    def do_build_finish(self, result):
+        return result.propagate_pointer()
+
+
+class MesonBuildResult(Ide.BuildResult):
+    pass
+


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