Commit 7b1f7bad authored by dogmaphobic's avatar dogmaphobic

Fix GStreamer relocation for Mac OS release (installer) builds.

parent 50ab2ed9
...@@ -65,7 +65,15 @@ LinuxBuild { ...@@ -65,7 +65,15 @@ LinuxBuild {
CONFIG += qt \ CONFIG += qt \
thread \ thread \
c++11 \ c++11 \
contains(DEFINES, ENABLE_VERBOSE_OUTPUT) {
message("Enable verbose compiler output (manual override from command line)")
} else:exists(user_config.pri):infile(user_config.pri, DEFINES, ENABLE_VERBOSE_OUTPUT) {
message("Enable verbose compiler output (manual override from user_config.pri)")
} else {
CONFIG += \
silent silent
}
QT += \ QT += \
concurrent \ concurrent \
......
...@@ -69,41 +69,35 @@ static void qgcputenv(const QString& key, const QString& root, const QString& pa ...@@ -69,41 +69,35 @@ static void qgcputenv(const QString& key, const QString& root, const QString& pa
void initializeVideoStreaming(int &argc, char* argv[]) void initializeVideoStreaming(int &argc, char* argv[])
{ {
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING)
// Initialize GStreamer #ifdef __macos__
GError* error = NULL; #ifdef QGC_INSTALL_RELEASE
if (!gst_init_check(&argc, &argv, &error)) { QString currentDir = QCoreApplication::applicationDirPath();
qCritical() << "gst_init_check() failed: " << error->message; qgcputenv("GST_PLUGIN_SCANNER", currentDir, "/../Frameworks/GStreamer.framework/Versions/1.0/libexec/gstreamer-1.0/gst-plugin-scanner");
g_error_free(error); qgcputenv("GTK_PATH", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current");
} qgcputenv("GIO_EXTRA_MODULES", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gio/modules");
// Our own plugin qgcputenv("GST_PLUGIN_SYSTEM_PATH_1_0", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gstreamer-1.0");
GST_PLUGIN_STATIC_REGISTER(QGC_VIDEOSINK_PLUGIN); qgcputenv("GST_PLUGIN_SYSTEM_PATH", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gstreamer-1.0");
// The static plugins we use qgcputenv("GST_PLUGIN_PATH_1_0", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gstreamer-1.0");
#if defined(__mobile__) qgcputenv("GST_PLUGIN_PATH", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gstreamer-1.0");
GST_PLUGIN_STATIC_REGISTER(coreelements); #endif
GST_PLUGIN_STATIC_REGISTER(libav); #endif
GST_PLUGIN_STATIC_REGISTER(rtp); // Initialize GStreamer
GST_PLUGIN_STATIC_REGISTER(udp); GError* error = NULL;
GST_PLUGIN_STATIC_REGISTER(videoparsersbad); if (!gst_init_check(&argc, &argv, &error)) {
GST_PLUGIN_STATIC_REGISTER(x264); qCritical() << "gst_init_check() failed: " << error->message;
#endif g_error_free(error);
}
#ifdef __macos__ // Our own plugin
#ifdef QGC_INSTALL_RELEASE GST_PLUGIN_STATIC_REGISTER(QGC_VIDEOSINK_PLUGIN);
QString currentDir = QCoreApplication::applicationDirPath(); // The static plugins we use
qgcputenv("GST_PLUGIN_SCANNER", currentDir, "/gst-plugin-scanner"); #if defined(__mobile__)
qgcputenv("GTK_PATH", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current"); GST_PLUGIN_STATIC_REGISTER(coreelements);
qgcputenv("GIO_EXTRA_MODULES", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gio/modules"); GST_PLUGIN_STATIC_REGISTER(libav);
qgcputenv("GST_PLUGIN_SYSTEM_PATH_1_0", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gstreamer-1.0"); GST_PLUGIN_STATIC_REGISTER(rtp);
qgcputenv("GST_PLUGIN_SYSTEM_PATH", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gstreamer-1.0"); GST_PLUGIN_STATIC_REGISTER(udp);
qgcputenv("GST_PLUGIN_PATH_1_0", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gstreamer-1.0"); GST_PLUGIN_STATIC_REGISTER(videoparsersbad);
qgcputenv("GST_PLUGIN_PATH", currentDir, "/../Frameworks/GStreamer.framework/Versions/Current/lib/gstreamer-1.0"); GST_PLUGIN_STATIC_REGISTER(x264);
// QStringList env = QProcessEnvironment::systemEnvironment().keys(); #endif
// foreach(const QString &key, env) {
// qDebug() << key << QProcessEnvironment::systemEnvironment().value(key);
// }
#endif
#endif
#else #else
Q_UNUSED(argc); Q_UNUSED(argc);
Q_UNUSED(argv); Q_UNUSED(argv);
......
...@@ -26,7 +26,7 @@ OTOOL_CMD = 'otool' ...@@ -26,7 +26,7 @@ OTOOL_CMD = 'otool'
def shell_call(cmd, cmd_dir='.', fail=True): def shell_call(cmd, cmd_dir='.', fail=True):
print "call", cmd #print("call", cmd)
try: try:
ret = subprocess.check_call( ret = subprocess.check_call(
cmd, cwd=cmd_dir, cmd, cwd=cmd_dir,
...@@ -40,7 +40,7 @@ def shell_call(cmd, cmd_dir='.', fail=True): ...@@ -40,7 +40,7 @@ def shell_call(cmd, cmd_dir='.', fail=True):
def shell_check_call(cmd): def shell_check_call(cmd):
print "ccall", cmd #print("ccall", cmd)
try: try:
process = subprocess.Popen( process = subprocess.Popen(
cmd, stdout=subprocess.PIPE) cmd, stdout=subprocess.PIPE)
...@@ -54,6 +54,7 @@ class OSXRelocator(object): ...@@ -54,6 +54,7 @@ class OSXRelocator(object):
''' '''
Wrapper for OS X's install_name_tool and otool commands to help Wrapper for OS X's install_name_tool and otool commands to help
relocating shared libraries. relocating shared libraries.
It parses lib/ /libexec and bin/ directories, changes the prefix path of It parses lib/ /libexec and bin/ directories, changes the prefix path of
the shared libraries that an object file uses and changes it's library the shared libraries that an object file uses and changes it's library
ID if the file is a shared library. ID if the file is a shared library.
...@@ -61,19 +62,19 @@ class OSXRelocator(object): ...@@ -61,19 +62,19 @@ class OSXRelocator(object):
def __init__(self, root, lib_prefix, new_lib_prefix, recursive): def __init__(self, root, lib_prefix, new_lib_prefix, recursive):
self.root = root self.root = root
self.lib_prefix = self._fix_path(lib_prefix) self.lib_prefix = self._fix_path(lib_prefix).encode('utf-8')
self.new_lib_prefix = self._fix_path(new_lib_prefix) self.new_lib_prefix = self._fix_path(new_lib_prefix).encode('utf-8')
self.recursive = recursive self.recursive = recursive
def relocate(self): def relocate(self):
self.parse_dir(self.root, filters=['', '.dylib', '.so', '0']) self.parse_dir(self.root, filters=['', '.dylib', '.so'])
def relocate_file(self, object_file, id=None): def relocate_file(self, object_file, id=None):
self.change_libs_path(object_file) self.change_libs_path(object_file)
self.change_id(object_file, id) self.change_id(object_file, id)
def change_id(self, object_file, id=None): def change_id(self, object_file, id=None):
id = id or object_file.replace(self.lib_prefix, self.new_lib_prefix) id = id or object_file.replace(self.lib_prefix.decode('utf-8'), self.new_lib_prefix.decode('utf-8'))
filename = os.path.basename(object_file) filename = os.path.basename(object_file)
if not (filename.endswith('so') or filename.endswith('dylib')): if not (filename.endswith('so') or filename.endswith('dylib')):
return return
...@@ -105,13 +106,13 @@ class OSXRelocator(object): ...@@ -105,13 +106,13 @@ class OSXRelocator(object):
@staticmethod @staticmethod
def list_shared_libraries(object_file): def list_shared_libraries(object_file):
cmd = [OTOOL_CMD, "-L", object_file] cmd = [OTOOL_CMD, "-L", object_file]
res = shell_check_call(cmd).split('\n') res = shell_check_call(cmd).split(b'\n')
# We don't use the first line # We don't use the first line
libs = res[1:] libs = res[1:]
# Remove the first character tabulation # Remove the first character tabulation
libs = [x[1:] for x in libs] libs = [x[1:] for x in libs]
# Remove the version info # Remove the version info
libs = [x.split(' ', 1)[0] for x in libs] libs = [x.split(b' ', 1)[0] for x in libs]
return libs return libs
@staticmethod @staticmethod
...@@ -157,4 +158,3 @@ def main(): ...@@ -157,4 +158,3 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
main() main()
...@@ -26,6 +26,9 @@ GST_ROOT=/Library/Frameworks/GStreamer.framework ...@@ -26,6 +26,9 @@ GST_ROOT=/Library/Frameworks/GStreamer.framework
GST_BASE=$GST_ROOT/Versions/$GST_VER GST_BASE=$GST_ROOT/Versions/$GST_VER
RELOC=$(dirname $0)/osxrelocator.py RELOC=$(dirname $0)/osxrelocator.py
OLDDLPATH=/Library/Frameworks/GStreamer.framework/
NEWDLPATH=@executable_path/../Frameworks/GStreamer.framework/
echo "GST Installer" echo "GST Installer"
[ "$#" -eq 3 ] || die "3 arguments required, $# provided" [ "$#" -eq 3 ] || die "3 arguments required, $# provided"
[ -d "$2" ] || die "Could not find $2" [ -d "$2" ] || die "Could not find $2"
...@@ -46,6 +49,8 @@ process_framework() { ...@@ -46,6 +49,8 @@ process_framework() {
rsync -a --delete "$GST_ROOT" "$FMWORK_TARGET" || die "Error copying $GST_ROOT to $FMWORK_TARGET" rsync -a --delete "$GST_ROOT" "$FMWORK_TARGET" || die "Error copying $GST_ROOT to $FMWORK_TARGET"
#-- Prune unused stuff #-- Prune unused stuff
rm -rf $GST_TARGET/bin rm -rf $GST_TARGET/bin
rm -rf $GST_TARGET/etc
rm -rf $GST_TARGET/share
rm -rf $GST_TARGET/Headers rm -rf $GST_TARGET/Headers
rm -rf $GST_TARGET/include rm -rf $GST_TARGET/include
rm -rf $GST_TARGET/lib/*.a rm -rf $GST_TARGET/lib/*.a
...@@ -57,32 +62,9 @@ process_framework() { ...@@ -57,32 +62,9 @@ process_framework() {
rm -rf $GST_TARGET/lib/libffi-3.0.13 rm -rf $GST_TARGET/lib/libffi-3.0.13
rm -rf $GST_TARGET/lib/pkgconfig rm -rf $GST_TARGET/lib/pkgconfig
rm $GST_TARGET/Commands rm $GST_TARGET/Commands
#-- Some dylibs are dupes instead of symlinks.
#-- This will do a minimum job in trying to clean those.
#-- Doesn't work. The stupid thing can't load a dlyb symlink.
#for f in $GST_TARGET/lib/*.dylib
#do
# foo=$(basename "$f")
# bar="${foo%.*}"
# for i in `seq 0 9`;
# do
# if [ -e $GST_TARGET/lib/$bar.$i.dylib ]; then
# DUPES="$DUPES
#rm -f $GST_TARGET/lib/$bar.$i.dylib"
# DUPES="$DUPES
#ln -s $f $GST_TARGET/lib/$bar.$i.dylib"
# fi
# done
#done
#IFS=$'\n'
#for c in $DUPES
#do
# eval $c
#done
#-- Now relocate the embeded paths #-- Now relocate the embeded paths
echo "GST Installer: Relocating" echo "GST Installer: Relocating"
python $RELOC -r $GST_TARGET/lib /Library/Frameworks/GStreamer.framework/ @executable_path/../Frameworks/GStreamer.framework/ > /dev/null || die "Error relocating binaries in $GST_TARGET/lib" python $RELOC -r "$GST_TARGET" "$OLDDLPATH" "$NEWDLPATH" > /dev/null || die "Error relocating binaries in $GST_TARGET/lib"
python $RELOC -r $GST_TARGET/libexec /Library/Frameworks/GStreamer.framework/ @executable_path/../Frameworks/GStreamer.framework/ > /dev/null || die "Error relocating binaries in $GST_TARGET/libexec"
} }
#-- Check and see if we've already processed the framework #-- Check and see if we've already processed the framework
...@@ -91,9 +73,12 @@ echo "GST Installer: Checking $GST_TARGET" ...@@ -91,9 +73,12 @@ echo "GST Installer: Checking $GST_TARGET"
#-- Now copy the framework to the app bundle #-- Now copy the framework to the app bundle
echo "GST Installer: Copying $GST_SOURCE to $BUNDLE_TARGET/Contents/Frameworks/" echo "GST Installer: Copying $GST_SOURCE to $BUNDLE_TARGET/Contents/Frameworks/"
rsync -a --delete $GST_SOURCE $BUNDLE_TARGET/Contents/Frameworks/ || die "Error copying framework into app bundle" rsync -a --delete $GST_SOURCE $BUNDLE_TARGET/Contents/Frameworks/ || die "Error copying framework into app bundle"
#-- Move this gst binary to MacOS #-- The plugin scanner needs to find the GStreamer libraries
mv $BUNDLE_TARGET/Contents/Frameworks/GStreamer.framework/Versions/1.0/libexec/gstreamer-1.0/gst-plugin-scanner $BUNDLE_TARGET/Contents/MacOS/ || die "Error moving gst-plugin-scanner" GSTINBUNDLE=$BUNDLE_TARGET/Contents/Frameworks/GStreamer.framework/Versions/$GST_VER
pushd $GSTINBUNDLE/libexec && ln -sf ../../../../../Frameworks . && popd || die "Error creating Frameworks symlink in $GST_TARGET/libexec"
#-- Fix main binary #-- Fix main binary
python $RELOC $QGC_BINARY /Library/Frameworks/GStreamer.framework/ @executable_path/../Frameworks/GStreamer.framework/ > /dev/null || die "Error relocating $QGC_BINARY" install_name_tool -change /Library/Frameworks/GStreamer.framework/Versions/1.0/lib/GStreamer @executable_path/../Frameworks/GStreamer.framework/Versions/1.0/lib/GStreamer "$QGC_BINARY" > /dev/null || die "Error relocating $QGC_BINARY"
pushd $GSTINBUNDLE && install_name_tool -id @executable_path/../Frameworks/GStreamer.framework/Versions/1.0/lib/GStreamer GStreamer && popd || die "Error relocating GStreamer"
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