Commit 98eb1b9d authored by Emmanuele Bassi's avatar Emmanuele Bassi

Add Meson build

Meson is a meta-build system that has several advantages over the
existing Autotools build:

  - it's faster
  - it's easier to understand
  - it's well maintained
  - it's well integrated with the GNOME tooling

Various projects in the GNOME ecosystem are moving away from Autootols
and using Meson as a replacement.
parent 94084ef4
#!/bin/sh
set -x
test -n "$srcdir" || srcdir=$1
test -n "$srcdir" || srcdir=.
cd "$srcdir"
PROJECT=gnome-screenshot
VERSION=$(git describe --abbrev=0)
NAME="${PROJECT}-${VERSION}"
rm -f "${NAME}.tar"
echo "Creating git tree archive…"
git archive --prefix="${NAME}/" --format=tar HEAD > ${NAME}.tar
rm -f "${NAME}.tar.xz"
echo "Compressing archive…"
xz -f "${NAME}.tar"
set +x
#!/usr/bin/env python3
import os
import subprocess
prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr/local')
datadir = os.path.join(prefix, 'share')
# Packaging tools define DESTDIR and this isn't needed for them
if 'DESTDIR' not in os.environ:
print('Updating icon cache...')
icon_cache_dir = os.path.join(datadir, 'icons', 'hicolor')
if not os.path.exists(icon_cache_dir):
os.makedirs(icon_cache_dir)
subprocess.call(['gtk-update-icon-cache', '-qtf', icon_cache_dir])
print('Updating desktop database...')
desktop_database_dir = os.path.join(datadir, 'applications')
if not os.path.exists(desktop_database_dir):
os.makedirs(desktop_database_dir)
subprocess.call(['update-desktop-database', '-q', desktop_database_dir])
print('Compiling GSettings schemas...')
schemas_dir = os.path.join(datadir, 'glib-2.0', 'schemas')
if not os.path.exists(schemas_dir):
os.makedirs(schemas_dir)
subprocess.call(['glib-compile-schemas', schemas_dir])
project('gnome-screenshot', 'c',
version: '3.23.0',
license: 'GPLv2+',
meson_version: '>= 0.40.1',
default_options: [
'buildtype=debugoptimized',
'warning_level=1',
'c_std=c99',
])
add_project_arguments([ '-D_POSIX_C_SOURCE', '-D_DEFAULT_SOURCE' ], language: 'c')
cc = meson.get_compiler('c')
gnome_screenshot_prefix = get_option('prefix')
gnome_screenshot_bindir = join_paths(gnome_screenshot_prefix, get_option('bindir'))
gnome_screenshot_datadir = join_paths(gnome_screenshot_prefix, get_option('datadir'))
gnome_screenshot_libexecdir = join_paths(gnome_screenshot_prefix, get_option('libexecdir'))
gnome_screenshot_localedir = join_paths(gnome_screenshot_datadir, 'locale')
gnome_screenshot_appsdir = join_paths(gnome_screenshot_datadir, 'applications')
gnome_screenshot_appdatadir = join_paths(gnome_screenshot_datadir, 'metainfo')
gnome_screenshot_servicesdir = join_paths(gnome_screenshot_datadir, 'dbus-1', 'services')
gnome_screenshot_schemadir = join_paths(gnome_screenshot_datadir, 'glib-2.0', 'schemas')
glib_req_version = '>= 2.35.1'
gtk_req_version = '>= 3.0.0'
mathlib_dep = cc.find_library('m', required: false)
x11_dep = [ dependency('x11'), dependency('xext') ]
glib_dep = dependency('glib-2.0', version: glib_req_version)
gtk_dep = dependency('gtk+-3.0', version: gtk_req_version)
canberra_dep = dependency('libcanberra-gtk3')
config_h = configuration_data()
config_h.set_quoted('VERSION', meson.project_version())
config_h.set_quoted('GETTEXT_PACKAGE', meson.project_name())
if cc.has_header('X11/extensions/shape.h')
config_h.set('HAVE_X11_EXTENSIONS_SHAPE_H', 1)
endif
configure_file(output: 'config.h', configuration: config_h)
root_inc = include_directories('.')
i18n = import('i18n')
subdir('src')
subdir('po')
meson.add_install_script('build-aux/postinstall.py')
i18n.gettext(meson.project_name(), preset: 'glib')
gnome = import('gnome')
sources = [
'gnome-screenshot.c',
'cheese-flash.c',
'screenshot-application.c',
'screenshot-area-selection.c',
'screenshot-config.c',
'screenshot-dialog.c',
'screenshot-filename-builder.c',
'screenshot-interactive-dialog.c',
'screenshot-shadow.c',
'screenshot-utils.c',
]
resources = gnome.compile_resources('screenshot-resources',
'gnome-screenshot.gresource.xml',
source_dir: '.',
c_name: 'screenshot')
executable('gnome-screenshot', sources + resources,
include_directories: [ root_inc, include_directories('.') ],
dependencies: [ mathlib_dep, x11_dep, glib_dep, gtk_dep, canberra_dep ],
c_args: [
'-DLOCALEDIR="@0@"'.format(gnome_screenshot_localedir),
'-DGLIB_DISABLE_DEPRECATION_WARNINGS',
'-DGDK_DISABLE_DEPRECATION_WARNINGS',
],
install: true)
i18n.merge_file('desktop',
type: 'desktop',
input: 'org.gnome.Screenshot.desktop.in',
output: 'org.gnome.Screenshot.desktop',
po_dir: join_paths(meson.current_source_dir(), '../po'),
install: true,
install_dir: gnome_screenshot_appsdir)
i18n.merge_file('desktop',
input: 'org.gnome.Screenshot.metainfo.xml.in',
output: 'org.gnome.Screenshot.metainfo.xml',
po_dir: join_paths(meson.current_source_dir(), '../po'),
install: true,
install_dir: gnome_screenshot_appdatadir)
service_conf = configuration_data ()
service_conf.set('bindir', gnome_screenshot_bindir)
configure_file(input: 'org.gnome.Screenshot.service.in',
output: 'org.gnome.Screenshot.service',
configuration: service_conf,
install: true,
install_dir: gnome_screenshot_servicesdir)
install_data('org.gnome.gnome-screenshot.gschema.xml',
install_dir: gnome_screenshot_schemadir)
install_data('gnome-screenshot.1',
install_dir: join_paths(gnome_screenshot_datadir, 'man', 'man1'))
install_data('gnome-screenshot.convert',
install_dir: join_paths(gnome_screenshot_datadir, 'GConf', 'gsettings'))
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