Commit 9f3da748 authored by Martin Blanchard's avatar Martin Blanchard Committed by Christian Hergert

build: Port to the meson build system

This commit provides an initial port to the meson build system. See
meson_options.txt for the changes to command line options. For a full
build of GtkSourceView, the following will work.

 meson -Dglade_catalog=true -Dinstall_tests=true -Dgtk_doc=true build/
parent ba37e8dc
# Note that we do not install in the detected GLADE_CATALOG_DIR
# since we may not have permissions to do it, for instance if
# compiling with a prefix while glade is installed in /usr.
# We use the variable only to find the dtd file.
# If you install gtksourceview and glade in different prefixes
# and want to use the catalog in glade, you will need to set
# the GLADE_CATALOG_SEARCH_PATH environment variable.
catalog_in = configuration_data()
catalog_in.set('GSV_API_VERSION', api_version)
catalog_xml = configure_file(
input: 'gtksourceview.xml.in',
output: 'gtksourceview.xml',
configuration: catalog_in,
install: true,
install_dir: join_paths(
datadir,
'glade',
'catalogs'
)
)
if xmllint_prg.found()
catalog_dtd = join_paths(
gladeui_dep.get_pkgconfig_variable('catalogdir'),
'glade-catalog.dtd'
)
test(
'Validate Glade catalogue',
xmllint_prg,
args: [
'--dtdvalid',
catalog_dtd,
catalog_xml,
'--noout',
]
)
endif
if install_glade_catalog
subdir('glade')
endif
install_subdir('language-specs',
install_dir: pkgdatadir,
exclude_files: [ 'Makefile.am',
'check-language.sh',
'lang_v1_to_v2.xslt',
'language-specs.its',
'language-specs.pot',
'testv1.lang',
'ue2gsv.pl',
'update-pot.sh' ]
)
install_subdir('styles',
install_dir: pkgdatadir,
exclude_files: [ 'Makefile.am',
'check-style.sh',
'styles.its',
'styles.pot',
'testdark.xml',
'update-pot.sh' ]
)
if build_gtk_doc
subdir('reference')
endif
glib_prefix = glib_dep.get_pkgconfig_variable('prefix')
glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html')
gtk_prefix = gtk_dep.get_pkgconfig_variable('prefix')
gtk_docpath = join_paths(gtk_prefix, 'share', 'gtk-doc', 'html')
reference_private_h = [
'config.h',
'gtksource.h',
'gtksourcebuffer-private.h',
'gtksourcebufferinputstream.h',
'gtksourcebufferinternal.h',
'gtksourcebufferoutputstream.h',
'gtksourcecompletioncontainer.h',
'gtksourcecompletionmodel.h',
'gtksourcecompletion-private.h',
'gtksourcecompletionwordsbuffer.h',
'gtksourcecompletionwordslibrary.h',
'gtksourcecompletionwordsproposal.h',
'gtksourcecompletionwordsutils.h',
'gtksourcecontextengine.h',
'gtksourceencoding-private.h',
'gtksourceengine.h',
'gtksourcegutter-private.h',
'gtksourcegutterrendererlines.h',
'gtksourcegutterrenderermarks.h',
'gtksourcegutterrenderer-private.h',
'gtksourceiter.h',
'gtksourcelanguage-private.h',
'gtksourcemarkssequence.h',
'gtksourcepixbufhelper.h',
'gtksourceregex.h',
'gtksourcestyle-private.h',
'gtksourcetypes-private.h',
'gtksourceundomanagerdefault.h',
'gtksourceutils-private.h',
]
reference_content_files = files([
'lang-tutorial.xml',
'porting-guide-3-to-4.xml',
])
reference_sources = [
join_paths(srcdir, 'gtksourceview'),
join_paths(builddir, 'gtksourceview'),
]
into_xml = configure_file(
input: 'intro.xml.in',
output: 'intro.xml',
configuration: config_h
)
lang_reference_xml = configure_file(
input: 'lang-reference.xml.in',
output: 'lang-reference.xml',
configuration: config_h
)
style_reference_xml = configure_file(
input: 'style-reference.xml.in',
output: 'style-reference.xml',
configuration: config_h
)
reference_content_files += [
into_xml,
lang_reference_xml,
style_reference_xml,
]
gtksourceview_docs_xml = configure_file(
input: 'gtksourceview-docs.xml.in',
output: 'gtksourceview-docs.xml',
configuration: config_h
)
reference_scan_args = [
'--rebuild-types',
'--ignore-decorators=GTK_SOURCE_DEPRECATED\w*\s*\([^)]*\)|GTK_SOURCE_DEPRECATED\w*|GTK_SOURCE_AVAILABLE\w*|_GTK_SOURCE_EXTERN',
'--deprecated-guards=GTKSOURCEVIEW_DISABLE_DEPRECATED',
'--ignore-headers=' + ' '.join(reference_private_h),
]
reference_fixxref_args = [
'--html-dir=@0@'.format(docpath),
'--extra-dir=@0@'.format(join_paths(glib_docpath, 'glib')),
'--extra-dir=@0@'.format(join_paths(glib_docpath, 'gobject')),
'--extra-dir=@0@'.format(join_paths(glib_docpath, 'gio')),
'--extra-dir=@0@'.format(join_paths(gtk_docpath, 'gtk')),
]
gnome.gtkdoc('@0@.0'.format(package_string),
main_xml: join_paths(builddir, '@0@'.format(gtksourceview_docs_xml)),
gobject_typesfile: 'gtksourceview-4.0.types',
src_dir: reference_sources,
dependencies: gtksource_dep,
content_files: reference_content_files,
scan_args: reference_scan_args,
fixxref_args: reference_fixxref_args,
install: true
)
completionwords_c_args = [
'-DHAVE_CONFIG_H',
'-DGTK_SOURCE_COMPILATION',
'-DG_LOG_DOMAIN="GtkSourceView"',
]
completionwords_public_h = [
'gtksourcecompletionwords.h',
]
completionwords_public_c = [
'gtksourcecompletionwords.c',
'gtksourcecompletionwordsbuffer.c',
'gtksourcecompletionwordslibrary.c',
'gtksourcecompletionwordsproposal.c',
'gtksourcecompletionwordsutils.c',
]
install_headers(
completionwords_public_h,
install_dir: join_paths(
pkgincludedir,
'gtksourceview',
'completion-providers',
'words'
)
)
completionwords_lib = static_library(
package_string + 'completionwords',
completionwords_public_c,
include_directories: rootdir,
dependencies: core_dep,
c_args: completionwords_c_args,
install: false,
)
gtksource_libs += [
completionwords_lib,
]
completionwords_dep = declare_dependency(
link_with: completionwords_lib,
include_directories: rootdir,
dependencies: core_dep,
)
gtksource_deps += completionwords_dep
extra_public_sources += files([
'gtksourcecompletionwords.c',
'gtksourcecompletionwords.h',
])
core_public_h = files([
'gtksource.h',
'gtksourceautocleanups.h',
'gtksourcebuffer.h',
'gtksourcecompletion.h',
'gtksourcecompletioncontext.h',
'gtksourcecompletioninfo.h',
'gtksourcecompletionitem.h',
'gtksourcecompletionproposal.h',
'gtksourcecompletionprovider.h',
'gtksourceencoding.h',
'gtksourcefile.h',
'gtksourcefileloader.h',
'gtksourcefilesaver.h',
'gtksourcegutter.h',
'gtksourcegutterrenderer.h',
'gtksourcegutterrendererpixbuf.h',
'gtksourcegutterrenderertext.h',
'gtksourceinit.h',
'gtksourcelanguage.h',
'gtksourcelanguagemanager.h',
'gtksourcemap.h',
'gtksourcemark.h',
'gtksourcemarkattributes.h',
'gtksourceprintcompositor.h',
'gtksourceregion.h',
'gtksourcesearchcontext.h',
'gtksourcesearchsettings.h',
'gtksourcespacedrawer.h',
'gtksourcestyle.h',
'gtksourcestylescheme.h',
'gtksourcestyleschemechooser.h',
'gtksourcestyleschemechooserbutton.h',
'gtksourcestyleschemechooserwidget.h',
'gtksourcestyleschememanager.h',
'gtksourcetag.h',
'gtksourcetypes.h',
'gtksourceundomanager.h',
'gtksourceutils.h',
'gtksourceview.h',
])
core_public_c = files([
'gtksourcebuffer.c',
'gtksourcecompletion.c',
'gtksourcecompletioncontext.c',
'gtksourcecompletioninfo.c',
'gtksourcecompletionitem.c',
'gtksourcecompletionproposal.c',
'gtksourcecompletionprovider.c',
'gtksourceencoding.c',
'gtksourcefile.c',
'gtksourcefileloader.c',
'gtksourcefilesaver.c',
'gtksourcegutter.c',
'gtksourcegutterrenderer.c',
'gtksourcegutterrendererpixbuf.c',
'gtksourcegutterrenderertext.c',
'gtksourceinit.c',
'gtksourcelanguage.c',
'gtksourcelanguagemanager.c',
'gtksourcemap.c',
'gtksourcemark.c',
'gtksourcemarkattributes.c',
'gtksourceprintcompositor.c',
'gtksourceregion.c',
'gtksourcesearchcontext.c',
'gtksourcesearchsettings.c',
'gtksourcespacedrawer.c',
'gtksourcestyle.c',
'gtksourcestylescheme.c',
'gtksourcestyleschemechooser.c',
'gtksourcestyleschemechooserbutton.c',
'gtksourcestyleschemechooserwidget.c',
'gtksourcestyleschememanager.c',
'gtksourcetag.c',
'gtksourceundomanager.c',
'gtksourceutils.c',
'gtksourceversion.c',
'gtksourceview.c',
])
core_private_c = files([
'gtksourcebufferinputstream.c',
'gtksourcebufferinternal.c',
'gtksourcebufferoutputstream.c',
'gtksourcecompletioncontainer.c',
'gtksourcecompletionmodel.c',
'gtksourcecontextengine.c',
'gtksourceengine.c',
'gtksourcegutterrendererlines.c',
'gtksourcegutterrenderermarks.c',
'gtksourceiter.c',
'gtksourcelanguage-parser-2.c',
'gtksourcemarkssequence.c',
'gtksourcepixbufhelper.c',
'gtksourceregex.c',
'gtksourceundomanagerdefault.c',
])
core_c_args = [
'-DHAVE_CONFIG_H',
'-DGTK_SOURCE_COMPILATION',
'-DG_LOG_DOMAIN="GtkSourceView"',
]
core_deps = [
libm_dep,
glib_dep,
gobject_dep,
gio_dep,
gtk_dep,
libxml_dep,
]
if config_h.has('OS_OSX')
core_c_args += '-xobjective-c'
core_deps += [
cocoa_dep,
]
endif
core_enums_header = '''
#if !defined (GTK_SOURCE_H_INSIDE) && !defined (GTK_SOURCE_COMPILATION)
# error "Only <gtksourceview/gtksource.h> can be included directly."
#endif
#include <gtksourceview/gtksourceversion.h>
'''
core_enums = gnome.mkenums_simple('gtksource-enumtypes',
sources: core_public_h,
identifier_prefix: 'GtkSource',
symbol_prefix: 'gtk_source',
header_prefix: core_enums_header,
decorator: 'GTK_SOURCE_ENUM_EXTERN',
install_header: true,
install_dir: join_paths(pkgincludedir, 'gtksourceview'),
)
version_h = configuration_data()
version_h.set('GTK_SOURCE_MAJOR_VERSION', version_major)
version_h.set('GTK_SOURCE_MINOR_VERSION', version_minor)
version_h.set('GTK_SOURCE_MICRO_VERSION', version_micro)
gtksourceversion_h = configure_file(
input: 'gtksourceversion.h.in',
output: 'gtksourceversion.h',
configuration: version_h,
install: true,
install_dir: join_paths(pkgincludedir, 'gtksourceview'),
)
core_sources = [
core_public_c,
core_private_c,
core_enums,
gtksourceversion_h,
]
install_headers(
core_public_h,
install_dir: join_paths(pkgincludedir, 'gtksourceview'),
)
core_lib = static_library(package_string + 'core', core_sources,
include_directories: rootdir,
dependencies: core_deps,
c_args: core_c_args,
install: false
)
gtksource_libs = [
core_lib,
]
core_enums_h = core_enums.get(1)
core_dep = declare_dependency(
link_with: core_lib,
include_directories: rootdir,
dependencies: core_deps,
sources: [core_enums_h]
)
gtksource_deps = [
core_dep,
]
extra_public_sources = []
subdir('completion-providers')
gtksource_res = gnome.compile_resources(
'gtksourceview-gresources',
'gtksourceview.gresource.xml'
)
gtksource_lib = shared_library(package_string, gtksource_res,
version: lib_version,
include_directories: rootdir,
dependencies: gtksource_deps,
link_whole: gtksource_libs,
c_args: core_c_args,
install: true,
gnu_symbol_visibility: 'hidden',
)
gtksource_dep_sources = [
core_enums_h,
]
if generate_gir
gtksource_gir_sources = [
core_public_c,
core_public_h,
core_enums_h,
extra_public_sources,
]
gtksource_gir = gnome.generate_gir(gtksource_lib,
sources: gtksource_gir_sources,
nsversion: api_version,
namespace: 'GtkSource',
symbol_prefix: 'gtk_source',
identifier_prefix: 'GtkSource',
export_packages: [package_string],
link_with: gtksource_lib,
includes: [ 'Gdk-3.0', 'Gtk-3.0' ],
install: true,
install_dir_gir: girdir,
install_dir_typelib: typelibdir,
extra_args: [ '--c-include=gtksourceview/gtksource.h',
'--warn-all' ],
)
gtksource_dep_sources += [
gtksource_gir,
]
if generate_vapi
configure_file(
input: 'GtkSource.metadata.in',
output: 'GtkSource-@0@.metadata'.format(api_version),
copy: true,
)
gtksource_vapi = gnome.generate_vapi(package_string,
sources: gtksource_gir.get(0),
metadata_dirs: join_paths(builddir, 'gtksourceview'),
install: true,
install_dir: vapidir,
packages: [ 'atk',
'gdk-3.0',
'gdk-pixbuf-2.0',
'gio-2.0',
'gtk+-3.0',
'pango',
'cairo' ],
)
endif
endif
gtksource_dep = declare_dependency(
link_with: gtksource_lib,
include_directories: rootdir,
dependencies: gtksource_deps,
sources: gtksource_dep_sources,
)
gtksource_pc_reqs = [
'glib-2.0 @0@'.format(glib_req),
'gobject-2.0 @0@'.format(glib_req),
'gio-2.0 @0@'.format(glib_req),
'gtk+-3.0 @0@'.format(gtk_req),
]
gtksource_pc_private_reqs = [
'libxml-2.0 @0@'.format(libxml_req),
]
gtksource_pc = pkg.generate(
name: package_string,
description: 'Source code editing Gtk+ widget.',
requires: gtksource_pc_reqs,
requires_private: gtksource_pc_private_reqs,
version: version,
subdirs: package_string,
libraries: gtksource_lib,
install_dir: pkgconfigdir,
)
project('gtksourceview', 'c',
version: '4.3.0',
license: 'LGPL-2.1-or-later',
meson_version: '>= 0.50.0',
default_options: [ 'c_std=gnu99',
'buildtype=debugoptimized',
'warning_level=2' ],
)
i18n = import('i18n')
gnome = import('gnome')
pkg = import('pkgconfig')
# Versioning
version = meson.project_version()
version_arr = version.split('.')
version_major = version_arr[0].to_int()
version_minor = version_arr[1].to_int()
version_micro = version_arr[2].to_int()
api_version = '4'
lib_version = '0.0.0'
lib_version_arr = version.split('.')
lib_version_major = version_arr[0].to_int()
lib_version_minor = version_arr[1].to_int()
lib_version_micro = version_arr[2].to_int()
package_name = meson.project_name()
package_string = '@0@-@1@'.format(package_name, api_version)
# Paths
rootdir = include_directories('.')
srcdir = meson.source_root()
builddir = meson.build_root()
prefix = get_option('prefix')
includedir = join_paths(prefix, get_option('includedir'))
libdir = join_paths(prefix, get_option('libdir'))
libexecdir = join_paths(prefix, get_option('libexecdir'))
typelibdir = join_paths(libdir, 'girepository-1.0')
datadir = join_paths(prefix, get_option('datadir'))
localedir = join_paths(prefix, get_option('localedir'))
pkgincludedir = join_paths(includedir, package_string)
pkgconfigdir = join_paths(libdir, 'pkgconfig')
pkgdatadir = join_paths(datadir, package_string)
girdir = join_paths(datadir, 'gir-1.0')
vapidir = join_paths(datadir, 'vala', 'vapi')
mandir = join_paths(prefix, get_option('mandir'))
testexecdir = join_paths(libexecdir, 'installed-tests', package_string)
testdatadir = join_paths(datadir, 'installed-tests', package_string)
docpath = join_paths(datadir, 'gtk-doc', 'html', package_string)
# Options
install_glade_catalog = get_option('glade_catalog')
generate_gir = get_option('gir')
generate_vapi = generate_gir and get_option('vapi')
build_gtk_doc = get_option('gtk_doc')
# Dependencies
cc = meson.get_compiler('c')
libm_dep = cc.find_library('m', required: false)
glib_req = '>= 2.48'
gtk_req = '>= 3.20'
libxml_req = '>= 2.6'
gladeui_req = '>= 3.9'
introspection_req = '>= 1.42.0'
gtk_doc_req = '>= 1.25'
glib_dep = dependency('glib-2.0', version: glib_req)
gobject_dep = dependency('gobject-2.0', version: glib_req)
gio_dep = dependency('gio-2.0', version: glib_req)
gtk_dep = dependency('gtk+-3.0', version: gtk_req)
libxml_dep = dependency('libxml-2.0', version: libxml_req)
gtk_quartz_dep = dependency('gtk+-quartz-3.0', version: gtk_doc_req, required: false)
if install_glade_catalog
gladeui_dep = dependency('gladeui-2.0', version: gladeui_req)
else
gladeui_dep = []
endif
if generate_gir
introspection_dep = dependency('gobject-introspection-1.0', version: introspection_req)
else
introspection_dep = []
endif
if generate_vapi
vapigen_dep = dependency('vapigen')
else
vapigen_dep = []
endif
if build_gtk_doc
gtk_doc_dep = dependency('gtk-doc', version: gtk_doc_req)
else
gtk_doc_dep = []
endif
xmllint_prg = find_program('xmllint', required: false)
# Configurations
add_project_arguments([
'-DG_DISABLE_DEPRECATED',
'-DGDK_DISABLE_DEPRECATED',
'-DGTK_DISABLE_DEPRECATED',
'-DGDK_PIXBUF_DISABLE_DEPRECATED',
], language: 'c')
config_h = configuration_data()
config_h.set_quoted('GSV_API_VERSION', api_version)
config_h.set_quoted('GETTEXT_PACKAGE', package_string)
config_h.set_quoted('DATADIR', datadir)
check_headers = [
['unistd.h', 'HAVE_UNISTD_H'],
]
foreach header: check_headers
if cc.has_header(header.get(0))
config_h.set(header.get(1), 1)
endif
endforeach
if build_machine.system() == 'darwin' and gtk_quartz_dep.found()
cocoa_dep = dependency('appleframeworks', modules: 'Cocoa', required: false)
assert(cocoa_dep.found(), 'Dependency appleframeworks not found')
config_h.set_quoted('OS_OSX', 'yes')
endif
# Compiler flags and warnings
global_c_args = []
test_c_args = [
'-Wcast-align',
'-Wdeclaration-after-statement',
'-Werror=address',
'-Werror=array-bounds',
'-Werror=empty-body',
'-Werror=implicit',
'-Werror=implicit-function-declaration',
'-Werror=incompatible-pointer-types',
'-Werror=init-self',
'-Werror=int-conversion',
'-Werror=int-to-pointer-cast',
'-Werror=main',
'-Werror=misleading-indentation',
'-Werror=missing-braces',
'-Werror=missing-include-dirs',
'-Werror=nonnull',