From 41b48d1ff24428c0f75cb91d4198fd8d8f7a8e0f Mon Sep 17 00:00:00 2001 From: rabix Date: Sun, 27 Feb 2022 15:24:37 +0800 Subject: [PATCH] add templates --- bin/7zip.cmd | 4 +- bin/cmake.cmd | 4 +- bin/edit.cmd | 9 ++-- bin/g++.cmd | 4 +- bin/gcc.cmd | 4 +- bin/make.cmd | 4 +- bin/vid-init.cmd | 14 ++--- start.cmd | 6 +-- tools/7z.bat | 130 +++++++++++++++++++++++------------------------ 9 files changed, 89 insertions(+), 90 deletions(-) diff --git a/bin/7zip.cmd b/bin/7zip.cmd index 4a3c7b9..be4910d 100644 --- a/bin/7zip.cmd +++ b/bin/7zip.cmd @@ -1,2 +1,2 @@ -@echo off -call %VID_HOME%\tools\7z.bat %* \ No newline at end of file +@echo off +call "%VID_HOME%\tools\7z.bat" %* diff --git a/bin/cmake.cmd b/bin/cmake.cmd index 284daa0..8b477aa 100644 --- a/bin/cmake.cmd +++ b/bin/cmake.cmd @@ -1,2 +1,2 @@ -@echo off -call %VID_HOME%\tools\cmakew.bat %* \ No newline at end of file +@echo off +call "%VID_HOME%\tools\cmakew.bat" %* diff --git a/bin/edit.cmd b/bin/edit.cmd index 88740a3..a042755 100644 --- a/bin/edit.cmd +++ b/bin/edit.cmd @@ -1,5 +1,4 @@ -@echo off -setlocal -for /D %%A in (. %1) do set open=%%~dpnA -echo %open% -start "" %VID_HOME%\tools\lite\lite.exe %open% +@echo off +setlocal +for /D %%A in (. %1) do set open=%%~dpnA +start "" "%VID_HOME%\tools\lite\lite.exe" %open% diff --git a/bin/g++.cmd b/bin/g++.cmd index 0e2b0ae..2c83ef8 100644 --- a/bin/g++.cmd +++ b/bin/g++.cmd @@ -1,2 +1,2 @@ -@echo off -call %VID_HOME%\tools\6.0g-mingw64.bat g++ %* \ No newline at end of file +@echo off +call "%VID_HOME%\tools\6.0g-mingw64.bat" g++ %* diff --git a/bin/gcc.cmd b/bin/gcc.cmd index a0bac38..077b691 100644 --- a/bin/gcc.cmd +++ b/bin/gcc.cmd @@ -1,2 +1,2 @@ -@echo off -call %VID_HOME%\tools\6.0g-mingw64.bat gcc %* \ No newline at end of file +@echo off +call "%VID_HOME%\tools\6.0g-mingw64.bat" gcc %* diff --git a/bin/make.cmd b/bin/make.cmd index 74d74f2..4583b41 100644 --- a/bin/make.cmd +++ b/bin/make.cmd @@ -1,2 +1,2 @@ -@echo off -call %VID_HOME%\tools\6.0g-mingw64.bat mingw32-make %* \ No newline at end of file +@echo off +call "%VID_HOME%\tools\6.0g-mingw64.bat" mingw32-make %* diff --git a/bin/vid-init.cmd b/bin/vid-init.cmd index 4693dc2..b5fc53e 100644 --- a/bin/vid-init.cmd +++ b/bin/vid-init.cmd @@ -1,7 +1,7 @@ -@echo off -set fn=%VID_HOME%\templates\%1.7z -if exist %fn% ( - call %VID_HOME%\tools\7z.bat x -o. -y %fn% -) else ( - echo Template %1 not found -) \ No newline at end of file +@echo off +set fn="%VID_HOME%\templates\%1.7z" +if exist %fn% ( + call "%VID_HOME%\tools\7z.bat" x -o. -y %fn% +) else ( + echo Template %1 not found +) diff --git a/start.cmd b/start.cmd index 538e240..bb64490 100644 --- a/start.cmd +++ b/start.cmd @@ -1,4 +1,4 @@ -@echo off -set VID_HOME=%~dp0 -set PATH=%~dp0\bin;%PATH% +@echo off +set VID_HOME=%~dp0 +set PATH=%~dp0\bin;%PATH% cmd /k \ No newline at end of file diff --git a/tools/7z.bat b/tools/7z.bat index bd2e9a0..dd7c273 100644 --- a/tools/7z.bat +++ b/tools/7z.bat @@ -1,66 +1,66 @@ -@echo off -setlocal ENABLEEXTENSIONS -setlocal enableDelayedExpansion - -@rem set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem get script directory name -set DIRNAME=%~dp0\..\.cache -if "%DIRNAME%" == "" set DIRNAME=. - -@rem strip trailing backslash from DIRNAME path to make it easier to work with -IF %DIRNAME:~-1%==\ SET DIRNAME=%DIRNAME:~0,-1% - -@rem get OS bitness -reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS_BITNESS=32BIT || set OS_BITNESS=64BIT - -set UNZIP_EXE=%DIRNAME%\7zip\7z.exe - -@rem require 7zip to unzip the cmake dist because windows sucks -if not exist %UNZIP_EXE% ( - echo Downloading 7zip... - - if %OS_BITNESS%==64BIT ( - call :downloadFile https://www.7-zip.org/a/7z1801-x64.exe %TEMP%\7zInstall.exe - ) else ( - call :downloadFile https://www.7-zip.org/a/7z1801.exe %TEMP%\7zInstall.exe - ) - - echo Installing 7zip - - @rem don't forget the trailing backslash here because 7zip is too stupid to deal with paths and just removes the last char - %TEMP%\7zInstall.exe /S /D=%DIRNAME%\7zip\ - del %TEMP%\7zInstall.exe -) -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto runCmake - -set CMD_LINE_ARGS=%* -goto runCmake - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:runCmake - -%UNZIP_EXE% %CMD_LINE_ARGS% -goto end - - -@rem args: fileUrl, filePath -:downloadFile -powershell -Command "(New-Object Net.WebClient).DownloadFile('%~1', '%~2')" -EXIT /B 0 - -:end +@echo off +setlocal ENABLEEXTENSIONS +setlocal enableDelayedExpansion + +@rem set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem get script directory name +set DIRNAME=%~dp0\..\.cache +if "%DIRNAME%" == "" set DIRNAME=. + +@rem strip trailing backslash from DIRNAME path to make it easier to work with +IF %DIRNAME:~-1%==\ SET DIRNAME=%DIRNAME:~0,-1% + +@rem get OS bitness +reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set OS_BITNESS=32BIT || set OS_BITNESS=64BIT + +set UNZIP_EXE=%DIRNAME%\7zip\7z.exe + +@rem require 7zip to unzip the cmake dist because windows sucks +if not exist %UNZIP_EXE% ( + echo Downloading 7zip... + + if %OS_BITNESS%==64BIT ( + call :downloadFile https://www.7-zip.org/a/7z1801-x64.exe %TEMP%\7zInstall.exe + ) else ( + call :downloadFile https://www.7-zip.org/a/7z1801.exe %TEMP%\7zInstall.exe + ) + + echo Installing 7zip + + @rem don't forget the trailing backslash here because 7zip is too stupid to deal with paths and just removes the last char + %TEMP%\7zInstall.exe /S /D=%DIRNAME%\7zip\ + del %TEMP%\7zInstall.exe +) +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto runCmake + +set CMD_LINE_ARGS=%* +goto runCmake + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:runCmake + +%UNZIP_EXE% %CMD_LINE_ARGS% +goto end + + +@rem args: fileUrl, filePath +:downloadFile +powershell -Command "(New-Object Net.WebClient).DownloadFile('%~1', '%~2')" +EXIT /B 0 + +:end if "%OS%"=="Windows_NT" endlocal \ No newline at end of file