aboutsummaryrefslogtreecommitdiffstats
path: root/dist/macos
diff options
context:
space:
mode:
Diffstat (limited to 'dist/macos')
-rw-r--r--dist/macos/bundle/Barrier.app/Contents/Info.plist.in32
-rw-r--r--dist/macos/bundle/Barrier.app/Contents/PkgInfo1
-rw-r--r--dist/macos/bundle/Barrier.app/Contents/Resources/Barrier.icnsbin0 -> 470437 bytes
-rwxr-xr-xdist/macos/bundle/build_installer.sh.in77
-rwxr-xr-xdist/macos/bundle/reref_dylibs.sh41
5 files changed, 151 insertions, 0 deletions
diff --git a/dist/macos/bundle/Barrier.app/Contents/Info.plist.in b/dist/macos/bundle/Barrier.app/Contents/Info.plist.in
new file mode 100644
index 0000000..b973f5e
--- /dev/null
+++ b/dist/macos/bundle/Barrier.app/Contents/Info.plist.in
@@ -0,0 +1,32 @@
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDisplayName</key>
+ <string>Barrier</string>
+ <key>CFBundleExecutable</key>
+ <string>barrier.sh</string>
+ <key>CFBundleIconFile</key>
+ <string>Barrier.icns</string>
+ <key>CFBundleIdentifier</key>
+ <string>barrier</string>
+ <!-- TODO: Fix this in v2.0 //-->
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>Barrier</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>SYN1</string>
+ <key>CFBundleShortVersionString</key>
+ <string>@BARRIER_VERSION@</string>
+ <key>CFBundleVersion</key>
+ <string>@BARRIER_VERSION@</string>
+ <key>NSHumanReadableCopyright</key>
+ <string>© 2018 Debauchee Open Source Group</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>10.9.0</string>
+ </dict>
+</plist>
diff --git a/dist/macos/bundle/Barrier.app/Contents/PkgInfo b/dist/macos/bundle/Barrier.app/Contents/PkgInfo
new file mode 100644
index 0000000..583e36a
--- /dev/null
+++ b/dist/macos/bundle/Barrier.app/Contents/PkgInfo
@@ -0,0 +1 @@
+APPLSYN1 \ No newline at end of file
diff --git a/dist/macos/bundle/Barrier.app/Contents/Resources/Barrier.icns b/dist/macos/bundle/Barrier.app/Contents/Resources/Barrier.icns
new file mode 100644
index 0000000..9f573da
--- /dev/null
+++ b/dist/macos/bundle/Barrier.app/Contents/Resources/Barrier.icns
Binary files differ
diff --git a/dist/macos/bundle/build_installer.sh.in b/dist/macos/bundle/build_installer.sh.in
new file mode 100755
index 0000000..f939b77
--- /dev/null
+++ b/dist/macos/bundle/build_installer.sh.in
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+# change this to rename the installer package
+B_DMG="Barrier-@BARRIER_VERSION@.dmg"
+
+# sanity check so we don't distribute packages full of debug symbols
+if [ "@CMAKE_BUILD_TYPE@" != "Release" ]; then
+ echo Will only build installers for Release builds
+ exit 1
+fi
+
+cd @CMAKE_CURRENT_SOURCE_DIR@/build/bundle || exit 1
+
+B_REREF_SCRIPT=@CMAKE_CURRENT_SOURCE_DIR@/build/bundle/reref_dylibs.sh
+if [ ! -x $B_REREF_SCRIPT ]; then
+ echo Missing script: $B_REREF_SCRIPT
+ exit 1
+fi
+
+# remove any old copies so there's no confusion about whether this
+# process completes successfully or not
+rm -rf temp.dmg $B_DMG
+
+cd Barrier.app/Contents 2>/dev/null
+if [ $? -ne 0 ]; then
+ echo Please make sure that the build completed successfully
+ echo before trying to create the installer.
+ exit 1
+fi
+
+# MacOS folder holds the executables, non-system libraries,
+# and the startup script
+rm -rf MacOS
+mkdir MacOS || exit 1
+cd MacOS || exit 1
+
+# copy all executables
+cp @CMAKE_RUNTIME_OUTPUT_DIRECTORY@/* . || exit 1
+
+# copy the qt platform plugin
+# TODO: this is hacky and will probably break if there is more than one qt
+# version installed. need a better way to find this library
+B_COCOA=$(find /usr/local/Cellar/qt -type f -name libqcocoa.dylib | head -1)
+if [ $? -ne 0 ] || [ "x$B_COCOA" = "x" ]; then
+ echo "Could not find cocoa platform plugin"
+ exit 1
+fi
+mkdir platforms
+cp $B_COCOA platforms/ || exit 1
+
+# make sure we can r/w all these binaries
+chmod -R u+rw * || exit 1
+
+# only one executable (barrier) needs non-system libraries although it's
+# libraries can call each other. use a recursive script to handle the
+# re-referencing
+$B_REREF_SCRIPT barrier || exit 1
+# the cocoa platform plugin also needs to know where to find the qt libraries.
+# because it exists in a subdirectory we append ../ to the relative path of the
+# libraries in its metadata
+$B_REREF_SCRIPT platforms/libqcocoa.dylib ../ || exit 1
+
+# create a startup script that will change to the binary directory
+# before starting barrier
+printf "%s\n" "#!/bin/sh" "cd \$(dirname \$0)" "exec ./barrier" > barrier.sh
+chmod +x barrier.sh
+
+# create the DMG to be distributed in build/bundle
+cd ../../..
+hdiutil create -size 64m -fs HFS+ -volname "Barrier" temp.dmg || exit 1
+hdiutil attach temp.dmg -mountpoint mnt || exit 1
+cp -r Barrier.app mnt/ || exit 1
+hdiutil detach mnt || exit 1
+hdiutil convert temp.dmg -format UDZO -o $B_DMG || exit 1
+rm temp.dmg
+
+echo "Installer created successfully"
diff --git a/dist/macos/bundle/reref_dylibs.sh b/dist/macos/bundle/reref_dylibs.sh
new file mode 100755
index 0000000..15191bd
--- /dev/null
+++ b/dist/macos/bundle/reref_dylibs.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# $1 = binary (program or dylib)
+B_TARGET=$1
+if [ "x$B_TARGET" = "x" ]; then
+ echo Which binary needs to be re-referenced?
+ exit 1
+fi
+
+cd $(dirname $B_TARGET) || exit 1
+
+# where to find non-system libraries relative to target's directory.
+# the vast majority of the time this should be empty
+B_REL_PATH=$2
+
+# we're in target's directory now. trim off the path
+B_TARGET=$(basename $B_TARGET)
+
+# get a list of non-system libraries and make local copies
+B_LIBS=$(otool -XL $B_TARGET | awk '{ print $1 }' | grep -Ev '^(/usr/lib|/System)')
+[ $? -ne 0 ] && exit 1
+for B_LIB in $B_LIBS; do
+ B_LIB_NAME=$(basename $B_LIB)
+
+ # ignore self-references
+ [ "$B_TARGET" = "$B_LIB_NAME" ] && continue
+
+ B_DST=${B_REL_PATH}${B_LIB_NAME}
+ if [ ! -e $B_DST ]; then
+ cp $B_LIB $B_DST || exit 1
+ chmod u+rw $B_DST || exit 1
+ # recursively call this script on libraries purposefully not passing
+ # $B_REL_PATH so that it is only used explicitly
+ $0 $B_DST
+ fi
+
+ # adjust the target's metadata to point to the local copy
+ # rather than the system-wide copy which would only exist on
+ # a development machine
+ install_name_tool -change $B_LIB @loader_path/$B_DST $B_TARGET || exit 1
+done