Skip to content

Commit d6db379

Browse files
committed
Correct install_ide_version under Windows
git-bash's ln command actually just does a copy, which is super slow. Worse, the command fails when the "link" folder already exists, even though I use ln --force. So use the Windows native mklink command instead.
1 parent e7e58c6 commit d6db379

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

arduino-ci-script.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,21 @@ function install_ide_version()
445445
{
446446
local -r IDEversion="$1"
447447

448-
# Create a symbolic link so that the Arduino IDE can always be referenced from the same path no matter which version is being used.
449-
ln --symbolic --force --no-dereference $ARDUINO_CI_SCRIPT_VERBOSITY_OPTION "${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/arduino-${IDEversion}" "${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}"
448+
# Create a symbolic link so that the Arduino IDE can always be referenced by the user from the same path no matter which version is being used.
449+
if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]]; then
450+
# git-bash's ln just does a copy instead of making a symlink, which takes forever and fails when the target folder exists (despite --force), which takes forever.
451+
# Therefore, use the native Windows command mklink to create a directory junction instead.
452+
# Using a directory junction instead of symlink because supposedly a symlink requires admin privileges.
453+
454+
# Windows doesn't seem to provide any way to overwrite directory junctions
455+
if [[ -d "${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}" ]]; then
456+
rm --recursive --force "${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER:?}"
457+
fi
458+
# https://stackoverflow.com/a/25394801
459+
cmd <<< "mklink /J \"${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}\\${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}\" \"${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER//\//\\}\\arduino-${IDEversion}\"" > /dev/null
460+
else
461+
ln --symbolic --force --no-dereference $ARDUINO_CI_SCRIPT_VERBOSITY_OPTION "${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/arduino-${IDEversion}" "${ARDUINO_CI_SCRIPT_APPLICATION_FOLDER}/${ARDUINO_CI_SCRIPT_IDE_INSTALLATION_FOLDER}"
462+
fi
450463
}
451464
452465

0 commit comments

Comments
 (0)