Skip to content

Commit 7a788fd

Browse files
authored
fix: improve checking for Rez (fix #994) (#995)
* 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
1 parent 37bcf5f commit 7a788fd

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

.changes/995-xcode-path.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-bundler": patch
3+
---
4+
5+
Improve checking for Xcode command line tools to allow builds on mac

cli/tauri-bundler/src/bundle/templates/dmg/bundle_dmg

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function usage() {
5454
echo " --disk-image-size x"
5555
echo " set the disk image size manually to x MB"
5656
echo " --hdiutil-verbose"
57-
echo " execute hdiutil in verbose mode"
57+
echo " execute hdiutil in verbose mode"
5858
echo " --hdiutil-quiet"
5959
echo " execute hdiutil in quiet mode"
6060
echo " --sandbox-safe"
@@ -158,10 +158,10 @@ while [ ! -z ${1+x} ] && test "${1:0:1}" = "-"; do
158158
shift;;
159159
--hdiutil-quiet)
160160
HDIUTIL_VERBOSITY='-quiet'
161-
shift;;
161+
shift;;
162162
--sandbox-safe)
163163
SANDBOX_SAFE=1
164-
shift;;
164+
shift;;
165165
--rez)
166166
REZ_PATH=$2
167167
shift; shift;;
@@ -237,7 +237,7 @@ fi
237237

238238
if [ $SANDBOX_SAFE -eq 0 ]; then
239239
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}"
240-
else
240+
else
241241
hdiutil makehybrid ${HDIUTIL_VERBOSITY} -default-volume-name "${VOLUME_NAME}" -hfs -o "${DMG_TEMP_NAME}" "$SRC_FOLDER"
242242
hdiutil convert -format UDRW -ov -o "${DMG_TEMP_NAME}" "${DMG_TEMP_NAME}"
243243
DISK_IMAGE_SIZE_CUSTOM=$DISK_IMAGE_SIZE
@@ -271,9 +271,11 @@ echo "Mounting disk image..."
271271
MOUNT_DIR="/Volumes/${VOLUME_NAME}"
272272

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

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

326328
if [ $SKIP_JENKINS -eq 0 ]; then
327329
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"
328-
sleep 2 # pause to workaround occasional "Can’t get disk" (-1728) issues
330+
sleep 2 # pause to workaround occasional "Can’t get disk" (-1728) issues
329331
echo "Running Applescript: /usr/bin/osascript \"${APPLESCRIPT}\" \"${VOLUME_NAME}\""
330332
(/usr/bin/osascript "${APPLESCRIPT}" "${VOLUME_NAME}" || if [[ "$?" -ne 0 ]]; then echo "Failed running AppleScript"; hdiutil detach "${DEV_NAME}"; exit 64; fi)
331333
echo "Done running the applescript..."
@@ -384,7 +386,7 @@ else
384386
# check if hdiutil supports internet-enable
385387
# support was removed in macOS 10.15
386388
# https://github.com/andreyvit/create-dmg/issues/76
387-
if hdiutil internet-enable -help >/dev/null 2>/dev/null
389+
if hdiutil internet-enable -help >/dev/null 2>/dev/null
388390
then
389391
hdiutil internet-enable -yes "${DMG_DIR}/${DMG_NAME}"
390392
else

cli/tauri-bundler/src/bundle/templates/dmg/dmg-license.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import tempfile
3131
import optparse
3232

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

3435
class Path(str):
3536
def __enter__(self):
@@ -140,7 +141,7 @@ def escape(s):
140141
'--rez',
141142
'-r',
142143
action='store',
143-
default='/Applications/Xcode.app/Contents/Developer/Tools/Rez',
144+
default=REZ_PATH,
144145
help='The path to the Rez tool. Defaults to %default'
145146
)
146147
parser.add_option(
@@ -155,7 +156,7 @@ def escape(s):
155156
options, args = parser.parse_args()
156157
cond = len(args) != 2
157158
if not os.path.exists(options.rez):
158-
print('Failed to find Rez at "%s"!\n' % options.rez)
159+
print('Failed to find Rez at "%s"! Run `xcode-select --install` and try again.\n' % options.rez)
159160
cond = True
160161
if cond:
161162
parser.print_usage()

0 commit comments

Comments
 (0)