ソースをダウンロードしてビルド、アーカイブを作成するバッチファイルです。
必要
VS2019
こちらの記事を参考にインストールしてください。
VS2017でもビルドできると思いますが、確認はしていません。
Git for Windows
公式サイトの「Download」をクリックします。
インストールで特に変更するところはありません。
7-Zip
公式サイトからダウンロードしてインストールします。
バッチファイル
拡張子を.batにして保存します。
@echo off setlocal cd /d %~dp0 set ARCH=x86 set RUNTIME=dynamic set TARGET=Build set CONFIG=Release set REPO_DIR=TVTest set OUT_DIR=package for %%i in (%*) do ( if /i "%%i" == "x86" set ARCH=x86 if /i "%%i" == "x64" set ARCH=x64 if /i "%%i" == "Both" set ARCH=Both if /i "%%i" == "dynamic" set RUNTIME=dynamic if /i "%%i" == "MD" set RUNTIME=dynamic if /i "%%i" == "static" set RUNTIME=static if /i "%%i" == "MT" set RUNTIME=static if /i "%%i" == "Build" set TARGET=Build if /i "%%i" == "Rebuild" set TARGET=Rebuild if /i "%%i" == "Clean" set TARGET=Clean if /i "%%i" == "Debug" set CONFIG=Debug if /i "%%i" == "Release" set CONFIG=Release ) if not exist "%REPO_DIR%" ( git clone -b develop --recursive https://github.com/DBCTRADO/TVTest.git "%REPO_DIR%" ) cd /d "%REPO_DIR%" for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do ( set VS_INSTALL_DIR=%%i ) call "%VS_INSTALL_DIR%\Common7\Tools\VsDevCmd.bat" -no_logo set TOOLSET=v141 if "%VisualStudioVersion%" == "16.0" set TOOLSET=v142 if /i "%ARCH%" == "Both" ( call :Build x86 if errorlevel 1 exit /b 1 call :Build x64 if errorlevel 1 exit /b 1 ) else ( call :Build %ARCH% if errorlevel 1 exit /b 1 ) exit /b :Build set ARCH=%1 if /i "%ARCH%" == "x86" ( set PLATFORM=Win32 ) else ( set PLATFORM=%ARCH% ) if /i "%CONFIG%" == "Debug" set RUNTIME= set SRC_CONFIG=%CONFIG% if /i "%RUNTIME%" == "dynamic" set SRC_CONFIG=%SRC_CONFIG%_MD pushd src\LibISDB\Projects MSBuild LibISDB.sln /nologo /m /t:%TARGET% /p:Configuration=%SRC_CONFIG%;Platform=%ARCH%;PlatformToolset=%TOOLSET% if errorlevel 1 exit /b 1 popd pushd src MSBuild TVTest_All.sln /nologo /m /t:%TARGET% /p:Configuration=%SRC_CONFIG%;Platform=%PLATFORM%;PlatformToolset=%TOOLSET% if errorlevel 1 exit /b 1 popd set PLUGIN_CONFIG=%CONFIG% if /i "%RUNTIME%" == "static" set PLUGIN_CONFIG=%PLUGIN_CONFIG%_static pushd sdk\Samples MSBuild Samples.sln /nologo /m /t:%TARGET% /p:Configuration=%PLUGIN_CONFIG%;Platform=%PLATFORM%;PlatformToolset=%TOOLSET% if errorlevel 1 exit /b 1 popd if /i "%TARGET%" == "Clean" exit /b package.sh -a %ARCH% -c "%RUNTIME%" -t %CONFIG% -o "%OUT_DIR%" exit /b
使い方
コマンドプロンプトでバッチファイルを実行するときに引数を指定します。
バッチファイル [x86|x64|Both] [dynamic|static] [Build|Rebuild|Clean] [Debug|Release]
引数のデフォルト値は以下です。
バッチファイル x86 dynamic Build Release
x86は32bit版、x64は64bit版、Bothは32bit版と64bit版の両方です。
dynamicは動的リンク、staticは静的リンクです。
dynamicの代わりにMD、staticの代わりにMTを指定することもできます。
バッチファイルと同じフォルダにある TVTest\package に出力されます。
ソースのダウンロード先を変更する場合は「set REPO_DIR=」にフォルダパスを書きます。
アーカイブの出力先を変更する場合は「set OUT_DIR=」にフォルダパスを書きます。
コメント
バッチコンパイルする場合はWindows10のSDKが必要になるようです。VS2019インストール時に特定SDKをあわせてインストールすることで回避できました。