[template-glib] build: Add options for private directories as subproject



commit 2c0efb5d7258f2a6ad5b64109957390d441f18bc
Author: Patrick Griffis <tingping tingping se>
Date:   Tue Jun 6 17:25:17 2017 -0400

    build: Add options for private directories as subproject

 meson.build       |   16 +++++++++++++---
 meson_options.txt |   17 +++++++++++++++++
 src/meson.build   |   17 +++++++++++++++--
 3 files changed, 45 insertions(+), 5 deletions(-)
---
diff --git a/meson.build b/meson.build
index 38e9f26..e2d2fef 100644
--- a/meson.build
+++ b/meson.build
@@ -83,9 +83,19 @@ add_project_arguments(
 )
 
 # Setup various paths that subdirectory meson.build files need
-girdir = join_paths(get_option('datadir'), 'gir-1.0')
-typelibdir = join_paths(get_option('libdir'), 'girepository-1.0')
-vapidir = join_paths(get_option('datadir'), 'vala', 'vapi')
+if meson.is_subproject()
+  girdir = get_option('pkggirdir')
+  typelibdir = get_option('pkgtypelibdir')
+  libdir = get_option('pkglibdir')
+  vapidir = get_option('pkgvapidir')
+  includedir = get_option('pkgincludedir')
+else
+  libdir = get_option('libdir')
+  includedir = get_option('includedir')
+  girdir = join_paths(get_option('datadir'), 'gir-1.0')
+  typelibdir = join_paths(get_option('libdir'), 'girepository-1.0')
+  vapidir = join_paths(get_option('datadir'), 'vala', 'vapi')
+endif
 
 gnome = import('gnome')
 i18n = import('i18n')
diff --git a/meson_options.txt b/meson_options.txt
index d98cbf4..db71728 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -7,6 +7,23 @@ option('enable_profiling', type: 'boolean', value: false)
 option('with_introspection', type: 'boolean', value: true)
 option('with_vapi', type: 'boolean', value: true)
 
+# For subproject usage
+option('pkggirdir', type: 'string',
+  description: 'Private directory used when built as a subproject'
+)
+option('pkgvapidir', type: 'string',
+  description: 'Private directory used when built as a subproject'
+)
+option('pkglibdir', type: 'string',
+  description: 'Private directory used when built as a subproject'
+)
+option('pkgtypelibdir', type: 'string',
+  description: 'Private directory used when built as a subproject'
+)
+option('pkgincludedir', type: 'string',
+  description: 'Private directory used when built as a subproject'
+)
+
 option('enable-gtk-doc',
        type: 'boolean', value: false,
        description: 'Whether to generate the API reference for Template-GLib')
diff --git a/src/meson.build b/src/meson.build
index a8ccd75..860aba7 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,5 +1,5 @@
 libtemplate_glib_header_subdir = 'template-glib-' + apiversion
-libtemplate_glib_header_dir = join_paths(get_option('includedir'), libtemplate_glib_header_subdir)
+libtemplate_glib_header_dir = join_paths(includedir, libtemplate_glib_header_subdir)
 
 version_data = configuration_data()
 version_data.set('TMPL_MAJOR_VERSION', template_glib_version_major)
@@ -136,6 +136,9 @@ libtemplate_glib_sources = [
   'tmpl-util.c',
 ]
 
+if libdir == '' or includedir == ''
+  error('You must set pkglibdir and pkgincludedir when using as a subproject')
+endif
 
 libtemplate_glib = library(
   'template_glib-' + apiversion,
@@ -147,6 +150,7 @@ libtemplate_glib = library(
      soversion: soversion,
        version: libversion,
        install: true,
+   install_dir: libdir,
 )
 
 libtemplate_glib_dep = declare_dependency(
@@ -157,6 +161,9 @@ libtemplate_glib_dep = declare_dependency(
 )
 
 if get_option('with_introspection')
+  if girdir == '' or typelibdir == ''
+    error('You must set pkggirdir and pkgtypelidir when using as a subproject')
+  endif
 
   libtemplate_glib_gir = gnome.generate_gir(libtemplate_glib,
                 sources: libtemplate_glib_generated_headers + libtemplate_glib_public_headers + 
libtemplate_glib_public_sources,
@@ -173,6 +180,9 @@ if get_option('with_introspection')
   )
 
   if get_option('with_vapi')
+    if vapidir == ''
+      error('You must set pkgvapidir when using as a subproject')
+    endif
 
     libtemplate_glib_vapi = gnome.generate_vapi('template-glib-' + apiversion,
           sources: libtemplate_glib_gir[0],
@@ -184,7 +194,9 @@ if get_option('with_introspection')
   endif
 endif
 
-install_headers(libtemplate_glib_public_headers, subdir: libtemplate_glib_header_subdir)
+install_headers(libtemplate_glib_public_headers,
+  install_dir: libtemplate_glib_header_dir
+)
 
 pkgg = import('pkgconfig')
 
@@ -196,5 +208,6 @@ pkgg.generate(
      filebase: 'template-glib-@0@'.format(apiversion),
   description: 'A templating library for GLib',
      requires: 'gio-2.0',
+  install_dir: join_paths(libdir, 'pkgconfig'),
 )
 


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