diff options
-rw-r--r-- | libgd/meson.build | 202 | ||||
-rw-r--r-- | meson.build | 17 | ||||
-rw-r--r-- | meson_options.txt | 25 | ||||
-rw-r--r-- | meson_readme.md | 87 |
4 files changed, 331 insertions, 0 deletions
diff --git a/libgd/meson.build b/libgd/meson.build new file mode 100644 index 0000000..b9d5dd4 --- /dev/null +++ b/libgd/meson.build @@ -0,0 +1,202 @@ +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 + +# --------- Building ----------- + +static = get_option('static') +install_introspection = get_option('with-introspection') +with_vapi = get_option('with-vapi') + +if static + libgd_lib = static_library('gd', sources, + dependencies: [libgtk, libm], + include_directories: libgd_include, + c_args: c_args + ) +endif + +# Currently in Meson building gir requires a shared library +if not static or (install_introspection or with_vapi) + if not static and pkglibdir == '' + error('Installing shared library but pkglibdir is unset!') + endif + + libgd_shared_lib = shared_library('gd', sources, + dependencies: [libgtk, libm], + include_directories: libgd_include, + c_args: c_args, + install: not static, + install_dir: pkglibdir + ) + + if not static + libgd_lib = libgd_shared_lib + endif +endif + +if install_introspection or with_vapi + if install_introspection + if pkgdatadir == '' + error('Installing introspection but pkgdatadir is unset!') + elif pkglibdir == '' + error('Installing introspection but pkglibdir is unset!') + endif + endif + + libgd_gir = gnome.generate_gir(libgd_shared_lib, + sources : sources, + nsversion : '1.0', + namespace : 'Gd', + symbol_prefix : 'gd', + identifier_prefix : 'Gd', + includes : 'Gtk-3.0', + include_directories: libgd_include, + install: install_introspection, + install_dir_gir: join_paths(pkgdatadir, 'gir-1.0'), + install_dir_typelib: join_paths(pkglibdir, 'girepository-1.0'), + 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'] + ) + 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..7051e12 --- /dev/null +++ b/meson.build @@ -0,0 +1,17 @@ +project('libgd', 'c', + meson_version: '>= 0.38.0' +) + +if not meson.is_subproject() + error('This project is only intended to be used as a subproject!') +endif + +pkglibdir = get_option('pkglibdir') +pkgdatadir = get_option('pkgdatadir') + +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..fcab3a0 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,25 @@ +option('pkglibdir', type: 'string', value: '', + description: 'The private directory the shared library/typelib will be installed into.' +) +option('pkgdatadir', type: 'string', value: '', + description: 'The private directory the gir file will be installed into.' +) +option('static', type: 'boolean', value: false, + description: 'Build as a static library' +) +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..67b9bca --- /dev/null +++ b/meson_readme.md @@ -0,0 +1,87 @@ +See README for general information. Read below for usage with Meson. + +Usage +===== + +libgd is intended to be used as a submodule from other projects. This requires passing default_options to the subproject which was added in Meson 0.38.0. To see a full list of options you can run `mesonconf $your_build_dir`. If building a non-static library `pkglibdir` must be set to a private location to install to. For introspection files you also must set `pkgdatadir`. + +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: + +Shared Library +-------------- + +```meson +pkglibdir = join_paths(get_option('libdir'), meson.project_name()) +libgd = subproject('libgd', + default_options: [ + 'pkglibdir=' + pkglibdir, + 'with-tagged-entry=true' + ] +) +# Pass as dependency to another target +libgd_dep = libgd.get_variable('libgd_dep') +``` + +Static Library +-------------- + +```meson +libgd = subproject('libgd', + default_options: [ + 'with-tagged-entry=true', + 'static=true' + ] +) +libgd_dep = libgd.get_variable('libgd_dep') +``` + +Introspection +------------- + +```meson +pkglibdir = join_paths(get_option('libdir'), meson.project_name()) +pkgdatadir = join_paths(get_option('datadir'), meson.project_name()) +libgd = subproject('libgd', + default_options: [ + 'pkglibdir=' + pkglibdir, + 'pkgdatadir=' + pkgdatadir, + 'with-tagged-entry=true', + 'with-introspection=true' + ] +) +``` + +```python +import os +import gi +gi.require_version('GIRepository', '2.0') +from gi.repository import GIRepository +pkglibdir = '/usr/lib/foo' # This would be defined at build time +pkggirdir = os.path.join(pkglibdir, 'girepository-1.0') +GIRepository.Repository.prepend_search_path(pkggirdir) +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' + ] +) +# Pass as dependency to a Vala target +libgd_vapi_dep = libgd.get_variable('libgd_vapi_dep') +``` |