diff --git a/bundle.sh b/bundle.sh new file mode 100755 index 0000000..ca8cede --- /dev/null +++ b/bundle.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +err_ok=0 +err_bad_arg=1 +err_bad_run=2 + +rm_if_dir() { + [[ -d $1 ]] && rm -rf "$1" && echo "removed $1" + return 0 +} +perish() { + rm_if_dir "${tmpdir}" + exit "$1" +} +err() { + echo "error, dropping build" + rm_if_dir "${appdir}" + perish $1 +} +:() { + echo "$@" + echo + eval "$@" || err ${err_bad_run} +} + +declare -A icon_names=( + [Tycho]="resources/color/pfhor-hand.png" +) + +name=$1 +exe=$2 + +if [[ ! $name ]] +then + echo "program name needed (available: Tycho)" + err ${err_bad_arg} +fi + +if [[ ! $exe ]] +then + echo "full path to executable required (ex. '$0 $name ~/bin/maraiah-tycho')" + err ${err_bad_arg} +fi + +app=${name}.app + +srcdir=${PWD}/${name,,} +exedir=$(dirname "${exe}") +appdir=${exedir}/${app} + +tmpdir=$(mktemp -d) +icondir=${tmpdir}/${name}.iconset +icon=${srcdir}/${icon_names[${name}]} + +: rm_if_dir "${appdir}" + +: mkdir -p "${appdir}/Contents/"{Frameworks,MacOS,Resources} "${icondir}" + +: cp "${exe}" "${appdir}/Contents/MacOS" +: cp "${srcdir}/resources/Info.plist" "${appdir}/Contents" + +: sips -z 16 16 "${icon}" --out "${icondir}/icon_16x16.png" +: sips -z 32 32 "${icon}" --out "${icondir}/icon_32x32.png" +: sips -z 64 64 "${icon}" --out "${icondir}/icon_64x64.png" +: sips -z 128 128 "${icon}" --out "${icondir}/icon_128x128.png" +: sips -z 256 256 "${icon}" --out "${icondir}/icon_256x256.png" +: sips -z 512 512 "${icon}" --out "${icondir}/icon_512x512.png" +: sips -z 1024 1024 "${icon}" --out "${icondir}/icon_512x512@2x.png" + +: cp "${icondir}/icon_32x32.png" "${icondir}/icon_16x16@2x.png" +: cp "${icondir}/icon_64x64.png" "${icondir}/icon_32x32@2x.png" +: cp "${icondir}/icon_256x256.png" "${icondir}/icon_128x128@2x.png" +: cp "${icondir}/icon_512x512.png" "${icondir}/icon_256x256@2x.png" + +: iconutil -c icns -o "${appdir}/Contents/Resources/${name}.icns" "${icondir}" + +while IFS= read -r lnk +do + lnk=$(dirname "${lnk}") + : cp -r "${lnk}" "${appdir}/Contents/Frameworks" +done < "${exedir}"/build/maraiah-tycho-*/out/etc/link.txt + +echo "success: bundle written to ${appdir}" +perish ${err_ok} + +## EOF diff --git a/tycho/resources/Info.plist b/tycho/resources/Info.plist new file mode 100644 index 0000000..5365edd --- /dev/null +++ b/tycho/resources/Info.plist @@ -0,0 +1,36 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDisplayName + Tycho + CFBundleExecutable + maraiah-tycho + CFBundleIconFile + Tycho.icns + CFBundleIdentifier + net.greyserv.maraiah.tycho + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Tycho + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.0.0 + CFBundleVersion + 20190704.093221 + CSResourcesFileMapped + + LSApplicationCategoryType + public.app-category.developer-tools + LSRequiresCarbon + + NSHighResolutionCapable + + NSHumanReadableCopyright + Public domain software. + +