mirror of
https://github.com/RPCS3/hidapi.git
synced 2026-01-31 01:25:21 +01:00
Made a Mac Application Bundle (TestGUI.app) for this application. Handle dock actions properly for Quit and Show (single click) events.
81 lines
1.9 KiB
Bash
Executable File
81 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#### Configuration:
|
|
# The name of the executable. It is assumed
|
|
# that it is in the current working directory.
|
|
EXE_NAME=testgui
|
|
# Path to the executable directory inside the bundle.
|
|
EXEPATH=./TestGUI.app/Contents/MacOS
|
|
# Libraries to explicitly bundle, even though they
|
|
# may not be in /opt/local. One per line. These
|
|
# are used with grep, so only a portion of the name
|
|
# is required. eg: libFOX, libz, etc.
|
|
LIBS_TO_BUNDLE=libFOX
|
|
|
|
|
|
function copydeps {
|
|
local file=$1
|
|
# echo "Copying deps for $file...."
|
|
local BASE_OF_EXE=`basename $file`
|
|
|
|
# A will contain the dependencies of this library
|
|
local A=`otool -LX $file |cut -f 1 -d " "`
|
|
local i
|
|
for i in $A; do
|
|
local BASE=`basename $i`
|
|
|
|
# See if it's a lib we specifically want to bundle
|
|
local bundle_this_lib=0
|
|
local j
|
|
for j in $LIBS_TO_BUNDLE; do
|
|
echo $i |grep -q $j
|
|
if [ $? -eq 0 ]; then
|
|
bundle_this_lib=1
|
|
echo "bundling $i because it's in the list."
|
|
break;
|
|
fi
|
|
done
|
|
|
|
# See if it's in /opt/local. Bundle all in /opt/local
|
|
local isOptLocal=0
|
|
echo $i |grep -q /opt/local
|
|
if [ $? -eq 0 ]; then
|
|
isOptLocal=1
|
|
echo "bundling $i because it's in /opt/local."
|
|
fi
|
|
|
|
# Bundle the library
|
|
if [ $isOptLocal -ne 0 ] || [ $bundle_this_lib -ne 0 ]; then
|
|
|
|
# Copy the file into the bundle if it exists.
|
|
if [ -f $EXEPATH/$BASE ]; then
|
|
z=0
|
|
else
|
|
cp $i $EXEPATH
|
|
fi
|
|
|
|
|
|
# echo "$BASE_OF_EXE depends on $BASE"
|
|
|
|
# Fix the paths using install_name_tool and then
|
|
# call this function recursively for each dependency
|
|
# of this library.
|
|
if [ $BASE_OF_EXE != $BASE ]; then
|
|
|
|
# Fix the paths
|
|
install_name_tool -id @executable_path/$BASE $EXEPATH/$BASE
|
|
install_name_tool -change $i @executable_path/$BASE $EXEPATH/$BASE_OF_EXE
|
|
|
|
# Call this function (recursive) on
|
|
# on each dependency of this library.
|
|
copydeps $EXEPATH/$BASE
|
|
fi
|
|
fi
|
|
done
|
|
}
|
|
|
|
rm $EXEPATH/*
|
|
cp $EXE_NAME $EXEPATH
|
|
copydeps $EXEPATH/$EXE_NAME
|
|
|