[libgd/wip/tingping/meson] Add Meson subproject support



commit 7708f0de3d69f5b492de62c21a2203c9d7128531
Author: Zeeshan Ali <zeenix gmail com>
Date:   Tue Oct 11 12:31:58 2016 +0200

    Add Meson subproject support
    
    With contrubitions from:
    - Zeeshan Ali <zeenix gmail com>
    - Nirbheek Chauhan <nirbheek centricular com>

 libgd/meson.build |  171 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 meson.build       |   18 ++++++
 meson_options.txt |   19 ++++++
 meson_readme.md   |   74 +++++++++++++++++++++++
 4 files changed, 282 insertions(+), 0 deletions(-)
---
diff --git a/libgd/meson.build b/libgd/meson.build
new file mode 100644
index 0000000..39890e2
--- /dev/null
+++ b/libgd/meson.build
@@ -0,0 +1,171 @@
+gnome = import('gnome')
+
+sources = [
+  'gd.h',
+  'gd-types-catalog.c'
+]
+built_sources = []
+c_args = []
+
+if get_option('with-gtk-hacks')
+  sources += [
+    'gd-entry-focus-hack.c',
+    'gd-entry-focus-hack.h',
+    'gd-icon-utils.c',
+    'gd-icon-utils.h',
+  ]
+  c_args += '-DLIBGD_GTK_HACKS=1'
+endif
+
+if (get_option('with-main-box') or
+    get_option('with-main-icon-box'))
+  sources += [
+    'gd-main-box-child.c',
+    'gd-main-box-child.h',
+    'gd-main-box-generic.c',
+    'gd-main-box-generic.h',
+    'gd-main-box-item.c',
+    'gd-main-box-item.h'
+  ]
+  c_args += '-DLIBGD__BOX_COMMON=1'
+
+  if get_option('with-main-icon-box')
+    sources += [
+      'gd-main-icon-box.c',
+      'gd-main-icon-box.h',
+      'gd-main-icon-box-child.c',
+      'gd-main-icon-box-child.h',
+      'gd-icon-utils.c',
+      'gd-icon-utils.h',
+    ]
+    c_args += '-DLIBGD_MAIN_ICON_BOX=1'
+  endif
+
+  if get_option('with-main-box')
+    sources += [
+      'gd-main-box.c',
+      'gd-main-box.h',
+    ]
+    c_args += '-DLIBGD_MAIN_BOX=1'
+  endif
+endif
+
+if (get_option('with-main-icon-view') or
+    get_option('with-main-list-view') or
+    get_option('with-main-view'))
+  sources += [
+    'gd-main-view-generic.c',
+    'gd-main-view-generic.h',
+    'gd-styled-text-renderer.c',
+    'gd-styled-text-renderer.h',
+    'gd-two-lines-renderer.c',
+    'gd-two-lines-renderer.h',
+  ]
+  c_args += '-DLIBGD__VIEW_COMMON=1'
+
+  if (get_option('with-main-icon-view') or
+      get_option('with-main-view'))
+    sources += [
+      'gd-main-icon-view.c',
+      'gd-main-icon-view.h',
+      'gd-toggle-pixbuf-renderer.c',
+      'gd-toggle-pixbuf-renderer.h'
+    ]
+    c_args += '-DLIBGD_MAIN_ICON_VIEW=1'
+  endif
+
+  if (get_option('with-main-list-view') or
+      get_option('with-main-view'))
+    sources += [
+      'gd-main-list-view.c',
+      'gd-main-list-view.h',
+    ]
+    c_args += '-DLIBGD_MAIN_LIST_VIEW=1'
+  endif
+
+  if get_option('with-main-view')
+    sources += [
+      'gd-main-view.c',
+      'gd-main-view.h',
+    ]
+    c_args += '-DLIBGD_MAIN_VIEW=1'
+  endif
+endif
+
+if get_option('with-margin-container')
+  sources += [
+    'gd-margin-container.c',
+    'gd-margin-container.h',
+  ]
+  c_args += '-DLIBGD_MARGIN_CONTAINER=1'
+endif
+
+if get_option('with-tagged-entry')
+  gdres = gnome.compile_resources(
+    'gd-tagged-entry-resources',
+    'gd-tagged-entry.gresource.xml'
+  )
+  built_sources += gdres[1]
+  sources += [
+    gdres[0],
+    'gd-tagged-entry.c',
+    'gd-tagged-entry.h',
+  ]
+  c_args += '-DLIBGD_TAGGED_ENTRY=1'
+endif
+
+if get_option('with-notification')
+  sources += [
+    'gd-notification.c',
+    'gd-notification.h',
+  ]
+  c_args += '-DLIBGD_NOTIFICATION=1'
+endif
+
+if sources.length() == 2
+  error('You must include a feature to be built!')
+endif
+
+libgd_lib = library('gd', sources,
+  dependencies: [libgtk, libm],
+  include_directories: libgd_include,
+  c_args: c_args,
+  install: get_option('default_library') == 'shared',
+  install_dir: pkglibdir
+)
+
+if get_option('with-introspection') or get_option('with-vapi')
+  libgd_gir = gnome.generate_gir(libgd_lib,
+    sources : sources,
+    nsversion : '1.0',
+    namespace : 'Gd',
+    symbol_prefix : 'gd',
+    identifier_prefix : 'Gd',
+    includes : 'Gtk-3.0',
+    include_directories: libgd_include,
+    install: true,
+    install_dir_gir: pkglibdir,
+    install_dir_typelib: pkglibdir,
+    extra_args: [
+      '--c-include=libgd/gd.h',
+    ]
+  )
+  built_sources += libgd_gir
+
+  if get_option('with-vapi')
+    libgd_vapi_dep = gnome.generate_vapi('gd-1.0',
+      sources: libgd_gir[0],
+      packages: ['gtk+-3.0'],
+      install: true,
+      install_dir: pkglibdir
+    )
+  endif
+endif
+
+libgd_dep = declare_dependency(
+  link_with: libgd_lib,
+  include_directories: libgd_include,
+  dependencies: libgtk,
+  compile_args: c_args,
+  sources: built_sources
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..4c6b0f5
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,18 @@
+project('libgd', 'c',
+  meson_version: '>= 0.37.0'
+)
+
+if not meson.is_subproject()
+  error('This project is only intended to be used as a subproject!')
+endif
+pkglibdir = get_option('pkglibdir')
+if pkglibdir == ''
+  error('You must define a private package directory with "pkglibdir=/usr/lib/foo"')
+endif
+
+libgtk = dependency('gtk+-3.0', version: '>= 3.7.10')
+cc = meson.get_compiler('c')
+libm = cc.find_library('m', required: false)
+libgd_include = include_directories('.')
+
+subdir('libgd')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..de8c2bf
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,19 @@
+option('pkglibdir', type: 'string', value: '',
+  description: 'The private directory the files will be installed into. (REQUIRED)'
+)
+option('with-introspection', type: 'boolean', value: false,
+  description: 'Build gobject-introspection support'
+)
+option('with-vapi', type: 'boolean', value: false,
+  description: 'Build vapi file'
+)
+# Widget options
+option('with-gtk-hacks', type: 'boolean', value: false)
+option('with-main-view', type: 'boolean', value: false)
+option('with-main-icon-view', type: 'boolean', value: false)
+option('with-main-list-view', type: 'boolean', value: false)
+option('with-margin-container', type: 'boolean', value: false)
+option('with-tagged-entry', type: 'boolean', value: false)
+option('with-notification', type: 'boolean', value: false)
+option('with-main-box', type: 'boolean', value: false)
+option('with-main-icon-box', type: 'boolean', value: false)
\ No newline at end of file
diff --git a/meson_readme.md b/meson_readme.md
new file mode 100644
index 0000000..1d93672
--- /dev/null
+++ b/meson_readme.md
@@ -0,0 +1,74 @@
+See README for general information. Read below for usage with Meson.
+
+Usage
+=====
+
+libgd is intended to be used as a submodule from other projects. So given a Meson project using git
+you would run this to do initial setup:
+
+```
+mkdir subprojects
+git submodule add https://git.gnome.org/browse/libgd subprojects/libgd
+```
+
+Then from within your `meson.build` file:
+
+Static Library
+--------------
+
+```meson
+pkglibdir = join_paths(get_option('libdir'), meson.project_name())
+libgd = subproject('libgd',
+  default_options: [
+    'pkglibdir=' + pkglibdir,
+    'with-tagged-entry=true',
+    'default_library=static'
+  ]
+)
+libgd_dep = libgd.get_variable('libgd_dep')
+
+executable('foo', 'main.c',
+  dependencies: libgd_dep
+)
+```
+
+Introspection
+-------------
+
+```meson
+pkglibdir = join_paths(get_option('libdir'), meson.project_name())
+libgd = subproject('libgd',
+  default_options: [
+    'pkglibdir=' + pkglibdir,
+    'with-tagged-entry=true',
+    'with-introspection=true'
+  ]
+)
+```
+
+```python
+import gi
+gi.require_version('GIRepository', '2.0')
+from gi.repository import GIRepository
+pkglibdir = '/usr/lib/foo'
+GIRepository.Repository.prepend_search_path(pkglibdir)
+GIRepository.Repository.prepend_library_path(pkglibdir)
+gi.require_version('Gd', '1.0')
+
+```
+
+Vala
+----
+
+```meson
+pkglibdir = join_paths(get_option('libdir'), meson.project_name())
+libgd = subproject('libgd',
+  default_options: [
+    'pkglibdir=' + pkglibdir,
+    'with-tagged-entry=true',
+    'with-vapi=true'
+  ]
+)
+libgd_vapi_dep = libgd.get_variable('libgd_vapi_dep')
+
+```


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