From bc13d9f3af1d5114e47b75633c4fd5578214b460 Mon Sep 17 00:00:00 2001 From: Wu Xiaotian Date: Sun, 5 Apr 2020 22:02:48 +0800 Subject: add meson build system --- help/LINGUAS | 107 ++++++++++++++++ help/meson.build | 10 ++ meson.build | 255 +++++++++++++++++++++++++++++++++++++++ meson_options.txt | 7 ++ meson_post_install.py | 17 +++ po/meson.build | 3 + src/meson.build | 129 ++++++++++++++++++++ src/skey/meson.build | 27 +++++ subprojects/mate-submodules.wrap | 6 + 9 files changed, 561 insertions(+) create mode 100644 help/LINGUAS create mode 100644 help/meson.build create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100755 meson_post_install.py create mode 100644 po/meson.build create mode 100644 src/meson.build create mode 100644 src/skey/meson.build create mode 100644 subprojects/mate-submodules.wrap diff --git a/help/LINGUAS b/help/LINGUAS new file mode 100644 index 0000000..5c95584 --- /dev/null +++ b/help/LINGUAS @@ -0,0 +1,107 @@ +af +am +ar +as +ast +az +be +bg +bn +bn_IN +br +bs +ca +ca@valencia +cmn +crh +cs +cy +da +de +dz +el +en_AU +en_CA +en_GB +eo +es +es_AR +es_CL +es_CO +es_ES +es_MX +es_PR +et +eu +fa +fi +fr +fur +fy +ga +gl +gu +ha +he +hi +hr +hu +hy +id +ie +ig +is +it +ja +ka +kk +kn +ko +ku +ku_IQ +ky +lt +lv +mai +mg +mk +ml +mn +mr +ms +nb +nds +ne +nl +nn +oc +or +pa +pl +ps +pt +pt_BR +ro +ru +si +sk +sl +sq +sr +sr@latin +sv +ta +te +th +tr +ug +uk +ur +uz +vi +wa +xh +yo +zh_CN +zh_HK +zh_TW diff --git a/help/meson.build b/help/meson.build new file mode 100644 index 0000000..955d3c4 --- /dev/null +++ b/help/meson.build @@ -0,0 +1,10 @@ +help_media = [ + 'figures/mate-terminal-default.png', + 'figures/mate-terminal-tabbed.png', +] + +gnome.yelp('mate-terminal', + sources: ['index.docbook', 'legal.xml'], + media: help_media, + symlink_media: true, +) diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..d734ab7 --- /dev/null +++ b/meson.build @@ -0,0 +1,255 @@ +project( + 'mate-terminal', 'c', + version: '1.25.0', + meson_version: '>=0.47.0', + license: 'GPL2', + default_options : [ 'warning_level=1', 'buildtype=debugoptimized', 'c_std=gnu11'], +) + +package_name = meson.project_name() +package_version = meson.project_version() + +# Versionning +version_arr = package_version.split('.') +version_major = version_arr[0].to_int() +version_minor = version_arr[1].to_int() +version_micro = version_arr[2].to_int() + +package_string = '@0@ @1@.0'.format(package_name, package_version) + +config_h = configuration_data() +config_h.set_quoted('PACKAGE', package_name, description: 'Name of package') +config_h.set_quoted('PACKAGE_NAME', package_name, description: 'Define to the full name of this package.') +config_h.set_quoted('PACKAGE_STRING', package_string, description: 'Define to the full name and version of this package.') +config_h.set_quoted('PACKAGE_VERSION', package_version, description: 'Define to the version of this package.') +config_h.set_quoted('PACKAGE_URL', 'https://mate-desktop.org', description: 'Define to the home page for this package.') +config_h.set_quoted('GETTEXT_PACKAGE', package_name, description: 'Gettext package') +config_h.set_quoted('VERSION', package_version, description: 'Name of package') + +# Compiler & Project arguments +add_project_arguments([ + '-DHAVE_CONFIG_H', + '-I' + meson.build_root(), + ], language: 'c') + +# get suported warning flags +test_args = [ + #'-fstack-protector-strong', + #'-Waggregate-return', + #'-Warray-bounds', + '-Wcast-align', + '-Wchar-subscripts', + #'-Wclobbered', + #'-Wdeclaration-after-statement', + #'-Wempty-body', + #'-Wextra', + #'-Wformat=2', + #'-Wformat-nonliteral', + #'-Wformat-security', + #'-Werror=format-security', + #'-Werror=format=2', + #'-Wformat-signedness', + #'-Wignored-qualifiers', + #'-Wimplicit-function-declaration', + #'-Winit-self', + #'-Winline', + '-Wmissing-declarations', + #'-Wmissing-format-attribute', + #'-Wmissing-include-dirs', + #'-Wmissing-noreturn', + #'-Wmissing-parameter-type', + '-Wmissing-prototypes', + '-Wnested-externs', + #'-Wno-discarded-qualifiers', + #'-Wno-missing-field-initializers', + #'-Wno-strict-aliasing', + #'-Wno-suggest-attribute=format', + #'-Wno-unused-parameter', + #'-Wold-style-definition', + #'-Woverride-init', + #'-Wpacked', + '-Wpointer-arith', + #'-Wredundant-decls', + #'-Wreturn-type', + '-Wshadow', + '-Wsign-compare', + #'-Wstrict-aliasing', + #'-Wstrict-prototypes', + #'-Wswitch-default', + #'-Wtype-limits', + #'-Wundef', + #'-Wuninitialized', + #'-Wunused-but-set-variable', + #'-Wwrite-strings' + #'-Wall', + #'-ansi', + ] + +cc = meson.get_compiler('c') + +foreach arg: test_args + if cc.has_multi_arguments(arg) + add_project_arguments(arg, language : 'c') + endif +endforeach + +# byte order +if build_machine.endian() == 'big' + config_h.set('WORDS_BIGENDIAN', 1) +endif + +gnome = import('gnome') +i18n = import('i18n') + +# Paths +rootdir = include_directories('.') + +srcdir = meson.current_source_dir() +builddir = meson.current_build_dir() + +prefix = get_option('prefix') + +buildtype = get_option('buildtype') + +bindir = join_paths(prefix, get_option('bindir')) +libdir = join_paths(prefix, get_option('libdir')) +datadir = join_paths(prefix, get_option('datadir')) +pkgdatadir = join_paths(datadir, package_name) + +# Dependencies +glib_req = '>= 2.50.0' +gio_req = '>= 2.50.0' +gtk_req = '>= 3.22.0' +vte_req = '>= 0.48' +dconf_req = '>= 0.13.4' +ice_req = '>= 1.0.0' +sm_req = '>= 1.0.0' + +glib_dep = dependency('glib-2.0', version: glib_req) +gtk_dep = dependency('gtk+-3.0', version: gtk_req) +gio_dep = dependency('gio-2.0', version: gio_req) +vte_dep = dependency('vte-2.91', version: vte_req) +dconf_dep = dependency('dconf', version: dconf_req) +x11_dep = dependency('x11') +sm_dep = dependency('sm', version: sm_req, required: false) + +term_deps = [ + vte_dep, + glib_dep, + gio_dep, + gtk_dep, + dconf_dep, + x11_dep, +] + +build_skey = false +if get_option('skey') + build_skey = true + config_h.set('ENABLE_SKEY', 1, description: 'Define if s/key support is enabled') +endif + +build_sm = false +ice_dep = dependency('ice', version: ice_req, required: false) +if get_option('sm') and sm_dep.found() and ice_dep.found() + build_sm = true + config_h.set('HAVE_SMCLIENT', 1) + mate_submodules_dep = dependency('mate-submodules', version: '1.24.0', + fallback: ['mate-submodules', 'mate_submodules_dep']) + term_deps += [mate_submodules_dep] +endif + +configure_file( + output: 'config.h', + configuration: config_h +) + +subdir('help') +subdir('src') +subdir('po') + +desktop_in = configuration_data() +desktop_in.set('VERSION', meson.project_version()) + +desktop_file_configured = configure_file( + input: 'mate-terminal.desktop.in.in', + output: 'mate-terminal.desktop.in', + configuration: desktop_in, +) + +desktop_file = i18n.merge_file( + 'desktop-file', + input: desktop_file_configured, + output: 'mate-terminal.desktop', + type: 'desktop', + po_dir: join_paths(srcdir, 'po'), + install: true, + install_dir: join_paths( + datadir, + 'applications', + ) +) + +desktop_file_validate = find_program('desktop-file-validate', required: false) +if desktop_file_validate.found() + test( + 'validate-desktop', + desktop_file_validate, + args: [ + desktop_file.full_path(), + ] + ) +endif + +install_man('mate-terminal.1') + +appdata_file = i18n.merge_file( + 'appdata-file', + input: 'mate-terminal.appdata.xml.in', + output: 'mate-terminal.appdata.xml', + type: 'xml', + po_dir: join_paths(srcdir, 'po'), + install: true, + install_dir: join_paths( + datadir, + 'metainfo', + ) +) + +appstream_util = find_program('appstream-util', required: false) +if appstream_util.found() + test( + 'validate-appdata', + appstream_util, + args: [ + 'validate-relax', + '--nonet', + appdata_file.full_path() + ] + ) +endif + +install_data( + 'mate-terminal.wrapper', + install_mode: 'rwxr-xr-x', + install_dir: get_option('bindir') + ) + +summary = [ + '', + 'mate-terminal-@0@:'.format(meson.project_version()), + '', + ' prefix: @0@'.format(prefix), + ' source code location: @0@'.format(srcdir), + ' compiler: @0@'.format(cc.get_id()), + '', + ' smclient support: @0@'.format(build_sm), + ' s/key support: @0@'.format(build_skey), + '', +] + +meson.add_install_script( + 'meson_post_install.py', + datadir, +) + +message('\n'.join(summary)) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..7fe6bde --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,7 @@ +option('skey', + type: 'boolean', value: true, + description: 'whether to enable s/key support') + +option('sm', + type: 'boolean', value: true, + description: 'session management support, for embedded/size-sensitive custom non-MATE builds') diff --git a/meson_post_install.py b/meson_post_install.py new file mode 100755 index 0000000..a09d57d --- /dev/null +++ b/meson_post_install.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 + +import os +import subprocess +import sys + +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 desktop database...') + subprocess.call(['update-desktop-database', '-q', + os.path.join(datadir, 'applications')]) diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 0000000..fbf2aa0 --- /dev/null +++ b/po/meson.build @@ -0,0 +1,3 @@ +i18n = import('i18n') +i18n.gettext(meson.project_name(), preset: 'glib') + diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..a8cd1b1 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,129 @@ +version_data = configuration_data() +version_data.set('TERMINAL_MAJOR_VERSION', version_major) +version_data.set('TERMINAL_MINOR_VERSION', version_minor) +version_data.set('TERMINAL_MICRO_VERSION', version_micro) + +version_h = configure_file( + input: 'terminal-version.h.in', + output: 'terminal-version.h', + configuration: version_data, +) + +cargs = [ + '-DG_LOG_DOMAIN="marco"', + '-DTERMINAL_COMPILATION', + '-DTERMINAL_RESOURCES_PATH_PREFIX="/org/mate/terminal"', + '-DTERM_DATADIR="@0@"'.format(datadir), + '-DTERM_LOCALEDIR="@0@/locale"'.format(datadir), + '-DTERM_PKGDATADIR="@0@"'.format(pkgdatadir), + '-DTERM_HELPDIR="@0@/help"'.format(datadir), + '-DSN_API_NOT_YET_FROZEN', + '-DGDK_MULTIHEAD_SAFE', + '-DG_DISABLE_SINGLE_INCLUDES', + '-DPANGO_DISABLE_SINGLE_INCLUDES', + '-DATK_DISABLE_SINGLE_INCLUDES', + '-DGDK_DISABLE_SINGLE_INCLUDES', + '-DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES', + '-DGTK_DISABLE_SINGLE_INCLUDES', + '-DEGG_SM_CLIENT_BACKEND_XSMP', +] + +sources = [ + 'eggshell.c', + 'eggshell.h', + 'profile-editor.c', + 'profile-editor.h', + 'terminal.c', + 'terminal-accels.c', + 'terminal-accels.h', + 'terminal-app.c', + 'terminal-app.h', + 'terminal-close-button.h', + 'terminal-close-button.c', + 'terminal-debug.c', + 'terminal-debug.h', + 'terminal-encoding.c', + 'terminal-encoding.h', + 'terminal-info-bar.c', + 'terminal-info-bar.h', + 'terminal-intl.h', + 'terminal-options.c', + 'terminal-options.h', + 'terminal-profile.c', + 'terminal-profile.h', + 'terminal-screen.c', + 'terminal-screen.h', + 'terminal-screen-container.c', + 'terminal-screen-container.h', + 'terminal-search-dialog.c', + 'terminal-search-dialog.h', + 'terminal-tab-label.c', + 'terminal-tab-label.h', + 'terminal-tabs-menu.c', + 'terminal-tabs-menu.h', + 'terminal-util.c', + 'terminal-util.h', + 'terminal-window.c', + 'terminal-window.h', + version_h, +] + +if build_skey + subdir('skey') + sources += [ + 'skey-popup.c', + 'skey-popup.h', + ] +endif + +schemas_data = configuration_data() +schemas_data.set('GETTEXT_PACKAGE', meson.project_name()) + +schemas_in = [ + 'org.mate.terminal.gschema.xml', +] + +schemas = [] +foreach s: schemas_in + schemas += configure_file( + input: '@0@.in'.format(s), + output: '@0@'.format(s), + configuration: schemas_data, + ) +endforeach + +install_data(schemas, + install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas'), +) + +source_enum = gnome.mkenums('terminal-type-builtins', + sources: 'terminal-profile.h', + h_template: 'terminal-type-builtins.h.template', + c_template: 'terminal-type-builtins.c.template', + ) + +source_resources = gnome.compile_resources( + 'terminal-resources', + 'terminal.gresource.xml', + source_dir : '.', + c_name : 'terminal' + ) + +marshalers = gnome.genmarshal('terminal-marshal', + sources: 'terminal-marshal.list', + prefix: '_terminal_marshal', +) + +executable('mate-terminal', + sources, source_enum, source_resources, marshalers, + include_directories : [ + include_directories('.'), + include_directories('..'), + ], + dependencies : term_deps, + link_with : [ + libskey, + ], + c_args : cargs, + install: true, +) diff --git a/src/skey/meson.build b/src/skey/meson.build new file mode 100644 index 0000000..0560e47 --- /dev/null +++ b/src/skey/meson.build @@ -0,0 +1,27 @@ +libskey = static_library( + 'skey', + sources : [ + 'btoe.c', + 'btoe.h', + 'skey.h', + 'skey.c', + 'skeyutil.h', + 'skeyutil.c', + 'md4.c', + 'md4.h', + 'md5.c', + 'md5.h', + 'sha1.h', + 'sha1.c', + ], + dependencies : term_deps, + install: false, +) + +t=executable('testskey', + 'test.c', + link_with : [libskey], + dependencies : term_deps, +) + +test('test skey', t) diff --git a/subprojects/mate-submodules.wrap b/subprojects/mate-submodules.wrap new file mode 100644 index 0000000..7846605 --- /dev/null +++ b/subprojects/mate-submodules.wrap @@ -0,0 +1,6 @@ +[wrap-git] +directory =mate-submodules +url=https://github.com/mate-desktop/mate-submodules.git +push-url=ssh://git@github.com:mate-desktop/mate-submodules.git +revision=master +depth=1 -- cgit v1.2.1