anchor.diff:  endlocal & SET %~1=%OUTPUT%
   GOTO :EOF
   :CANONICALIZE_PATH_INNER
  -if "%~3" NEQ "" (pushd %~3 || GOTO :EOF)
  +if "%~3" NEQ "" (pushd %3 || GOTO :EOF)
   SET OUTPUT=%~f2
  -if "%~3" NEQ "" popd %~3
  -GOTO :EOF
  +if "%~3" NEQ "" popd
  +GOTO :EOF
  +
  +:DIFF_TIME
  +@REM Calculates elapsed time between two timestamps (TIME environment variable format)
  +@REM %1 - Output variable
  +@REM %2 - Start time
  +@REM %3 - End time
  +setlocal EnableDelayedExpansion
  +set START_ARG=%2
  +set END_ARG=%3
  +set END=!END_ARG:%TIME:~8,1%=%%100)*100+1!
  +set START=!START_ARG:%TIME:~8,1%=%%100)*100+1!
  +set /A DIFF=((((10!END:%TIME:~2,1%=%%100)*60+1!%%100)-((((10!START:%TIME:~2,1%=%%100)*60+1!%%100), DIFF-=(DIFF^>^>31)*24*60*60*100
  +set /A CC=DIFF%%100+100,DIFF/=100,SS=DIFF%%60+100,DIFF/=60,MM=DIFF%%60+100,HH=DIFF/60+100
  +@endlocal & set %1=%HH:~1%%TIME:~2,1%%MM:~1%%TIME:~2,1%%SS:~1%%TIME:~8,1%%CC:~1%
  +@GOTO :EOF
  +
  +:WRITE_CUSTOM_SCRIPT_SKELETON
  +@REM Writes the following text to the supplied file
  +@REM %1 - Output filename
  +setlocal
  +@(
  +ECHO @ECHO.
  +ECHO @ECHO ********************************************************************************
  +ECHO @ECHO ** This is a custom run script skeleton.
  +ECHO @ECHO ********************************************************************************
  +ECHO @ECHO.
  +ECHO @ECHO ********************************************************************************
  +ECHO @ECHO ** The working directory is:
  +ECHO @ECHO ********************************************************************************
  +ECHO dir
  +ECHO @ECHO.
  +ECHO @ECHO ********************************************************************************
  +ECHO @ECHO ** The environment is:
  +ECHO @ECHO ********************************************************************************
  +ECHO set
  +ECHO @ECHO.
  +ECHO @ECHO ********************************************************************************
  +ECHO @ECHO ** Edit or replace this script to run custom steps after a successful build:
  +ECHO @ECHO ** %~1
  +ECHO @ECHO ********************************************************************************
  +ECHO @ECHO.
  +) > "%~1"
  +endlocal
  +GOTO :EOF
  
positive.code: :MAKE_OR_CLEAN_DIRECTORY
  @REM Create directory if it doesn't exist or clean it if it does
  @REM %1 - Directory path to clean or create
  setlocal disableDelayedExpansion
  IF NOT EXIST "%~1" (
      ECHO Creating %~1
      mkdir "%~1" && GOTO :EOF
  )
  ECHO Cleaning %~1 ...
  for /F "usebackq delims=" %%I in (`dir /a /b "%~1"`) do (
      (rmdir /s /q  "%~1\%%I" 2>nul ) || del /q /f "%~1\%%I")
  GOTO :EOF
  
  :TOLOWER
  
negative.code: @IF "%PS_ECHO_ON%" NEQ "" (echo on) ELSE (echo off)
  @GOTO :MAIN
  :HELP
  @ECHO.
  @ECHO Performs initial build or rebuild of the app (build) and deps (build/deps).
  @ECHO Default options are determined from build directories and system state.
  @ECHO.
  @ECHO Usage: build_win [-ARCH ^<arch^>] [-CONFIG ^<config^>] [-DESTDIR ^<directory^>]
  @ECHO                  [-STEPS ^<all^|all-dirty^|app^|app-dirty^|deps^|deps-dirty^>]
  @ECHO                  [-RUN ^<console^|custom^|none^|viewer^|window^>]
  @ECHO.
  @ECHO  -a -ARCH      Target processor architecture
  @ECHO                Default: %PS_ARCH_HOST%
  @ECHO  -c -CONFIG    MSVC project config
  @ECHO                Default: %PS_CONFIG_DEFAULT%
  @ECHO  -s -STEPS     Performs only the specified build steps:
  @ECHO                  all - clean and build deps and app
  @ECHO                  all-dirty - build deps and app without cleaning
  @ECHO                  app - clean and build main applications
  @ECHO                  app-dirty - build main applications without cleaning
  @ECHO                  deps - clean and build deps
  @ECHO                  deps-dirty - build deps without cleaning
  @ECHO                Default: %PS_STEPS_DEFAULT%
  @ECHO  -r -RUN       Specifies what to perform at the run step:
  @ECHO                  console - run and wait on prusa-slicer-console.exe
  @ECHO                  custom - run and wait on your custom build/%PS_CUSTOM_RUN_FILE%
  @ECHO                  ide - open project in Visual Studio if not open (no wait)
  @ECHO                  none - run step does nothing
  @ECHO                  viewer - run prusa-gcodeviewer.exe (no wait)
  @ECHO                  window - run prusa-slicer.exe (no wait)
  @ECHO                Default: none
  @ECHO  -d -DESTDIR   Deps destination directory
  @ECHO                Warning: Changing destdir path will not delete the old destdir.
  @ECHO                Default: %PS_DESTDIR_DEFAULT_MSG%
  @ECHO.
  @ECHO  Examples:
  @ECHO.
  @ECHO  Initial build:           build_win -d "c:\src\PrusaSlicer-deps"
  @ECHO  Build post deps change:  build_win -s all
  @ECHO  App dirty build:         build_win
  @ECHO  App dirty build ^& run:   build_win -r console
  @ECHO  All clean build ^& run:   build_win -s all -r console -d "deps\build\out_deps"
  @ECHO.
  GOTO :END
  
  :MAIN
  REM Script constants
  SET START_TIME=%TIME%
  SET PS_START_DIR=%CD%
  SET PS_SOLUTION_NAME=PrusaSlicer
  SET PS_CHOICE_TIMEOUT=30
  SET PS_CUSTOM_RUN_FILE=custom_run.bat
  SET PS_DEPS_PATH_FILE_NAME=.DEPS_PATH.txt
  SET PS_DEPS_PATH_FILE=%~dp0deps\build\%PS_DEPS_PATH_FILE_NAME%
  SET PS_CONFIG_LIST="Debug;MinSizeRel;Release;RelWithDebInfo"
  
  REM Probe build directories and system state for reasonable default arguments
  pushd %~dp0
  SET PS_CONFIG=RelWithDebInfo
  SET PS_ARCH=%PROCESSOR_ARCHITECTURE:amd64=x64%
  CALL :TOLOWER PS_ARCH
  SET PS_RUN=none
  SET PS_DESTDIR=
  CALL :RESOLVE_DESTDIR_CACHE
  
  REM Set up parameters used by help menu
  SET PS_CONFIG_DEFAULT=%PS_CONFIG%
  SET PS_ARCH_HOST=%PS_ARCH%
  (echo " -help /help -h /h -? /? ")| findstr /I /C:" %~1 ">nul && GOTO :HELP
  
  REM Parse arguments
  SET EXIT_STATUS=1
  SET PS_CURRENT_STEP=arguments
  SET PARSER_STATE=
  SET PARSER_FAIL=
  FOR %%I in (%*) DO CALL :PARSE_OPTION "ARCH CONFIG DESTDIR STEPS RUN" PARSER_STATE "%%~I"
  IF "%PARSER_FAIL%" NEQ "" (
      @ECHO ERROR: Invalid switch: %PARSER_FAIL% 1>&2
      GOTO :HELP
  