[gnome-builder] templates: refactor and add vala support for shared-library template



commit 1c34219ba8586302b221feec29995ce2e8d04c31
Author: Christian Hergert <chergert redhat com>
Date:   Fri Apr 22 04:08:27 2016 -0700

    templates: refactor and add vala support for shared-library template
    
    I'm sure there are more things that need to be done for "best practices",
    but this gets us something to start from.
    
     ide create-project -t shared-library -g vala myproject

 configure.ac                                       |    4 +-
 plugins/Makefile.am                                |    2 +-
 plugins/autotools-templates/Makefile.am            |   50 +++++
 .../autotools-templates.plugin}                    |    6 +-
 .../autotools_templates/__init__.py                |  210 ++++++++++++++++++++
 .../autotools_templates/resources}/CONTRIBUTING.md |    0
 .../autotools_templates/resources}/Makefile.am     |    0
 .../autotools_templates/resources}/NEWS            |    0
 .../autotools_templates/resources}/README.md       |    0
 .../autotools_templates/resources}/autogen.sh      |    0
 .../autotools_templates/resources}/configure.ac    |    5 +
 .../resources}/data/Makefile.am                    |    0
 .../resources}/data/package.pc.in                  |    0
 .../autotools_templates/resources}/git.mk          |    0
 .../autotools_templates/resources}/m4/Makefile.am  |    0
 .../resources}/m4/appstream-xml.m4                 |    0
 .../resources}/m4/ax_append_compile_flags.m4       |    0
 .../resources}/m4/ax_append_flag.m4                |    0
 .../resources}/m4/ax_check_compile_flag.m4         |    0
 .../resources}/m4/ax_check_link_flag.m4            |    0
 .../resources}/m4/ax_compiler_vendor.m4            |    0
 .../resources}/m4/ax_cxx_compile_stdcxx_11.m4      |    0
 .../resources}/m4/ax_require_defined.m4            |    0
 .../resources}/m4/glib-gettext.m4                  |    0
 .../autotools_templates/resources}/m4/gsettings.m4 |    0
 .../autotools_templates/resources}/m4/intltool.m4  |    0
 .../resources}/m4/introspection.m4                 |    0
 .../autotools_templates/resources}/m4/libtool.m4   |    0
 .../autotools_templates/resources}/m4/pkg.m4       |    0
 .../autotools_templates/resources}/m4/vala.m4      |    0
 .../autotools_templates/resources}/m4/vapigen.m4   |    0
 .../autotools_templates/resources}/po/Makevars     |    0
 .../autotools_templates/resources}/po/POTFILES.in  |    0
 .../resources/src/Makefile.shared-library-c}       |    2 +
 .../resources/src/Makefile.shared-library-vala}    |   11 +-
 .../resources}/src/package-version.h.in            |    0
 .../autotools_templates/resources}/src/package.h   |    0
 .../autotools_templates/resources/src/package.vala |    7 +
 plugins/autotools-templates/configure.ac           |   11 +
 plugins/library-template/Makefile.am               |   48 -----
 plugins/library-template/configure.ac              |   11 -
 .../library-template/library_template/__init__.py  |  160 ---------------
 42 files changed, 300 insertions(+), 227 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6ec15cb..d34aa9c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -236,6 +236,7 @@ dnl ***********************************************************************
 dnl Check for supported plugins
 dnl ***********************************************************************
 m4_include([plugins/autotools/configure.ac])
+m4_include([plugins/autotools-templates/configure.ac])
 m4_include([plugins/build-tools/configure.ac])
 m4_include([plugins/c-pack/configure.ac])
 m4_include([plugins/clang/configure.ac])
@@ -255,7 +256,6 @@ m4_include([plugins/html-completion/configure.ac])
 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/mingw/configure.ac])
 m4_include([plugins/project-tree/configure.ac])
 m4_include([plugins/python-gi-imports-completion/configure.ac])
