Skip to content

Commit

Permalink
tools: update bcz.cmd to use the progress bar VT sequence (#8335)
Browse files Browse the repository at this point in the history
## Summary of the Pull Request

Does what the title says. Now while you're building terminal projects,
the taskbar will show indeterminate progress. If the build fails, it'll
blink the error state for 500ms before returning to normal.

## References
* Made possible by #8055 _and viewers like you_

## PR Checklist
* [x] scratches an itch I've had since at least 2018
* [x] I work here
* [x] this is a build script

## Validation Steps Performed
tested manually
  • Loading branch information
zadjii-msft authored Nov 20, 2020
1 parent a77b494 commit 14fe993
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tools/bcz.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,46 @@ set _BUILD_CMDLINE="%MSBUILD%" %OPENCON%\OpenConsole.sln /t:"%_MSBUILD_TARGET%"

echo %_BUILD_CMDLINE%
echo Starting build...

@rem start indeterminate progress in the taskbar
@rem this `<NUL set /p =` magic will output the text _without a newline_
<NUL set /p =]9;4;3

%_BUILD_CMDLINE%

@rem capture the return value of msbuild, so we can return that as our return value.
set _build_result=%errorlevel%
if (%_build_result%) == (0) (

@rem clear the progress
<NUL set /p =]9;4

) else (

@rem set the taskbar to the error state, then sleep for 500ms, before clearing
@rem the progress state. This will "blink" the error state into the taskbar

<NUL set /p =]9;4;2;100

@rem this works to "sleep" the console for 500ms. `ping` can't wait for less
@rem than 500ms, and it will only wait if the target address _doesn't_ respond,
@rem hence why we're using 128., not 127.

ping 128.0.0.1 -n 1 -w 500 > nul

<NUL set /p =]9;4

)

rem Cleanup unused variables here. Note we cannot use setlocal because we need to pass modified
rem _LAST_BUILD_CONF out to OpenCon.cmd later.
rem
set _MSBUILD_TARGET=
set _BIN_=%~dp0\bin\%PLATFORM%\%_LAST_BUILD_CONF%

@rem Exit with the value from msbuild. If msbuild is unsuccessful in building, this will be 1
EXIT /b %_build_result%

goto :eof

rem ############################################################################
Expand Down

0 comments on commit 14fe993

Please sign in to comment.