ソースをダウンロードしてビルド、アーカイブを作成するバッチファイルです。
必要
VS2019
こちらの記事を参考にインストールしてください。
VS2017でもビルドできると思いますが、確認はしていません。
Git for Windows
公式サイトの「Download」をクリックします。
インストールで特に変更するところはありません。
7-Zip
公式サイトからダウンロードしてインストールします。
バッチファイル
拡張子を.batにして保存します。
@echo off setlocal cd /d %~dp0 set ARCH=x86 set TARGET=Build set CONFIG=Release set REPO_DIR=libaribb25 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" == "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 https://github.com/epgdatacapbon/libaribb25.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 WINDOWS_SDK=10.0.17763.0 if "%VisualStudioVersion%" == "16.0" set WINDOWS_SDK=10.0 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% ) MSBuild arib_std_b25.sln /nologo /m /t:%TARGET% /p:Configuration=%CONFIG%;Platform=%PLATFORM%;WindowsTargetPlatformVersion=%WINDOWS_SDK%;PlatformToolset=%TOOLSET% if errorlevel 1 exit /b 1 if /i "%TARGET%" == "Clean" exit /b set SRC_BIN_DIR=%PLATFORM%\%CONFIG% set DST_DIR=%OUT_DIR%\%ARCH%\%CONFIG% if exist "%DST_DIR%" rd /s /q "%DST_DIR%" md "%DST_DIR%" copy /v %SRC_BIN_DIR%\libaribb25.dll "%DST_DIR%\B25Decoder.dll" >nul for /f "usebackq tokens=*" %%i in (`git rev-parse --short HEAD`) do set GIT_HASH=%%i set ARCHIVE_NAME=%OUT_DIR%\B25Decoder_%GIT_HASH%_%ARCH% for /f "usebackq tokens=1,2*" %%i in (`reg query HKLM\Software\7-Zip /v Path`) do if "%%i" == "Path" set PATH=%%k;%PATH% 7z a "%ARCHIVE_NAME%.7z" ".\%DST_DIR%\*" -mx=9 -ms=on -myx=9 exit /b
使い方
コマンドプロンプトでバッチファイルを実行するときに引数を指定します。
バッチファイル [x86|x64|Both] [Build|Rebuild|Clean] [Debug|Release]
引数のデフォルト値は以下です。
バッチファイル x86 Build Release
x86は32bit版、x64は64bit版、Bothは32bit版と64bit版の両方です。
バッチファイルと同じフォルダにある libaribb25\package に出力されます。
ソースのダウンロード先を変更する場合は「set REPO_DIR=」にフォルダパスを書きます。
アーカイブの出力先を変更する場合は「set OUT_DIR=」にフォルダパスを書きます。
コメント