2020-07-20 13:27:23 +00:00
|
|
|
@echo off
|
2021-07-15 07:39:40 +00:00
|
|
|
setlocal EnableDelayedExpansion
|
2020-10-20 23:29:27 +00:00
|
|
|
|
2020-11-03 02:52:22 +00:00
|
|
|
set root=%~dp0
|
2021-07-15 07:39:40 +00:00
|
|
|
set home=!root!\home
|
|
|
|
set cmder_root=!root!\Cmder
|
|
|
|
set installer_root=!root!\Installer
|
|
|
|
set vim_root=!home!\vimfiles
|
|
|
|
set tools_root=!root!\Tools
|
|
|
|
set compiler_root=!tools_root!\Compiler
|
|
|
|
|
|
|
|
if not exist !home! mkdir !home!
|
|
|
|
if not exist !installer_root! mkdir !installer_root!
|
|
|
|
if not exist !tools_root! mkdir !tools_root!
|
|
|
|
if not exist !compiler_root! mkdir !compiler_root!
|
|
|
|
|
|
|
|
REM ----------------------------------------------------------------------------
|
2020-07-20 13:27:23 +00:00
|
|
|
REM Cmder
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ----------------------------------------------------------------------------
|
2020-10-20 23:49:24 +00:00
|
|
|
set cmder_version=v1.3.16
|
2021-07-15 07:39:40 +00:00
|
|
|
set cmder_zip=!installer_root!\win32_cmder_!cmder_version!.7z
|
|
|
|
call :DownloadFile https://github.com/cmderdev/cmder/releases/download/!cmder_version!/cmder.7z "!cmder_zip!" || exit /b
|
|
|
|
call :Unzip "!cmder_zip!" "!cmder_root!" || exit /b
|
2020-07-20 13:27:23 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ----------------------------------------------------------------------------
|
2020-11-04 14:27:24 +00:00
|
|
|
REM Misc Tools
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ----------------------------------------------------------------------------
|
2020-11-04 14:27:24 +00:00
|
|
|
REM clang-format: C/C++ formatting tool
|
|
|
|
REM ctags: C/C++ code annotation generator
|
|
|
|
REM scanmapset: Bind capslock to escape via registry
|
|
|
|
REM uncap: Bind capslock to escape via run-time program
|
2021-01-06 23:23:02 +00:00
|
|
|
REM clang-format: Default clang-format style
|
2021-07-15 07:39:40 +00:00
|
|
|
call :CopyFile "!installer_root!\win32_clang_format.exe" "!cmder_root!\bin\clang-format.exe" || exit /b
|
|
|
|
call :CopyFile "!installer_root!\win32_ctags.exe" "!cmder_root!\bin\ctags.exe" || exit /b
|
|
|
|
call :CopyFile "!installer_root!\win32_scanmapset.exe" "!cmder_root!\bin\scanmapset.exe" || exit /b
|
|
|
|
call :CopyFile "!installer_root!\win32_uncap.exe" "!cmder_root!\bin\uncap.exe" || exit /b
|
|
|
|
call :CopyFile "!installer_root!\clang-format-style-file" "!home!\_clang-format" || exit /b
|
2020-07-20 13:27:23 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ----------------------------------------------------------------------------
|
2020-11-04 14:27:24 +00:00
|
|
|
REM GVim, Vim Plug, Vim Config
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ----------------------------------------------------------------------------
|
|
|
|
set gvim_zip=!installer_root!\win32_gvim_x64.7z
|
|
|
|
set gvim_path=!tools_root!\GVim
|
|
|
|
call :DownloadFile https://tuxproject.de/projects/vim/complete-x64.7z !gvim_zip! || exit /b
|
|
|
|
call :Unzip "!gvim_zip!" "!gvim_path!" || exit /b
|
2020-11-04 14:27:24 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
call :CopyFile "!installer_root!\_vimrc" "!home!" || exit /b
|
|
|
|
call :CopyFile "!installer_root!\win32_gvim_fullscreen.dll" "!gvim_path!\gvim_fullscreen.dll" || exit /b
|
2020-11-04 14:27:24 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
set vim_plug_path=!vim_root!\autoload
|
|
|
|
set vim_plug=!vim_plug_path!\plug.vim
|
|
|
|
if not exist "!vim_plug_path!" mkdir "!vim_plug_path!"
|
|
|
|
call :DownloadFile https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim "!vim_plug!" || exit /b
|
2020-07-20 13:27:23 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
set vim_clang_format=!vim_root!\clang-format.py
|
|
|
|
call :DownloadFile https://raw.githubusercontent.com/llvm/llvm-project/main/clang/tools/clang-format/clang-format.py "!vim_clang_format!" || exit /b
|
2021-01-06 23:23:02 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ----------------------------------------------------------------------------
|
2020-11-04 14:27:24 +00:00
|
|
|
REM ripgrep
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ----------------------------------------------------------------------------
|
|
|
|
set rg_zip=!installer_root!\win32_rg_v12.1.1.7z
|
|
|
|
set rg_exe=!cmder_root!\bin\rg.exe
|
|
|
|
call :Unzip "!rg_zip!" "!cmder_root!\bin" || exit /b
|
2020-07-20 13:27:23 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ----------------------------------------------------------------------------
|
2020-11-04 14:27:24 +00:00
|
|
|
REM Zig
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ----------------------------------------------------------------------------
|
|
|
|
set zig_sha256=8580fbbf3afb72e9b495c7f8aeac752a03475ae0bbcf5d787f3775c7e1f4f807
|
|
|
|
set zig_version=0.8.0
|
|
|
|
set zig_file=zig-windows-x86_64-!zig_version!.zip
|
|
|
|
set zig_zip=!installer_root!\win32_!zig_file!
|
|
|
|
set zig_path=!compiler_root!\zig-windows-x86_64-!zig_version!
|
|
|
|
call :DownloadFile https://ziglang.org/download/!zig_version!/!zig_file! !zig_zip! || exit /b
|
|
|
|
call :VerifyFile !zig_zip! !zig_sha256!
|
|
|
|
call :Unzip "!zig_zip!" "!compiler_root!" || exit /b
|
|
|
|
|
|
|
|
REM ----------------------------------------------------------------------------
|
2020-11-04 14:27:24 +00:00
|
|
|
REM Python
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ----------------------------------------------------------------------------
|
2020-11-04 14:27:24 +00:00
|
|
|
set python_version=3.9.0.2dot
|
|
|
|
set python_version_nodot=3902
|
2021-07-15 07:39:40 +00:00
|
|
|
set python_url=https://github.com/winpython/winpython/releases/download/3.0.20201028/Winpython64-!python_version!.exe
|
|
|
|
set python_zip=!installer_root!\win32_Winpython64-!python_version!.exe
|
|
|
|
set python_path=!tools_root!\WPy64-!python_version_nodot!
|
|
|
|
call :DownloadFile !python_url! "!python_zip!" || exit /b
|
|
|
|
call :Unzip "!python_zip!" "!tools_root!" || exit /b
|
2020-11-02 12:33:46 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ----------------------------------------------------------------------------
|
2020-11-04 14:27:24 +00:00
|
|
|
REM Generate Cmder Startup Config File
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ----------------------------------------------------------------------------
|
|
|
|
set cmder_config_file=!cmder_root!\config\user_profile.cmd
|
|
|
|
echo - Generate cmder config at !cmder_config_file!
|
|
|
|
echo @echo off> !cmder_config_file!
|
|
|
|
echo set PATH=!zig_path!;%%PATH%%>> "!cmder_config_file!"
|
|
|
|
echo set PATH=!python_path!\python-3.9.0.amd64;%%PATH%%>> "!cmder_config_file!"
|
|
|
|
echo set PATH=!python_path!\python-3.9.0.amd64\Scripts;%%PATH%%>> "!cmder_config_file!"
|
|
|
|
echo set PYTHONHOME=!python_path!\python-3.9.0.amd64>> "!cmder_config_file!"
|
|
|
|
echo set HOME=!cmder_root!\..\Home>> "!cmder_config_file!"
|
|
|
|
echo set HOMEPATH=!cmder_root!\..\Home>> "!cmder_config_file!"
|
|
|
|
echo set USERPROFILE=!cmder_root!\..\Home>> "!cmder_config_file!"
|
|
|
|
echo alias gvim=!cmder_root!\..\Tools\GVim\gvim.exe $*>> "!cmder_config_file!"
|
|
|
|
|
|
|
|
REM ----------------------------------------------------------------------------
|
2020-11-24 04:15:27 +00:00
|
|
|
REM CTags Helper Script
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ----------------------------------------------------------------------------
|
|
|
|
set ctags_file=!cmder_root!\bin\ctags_cpp.bat
|
|
|
|
echo @echo off> !ctags_file!
|
|
|
|
echo ctags --c++-kinds=+p --fields=+iaS --extras=+q !!*>> !ctags_file!
|
2020-11-24 04:15:27 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
echo - Setup complete. Launch !cmder_root!\cmder.exe [or restart Cmder instance if you're updating an existing installation]
|
2020-11-04 14:27:24 +00:00
|
|
|
exit /b
|
2020-11-03 02:52:22 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ------------------------------------------------------------------------------------------------
|
2020-11-04 14:27:24 +00:00
|
|
|
REM Functions
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ------------------------------------------------------------------------------------------------
|
2020-11-04 14:27:24 +00:00
|
|
|
:DownloadFile
|
|
|
|
set url=%~1
|
|
|
|
set dest_file=%~2
|
2021-07-15 07:39:40 +00:00
|
|
|
set msg=[Download File] !url! to !dest_file!
|
2020-10-19 22:16:04 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
if exist !dest_file! (
|
|
|
|
echo - [Cached] !msg!
|
|
|
|
) else (
|
|
|
|
echo - !msg!
|
|
|
|
call powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest !url! -OutFile !dest_file! -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox"
|
|
|
|
)
|
2020-10-19 22:16:04 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
if not exist !dest_file! echo [Download File] Failed to download file from !url!
|
|
|
|
exit /B !ERRORLEVEL!
|
|
|
|
|
|
|
|
REM ------------------------------------------------------------------------------------------------
|
2020-11-04 14:27:24 +00:00
|
|
|
:CopyFile
|
|
|
|
set src_file=%~1
|
|
|
|
set dest_file=%~2
|
2020-10-20 23:49:24 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
call copy /Y !src_file! !dest_file! > nul
|
|
|
|
if exist "!dest_file!" echo - [Copy] !src_file! to !dest_file!
|
|
|
|
if not exist "!dest_file!" echo - [Copy] Failed to copy file from !src_file! to !dest_file!
|
|
|
|
exit /B !ERRORLEVEL!
|
2020-11-03 02:52:22 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
REM ------------------------------------------------------------------------------------------------
|
2020-11-04 14:27:24 +00:00
|
|
|
:Unzip
|
|
|
|
set zip_file=%~1
|
|
|
|
set dest=%~2
|
2021-07-15 07:39:40 +00:00
|
|
|
set msg=[Unzip] !zip_file! to !dest!
|
2020-11-03 03:32:35 +00:00
|
|
|
|
2021-07-15 07:39:40 +00:00
|
|
|
if exist !dest! (
|
|
|
|
echo - [Cached] !msg!
|
|
|
|
) else (
|
|
|
|
echo - !msg!
|
|
|
|
call !installer_root!\win32_7za.exe x -y -o!dest! !zip_file!
|
|
|
|
)
|
|
|
|
exit /B
|
|
|
|
|
|
|
|
REM ------------------------------------------------------------------------------------------------
|
|
|
|
:VerifyFile
|
|
|
|
set file=%~1
|
|
|
|
set expected_sha256=%~2
|
|
|
|
|
|
|
|
REM Calculate hash
|
|
|
|
set calculated_sha256_file=!file!.sha256.txt
|
|
|
|
call powershell "$FileHash = Get-FileHash -algorithm sha256 !file!; $FileHash.Hash.ToLower()" > !calculated_sha256_file!
|
|
|
|
|
|
|
|
REM Verify Hash
|
|
|
|
set /p actual_sha256=< !calculated_sha256_file!
|
|
|
|
if "!expected_sha256!" neq "!actual_sha256!" (
|
|
|
|
echo - [Verify] Hash BAD: Expected: !expected_sha256!
|
|
|
|
echo Calculated: !actual_sha256!
|
|
|
|
exit /B -1
|
|
|
|
) else (
|
|
|
|
echo - [Verify] Hash OK: !expected_sha256!
|
|
|
|
exit /B 0
|
|
|
|
)
|