From d86c29b0e518f765e7570573c76bc033fbd17f6d Mon Sep 17 00:00:00 2001 From: Wu Xiaotian Date: Wed, 19 Jun 2019 22:04:32 +0800 Subject: switch to use meson build system --- doc/creating_themes/meson.build | 3 + doc/man/meson.build | 6 + doc/meson.build | 2 + meson.build | 340 ++++++++++++++++++++++++++++++++++++++++ meson_options.txt | 31 ++++ meson_post_install.py | 22 +++ po/meson.build | 2 + src/meson.build | 243 ++++++++++++++++++++++++++++ src/themes/meson.build | 20 +++ src/tools/meson.build | 33 ++++ src/wm-tester/meson.build | 65 ++++++++ 11 files changed, 767 insertions(+) create mode 100644 doc/creating_themes/meson.build create mode 100644 doc/man/meson.build create mode 100644 doc/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/themes/meson.build create mode 100644 src/tools/meson.build create mode 100644 src/wm-tester/meson.build diff --git a/doc/creating_themes/meson.build b/doc/creating_themes/meson.build new file mode 100644 index 00000000..b62499e6 --- /dev/null +++ b/doc/creating_themes/meson.build @@ -0,0 +1,3 @@ +install_data('C/index.docbook', + install_dir : join_paths(get_option('datadir'), 'help', 'C', 'creating-marco-themes')) + diff --git a/doc/man/meson.build b/doc/man/meson.build new file mode 100644 index 00000000..b565046f --- /dev/null +++ b/doc/man/meson.build @@ -0,0 +1,6 @@ +install_man(['marco.1', + 'marco-theme-viewer.1', + 'marco-window-demo.1', + 'marco-message.1'] + ) + diff --git a/doc/meson.build b/doc/meson.build new file mode 100644 index 00000000..6450e842 --- /dev/null +++ b/doc/meson.build @@ -0,0 +1,2 @@ +subdir('man') +subdir('creating_themes') diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..d93f0b9a --- /dev/null +++ b/meson.build @@ -0,0 +1,340 @@ +project( + 'marco', 'c', + version: '1.23.1', + 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() + +soversion = 2 + +if version_minor.is_odd() + interface_age = 0 +else + interface_age = version_micro +endif + +current = version_minor * 100 + version_micro - interface_age +revision = interface_age +libversion = '@0@.@1@.@2@'.format(soversion, current, revision) +package_string = '@0@-@1@.0'.format(package_name, soversion) + +config_h = configuration_data() +config_h.set_quoted('PACKAGE', package_name) +config_h.set_quoted('PACKAGE_NAME', package_name) +config_h.set_quoted('PACKAGE_STRING', package_string) +config_h.set_quoted('PACKAGE_VERSION', package_version) +config_h.set_quoted('GETTEXT_PACKAGE', package_name) +config_h.set_quoted('VERSION', package_version) + +# 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', + #'-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_argument(arg) + add_project_arguments(arg, language : 'c') + endif +endforeach + +# Integer sizes +config_h.set('SIZEOF_CHAR', cc.sizeof('char')) +config_h.set('SIZEOF_SHORT', cc.sizeof('short')) +config_h.set('SIZEOF_LONG', cc.sizeof('long')) +config_h.set('SIZEOF_INT', cc.sizeof('int')) +config_h.set('SIZEOF_VOID_P', cc.sizeof('void *')) +config_h.set('SIZEOF_LONG_LONG', cc.sizeof('long long')) +config_h.set('SIZEOF___INT64', cc.sizeof('__int64')) + +# byte order +if build_machine.endian() == 'big' + config_h.set('WORDS_BIGENDIAN', 1) +endif + +gnome = import('gnome') +i18n = import('i18n') +pkg = import('pkgconfig') + +# 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')) +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') +glibdir = join_paths(datadir, 'glib-2.0') +gtkdocdir = join_paths(datadir, 'gtk-doc') +localdir = join_paths(datadir, 'local') +vapidir = join_paths(datadir, 'vala', 'vapi') + +# Dependencies +glib_req = '>= 2.58.0' +gio_req = '>= 2.25.10' +gtk_req = '>= 3.22.0' +pango_req = '>= 1.2.0' +libcanberra_gtk_req = '>= 3.22.0' +startup_notification_req = '>= 0.7' + +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) +pango_dep = dependency('pango', version: pango_req) +libcanberra_gtk_dep = dependency('libcanberra-gtk3') +x11_dep = dependency('x11') + +marco_deps = [ + glib_dep, + gtk_dep, + gio_dep, + pango_dep, + libcanberra_gtk_dep, +] + +marco_message_deps = [ + gtk_dep, + x11_dep, +] +marco_window_demo_deps = [ + gtk_dep, + x11_dep, +] + +xcomposite_req ='>= 0.3' +xrender_req ='>= 0.0' + +startup_notification_dep = dependency('libstartup-notification-1.0', version:startup_notification_req, required: false) +xcomposite_dep = dependency('xcomposite', version:xcomposite_req, required: false) +xrender_dep = dependency('xrender', version:xrender_req, required: false) +xcursor_dep = dependency('xcursor', required: false) +libgtop_dep = dependency('libgtop-2.0', required: false) +xrandr_dep = dependency('xrandr', required: false) +xpresent_dep = dependency('xpresent', required: false) +xinerama_dep = dependency('xinerama', required: false) +sm_dep = dependency('sm', required: false) + +verbose_mode = not get_option('disable-verbose-mode') +if verbose_mode + config_h.set('WITH_VERBOSE_MODE', 1, description: 'Build with verbose mode support') +endif + +if cc.has_function('backtrace', prefix : '#include ') + config_h.set('HAVE_BACKTRACE', 1) +endif + +build_startup_notification = not get_option('disable-startup-notification') +if build_startup_notification and not startup_notification_dep.found() + build_startup_notification = false +else + config_h.set('HAVE_STARTUP_NOTIFICATION', 1, description: 'Building with startup notification support') + config_h.set('SN_API_NOT_YET_FROZEN', 1) + marco_deps += [ startup_notification_dep ] +endif + +build_xcomposite = not get_option('disable-compositor') +if build_xcomposite and not xcomposite_dep.found() + build_xcomposite = false +else + marco_deps += [ xcomposite_dep, dependency('xfixes'), xrender_dep, dependency('xdamage')] + config_h.set('HAVE_COMPOSITE_EXTENSIONS', 1) +endif + +build_render = not get_option('disable-render') +if build_render and not xrender_dep.found() + build_render = false +else + marco_deps += [xrender_dep] + config_h.set('HAVE_RENDER', 1, description: 'Building with Render extension support') +endif + +build_xcursor = false +if xcursor_dep.found() + marco_deps += [xcursor_dep] + config_h.set('HAVE_XCURSOR', 1, description: 'Building with Render extension support') + build_xcursor = true +endif + +if libgtop_dep.found() + marco_deps += [libgtop_dep] + config_h.set('HAVE_GTOP', 1, description: 'Building with libgtop') +endif + +build_xinerama = not get_option('disable-xinerama') +if build_xinerama and not xinerama_dep.found() + config_h.set('HAVE_XFREE_XINERAMA', 1) + config_h.set('HAVE_XINERAMA', 1) + marco_message_deps += [ xinerama_dep ] +endif + +#xext +build_shape = false +if cc.has_header('X11/extensions/shape.h') + config_h.set('HAVE_SHAPE', 1) + build_shape = true +endif + +if cc.has_header('X11/XKBlib.h') + config_h.set('HAVE_XKB', 1) +endif + +build_randr = false +if xrandr_dep.found() + config_h.set('HAVE_RANDR', 1, description: 'Have the Xrandr extension library') + build_randr = true + marco_deps += [ xrandr_dep ] +endif + +#xext +build_xsync = not get_option('disable-xsync') +if build_xsync and not cc.has_header('X11/extensions/sync.h') + build_xsync = false +else + config_h.set('HAVE_XSYNC', 1) +endif + +build_xpresent = xpresent_dep.found() +if build_xpresent + config_h.set('HAVE_PRESENT', 1, description: 'Have the Xpresent extension library') + marco_deps += [ xpresent_dep ] +endif + +libm = cc.find_library('m', required: false) +if libm.found() + marco_deps += [libm] +endif + +build_sm = not get_option('disable-sm') +if build_sm and not sm_dep.found() + config_h.set('HAVE_SM', 1) + marco_deps += [ sm_dep ] + marco_message_deps += [ sm_dep ] +else + build_sm = false + message('--enable-sm forced and -lSM not found') +endif + +gdk_pixbuf_csource = find_program('gdk-pixbuf-csource') +zenity = find_program('zenity') + +libxext = cc.find_library('Xext', required: false) +if build_xsync + marco_deps += [libxext] +endif + +config_h.set_quoted('MARCO_LOCALEDIR', localdir) +config_h.set_quoted('LIBDIR', libdir) +config_h.set_quoted('MARCO_DATADIR', datadir) + +configure_file( + output: 'config.h', + configuration: config_h +) + +subdir('doc') +subdir('src') +subdir('po') + +summary = [ + '', + 'marco-@0@:'.format(meson.project_version()), + '', + ' prefix: @0@'.format(prefix), + ' source code location: @0@'.format(srcdir), + ' compiler: @0@'.format(cc.get_id()), + '', + ' Xinerama: @0@'.format(build_xinerama), + ' Startup notification: @0@'.format(build_startup_notification), + ' Compositing manager: @0@'.format(build_xcomposite), + ' Session management: @0@'.format(build_sm), + ' Shape extension: @0@'.format(build_shape), + ' Resize-and-rotate: @0@'.format(build_randr), + ' Xsync: @0@'.format(build_xsync), + ' Xpresent: @0@'.format(build_xpresent), + ' Render: @0@'.format(build_render), + ' Xcursor: @0@'.format(build_xcursor), + '', +] + +meson.add_install_script( + 'meson_post_install.py', + libdir, datadir, +) + +message('\n'.join(summary)) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..8aac9850 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,31 @@ +option('disable-verbose-mode', + type: 'boolean', value: true, + description: 'disable marco\'s ability to do verbose logging, for embedded/size-sensitive custom builds') + +option('disable-sm', + type: 'boolean', value: false, + description: 'disable marco\'s session management support, for embedded/size-sensitive custom non-MATE builds') + +option('disable-startup-notification', + type: 'boolean', value: false, + description: 'disable marco\'s startup notification support, for embedded/size-sensitive custom non-MATE builds') + +option('disable-compositor', + type: 'boolean', value: false, + description: 'disable marco\'s compositing manager') + +option('disable-xsync', + type: 'boolean', value: false, + description: 'disable marco\'s use of the XSync extension') + +option('disable-render', + type: 'boolean', value: false, + description: 'disable marco\'s use of the RENDER extension') + +option('disable-shape', + type: 'boolean', value: false, + description: 'disable marco\'s use of the shaped window extension') + +option('disable-xinerama', + type: 'boolean', value: false, + description: 'disable marco\'s use of the Xinerama extension') diff --git a/meson_post_install.py b/meson_post_install.py new file mode 100755 index 00000000..96a0818b --- /dev/null +++ b/meson_post_install.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import os +import subprocess +import sys + +libdir = sys.argv[1] +datadir = sys.argv[2] + +# 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')]) diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 00000000..79c6233f --- /dev/null +++ b/po/meson.build @@ -0,0 +1,2 @@ +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 00000000..eb5a5820 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,243 @@ +cargs = ['-DG_LOG_DOMAIN="marco"'] + +install_headers([ + 'include/boxes.h', + 'ui/gradient.h', + 'include/util.h', + 'include/common.h', + 'ui/preview-widget.h', + 'ui/theme-parser.h', + 'ui/theme.h' + ], + subdir : 'marco-1/marco-private' +) + +libmarco = shared_library( + 'marco-private', + sources : [ + 'core/async-getprop.c', + 'core/async-getprop.h', + 'core/atomnames.h', + 'core/bell.c', + 'core/bell.h', + 'core/boxes.c', + 'include/boxes.h', + 'compositor/compositor.c', + 'compositor/compositor-private.h', + 'compositor/compositor-xrender.c', + 'compositor/compositor-xrender.h', + 'include/compositor.h', + 'core/constraints.c', + 'core/constraints.h', + 'core/core.c', + 'core/delete.c', + 'core/display.c', + 'core/display-private.h', + 'include/display.h', + 'ui/draw-workspace.c', + 'ui/draw-workspace.h', + 'core/edge-resistance.c', + 'core/edge-resistance.h', + 'core/effects.c', + 'core/effects.h', + 'core/errors.c', + 'include/errors.h', + 'core/eventqueue.c', + 'core/eventqueue.h', + 'core/frame.c', + 'core/frame-private.h', + 'include/frame.h', + 'ui/gradient.c', + 'ui/gradient.h', + 'core/group-private.h', + 'core/group-props.c', + 'core/group-props.h', + 'core/group.c', + 'core/group.h', + 'core/iconcache.c', + 'core/iconcache.h', + 'core/keybindings.c', + 'core/keybindings.h', + 'core/main.c', + 'include/main.h', + 'core/marco-Xatomtype.h', + 'core/place.c', + 'core/place.h', + 'core/prefs.c', + 'include/prefs.h', + 'core/screen.c', + 'core/screen-private.h', + 'include/screen.h', + 'include/types.h', + 'core/session.c', + 'core/session.h', + 'core/stack.c', + 'core/stack.h', + 'core/util.c', + 'include/util.h', + 'core/window-props.c', + 'core/window-props.h', + 'core/window.c', + 'core/window-private.h', + 'include/window.h', + 'core/workspace.c', + 'core/workspace.h', + 'core/xprops.c', + 'include/xprops.h', + 'include/common.h', + 'include/core.h', + 'include/ui.h', + 'ui/fixedtip.c', + 'ui/fixedtip.h', + 'ui/frames.c', + 'ui/frames.h', + 'ui/menu.c', + 'ui/menu.h', + 'ui/metaaccellabel.c', + 'ui/metaaccellabel.h', + 'ui/preview-widget.c', + 'ui/preview-widget.h', + 'ui/resizepopup.c', + 'include/resizepopup.h', + 'ui/tabpopup.c', + 'include/tabpopup.h', + 'ui/tile-preview.c', + 'include/tile-preview.h', + 'ui/theme-parser.c', + 'ui/theme-parser.h', + 'ui/theme.c', + 'ui/theme.h', + 'ui/ui.c', + 'include/all-keybindings.h', + ], + include_directories : [ + include_directories('.'), + include_directories('..'), + include_directories('include'), + ], + dependencies : marco_deps, + soversion: soversion, + version: libversion, + c_args : cargs, + install: true, +) + +executable('marco', + 'core/main.c', + 'include/main.h', + include_directories : [ + include_directories('.'), + include_directories('..'), + include_directories('./include'), + ], + dependencies : marco_deps, + link_with : [ + libmarco + ], + c_args : cargs, + install: true, +) +executable('marco-theme-viewer', + 'ui/theme-viewer.c', + include_directories : [ + include_directories('.'), + include_directories('..'), + include_directories('./include'), + ], + dependencies : marco_deps, + link_with : [ + libmarco, + ], + install: true, +) + +executable('testboxes', + 'include/util.h', + 'core/util.c', + 'include/boxes.h', + 'core/boxes.c', + 'core/testboxes.c', + include_directories : [ + include_directories('.'), + include_directories('..'), + include_directories('./include'), + ], + dependencies : marco_deps, +) + +executable('testgradient', + 'ui/gradient.h', + 'ui/gradient.c', + 'ui/testgradient.c', + dependencies : marco_deps, +) + +executable('testasyncgetprop', + 'core/async-getprop.h', + 'core/async-getprop.c', + 'core/testasyncgetprop.c', + dependencies : marco_deps, +) + +gnome = import('gnome') +i18n = import('i18n') + +i18n.merge_file( + input: 'marco.desktop.in', + output: 'marco.desktop', + type: 'desktop', + po_dir: join_paths(meson.source_root(), 'po'), + install: true, + install_dir: join_paths(get_option('datadir'), 'applications') + ) + +i18n.merge_file( + input: 'marco-wm.desktop.in', + output: 'marco-wm.desktop', + type: 'desktop', + po_dir: join_paths(meson.source_root(), 'po'), + install: true, + install_dir: join_paths(datadir, 'mate', 'wm-properties') + ) + +compiled_schemas = gnome.compile_schemas() +install_data('org.mate.marco.gschema.xml', + install_dir : 'share/glib-2.0/schemas') + +xml_files = [ + '50-marco-desktop-key.xml', + '50-marco-window-key.xml', + '50-marco-global-key.xml', + ] + +foreach xml : xml_files + i18n.merge_file(xml, + input: xml+ '.in', + output: xml, + po_dir: '../po', + data_dirs: '..', + install: true, + install_dir: join_paths(get_option('datadir'), 'mate-control-center', 'keybindings') + ) +endforeach + +pkconf = configuration_data() +pkconf.set('prefix', prefix) +pkconf.set('exec_prefix', prefix) +pkconf.set('libdir', libdir) +pkconf.set('includedir', includedir) +pkconf.set('libexecdir', libexecdir) +pkconf.set('VERSION', meson.project_version()) + +pc = configure_file( + input : 'libmarco-private.pc.in', + output : 'libmarco-private.pc', + configuration : pkconf +) + +install_data(pc, + install_dir: join_paths(get_option('libdir'), 'pkgconfig'), +) +subdir('wm-tester') +subdir('tools') +subdir('themes') diff --git a/src/themes/meson.build b/src/themes/meson.build new file mode 100644 index 00000000..e11da1f5 --- /dev/null +++ b/src/themes/meson.build @@ -0,0 +1,20 @@ +themes = [ + 'ClearlooksRe', + 'eOS', + 'DustBlue', + 'WinMe', + 'Splint-Left', + 'Dopple', + 'Spidey-Left', + 'Splint', + 'Dopple-Left', + 'Spidey', +] + +themedir = join_paths(datadir, 'themes') +foreach theme: themes + install_subdir(theme, + install_dir : join_paths(themedir, theme, 'metacity-1'), + strip_directory : true + ) +endforeach diff --git a/src/tools/meson.build b/src/tools/meson.build new file mode 100644 index 00000000..c6f1b4a9 --- /dev/null +++ b/src/tools/meson.build @@ -0,0 +1,33 @@ +cargs = ['-DMARCO_ICON_DIR="marco"'] + +install_data('marco-window-demo.png', + install_dir: join_paths(pkgdatadir, 'icons') +) + +executable('marco-message', + 'marco-message.c', + include_directories : [ + include_directories('.'), + include_directories('..'), + ], + dependencies: marco_message_deps, + link_with : [ + libmarco + ], + c_args : cargs, + install: true, +) + +executable('marco-window-demo', + 'marco-window-demo.c', + include_directories : [ + include_directories('.'), + include_directories('..'), + ], + dependencies: marco_window_demo_deps, + link_with : [ + libmarco + ], + c_args : cargs, + install: true, +) diff --git a/src/wm-tester/meson.build b/src/wm-tester/meson.build new file mode 100644 index 00000000..14d8c8bf --- /dev/null +++ b/src/wm-tester/meson.build @@ -0,0 +1,65 @@ +test1 = executable('wm-tester', + 'main.c', + include_directories : [ + include_directories('.'), + include_directories('..'), + ], + dependencies: marco_deps, + link_with : [ + libmarco + ], +) + +test2 = executable('test-gravity', + 'test-gravity.c', + include_directories : [ + include_directories('.'), + include_directories('..'), + ], + dependencies: marco_deps, + link_with : [ + libmarco + ], +) + +test3 = executable('test-resizing', + 'test-resizing.c', + include_directories : [ + include_directories('.'), + include_directories('..'), + ], + dependencies: marco_deps, + link_with : [ + libmarco + ], +) + +test4 = executable('focus-window', + 'focus-window.c', + include_directories : [ + include_directories('.'), + include_directories('..'), + ], + dependencies: marco_deps, + link_with : [ + libmarco + ], +) + +test5 = executable('test-size-hints', + 'test-size-hints.c', + include_directories : [ + include_directories('.'), + include_directories('..'), + ], + dependencies: marco_deps, + link_with : [ + libmarco + ], +) + +test('wm-tester', test1) +test('test-gravity', test2) +test('test-resizing', test3) +test('focus-window', test4) +test('test-size-hints', test5) -- cgit v1.2.1