Commit d1248f55 authored by Tom Schoonjans's avatar Tom Schoonjans Committed by Christian Hergert

build: fix compilation on macOS

parent 9c8e1f45
......@@ -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,
......
......@@ -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);
......
......@@ -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,
......
......@@ -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
......
/*
* 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__ */
/*
* 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;
}
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment