Created
November 29, 2018 15:10
-
-
Save KageShiron/7151271514e1d4144b8d4999d1187d0b to your computer and use it in GitHub Desktop.
find-tools.batの編集案
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: ビルドツールのパスを見つける | |
:: | |
:: ===7z.exeのパスを探索する手順=== | |
:: 1. CMD_7Zがセットされていれば利用する | |
:: 2. パスが通っていればそれを使う | |
:: 3. デフォルトのインストールパスで見つかればそれを使う | |
:: 4. 1~3で見つからなければCMD_7Zを削除する | |
@echo off | |
if defined FIND_TOOLS_CALLED ( | |
echo find-tools.bat already called | |
exit /b | |
) | |
setlocal | |
set SEARCHPATH=%PATH%;%ProgramFiles%\__APPDIR__\;%ProgramFiles(x86)%\__APPDIR__\;%ProgramW6432%\__APPDIR__\; | |
:: CMD_*が定義されていなければ探索ルーチンへ | |
echo find-tools.bat | |
if not defined CMD_7Z call :7z 2> nul | |
if not defined CMD_HHC call :hhc 2> nul | |
if not defined CMD_ISCC call :iscc 2> nul | |
if not defined CMD_CPPCHECK call :cppcheck 2> nul | |
if not defined CMD_DOXYGEN call :doxygen 2> nul | |
if not defined CMD_MSBUILD call :msbuild 2> nul | |
endlocal && set "CMD_7Z=%CMD_7Z%" && set "CMD_HHC=%CMD_HHC%" && set "CMD_ISCC=%CMD_ISCC%" && set "CMD_CPPCHECK=%CMD_CPPCHECK%" && set "CMD_DOXYGEN=%CMD_DOXYGEN%"&& set "CMD_MSBUILD=%CMD_MSBUILD%" | |
echo ├─ CMD_7Z=%CMD_7Z% | |
echo ├─ CMD_HHC=%CMD_HHC% | |
echo ├─ CMD_ISCC=%CMD_ISCC% | |
echo ├─ CMD_CPPCHECK=%CMD_CPPCHECK% | |
echo ├─ CMD_DOXYGEN=%CMD_DOXYGEN% | |
echo └─ CMD_MSBUILD=%CMD_MSBUILD% | |
set FIND_TOOLS_CALLED=1 | |
exit /b | |
:7z | |
PATH=%SEARCHPATH:__APPDIR__=7-Zip% | |
:: whereの出力の1行目をCMD_7Zに代入 | |
for /f "usebackq delims=" %%a in (`where 7z`) do ( | |
set "CMD_7Z=%%a" | |
exit /b | |
) | |
exit /b | |
:hhc | |
PATH=%SEARCHPATH:__APPDIR__=HTML Help Workshop% | |
for /f "usebackq delims=" %%a in (`where hhc.exe`) do ( | |
set "CMD_HHC=%%a" | |
exit /b | |
) | |
exit /b | |
:iscc | |
PATH=%SEARCHPATH:__APPDIR__=Inno Setup 5% | |
for /f "usebackq delims=" %%a in (`where ISCC.exe`) do ( | |
set "CMD_ISCC=%%a" | |
exit /b | |
) | |
exit /b | |
:cppcheck | |
PATH=%SEARCHPATH:__APPDIR__=cppcheck% | |
for /f "usebackq delims=" %%a in (`where cppecheck.exe`) do ( | |
set "CMD_CPPCHECK=%%a" | |
exit /b | |
) | |
exit /b | |
:doxygen | |
PATH=%SEARCHPATH:__APPDIR__=doxygen\bin% | |
for /f "usebackq delims=" %%a in (`where doxygen.exe`) do ( | |
set "CMD_DOXYGEN=%%a" | |
exit /b | |
) | |
exit /b | |
:msbuild | |
:: ref https://github.com/Microsoft/vswhere | |
PATH=%SEARCHPATH:__APPDIR__=Microsoft Visual Studio\Installer% | |
for /f "usebackq tokens=*" %%i in (`vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do ( | |
set "CMD_MSBUILD=%%i\MSBuild\15.0\Bin\MSBuild.exe" | |
exit /b | |
) | |
exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment