ソースをダウンロードしてビルド、アーカイブを作成するバッチファイルです。
必要
VS2019
こちらの記事を参考にインストールしてください。
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 CLONE_DIR= 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 defined CLONE_DIR ( if not exist "%CLONE_DIR%" md "%CLONE_DIR%" cd /d "%CLONE_DIR%" ) if not exist BonDriver_BDA git clone --recursive https://github.com/radi-sh/BonDriver_BDA.git if not exist BDASpecial-PlexPX git clone https://github.com/radi-sh/BDASpecial-PlexPX.git if not exist Rijndael4plex git clone https://github.com/radi-sh/Rijndael4plex.git if not exist BDASpecial-IT35 git clone https://github.com/radi-sh/BDASpecial-IT35.git if not exist BDASpecial-DD git clone https://github.com/radi-sh/BDASpecial-DD.git if not exist BDASpecial-LWire git clone https://github.com/radi-sh/BDASpecial-LWire.git echo .gitmodules> exclude.txt echo README.md>> exclude.txt xcopy /e /v /y /exclude:exclude.txt BDASpecial-PlexPX BonDriver_BDA >nul xcopy /e /v /y /exclude:exclude.txt Rijndael4plex BonDriver_BDA >nul xcopy /e /v /y /exclude:exclude.txt BDASpecial-IT35 BonDriver_BDA >nul xcopy /e /v /y /exclude:exclude.txt BDASpecial-DD BonDriver_BDA >nul xcopy /e /v /y /exclude:exclude.txt BDASpecial-LWire BonDriver_BDA >nul del exclude.txt cd BonDriver_BDA 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 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 BUILD_CONFIG=%CONFIG% if /i "%RUNTIME%" == "static" set BUILD_CONFIG=%BUILD_CONFIG%_Static MSBuild BonDriver_BDA.sln /nologo /m /t:%TARGET% /p:Configuration=%BUILD_CONFIG%;Platform=%PLATFORM% if errorlevel 1 exit /b 1 if /i "%TARGET%" == "Clean" exit /b set SRC_BIN_DIR=%PLATFORM%\%BUILD_CONFIG% set DST_DIR=%OUT_DIR%\%ARCH%\%CONFIG% if exist "%DST_DIR%" rd /s /q "%DST_DIR%" md "%DST_DIR%" md "%DST_DIR%\bin" md "%DST_DIR%\doc" copy /v %SRC_BIN_DIR%\*.dll "%DST_DIR%\bin" >nul copy /v %SRC_BIN_DIR%\*.tvtp "%DST_DIR%\bin" >nul if /i "%CONFIG%" == "Release" ren "%DST_DIR%\bin\WinSCard-x3U4.dll" WinSCard.dll copy /v doc "%DST_DIR%\doc" >nul copy /v doc\WinSCard-x3U4 "%DST_DIR%\doc" >nul copy /v doc\x3U4Remocon "%DST_DIR%\doc" >nul for /f "usebackq tokens=*" %%i in (`git rev-parse --short HEAD`) do set GIT_HASH=%%i set ARCHIVE_NAME=%OUT_DIR%\BonDriver_BDA_%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] [dynamic|static] [Build|Rebuild|Clean] [Debug|Release]
引数のデフォルト値は以下です。
バッチファイル x86 dynamic Build Release
x86は32bit版、x64は64bit版、Bothは32bit版と64bit版の両方です。
dynamicは動的リンク、staticは静的リンクです。
dynamicの代わりにMD、staticの代わりにMTを指定することもできます。
バッチファイルと同じフォルダにある BonDriver_BDA\package に出力されます。
ソースのダウンロード先を変更する場合は「set CLONE_DIR=」にフォルダパスを書きます。
アーカイブの出力先を変更する場合は「set OUT_DIR=」にフォルダパスを書きます。
コメント