[gtk/wip/chergert/quartz4u] build: stub out macOS backend



commit 5ff8f3b1a928cebbba5cf942c1ca14104c6db033
Author: Christian Hergert <chergert redhat com>
Date:   Thu Apr 23 16:36:46 2020 -0700

    build: stub out macOS backend

 gdk/macos/gdkdisplay-macos.c | 54 ++++++++++++++++++++++++++++++++++++++++++++
 gdk/macos/gdkmacos.h         |  0
 gdk/macos/gdkmacosdisplay.h  |  0
 gdk/macos/meson.build        | 41 +++++++++++++++++++++++++++++++++
 gdk/meson.build              |  3 ++-
 meson.build                  |  8 +++++--
 meson_options.txt            |  2 ++
 7 files changed, 105 insertions(+), 3 deletions(-)
---
diff --git a/gdk/macos/gdkdisplay-macos.c b/gdk/macos/gdkdisplay-macos.c
new file mode 100644
index 0000000000..d9792523cc
--- /dev/null
+++ b/gdk/macos/gdkdisplay-macos.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright © 2020 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gdk/gdk-private.h"
+
+/**
+ * SECTION:macos_interaction
+ * @Short_description: macOS backend-specific functions
+ * @Title: macOS Interaction
+ * @Include: gdk/macos/gdkmacos.h
+ *
+ * The functions in this section are specific to the GDK macOS backend.
+ * To use them, you need to include the `<gdk/macos/gdkmacos.h>` header and
+ * use the macOS-specific pkg-config `gtk4-macos` file to build your
+ * application.
+ *
+ * To make your code compile with other GDK backends, guard backend-specific
+ * calls by an ifdef as follows. Since GDK may be built with multiple
+ * backends, you should also check for the backend that is in use (e.g. by
+ * using the GDK_IS_MACOS_DISPLAY() macro).
+ * |[<!-- language="C" -->
+ * #ifdef GDK_WINDOWING_MACOS
+ *   if (GDK_IS_MACOS_DISPLAY (display))
+ *     {
+ *       // make macOS-specific calls here
+ *     }
+ *   else
+ * #endif
+ * #ifdef GDK_WINDOWING_X11
+ *   if (GDK_IS_X11_DISPLAY (display))
+ *     {
+ *       // make X11-specific calls here
+ *     }
+ *   else
+ * #endif
+ *   g_error ("Unsupported GDK backend");
+ * ]|
+ */
diff --git a/gdk/macos/gdkmacos.h b/gdk/macos/gdkmacos.h
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdk/macos/gdkmacosdisplay.h b/gdk/macos/gdkmacosdisplay.h
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/gdk/macos/meson.build b/gdk/macos/meson.build
new file mode 100644
index 0000000000..af1ccf000e
--- /dev/null
+++ b/gdk/macos/meson.build
@@ -0,0 +1,41 @@
+gdk_macos_sources = files([
+  # 'gdkapplaunchcontext-macos.c',
+  # 'gdkcairocontext-macos.c',
+  # 'gdkclipboard-macos.c',
+  # 'gdkcursor-macos.c',
+  # 'gdkdevice-macos.c',
+  'gdkdisplay-macos.c',
+  # 'gdkdrag-macos.c',
+  # 'gdkdrop-macos.c',
+  # 'gdkeventsource.c',
+  # 'gdkglcontext-macos.c',
+  # 'gdkkeys-macos.c',
+  # 'gdkmonitor-macos.c',
+  # 'gdkprimary-macos.c',
+  # 'gdksurface-macos.c',
+])
+
+gdk_macos_public_headers = files([
+  # 'gdkmacosdevice.h',
+  'gdkmacosdisplay.h',
+  # 'gdkmacosglcontext.h',
+  # 'gdkmacosmonitor.h',
+  # 'gdkmacossurface.h'
+])
+
+install_headers(gdk_macos_public_headers, 'gdkmacos.h', subdir: 'gtk-4.0/gdk/macos/')
+
+gdk_macos_deps = [
+]
+
+libgdk_macos = static_library('gdk-macos',
+                                gdk_macos_sources, gdkconfig, gdkenum_h,
+                                include_directories: [ confinc, gdkinc, ],
+                                c_args: [
+                                  '-DGTK_COMPILATION',
+                                  '-DG_LOG_DOMAIN="Gdk"',
+                                  '-xobjective-c',
+                                ] + common_cflags,
+                                link_args: common_ldflags,
+                                link_with: [],
+                                dependencies: [ gdk_deps, gdk_macos_deps])
diff --git a/gdk/meson.build b/gdk/meson.build
index ac14c3b6fe..5835c0fbbf 100644
--- a/gdk/meson.build
+++ b/gdk/meson.build
@@ -143,6 +143,7 @@ gdkconfig_cdata.set('GDK_WINDOWING_X11', x11_enabled)
 gdkconfig_cdata.set('GDK_WINDOWING_WAYLAND', wayland_enabled)
 gdkconfig_cdata.set('GDK_WINDOWING_WIN32', win32_enabled)
 gdkconfig_cdata.set('GDK_WINDOWING_BROADWAY', broadway_enabled)
