Skip to content

Commit 6224956

Browse files
committed
Ensure plinth/ghc is a real symlink on Windows
1 parent b41c3e9 commit 6224956

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

plinth-build.sh

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,32 @@ if [ ! -e ./mk/config.h ] || [ "$REBUILD" -eq 1 ]; then
141141
DID_BOOT_OR_CONFIGURE=1
142142
fi
143143

144-
# On Windows, plinth/ghc may not be a a real symlink, recreate it to
145-
# prevent it from becoming stale.
146-
if [ "$IS_WINDOWS" -eq 1 ] && ([ -f plinth/ghc ] || ([ "$DID_BOOT_OR_CONFIGURE" -eq 1 ] && [ -d plinth/ghc ] && [ ! -L plinth/ghc ])); then
147-
echo "re-creating plinth/ghc symlink..."
148-
rm -rf plinth/ghc
149-
ln -s ../ghc plinth/ghc
144+
# On Windows, plinth/ghc must be a real symlink to ../ghc
145+
if [ "$IS_WINDOWS" -eq 1 ] && [ ! -L plinth/ghc ]; then
146+
echo "error: plinth/ghc is not a symlink."
147+
echo ""
148+
# Check Developer Mode via PowerShell (the registry key location varies across Windows versions)
149+
DEV_MODE=$(powershell.exe -NoProfile -Command "(Get-WindowsDeveloperLicense).IsValid" 2>/dev/null | tr -d '\r')
150+
[ "$DEV_MODE" = "True" ] && DEV_MODE=1 || DEV_MODE=0
151+
if [ "$DEV_MODE" != "1" ]; then
152+
echo " Windows Developer Mode is not enabled."
153+
echo " Enable it in: Settings > System > Advanced"
154+
echo ""
155+
fi
156+
SYMLINKS_CFG=$(git config --get core.symlinks 2>/dev/null || echo "false")
157+
if [ "$SYMLINKS_CFG" != "true" ]; then
158+
echo " git core.symlinks is not enabled."
159+
echo " Run: git config core.symlinks true"
160+
echo ""
161+
fi
162+
if [ "$DEV_MODE" = "1" ] && [ "$SYMLINKS_CFG" = "true" ]; then
163+
echo " Developer Mode and core.symlinks are both enabled, but plinth/ghc"
164+
echo " is still not a symlink. Try re-checking out the path:"
165+
echo " rm -rf plinth/ghc && git checkout -- plinth/ghc"
166+
echo ""
167+
fi
168+
echo "After fixing, re-run this script."
169+
exit 1
150170
fi
151171

152172
if [ ! -x ./_build/stage1/bin/ghc ] || [ "$REBUILD" -eq 1 ]; then

0 commit comments

Comments
 (0)