Commit a8e5ce28 authored by Martin Blanchard's avatar Martin Blanchard

build: Port to the meson build system

Introduce meson build scripts along autotools ones. Porting modules to
the meson build system is a GNOME Goal, details here:

https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting

#71
parent 3526ef00
#!/usr/bin/env python3
import os
import subprocess
import sys
libdir = sys.argv[1]
datadir = sys.argv[1]
# Packaging tools define DESTDIR and this isn't needed for them
if 'DESTDIR' not in os.environ:
print('Compiling gsettings schemas...')
subprocess.call(['glib-compile-schemas',
os.path.join(datadir, 'glib-2.0', 'schemas')])
print('Updating icon cache...')
subprocess.call(['gtk-update-icon-cache', '-qtf',
os.path.join(datadir, 'icons', 'hicolor')])
print('Updating desktop database...')
subprocess.call(['update-desktop-database', '-q',
os.path.join(datadir, 'applications')])
print('Compiling python modules...')
subprocess.call([sys.executable, '-m', 'compileall', '-f', '-q',
os.path.join(libdir, 'gedit', 'plugins')])
print('Compiling python modules (optimized versions) ...')
subprocess.call([sys.executable, '-O', '-m', 'compileall', '-f', '-q',
os.path.join(libdir, 'gedit', 'plugins')])
install_subdir(
'hicolor',
install_dir: join_paths(
datadir,
'icons',
)
)
subdir('icons')
install_man('gedit.1')
install_data(
'gedit.convert',
install_dir: join_paths(
gconfdir,
'gsettings',
)
)
install_data(
'gedit-bugreport.sh',
install_dir: join_paths(
libexecdir,
package_name,
)
)
i18n.merge_file(
'appdata-file',
input: 'org.gnome.gedit.appdata.xml.in',
output: 'org.gnome.gedit.appdata.xml',
type: 'xml',
po_dir: join_paths(srcdir, 'po'),
install: true,
install_dir: join_paths(
datadir,
'metainfo',
)
)
desktop_in = configuration_data()
desktop_in.set('VERSION', version)
desktop_in.set('FULL_LIBEXECDIR', libexecdir)
desktop_file = configure_file(
input: 'org.gnome.gedit.desktop.in.in',
output: 'org.gnome.gedit.desktop.in',
configuration: desktop_in,
install: false,
)
i18n.merge_file(
'desktop-file',
input: desktop_file,
output: 'org.gnome.gedit.desktop',
type: 'desktop',
po_dir: join_paths(srcdir, 'po'),
install: true,
install_dir: join_paths(
datadir,
'applications',
)
)
quoted_plugins = []
foreach plugin_name:active_plugins
quoted_plugins += [
'\'@0@\''.format(plugin_name)
]
endforeach
gschema_xml = configuration_data()
gschema_xml.set('GETTEXT_PACKAGE', package_name)
gschema_xml.set('ACTIVE_PLUGINS', ', '.join(quoted_plugins))
configure_file(
input: 'org.gnome.gedit.gschema.xml.in',
output: 'org.gnome.gedit.gschema.xml',
configuration: gschema_xml,
install: true,
install_dir: join_paths(
glibdir,
'schemas',
)
)
service_in = configuration_data()
service_in.set('bindir', bindir)
configure_file(
input: 'org.gnome.gedit.service.in',
output: 'org.gnome.gedit.service',
configuration: service_in,
install: true,
install_dir: join_paths(
dbusdir,
'services',
)
)
if build_gtk_doc == true
subdir('reference')
endif
glib_prefix = glib_dep.get_pkgconfig_variable('prefix')
glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html', 'glib')
gobject_prefix = gobject_dep.get_pkgconfig_variable('prefix')
gobject_docpath = join_paths(gobject_prefix, 'share', 'gtk-doc', 'html', 'gobject')
gtk_prefix = gtk_dep.get_pkgconfig_variable('prefix')
gtk_docpath = join_paths(gobject_prefix, 'share', 'gtk-doc', 'html', 'gtk')
libgedit_reference_ignored_h = [
'gedit-app-osx.h',
'gedit-app-win32.h',
'gedit-app-x11.h',
'gedit-close-confirmation-dialog.h',
'gedit-dirs.h',
'gedit-document-private.h',
'gedit-documents-panel.h',
'gedit-encoding-items.h',
'gedit-encodings-dialog.h',
'gedit-enum-types.h',
'gedit-file-chooser-dialog-gtk.h',
'gedit-file-chooser-dialog-osx.h',
'gedit-file-chooser-dialog.h',
'gedit-highlight-mode-dialog.h',
'gedit-highlight-mode-selector.h',
'gedit-history-entry.h',
'gedit-io-error-info-bar.h',
'gedit-menu-stack-switcher.h',
'gedit-metadata-manager.h',
'gedit-multi-notebook.h',
'gedit-notebook-popup-menu.h',
'gedit-notebook-stack-switcher.h',
'gedit-notebook.h',
'gedit-open-document-selector-helper.h',
'gedit-open-document-selector-store.h',
'gedit-open-document-selector.h',
'gedit-open-menu-button.h',
'gedit-plugins-engine.h',
'gedit-preferences-dialog.h',
'gedit-print-job.h',
'gedit-print-preview.h',
'gedit-recent.h',
'gedit-replace-dialog.h',
'gedit-settings.h',
'gedit-small-button.h',
'gedit-status-menu-button.h',
'gedit-tab-label.h',
'gedit-view-centering.h',
'gedit-view-frame.h',
'gedit-window-private.h',
]
libgedit_reference_scan_args = [
'--rebuild-types',
'--deprecated-guards=GEDIT_DISABLE_DEPRECATED',
'--ignore-headers=' + ' '.join(libgedit_reference_ignored_h),
]
libgedit_reference_mkdb_args = [
'--xml-mode',
'--output-format=xml',
'--name-space=gedit',
]
libgedit_reference_fixxref_args = [
'--html-dir=@0@'.format(join_paths(gtkdocdir, 'html', package_string)),
'--extra-dir=@0@'.format(glib_docpath),
'--extra-dir=@0@'.format(gobject_docpath),
'--extra-dir=@0@'.format(gtk_docpath),
]
gnome.gtkdoc(
package_name,
main_sgml: 'gedit-docs.xml',
src_dir: join_paths(srcdir, 'gedit'),
dependencies: libgedit_dep,
scan_args: libgedit_reference_scan_args,
mkdb_args: libgedit_reference_mkdb_args,
fixxref_args: libgedit_reference_fixxref_args,
install: true,
install_dir: join_paths(
gtkdocdir,
'html',
package_string,
)
)
libgedit_public_h = files(
'gedit-app-activatable.h',
'gedit-app.h',
'gedit-commands.h',
'gedit-debug.h',
'gedit-document.h',
'gedit-encodings-combo-box.h',
'gedit-menu-extension.h',
'gedit-message-bus.h',
'gedit-message.h',
'gedit-progress-info-bar.h',
'gedit-statusbar.h',
'gedit-tab.h',
'gedit-utils.h',
'gedit-view-activatable.h',
'gedit-view.h',
'gedit-window-activatable.h',
'gedit-window.h',
)
libgedit_private_h = files(
'gedit-app-private.h',
'gedit-close-confirmation-dialog.h',
'gedit-commands-private.h',
'gedit-dirs.h',
'gedit-document-private.h',
'gedit-documents-panel.h',
'gedit-encoding-items.h',
'gedit-encodings-dialog.h',
'gedit-file-chooser-dialog-gtk.h',
'gedit-file-chooser-dialog.h',
'gedit-highlight-mode-dialog.h',
'gedit-highlight-mode-selector.h',
'gedit-history-entry.h',
'gedit-io-error-info-bar.h',
'gedit-menu-stack-switcher.h',
'gedit-metadata-manager.h',
'gedit-multi-notebook.h',
'gedit-notebook.h',
'gedit-notebook-popup-menu.h',
'gedit-notebook-stack-switcher.h',
'gedit-open-document-selector.h',
'gedit-open-document-selector-helper.h',
'gedit-open-document-selector-store.h',
'gedit-pango.h',
'gedit-plugins-engine.h',
'gedit-preferences-dialog.h',
'gedit-print-job.h',
'gedit-print-preview.h',
'gedit-recent.h',
'gedit-replace-dialog.h',
'gedit-settings.h',
'gedit-status-menu-button.h',
'gedit-tab-label.h',
'gedit-tab-private.h',
'gedit-view-centering.h',
'gedit-view-frame.h',
'gedit-window-private.h',
)
libgedit_sources = files(
'gedit-app-activatable.c',
'gedit-app.c',
'gedit-close-confirmation-dialog.c',
'gedit-commands-documents.c',
'gedit-commands-edit.c',
'gedit-commands-file.c',
'gedit-commands-file-print.c',
'gedit-commands-help.c',
'gedit-commands-search.c',
'gedit-commands-view.c',
'gedit-debug.c',
'gedit-dirs.c',
'gedit-document.c',
'gedit-documents-panel.c',
'gedit-encoding-items.c',
'gedit-encodings-combo-box.c',
'gedit-encodings-dialog.c',
'gedit-file-chooser-dialog.c',
'gedit-file-chooser-dialog-gtk.c',
'gedit-highlight-mode-dialog.c',
'gedit-highlight-mode-selector.c',
'gedit-history-entry.c',
'gedit-io-error-info-bar.c',
'gedit-menu-extension.c',
'gedit-menu-stack-switcher.c',
'gedit-message-bus.c',
'gedit-message.c',
'gedit-metadata-manager.c',
'gedit-multi-notebook.c',
'gedit-notebook.c',
'gedit-notebook-popup-menu.c',
'gedit-notebook-stack-switcher.c',
'gedit-open-document-selector.c',
'gedit-open-document-selector-helper.c',
'gedit-open-document-selector-store.c',
'gedit-pango.c',
'gedit-plugins-engine.c',
'gedit-preferences-dialog.c',
'gedit-print-job.c',
'gedit-print-preview.c',
'gedit-progress-info-bar.c',
'gedit-recent.c',
'gedit-replace-dialog.c',
'gedit-settings.c',
'gedit-statusbar.c',
'gedit-status-menu-button.c',
'gedit-tab.c',
'gedit-tab-label.c',
'gedit-utils.c',
'gedit-view-activatable.c',
'gedit-view.c',
'gedit-view-centering.c',
'gedit-view-frame.c',
'gedit-window-activatable.c',
'gedit-window.c',
)
libgedit_c_args = [
'-DHAVE_CONFIG_H',
]
libgedit_link_args = [
]
libgedit_deps = [
glib_dep,
gobject_dep,
gio_dep,
gtk_dep,
gtksourceview_dep,
libpeas_dep,
libpeas_gtk_dep,
libxml_dep,
libgd_dep,
]
if windowing_target == 'quartz'
libgedit_sources += files(
'gedit-app-osx.c',
'gedit-file-chooser-dialog-osx.c',
)
elif windowing_target == 'win32'
libgedit_sources += files(
'gedit-app-win32.c',
)
else
libgedit_sources += files(
'gedit-app-x11.c',
)
libgedit_deps += [
x11_dep,
]
endif
libgedit_enums = gnome.mkenums(
'gedit-enum-types',
sources: libgedit_public_h + ['gedit-notebook.h'],
h_template: 'gedit-enum-types.h.template',
c_template: 'gedit-enum-types.c.template',
)
subdir('resources')
libgedit_sources += [
libgedit_enums.get(0),
libgedit_res.get(0),
]
libgedit_dep_sources = []
install_headers(
libgedit_public_h,
install_dir: join_paths(
pkgincludedir,
'gedit',
)
)
libgedit_sha = shared_library(
package_string,
libgedit_sources + [libgedit_enums.get(1), libgedit_res.get(1)],
include_directories: rootdir,
dependencies: libgedit_deps,
c_args: libgedit_c_args,
link_args: libgedit_link_args,
install: true,
install_dir: pkglibdir,
)
if generate_gir == true
libgedit_public_h += [
libgedit_enums.get(1),
]
libgedit_gir_includes = [
'Gtk-3.0',
'GtkSource-4',
]
libgedit_gir = gnome.generate_gir(
libgedit_sha,
sources: libgedit_sources + libgedit_public_h,
nsversion: '3.0',
namespace: 'Gedit',
symbol_prefix: 'gedit',
identifier_prefix: 'Gedit',
export_packages: [package_string],
includes: libgedit_gir_includes,
link_with: libgedit_sha,
install: true,
install_dir_gir: join_paths(pkgdatadir, 'gir-1.0'),
install_dir_typelib: join_paths(pkglibdir, 'girepository-1.0'),
)
python3.install_sources(
'Gedit.py',
subdir: join_paths(
'gi',
'overrides',
)
)
libgedit_dep_sources += [
libgedit_gir,
]
if generate_vapi == true
libgedit_vapi_packages = [
'gio-2.0',
'atk',
'gdk-3.0',
'gtk+-3.0',
'gtksourceview-4',
]
libgedit_vapi = gnome.generate_vapi(
package_name,
sources: libgedit_gir.get(0),
packages: libgedit_vapi_packages,
install: true,
install_dir: vapidir,
)
endif
endif
libgedit_dep = declare_dependency(
link_with: libgedit_sha,
include_directories: rootdir,
dependencies: libgedit_deps,
sources: libgedit_dep_sources,
)
libgedit_pc = pkg.generate(
name: package_name,
description: 'GNOME text editor',
requires: ['gtksourceview-4', 'libpeas-1.0', 'libpeas-gtk-1.0'],
version: version,
subdirs: package_string,
libraries: libgedit_sha,
install_dir: pkgconfigdir,
)
# FIXME: https://github.com/mesonbuild/meson/issues/1687
custom_target(
'org.gnome.gedit.enums.xml',
input : libgedit_sources + libgedit_public_h + ['gedit-notebook.h'],
output: 'org.gnome.gedit.enums.xml',
capture: true,
command: [
'glib-mkenums',
'--comments', '<!-- @comment@ -->',
'--fhead', '<schemalist>',
'--vhead', ' <@type@ id="org.gnome.gedit.@EnumName@">',
'--vprod', ' <value nick="@valuenick@" value="@valuenum@"/>',
'--vtail', ' </@type@>',
'--ftail', '</schemalist>',
'@INPUT@'
],
install: true,
install_dir: join_paths(
glibdir,
'schemas',
)
)
gedit_sources = [
'gedit.c',
]
gedit_c_args = [
'-DHAVE_CONFIG_H',
]
gedit_deps = [
libgedit_dep,
]
gedit_exe = executable(
package_name,
gedit_sources,
dependencies: gedit_deps,
c_args: gedit_c_args,
install: true,
install_dir: bindir,
)
gresource_xml = configuration_data()
if windowing_targets.contains('quartz')
gresource_xml.set(
'OS_DEPENDENT_RESOURCE_FILES',
'<file preprocess="xml-stripblanks">gtk/menus-traditional.ui</file>'
)
else
gresource_xml.set('OS_DEPENDENT_RESOURCE_FILES', '')
endif
libgedit_res_xml = configure_file(
input: 'gedit.gresource.xml.in',
output: 'gedit.gresource.xml',
configuration: gresource_xml
)
libgedit_res = gnome.compile_resources(
'gedit-resources',
libgedit_res_xml,
)
ar
bg
ca
cs
da
de
el
es
eu
fi
fr
gl
hu
id
it
ja
ko
lv
oc
pl
pt_BR
ro
ru
sl
sv
te
th
uk
zh_CN
zh_HK
zh_TW
\ No newline at end of file
gedit_help_sources = [
'gedit-change-color-scheme.page',
'gedit-change-default-font.page',
'gedit-close-file.page',
'gedit-create-new-file.page',
'gedit-edit-as-root.page',
'gedit-files-basic.page',
'gedit-full-screen.page',
'gedit-open-files-from-sidepane.page',
'gedit-open-files.page',
'gedit-open-on-server.page',
'gedit-open-recent.page',
'gedit-plugin-guide.page',
'gedit-plugins-change-case.page',
'gedit-plugins-doc-stats.page',
'gedit-plugins-external-tools.page',
'gedit-plugins-file-browser.page',
'gedit-plugins-insert-date-time.page',
'gedit-plugins-install.page',
'gedit-plugins-modelines.page',
'gedit-plugins-pyconsole.page',
'gedit-plugins-quick-open.page',
'gedit-plugins-snippets.page',
'gedit-plugins-sort.page',
'gedit-printing-order.page',
'gedit-printing.page',
'gedit-printing-select.page',
'gedit-quickstart.page',
'gedit-replace.page',
'gedit-save-file.page',
'gedit-search.page',
'gedit-shortcut-keys.page',
'gedit-spellcheck.page',
'gedit-syntax-highlighting.page',
'gedit-tab-groups.page',
'gedit-tabs-moving.page',
'gedit-tabs.page',
'gedit-undo-recent-action.page',
'index.page',
'legal.xml',
]
gedit_help_media = [
'figures/gedit-html-snippet.png',
'figures/gedit-icon.png',
'figures/gedit3-screenshot.png',
]
gnome.yelp(
package_name,
sources: gedit_help_sources,
media: gedit_help_media,
symlink_media: true,
)
project(
'gedit', 'c',
version: '3.31.1',
meson_version: '>=0.46.0',
license: 'GPL2'
)
gnome = import('gnome')
i18n = import('i18n')
pkg = import('pkgconfig')
python = import('python')
# Versioning
version = meson.project_version()
version_arr = version.split('.')
version_major = version_arr[0]
version_minor = version_arr[1]
version_micro = version_arr[2]
api_version = '3.14'
package_name = meson.project_name()
package_string = '@0@-@1@'.format(package_name, api_version)
# Paths
rootdir = include_directories('.')
srcdir = meson.current_source_dir()
builddir = meson.current_build_dir()
prefix = get_option('prefix')
bindir = join_paths(prefix, get_option('bindir'))
includedir = join_paths(prefix, get_option('includedir'))
libdir = join_paths(prefix, get_option('libdir'))
libexecdir = join_paths(prefix, get_option('libexecdir'))
datadir = join_paths(prefix, get_option('datadir'))
pkgincludedir = join_paths(includedir, package_string)
pkgconfigdir = join_paths(libdir, 'pkgconfig')
pkglibdir = join_paths(libdir, package_name)
pkgdatadir = join_paths(datadir, package_name)
dbusdir = join_paths(datadir, 'dbus-1')
gconfdir = join_paths(datadir, 'GConf')
glibdir = join_paths(datadir, 'glib-2.0')
gtkdocdir = join_paths(datadir, 'gtk-doc')
localdir = join_paths(datadir, 'local')
vapidir = join_paths(datadir, 'vala', 'vapi')
# Subprojects
libgd_sp = subproject(
'libgd',
default_options: [
'with-tagged-entry=true',
'static=true',
]
)
# Dependencies
glib_req = '>= 2.44.0'
gtk_req = '>= 3.22.0'
gtksourceview_req = '>= 4.0.2'
libpeas_req = '>= 1.14.1'
libxml_req = '>= 2.5.0'
libsoup_req = '>= 2.60.0'
gspell_req = '>= 0.2.5'
pygobject_req = '>= 3.0.0'
introspection_req = '>= 0.9.3'
vala_req = '>= 0.25.1'
gtk_doc_req = '>= 1.0'
glib_dep = dependency('glib-2.0', version: glib_req)
gobject_dep = dependency('gobject-2.0', version: glib_req)
gmodule_dep = dependency('gmodule-2.0', version: glib_req)
gio_dep = dependency('gio-2.0', version: glib_req)
gdk_dep = dependency('gdk-3.0', version: gtk_req)
gtk_dep = dependency('gtk+-3.0', version: gtk_req)
gtksourceview_dep = dependency('gtksourceview-4', version: gtksourceview_req)
libpeas_dep = dependency('libpeas-1.0', version: libpeas_req)
libpeas_gtk_dep = dependency('libpeas-gtk-1.0', version: libpeas_req)
libxml_dep = dependency('libxml-2.0', version: libxml_req)
libgd_dep = libgd_sp.get_variable('libgd_dep')
libsoup_dep = dependency('libsoup-2.4', version: libsoup_req, required: true)
gspell_dep = dependency('gspell-1', version: gspell_req, required: true)
x11_dep = dependency('x11', required: false)
introspection_dep = dependency('gobject-introspection-1.0', version: introspection_req, required: false)
vapigen_dep = dependency('vapigen', version: vala_req, required: false)
gtk_doc_dep = dependency('gtk-doc', version: gtk_doc_req, required: false)
python3 = python.find_installation('python3')
# Configurations
windowing_targets = gdk_dep.get_pkgconfig_variable('targets').split()
if windowing_targets.contains('quartz')
windowing_target = 'quartz'
elif windowing_targets.contains('win32')
windowing_target = 'win32'
else
if not x11_dep.found()
error('Native dependency \'x11\' not found')
else
windowing_target = 'x11'
endif
endif
config_h = configuration_data()
config_h.set_quoted('PACKAGE_NAME', package_name)
config_h.set_quoted('PACKAGE_STRING', package_string)
config_h.set_quoted('PACKAGE_VERSION', version)
config_h.set_quoted('GETTEXT_PACKAGE', package_name)
config_h.set_quoted('LOCALEDIR', localdir)
config_h.set_quoted('LIBDIR', libdir)
config_h.set_quoted('DATADIR', datadir)
config_h.set_quoted('VERSION', version)
config_h.set('GEDIT_MAJOR_VERSION', version_major)
config_h.set('GEDIT_MINOR_VERSION', version_minor)
config_h.set('GEDIT_MICRO_VERSION', version_micro)
configure_file(
output: 'config.h',
configuration: config_h
)
# Options
build_plugins = get_option('plugins')
generate_gir = get_option('introspection')
if generate_gir and not introspection_dep.found()
generate_gir = false
endif
generate_vapi = generate_gir and get_option('vapi')
if generate_vapi and not vapigen_dep.found()
generate_vapi = false
endif
build_gtk_doc = get_option('documentation')
if build_gtk_doc and not gtk_doc_dep.found()