Commit 36a2e4f8 authored by Iñigo Martínez's avatar Iñigo Martínez

build: Port to meson build system

Meson is a build system focused on speed an ease of use, which
helps speeding up the software development. This patch adds meson
support along autotools.
parent c1b4f79d
install_subdir(
'hicolor',
exclude_files: 'gnome-characters.svg',
exclude_directories: ['scalable', '24x24', '512x512'],
install_dir: join_paths(characters_datadir, 'icons')
)
subdir('icons')
resource_data = files(
'icons/hicolor/scalable/categories/characters-arrow-symbolic.svg',
'icons/hicolor/scalable/categories/characters-bullet-symbolic.svg',
'icons/hicolor/scalable/categories/characters-currency-symbolic.svg',
'icons/hicolor/scalable/categories/characters-emoji-activities.svg',
'icons/hicolor/scalable/categories/characters-emoji-animals.svg',
'icons/hicolor/scalable/categories/characters-emoji-flags.svg',
'icons/hicolor/scalable/categories/characters-emoji-food.svg',
'icons/hicolor/scalable/categories/characters-emoji-objects.svg',
'icons/hicolor/scalable/categories/characters-emoji-smileys.svg',
'icons/hicolor/scalable/categories/characters-emoji-symbols.svg',
'icons/hicolor/scalable/categories/characters-emoji-travel.svg',
'icons/hicolor/scalable/categories/characters-latin-symbolic.svg',
'icons/hicolor/scalable/categories/characters-math-symbolic.svg',
'icons/hicolor/scalable/categories/characters-picture-symbolic.svg',
'icons/hicolor/scalable/categories/characters-punctuation-symbolic.svg',
'application.css',
'app-menu.ui',
'characterlist.ui',
'character.ui',
'mainview.ui',
'mainwindow.ui',
'menu.ui'
)
resources = [
[characters_name, resource_data],
[characters_background_name, files('ShellSearchProvider2.xml')]
]
foreach resource: resources
name = resource[0] + '.data'
gnome.compile_resources(
name,
name + '.gresource.xml',
gresource_bundle: true,
dependencies: resource[1],
install: true,
install_dir: characters_pkgdatadir
)
endforeach
desktop = characters_name + '.desktop'
i18n.merge_file(
desktop,
type: 'desktop',
input: desktop + '.in',
output: desktop,
po_dir: po_dir,
install: true,
install_dir: join_paths(characters_datadir, 'applications')
)
appdata = characters_name + '.appdata.xml'
i18n.merge_file(
appdata,
input: appdata + '.in',
output: appdata,
po_dir: po_dir,
install: true,
install_dir: join_paths(characters_datadir, 'metainfo')
)
service_conf = configuration_data()
service_conf.set('PACKAGE_NAME', meson.project_name())
service_conf.set('pkgdatadir', characters_pkgdatadir)
services = [
characters_name,
characters_background_name
]
foreach service: services
configure_file(
input: service + '.service.in',
output: service + '.service',
configuration: service_conf,
install: true,
install_dir: dbus_service_dir
)
endforeach
install_data(
characters_name + '.gschema.xml',
install_dir: join_paths(characters_datadir, 'glib-2.0', 'schemas')
)
install_data(
characters_name + '.search-provider.ini',
install_dir: join_paths(characters_datadir, 'gnome-shell', 'search-providers')
)
gc_h = 'gc.h'
sources = files('gc.c')
enum_types = 'gc-enumtypes'
gc_enums = gnome.mkenums(
enum_types,
sources: gc_h,
c_template: enum_types + '.c.template',
h_template: enum_types + '.h.template',
identifier_prefix: characters_ns,
symbol_prefix: characters_ns.to_lower()
)
cflags = [
'-DG_LOG_DOMAIN="libgc"',
'-DG_DISABLE_DEPRECATED',
'-DPREFIX="@0@"'.format(characters_prefix),
'-DLIBDIR="@0@"'.format(characters_libdir)
]
libgc = shared_library(
characters_ns.to_lower(),
sources: sources + gc_enums,
include_directories: top_inc,
dependencies: libgc_deps,
c_args: cflags,
install: true
)
gnome.generate_gir(
libgc,
sources: sources + [gc_enums[0], gc_h],
nsversion: characters_gir_version,
namespace: characters_ns,
identifier_prefix: characters_ns,
symbol_prefix: characters_ns.to_lower(),
header: gc_h,
includes: ['Gio-2.0', 'Gtk-3.0'],
install: true
)
project(
'org.gnome.Characters', 'c',
version: '3.26.2',
license: 'BSD3',
default_options: 'buildtype=debugoptimized',
meson_version: '>= 0.42.0'
)
characters_name = meson.project_name()
characters_background_name = characters_name + '.BackgroundService'
characters_version = meson.project_version()
characters_prefix = get_option('prefix')
characters_bindir = join_paths(characters_prefix, get_option('bindir'))
characters_datadir = join_paths(characters_prefix, get_option('datadir'))
characters_libdir = join_paths(characters_prefix, get_option('libdir'))
characters_libexecdir = join_paths(characters_prefix, get_option('libexecdir'))
characters_pkgdatadir = join_paths(characters_datadir, characters_name)
characters_gir_version = '1.0'
characters_ns = 'Gc'
cc = meson.get_compiler('c')
# *** Check for dbus service dir ***
dbus_service_dir = get_option('dbus_service_dir')
if dbus_service_dir == ''
dbus_dep = dependency('dbus-1', required: false)
assert(dbus_dep.found(), 'dbus-1 required but not found, please provide a valid D-Bus service dir')
dbus_service_dir = dbus_dep.get_pkgconfig_variable('session_bus_services_dir')
endif
libunistring_src = '''
#include <uniconv.h>
int main() {
u8_strconv_from_locale((char*)0);
};
'''
# FIXME: libunistring doesn't have pkgconfig support
assert(cc.links(libunistring_src, name: 'libunistring support', args: '-lunistring'), 'libunistring is required but not found')
# Just check that gjs-1.0 is present and recent enough
dependency('gjs-1.0', version: '>= 1.43.3')
libgc_deps = [
dependency('gio-2.0'),
dependency('gtk+-3.0'),
dependency('pango'),
declare_dependency(link_args: '-lunistring')
]
if get_option('pangoft2')
libgc_deps += dependency('pangoft2')
endif
gnome = import('gnome')
i18n = import('i18n')
po_dir = join_paths(meson.source_root(), 'po')
top_inc = include_directories('.')
subdir('po')
subdir('data')
# FIXME: local gnulib library is not built
#subdir('gllib')
subdir('lib')
subdir('src')
if get_option('installed_tests')
subdir('tests')
endif
configure_file(
output: 'config.h',
configuration: configuration_data()
)
meson.add_install_script(
'meson_post_install.py',
characters_datadir,
characters_bindir
)
option('dbus_service_dir', type: 'string', value: '', description: 'custom directory for dbus service files')
option('pangoft2', type: 'boolean', value: true, description: 'enable pangoft2 support')
option('installed_tests', type: 'boolean', value: false, description: 'Enable installation of some test cases')
#!/usr/bin/env python3
import glob
import os
import re
import subprocess
import sys
datadir = sys.argv[1]
destdir = os.environ.get('DESTDIR', '')
bindir = os.path.normpath(destdir + os.sep + sys.argv[2])
# FIXME: meson will not track the creation of these files
# https://github.com/mesonbuild/meson/blob/master/mesonbuild/scripts/uninstall.py#L39
if not os.path.exists(bindir):
os.makedirs(bindir)
src = os.path.join(datadir, 'org.gnome.Characters', 'org.gnome.Characters')
dest = os.path.join(bindir, 'gnome-characters')
subprocess.call(['ln', '-s', '-f', src, dest])
if not os.environ.get('DESTDIR'):
icondir = os.path.join(datadir, 'icons', 'hicolor')
print('Update icon cache...')
subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir])
schemadir = os.path.join(datadir, 'glib-2.0', 'schemas')
print('Compiling gsettings schemas...')
subprocess.call(['glib-compile-schemas', schemadir])
# FIXME
'''
search_pattern = '/*.desktop'
desktopdir = os.path.join(datadir, 'applications')
print('Validate desktop files...')
[subprocess.call(['desktop-file-validate', file])
for file in glob.glob(desktopdir + search_pattern, recursive=False)]
'''
i18n.gettext(characters_name, preset: 'glib')
script_conf = configuration_data()
script_conf.set('GJS', find_program('gjs').path())
script_conf.set('PACKAGE_VERSION', characters_version)
script_conf.set('libdir', characters_libdir)
script_conf.set('prefix', characters_prefix)
scripts = [
characters_name,
characters_background_name
]
foreach script: scripts
configure_file(
input: script + '.in',
output: script,
configuration: script_conf,
install: true,
install_dir: characters_pkgdatadir
)
endforeach
common_resource_data = files(
'params.js',
'util.js'
)
resource_data = common_resource_data + files(
'categoryList.js',
'character.js',
'characterList.js',
'main.js',
'menu.js',
'window.js'
)
resources = [[characters_name, resource_data]]
resource_data = common_resource_data + files(
'searchProvider.js',
'service.js'
)
resources += [[characters_background_name, resource_data]]
foreach resource: resources
name = resource[0] + '.src'
gnome.compile_resources(
name,
name + '.gresource.xml',
gresource_bundle: true,
dependencies: resource[1],
install: true,
install_dir: characters_pkgdatadir
)
endforeach
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
installed_tests_execdir = join_paths(characters_libexecdir, 'installed-tests', characters_name)
installed_tests_metadir = join_paths(characters_datadir, 'installed-tests', characters_name)
tests = ['smoke_test.py']
tests_data = files('testutil.py')
install_data(
tests + tests_data,
install_dir: installed_tests_execdir
)
template = 'test.in'
foreach test: tests
tests_conf = configuration_data()
tests_conf.set('testdir', installed_tests_execdir)
configure_file(
input: template,
output: test + '.test',
configuration: tests_conf,
install: true,
install_dir: installed_tests_metadir
)
endforeach
[Test]
Type=session-exclusive
Exec=@testdir@/smoke_test.py
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment