GST is made into a static library, while Python2 's GST has multiple libraries referencing GST in a dynamic library
So, think of a way to package the GST required by python2 into a separate shared library
The way to do this is to python2_gst all the. So first into. A
Get all the linked GST functions by nm-g and filtering
Generate a small file of these functions, referencing all of them in a static function
The small file is then compiled into so files and linked to the GST library so that the GST functions required by PYTHON2_GST are all linked in.
At the same time, the way that the GST dynamic plug-in can be added is also registered at startup, so that the package that python2_gst gets is self-contained.
Diff-nur gst-python-0.10.22_test/codegen/gen_gst_import_code.py Gst-python-0.10.22/codegen/gen_gst_import_ code.py---gst-python-0.10.22_test/codegen/gen_gst_import_code.py2015-01-18 22:01:56.753066000 +0800+++ gst-python-0.10.22/codegen/gen_gst_import_code.py1970-01-01 08:00:00.000000000 +0800@@ -1,32 +0,0 @@-import OS, Sys--def Main (argv):-If Len (argv) < 3:-print "need more params." -return-1--Src_file = argv[1]-dest_file = argv[2]-try:-s_handle = open (Src_file, "R")- S_buff = S_handle.readlines ()-s_handle.close ()-except Exception, detail:-print "Exception: {0}". forma T (detail)-return-1-try:-d_handle = open (Dest_file, "w")-for line in s_buff:-D_han Dle.write ("extern void%s (); \ n"% line[:-1])-D_handle.write ("\nstatic void __gst_import_functions () \n{\n")- For line in s_buff:-d_handle.write ("%s (); \ n"% line[:-1])-D_handle.write ("}\n\n")- D_handle.close ()-except Exception, detail:-print "Exception: {0}". Format (detail)-return-1- return 0--if __name__ = = ' __main__ ':-Sys.exit (Main (SYS.ARGV)) Diff-nur Gst-python-0.10.22_test/codegen/gen_imp_co de.sh gst-python-0.10.22/codegen/gen_imp_code.sh---gst-python-0.10.22_test/codegen/gen_imp_code.sh2015-01-19 03:03:07.211836824 +0800+++ gst-python-0.10.22/codegen/gen_imp_code.sh1970-01-01 08:00:00.000000000 +0800@@ -1,4 + 0,0 @@-#!/bin/sh--nm-g $ | grep "U" | awk "{print \$2}" | grep "^gst_"-diff-nur gst-python-0.10.22_test/gst/gst_static_plugin_reg.c gst-python-0.10.22/gst/gst_static_ PLUGIN_REG.C---gst-python-0.10.22_test/gst/gst_static_plugin_reg.c2015-01-18 23:20:09.490976826 +0800+++ gst-python-0.10.22/gst/gst_static_plugin_reg.c1970-01-01 08:00:00.000000000 +0800@@ -1,4 +0,0 @@--void init_register _static_gst_plugin ()-{-}diff-nur gst-python-0.10.22_test/gst/makefile.am gst-python-0.10.22/gst/makefile.am--- Gst-python-0.10.22_test/gst/makefile.am2015-01-19 03:51:50.722665473 +0800+++ gst-python-0.10.22/gst/makefile.am2011-10-20 20:31:28.000000000 +0800@@ -53,9 +53,9 @@ # GStreamer Bindings _gst_la_cflags = $ (common_cflags)-_gst_la_libadd = $ (Commo N_libadd) +_gst_la_libadd = $ (common_libadd) $ (gst_base_libs) _gst_la_ldflags = $ (common_ldflags)- Export-symbols-regex "^ (init_gst|_pygobject_api|pygstminiobject_). *"--lgst_pack+$ (gst_base_libs) $ (GST_ Controller_libs) $ (gst_net_libs) $ (gst_dp_libs) _gst_la_sources = gst-argtypes.c gstmodule.c @@ -90,9 +90,9 @@ -90,9 GStrea MER interfaces Bindings Interfaces_la_cflags = $ (common_cflags) $ (gst_plugins_base_cflags)-interfaces_la_libadd = $ ( Common_libadd) #-lgstinterfaces-$ (gst_majorminor) +interfaces_la_libadd = $ (common_libadd)-lgstinterfaces-$ (GST_ Majorminor) Interfaces_la_ldflags = $ (common_ldflags)--export-symbols-regex "^ (INITINTERFACE|_PYGOBJECT_API). *"- Lgst_pack+-export-symbols-regex "^ (INITINTERFACE|_PYGOBJECT_API). *" $ (gst_plugins_base_libs) Interfaces_la_SOURCES = interfacesmodule.c Nodist_interfaces_la_sources = interfaces.c Interfaces_overrides = interfaces.override xoverlay.override@@ -103,9 +103,9 @@ # GStreamer pbutils Bindings pbutils_la_cflags = $ (common_cflags) $ (gst_plugins_base _cflags)-pbutils_la_libadd = $ (common_libadd)-lgst_pack+pbutils_la_libadd = $ (common_libadd) $ (GST_PLUGINS_BASE_ LIBS)-lgstpbutils-0.10 pbutils_la_ldflags = $ (common_ldflags)--export-symbols-regex "^ (INITPBUTILS|_PYGOBJECT_API) . * "-lgst_pack+-export-symbols-regex" ^ (INITPBUTILS|_PYGOBJECT_API). * "$ (gst_plugins_base_libs) Pbutils_la_SOURCES = pbutilsmodule.c gst-argtypes.c nodist_pbutils_la_sources = pbutils.c Pbutils_overrides = pbutils.override@@ -127,9 + 127,9 @@ audio_lib = audio.la Pygstexec_ltlibraries + = $ (audio_lib) Audio_la_cflags = $ (common_cflags) $ (GST_PLUGINS_BA se_cflags)-Audio_la_libadd = $ (common_libadd) #$ (gst_plugins_base_libs)-lgstaudio-0.10+ Audio_la_LIBADD = $ (common_ Libadd) $ (gst_plugins_base_libs)-lgstaudio-0.10 audio_la_ldflags = $ (common_ldflags)--export-symbols-regex "^ (INITAUDIO|_PYGOBJECT_API). *"-lgst_pack #$ (gst_plugins_base_libs) +- Export-symbols-regex "^ (INITAUDIO|_PYGOBJECT_API). *" $ (gst_plugins_base_libs) audio_la_sources = audiomodule.c GST-ARGTYPES.C nodist_audio_la_sources = audio.c audio.c: $ (audio_defs) $ (audio_overrides) $ (GEN_FILES) @@ -149,9 +149,9 @@ Video_lib = video.la pygstexec_ltlibraries + $ (video_lib) Video_la_cflags = $ (common_cflags) $ (GST_PLUGINS_BASE_CFL AGS)-Video_la_libadd = $ (common_libadd) #$ (gst_plugins_base_libs)-lgstvideo-0.10+ Video_la_libadd = $ (common_libadd) $ (gst_plugins_base_libs)-lgstvideo-0.10 video_la_ldflags = $ (common_ldflags)--export-symbols-regex "^ (initvideo|_ PYGOBJECT_API). * "-lgst_pack # $ (gst_plugins_base_libs) +-export-symbols-regex" ^ (INITVIDEO|_PYGOBJECT_API). * "$ (GST _plugins_base_libs) video_la_sources = videomodule.c gst-argtypes.c nodist_video_la_sources = video.c video.c: $ (VIDEO_ DEFS) $ (video_overrides) $ (gen_files) @@-171,105 +171,15 @@ Tag_lib = tag.la Pygstexec_ltlibraries + = $ (tag_lib) Tag_la_cflags = $ (common_cflags) $ (gst_plugins_base_cflags)-Tag_ La_libadd = $ (common_libadd) # $ (gst_plugins_base_libs)-lgsttag-0.10+ Tag_la_libadd = $ (common_libadd) $ (GST_PLUGINS_ base_libs)-lgsttag-0.10 tag_la_ldflags = $ (common_ldflags)--export-symbols-regex "^ (INITTAG|_PYGOBJECT_API). *"- Lgst_pack #$ (gst_plugins_base_libs) +-export-symbols-regex "^ (INITTAG|_PYGOBJECT_API). *" $ (GST_PLUGINS_BASE_LIBS) tag_la_sources = tagmodule.c gst-argtypes.c nodist_tag_la_sources = tag.c tag.c: $ (tag_defs) $ (TAG_OVERRIDES) $ (GEN_FILE S) Endif-libgst_pack_lib = libgst_pack.la-pygstexec_ltlibraries + = $ (libgst_pack_lib)-libgst_pack_la_sources = Gst_ Static_plugin_reg.c--libgst_pack_la_cflags = $ (common_cflags)-fpic-libgst_pack_la_libadd = $ (common_libadd) $ (GST_ Base_libs)-libgst_pack_la_ldflags =-shared-fpic $ (gst_base_libs) $ (gst_controller_libs) $ (GST_NET_LIBS) $ (GST_DP_ LIBS)-nodist_libgst_pack_la_sources = lib_gst.c-cleanfiles + =Lib_gst.c-noinst_libraries = Lib_gst.a-lib_gst_a_cflags = $ (_gst_la_cflags)-lib_gst_a_sources = $ (_gst_la_SOURCES) $ ( nodist__gst_la_sources)-_gst_la_dependencies = $ (libgst_pack_lib)-lib_gst.c:lib_gst.a---if HAVE_PYGOBJECT_2_16- Libgst_pack_la_ldflags + = $ (gst_libs) $ (gst_option_libs)-nodist_libgst_pack_la_sources + = Libgstoption.c-CLEANFILES + = Libgstoption.c-noinst_libraries + = Libgstoption.a-libgstoption_a_cflags = $ (common_cflags)-libgstoption_a_ SOURCES =.. /GSTOPTIONMODULE.C-LIBGSTOPTION.C:LIBGSTOPTION.A---endif--libgst_pack_la_ldflags + + $ (GST_PLUGINS_BASE_LIBS)- lgstinterfaces-$ (gst_majorminor)-nodist_libgst_pack_la_sources + = Libinterfaces.c-cleanfiles + = Libinterfaces.c-noinst_libraries + = Libinterfaces.a-libinterfaces_a_cflags = $ (interfaces_la_cflags)-libinterfaces _a_sources = $ (interfaces_la_sources) $ (nodist_interfaces_la_sources)-interfaces_la_dependencies = $ (libgst_pack_ LIB)-libinterfaces.c:libinterfaces.a---libgst_pack_la_ldflags + =-lgstpbutils-0.10-nodist_libgst_Pack_la_sources + = libpbutils.c-cleanfiles + libpbutils.c-noinst_libraries + libpbutils.a-libpbutils_a_cflags = $ ( Pbutils_la_cflags)-libpbutils_a_sources = $ (pbutils_la_sources) $ (nodist_pbutils_la_sources)-pbutils_la_ DEPENDENCIES = $ (libgst_pack_lib)-LIBPBUTILS.C:LIBPBUTILS.A---if have_gst_audio-libgst_pack_la_ldflags + =- Lgstaudio-0.10-nodist_libgst_pack_la_sources + = Libaudio.c-cleanfiles + libaudio.c-noinst_libraries + = libaudio.a- Libaudio_a_cflags = $ (audio_la_cflags)-libaudio_a_sources=$ (audio_la_sources) $ (nodist_audio_la_sources)-Audio_la _dependencies = $ (libgst_pack_lib)-libaudio.c:libaudio.a---endif--if have_gst_video-libgst_pack_la_ldflags + =- Lgstvideo-0.10-nodist_libgst_pack_la_sources + = Libvideo.c-cleanfiles + libvideo.c-noinst_libraries + = libvideo.a- Libvideo_a_cflags = $ (video_la_cflags)-libvideo_a_sources=$ (video_la_sources) $ (nodist_video_la_sources)-Video_la _dependencies = $ (libgst_pack_lib)-libvideo.c:libvideo.a---endif--if have_gst_tag-libgsT_pack_la_ldflags + =-lgsttag-0.10-nodist_libgst_pack_la_sources + libtag.c-cleanfiles + = Libtag.c-noinst_libraries + = Libtag.a-libtag_a_cflags = $ (tag_la_cflags)-libtag_a_sources = $ (tag_la_sources) $ (nodist_tag_la_sources)-Tag_la_ DEPENDENCIES = $ (libgst_pack_lib)-libtag.c:libtag.a--endif--. a.c:-/bin/sh $ (top_srcdir)/codegen/gen_imp_code.sh $ < > $<.imp-&& $ (PYTHON) $ (top_srcdir)/codegen/gen_gst_import_code.py $<.imp [email protected]-&& rm-f $<.imp. DEFS.C: $ (Am_v_gen) ($ (PYTHON) $ (top_srcdir)/codegen/codegen.py Diff-nur gst-pyt hon-0.10.22_test/gst/makefile_static.am gst-python-0.10.22/gst/makefile_static.am---gst-python-0.10.22_test/gst /makefile_static.am2015-01-19 04:20:32.000000000 +0800+++ gst-python-0.10.22/gst/makefile_static.am1970-01-01 08:00:00.000000000 +0800@@ -1,92 +0,0 @@--libgst_pack_lib = libgst_pack.la-pygstexec_ltlibraries + + $ (libgst_pack_lib) -libgst_pack_la_sources = Gst_static_plugin_reg.c--libgst_pack_la_cflags = $ (cOmmon_cflags)-fpic-libgst_pack_la_libadd = $ (common_libadd) $ (gst_base_libs)-libgst_pack_la_ldflags =-shared-fpic $ (gst_base_libs) $ (gst_controller_libs) $ (gst_net_libs) $ (gst_dp_libs)-nodist_libgst_pack_la_sources = lib_ Gst.c-cleanfiles + = Lib_gst.c-noinst_libraries = Lib_gst.a-lib_gst_a_cflags = $ (_gst_la_cflags)-lib_gst_a_SOURCES = $ ( _gst_la_sources) $ (nodist__gst_la_sources)-_gst_la_dependencies = $ (libgst_pack_lib)-lib_gst.c:lib_gst.a---if have _pygobject_2_16-libgst_pack_la_ldflags + = $ (gst_libs) $ (gst_option_libs)-nodist_libgst_pack_la_sources + = Libgstoption.c-cleanfiles + = libgstoption.c-noinst_libraries + = Libgstoption.a-libgstoption_a_cflags = $ (common_ cflags)-libgstoption_a_sources =.. /GSTOPTIONMODULE.C-LIBGSTOPTION.C:LIBGSTOPTION.A---endif--libgst_pack_la_ldflags + + $ (GST_PLUGINS_BASE_LIBS)- lgstinterfaces-$ (gst_majorminor)-nodist_libgst_pack_la_sources + = Libinterfaces.c-cleanfiles + = Libinterfaces.c-noinst_libraries + = Libinterfaces.a-libinterfaces_a_cflags = $ (intErfaces_la_cflags)-libinterfaces_a_sources = $ (interfaces_la_sources) $ (nodist_interfaces_la_sources)-interfaces_ La_dependencies = $ (libgst_pack_lib)-LIBINTERFACES.C:LIBINTERFACES.A---libgst_pack_la_ldflags + =- Lgstpbutils-0.10-nodist_libgst_pack_la_sources + = Libpbutils.c-cleanfiles + libpbutils.c-noinst_libraries + = Libpbutils.a-libpbutils_a_cflags = $ (pbutils_la_cflags)-libpbutils_a_sources = $ (pbutils_la_sources) $ (nodist_ pbutils_la_sources)-pbutils_la_dependencies = $ (libgst_pack_lib)-LIBPBUTILS.C:LIBPBUTILS.A---if HAVE_GST_AUDIO- Libgst_pack_la_ldflags + =-lgstaudio-0.10-nodist_libgst_pack_la_sources + libaudio.c-cleanfiles + = libaudio.c- Noinst_libraries + = Libaudio.a-libaudio_a_cflags = $ (audio_la_cflags)-libaudio_a_sources=$ (Audio_la_SOURCES) $ ( nodist_audio_la_sources)-audio_la_dependencies = $ (libgst_pack_lib)-libaudio.c:libaudio.a---endif--if HAVE_GST_ Video-libgst_pack_la_ldflags + =-lgstvideo-0.10-nodist_libgst_pack_la_sources + libvideo.c-cleanfiles + = LIBVIdeo.c-noinst_libraries + = Libvideo.a-libvideo_a_cflags = $ (video_la_cflags)-libvideo_a_sources=$ (Video_la_SOURCES ) $ (nodist_video_la_sources)-video_la_dependencies = $ (libgst_pack_lib)-libvideo.c:libvideo.a---endif--if HAVE_GST _tag-libgst_pack_la_ldflags + =-lgsttag-0.10-nodist_libgst_pack_la_sources + libtag.c-cleanfiles + = Libtag.c-noinst _libraries + = Libtag.a-libtag_a_cflags = $ (tag_la_cflags)-libtag_a_sources = $ (tag_la_sources) $ (nodist_tag_la_ SOURCES)-tag_la_dependencies = $ (libgst_pack_lib)-libtag.c:libtag.a--endif--. a.c:-/bin/sh $ (top_srcdir)/codegen/ gen_imp_code.sh $< > $<.imp-&& $ (PYTHON) $ (top_srcdir)/codegen/gen_gst_import_code.py $<.imp [ email protected]-&& rm-f $<.imp-diff-nur gst-python-0.10.22_test/makefile.am gst-python-0.10.22/ makefile.am---gst-python-0.10.22_test/makefile.am2015-01-19 04:53:18.269354984 +0800+++ gst-python-0.10.22/ makefile.am2010-11-20 02:44:51.000000000 +0800@@ -1,8 +1,8 @@ subdirs = Common codegEn GST Examples Plugin testsuite pkgconfig common_cflags = $ (python_includes) $ (pygobject_cflags) $ (gst_cflags) $ (gst_opt ion_cflags)-fno-strict-aliasing-common_libadd =-common_ldflags =-module-avoid-version-wl,--rpath,. -l./gst/.libs/-lgst_pack+common_libadd = $ (gst_libs) $ (gst_option_libs) +common_ldflags =-module-avoid-version # Include before extra_dist for Win32 assignment include $ (top_srcdir)/common/win32.mak@@ -22,10 +22,6 @@-export-symbols-r Egex "^ (INITGSTOPTION|_PYGOBJECT_API). *" gstoption_la_sources = gstoptionmodule.c-if have_pygobject_2_16-gstoption_ La_dependencies = Gst/libgst_pack.la-endif-extra_dist = gstlibtoolimporter.py pygst.py.in Diff-nur gst-python-0.10.22 _test/win32/common/config.h gst-python-0.10.22/win32/common/config.h---gst-python-0.10.22_test/win32/common/ config.h1970-01-01 08:00:00.000000000 +0800+++ gst-python-0.10.22/win32/common/config.h2011-10-30 00:06:10.000000000 +0800@@ -0,0 +1,88 @@+/* config.h.in. Generated from Configure.ac by AutohEader. */++/* Defined If Gcov is enabled to force a rebuild due to config.h changing */+ #undef gst_gcov_enabled++/* Define to 1 I f you have the <dlfcn.h> header file. */+ #undef have_dlfcn_h++/* Define to 1 if you have the <inttypes.h> header file. */+ #undef have_inttypes_h++/* Define to 1 if you have the <memory.h> header file. */+ #undef have_memory_h++/* We can use the Plugins-install methods */+ #define Have_plugins_install 1++/* Defined if We hav E a 2.12 series Pygobject */+ #undef have_pygobject_2_12++/* Defined If we have a 2.16 series Pygobject */+ #undef Have_pygo bject_2_16++/* Define to 1 if you have the <stdint.h> header file. */+ #undef have_stdint_h++/* Define to 1 if you have the <stdlib.h> header file. */+ #undef have_stdlib_h++/* Define to 1 if you have the <strings.h> header file. */+ #undef have_strings_h++/* Define to 1 if you have the <string.h> header file. */+ #undef have_string_h++/* Define to 1 if you have the <sys/stat.h> Header file. */+ #undef have_sys_stat_h++/* Define to 1 if you have the <sys/types.h> header file. */+ #undef have_sys_types_h++/* Define to 1 if you have the <unistd.h> header file. */+ #undef have_unistd_h++/* Define If Valgrind should be used */+ #undef have_valgrind++/* We can use the Videoorientation Interface */+ #define HAVE_VIDEO_ORIENTATION_INTERFACE 1++/* define to 1 if your C compiler doesn ' t accept-c and-o togeth Er. */+ #undef no_minus_c_minus_o++/* Name of the package */+ #define PACKAGE "Gst-python" ++/* define to the address where bug Repor TS for the package should is sent. */+ #define Package_bugreport "Http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer" ++/* define to the full name of this package. */+ #define PACKAGE_NAME "GStreamer Python Bindings" ++/* define to the full NAME and version of the This package. */+ #define Package_string "GStreamer Python Bindings 0.10.22" ++/* define to the one symbol short name of the the The. */+ #define PACKAGE_TARNAME "Gst-python"++/* Define to the version of the the". */+ #define Package_version "0.10.22" ++/* pygst major VERSION */+ #define Pygst_major_version 0++/* pygst Micro VERSION */+# Define Pygst_micro_version 22++/* pygst minor version */+ #define Pygst_minor_version 10++/* pygst nano VERSION */+ #define Pygst_nano_version 0++/* Define to 1 if you have the ANSI C header files. */+ #undef stdc_headers++/* version number of package */+ #define VERSION "0.10.22"
python2-gst0.10 making patches for static packages