              # Needed for the following binutils bug:
              # https://github.com/mesonbuild/meson/issues/1911
              # However, g-ir-scanner does not understand -Wl,-rpath
-@@ -404,18 +405,24 @@ class GnomeModule(ExtensionModule):
+@@ -615,19 +616,19 @@ class GnomeModule(ExtensionModule):
              link_command.append('--extra-library=' + lib.name)
          else:
              link_command.append('-l' + lib.name)
 -        return link_command
--
--    def _get_dependencies_flags(self, deps, state, depends, include_rpath=False,
--                                use_gir_args=False, separate_nodedup=False):
--        cflags = OrderedSet()
--        internal_ldflags = OrderedSet()
--        external_ldflags = OrderedSet()
 +        return link_command, new_depends
-+
+ 
+-    def _get_dependencies_flags(
 +    def _get_dependencies_flags_raw(
-+            self, deps,
-+            state,
-+            depends,
-+            include_rpath: bool = False,
-+            use_gir_args: bool = False,
-+            ) -> T.Tuple[OrderedSet[str], OrderedSet[T.Union[str, T.Tuple[str, str]]], OrderedSet[T.Union[str, T.Tuple[str, str]]], OrderedSet[str],
-+                         T.List]:
-+        cflags: OrderedSet[str] = OrderedSet()
+             self, deps: T.Sequence[T.Union['Dependency', build.SharedLibrary, build.StaticLibrary]],
+-            state: 'ModuleState', depends: T.List[build.BuildTarget], include_rpath: bool = False,
+-            use_gir_args: bool = False, separate_nodedup: bool = False
+-            ) -> T.Tuple[OrderedSet[str], OrderedSet[str], OrderedSet[str], T.Optional[T.List[str]], OrderedSet[str]]:
++            state: 'ModuleState', depends: T.List[build.BuildTarget], include_rpath: bool,
++            use_gir_args: bool
++            ) -> T.Tuple[OrderedSet[str], OrderedSet[T.Union[str, T.Tuple[str, str]]], OrderedSet[T.Union[str, T.Tuple[str, str]]], T.Optional[T.List[str]], OrderedSet[str],
++                         T.List[T.Union[build.BuildTarget, 'build.GeneratedTypes', 'FileOrString']]]:
+         cflags: OrderedSet[str] = OrderedSet()
+-        internal_ldflags: OrderedSet[str] = OrderedSet()
+-        external_ldflags: OrderedSet[str] = OrderedSet()
          # External linker flags that can't be de-duped reliably because they
 -        # require two args in order, such as -framework AVFoundation
--        external_ldflags_nodedup = []
--        gi_includes = OrderedSet()
+-        external_ldflags_nodedup: T.List[str] = []
 +        # require two args in order, such as -framework AVFoundation will be stored as a tuple.
 +        internal_ldflags: OrderedSet[T.Union[str, T.Tuple[str, str]]] = OrderedSet()
 +        external_ldflags: OrderedSet[T.Union[str, T.Tuple[str, str]]] = OrderedSet()
-+        gi_includes: OrderedSet[str] = OrderedSet()
+         gi_includes: OrderedSet[str] = OrderedSet()
          deps = mesonlib.listify(deps)
-+        depends = list(depends)
  
-         for dep in deps:
-             if isinstance(dep, Dependency):
-@@ -427,21 +434,20 @@ class GnomeModule(ExtensionModule):
+@@ -642,21 +643,20 @@ class GnomeModule(ExtensionModule):
                  cflags.update(state.get_include_args(dep.include_directories))
                  for lib in dep.libraries:
                      if isinstance(lib, build.SharedLibrary):

             external_ldflags = fix_ldflags(external_ldflags)
-        if not separate_nodedup:
-            external_ldflags.update(external_ldflags_nodedup)
-            return cflags, internal_ldflags, external_ldflags, gi_includes
-        else:
-            return cflags, internal_ldflags, external_ldflags, external_ldflags_nodedup, gi_includes
+        return cflags, internal_ldflags, external_ldflags, gi_includes, depends
+
+    def _get_dependencies_flags(
+            self, deps,
+            state,
+            depends,
+            include_rpath: bool = False,
+            use_gir_args: bool = False,
+            ) -> T.Tuple[OrderedSet[str], T.List[str], T.List[str], OrderedSet[str],
+                         T.List]:
+
+        cflags, internal_ldflags_raw, external_ldflags_raw, gi_includes, depends = self._get_dependencies_flags_raw(deps, state, depends, include_rpath, use_gir_args)
+        internal_ldflags: T.List[str] = []

From b8ba462ae72e0818898357464263ec84722f6d4c Mon Sep 17 00:00:00 2001
From: Jan Tojnar <jtojnar@gmail.com>
Date: Sat, 26 Mar 2022 02:26:27 +0100
Subject: [PATCH] gnome: Fix gtkdoc when using multiple Apple frameworks
