gst-full: Register GIO modules when glib-networking is a subproject
authorXavier Claessens <xavier.claessens@collabora.com>
Thu, 23 Jun 2022 15:50:00 +0000 (11:50 -0400)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 14 Sep 2022 20:46:20 +0000 (20:46 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2653>

meson.build
scripts/generate_init_static_plugins.py

index 69f7d9b..1da3ac6 100644 (file)
@@ -205,10 +205,14 @@ foreach sp : subprojects
 endforeach
 
 # Check if we need to also build glib-networking for TLS modules
+giomodules = []
 glib_dep = dependency('glib-2.0')
 if glib_dep.type_name() == 'internal'
-  subproject('glib-networking', required : get_option('tls'),
+  subp = subproject('glib-networking', required : get_option('tls'),
              default_options: ['gnutls=auto', 'openssl=auto'])
+  if subp.found()
+    giomodules += subp.get_variable('giomodules', [])
+  endif
 endif
 
 gst_plugins_doc_dep = custom_target('plugins-doc-cache',
@@ -322,7 +326,8 @@ if building_full
                '-e ' + get_option('gst-full-elements'),
                '-t ' + get_option('gst-full-typefind-functions'),
                '-d ' + get_option('gst-full-device-providers'),
-               '-T ' + get_option('gst-full-dynamic-types')
+               '-T ' + get_option('gst-full-dynamic-types'),
+               '--giomodules', ';'.join(giomodules),
                ]
   )
 
@@ -385,12 +390,17 @@ if building_full
     endif
   endif
 
+  giomodules_deps = []
+  foreach module : giomodules
+    giomodules_deps += dependency(module)
+  endforeach
+
   # Build both shared and static library
   gstfull = both_libraries('gstreamer-full-1.0',
     init_static_plugins_c,
     link_args: gstfull_link_args,
     link_whole : exposed_libs,
-    dependencies : [incdir_deps, glib_deps, all_plugins],
+    dependencies : [incdir_deps, glib_deps, all_plugins, giomodules_deps],
     link_depends : link_deps,
     install : true,
   )
index 11e7af5..6b86ea4 100755 (executable)
@@ -12,6 +12,7 @@ $typefind_funcs_declaration
 $device_providers_declaration
 $dynamic_types_declaration
 $plugins_declaration
+$giomodules_declaration
 
 void
 gst_init_static_plugins (void)
@@ -23,6 +24,7 @@ gst_init_static_plugins (void)
     $device_providers_registration
     $dynamic_types_registration
     $plugins_registration
+    $giomodules_registration
 
     g_once_init_leave (&initialization_value, 1);
   }
@@ -69,6 +71,8 @@ if __name__ == "__main__":
                         dest="deviceproviders", help="The list of plugin:deviceproviders")
     parser.add_argument('-T', '--dynamic-types', nargs='?', default='',
                         dest="dynamictypes", help="The list of plugin:dynamictypes")
+    parser.add_argument('--giomodules', nargs='?', default='',
+                        dest="giomodules", help="The list of GIO modules")
     options = parser.parse_args()
     if options.output is None:
         output_file = 'gstinitstaticplugins.c'
@@ -85,6 +89,8 @@ if __name__ == "__main__":
     dynamic_types_registration = []
     plugins_declaration = []
     plugins_registration = []
+    giomodules_declaration = []
+    giomodules_registration = []
 
     if ',' in options.plugins or ':' in options.plugins:
         print("Only ';' is allowed in the list of plugins.")
@@ -116,6 +122,13 @@ if __name__ == "__main__":
         plugins_registration += ['GST_PLUGIN_STATIC_REGISTER(%s);' % (plugin_name)]
         plugins_declaration += ['GST_PLUGIN_STATIC_DECLARE(%s);' % (plugin_name)]
 
+    giomodules = options.giomodules.split(';') if options.giomodules else []
+    for module_name in giomodules:
+        if module_name.startswith('gio'):
+            module_name = module_name[3:]
+        giomodules_declaration.append(f'extern void g_io_{module_name}_load (gpointer data);')
+        giomodules_registration.append(f'g_io_{module_name}_load (NULL);')
+
     with open(output_file.strip(), "w") as f:
         static_elements_plugin = ''
         f.write(TEMPLATE.substitute({
@@ -129,4 +142,6 @@ if __name__ == "__main__":
             'dynamic_types_registration': '\n    '.join(dynamic_types_registration),
             'plugins_declaration': '\n'.join(plugins_declaration),
             'plugins_registration': '\n    '.join(plugins_registration),
+            'giomodules_declaration': '\n'.join(giomodules_declaration),
+            'giomodules_registration': '\n    '.join(giomodules_registration),
         }))