[libgd/wip/meson] meson: Make libgd subdir rather than subproject



commit 993b2be7b1bd442b184786fd59b2b07fef82ad3e
Author: Zeeshan Ali <zeenix gmail com>
Date:   Wed Oct 12 12:43:24 2016 +0200

    meson: Make libgd subdir rather than subproject
    
    Until it's actually possible to use libgd as meson subproject, let's not
    define it as a project so other projects can use it as part of their
    project, using subdir() function of meson.
    
    Also update instructions in comments to reflect this change.

 meson.build       |   74 ++++++++++++++++++++++++++++-------------------------
 meson_options.txt |   13 ---------
 2 files changed, 39 insertions(+), 48 deletions(-)
---
diff --git a/meson.build b/meson.build
index acd55ff..9fb4879 100644
--- a/meson.build
+++ b/meson.build
@@ -3,21 +3,19 @@
 #
 # Author: Zeeshan Ali <zeeshanak gnome org>
 #
-# This build file currently is not very useful, as is. There is currently no way
-# in meson for the main project to pass any flags/options to subproject's build
-# and hence it can't choose which components to build, which is what all users
-# of libgd currently do.
+# libgd should be defined as a project itself to be used as meson subproject in
+# other projects but that is currently not possible since meson doesn't
+# currently provide a mechanism for the main project to pass any flags/options
+# to subproject's build.
 #
-# However, you can build libgd standalone with it:
-#
-# $ mkdir build
-# $ cd build
-# $ meson # choose components to build using -Doption=true paremeters
-#         # Check meson.options for list of options
-# $ ninja # ninja-build on Fedora
+# For now, just treat libgd submodule repo like a normal subdir in your project
+# and make use of 'libgd_dep' variable defined here to pass to 'dependencies'
+# keywords.
 #
 
-project('libgd', 'c')
+# Uncomment following line (and remove this comment) to use libgd as meson
+# subproject in future.
+#project('libgd', 'c')
 
 gtk = dependency('gtk+-3.0')
 cc = meson.get_compiler('c')
@@ -27,16 +25,16 @@ sources = [ 'libgd/gd.h',
             'libgd/gd-types-catalog.c',
             'libgd/gd-types-catalog.h' ]
 
-if get_option('libgd-gtk-hacks')
+if get_variable('libgd_gtk_hacks', false)
     sources += [ 'libgd/gd-entry-focus-hack.c',
                  'libgd/gd-entry-focus-hack.h',
                  'libgd/gd-icon-utils.c',
                  'libgd/gd-icon-utils.h' ]
 endif
 
-build_view_generic = (get_option('libgd-main-icon-view') or
-                      get_option('libgd-main-list-view') or
-                      get_option('libgd-main-view'))
+build_view_generic = (get_variable('libgd_main_icon_view', false) or
+                      get_variable('libgd_main_list_view', false) or
+                      get_variable('libgd_main_view', false))
 
 if build_view_generic
     sources += [ 'libgd/gd-main-view-generic.c',
@@ -47,8 +45,8 @@ if build_view_generic
                  'libgd/gd-two-lines-renderer.h' ]
 endif
 
-build_icon_view = (get_option('libgd-main-icon-view') or
-                   get_option('libgd-main-view'))
+build_icon_view = (get_variable('libgd_main_icon_view', false) or
+                   get_variable('libgd_main_view', false))
 if build_icon_view
     sources += [ 'libgd/gd-main-icon-view.c',
                  'libgd/gd-main-icon-view.h',
@@ -56,56 +54,58 @@ if build_icon_view
                  'libgd/gd-toggle-pixbuf-renderer.h' ]
 endif
 
-build_list_view = (get_option('libgd-main-list-view') or
-                   get_option('libgd-main-view'))
+build_list_view = (get_variable('libgd_main-list_view', false) or
+                   get_variable('libgd_main_view', false))
 if build_list_view
     sources += [ 'libgd/gd-main-list-view.c',
                  'libgd/gd-main-list-view.h' ]
 endif
 
-if get_option('libgd-main-view')
+if get_variable('libgd_main_view', false)
     sources += [ 'libgd/gd-main-view.c',
                  'libgd/gd-main-view.h' ]
 endif
 
-if get_option('libgd-main-toolbar')
+if get_variable('libgd_main_toolbar', false)
     sources += [ 'libgd/gd-main-toolbar.c',
                  'libgd/gd-main-toolbar.h' ]
 endif
 
-if get_option('libgd-header-bar')
+if get_variable('libgd_header_bar', false)
     sources += [ 'libgd/gd-header-bar.c',
                  'libgd/gd-header-bar.h' ]
 endif
 
-if get_option('libgd-header-button')
+if get_variable('libgd_header_button', false)
     sources += [ 'libgd/gd-header-button.c',
                  'libgd/gd-header-button.h' ]
 endif
 
-if get_option('libgd-margin-container')
+if get_variable('libgd_margin_container', false)
     sources += [ 'libgd/gd-margin-container.c',
                  'libgd/gd-margin-container.h' ]
 endif
 
-if get_option('libgd-notification')
+if get_variable('libgd_notification', false)
     sources += [ 'libgd/gd-notification.c',
                  'libgd/gd-notification.h' ]
 endif
 
-if get_option('libgd-revealer')
+if get_variable('libgd_revealer', false)
     sources += [ 'libgd/gd-revealer.c',
                  'libgd/gd-revealer.h' ]
 endif
 
 libgd = shared_library('gd', sources, dependencies: [gtk, libm])
-if get_option('libgd-static')
+if get_variable('libgd_static', false)
     libgd_lib = static_library('gd', sources, dependencies: [gtk, libm])
 else
     libgd_lib = libgd
 endif
 
-if get_option('libgd-gir') or get_option('libgd-vapi')
+built_sources = []
+
+if get_variable('libgd_gir', false) or get_variable('libgd_vapi', false)
     gnome = import('gnome')
     gir = gnome.generate_gir(libgd,
                              sources : sources,
@@ -114,9 +114,12 @@ if get_option('libgd-gir') or get_option('libgd-vapi')
                              symbol_prefix : 'gd',
                              identifier_prefix : 'Gd',
                              includes : 'Gtk-3.0',
-                             extra_args: ['-I' + meson.source_root()])
+                             extra_args: ['-I' + meson.source_root(),
+                                          '-I' + meson.current_source_dir(),
+                                          '--c-include="libgd/gd.h"'])
+   built_sources += gir
 
-    if get_option('libgd-vapi')
+    if get_variable('libgd_vapi', false)
         vapigen = find_program('vapigen')
         vapi = custom_target('gd-1.0.vapi',
                              output: 'gd-1.0.vapi',
@@ -125,12 +128,13 @@ if get_option('libgd-gir') or get_option('libgd-vapi')
                                                 '--pkg', 'gtk+-3.0',
                                                 '@INPUT@'],
                              install: false)
+        built_sources += vapi
     endif
 endif
 
-include = include_directories(meson.source_root())
+include = include_directories(meson.source_root(),
+                              meson.current_source_dir())
 
-# If you use libgd as meson subproject in your project, you'll want to make use
-# of libgd_dep variable
 libgd_dep = declare_dependency(link_with: libgd_lib,
-                               include_directories: include)
+                               include_directories: include,
+                               sources: built_sources)


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