aboutsummaryrefslogtreecommitdiff
path: root/etc/bootstrap/bbot-bootstrap-msvc.bat
diff options
context:
space:
mode:
Diffstat (limited to 'etc/bootstrap/bbot-bootstrap-msvc.bat')
-rw-r--r--etc/bootstrap/bbot-bootstrap-msvc.bat57
1 files changed, 46 insertions, 11 deletions
diff --git a/etc/bootstrap/bbot-bootstrap-msvc.bat b/etc/bootstrap/bbot-bootstrap-msvc.bat
index 6dd9579..ba08fd5 100644
--- a/etc/bootstrap/bbot-bootstrap-msvc.bat
+++ b/etc/bootstrap/bbot-bootstrap-msvc.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 set "MSVC=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community"
set "MSVC=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
set "VCVARS=VC\Auxiliary\Build\vcvars64.bat"
@@ -44,18 +83,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
@@ -123,7 +158,7 @@ cmd /C build-msvc.bat --timeout %TIMEOUT% --install-dir %INSTALL%^
@if errorlevel 1 goto error
cd ..
-rmdir /S /Q %bstrap%
+@call :rmdir_S %bstrap%
@if errorlevel 1 goto error
@@ -136,7 +171,7 @@ rmdir /S /Q %bstrap%
@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
@@ -146,7 +181,7 @@ bpkg install bbot
@if errorlevel 1 goto error
cd ..
-rmdir /S /Q %config%
+@call :rmdir_S %config%
@if errorlevel 1 goto error
@rem