diff options
author | Richard Hughes <richard@hughsie.com> | 2016-08-24 12:20:51 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2016-12-06 21:21:49 +0000 |
commit | 0dddb3f191a90586d4c444136ef4e7cc3b192103 (patch) | |
tree | 047c605d15bccd832cf1ee96c4387c0a2865ad70 | |
parent | e81797f518bc579e7c4256756eacd475fe8c652e (diff) | |
download | appstream-glib-0dddb3f191a90586d4c444136ef4e7cc3b192103.tar.gz |
Implement meson buildsystem as experiment
With lots of help from Igor Gnatenko, many thanks.
-rw-r--r-- | client/meson.build | 41 | ||||
-rw-r--r-- | data/installed-tests/meson.build | 10 | ||||
-rw-r--r-- | data/meson.build | 10 | ||||
-rw-r--r-- | data/tests/meson.build | 36 | ||||
-rw-r--r-- | libappstream-builder/appstream-builder.map | 6 | ||||
-rw-r--r-- | libappstream-builder/meson.build | 123 | ||||
-rw-r--r-- | libappstream-builder/plugins/meson.build | 26 | ||||
-rw-r--r-- | libappstream-glib/appstream-glib.map | 6 | ||||
-rw-r--r-- | libappstream-glib/as-version.h.in | 6 | ||||
-rw-r--r-- | libappstream-glib/meson.build | 223 | ||||
-rw-r--r-- | meson.build | 124 | ||||
-rw-r--r-- | meson_options.txt | 5 |
12 files changed, 613 insertions, 3 deletions
diff --git a/client/meson.build b/client/meson.build new file mode 100644 index 0000000..f11db12 --- /dev/null +++ b/client/meson.build @@ -0,0 +1,41 @@ +as_util_cargs = ['-DG_LOG_DOMAIN="As"'] + +if get_option('enable-builder') + appstream_builder = executable( + 'appstream-builder', + sources : 'as-builder.c', + include_directories : [ + include_directories('..'), + asglib_incdir, + asbuilder_incdir, + ], + dependencies : [ + glib, + gdkpixbuf, + soup, + libarchive + ], + link_with : [ + asglib, + asbuilder + ], + c_args : as_util_cargs + ) +endif + +appstream_util = executable( + 'appstream-util', + sources : 'as-util.c', + include_directories : [ + include_directories('@0@/..'.format(meson.current_build_dir())), + asglib_incdir, + ], + dependencies : [ + glib, + gdkpixbuf, + soup, + libarchive + ], + link_with : asglib, + c_args : as_util_cargs +) diff --git a/data/installed-tests/meson.build b/data/installed-tests/meson.build new file mode 100644 index 0000000..80ed69e --- /dev/null +++ b/data/installed-tests/meson.build @@ -0,0 +1,10 @@ +configure_file( + input : 'appdata-validate.test.in', + output : 'appdata-validate.test', + configuration : conf +) +configure_file( + input : 'destdir-check.test.in', + output : 'destdir-check.test', + configuration : conf +) diff --git a/data/meson.build b/data/meson.build new file mode 100644 index 0000000..c4b4ef4 --- /dev/null +++ b/data/meson.build @@ -0,0 +1,10 @@ +install_data('appstream-xml.m4', install_dir : 'share/aclocal') + +install_man('appstream-util.1') + +if get_option('enable-builder') + install_man('appstream-builder.1') +endif + +subdir('installed-tests') +subdir('tests') diff --git a/data/tests/meson.build b/data/tests/meson.build new file mode 100644 index 0000000..4dfa5f2 --- /dev/null +++ b/data/tests/meson.build @@ -0,0 +1,36 @@ +if get_option('enable-builder') + custom_target('firmware-2.0.0', + output : 'colorhug-als-2.0.0.cab', + input : [ + 'firmware/2_0_0/firmware.inf', + 'firmware/2_0_0/firmware.bin' + ], + command : [gcab, '--create', '--nopath', '@OUTPUT@', '@INPUT@'], + install : false, + install_dir : '' + ) + + custom_target('firmware-2.0.1', + output : 'colorhug-als-2.0.1.cab', + input : [ + 'firmware/2_0_1/firmware.inf', + 'firmware/2_0_1/firmware.bin', + 'firmware/2_0_1/firmware.metainfo.xml' + ], + command : [gcab, '--create', '--nopath', '@OUTPUT@', '@INPUT@'], + install : false, + install_dir : '' + ) + + custom_target('firmware-2.0.2', + output : 'colorhug-als-2.0.2.cab', + input : [ + 'firmware/2_0_2/firmware.inf', + 'firmware/2_0_2/firmware.bin', + 'firmware/2_0_2/firmware.metainfo.xml' + ], + command : [gcab, '--create', '--nopath', '@OUTPUT@', '@INPUT@'], + install : false, + install_dir : '' + ) +endif diff --git a/libappstream-builder/appstream-builder.map b/libappstream-builder/appstream-builder.map new file mode 100644 index 0000000..e403981 --- /dev/null +++ b/libappstream-builder/appstream-builder.map @@ -0,0 +1,6 @@ +{ +global: + asb_*; +local: + *; +}; diff --git a/libappstream-builder/meson.build b/libappstream-builder/meson.build new file mode 100644 index 0000000..f13f130 --- /dev/null +++ b/libappstream-builder/meson.build @@ -0,0 +1,123 @@ +pkgg = import('pkgconfig') + +asbuilder_cargs = [ + '-DG_LOG_DOMAIN="Asb"', + '-DASB_PLUGIN_DIR="@0@/@1@/asb-plugins-@2@"'.format( + get_option('prefix'), get_option('libdir'), + as_plugin_version, + ), +] + +deps = [glib, gmodule, gdkpixbuf, libarchive, soup, yaml] + +if rpm.found() + deps = deps + [rpm] +endif + +if alpm.found() + deps = deps + [alpm] +endif + +headers = [ + 'appstream-builder.h', + 'asb-app.h', +] + +sources = [ + 'asb-app.c', + 'asb-app.h', + 'asb-context.c', + 'asb-context.h', + 'asb-context-private.h', + 'asb-package.c', + 'asb-package-cab.c', + 'asb-package-cab.h', + 'asb-package-deb.c', + 'asb-package-deb.h', + 'asb-package.h', + 'asb-task.c', + 'asb-task.h', + 'asb-utils.c', + 'asb-utils.h', + 'asb-plugin.c', + 'asb-plugin.h', + 'asb-plugin-loader.c', + 'asb-plugin-loader.h', +] + +if rpm.found() + sources = sources + ['asb-package-rpm.c', 'asb-package-rpm.h'] +endif + +if alpm.found() + sources = sources + ['asb-package-alpm.c', 'asb-package-alpm.h'] +endif + +mapfile = 'appstream-builder.map' +vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) +asbuilder = shared_library( + 'appstream-builder', sources, + soversion : lt_current, + version : lt_version, + dependencies : deps, + c_args : asbuilder_cargs, + include_directories : [ + top_build_incdir, + asglib_incdir, + ], + link_args : vflag, + link_depends : mapfile, + link_with : asglib, + install : true +) +asbuilder_incdir = include_directories('.') + +subdir('plugins') + +pkgg.generate( + version : as_version, + libraries : asbuilder, + name : 'appstream-builder', + description : 'Objects and helper methods to help reading and writing AppStream metadata', + filebase : 'appstream-builder', + subddirs : 'appstream-builder' +) + +asb_self_test = executable( + 'asb-self-test', 'asb-self-test.c', + include_directories : [ + include_directories('..'), + asglib_incdir, + ], + dependencies : [glib, gdkpixbuf, soup], + c_args : cargs + [ + '-DTESTDIRSRC="@0@/../data/tests"'.format(meson.current_source_dir()), + '-DTESTDIRBUILD="@0@/../data/tests"'.format(meson.current_build_dir()), + '-DTESTPLUGINDIR="@0@/plugins"'.format(meson.current_build_dir()), + ], + link_with : asbuilder +) +test('asb-self-test', asb_self_test) + +asbuilder_introspection_srcs = [ + 'asb-app.c', + 'asb-app.h', + 'asb-context.c', + 'asb-context.h', + 'asb-context-private.h', + 'asb-package.c', + 'asb-package.h', + 'asb-task.c', + 'asb-task.h', +] + +#gnome.generate_gir(asbuilder, +# sources : asbuilder_introspection_srcs, +# nsversion : '1.0', +# namespace : 'AppStreamBuilder', +# symbol_prefix : 'asb_', +# identifier_prefix : 'Asb', +# export_packages : 'appstream-glib', +# includes : ['AppStreamGlib-1.0', 'GObject-2.0', 'Gio-2.0', 'GdkPixbuf-2.0'], +# install : true +#) diff --git a/libappstream-builder/plugins/meson.build b/libappstream-builder/plugins/meson.build new file mode 100644 index 0000000..18849ca --- /dev/null +++ b/libappstream-builder/plugins/meson.build @@ -0,0 +1,26 @@ +asb_plugins_cargs = ['-DG_LOG_DOMAIN="Asb"'] + +asb_plugins = [ + ['gettext', 'asb-plugin-gettext.c', []], + ['hardcoded', 'asb-plugin-hardcoded.c', []], + ['desktop', 'asb-plugin-desktop.c', []], + ['appdata', 'asb-plugin-appdata.c', []], + ['font', 'asb-plugin-font.c', [gdk, freetype, fontconfig]], +] + +foreach i : asb_plugins + shared_library('libasb_plugin_@0@'.format(i.get(0)), + sources : i.get(1), + include_directories: [ + top_build_incdir, + asbuilder_incdir, + asglib_incdir, + ], + dependencies : [ + glib, gdkpixbuf, soup, + i.get(2), + ], + link_with : asbuilder, + c_args : asb_plugins_cargs + ) +endforeach diff --git a/libappstream-glib/appstream-glib.map b/libappstream-glib/appstream-glib.map new file mode 100644 index 0000000..30a965c --- /dev/null +++ b/libappstream-glib/appstream-glib.map @@ -0,0 +1,6 @@ +{ +global: + as_*; +local: + *; +}; diff --git a/libappstream-glib/as-version.h.in b/libappstream-glib/as-version.h.in index 0245caa..e580fff 100644 --- a/libappstream-glib/as-version.h.in +++ b/libappstream-glib/as-version.h.in @@ -38,9 +38,9 @@ /* compile time version */ -#define AS_MAJOR_VERSION (@AS_MAJOR_VERSION@) -#define AS_MINOR_VERSION (@AS_MINOR_VERSION@) -#define AS_MICRO_VERSION (@AS_MICRO_VERSION@) +#define AS_MAJOR_VERSION (@AS_MAJOR_VERSION_CONF@) +#define AS_MINOR_VERSION (@AS_MINOR_VERSION_CONF@) +#define AS_MICRO_VERSION (@AS_MICRO_VERSION_CONF@) /* check whether a As version equal to or greater than * major.minor.micro. diff --git a/libappstream-glib/meson.build b/libappstream-glib/meson.build new file mode 100644 index 0000000..de3a487 --- /dev/null +++ b/libappstream-glib/meson.build @@ -0,0 +1,223 @@ +pkgg = import('pkgconfig') + +cargs = [ + '-DG_LOG_DOMAIN="As"', + '-DLOCALSTATEDIR="/var"' +] + +deps = [glib, gdkpixbuf, giounix, libarchive, soup, uuid, libgcab] + +if yaml.found() + deps += yaml +endif + +asresources = gnome.compile_resources( + 'as-resources', 'appstream-glib.gresource.xml', + c_name : 'as' +) + +configure_file( + input : 'as-version.h.in', + output : 'as-version.h', + install_dir : get_option('includedir') + 'libappstream-glib', + configuration : conf +) + +headers = [ + 'appstream-glib.h', + 'as-app.h', + 'as-bundle.h', + 'as-checksum.h', + 'as-content-rating.h', + 'as-enums.h', + 'as-icon.h', + 'as-image.h', + 'as-inf.h', + 'as-markup.h', + 'as-monitor.h', + 'as-node.h', + 'as-problem.h', + 'as-profile.h', + 'as-provide.h', + 'as-release.h', + 'as-screenshot.h', + 'as-store.h', + 'as-tag.h', + 'as-translation.h', + 'as-utils.h' +] + +sources = [ + 'as-app-builder.c', + 'as-app-builder.h', + 'as-app.c', + 'as-app-desktop.c', + 'as-app-inf.c', + 'as-app-private.h', + 'as-app-validate.c', + 'as-bundle.c', + 'as-bundle.c', + 'as-bundle.h', + 'as-bundle-private.h', + 'as-bundle-private.h', + 'as-checksum.c', + 'as-checksum-private.h', + 'as-content-rating.c', + 'as-content-rating.h', + 'as-content-rating-private.h', + 'as-enums.c', + 'as-icon.c', + 'as-icon-private.h', + 'as-image.c', + 'as-image-private.h', + 'as-inf.c', + 'as-inf.h', + 'as-markup.c', + 'as-markup.h', + 'as-monitor.c', + 'as-monitor.c', + 'as-monitor.h', + 'as-monitor.h', + 'as-node.c', + 'as-node-private.h', + 'as-problem.c', + 'as-problem.h', + 'as-profile.c', + 'as-profile.h', + 'as-provide.c', + 'as-provide-private.h', + 'as-ref-string.c', + 'as-ref-string.h', + 'as-release.c', + 'as-release-private.h', + asresources, + 'as-review.c', + 'as-review.h', + 'as-review-private.h', + 'as-screenshot.c', + 'as-screenshot-private.h', + 'as-stemmer.c', + 'as-stemmer.h', + 'as-store.c', + 'as-store-cab.c', + 'as-store-cab.h', + 'as-suggest.c', + 'as-suggest.h', + 'as-suggest-private.h', + 'as-tag.c', + 'as-translation.c', + 'as-translation.h', + 'as-translation-private.h', + 'as-utils.c', + 'as-utils-private.h', + 'as-yaml.c', + 'as-yaml.h' +] + +if gperf.found() + astagpriv = custom_target( + 'gperf as-tag', + output : 'as-tag-private.h', + input : 'as-tag.gperf', + command : [ + gperf, + '@INPUT@', + '--output-file', + '@OUTPUT@' + ] + ) + sources = sources + [astagpriv] +endif + +install_headers(headers, subdir : 'libappstream-glib') + +mapfile = 'appstream-glib.map' +vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) +asglib = shared_library( + 'appstream-glib', sources, + soversion : lt_current, + version : lt_version, + dependencies : deps, + c_args : cargs, + include_directories : include_directories('..'), + link_args : vflag, + link_depends : mapfile, + install : true +) +asglib_incdir = include_directories('.') + +pkgg.generate( + version : as_version, + libraries : asglib, + name : 'appstream-glib', + description : 'Objects and helper methods to help reading and writing AppStream metadata', + filebase : 'appstream-glib', + subddirs : 'appstream-glib' +) + +selftest = executable( + 'as-self-test', 'as-self-test.c', + include_directories : include_directories('..'), + dependencies : deps, + c_args : cargs + ['-DTESTDIRSRC="@0@/../data/tests"'.format(meson.current_source_dir())] + + ['-DTESTDIRBUILD="@0@/../data/tests"'.format(meson.current_build_dir())], + link_with : asglib +) +test('as-self-test', selftest) + +introspection_sources = [ + 'as-app.c', + 'as-app.h', + 'as-app-validate.c', + 'as-bundle.c', + 'as-bundle.h', + 'as-checksum.c', + 'as-checksum.h', + 'as-content-rating.c', + 'as-content-rating.h', + 'as-enums.c', + 'as-enums.h', + 'as-icon.c', + 'as-icon.h', + 'as-image.c', + 'as-image.h', + 'as-inf.c', + 'as-inf.h', + 'as-node.c', + 'as-node.h', + 'as-problem.c', + 'as-problem.h', + 'as-provide.c', + 'as-provide.h', + 'as-release.c', + 'as-release.h', + 'as-review.c', + 'as-review.h', + 'as-screenshot.c', + 'as-screenshot.h', + 'as-store.c', + 'as-store.h', + 'as-suggest.c', + 'as-suggest.h', + 'as-tag.c', + 'as-tag.h', + 'as-translation.c', + 'as-translation.h', + 'as-utils.c', + 'as-utils.h' +] + +gnome.generate_gir(asglib, + sources : introspection_sources, + nsversion : '1.0', + namespace : 'AppStreamGlib', + symbol_prefix : 'as_', + identifier_prefix : 'As', + export_packages : 'appstream-glib', + includes : [ + 'GObject-2.0', + 'Gio-2.0', + 'GdkPixbuf-2.0' + ], + install : true +) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..31b4dbb --- /dev/null +++ b/meson.build @@ -0,0 +1,124 @@ +project('appstream-glib', 'c', + version : '0.6.5', + license : 'LGPL-2.1+', + default_options : ['b_asneeded=True', 'b_lundef=True'], + meson_version : '>=0.34.0') + +as_version = meson.project_version() +varr = as_version.split('.') +as_major_version = varr[0] +as_minor_version = varr[1] +as_micro_version = varr[2] + +conf = configuration_data() +conf.set('AS_MAJOR_VERSION_CONF', as_major_version) +conf.set('AS_MINOR_VERSION_CONF', as_minor_version) +conf.set('AS_MICRO_VERSION_CONF', as_micro_version) +conf.set('PACKAGE_VERSION', '"@0@"'.format(as_version)) + +# this refers to the plugin API version +# this is not in any way related to a package or soname version +as_plugin_version = '2' + +# libtool versioning - this applies to libpackagekit +# +# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details +# +# - If interfaces have been changed or added, but binary compatibility +# has been preserved, change: +# CURRENT += 1 +# REVISION = 0 +# AGE += 1 +# - If binary compatibility has been broken (eg removed or changed +# interfaces), change: +# CURRENT += 1 +# REVISION = 0 +# AGE = 0 +# - If the interface is the same as the previous version, but bugs are +# fixed, change: +# REVISION += 1 +lt_current = '8' +lt_revision = '10' +lt_age = '0' +lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision) + +glib_ver = '>= 2.45.8' +uuid = dependency('uuid') +glib = dependency('glib-2.0', version : glib_ver) +gmodule = dependency('gmodule-2.0', version : glib_ver) +giounix = dependency('gio-unix-2.0', version : glib_ver) +libarchive = dependency('libarchive') +soup = dependency('libsoup-2.4', version : '>= 2.51.92') +gdk = dependency('gdk-3.0') +gdkpixbuf = dependency('gdk-pixbuf-2.0', version : '>= 2.31.5') +libgcab = dependency('libgcab-1.0', required : false) + +# builder (default enabled) +if get_option('enable-builder') + gtk = dependency('gtk+-3.0') + gmodule = dependency('gmodule-2.0') + gcab = find_program('gcab') + if get_option('enable-rpm') + rpm = dependency('rpm') + conf.set('HAVE_RPM', 1) + endif + if get_option('enable-alpm') + alpm = dependency('libalpm') + conf.set('HAVE_ALPM', 1) + endif + if get_option('enable-fonts') + conf.set('HAVE_FONTS', 1) + freetype = dependency('freetype2', version : '>= 9.10.0') + fontconfig = dependency('fontconfig') + endif +endif +if get_option('enable-dep11') + yaml = dependency('yaml-0.1') + conf.set('AS_BUILD_DEP11', 1) +else + yaml = dependency('yaml-0.1', required : false) +endif + +# use gperf for faster string -> enum matching +gperf = find_program('gperf', required : false) +if gperf.found() + conf.set('HAVE_GPERF', 1) +endif + +gnome = import('gnome') + +conf.set_quoted('GETTEXT_PACKAGE', meson.project_version()) +conf.set_quoted('LOCALEDIR', get_option('localedir')) +configure_file( + output : 'config.h', + configuration : conf +) +top_build_incdir = include_directories(meson.current_build_dir()) + +add_global_arguments('-DAS_COMPILATION', language : 'c') + +subdir('libappstream-glib') +subdir('data') + +if get_option('enable-builder') + # depends on data + subdir('libappstream-builder') +endif + +# depends on libappstream-builder +subdir('client') + +archiver = find_program('git', required : false) +if archiver.found() + run_target('dist', 'git', 'archive', '--prefix=appstream-glib/', + 'HEAD', + '--output', 'appstream-glib-' + as_version + '.tar.gz') + +#-version=`./meson.py -v` +#-git archive --prefix meson-${version}/ HEAD | gzip > meson_${version}.tar.gz + +else + message('git-archive-all not found, you will not be able to run `ninja dist`') + message('Install git-archive-all with pip:') + message(' $ pip install git-archive-all') +endif diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..bc961ad --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,5 @@ +option('enable-dep11', type : 'boolean', value : true, description : 'enable DEP-11') +option('enable-builder', type : 'boolean', value : true, description : 'enable AppStream builder') +option('enable-rpm', type : 'boolean', value : true, description : 'enable RPM support') +option('enable-alpm', type : 'boolean', value : true, description : 'enable ALPM support') +option('enable-fonts', type : 'boolean', value : true, description : 'enable font support') |