Files
Sourcetrail/setup/MacOSX/bundle_install.sh.in
T
Eberhard Graether 9fc71f9d7f build: fixed MacOS bundle to include all libraries and frameworks
Follwed instructions for Qt from: http://qt-project.org/doc/qt-4.8/deployment-mac.html

fortune cookie message = Smile! A smile will make you younger.
2015-02-05 11:48:39 +01:00

121 lines
4.8 KiB
Bash
Executable File

#!/bin/bash
ABORT="\033[31mAbort:\033[00m"
SUCCESS="\033[32mSuccess:\033[00m"
INFO="\033[33mInfo:\033[00m"
MY_PATH=`dirname "$0"`
cd $MY_PATH
echo -e $INFO "Creating app bundle for MacOSX."
BUNDLE_NAME="@MACOSX_BUNDLE_NAME@"
APP_NAME="@MACOSX_BINARY_NAME@"
DYNLIB_PATHS=(@MACOSX_DYNAMIC_LIBRARIES@)
QT_DIR="@MACOSX_QT_DIR@"
QT_FRAMEWORK_PATHS=(@MACOSX_QT_FRAMEWORKS@)
if [ ! -x "$APP_NAME" ]
then
echo -e $ABORT "Executable $APP_NAME does not exist."
exit 1
fi
if [ ! -e "bundle_info.plist" ]
then
echo -e $ABORT "bundle_info.plist does not exist."
exit 1
fi
BUNDLE_PATH=$BUNDLE_NAME.app
BIN_DIR=$BUNDLE_PATH/Contents/MacOS
DYNLIB_DIR=$BUNDLE_PATH/Contents/lib
PLUGIN_DIR=$BUNDLE_PATH/Contents/PlugIns/platforms
FRAMEWORK_DIR=$BUNDLE_PATH/Contents/Frameworks
RES_DIR=$BUNDLE_PATH/Contents/Resources
APP_PATH=$BIN_DIR/$APP_NAME
if [ -d "$BUNDLE_PATH" ]
then
echo -e $INFO "Removing old bundle."
rm -rf $BUNDLE_PATH
fi
echo -e $INFO "Creating bundle folders."
mkdir -p $BIN_DIR
mkdir -p $DYNLIB_DIR
mkdir -p $PLUGIN_DIR
mkdir -p $FRAMEWORK_DIR
mkdir -p $RES_DIR
echo -e $INFO "Copying bundle contents."
cp $APP_NAME $APP_PATH
cp bundle_info.plist $BUNDLE_PATH/Contents/Info.plist
cp -R ../data $RES_DIR/data
echo -e $INFO "Copying dynamic libraries."
for LIB_PATH in ${DYNLIB_PATHS[@]}
do
LIB_NAME=$(basename $LIB_PATH)
cp $LIB_PATH $DYNLIB_DIR/$LIB_NAME
install_name_tool -change $LIB_NAME @executable_path/../lib/$LIB_NAME $APP_PATH
install_name_tool -change @rpath/$LIB_NAME @executable_path/../lib/$LIB_NAME $APP_PATH
echo "lib" $LIB_PATH $LIB_NAME
done
echo -e $INFO "Fixing lib dependencies"
install_name_tool -change libboost_system.dylib @executable_path/../lib/libboost_system.dylib $DYNLIB_DIR/libboost_filesystem.dylib
otool -L $DYNLIB_DIR/libboost_filesystem.dylib
echo -e $INFO "Copying Plugins"
cp $QT_DIR/plugins/platforms/libqcocoa.dylib $PLUGIN_DIR/libqcocoa.dylib
echo -e $INFO "Copying frameworks."
for FRAMEWORK_BIN_PATH in ${QT_FRAMEWORK_PATHS[@]}
do
FRAMEWORK_PATH=$(echo $FRAMEWORK_BIN_PATH | grep -o "\S*.framework")
FRAMEWORK_NAME=$(echo $FRAMEWORK_BIN_PATH | grep -o "\w*.framework")
cp -R $FRAMEWORK_PATH $FRAMEWORK_DIR/$FRAMEWORK_NAME
FRAMEWORK_SUB_PATH=$(echo $FRAMEWORK_BIN_PATH | grep -o "\w*.framework\S*")
install_name_tool -id @executable_path/../Frameworks/$FRAMEWORK_SUB_PATH $FRAMEWORK_DIR/$FRAMEWORK_SUB_PATH
install_name_tool -change $FRAMEWORK_BIN_PATH @executable_path/../Frameworks/$FRAMEWORK_SUB_PATH $APP_PATH
echo "framework" $FRAMEWORK_BIN_PATH $FRAMEWORK_PATH
done
# http://qt-project.org/doc/qt-4.8/deployment-mac.html
echo -e $INFO "Fixing framework dependencies"
install_name_tool -change $QT_DIR/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore $FRAMEWORK_DIR/QtGui.framework/Versions/5/QtGui
install_name_tool -change $QT_DIR/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore $FRAMEWORK_DIR/QtWidgets.framework/Versions/5/QtWidgets
install_name_tool -change $QT_DIR/lib/QtGui.framework/Versions/5/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui $FRAMEWORK_DIR/QtWidgets.framework/Versions/5/QtWidgets
install_name_tool -change $QT_DIR/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore $FRAMEWORK_DIR/QtPrintSupport.framework/Versions/5/QtPrintSupport
install_name_tool -change $QT_DIR/lib/QtGui.framework/Versions/5/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui $FRAMEWORK_DIR/QtPrintSupport.framework/Versions/5/QtPrintSupport
install_name_tool -change $QT_DIR/lib/QtWidgets.framework/Versions/5/QtWidgets @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets $FRAMEWORK_DIR/QtPrintSupport.framework/Versions/5/QtPrintSupport
install_name_tool -change $QT_DIR/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore $PLUGIN_DIR/libqcocoa.dylib
install_name_tool -change $QT_DIR/lib/QtGui.framework/Versions/5/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui $PLUGIN_DIR/libqcocoa.dylib
install_name_tool -change $QT_DIR/lib/QtWidgets.framework/Versions/5/QtWidgets @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets $PLUGIN_DIR/libqcocoa.dylib
install_name_tool -change $QT_DIR/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport @executable_path/../Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport $PLUGIN_DIR/libqcocoa.dylib
otool -L $FRAMEWORK_DIR/QtCore.framework/Versions/5/QtCore
otool -L $FRAMEWORK_DIR/QtGui.framework/Versions/5/QtGui
otool -L $FRAMEWORK_DIR/QtWidgets.framework/Versions/5/QtWidgets
otool -L $FRAMEWORK_DIR/QtPrintSupport.framework/Versions/5/QtPrintSupport
otool -L $PLUGIN_DIR/libqcocoa.dylib
echo -e $INFO "App dependencies"
otool -L $APP_PATH
echo -e $SUCCESS "Installed bundle successfully!"