-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish renaming app to SIUE Fat Segmentation Tool
Rename MacDeployScript to MacDeployScript.sh Ignore MacDeployScript.sh from Git. Add sample MacDeployScript with indicators like this <INSERT-HERE> to change for custom path.
- Loading branch information
1 parent
565a14f
commit 672951b
Showing
2 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
#!/bin/bash | ||
|
||
# Location of libraries to import into app bundle | ||
LIB_DIR=/usr/local/lib | ||
|
||
# Application name | ||
APP_NAME="SIUE Fat Segmentation Tool" | ||
|
||
# Version | ||
VERSION=v1.0.2.0 | ||
|
||
# Release type (Debug|Release) | ||
RELEASE=Debug | ||
|
||
# Name for DMG | ||
DMG_NAME=$APP_NAME-$VERSION-$RELEASE-OSX_x64 | ||
|
||
# Location of the application bundle to include libraries | ||
APP_DIR=<PATH-TO-APP-REMOVE-DEBUG/RELEASE-PREFIX>-$RELEASE/$APP_NAME.app | ||
|
||
# Location of DMG directory that contains contents of what the DMG will have in it | ||
DMG_DIR=$APP_DIR/../dmg_folder | ||
|
||
# Location of the actual application binary inside app bundle | ||
APP_BIN=Contents/MacOS/$APP_NAME | ||
|
||
# Location of macdeployqt file | ||
MACDEPLOYQT=<PATH-TO-MACDEPLOYQT>/macdeployqt | ||
|
||
# List of third-party libraries that will be imported to the App bundle | ||
# Do NOT include Qt libraries or system libraries because Qt libraries are handled by macdeployqt and system libraries do not need to be imported | ||
# | ||
# Run otool -L /path/to/app/Contents/MacOS/app to get a list of dependencies for program. Exclude any Qt file or files beginning with /System/* or /usr/lib/* | ||
# The remaining libraries beginning with @rpath or /usr/local/lib will likely need to be imported | ||
# | ||
# For each library, run otool -L LIB_NAME on that library to get a list of dependencies for THAT library. Note which libraries require which dependencies because that | ||
# needs to be changed. Include all of the libraries dependencies in the LIBS list too. (Only if it is new and not already included in list). | ||
# This is recursive. So for each new library, you MUST run otool on it to get dependencies for THAT library then. | ||
LIBS=( | ||
"libnifticdf.2.dylib" | ||
"libniftiio.2.dylib" | ||
"libopencv_core.3.2.dylib" | ||
"libopencv_imgproc.3.2.dylib" | ||
"libopencv_highgui.3.2.dylib" | ||
"libopencv_video.3.2.dylib" | ||
"libznz.2.dylib" | ||
"libopencv_videoio.3.2.dylib" | ||
"libopencv_imgcodecs.3.2.dylib" | ||
) | ||
|
||
# When replacing the old path name to the new one, use these directory prefixes. Should NOT need to be changed. This changes any directories beginning with @rpath or $LIB_DIR | ||
OLD_PATH_DIRS=($LIB_DIR "@rpath") | ||
|
||
# Contains a multidimensional array of dependencies between libraries. First value indicates the dependency and the second value is the library that contains the dependency. | ||
# | ||
# As specified above in LIBS documentation, run otool -L LIB_NAME for each library and note the dependencies. If any third-party dependencies are present, include them below | ||
# so they are changed upon running of script. | ||
DEPS=( | ||
"libznz.2.dylib" "libniftiio.2.dylib" | ||
|
||
"libopencv_imgproc.3.2.dylib" "libopencv_imgproc.3.2.dylib" | ||
|
||
"libopencv_videoio.3.2.dylib" "libopencv_highgui.3.2.dylib" | ||
"libopencv_imgcodecs.3.2.dylib" "libopencv_highgui.3.2.dylib" | ||
"libopencv_imgproc.3.2.dylib" "libopencv_highgui.3.2.dylib" | ||
"libopencv_core.3.2.dylib" "libopencv_highgui.3.2.dylib" | ||
|
||
"libopencv_imgproc.3.2.dylib" "libopencv_video.3.2.dylib" | ||
"libopencv_core.3.2.dylib" "libopencv_video.3.2.dylib" | ||
|
||
"libopencv_imgcodecs.3.2.dylib" "libopencv_videoio.3.2.dylib" | ||
"libopencv_imgproc.3.2.dylib" "libopencv_videoio.3.2.dylib" | ||
"libopencv_core.3.2.dylib" "libopencv_videoio.3.2.dylib" | ||
|
||
"libopencv_imgproc.3.2.dylib" "libopencv_imgcodecs.3.2.dylib" | ||
"libopencv_core.3.2.dylib" "libopencv_imgcodecs.3.2.dylib" | ||
) | ||
|
||
# Run macdeployqt to fix Qt library dependencies | ||
$MACDEPLOYQT "$APP_DIR" | ||
|
||
# Loop through each library and copy the library to Frameworks dir in app bundle, add ID using install_name and change the library name in main application to use relative path | ||
for i in "${LIBS[@]}" | ||
do | ||
cp $LIB_DIR/$i "$APP_DIR/Contents/Frameworks/$i" | ||
|
||
install_name_tool -id @executable_path/../Frameworks/$i "$APP_DIR/Contents/Frameworks/$i" | ||
|
||
for j in "${OLD_PATH_DIRS[@]}" | ||
do | ||
install_name_tool -change $j/$i @executable_path/../Frameworks/$i "$APP_DIR/$APP_BIN" | ||
done | ||
done | ||
|
||
# Loop through each dependency between libraries and change the corresponding name to new relative path in library | ||
ARR_SIZE=${#DEPS[@]} | ||
for i in "${OLD_PATH_DIRS[@]}" | ||
do | ||
for ((j=0; j<$ARR_SIZE; j = j + 2)) | ||
do | ||
install_name_tool -change $i/${DEPS[$j]} @executable_path/../Frameworks/${DEPS[$j]} "$APP_DIR/Contents/Frameworks/${DEPS[$j+1]}" | ||
done | ||
done | ||
|
||
# Create dmg directory | ||
mkdir "$DMG_DIR" | ||
|
||
# Remove EVERYTHING from dmg directory. | ||
rm -rf "$DMG_DIR/*" | ||
|
||
# Copy app bundle to dmg folder | ||
cp -R "$APP_DIR" "$DMG_DIR/" | ||
|
||
# Create symlink of Applications in folder so user can drag application to folder | ||
ln -s /Applications "$DMG_DIR/Applications" | ||
|
||
# Create DMG file with contents being the contents of $DMG_DIR | ||
hdiutil create -volname "$APP_NAME" -srcfolder "$DMG_DIR" -ov -format UDZO "$APP_DIR/../$DMG_NAME.dmg" | ||
|
||
# Output otool result to see if all dependencies were met | ||
otool -L "$APP_DIR/$APP_BIN" | ||
otool -L "$APP_DIR/Contents/Frameworks/lib"* |