summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Schoonjans <Tom.Schoonjans@diamond.ac.uk>2019-09-10 08:54:11 +0100
committerChristian Hergert <chergert@redhat.com>2019-10-28 10:11:42 -0700
commitd1248f5548524bae66ed3a67ad0a19f20fd56956 (patch)
tree61caf43f5879aea024c7cf169d002f1f5a26dafb
parent9c8e1f45def9c187a28eaea185ba60c5ed070429 (diff)
downloadlibpeas-d1248f5548524bae66ed3a67ad0a19f20fd56956.tar.gz
build: fix compilation on macOS
-rw-r--r--libpeas-gtk/meson.build1
-rw-r--r--libpeas-gtk/peas-gtk-plugin-manager.c4
-rw-r--r--libpeas/meson.build17
-rw-r--r--libpeas/peas-dirs.c93
-rw-r--r--libpeas/peas-utils-osx.h41
-rw-r--r--libpeas/peas-utils-osx.m121
-rw-r--r--meson.build6
7 files changed, 191 insertions, 92 deletions
diff --git a/libpeas-gtk/meson.build b/libpeas-gtk/meson.build
index 00def42..8fa0856 100644
--- a/libpeas-gtk/meson.build
+++ b/libpeas-gtk/meson.build
@@ -56,6 +56,7 @@ libpeas_gtk_sha = library(
package_gtk_string.strip('lib'),
libpeas_gtk_c,
version: lib_version,
+ darwin_versions: lib_version_osx,
include_directories: rootdir,
dependencies: libpeas_gtk_deps,
c_args: libpeas_gtk_c_args,
diff --git a/libpeas-gtk/peas-gtk-plugin-manager.c b/libpeas-gtk/peas-gtk-plugin-manager.c
index 2198a4f..5835c0f 100644
--- a/libpeas-gtk/peas-gtk-plugin-manager.c
+++ b/libpeas-gtk/peas-gtk-plugin-manager.c
@@ -30,7 +30,7 @@
#include <girepository.h>
#ifdef OS_OSX
-#import <Cocoa/Cocoa.h>
+#include "peas-utils-osx.h"
#endif
#include <libpeas/peas-engine.h>
@@ -190,7 +190,7 @@ help_button_cb (GtkWidget *button,
help_uri = peas_plugin_info_get_help_uri (info);
#ifdef OS_OSX
- [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[NSString stringWithUTF8String:help_uri]]];
+ peas_open_url_osx (help_uri);
#else
gtk_show_uri_on_window (get_toplevel (button), help_uri, GDK_CURRENT_TIME, &error);
diff --git a/libpeas/meson.build b/libpeas/meson.build
index d1f712c..2e1f2c2 100644
--- a/libpeas/meson.build
+++ b/libpeas/meson.build
@@ -46,6 +46,14 @@ libpeas_sources = files(
'peas-utils.c',
)
+if build_machine.system() == 'darwin'
+ libpeas_sources += [
+ 'peas-utils-osx.m',
+ 'peas-utils-osx.h',
+ ]
+endif
+
+
libpeas_deps = [
glib_dep,
gobject_dep,
@@ -64,6 +72,13 @@ libpeas_c_args = [
libpeas_link_args = [
]
+if build_machine.system() == 'darwin'
+ libpeas_link_args += [
+ '-Wl,-framework', '-Wl,Foundation',
+ '-Wl,-framework', '-Wl,AppKit',
+ ]
+endif
+
libpeas_marshal = gnome.genmarshal(
'peas-marshal',
sources: 'peas-marshal.list',
@@ -89,9 +104,11 @@ libpeas_sha = library(
package_string.strip('lib'),
libpeas_sources,
version: lib_version,
+ darwin_versions: lib_version_osx,
include_directories: [rootdir, libpeas_srcdir],
dependencies: libpeas_deps,
c_args: libpeas_c_args + hidden_visibility_args,
+ objc_args: libpeas_c_args,
link_args: libpeas_link_args,
install: true,
install_dir: libdir,
diff --git a/libpeas/peas-dirs.c b/libpeas/peas-dirs.c
index 77a202c..eca5611 100644
--- a/libpeas/peas-dirs.c
+++ b/libpeas/peas-dirs.c
@@ -26,92 +26,7 @@
#include "peas-dirs.h"
#ifdef OS_OSX
-
-#import <Cocoa/Cocoa.h>
-
-static gchar *
-dirs_os_x_get_bundle_resource_dir (void)
-{
- NSAutoreleasePool *pool;
- gchar *str = NULL;
- NSString *path;
-
- pool = [[NSAutoreleasePool alloc] init];
-
- if ([[NSBundle mainBundle] bundleIdentifier] == nil)
- {
- [pool release];
- return NULL;
- }
-
- path = [[NSBundle mainBundle] resourcePath];
-
- if (!path)
- {
- [pool release];
- return NULL;
- }
-
- str = g_strdup ([path UTF8String]);
- [pool release];
- return str;
-}
-
-static gchar *
-dirs_os_x_get_resource_dir (const gchar *subdir,
- const gchar *default_dir)
-{
- gchar *res_dir;
- gchar *ret;
-
- res_dir = dirs_os_x_get_bundle_resource_dir ();
-
- if (res_dir == NULL)
- {
- ret = g_build_filename (default_dir, "libpeas-1.0", NULL);
- }
- else
- {
- ret = g_build_filename (res_dir, subdir, "libpeas-1.0", NULL);
- g_free (res_dir);
- }
-
- return ret;
-}
-
-static gchar *
-dirs_os_x_get_data_dir (void)
-{
- return dirs_os_x_get_resource_dir ("share", DATADIR);
-}
-
-static gchar *
-dirs_os_x_get_lib_dir (void)
-{
- return dirs_os_x_get_resource_dir ("lib", LIBDIR);
-}
-
-static gchar *
-dirs_os_x_get_locale_dir (void)
-{
- gchar *res_dir;
- gchar *ret;
-
- res_dir = dirs_os_x_get_bundle_resource_dir ();
-
- if (res_dir == NULL)
- {
- ret = g_build_filename (DATADIR, "locale", NULL);
- }
- else
- {
- ret = g_build_filename (res_dir, "share", "locale", NULL);
- g_free (res_dir);
- }
-
- return ret;
-}
-
+#include "peas-utils-osx.h"
#endif
gchar *
@@ -127,7 +42,7 @@ peas_dirs_get_data_dir (void)
data_dir = g_build_filename (win32_dir, "share", "libpeas-1.0", NULL);
g_free (win32_dir);
#elif defined (OS_OSX)
- data_dir = dirs_os_x_get_data_dir ();
+ data_dir = peas_dirs_os_x_get_data_dir ();
#else
data_dir = g_build_filename (DATADIR, "libpeas-1.0", NULL);
#endif
@@ -148,7 +63,7 @@ peas_dirs_get_lib_dir (void)
lib_dir = g_build_filename (win32_dir, "lib", "libpeas-1.0", NULL);
g_free (win32_dir);
#elif defined (OS_OSX)
- lib_dir = dirs_os_x_get_lib_dir ();
+ lib_dir = peas_dirs_os_x_get_lib_dir ();
#else
lib_dir = g_build_filename (LIBDIR, "libpeas-1.0", NULL);
#endif
@@ -189,7 +104,7 @@ peas_dirs_get_locale_dir (void)
g_free (win32_dir);
#elif defined (OS_OSX)
- locale_dir = dirs_os_x_get_locale_dir ();
+ locale_dir = peas_dirs_os_x_get_locale_dir ();
#else
locale_dir = g_build_filename (DATADIR, "locale", NULL);
#endif
diff --git a/libpeas/peas-utils-osx.h b/libpeas/peas-utils-osx.h
new file mode 100644
index 0000000..bef2ce2
--- /dev/null
+++ b/libpeas/peas-utils-osx.h
@@ -0,0 +1,41 @@
+/*
+ * peas-utils-osx.h
+ * This file is part of libpeas
+ *
+ * Copyright (C) 2008 Ignacio Casal Quinteiro
+ *
+ * libpeas 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.1 of the License, or (at your option) any later version.
+ *
+ * libpeas 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Author: Tom Schoonjans <Tom.Schoonjans@gmail.com>
+ */
+#ifndef __PEAS_UTILS_OSX_H__
+#define __PEAS_UTILS_OSX_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gchar *peas_dirs_os_x_get_bundle_resource_dir (void);
+gchar *peas_dirs_os_x_get_resource_dir (const gchar *subdir,
+ const gchar *default_dir);
+gchar *peas_dirs_os_x_get_data_dir (void);
+gchar *peas_dirs_os_x_get_lib_dir (void);
+gchar *peas_dirs_os_x_get_locale_dir (void);
+void peas_open_url_osx (const gchar *uri);
+
+G_END_DECLS
+
+#endif /* __PEAS_UTILS_OSX_H__ */
+
diff --git a/libpeas/peas-utils-osx.m b/libpeas/peas-utils-osx.m
new file mode 100644
index 0000000..3b7b11b
--- /dev/null
+++ b/libpeas/peas-utils-osx.m
@@ -0,0 +1,121 @@
+/*
+ * peas-utils-osx.m
+ * This file is part of libpeas
+ *
+ * Copyright (C) 2008 Ignacio Casal Quinteiro
+ *
+ * libpeas 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.1 of the License, or (at your option) any later version.
+ *
+ * libpeas 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Author: Tom Schoonjans <Tom.Schoonjans@gmail.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "peas-utils-osx.h"
+
+#import <Foundation/Foundation.h>
+
+#import <AppKit/AppKit.h>
+
+void
+peas_open_url_osx (const gchar *uri)
+{
+ [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[NSString stringWithUTF8String:uri]]];
+}
+
+gchar *
+peas_dirs_os_x_get_bundle_resource_dir (void)
+{
+ NSAutoreleasePool *pool;
+ gchar *str = NULL;
+ NSString *path;
+
+ pool = [[NSAutoreleasePool alloc] init];
+
+ if ([[NSBundle mainBundle] bundleIdentifier] == nil)
+ {
+ [pool release];
+ return NULL;
+ }
+
+ path = [[NSBundle mainBundle] resourcePath];
+
+ if (!path)
+ {
+ [pool release];
+ return NULL;
+ }
+
+ str = g_strdup ([path UTF8String]);
+ [pool release];
+ return str;
+}
+
+gchar *
+peas_dirs_os_x_get_resource_dir (const gchar *subdir,
+ const gchar *default_dir)
+{
+ gchar *res_dir;
+ gchar *ret;
+
+ res_dir = peas_dirs_os_x_get_bundle_resource_dir ();
+
+ if (res_dir == NULL)
+ {
+ ret = g_build_filename (default_dir, "libpeas-1.0", NULL);
+ }
+ else
+ {
+ ret = g_build_filename (res_dir, subdir, "libpeas-1.0", NULL);
+ g_free (res_dir);
+ }
+
+ return ret;
+}
+
+gchar *
+peas_dirs_os_x_get_data_dir (void)
+{
+ return peas_dirs_os_x_get_resource_dir ("share", DATADIR);
+}
+
+gchar *
+peas_dirs_os_x_get_lib_dir (void)
+{
+ return peas_dirs_os_x_get_resource_dir ("lib", LIBDIR);
+}
+
+gchar *
+peas_dirs_os_x_get_locale_dir (void)
+{
+ gchar *res_dir;
+ gchar *ret;
+
+ res_dir = peas_dirs_os_x_get_bundle_resource_dir ();
+
+ if (res_dir == NULL)
+ {
+ ret = g_build_filename (DATADIR, "locale", NULL);
+ }
+ else
+ {
+ ret = g_build_filename (res_dir, "share", "locale", NULL);
+ g_free (res_dir);
+ }
+
+ return ret;
+}
diff --git a/meson.build b/meson.build
index 5a88c0a..56813ab 100644
--- a/meson.build
+++ b/meson.build
@@ -39,6 +39,9 @@ lib_version = '@0@.@1@.@2@'.format(
lib_version_revision
)
+osx_current = lib_version_current + 1
+lib_version_osx = [osx_current, '@0@.@1@'.format(osx_current, interface_age)]
+
package_name = meson.project_name()
package_string = '@0@-@1@'.format(package_name, api_version)
package_long_string = '@0@-@1@'.format(package_name, version)
@@ -131,7 +134,8 @@ add_project_arguments([
], language: 'c')
if build_machine.system() == 'darwin'
- config_h.set_quoted('OS_OSX', 1)
+ config_h.set('OS_OSX', 1)
+ add_languages('objc')
endif
# Detect and set symbol visibility