summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Piédallu <felix@piedallu.me>2020-02-20 16:12:53 +0100
committerBastien Nocera <hadess@hadess.net>2020-02-20 18:05:39 +0100
commit41267fdbe47c93d377f314780be7b9fb5715686a (patch)
treead7097f5a6384363ac8be8232fa0cdff881c8157
parentbf8b2e770e2523827a1f13dcb8146e7b407cdb67 (diff)
build: Add meson build system
-rw-r--r--data/meson.build37
-rw-r--r--meson.build87
-rw-r--r--meson_options.txt8
-rw-r--r--po/meson.build7
-rw-r--r--src/meson.build34
-rw-r--r--tests/meson.build52
6 files changed, 225 insertions, 0 deletions
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 0000000..35bd8a5
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,37 @@
+
+install_man('update-mime-database.1')
+
+freedesktop_org_xml = custom_target('freedesktop.org.xml',
+ input : files(
+ 'freedesktop.org.xml.in',
+ 'its/shared-mime-info.its',
+ 'its/shared-mime-info.loc',
+ ),
+ output: 'freedesktop.org.xml',
+ command: [
+ find_program('freedesktop_generate.sh'),
+ '--meson',
+ meson.source_root(),
+ meson.build_root()
+ ],
+ install: true,
+ install_dir: get_option('datadir') / 'mime' / 'packages',
+)
+
+custom_target('shared-mime-info-spec-html',
+ input : 'shared-mime-info-spec.xml',
+ output: 'shared-mime-info-spec-html',
+ command: [
+ xmlto,
+ '-o', '@OUTPUT@',
+ 'html-nochunks',
+ '@INPUT@',
+ ],
+ build_by_default: true,
+)
+
+pkgconfig.generate(
+ name: 'shared-mime-info',
+ description: 'Freedesktop common MIME database',
+ version: meson.project_version(),
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..f1da353
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,87 @@
+
+project('shared-mime-info',
+ 'c',
+ version: '1.15',
+ meson_version: '>=0.49.0'
+)
+
+config = configuration_data()
+
+i18n = import('i18n')
+pkgconfig = import('pkgconfig')
+
+cc = meson.get_compiler('c')
+
+###############################################################################
+# Project configuration
+
+config.set_quoted('PACKAGE', meson.project_name())
+config.set_quoted('VERSION', meson.project_version())
+
+###############################################################################
+# Find tools
+
+itstool = find_program('itstool')
+xmllint = find_program('xmllint')
+xmlto = find_program('xmlto')
+
+###############################################################################
+# Find xdgmime
+
+xdgmime = get_option('xdgmime-path') / 'src'
+
+xdgmime_print_mime_data = find_program(xdgmime/'print-mime-data', required: false)
+xdgmime_test_mime_data = find_program(xdgmime/'test-mime-data', required: false)
+xdgmime_test_mime = find_program(xdgmime/'test-mime', required: false)
+xdgmime_found = (
+ xdgmime_print_mime_data.found() and
+ xdgmime_test_mime_data.found() and
+ xdgmime_test_mime.found()
+)
+
+if not xdgmime_found
+ warning('''
+***************************************************************************
+*** xdgmime not compiled, test suite cannot run. Check HACKING for info ***
+***************************************************************************
+ ''')
+endif
+
+###############################################################################
+# Dependencies
+
+check_functions = [
+ 'fdatasync',
+]
+foreach function : check_functions
+ config.set('HAVE_'+function.to_upper(), cc.has_function(function))
+endforeach
+
+
+libxml = dependency('libxml-2.0', version: '>=2.4')
+glib2 = dependency('glib-2.0', version: '>=2.6.0')
+
+gio = dependency('gio-2.0', required: false)
+
+subdir('po')
+subdir('data')
+subdir('src')
+subdir('tests')
+
+if get_option('update-mimedb')
+ upd_tool = (meson.is_cross_build()
+ ? find_program('update-mime-database').path()
+ : update_mime_database.full_path()
+ )
+ meson.add_install_script('sh', '-c', ' '.join([
+ upd_tool, '-V', '${MESON_INSTALL_DESTDIR_PREFIX}' / get_option('datadir') / 'mime',
+ ]))
+endif
+
+run_target('Changelog',
+ command: [ 'env',
+ 'git', 'log', '--stat',
+ '--after="Tue Oct 6 14:46:33 2009 +0000"',
+ '>', meson.source_root() / 'Changelog',
+ ],
+)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..9dcf72c
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,8 @@
+
+option('update-mimedb', type: 'boolean', value: false,
+ description: 'Call update-mime-database after install. It should not be enabled if DESTDIR is used.',
+)
+
+option('xdgmime-path', type: 'string', value: './xdgmime',
+ description: 'Path to the xdgmime executable',
+)
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 0000000..21498b2
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1,7 @@
+
+i18n.gettext(meson.project_name(),
+ preset: 'glib',
+)
+
+
+test('translations', find_program('check_translations.sh'))
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..5da9ddf
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,34 @@
+
+configure_file(
+ output: 'config.h',
+ configuration: config,
+)
+
+update_mime_database = executable('update-mime-database',
+ 'update-mime-database.c',
+ dependencies: [
+ glib2,
+ libxml,
+ ],
+ install: true,
+)
+
+test_subclassing = executable('test-subclassing',
+ 'test-subclassing.c',
+ dependencies: [
+ glib2,
+ libxml,
+ ],
+ install: false,
+)
+
+if gio.found()
+ test_tree_magic = executable('tree-magic',
+ 'test-tree-magic.c',
+ dependencies:[
+ glib2,
+ gio,
+ ],
+ install: false,
+ )
+endif
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..c506692
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,52 @@
+if meson.is_cross_build()
+ subdir_done()
+endif
+
+if xdgmime_found
+ run_target('test-staging',
+ command: [
+ find_program('test_staging.sh'),
+ meson.source_root(),
+ meson.build_root(),
+ freedesktop_org_xml,
+ update_mime_database,
+ xdgmime_print_mime_data.path(),
+ ]
+ )
+
+ test('test-mime',
+ find_program('test_mime.sh'),
+ args: [
+ meson.source_root(),
+ meson.build_root(),
+ freedesktop_org_xml,
+ update_mime_database,
+ xdgmime_test_mime_data.path(),
+ xdgmime_test_mime.path(),
+ test_tree_magic.full_path(),
+ ],
+ )
+endif
+
+run_target('check-generic-icons',
+ command: [ find_program('test_generic_icons.sh'), freedesktop_org_xml ],
+)
+
+test('No duplicate mime-types',
+ find_program('test_duplicate_mime_types.sh'),
+ args: freedesktop_org_xml,
+)
+
+test('xmllint freedesktop.org.xml',
+ xmllint,
+ args: [ '--noout', '--valid', freedesktop_org_xml, ],
+)
+
+test('Case sensitivity',
+ find_program('test-case-sensitivity.sh'),
+)
+
+test('update-mime-database',
+ update_mime_database,
+ args: meson.current_source_dir() / 'mime-db-tests',
+)