diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-11-11 15:35:59 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-11-11 18:35:40 +0300 |
commit | cc1e10db513d1a6da66556934f583270604b3973 (patch) | |
tree | b38ca4b9433bc546b92b1aae3b58749ebf2a208a /etc/bootstrap/bbot-bootstrap-clang.bat | |
parent | f5ae09e7b1b6e38502e8532e1801076253f450b2 (diff) |
Retry periodically failing rmdir in bootstrapt scripts for Windows
Diffstat (limited to 'etc/bootstrap/bbot-bootstrap-clang.bat')
-rw-r--r-- | etc/bootstrap/bbot-bootstrap-clang.bat | 57 |
1 files changed, 46 insertions, 11 deletions
diff --git a/etc/bootstrap/bbot-bootstrap-clang.bat b/etc/bootstrap/bbot-bootstrap-clang.bat index 09bd0e7..79c4009 100644 --- a/etc/bootstrap/bbot-bootstrap-clang.bat +++ b/etc/bootstrap/bbot-bootstrap-clang.bat @@ -5,6 +5,45 @@ rem license : TBC; see accompanying LICENSE file setlocal EnableExtensions EnableDelayedExpansion +goto start + +@rem Remove a directory recursively. Noop for non-existent directory. +@rem +@rem Note that the underlying rmdir call periodically fails with the +@rem 'directory not empty' diagnostics, in which case we make up to 100 +@rem removal attempts. +@rem +:rmdir_S + + @if not exist %1\ goto :eof + + @setlocal EnableDelayedExpansion + + @set /A "i=0" + + :rmdir_S_try + + @rem Note that rmdir doesn't properly set errorlevel, so we check for the + @rem directory existence to detect the failure. + @rem + rmdir /S /Q %1\ + + @if exist %1\ ( + if %i% neq 99 ( + set /A "i=%i%+1" + goto rmdir_S_try + ) + + echo error: unable to remove %1\ + endlocal + exit /b 1 + ) + + @endlocal +@goto :eof + +:start + rem If the MSVC variable is set, then set up the environment via the MSVC rem command prompt rather than letting Clang find some default (note that rem in the latter case, clang++ should be in PATH). @@ -60,18 +99,14 @@ rem @rem @rem Bootstrap the toolchain and then build bbot. @rem -@if exist %BUILD%\bootstrap\ ( - rmdir /S /Q %BUILD%\bootstrap - @if errorlevel 1 goto error -) +@call :rmdir_S %BUILD%\bootstrap +@if errorlevel 1 goto error mkdir %BUILD%\bootstrap @if errorlevel 1 goto error -@if exist %INSTALL% ( - rmdir /S /Q %INSTALL% - @if errorlevel 1 goto error -) +@call :rmdir_S %INSTALL% +@if errorlevel 1 goto error cd %BUILD%\bootstrap @@ -147,14 +182,14 @@ cmd /C build-clang.bat --make mingw32-make --make -j%NUMBER_OF_PROCESSORS%^ @if errorlevel 1 goto error cd .. -rmdir /S /Q %bstrap% +@call :rmdir_S %bstrap% @if errorlevel 1 goto error @rem @rem Build and install the bbot worker. @rem -@for /D %%d in (build2-toolchain-*) do set "config=%%d" +@for /D %%d in (build2-toolchain-*) do @set "config=%%d" cd %config% bpkg --fetch-timeout %TIMEOUT% build --yes bbot @@ -164,7 +199,7 @@ bpkg install bbot @if errorlevel 1 goto error cd .. -rmdir /S /Q %config% +@call :rmdir_S %config% @if errorlevel 1 goto error @rem |