Skip to content

Commit

Permalink
Add meson build
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamaranch committed Feb 15, 2025
1 parent 856f764 commit 12e6cab
Show file tree
Hide file tree
Showing 13 changed files with 349 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ appdata_in_files = org.xfce.ristretto.appdata.xml.in

EXTRA_DIST = \
$(desktop_in_files) \
$(appdata_in_files)
$(appdata_in_files) \
meson_options.txt \
meson.build \
xfce-revision.h.in \
$(NULL)

DISTCLEANFILES = \
$(desktop_DATA) \
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ AC_INIT([ristretto], [xdt_version], [https://gitlab.xfce.org/apps/ristretto])
AC_PREREQ([2.69])
AC_CONFIG_MACRO_DIRS([m4])
AC_REVISION([xdt_version_build])
AC_DEFINE([VERSION_FULL], [PACKAGE_VERSION], [Alias for VERSION and PACKAGE_VERSION for meson compatibility])

AM_INIT_AUTOMAKE([1.8 no-dist-gzip dist-bzip2 tar-ustar foreign])
AC_CONFIG_HEADERS([config.h])
Expand Down
4 changes: 4 additions & 0 deletions icons/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ uninstall-hook:
echo "*** $(gtk_update_icon_cache)"; \
echo "***"; \
fi

EXTRA_DIST = \
meson.build \
$(NULL)
13 changes: 13 additions & 0 deletions icons/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sizes = [16, 24, 32, 48, 64, 96, 128]

foreach size : sizes
install_data(
'@0@x@0@'.format(size) / 'org.xfce.ristretto.png',
install_dir: get_option('prefix') / get_option('datadir') / 'icons' / 'hicolor' / '@0@x@0@'.format(size) / 'apps',
)
endforeach

install_data(
'scalable' / 'org.xfce.ristretto.svg',
install_dir: get_option('prefix') / get_option('datadir') / 'icons' / 'hicolor' / 'scalable' / 'apps',
)
183 changes: 183 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
project(
'ristretto',
'c',
version : '0.13.3-dev',
license : 'GPL-2.0-or-later',
meson_version : '>= 0.54.0',
default_options : ['c_std=gnu11', 'buildtype=debugoptimized', 'warning_level=2']
)

project_namespace = 'apps'
pkgdatadir = get_option('prefix') / get_option('datadir') / meson.project_name()

cc = meson.get_compiler('c')
pkgconfig = import('pkgconfig')
gnome = import('gnome')
i18n = import('i18n')

dependency_versions = {
'glib': '>= 2.56.0',
'gtk': '>= 3.22.0',
'cairo': '>= 1.10.0',
'libexif': '>= 0.6.0',
'exo': '>= 4.16.0',
'libxfce4ui': '>= 4.16.0',
'libxfce4util': '>= 4.16.0',
'xfconf': '>= 4.12.1',

'libx11': '>= 1.6.7',
}

glib = dependency('glib-2.0', version: dependency_versions['glib'])
gio = dependency('gio-2.0', version: dependency_versions['glib'])
gio_unix = dependency('gio-unix-2.0', version: dependency_versions['glib'])
gtk = dependency('gtk+-3.0', version: dependency_versions['gtk'])
cairo = dependency('cairo', version: dependency_versions['cairo'])
libexif = dependency('libexif', version: dependency_versions['libexif'])
exo = dependency('exo-2', version: dependency_versions['exo'])
libxfce4ui = dependency('libxfce4ui-2', version: dependency_versions['libxfce4ui'])
libxfce4util = dependency('libxfce4util-1.0', version: dependency_versions['libxfce4util'])
xfconf = dependency('libxfconf-0', version: dependency_versions['xfconf'])

xdt_csource = find_program('xdt-csource', required: true)

feature_cflags = []

libx11 = dependency('x11', version: dependency_versions['libx11'], required: get_option('libx11'))
if libx11.found()
feature_cflags += '-DHAVE_LIBX11=1'
endif

tumbler_service_name_prefix = get_option('service-name-prefix')
if tumbler_service_name_prefix == ''
tumbler_service_name_prefix = 'org.freedesktop.thumbnails'
endif
tumbler_service_path_prefix = '/@0@'.format('/'.join(tumbler_service_name_prefix.split('.')))

headers = [
'math.h',
'string.h',
]
foreach header : headers
if cc.check_header(header)
feature_cflags += '-DHAVE_@0@=1'.format(header.underscorify().to_upper())
endif
endforeach

libmagic = cc.find_library('magic', required: false)
if libmagic.found() and cc.check_header('magic.h') and cc.has_function('magic_open', dependencies: libmagic)
feature_cflags += '-DHAVE_MAGIC_H=1'
endif

libm = cc.find_library('m', required: true)

extra_cflags = []
extra_cflags_check = [
'-Wmissing-declarations',
'-Wmissing-noreturn',
'-Wold-style-definition',
'-Wredundant-decls',
'-Wpointer-arith',
'-Wcast-align',
'-Winit-self',
'-Wshadow',
'-Wmissing-include-dirs',
'-Wundef',
'-Wformat',
'-Wformat-security',
'-Wformat-y2k',
'-Wnested-externs',
'-Wno-unused-parameter',
'-Wno-declaration-after-statement',
'-Wno-missing-field-initializers',
'-Werror=implicit-function-declaration',
'-Wno-error=deprecated-declarations',
]

optimization = get_option('optimization')
if get_option('debug') and optimization in ['0', 'g']
extra_cflags_check += '-fstack-protector-strong'
extra_cflags += [
'-DDEBUG=1',
'-DDEBUG_TRACE=1',
'-DG_ENABLE_DEBUG',
]
elif optimization in ['3', 'minsize']
extra_cflags += [
'-DNDEBUG',
'-DG_DISABLE_CAST_CHECKS',
'-DG_DISABLE_ASSERT',
]
endif

if dependency_versions.has_key('glib')
glib_version_parts = dependency_versions['glib'].split(' ')
glib_min_version_parts = glib_version_parts[1].split('.')
glib_min_version_define = 'GLIB_VERSION_@0@_@1@'.format(glib_min_version_parts[0], glib_min_version_parts[1])
extra_cflags += [
'-DGLIB_VERSION_MIN_REQUIRED=@0@'.format(glib_min_version_define),
'-DGLIB_VERSION_MAX_ALLOWED=@0@'.format(glib_min_version_define),
'-DG_LOG_USE_STRUCTURED=1',
]
endif

version_parts = meson.project_version().split('-dev')[0].split('.')
version_short = '@0@.@1@'.format(version_parts[0], version_parts[1])

extra_cflags += [
'-DPACKAGE="@0@"'.format(meson.project_name()),
'-DPACKAGE_NAME="@0@"'.format(meson.project_name()),
'-DPACKAGE_VERSION="@0@"'.format(meson.project_version()),
'-DVERSION="@0@"'.format(meson.project_version()),
'-DVERSION_SHORT="@0@"'.format(version_short),
'-DPACKAGE_STRING="@0@ @1@"'.format(meson.project_name(), meson.project_version()),
'-DPACKAGE_DATADIR="@0@"'.format(pkgdatadir),
'-DPACKAGE_LOCALE_DIR="@0@"'.format(get_option('prefix') / get_option('localedir')),
'-DPACKAGE_BUGREPORT="https://gitlab.xfce.org/@0@/@1@/-/issues"'.format(project_namespace, meson.project_name()),
'-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()),
'-DPREFIX="@0@"'.format(get_option('prefix')),
'-DBINDIR="@0@"'.format(get_option('prefix') / get_option('bindir')),
'-DDATADIR="@0@"'.format(get_option('prefix') / get_option('datadir')),
'-DINCLUDEDIR="@0@"'.format(get_option('prefix') / get_option('includedir')),
'-DLIBDIR="@0@"'.format(get_option('prefix') / get_option('libdir')),
'-DLIBEXECDIR="@0@"'.format(get_option('prefix') / get_option('libexecdir')),
'-DLOCALEDIR="@0@"'.format(get_option('prefix') / get_option('localedir')),
'-DLOCALSTATEDIR="@0@"'.format(get_option('prefix') / get_option('localstatedir')),
'-DSBINDIR="@0@"'.format(get_option('prefix') / get_option('sbindir')),
'-DSYSCONFDIR="@0@"'.format(get_option('prefix') / get_option('sysconfdir')),
'-DHAVE_XFCE_REVISION_H=1',
]

add_project_arguments(cc.get_supported_arguments(extra_cflags_check), language: 'c')
add_project_arguments(extra_cflags, language: 'c')
add_project_arguments(feature_cflags, language: 'c')

xfce_revision_h = vcs_tag(
command: ['git', 'rev-parse', '--short', 'HEAD'],
fallback: 'UNKNOWN',
input: 'xfce-revision.h.in',
output: 'xfce-revision.h',
replace_string: '@REVISION@',
)

i18n.merge_file(
input: 'org.xfce.ristretto.desktop.in',
output: 'org.xfce.ristretto.desktop',
po_dir: 'po',
type: 'desktop',
install: true,
install_dir: get_option('prefix') / get_option('datadir') / 'applications',
)

i18n.merge_file(
input: 'org.xfce.ristretto.appdata.xml.in',
output: 'org.xfce.ristretto.appdata.xml',
po_dir: 'po',
type: 'xml',
install: true,
install_dir: get_option('prefix') / get_option('datadir') / 'metainfo',
)

subdir('icons')
subdir('po')
subdir('src')
13 changes: 13 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
option(
'libx11',
type: 'feature',
value: 'auto',
description: 'Libx11 support',
)

option(
'service-name-prefix',
type: 'string',
value: '',
description: 'Alternative prefix to org.freedesktop.thumbnails for Tumbler services',
)
1 change: 1 addition & 0 deletions po/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
i18n.gettext(meson.project_name(), preset: 'glib')
4 changes: 3 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,6 @@ DISTCLEANFILES += \

EXTRA_DIST = \
main_window_ui.xml \
tumbler-service-dbus.xml.in
tumbler-service-dbus.xml.in \
meson.build \
$(NULL)
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ main (int argc,

if (version)
{
g_print ("%s\n", PACKAGE_STRING);
g_print ("%s %s\n", PACKAGE_NAME, VERSION_FULL);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main_window.c
Original file line number Diff line number Diff line change
Expand Up @@ -2827,7 +2827,7 @@ cb_rstto_main_window_about (GtkWidget *widget,

GtkWidget *about_dialog = gtk_about_dialog_new ();

gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (about_dialog), PACKAGE_VERSION);
gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (about_dialog), VERSION_FULL);

gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG (about_dialog),
_("Ristretto is an image viewer for the Xfce desktop environment."));
Expand Down
103 changes: 103 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
ristretto_sources = [
'app_menu_item.c',
'app_menu_item.h',
'file.c',
'file.h',
'gnome_wallpaper_manager.c',
'gnome_wallpaper_manager.h',
'icon_bar.c',
'icon_bar.h',
'image_list.c',
'image_list.h',
'image_viewer.c',
'image_viewer.h',
'main.c',
'main_window.c',
'main_window.h',
'mime_db.c',
'mime_db.h',
'monitor_chooser.c',
'monitor_chooser.h',
'preferences_dialog.c',
'preferences_dialog.h',
'print.c',
'print.h',
'privacy_dialog.c',
'privacy_dialog.h',
'properties_dialog.c',
'properties_dialog.h',
'settings.c',
'settings.h',
'thumbnailer.c',
'thumbnailer.h',
'util.c',
'util.h',
'wallpaper_manager.c',
'wallpaper_manager.h',
'xfce_wallpaper_manager.c',
'xfce_wallpaper_manager.h',
]

service_file = configure_file(
configuration: configuration_data({
'TUMBLER_SERVICE_NAME_PREFIX': tumbler_service_name_prefix,
'TUMBLER_SERVICE_PATH_PREFIX': tumbler_service_path_prefix,
}),
input: 'tumbler-service-dbus.xml.in',
output: 'tumbler-service-dbus.xml',
install: false,
)

ristretto_sources += gnome.gdbus_codegen(
'tumbler',
sources: service_file,
interface_prefix: tumbler_service_name_prefix,
namespace: 'Tumbler',
install_header: false,
)

ristretto_sources += gnome.genmarshal(
'marshal',
sources: 'marshal.list',
prefix: '_rstto_marshal',
internal: true,
install_header: false,
)

ristretto_sources += custom_target(
'main_window_ui.h',
input: 'main_window_ui.xml',
output: 'main_window_ui.h',
command: [xdt_csource, '--static', '--strip-comments', '--strip-content', '--name=main_window_ui', '--output=@OUTPUT@', '@INPUT@'],
)

executable(
'ristretto',
ristretto_sources,
sources: xfce_revision_h,
c_args: [
'-DG_LOG_DOMAIN="@0@"'.format('ristretto'),
'-DTUMBLER_SERVICE_NAME_PREFIX="@0@"'.format(tumbler_service_name_prefix),
'-DTUMBLER_SERVICE_PATH_PREFIX="@0@"'.format(tumbler_service_path_prefix),
],
include_directories: [
include_directories('..'),
],
dependencies: [
glib,
gio,
gio_unix,
gtk,
cairo,
libexif,
exo,
libxfce4ui,
libxfce4util,
xfconf,
libx11,
libmagic,
libm,
],
install: true,
install_dir: get_option('prefix') / get_option('bindir'),
)
7 changes: 6 additions & 1 deletion src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
#define __RISTRETTO_UTIL_H__

/* our config header */
#include <config.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_XFCE_REVISION_H
#include "xfce-revision.h"
#endif

/* standard headers */
#include <string.h>
Expand Down
Loading

0 comments on commit 12e6cab

Please sign in to comment.