From 765a918a62c76d5ce0cee48a0b1a74127214b0f3 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Tue, 18 Jul 2023 17:58:47 +0200 Subject: [PATCH] build: Add a Meta Toolkit private library Currently, Meta/Cogl/Clutter makes use of cairo_rectangle_int_t despite the existance of MetaRectangle. In order to make MetaRectangle usable in Cogl/Clutter as well, Mtk would provide such base types that are shared across the various private libraries Part-of: --- .gitlab-ci.yml | 2 +- doc/reference/cally/meson.build | 2 + doc/reference/clutter/meson.build | 2 + doc/reference/meson.build | 1 + doc/reference/meta/meson.build | 2 + doc/reference/mtk/meson.build | 24 +++++++++ doc/reference/mtk/mtk.toml.in | 34 +++++++++++++ doc/reference/mtk/urlmap.js | 7 +++ meson.build | 1 + mtk/meson.build | 39 +++++++++++++++ mtk/mtk/meson.build | 81 +++++++++++++++++++++++++++++++ mtk/mtk/mtk-macros.h | 33 +++++++++++++ mtk/mtk/mtk.h | 28 +++++++++++ src/tests/meson.build | 1 + 14 files changed, 256 insertions(+), 1 deletion(-) create mode 100644 doc/reference/mtk/meson.build create mode 100644 doc/reference/mtk/mtk.toml.in create mode 100644 doc/reference/mtk/urlmap.js create mode 100644 mtk/meson.build create mode 100644 mtk/mtk/meson.build create mode 100644 mtk/mtk/mtk-macros.h create mode 100644 mtk/mtk/mtk.h diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cdb7952f2..824dd1e1f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -637,7 +637,7 @@ reference: - meson setup . build --werror -Ddocs=true -Dtests=false - ninja -C build - mkdir references - - mv build/doc/reference/{cally/cally,clutter/clutter,cogl/cogl,cogl-pango/cogl-pango,meta/meta} references/ + - mv build/doc/reference/{cally/cally,clutter/clutter,cogl/cogl,cogl-pango/cogl-pango,meta/meta,mtk/mtk} references/ artifacts: expire_in: 1 week expose_as: 'Documentation' diff --git a/doc/reference/cally/meson.build b/doc/reference/cally/meson.build index 62706e785..63a420e2d 100644 --- a/doc/reference/cally/meson.build +++ b/doc/reference/cally/meson.build @@ -14,6 +14,7 @@ custom_target('cally-doc', gidocgen, 'generate', gidocgen_common_args, + '--add-include-path=@0@'.format(meson.current_build_dir() / '../../../mtk/mtk'), '--add-include-path=@0@'.format(meson.current_build_dir() / '../../../cogl/cogl'), '--add-include-path=@0@'.format(meson.current_build_dir() / '../../../cogl/cogl-pango'), '--add-include-path=@0@'.format(meson.current_build_dir() / '../../../clutter/clutter'), @@ -23,6 +24,7 @@ custom_target('cally-doc', '@INPUT1@', ], depends: [ + libmutter_mtk_gir[0], libmutter_cogl_gir[0], libmutter_cogl_pango_gir[0], libmutter_clutter_gir[0], diff --git a/doc/reference/clutter/meson.build b/doc/reference/clutter/meson.build index 6b260c8e0..d93906ab3 100644 --- a/doc/reference/clutter/meson.build +++ b/doc/reference/clutter/meson.build @@ -14,6 +14,7 @@ custom_target('clutter-doc', gidocgen, 'generate', gidocgen_common_args, + '--add-include-path=@0@'.format(meson.current_build_dir() / '../../../mtk/mtk'), '--add-include-path=@0@'.format(meson.current_build_dir() / '../../../cogl/cogl'), '--add-include-path=@0@'.format(meson.current_build_dir() / '../../../cogl/cogl-pango'), '--config=@INPUT0@', @@ -22,6 +23,7 @@ custom_target('clutter-doc', '@INPUT1@', ], depends: [ + libmutter_mtk_gir[0], libmutter_cogl_pango_gir[0], libmutter_cogl_gir[0], ], diff --git a/doc/reference/meson.build b/doc/reference/meson.build index 72665b511..4b54d9ffc 100644 --- a/doc/reference/meson.build +++ b/doc/reference/meson.build @@ -25,3 +25,4 @@ subdir('clutter') subdir('cogl') subdir('cogl-pango') subdir('meta') +subdir('mtk') \ No newline at end of file diff --git a/doc/reference/meta/meson.build b/doc/reference/meta/meson.build index f739b15ab..bff21c184 100644 --- a/doc/reference/meta/meson.build +++ b/doc/reference/meta/meson.build @@ -14,6 +14,7 @@ custom_target('meta-doc', gidocgen, 'generate', gidocgen_common_args, + '--add-include-path=@0@'.format(meson.current_build_dir() / '../../../mtk/mtk'), '--add-include-path=@0@'.format(meson.current_build_dir() / '../../../clutter/clutter'), '--add-include-path=@0@'.format(meson.current_build_dir() / '../../../cogl/cogl'), '--add-include-path=@0@'.format(meson.current_build_dir() / '../../../cogl/cogl-pango'), @@ -23,6 +24,7 @@ custom_target('meta-doc', '@INPUT1@', ], depends: [ + libmutter_mtk_gir[0], libmutter_clutter_gir[0], libmutter_cally_gir[0], libmutter_cogl_pango_gir[0], diff --git a/doc/reference/mtk/meson.build b/doc/reference/mtk/meson.build new file mode 100644 index 000000000..77c25181e --- /dev/null +++ b/doc/reference/mtk/meson.build @@ -0,0 +1,24 @@ +mtk_toml = configure_file( + input: 'mtk.toml.in', + output: 'mtk.toml', + configuration: toml_conf, + install: true, + install_dir: docs_dir / 'mtk', +) + +custom_target('mtk-doc', + input: [ mtk_toml, libmutter_mtk_gir[0] ], + output: 'mtk', + command: [ + gidocgen, + 'generate', + gidocgen_common_args, + '--config=@INPUT0@', + '--output-dir=@OUTPUT@', + '--content-dir=@0@'.format(meson.current_source_dir()), + '@INPUT1@', + ], + build_by_default: true, + install: true, + install_dir: docs_dir, +) diff --git a/doc/reference/mtk/mtk.toml.in b/doc/reference/mtk/mtk.toml.in new file mode 100644 index 000000000..cdae89451 --- /dev/null +++ b/doc/reference/mtk/mtk.toml.in @@ -0,0 +1,34 @@ +[library] +version = "@version@" +browse_url = "https://gitlab.gnome.org/GNOME/mutter/" +repository_url = "https://gitlab.gnome.org/GNOME/mutter.git" +website_url = "https://blogs.gnome.org/shell-dev/" +docs_url = "https://docs.gtk.org/" +authors = "Mutter Development Team" +license = "GPL-2.0-or-later" +description = "Mutter Toolkit Private Library" +dependencies = [ "GObject-2.0" ] +devhelp = true +search_index = true + + [dependencies."GObject-2.0"] + name = "GObject" + description = "The base type system library" + docs_url = "https://docs.gtk.org/gobject/" + +[theme] +name = "basic" +show_index_summary = true +show_class_hierarchy = true + +[source-location] +base_url = "https://gitlab.gnome.org/GNOME/mutter/-/blob/@vcs_tag@/" + +[extra] +# The same order will be used when generating the index +content_files = [ +] +content_images = [ +] +urlmap_file = "urlmap.js" + diff --git a/doc/reference/mtk/urlmap.js b/doc/reference/mtk/urlmap.js new file mode 100644 index 000000000..82261e3ca --- /dev/null +++ b/doc/reference/mtk/urlmap.js @@ -0,0 +1,7 @@ +// SPDX-FileCopyrightText: 2021 GNOME Foundation +// SPDX-License-Identifier: LGPL-2.1-or-later + +// A map between namespaces and base URLs for their online documentation +baseURLs = [ + [ 'GObject', 'https://docs.gtk.org/gobject/' ], +] diff --git a/meson.build b/meson.build index 1d7040fc0..3516a92e1 100644 --- a/meson.build +++ b/meson.build @@ -659,6 +659,7 @@ config_h = configure_file( top_includepath = include_directories('.') +subdir('mtk') subdir('cogl') subdir('clutter') subdir('data') diff --git a/mtk/meson.build b/mtk/meson.build new file mode 100644 index 000000000..2a978a2ba --- /dev/null +++ b/mtk/meson.build @@ -0,0 +1,39 @@ +mtk_includesubdir = pkgname / 'mtk' +mtk_includedir = includedir / mtk_includesubdir + +mtk_includepath = include_directories('.', 'mtk') +mtk_includes = [mtk_includepath] + +mtk_c_args = [ + '-DMTK_SYSCONFDIR="@0@"'.format(prefix / sysconfdir), + '-DMTK_COMPILATION=1', + '-DG_LOG_DOMAIN="Mtk"', +] + +mtk_debug_c_args = [] +if get_option('debug') + mtk_debug_c_args += [ + '-fno-omit-frame-pointer' + ] +elif buildtype != 'plain' + mtk_debug_c_args += [ + '-DG_DISABLE_ASSERT', + '-DG_DISABLE_CAST_CHECKS', + ] +endif +supported_mtk_debug_c_args = cc.get_supported_arguments(mtk_debug_c_args) +mtk_c_args += mtk_debug_c_args + +mtk_pkg_deps = [ + cairo_gobject_dep, + glib_dep, + gobject_dep, + gio_dep, +] + +mtk_deps = [ + mtk_pkg_deps, + m_dep +] + +subdir('mtk') diff --git a/mtk/mtk/meson.build b/mtk/mtk/meson.build new file mode 100644 index 000000000..2de4d2c34 --- /dev/null +++ b/mtk/mtk/meson.build @@ -0,0 +1,81 @@ +mtk_mtk_includesubdir = mtk_includesubdir / 'mtk' + +mtk_headers = [ + 'mtk.h', + 'mtk-macros.h', +] + +mtk_sources = [ +] + +mtk_private_headers = [ +] + + +libmutter_mtk_name = 'mutter-mtk-' + libmutter_api_version +libmutter_mtk = shared_library(libmutter_mtk_name, + sources: [ + mtk_sources, + mtk_headers, + mtk_private_headers, + ], + version: '0.0.0', + soversion: 0, + c_args: mtk_c_args, + include_directories: mtk_includes, + dependencies: [mtk_deps], + gnu_symbol_visibility: 'hidden', + install_rpath: pkglibdir, + install_dir: pkglibdir, + install: true, +) +libmutter_mtk_dep = declare_dependency( + link_with: libmutter_mtk, + dependencies: mtk_deps, +) + +if have_introspection + mtk_introspection_args = introspection_args + [ + '-DMTK_SYSCONFDIR="@0@"'.format(prefix / sysconfdir), + '-DMTK_COMPILATION=1', + '-DCOGL_DISABLE_DEPRECATION_WARNINGS', + '-DG_LOG_DOMAIN="Mtk"' + ] + + libmutter_mtk_gir = gnome.generate_gir(libmutter_mtk, + sources: [ + mtk_sources, + mtk_headers, + ], + nsversion: libmutter_api_version, + namespace: 'Mtk', + export_packages: [libmutter_mtk_name], + includes: [ + 'GObject-2.0', + 'cairo-1.0', + ], + extra_args: mtk_introspection_args + ['--c-include=mtk/mtk.h'], + install_dir_gir: pkglibdir, + install_dir_typelib: pkglibdir, + install: true, + ) + +endif + +install_headers(mtk_headers, + subdir: mtk_mtk_includesubdir) + + +pkg.generate(libmutter_mtk, + name: 'Mutter Toolkit', + filebase: libmutter_mtk_name, + description: 'Mutter Toolkit Private Library', + libraries: [m_dep], + subdirs: pkgname / 'mtk', + requires: [mtk_pkg_deps], + version: meson.project_version(), + variables: [ + 'apiversion=' + libmutter_api_version, + ], + install_dir: pcdir, +) diff --git a/mtk/mtk/mtk-macros.h b/mtk/mtk/mtk-macros.h new file mode 100644 index 000000000..d147fdeaa --- /dev/null +++ b/mtk/mtk/mtk-macros.h @@ -0,0 +1,33 @@ +/* + * Mtk + * + * A low-level base library. + * + * Copyright (C) 2023 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#pragma once + +#if !defined(__MTK_H_INSIDE__) && !defined(MTK_COMPILATION) +#error "Only can be included directly." +#endif + +#define MTK_EXPORT __attribute__((visibility ("default"))) extern + +/* MTK_EXPORT_TEST should be used to export symbols that are exported only + * for testability purposes + */ +#define MTK_EXPORT_TEST MTK_EXPORT diff --git a/mtk/mtk/mtk.h b/mtk/mtk/mtk.h new file mode 100644 index 000000000..31a9de196 --- /dev/null +++ b/mtk/mtk/mtk.h @@ -0,0 +1,28 @@ +/* + * Mtk + * + * A low-level base library. + * + * Copyright (C) 2023 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#pragma once + +#define __MTK_H_INSIDE__ + +#include "mtk/mtk-macros.h" + +#undef __MTK_H_INSIDE__ diff --git a/src/tests/meson.build b/src/tests/meson.build index 7e97119df..61fc02129 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -86,6 +86,7 @@ if have_introspection 'GDesktopEnums-3.0', 'xlib-2.0', 'xfixes-4.0', + libmutter_mtk_gir[0], libmutter_cogl_gir[0], libmutter_cogl_pango_gir[0], libmutter_clutter_gir[0],