@@ -553,6 +553,6 @@ echo "  XML Language Pack .................... : ${enable_xml_pack_plugin}"
 echo ""
 echo " Templates"
 echo ""
-echo "  Library .............................. : ${enable_library_template_plugin}"
+echo "  Autotools ............................ : ${enable_autotools_templates}"
 echo ""
 
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 2b08472..1811219 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,5 +1,6 @@
 SUBDIRS = \
        autotools \
+       autotools-templates \
        build-tools \
        clang \
        command-bar \
@@ -19,7 +20,6 @@ SUBDIRS = \
        html-preview \
        jedi \
        jhbuild \
-       library-template \
        project-tree \
        python-gi-imports-completion \
        mingw \
diff --git a/plugins/autotools-templates/Makefile.am b/plugins/autotools-templates/Makefile.am
new file mode 100644
index 0000000..746b1f0
--- /dev/null
+++ b/plugins/autotools-templates/Makefile.am
@@ -0,0 +1,50 @@
+if ENABLE_AUTOTOOLS_TEMPLATES
+
+plugindir = $(libdir)/gnome-builder/plugins
+dist_plugin_DATA = autotools-templates.plugin
+
+moduledir = $(libdir)/gnome-builder/plugins/autotools_templates
+dist_module_DATA = autotools_templates/__init__.py
+
+resourcedir = $(datadir)/gnome-builder/plugins/
+nobase_resource_DATA = \
+       autotools_templates/resources/README.md \
+       autotools_templates/resources/src/package.h \
+       autotools_templates/resources/src/package.vala \
+       autotools_templates/resources/src/Makefile.shared-library-c \
+       autotools_templates/resources/src/Makefile.shared-library-vala \
+       autotools_templates/resources/src/package-version.h.in \
+       autotools_templates/resources/po/POTFILES.in \
+       autotools_templates/resources/m4/gsettings.m4 \
+       autotools_templates/resources/m4/ax_require_defined.m4 \
+       autotools_templates/resources/m4/ax_compiler_vendor.m4 \
+       autotools_templates/resources/m4/glib-gettext.m4 \
+       autotools_templates/resources/m4/ax_append_compile_flags.m4 \
+       autotools_templates/resources/m4/appstream-xml.m4 \
+       autotools_templates/resources/m4/ax_check_link_flag.m4 \
+       autotools_templates/resources/m4/ax_check_compile_flag.m4 \
+       autotools_templates/resources/m4/ax_cxx_compile_stdcxx_11.m4 \
+       autotools_templates/resources/m4/Makefile.am \
+       autotools_templates/resources/m4/intltool.m4 \
+       autotools_templates/resources/m4/ax_append_flag.m4 \
+       autotools_templates/resources/m4/libtool.m4 \
+       autotools_templates/resources/m4/vala.m4 \
+       autotools_templates/resources/m4/introspection.m4 \
+       autotools_templates/resources/m4/pkg.m4 \
+       autotools_templates/resources/m4/vapigen.m4 \
+       autotools_templates/resources/Makefile.am \
+       autotools_templates/resources/CONTRIBUTING.md \
+       autotools_templates/resources/git.mk \
+       autotools_templates/resources/NEWS \
+       autotools_templates/resources/configure.ac \
+       autotools_templates/resources/autogen.sh \
+       autotools_templates/resources/data/package.pc.in \
+       autotools_templates/resources/data/Makefile.am \
+       autotools_templates/resources/po/Makevars \
+       $(NULL)
+
+EXTRA_DIST = $(nobase_resource_DATA)
+
+endif
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/library-template/library-template.plugin 
b/plugins/autotools-templates/autotools-templates.plugin
similarity index 55%
rename from plugins/library-template/library-template.plugin
rename to plugins/autotools-templates/autotools-templates.plugin
index bd9d232..1322586 100644
--- a/plugins/library-template/library-template.plugin
+++ b/plugins/autotools-templates/autotools-templates.plugin
@@ -1,6 +1,6 @@
 [Plugin]