+gdkconfig_cdata.set('GDK_WINDOWING_MACOS', macos_enabled)
 gdkconfig_cdata.set('GDK_RENDERING_VULKAN', have_vulkan)
 
 gdkconfig = configure_file(
@@ -218,7 +219,7 @@ endif
 
 gdk_backends = []
 gdk_backends_gen_headers = []  # non-public generated headers
-foreach backend : ['broadway', 'quartz', 'wayland', 'win32', 'x11']
+foreach backend : ['broadway', 'quartz', 'wayland', 'win32', 'x11', 'macos']
   if get_variable('@0@_enabled'.format(backend))
     subdir(backend)
     gdk_deps += get_variable('gdk_@0@_deps'.format(backend))
diff --git a/meson.build b/meson.build
index 12388f743a..c5c431a17a 100644
--- a/meson.build
+++ b/meson.build
@@ -93,6 +93,7 @@ gtk_api_version = '4.0'
 x11_enabled      = get_option('x11-backend')
 wayland_enabled  = get_option('wayland-backend')
 broadway_enabled = get_option('broadway-backend')
+macos_enabled    = get_option('macos-backend')
 quartz_enabled   = get_option('quartz-backend')
 win32_enabled    = get_option('win32-backend')
 
@@ -242,6 +243,8 @@ if cc.get_id() == 'msvc'
 elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
   test_cflags = [
     '-fno-strict-aliasing',
+    '-Wno-c++11-extensions',
+    '-Wno-missing-include-dirs',
     '-Wno-typedef-redefinition',
     '-Wcast-align',
     '-Wduplicated-branches',
@@ -368,7 +371,8 @@ pangocairo_dep = dependency('pangocairo', version: cairo_req,
 pixbuf_dep     = dependency('gdk-pixbuf-2.0', version: gdk_pixbuf_req,
                             fallback : ['gdk-pixbuf', 'gdkpixbuf_dep'])
 epoxy_dep      = dependency('epoxy', version: epoxy_req,
-                            fallback: ['libepoxy', 'libepoxy_dep'])
+                            fallback: ['libepoxy', 'libepoxy_dep'],
+                            static: false)
 atk_dep        = dependency('atk', version: atk_req)
 harfbuzz_dep   = dependency('harfbuzz', version: '>= 0.9', required: false)
 xkbdep         = dependency('xkbcommon', version: xkbcommon_req, required: wayland_enabled)
@@ -775,7 +779,7 @@ pkg_install_dir = join_paths(get_option('libdir'), 'pkgconfig')
 pkgs = [ 'gtk4.pc' ]
 
 pkg_targets = ''
-foreach backend: [ 'broadway', 'quartz', 'wayland', 'win32', 'x11', ]
+foreach backend: [ 'broadway', 'quartz', 'macos', 'wayland', 'win32', 'x11', ]
   if get_variable('@0@_enabled'.format(backend))
     pkgs += ['gtk4-@0@.pc'.format(backend)]
     pkg_targets += ' ' + backend
diff --git a/meson_options.txt b/meson_options.txt
index 73f26da7da..61c8930ab3 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -9,6 +9,8 @@ option('win32-backend', type: 'boolean', value: true,
   description : 'Enable the Windows gdk backend (only when building on Windows)')
 option('quartz-backend', type: 'boolean', value: true,
   description : 'Enable the macOS gdk backend (only when building on macOS)')
+option('macos-backend', type: 'boolean', value: true,
+  description : 'Enable the macOS gdk backend (only when building on macOS)')
 
 # Media backends
 option('media', type: 'string', value: 'gstreamer',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]