Переглянути джерело

Fix glib apple framework dependency problem (#817)

Kelvin Zhang 3 роки тому
батько
коміт
66716249c8

+ 79 - 0
packages/g/glib/patches/2.71.0/macosx.patch

@@ -0,0 +1,79 @@
+commit 4e5cf4e3689c49d641c08245100c095c416c4f86
+Author: Kelvin Zhang <[email protected]>
+Date:   Fri Dec 31 09:31:00 2021 -0800
+
+    Use meson dependency to link against apple framework
+    
+    Using ld_flags would work, but that does not propagate ldflags to users
+    of glib. Meson's dependency() call will propagate apple framework
+    dependencies to downstream users.
+
+diff --git a/gio/meson.build b/gio/meson.build
+index 5e879fd3d..a22c822b0 100644
+--- a/gio/meson.build
++++ b/gio/meson.build
+@@ -390,6 +390,8 @@ if host_system != 'windows'
+     settings_sources += files('gnextstepsettingsbackend.m')
+     contenttype_sources += files('gosxcontenttype.m')
+     appinfo_sources += files('gosxappinfo.m')
++    framework_dep = dependency('appleframeworks', modules : ['Foundation', 'CoreFoundation', 'AppKit'])
++    platform_deps += [framework_dep]
+     if glib_have_os_x_9_or_later
+       unix_sources += files('gcocoanotificationbackend.m')
+     endif
+diff --git a/glib/meson.build b/glib/meson.build
+index f78f32969..13750dd83 100644
+--- a/glib/meson.build
++++ b/glib/meson.build
+@@ -310,6 +310,8 @@ glib_sources = files(
+   'gprintf.c',
+ )
+ 
++platform_deps = []
++
+ if host_system == 'windows'
+   glib_win_rc = configure_file(
+     input: 'glib.rc.in',
+@@ -330,6 +332,13 @@ endif
+ 
+ if glib_have_cocoa
+   glib_sources += files('gosxutils.m')
++  framework_dep = dependency('appleframeworks', modules : ['Foundation', 'CoreFoundation', 'AppKit'])
++  platform_deps += [framework_dep]
++endif
++
++if glib_have_carbon
++  framework_dep = dependency('appleframeworks', modules : 'Carbon')
++  platform_deps += [framework_dep]
+ endif
+ 
+ glib_sources += files('gthread-@[email protected]'.format(threads_implementation))
+diff --git a/meson.build b/meson.build
+index 9d1b76c56..f780fa82e 100644
+--- a/meson.build
++++ b/meson.build
+@@ -769,8 +769,6 @@ if host_system == 'darwin'
+ 
+   add_project_arguments(objcc.get_supported_arguments(warning_objc_args), language: 'objc')
+ 
+-  osx_ldflags += ['-Wl,-framework,CoreFoundation']
+-
+   # Mac OS X Carbon support
+   glib_have_carbon = objcc.compiles('''#include <Carbon/Carbon.h>
+                                        #include <CoreServices/CoreServices.h>''',
+@@ -778,7 +776,6 @@ if host_system == 'darwin'
+ 
+   if glib_have_carbon
+     glib_conf.set('HAVE_CARBON', true)
+-    osx_ldflags += '-Wl,-framework,Carbon'
+     glib_have_os_x_9_or_later = objcc.compiles('''#include <AvailabilityMacros.h>
+                                                   #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
+                                                   #error Compiling for minimum OS X version before 10.9
+@@ -795,7 +792,6 @@ if host_system == 'darwin'
+ 
+   if glib_have_cocoa
+     glib_conf.set('HAVE_COCOA', true)
+-    osx_ldflags += ['-Wl,-framework,Foundation', '-Wl,-framework,AppKit']
+   endif
+ 
+   # FIXME: libgio mix C and objC source files and there is no way to reliably

+ 4 - 6
packages/g/glib/xmake.lua

@@ -3,12 +3,10 @@ package("glib")
     set_homepage("https://developer.gnome.org/glib/")
     set_description("Core application library for C.")
 
-    set_urls("https://download.gnome.org/sources/glib/$(version).tar.xz",
-             {version = function (version) return table.concat(table.slice((version):split('%.'), 1, 2), '.') .. "/glib-" .. version end})
-    add_versions("2.60.2", "2ef15475060addfda0443a7e8a52b28a10d5e981e82c083034061daf9a8f80d9")
-    add_versions("2.68.2", "ecc7798a9cc034eabdfd7f246e6dd461cdbf1175fcc2e9867cc7da7b7309e0fb")
-    add_versions("2.69.2", "a62249e35a8635175a697b3215f1df2b89e0fbb4adb520dcbe21a3ae1ebb8882")
-    add_versions("2.70.0", "200d7df811c5ba634afbf109f14bb40ba7fde670e89389885da14e27c0840742")
+    set_urls("https://gitlab.gnome.org/GNOME/glib/-/archive/$(version)/glib-$(version).tar.gz",
+             "https://gitlab.gnome.org/GNOME/glib.git")
+    add_versions("2.71.0", "10cdfa2893b7ccf6a95b25644ec51e2c609274a5af3ad8e743d6dc35434fdf11")
+    add_patches("2.71.0", path.join(os.scriptdir(), "patches", "2.71.0", "macosx.patch"), "a0c928643e40f3a3dfdce52950486c7f5e6f6e9cfbd76b20c7c5b43de51d6399")
 
     if is_plat("windows") then
         add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})