-Name=Library Templates
-Description=Provides templates for creating libraries
+Name=Autotools Templates
+Description=Provides templates for creating autotools projects
 Authors=Christian Hergert <christian hergert me>
 Copyright=Copyright © 2016 Christian Hergert
 
@@ -8,4 +8,4 @@ Builtin=true
 Hidden=true
 
 Loader=python3
-Module=library_template
+Module=autotools_templates
diff --git a/plugins/autotools-templates/autotools_templates/__init__.py 
b/plugins/autotools-templates/autotools_templates/__init__.py
new file mode 100644
index 0000000..d8434e3
--- /dev/null
+++ b/plugins/autotools-templates/autotools_templates/__init__.py
@@ -0,0 +1,210 @@
+#!/usr/bin/env python3
+
+#
+# __init__.py
+#
+# Copyright (C) 2016 Christian Hergert <chergert redhat com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+from gettext import gettext as _
+
+import gi
+import os
+
+gi.require_version('Ide', '1.0')
+gi.require_version('Template', '1.0')
+
+from gi.repository import Ide
+from gi.repository import Gio
+from gi.repository import GLib
+from gi.repository import GObject
+from gi.repository import Peas
+from gi.repository import Template
+
+def get_module_data_path(name):
+    engine = Peas.Engine.get_default()
+    plugin = engine.get_plugin_info('autotools_templates')
+    data_dir = plugin.get_data_dir()
+    return GLib.build_filenamev([data_dir, name])
+
+class LibraryTemplateProvider(GObject.Object, Ide.TemplateProvider):
+    def do_get_project_templates(self):
+        return [LibraryProjectTemplate()]
+
+class AutotoolsTemplate(Ide.TemplateBase, Ide.ProjectTemplate):
+    def __init__(self, id, name, icon_name, description, languages):
+        super().__init__()
+        self.id = id
+        self.name = name
+        self.icon_name = icon_name
+        self.description = description
+        self.languages = languages
+
+    def do_get_id(self):
+        return self.id
+
+    def do_get_name(self):
+        return self.name
+
+    def do_get_icon_name(self):
+        return self.icon_name
+
+    def do_get_description(self):
+        return self.description
+
+    def do_get_languages(self):
+        return self.languages
+
+    def do_expand_async(self, params, cancellable, callback, data):
+        task = Gio.Task.new(self, cancellable, callback)
+
+        name = params['name'].get_string().lower()
+
+        if 'path' in params:
+            dir_path = params['path'].get_string();
+        else:
+            dir_path = name
+
+        self.language = 'c'
+        if 'language' in params:
+            self.language = params['language'].get_string().lower()
+
+        if self.language not in ('c', 'vala'):
+            task.return_error(GLib.Error("Language %s not supported" % self.language))
+            return
+
+        directory = Gio.File.new_for_path(dir_path)
+
+        scope = Template.Scope.new()
+
+        prefix = name if not name.endswith('-glib') else name[:-5]
+        PREFIX = prefix.upper().replace('-','_')
+        prefix_ = prefix.lower().replace('-','_')
+
+        scope.get('name').assign_string(name)
+        scope.get('name_').assign_string(name.lower().replace('-','_'))
+        scope.get('NAME').assign_string(name.upper().replace('-','_'))
+
+        scope.get('prefix').assign_string(prefix)
+        scope.get('Prefix').assign_string(prefix.capitalize())
+        scope.get('prefix_').assign_string(prefix_)
+        scope.get('PREFIX').assign_string(PREFIX)
+
+        scope.get('packages').assign_string("gio-2.0 >= 2.42")
+        scope.get('major_version').assign_string('0')
+        scope.get('minor_version').assign_string('1')
+        scope.get('micro_version').assign_string('0')
+        scope.get('enable_i18n').assign_boolean(True)
+        scope.get('enable_gtk_doc').assign_boolean(False)
+        scope.get('enable_gobject_introspection').assign_boolean(True)
+        scope.get('enable_vapi').assign_boolean(True)
+        scope.get('enable_vala').assign_boolean(self.language == 'vala')
+        scope.get('license').assign_string('/* license */')
+        scope.get('translation_copyright').assign_string('Translation copyright holder')
+        scope.get('language').assign_string(self.language)
+
+        self.prepare_scope(scope)
+
+        expands = {
+            'name': name,
+            'prefix': prefix,
+        }
+
+        files = {
+            'resources/CONTRIBUTING.md':                'CONTRIBUTING.md',
+            'resources/Makefile.am':                    'Makefile.am',
+            'resources/NEWS':                           'NEWS',
+            'resources/README.md':                      'README.md',
+            'resources/autogen.sh':                     'autogen.sh',
+            'resources/configure.ac':                   'configure.ac',
+            'resources/git.mk':                         'git.mk',
+
+            'resources/m4/Makefile.am':                 'm4/Makefile.am',
+            'resources/m4/appstream-xml.m4':            'm4/appstream-xml.m4',
+            'resources/m4/ax_append_compile_flags.m4':  'm4/ax_append_compile_flags.m4',
+            'resources/m4/ax_append_flag.m4':           'm4/ax_append_flag.m4',
+            'resources/m4/ax_check_compile_flag.m4':    'm4/ax_check_compile_flag.m4',
+            'resources/m4/ax_check_link_flag.m4':       'm4/ax_check_link_flag.m4',
+            'resources/m4/ax_compiler_vendor.m4':       'm4/ax_compiler_vendor.m4',
+            'resources/m4/ax_cxx_compile_stdcxx_11.m4': 'm4/ax_cxx_compile_stdcxx_11.m4',
+            'resources/m4/ax_require_defined.m4':       'm4/ax_require_defined.m4',
+            'resources/m4/glib-gettext.m4':             'm4/glib-gettext.m4',
+            'resources/m4/gsettings.m4':                'm4/gsettings.m4',
+            'resources/m4/intltool.m4':                 'm4/intltool.m4',
+            'resources/m4/introspection.m4':            'm4/introspection.m4',
+            'resources/m4/libtool.m4':                  'm4/libtool.m4',
+            'resources/m4/pkg.m4':                      'm4/pkg.m4',
+            'resources/m4/vala.m4':                     'm4/vala.m4',
+            'resources/m4/vapigen.m4':                  'm4/vapigen.m4',
+
+            'resources/data/package.pc.in':             'data/%(name)s.pc.in',
+            'resources/data/Makefile.am':               'data/Makefile.am',
+            'resources/po/Makevars':                    'po/Makevars',
+            'resources/po/POTFILES.in':                 'po/POTFILES.in',
+        }
+        self.prepare_files(files)
+
+        modes = { 'resources/autogen.sh': 0o750 }
+        self.prepare_file_modes(modes)
+
+        for src,dst in files.items():
+            path = get_module_data_path(src)
+            destination = directory.get_child(dst % expands)
+            self.add_path(path, destination, scope, modes.get(src, 0))
+
+        self.expand_all_async(cancellable, self.expand_all_cb, task)
+
+    def do_expand_finish(self, result):
+        return result.propagate_boolean()
+
+    def expand_all_cb(self, obj, result, task):
+        try:
+            self.expand_all_finish(result)
+            task.return_boolean(True)
+        except Exception as exc:
+            print(exc)
+            task.return_error(GLib.Error(exc))
+
+    def prepare_scope(self, scope):
+        pass
+
+    def prepare_files(self, files):
+        pass
+
+    def prepare_file_modes(self, modes):
+        pass
+
+class LibraryProjectTemplate(AutotoolsTemplate):
+    def __init__(self):
+        super().__init__(
+            'shared-library',
+            _("Shared Library"),
+            'application-x-executable-symbolic',
+            _("Create a new autotools project with a shared library"),
+            ['C', 'Vala']
+         )
+
+    def prepare_files(self, files):
+        if self.language == 'c':
+            files['resources/src/Makefile.shared-library-c'] = 'src/Makefile.am'
+            files['resources/src/package.h'] = 'src/%(name)s.h'
+            files['resources/src/package-version.h.in'] = 'src/%(prefix)s-version.h.in'
+
+        if self.language == 'vala':
+            files['resources/src/Makefile.shared-library-vala'] = 'src/Makefile.am'
+            files['resources/src/package.vala'] = 'src/%(prefix)s.vala'
+
+
diff --git a/plugins/library-template/library_template/shared-library/CONTRIBUTING.md 
b/plugins/autotools-templates/autotools_templates/resources/CONTRIBUTING.md
similarity index 100%
rename from plugins/library-template/library_template/shared-library/CONTRIBUTING.md
rename to plugins/autotools-templates/autotools_templates/resources/CONTRIBUTING.md
diff --git a/plugins/library-template/library_template/shared-library/Makefile.am 
b/plugins/autotools-templates/autotools_templates/resources/Makefile.am
similarity index 100%
rename from plugins/library-template/library_template/shared-library/Makefile.am
rename to plugins/autotools-templates/autotools_templates/resources/Makefile.am
diff --git a/plugins/library-template/library_template/shared-library/NEWS 
b/plugins/autotools-templates/autotools_templates/resources/NEWS
similarity index 100%
rename from plugins/library-template/library_template/shared-library/NEWS
rename to plugins/autotools-templates/autotools_templates/resources/NEWS
diff --git a/plugins/library-template/library_template/shared-library/README.md 
b/plugins/autotools-templates/autotools_templates/resources/README.md
similarity index 100%
rename from plugins/library-template/library_template/shared-library/README.md
rename to plugins/autotools-templates/autotools_templates/resources/README.md
diff --git a/plugins/library-template/library_template/shared-library/autogen.sh 
b/plugins/autotools-templates/autotools_templates/resources/autogen.sh
similarity index 100%
rename from plugins/library-template/library_template/shared-library/autogen.sh
rename to plugins/autotools-templates/autotools_templates/resources/autogen.sh
diff --git a/plugins/library-template/library_template/shared-library/configure.ac 
b/plugins/autotools-templates/autotools_templates/resources/configure.ac
similarity index 98%
rename from plugins/library-template/library_template/shared-library/configure.ac
rename to plugins/autotools-templates/autotools_templates/resources/configure.ac
index 5599e84..bfdeb36 100644
--- a/plugins/library-template/library_template/shared-library/configure.ac
+++ b/plugins/autotools-templates/autotools_templates/resources/configure.ac
@@ -76,6 +76,9 @@ GLIB_GSETTINGS
 GOBJECT_INTROSPECTION_CHECK([1.42.0])
 {{end}}
 {{if enable_vala}}
+AM_PROG_VALAC([0.32])
+{{end}}
+{{if enable_vapi}}
 VAPIGEN_CHECK
 {{end}}
 
@@ -100,7 +103,9 @@ AC_CONFIG_FILES([
        Makefile
 
        src/Makefile
+{{if language == "c"}}
        src/{{prefix}}-version.h
+{{end}}
 
        data/Makefile
        data/{{name}}-$API_VERSION.pc:data/{{name}}.pc.in
diff --git a/plugins/library-template/library_template/shared-library/data/Makefile.am 
b/plugins/autotools-templates/autotools_templates/resources/data/Makefile.am
similarity index 100%
rename from plugins/library-template/library_template/shared-library/data/Makefile.am
rename to plugins/autotools-templates/autotools_templates/resources/data/Makefile.am
diff --git a/plugins/library-template/library_template/shared-library/data/package.pc.in 
b/plugins/autotools-templates/autotools_templates/resources/data/package.pc.in
similarity index 100%
rename from plugins/library-template/library_template/shared-library/data/package.pc.in
rename to plugins/autotools-templates/autotools_templates/resources/data/package.pc.in
diff --git a/plugins/library-template/library_template/shared-library/git.mk 
b/plugins/autotools-templates/autotools_templates/resources/git.mk
similarity index 100%
rename from plugins/library-template/library_template/shared-library/git.mk
rename to plugins/autotools-templates/autotools_templates/resources/git.mk
diff --git a/plugins/library-template/library_template/shared-library/m4/Makefile.am 
b/plugins/autotools-templates/autotools_templates/resources/m4/Makefile.am
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/Makefile.am
rename to plugins/autotools-templates/autotools_templates/resources/m4/Makefile.am
diff --git a/plugins/library-template/library_template/shared-library/m4/appstream-xml.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/appstream-xml.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/appstream-xml.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/appstream-xml.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/ax_append_compile_flags.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/ax_append_compile_flags.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/ax_append_compile_flags.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/ax_append_compile_flags.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/ax_append_flag.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/ax_append_flag.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/ax_append_flag.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/ax_append_flag.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/ax_check_compile_flag.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/ax_check_compile_flag.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/ax_check_compile_flag.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/ax_check_compile_flag.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/ax_check_link_flag.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/ax_check_link_flag.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/ax_check_link_flag.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/ax_check_link_flag.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/ax_compiler_vendor.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/ax_compiler_vendor.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/ax_compiler_vendor.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/ax_compiler_vendor.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/ax_cxx_compile_stdcxx_11.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/ax_cxx_compile_stdcxx_11.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/ax_cxx_compile_stdcxx_11.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/ax_cxx_compile_stdcxx_11.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/ax_require_defined.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/ax_require_defined.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/ax_require_defined.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/ax_require_defined.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/glib-gettext.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/glib-gettext.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/glib-gettext.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/glib-gettext.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/gsettings.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/gsettings.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/gsettings.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/gsettings.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/intltool.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/intltool.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/intltool.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/intltool.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/introspection.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/introspection.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/introspection.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/introspection.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/libtool.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/libtool.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/libtool.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/libtool.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/pkg.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/pkg.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/pkg.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/pkg.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/vala.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/vala.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/vala.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/vala.m4
diff --git a/plugins/library-template/library_template/shared-library/m4/vapigen.m4 
b/plugins/autotools-templates/autotools_templates/resources/m4/vapigen.m4
similarity index 100%
rename from plugins/library-template/library_template/shared-library/m4/vapigen.m4
rename to plugins/autotools-templates/autotools_templates/resources/m4/vapigen.m4
diff --git a/plugins/library-template/library_template/shared-library/po/Makevars 
b/plugins/autotools-templates/autotools_templates/resources/po/Makevars
similarity index 100%
rename from plugins/library-template/library_template/shared-library/po/Makevars
rename to plugins/autotools-templates/autotools_templates/resources/po/Makevars
diff --git a/plugins/library-template/library_template/shared-library/po/POTFILES.in 
b/plugins/autotools-templates/autotools_templates/resources/po/POTFILES.in
similarity index 100%
rename from plugins/library-template/library_template/shared-library/po/POTFILES.in
rename to plugins/autotools-templates/autotools_templates/resources/po/POTFILES.in
diff --git a/plugins/library-template/library_template/shared-library/src/Makefile.am 
b/plugins/autotools-templates/autotools_templates/resources/src/Makefile.shared-library-c
similarity index 99%
copy from plugins/library-template/library_template/shared-library/src/Makefile.am
copy to plugins/autotools-templates/autotools_templates/resources/src/Makefile.shared-library-c
index d5222e1..f30854e 100644
--- a/plugins/library-template/library_template/shared-library/src/Makefile.am
+++ b/plugins/autotools-templates/autotools_templates/resources/src/Makefile.shared-library-c
@@ -9,9 +9,11 @@ lib{{name_}}_ API_VERSION@_la_CFLAGS = \
        $({{NAME}}_CFLAGS) \
        $(WARN_CFLAGS) \
        $(NULL)
+
 lib{{name_}}_ API_VERSION@_la_LIBADD = \
        $({{NAME}}_LIBS) \
        $(NULL)
+
 lib{{name_}}_ API_VERSION@_la_LDFLAGS = \
        $(WARN_LDFLAGS) \
        $(NULL)
diff --git a/plugins/library-template/library_template/shared-library/src/Makefile.am 
b/plugins/autotools-templates/autotools_templates/resources/src/Makefile.shared-library-vala
similarity index 74%
rename from plugins/library-template/library_template/shared-library/src/Makefile.am
rename to plugins/autotools-templates/autotools_templates/resources/src/Makefile.shared-library-vala
index d5222e1..628a877 100644
--- a/plugins/library-template/library_template/shared-library/src/Makefile.am
+++ b/plugins/autotools-templates/autotools_templates/resources/src/Makefile.shared-library-vala
@@ -1,19 +1,26 @@
 lib_LTLIBRARIES = lib{{name}}- API_VERSION@.la
 
 lib{{name_}}_ API_VERSION@_la_SOURCES = \
-       {{prefix}}-version.h \
-       {{name}}.h \
+       {{name}}.vala \
        $(NULL)
 
 lib{{name_}}_ API_VERSION@_la_CFLAGS = \
        $({{NAME}}_CFLAGS) \
        $(WARN_CFLAGS) \
        $(NULL)
+
 lib{{name_}}_ API_VERSION@_la_LIBADD = \
        $({{NAME}}_LIBS) \
        $(NULL)
+
 lib{{name_}}_ API_VERSION@_la_LDFLAGS = \
        $(WARN_LDFLAGS) \
        $(NULL)
 
+lib{{name_}}_ API_VERSION@_la_VALAFLAGS = \
+       --thread \
+       --target-glib=2.44 \
+       --pkg glib-2.0 \
+       $(NULL)
+
 -include $(top_srcdir)/git.mk
diff --git a/plugins/library-template/library_template/shared-library/src/package-version.h.in 
b/plugins/autotools-templates/autotools_templates/resources/src/package-version.h.in
similarity index 100%
rename from plugins/library-template/library_template/shared-library/src/package-version.h.in
rename to plugins/autotools-templates/autotools_templates/resources/src/package-version.h.in
diff --git a/plugins/library-template/library_template/shared-library/src/package.h 
b/plugins/autotools-templates/autotools_templates/resources/src/package.h
similarity index 100%
rename from plugins/library-template/library_template/shared-library/src/package.h
rename to plugins/autotools-templates/autotools_templates/resources/src/package.h
diff --git a/plugins/autotools-templates/autotools_templates/resources/src/package.vala 
b/plugins/autotools-templates/autotools_templates/resources/src/package.vala
new file mode 100644
index 0000000..0ce448a
--- /dev/null
+++ b/plugins/autotools-templates/autotools_templates/resources/src/package.vala
@@ -0,0 +1,7 @@
+/* license */
+
+using GLib;
+
+namespace {{Prefix}} {
+
+}
diff --git a/plugins/autotools-templates/configure.ac b/plugins/autotools-templates/configure.ac
new file mode 100644
index 0000000..0c8a022
--- /dev/null
+++ b/plugins/autotools-templates/configure.ac
@@ -0,0 +1,11 @@
+AC_ARG_ENABLE([autotools-templates],
+              [AS_HELP_STRING([--enable-autotools-templates=@<:@yes/no@:>@],
+                              [Build with support for creating autotools projects.])],
+              [enable_autotools_templates=$enableval],
+              [enable_autotools_templates=yes])
+
+# for if ENABLE_AUTOTOOLS_TEMPLATE_PLUGIN in Makefile.am
+AM_CONDITIONAL(ENABLE_AUTOTOOLS_TEMPLATES, [test "x$enable_autotools_templates" = "xyes"])
+
+# Ensure our makefile is generated by autoconf
+AC_CONFIG_FILES([plugins/autotools-templates/Makefile])


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