Skip to content

Commit

Permalink
fix: improve checking for Rez (fix #994) (#995)
Browse files Browse the repository at this point in the history
* fix: improve checking for Rez (fix #994)

Check for Rez in Xcode.app and in command line tools, and error if neither is installed.

* Remove hardcoded paths in favor of xcode-select --print-path

This reverts commit 54784a0.

I'm not sure that this string substition will work how I want it to.

* Finally...fix issue finding xcode-select tools

* Add tip asking to run xcode-select --install

* Trim tailing whitespace

* add changefile
  • Loading branch information
caass committed Aug 28, 2020
1 parent 37bcf5f commit 7a788fd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changes/995-xcode-path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-bundler": patch
---

Improve checking for Xcode command line tools to allow builds on mac
18 changes: 10 additions & 8 deletions cli/tauri-bundler/src/bundle/templates/dmg/bundle_dmg
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function usage() {
echo " --disk-image-size x"
echo " set the disk image size manually to x MB"
echo " --hdiutil-verbose"
echo " execute hdiutil in verbose mode"
echo " execute hdiutil in verbose mode"
echo " --hdiutil-quiet"
echo " execute hdiutil in quiet mode"
echo " --sandbox-safe"
Expand Down Expand Up @@ -158,10 +158,10 @@ while [ ! -z ${1+x} ] && test "${1:0:1}" = "-"; do
shift;;
--hdiutil-quiet)
HDIUTIL_VERBOSITY='-quiet'
shift;;
shift;;
--sandbox-safe)
SANDBOX_SAFE=1
shift;;
shift;;
--rez)
REZ_PATH=$2
shift; shift;;
Expand Down Expand Up @@ -237,7 +237,7 @@ fi

if [ $SANDBOX_SAFE -eq 0 ]; then
hdiutil create ${HDIUTIL_VERBOSITY} -srcfolder "$SRC_FOLDER" -volname "${VOLUME_NAME}" -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW ${CUSTOM_SIZE} "${DMG_TEMP_NAME}"
else
else
hdiutil makehybrid ${HDIUTIL_VERBOSITY} -default-volume-name "${VOLUME_NAME}" -hfs -o "${DMG_TEMP_NAME}" "$SRC_FOLDER"
hdiutil convert -format UDRW -ov -o "${DMG_TEMP_NAME}" "${DMG_TEMP_NAME}"
DISK_IMAGE_SIZE_CUSTOM=$DISK_IMAGE_SIZE
Expand Down Expand Up @@ -271,9 +271,11 @@ echo "Mounting disk image..."
MOUNT_DIR="/Volumes/${VOLUME_NAME}"

# try unmount dmg if it was mounted previously (e.g. developer mounted dmg, installed app and forgot to unmount it)
echo "Unmounting disk image..."
DEV_NAME=$(hdiutil info | egrep --color=never '^/dev/' | sed 1q | awk '{print $1}')
test -d "${MOUNT_DIR}" && hdiutil detach "${DEV_NAME}"
if [ test -d "${MOUNT_DIR}" ]; then
echo "Unmounting previously mounted disk image..."
hdiutil detach "${DEV_NAME}"
fi

echo "Mount directory: $MOUNT_DIR"
DEV_NAME=$(hdiutil attach -readwrite -noverify -noautoopen "${DMG_TEMP_NAME}" | egrep --color=never '^/dev/' | sed 1q | awk '{print $1}')
Expand Down Expand Up @@ -325,7 +327,7 @@ EOS

if [ $SKIP_JENKINS -eq 0 ]; then
applescript_source | sed -e "s/WINX/$WINX/g" -e "s/WINY/$WINY/g" -e "s/WINW/$WINW/g" -e "s/WINH/$WINH/g" -e "s/BACKGROUND_CLAUSE/$BACKGROUND_CLAUSE/g" -e "s/REPOSITION_HIDDEN_FILES_CLAUSE/$REPOSITION_HIDDEN_FILES_CLAUSE/g" -e "s/ICON_SIZE/$ICON_SIZE/g" -e "s/TEXT_SIZE/$TEXT_SIZE/g" | perl -pe "s/POSITION_CLAUSE/$POSITION_CLAUSE/g" | perl -pe "s/QL_CLAUSE/$QL_CLAUSE/g" | perl -pe "s/APPLICATION_CLAUSE/$APPLICATION_CLAUSE/g" | perl -pe "s/HIDING_CLAUSE/$HIDING_CLAUSE/" >"$APPLESCRIPT"
sleep 2 # pause to workaround occasional "Can’t get disk" (-1728) issues
sleep 2 # pause to workaround occasional "Can’t get disk" (-1728) issues
echo "Running Applescript: /usr/bin/osascript \"${APPLESCRIPT}\" \"${VOLUME_NAME}\""
(/usr/bin/osascript "${APPLESCRIPT}" "${VOLUME_NAME}" || if [[ "$?" -ne 0 ]]; then echo "Failed running AppleScript"; hdiutil detach "${DEV_NAME}"; exit 64; fi)
echo "Done running the applescript..."
Expand Down Expand Up @@ -384,7 +386,7 @@ else
# check if hdiutil supports internet-enable
# support was removed in macOS 10.15
# https://github.com/andreyvit/create-dmg/issues/76
if hdiutil internet-enable -help >/dev/null 2>/dev/null
if hdiutil internet-enable -help >/dev/null 2>/dev/null
then
hdiutil internet-enable -yes "${DMG_DIR}/${DMG_NAME}"
else
Expand Down
5 changes: 3 additions & 2 deletions cli/tauri-bundler/src/bundle/templates/dmg/dmg-license.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import tempfile
import optparse

REZ_PATH = os.popen('xcode-select --print-path', 'r').read().strip()

class Path(str):
def __enter__(self):
Expand Down Expand Up @@ -140,7 +141,7 @@ def escape(s):
'--rez',
'-r',
action='store',
default='/Applications/Xcode.app/Contents/Developer/Tools/Rez',
default=REZ_PATH,
help='The path to the Rez tool. Defaults to %default'
)
parser.add_option(
Expand All @@ -155,7 +156,7 @@ def escape(s):
options, args = parser.parse_args()
cond = len(args) != 2
if not os.path.exists(options.rez):
print('Failed to find Rez at "%s"!\n' % options.rez)
print('Failed to find Rez at "%s"! Run `xcode-select --install` and try again.\n' % options.rez)
cond = True
if cond:
parser.print_usage()
Expand Down

0 comments on commit 7a788fd

Please sign in to comment.