Commit abb95c75 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.

https://bugzilla.gnome.org/show_bug.cgi?id=782707
parent c66f9e84
#!/bin/bash
# configure script adapter for Meson
# Based on build-api: https://github.com/cgwalters/build-api
# Copyright 2010, 2011, 2013 Colin Walters <walters@verbum.org>
# Copyright 2016, 2017 Emmanuele Bassi
# Copyright 2017 Iñigo Martínez <inigomartinez@gmail.com>
# Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php)
# Build API variables:
# Little helper function for reading args from the commandline.
# it automatically handles -a b and -a=b variants, and returns 1 if
# we need to shift $3.
read_arg() {
# $1 = arg name
# $2 = arg value
# $3 = arg parameter
local rematch='^[^=]*=(.*)$'
if [[ $2 =~ $rematch ]]; then
read "$1" <<< "${BASH_REMATCH[1]}"
else
read "$1" <<< "$3"
# There is no way to shift our callers args, so
# return 1 to indicate they should do it instead.
return 1
fi
}
sanitycheck() {
# $1 = arg name
# $1 = arg command
# $2 = arg alternates
local cmd=$( which $2 2>/dev/null )
if [ -x "$cmd" ]; then
read "$1" <<< "$cmd"
return 0
fi
test -z $3 || {
for alt in $3; do
cmd=$( which $alt 2>/dev/null )
if [ -x "$cmd" ]; then
read "$1" <<< "$cmd"
return 0
fi
done
}
echo -e "\e[1;31mERROR\e[0m: Command '$2' not found"
exit 1
}
checkoption() {
# $1 = arg
option="${1#*--}"
action="${option%%-*}"
name="${option#*-}"
if [ ${default_options[$name]+_} ]; then
case "$action" in
enable) meson_options[$name]=true;;
disable) meson_options[$name]=false;;
*) echo -e "\e[1;33mINFO\e[0m: Ignoring unknown action '$action'";;
esac
else
echo -e "\e[1;33mINFO\e[0m: Ignoring unknown option '$option'"
fi
}
echooption() {
# $1 = option
if [ ${meson_options[$1]+_} ]; then
echo ${meson_options[$1]}
elif [ ${default_options[$1]+_} ]; then
echo ${default_options[$1]}
fi
}
sanitycheck MESON 'meson'
sanitycheck MESONTEST 'mesontest'
sanitycheck NINJA 'ninja' 'ninja-build'
declare -A default_options=(
['zeitgeist']=true
['update-mimedb']=false
)
declare -A meson_options
while (($# > 0)); do
case "${1%%=*}" in
--prefix) read_arg prefix "$@" || shift;;
--bindir) read_arg bindir "$@" || shift;;
--sbindir) read_arg sbindir "$@" || shift;;
--libexecdir) read_arg libexecdir "$@" || shift;;
--datarootdir) read_arg datarootdir "$@" || shift;;
--datadir) read_arg datadir "$@" || shift;;
--sysconfdir) read_arg sysconfdir "$@" || shift;;
--libdir) read_arg libdir "$@" || shift;;
--mandir) read_arg mandir "$@" || shift;;
--includedir) read_arg includedir "$@" || shift;;
*) checkoption $1;;
esac
shift
done
# Defaults
test -z ${prefix} && prefix="/usr/local"
test -z ${bindir} && bindir=${prefix}/bin
test -z ${sbindir} && sbindir=${prefix}/sbin
test -z ${libexecdir} && libexecdir=${prefix}/bin
test -z ${datarootdir} && datarootdir=${prefix}/share
test -z ${datadir} && datadir=${datarootdir}
test -z ${sysconfdir} && sysconfdir=${prefix}/etc
test -z ${libdir} && libdir=${prefix}/lib
test -z ${mandir} && mandir=${prefix}/share/man
test -z ${includedir} && includedir=${prefix}/include
# The source directory is the location of this file
srcdir=$(dirname $0)
# The build directory is the current location
builddir=`pwd`
# If we're calling this file from the source directory then
# we automatically create a build directory and ensure that
# both Meson and Ninja invocations are relative to that
# location
if [[ -f "${builddir}/meson.build" ]]; then
mkdir -p _build
builddir="${builddir}/_build"
NINJA_OPT="-C ${builddir}"
fi
# Wrapper Makefile for Ninja
cat > Makefile <<END
# Generated by configure; do not edit
all:
CC="\$(CC)" CXX="\$(CXX)" ${NINJA} ${NINJA_OPT}
install:
DESTDIR="\$(DESTDIR)" ${NINJA} ${NINJA_OPT} install
check:
${MESONTEST} ${NINJA_OPT}
END
cmd_options=""
for key in "${!meson_options[@]}"; do
cmd_options="$cmd_options -Denable-$key=${meson_options[$key]}"
done
exec ${MESON} \
--prefix=${prefix} \
--libdir=${libdir} \
--libexecdir=${libexecdir} \
--datadir=${datadir} \
--sysconfdir=${sysconfdir} \
--bindir=${bindir} \
--includedir=${includedir} \
--mandir=${mandir} \
${cmd_options} \
${builddir} \
${srcdir}
apps_icon_sizes = [
'16x16',
'22x22',
'24x24',
'32x32',
'48x48',
'256x256'
]
# must be renamed to org.gnome.bijiben.png
foreach icon_size: apps_icon_sizes
install_data(
'_'.join(['hicolor', 'apps', icon_size, 'org.gnome.bijiben.png']),
install_dir: join_paths(bijiben_datadir, 'icons', 'hicolor', icon_size, 'apps')
)
endforeach
# must be renamed to org.gnome.bijiben-symbolic.svg
install_data(
'_'.join(['hicolor', 'apps', 'scalable', 'org.gnome.bijiben-symbolic.svg']),
install_dir: join_paths(bijiben_datadir, 'icons', 'hicolor', 'scalable', 'apps')
)
actions_icon_sizes = [
'16x16',
'24x24',
'48x48'
]
# must be renamed to note.png
foreach icon_size: actions_icon_sizes
install_data(
'_'.join(['hicolor', 'actions', icon_size, 'note.png']),
install_dir: join_paths(bijiben_pkgdatadir, 'icons', 'hicolor', icon_size, 'actions')
)
endforeach
# must be renamed to link.svg
install_data(
'_'.join(['hicolor', 'actions', 'scalable', 'link.svg']),
install_dir: join_paths(bijiben_pkgdatadir, 'icons', 'hicolor', 'scalable', 'actions')
)
subdir('icons')
mime = 'org.gnome.bijiben.xml'
custom_target(
mime,
input: mime + '.in',
output: mime,
command: intltool_xml_cmd,
install: true,
install_dir: join_paths(bijiben_datadir, 'mime', 'packages')
)
appdata = 'org.gnome.bijiben.appdata.xml'
custom_target(
appdata,
input: appdata + '.in',
output: appdata,
command: intltool_xml_cmd,
install: true,
install_dir: join_paths(bijiben_datadir, 'metainfo')
)
desktop = 'org.gnome.bijiben.desktop'
desktop_conf = configuration_data()
desktop_conf.set('VERSION', bijiben_version)
desktop_in = configure_file(
input: desktop + '.in.in',
output: desktop + '.in',
configuration: desktop_conf
)
custom_target(
desktop,
input: desktop_in,
output: desktop,
command: intltool_desktop_cmd,
install: true,
install_dir: join_paths(bijiben_datadir, 'applications')
)
service_conf = configuration_data()
service_conf.set('libexecdir', bijiben_libexecdir)
service = 'org.gnome.bijiben.SearchProvider.service'
configure_file(
input: service + '.in',
output: service,
install: true,
install_dir: join_paths(bijiben_datadir, 'dbus-1', 'services'),
configuration: service_conf
)
install_data(
'org.gnome.bijiben-search-provider.ini',
install_dir: join_paths(bijiben_datadir, 'gnome-shell', 'search-providers')
)
search_provider_dbus_iface = files('shell-search-provider-dbus-interfaces.xml')
web_files = files(
'Default.css',
'bijiben.js'
)
install_data(
web_files,
install_dir: bijiben_pkgdatadir
)
install_data(
'org.gnome.bijiben.gschema.xml',
install_dir: join_paths(bijiben_datadir, 'glib-2.0', 'schemas')
)
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
# please keep this list sorted alphabetically
#
cs
de
el
es
fr
hu
ko
pl
pt_BR
sv
sources = [
'colors.page',
'create.page',
'cut-copy-paste.page',
'delete.page',
'delete-permanent.page',
'delete-restore.page',
'format-list.page',
'format-text.page',
'index.page',
'introduction.page',
'new-window.page',
'notebooks.page',
'rename.page',
'search.page',
'share.page',
'legal.xml'
]
media = [
'figures/hicolor_apps_48x48_bijiben.png',
'figures/hicolor_apps_16x16_bijiben.png',
'figures/notes-3-12.png'
]
gnome.yelp(
bijiben_name,
sources: sources,
media: media,
symlink_media: true
)
project(
'bijiben', 'c',
version: '3.26.1',
license: 'GPL3',
default_options: [
'buildtype=debugoptimized',
'warning_level=1'
],
meson_version: '>= 0.43.0'
)
bijiben_name = meson.project_name()
bijiben_version = meson.project_version()
bijiben_prefix = get_option('prefix')
bijiben_bindir = join_paths(bijiben_prefix, get_option('bindir'))
bijiben_libexecdir = join_paths(bijiben_prefix, get_option('libexecdir'))
bijiben_localedir = join_paths(bijiben_prefix, get_option('localedir'))
bijiben_datadir = join_paths(bijiben_prefix, get_option('datadir'))
bijiben_pkgdatadir = join_paths(bijiben_datadir, bijiben_name)
cc = meson.get_compiler('c')
config_h = configuration_data()
# defines
set_defines = [
# package
['PACKAGE', bijiben_name],
['PACKAGE_BUGREPORT', 'http://bugzilla.gnome.org/enter_bug.cgi?product=' + bijiben_name],
['PACKAGE_NAME', bijiben_name],
['PACKAGE_STRING', '@0@ @1@'.format(bijiben_name, bijiben_version)],
['PACKAGE_TARNAME', bijiben_name],
['PACKAGE_URL', 'https://wiki.gnome.org/Apps/Bijiben'],
['PACKAGE_VERSION', bijiben_version],
['VERSION', bijiben_version],
# i18n
['GETTEXT_PACKAGE', bijiben_name]
]
foreach define: set_defines
config_h.set_quoted(define[0], define[1])
endforeach
# compiler flags
common_flags = [
'-DHAVE_CONFIG_H',
'-DDATADIR="@0@"'.format(bijiben_datadir),
'-DPACKAGE_LOCALE_DIR="@0@"'.format(bijiben_localedir)
]
if get_option('buildtype').contains('debug')
test_cflags = [
'-fno-strict-aliasing',
'-Wcast-align',
'-Wdeclaration-after-statement',
'-Werror',
'-Wformat=2',
'-Winit-self',
'-Winline',
'-Wmissing-declarations',
'-Wmissing-format-attribute',
'-Wmissing-include-dirs',
'-Wmissing-noreturn',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wno-error=missing-field-initializers',
'-Wno-error=unused-parameter',
'-Wno-missing-field-initializers',
'-Wno-suggest-attribute=format',
'-Wno-unused-parameter',
'-Wold-style-definition',
'-Wpacked',
'-Wpointer-arith',
'-Wredundant-decls',
'-Wshadow',
'-Wstrict-prototypes',
'-Wswitch-default',
'-Wswitch-enum',
'-Wundef',
'-Wunused-but-set-variable',
'-Wwrite-strings'
]
common_flags += cc.get_supported_arguments(test_cflags)
endif
add_project_arguments(common_flags, language: 'c')
libgd = subproject(
'libgd',
default_options: [
'static=true',
'with-view-common=true',
'with-gtk-hacks=true',
'with-main-view=true',
'with-tagged-entry=true'
]
)
libgd_dep = libgd.get_variable('libgd_dep')
tracker_sparql_dep = dependency('tracker-sparql-1.0', required: false)
if not tracker_sparql_dep.found()
tracker_sparql_dep = dependency('tracker-sparql-0.18', required: true)
endif
bijiben_deps = [
libgd_dep,
tracker_sparql_dep,
dependency('gio-unix-2.0'),
dependency('glib-2.0', version: '>= 2.53.4'),
dependency('goa-1.0'),
dependency('gtk+-3.0', version: '>= 3.11.4'),
dependency('libecal-1.2', version: '>= 3.13.90'),
dependency('libedataserver-1.2', version: '>= 3.13.90'),
dependency('libxml-2.0'),
dependency('uuid'),
dependency('webkit2gtk-4.0', version: '>= 2.10'),
cc.find_library('m')
]
gnome = import('gnome')
i18n = import('i18n')
po_dir = join_paths(meson.source_root(), 'po')
intltool_merge = find_program('intltool-merge')
intltool_cache = join_paths(po_dir, '.intltool-merge-cache')
intltool_desktop_cmd = [intltool_merge, '-d', '-u', '-c', intltool_cache, po_dir, '@INPUT@', '@OUTPUT@']
intltool_xml_cmd = [intltool_merge, '-x', '-u', '-c', intltool_cache, po_dir, '@INPUT@', '@OUTPUT@']
top_inc = include_directories('.')
subdir('data')
subdir('src')
subdir('po')
subdir('help')
configure_file(
output: 'config.h',
configuration: config_h
)
meson.add_install_script(
'meson_post_install.py',
bijiben_datadir,
get_option('enable-update-mimedb') ? 'update-mimedb' : ''
)
output = ' Version: ' + bijiben_version + '\n'
output += ' Enable Zeitgeist ' + enable_zeitgeist.to_string() + '\n'
message(output)
option('enable-zeitgeist', type: 'boolean', value: true, description: 'Enable Zeitgeist')
option('enable-update-mimedb', type: 'boolean', value: true, description: 'update-mime-database after install')
#!/usr/bin/env python3
import glob
import os
import re
import subprocess
import sys
if not os.environ.get('DESTDIR'):
datadir = sys.argv[1]
name_pattern = re.compile('hicolor_(?:apps|actions)_(?:\d+x\d+|scalable)_(.*)')
search_pattern = '/**/hicolor_*'
actions_icondir = os.path.join(datadir, 'bijiben', 'icons', 'hicolor')
[os.rename(file, os.path.join(os.path.dirname(file), name_pattern.search(file).group(1)))
for file in glob.glob(actions_icondir + search_pattern, recursive=True)]
icondir = os.path.join(datadir, 'icons', 'hicolor')
[os.rename(file, os.path.join(os.path.dirname(file), name_pattern.search(file).group(1)))
for file in glob.glob(icondir + search_pattern, recursive=True)]
print('Update icon cache...')
subprocess.call(['gtk-update-icon-cache', '-f', '-t', icondir])
schemadir = os.path.join(datadir, 'glib-2.0', 'schemas')
print('Compile gsettings schemas...')
subprocess.call(['glib-compile-schemas', schemadir])
desktop_file = os.path.join(datadir, 'applications', 'org.gnome.bijiben.desktop')
print('Validate desktop file...')
subprocess.call(['desktop-file-validate', desktop_file])
if sys.argv[2] == 'update-mimedb':
mimedir = os.path.join(datadir, 'mime')
print('Update mime database...')
subprocess.call(['update-mime-database', mimedir])
i18n.gettext(bijiben_name, preset: 'glib')
sources = files(
'deserializer/biji-lazy-deserializer.c',
'deserializer/biji-tomboy-reader.c',
'editor/biji-editor-selection.c',
'editor/biji-webkit-editor.c',
'provider/biji-import-provider.c',
'provider/biji-local-note.c',
'provider/biji-local-provider.c',
'provider/biji-memo-note.c',
'provider/biji-memo-provider.c',
'provider/biji-own-cloud-note.c',
'provider/biji-own-cloud-provider.c',
'provider/biji-provider.c',
'serializer/biji-lazy-serializer.c',
'biji-date-time.c',
'biji-error.c',
'biji-info-set.c',
'biji-item.c',
'biji-manager.c',
'biji-notebook.c',
'biji-note-id.c',
'biji-note-obj.c',
'biji-string.c',
'biji-timeout.c',
'biji-tracker.c',
'biji-zeitgeist.c'
)
marshalers = 'biji-marshalers'
sources += gnome.genmarshal(
marshalers,
sources: marshalers + '.list',
prefix: '_biji_marshal'
)
deps = bijiben_deps
cflags = []
enable_zeitgeist = get_option('enable-zeitgeist')
if enable_zeitgeist
deps += [dependency('zeitgeist-2.0')]
cflags += '-DBUILD_ZEITGEIST'
endif
libbiji = static_library(
'biji',
sources: sources,
include_directories: top_inc,
dependencies: deps,
c_args: cflags
)
libbiji_dep = declare_dependency(
link_with: libbiji,
include_directories: include_directories('.'),
dependencies: deps
)
subdir('libbiji')
sources = files(
'bjb-app-menu.c',
'bjb-bijiben.c',
'bjb-color-button.c',
'bjb-controller.c',
'bjb-debug.c',
'bjb-editor-toolbar.c',
'bjb-empty-results-box.c',
'bjb-import-dialog.c',
'bjb-load-more-button.c',
'bjb-main.c',
'bjb-main-toolbar.c',
'bjb-main-view.c',
'bjb-note-view.c',
'bjb-organize-dialog.c',
'bjb-rename-note.c',
'bjb-search-toolbar.c',
'bjb-selection-toolbar.c',
'bjb-settings.c',
'bjb-settings-dialog.c',
'bjb-share.c',
'bjb-window-base.c'
)
resource_data = files(
'resources/Adwaita.css',
'resources/app-menu.ui',
'resources/editor-toolbar.ui',
'resources/note-symbolic.svg',
'resources/settings-dialog.ui',
'resources/thumbnail-frame.png'
)
sources += gnome.compile_resources(
'bjb-resources',
'bjb.gresource.xml',
c_name: 'bjb',
dependencies: resource_data,
export: true
)
executable(
bijiben_name,
sources,
include_directories: top_inc,
dependencies: libbiji_dep,
install: true,
install_dir: bijiben_bindir
)
sources = files('bijiben-shell-search-provider.c')
sources += gnome.gdbus_codegen(
'bijiben-shell-search-provider-generated',
search_provider_dbus_iface,
interface_prefix: 'org.gnome.',
namespace: 'Bijiben'
)
executable(
'bijiben-shell-search-provider',
sources,
include_directories: top_inc,
dependencies: libbiji_dep,
install: true,
install_dir: bijiben_libexecdir
)
libgd @ cc901075
Subproject commit 643ad53887f6507a775c1f6e1cfbbbe4e939b043
Subproject commit cc90107531640bcba6c3c58e5cf6aec94d498763