Update windows scripts

This commit is contained in:
doylet 2024-10-28 14:48:51 +11:00
parent 2aca88b278
commit 2364e61b67
2 changed files with 104 additions and 0 deletions

101
Win/Scripts/dev.bat Normal file
View File

@ -0,0 +1,101 @@
@echo off
:: Setup :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
setlocal enabledelayedexpansion
set script_path=%~dpnx0
set script_dir_backslash=%~dp0
set script_dir=%script_dir_backslash:~0,-1%
set root_dir=%devenver_root%
:: Arguments :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
set clang_dir=%root_dir%\LLVM
set cmake_dir=%root_dir%\CMake
set node_dir=%root_dir%\NodeJS
set raddbg_dir=%root_dir%\raddbg\trunk
set raddbg_args=--user:%raddbg_dir%\..\doylet.raddbg_user
set raddbg_exe=raddbg.exe
set radlink_dir=%root_dir%\raddbg\trunk
set radlink_exe=radlink.exe
set rad_update_dir=%radlink_dir%\..
set rad_update_exe=update_trunk.bat
set remedybg_dir=%root_dir%\RemedyBG
set remedybg_exe=remedybg.exe
set virustotal_url=https://www.virustotal.com/gui/file
:: Argument parsing ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Remove the first argument which is the command (e.g. raddbg or radlink)
set option=%1
shift
if "%option%"=="raddbg" set "exe_dir=%raddbg_dir%" && set path=%exe_dir%;%path% && set cmd_line=start /B !exe_dir!\%raddbg_exe% %raddbg_args%
if "%option%"=="raddbg_env" endlocal && set path=%raddbg_dir%;%path% && goto :eof
if "%option%"=="radlink" set "exe_dir=%radlink_dir%" && set path=%exe_dir%;%path% && set cmd_line=!exe_dir!\%radlink_exe%
if "%option%"=="radlink_env" endlocal && set path=%radlink_dir%;%path% && goto :eof
if "%option%"=="rad_update" set "exe_dir=%rad_update_dir%" && set path=%rad_update_dir%;%path% && set cmd_line=!exe_dir!\update_trunk.bat
if "%option%"=="clang" set "exe_dir=%clang_dir%\%1\bin" && set path=%exe_dir%;%path% && set cmd_line=!exe_dir!\%2 && shift && shift
if "%option%"=="cmake" set "exe_dir=%cmake_dir%\%1" && set path=%exe_dir%;%path% && set cmd_line=!exe_dir!\%2 && shift && shift
if "%option%"=="remedybg" set "exe_dir=%remedybg_dir%\%1" && set path=%exe_dir%;%path% && set cmd_line=start /B !exe_dir!\%remedybg_exe% && shift
if "%option%"=="node" set "exe_dir=%node_dir%\%1" && set path=%exe_dir%;%path% && set cmd_line=!exe_dir!\%2 && shift && shift
if "%option%"=="virustotal" for /f "delims=" %%a in ('powershell -Command "(Get-FileHash \"%1\" -Algorithm SHA256).Hash"') do set virustotal_hash=%%a && shift
if "%option%"=="virustotal" set cmd_line=start /B %virustotal_url%/%virustotal_hash%
if "%cmd_line%"=="" set option=help
if "%option%"=="help" (
for /f "delims=" %%a in ('dir /B %clang_dir%') do set "clang_versions=%%a !clang_versions!"
for /f "delims=" %%a in ('dir /B %cmake_dir%') do set "cmake_versions=%%a !cmake_versions!"
for /f "delims=" %%a in ('dir /B %remedybg_dir%') do set "remedybg_versions=%%a !remedybg_versions!"
for /f "delims=" %%a in ('dir /B %node_dir%') do set "node_versions=%%a !node_versions!"
echo USAGE: dev [option] [args...]
echo.
echo NOTES:
echo Commands suffixed with '_env' augment the system path with the path to the tool for the
echo current shell session.
echo.
echo OPTIONS:
echo cmake [version] [exe] CMake build system: '%cmake_dir%\[version]\[exe] %cmake_args%'
echo Versions: !cmake_versions!
echo.
echo clang [version] [exe] CLANG compiler: '%clang_dir%\[version]\[exe] %clang_args%'
echo Example: 'dev clang 18.1.4 clang++.exe --help'
echo Versions: !clang_versions!
echo.
echo node [version] [exe] Node JS: '%node_dir%\[version]\[exe]'
echo Versions: !node_versions!
echo.
echo raddbg RAD debugger: '%raddbg_dir%\%raddbg_exe% %raddbg_args%'
echo raddbg_env [cmd...] '%raddbg_dir%;[PATH]'
echo radlink RAD linker: '%radlink_dir%\%radlink_exe%'
echo radlink_env [cmd...] '%radlink_dir%;[PATH]'
echo rad_update Update the RAD linker and debugger: '%rad_update_dir%\%rad_update_exe%'
echo remedybg [version] C/C++ debugger: '%remedybg_dir%\%remedybg_exe%'
echo Versions: !remedybg_versions!
echo.
echo virustotal [file] Lookup file SHA256 hash on VirusTotal: '%virustotal_url%/[file]'
goto :eof
)
:: Extract user arguments ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:extract_args
if "%~1" neq "" (
set user_args=%user_args% %1
shift
goto :extract_args
)
:trim_user_args_trailing_space
if "!user_args:~-1!"==" " (
set user_args=!user_args:~0,-1!
goto trim_user_args_trailing_space
)
:trim_cmd_line_trailing_space
if "!cmd_line:~-1!"==" " (
set cmd_line=!cmd_line:~0,-1!
goto trim_cmd_line_trailing_space
)
:: Eval ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo DEV: Running "%script_path%" with "%cmd_line%%user_args%"
call %cmd_line%%user_args%
goto :eof

View File

@ -0,0 +1,3 @@
@echo off
call %devenver_root%\msvc\msvc-14.41.bat
call %devenver_root%\msvc\win-sdk-22621.bat