ソースをダウンロードしてビルド、アーカイブを作成するバッチファイルです。
TVTestに加えて以下をビルドします。
- CasProcessor
- B25.tvcas
- TVTestVideoDecoder
- TvtPlay
- NicoJK
- jkcnsl
- TVCaptionMod2
必要
Visual Studio
2019以降でビルドできます。
こちらの記事を参考にインストールしてください。
2022で動作確認しています。
Git for Windows
公式サイトの「Download」をクリックします。
インストールで特に変更するところはありません。
7-Zip
公式サイトからダウンロードしてインストールします。
バッチファイル
拡張子を.batにして保存します。
@echo off
setlocal
cd /d %~dp0
rem デフォルト設定
set ARCH=x86
set RUNTIME=dynamic
set TARGET=Build
set CONFIG=Release
set REPO_DEL=False
set CLONE_DIR=
set OUT_DIR=TVTest\package
rem 引数の取得
for %%i in (%*) do (
if /i "%%i" == "help" goto Help
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 /i "%%i" == "del" set REPO_DEL=True
)
if defined CLONE_DIR (
if not exist "%CLONE_DIR%" md "%CLONE_DIR%"
cd /d "%CLONE_DIR%"
)
if /i "%REPO_DEL%" == "True" (
if exist TVTest rd /s /q TVTest
if exist CasProcessor rd /s /q CasProcessor
if exist TvCas rd /s /q TvCas
if exist TVTestVideoDecoder rd /s /q TVTestVideoDecoder
if exist TvtPlay rd /s /q TvtPlay
if exist NicoJK rd /s /q NicoJK
if exist jkcnsl rd /s /q jkcnsl
if exist TVCaptionMod2 rd /s /q TVCaptionMod2
)
rem ソースのダウンロード
if not exist TVTest git clone -b develop --recursive https://github.com/DBCTRADO/TVTest.git
if not exist CasProcessor git clone https://github.com/logue/CasProcessor.git
if not exist TvCas git clone https://github.com/logue/TvCas.git
if not exist TVTestVideoDecoder git clone https://github.com/DBCTRADO/TVTestVideoDecoder.git
if not exist TvtPlay git clone -b work-plus https://github.com/xtne6f/TvtPlay.git
if not exist NicoJK git clone https://github.com/xtne6f/NicoJK.git
if not exist jkcnsl git clone https://github.com/xtne6f/jkcnsl.git
if not exist TVCaptionMod2 git clone https://github.com/xtne6f/TVCaptionMod2.git
copy /v /y TVTest\src\TVTestPlugin.h CasProcessor >nul
copy /v /y TVTest\src\TVTestInterface.h CasProcessor >nul
rem Visual Studioのインストールフォルダの検索
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
)
rem 開発者コマンドプロンプトの起動
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 0
:Build
set ARCH=%1
if /i "%ARCH%" == "x86" (
set PLATFORM=Win32
) else (
set PLATFORM=%ARCH%
)
set TOOLSET=v142
if "%VisualStudioVersion%" == "17.0" set TOOLSET=v143
if /i "%CONFIG%" == "Debug" set RUNTIME=
set TVTEST_CONFIG=%CONFIG%
if /i "%RUNTIME%" == "dynamic" set TVTEST_CONFIG=%TVTEST_CONFIG%_MD
set PLUGIN_CONFIG=%CONFIG%
if /i "%RUNTIME%" == "static" set PLUGIN_CONFIG=%PLUGIN_CONFIG%_static
rem ビルド
pushd TVTest\src\LibISDB\Projects
MSBuild LibISDB.sln /nologo /m /t:%TARGET% /p:Configuration=%TVTEST_CONFIG%;Platform=%ARCH%
popd
if errorlevel 1 exit /b 1
pushd TVTest\src
MSBuild TVTest.sln /nologo /m /t:%TARGET% /p:Configuration=%TVTEST_CONFIG%;Platform=%PLATFORM%
popd
if errorlevel 1 exit /b 1
pushd TVTest\sdk\Samples
MSBuild Samples.sln /nologo /m /t:%TARGET% /p:Configuration=%PLUGIN_CONFIG%;Platform=%PLATFORM%
popd
if errorlevel 1 exit /b 1
pushd CasProcessor
MSBuild CasProcessor.sln /nologo /m /t:%TARGET% /p:Configuration=%CONFIG%;Platform=%PLATFORM%;PlatformToolset=%TOOLSET%;WindowsTargetPlatformVersion=10.0
popd
if errorlevel 1 exit /b 1
pushd TvCas
MSBuild TvCas.sln /nologo /m /t:%TARGET% /p:Configuration=%CONFIG%;Platform=%ARCH%;PlatformToolset=%TOOLSET%;WindowsTargetPlatformVersion=10.0
popd
if errorlevel 1 exit /b 1
pushd TVTestVideoDecoder\src
MSBuild TVTestVideoDecoder.sln /nologo /m /t:%TARGET% /p:Configuration=%CONFIG%;Platform=%PLATFORM%
popd
if errorlevel 1 exit /b 1
pushd TvtPlay\src
MSBuild TvtPlay.sln /nologo /m /t:%TARGET% /p:Configuration=%CONFIG%;Platform=%PLATFORM%;PlatformToolset=%TOOLSET%;WindowsTargetPlatformVersion=10.0
popd
if errorlevel 1 exit /b 1
pushd TvtPlay\BonDriver_Pipe_src
MSBuild BonDriver_Pipe.sln /nologo /m /t:%TARGET% /p:Configuration=%CONFIG%;Platform=%PLATFORM%;PlatformToolset=%TOOLSET%;WindowsTargetPlatformVersion=10.0
popd
if errorlevel 1 exit /b 1
pushd TvtPlay\TvtAudioStretchFilter_src\baseclasses
MSBuild BaseClasses_VC14.sln /nologo /m /t:%TARGET% /p:Configuration=%CONFIG%;Platform=%PLATFORM%;PlatformToolset=%TOOLSET%;WindowsTargetPlatformVersion=10.0
popd
if errorlevel 1 exit /b 1
pushd TvtPlay\TvtAudioStretchFilter_src\soundtouch\source\SoundTouch
MSBuild SoundTouch.sln /nologo /m /t:%TARGET% /p:Configuration=%CONFIG%;Platform=%PLATFORM%;PlatformToolset=%TOOLSET%;WindowsTargetPlatformVersion=10.0
popd
if errorlevel 1 exit /b 1
pushd TvtPlay\TvtAudioStretchFilter_src
MSBuild TvtAudioStretchFilter.sln /nologo /m /t:%TARGET% /p:Configuration=%CONFIG%;Platform=%PLATFORM%;PlatformToolset=%TOOLSET%;WindowsTargetPlatformVersion=10.0
popd
if errorlevel 1 exit /b 1
pushd NicoJK
MSBuild NicoJK.sln /nologo /m /t:%TARGET% /p:Configuration=%CONFIG%;Platform=%PLATFORM%
popd
if errorlevel 1 exit /b 1
pushd jkcnsl
if /i not "%TARGET%" == "Build" (
if exist bin rd /s /q bin
if exist obj rd /s /q obj
)
if /i not "%TARGET%" == "Clean" (
dotnet publish --nologo -c %CONFIG% -r win-%ARCH% --self-contained true /p:Platform="Any CPU";PublishSingleFile=true;PublishTrimmed=true
)
popd
if errorlevel 1 exit /b 1
pushd TVCaptionMod2\Caption_src
MSBuild Caption.sln /nologo /m /t:%TARGET% /p:Configuration=%CONFIG%;Platform=%PLATFORM%;PlatformToolset=%TOOLSET%;WindowsTargetPlatformVersion=10.0
popd
if errorlevel 1 exit /b 1
pushd TVCaptionMod2\src
MSBuild TVCaption2.sln /nologo /m /t:%TARGET% /p:Configuration=%CONFIG%;Platform=%PLATFORM%;PlatformToolset=%TOOLSET%;WindowsTargetPlatformVersion=10.0
popd
if errorlevel 1 exit /b 1
if /i "%TARGET%" == "Clean" exit /b 0
rem TVTestのファイルの配置
pushd TVTest
package.sh -a %ARCH% -c "%RUNTIME%" -t %CONFIG% -l all -o package -r ""
popd
set SRC_DIR=%PLATFORM%\%CONFIG%
if /i "%ARCH%" == "x86" (
set SRC_DIR2=%CONFIG%
) else (
set SRC_DIR2=%SRC_DIR%
)
set DST_DIR=TVTest\package\%ARCH%\%CONFIG%
rem フォルダの準備
md "%DST_DIR%\Plugins\NicoJK"
rem ファイルの配置
copy /v CasProcessor\%SRC_DIR%\CasProcessor.tvtp "%DST_DIR%\Plugins" >nul
copy /v TvCas\%SRC_DIR%\B25.tvcas "%DST_DIR%" >nul
copy /v TVTestVideoDecoder\src\%SRC_DIR%\TVTestVideoDecoder.ax "%DST_DIR%" >nul
copy /v TVTestVideoDecoder\doc\TVTestVideoDecoder.txt "%DST_DIR%" >nul
copy /v TvtPlay\src\%SRC_DIR2%\TvtPlay.tvtp "%DST_DIR%\Plugins" >nul
copy /v TvtPlay\src\Buttons24.bmp "%DST_DIR%\Plugins\TvtPlay_Buttons24.bmp" >nul
copy /v TvtPlay\src\Buttons32.bmp "%DST_DIR%\Plugins\TvtPlay_Buttons32.bmp" >nul
copy /v TvtPlay\BonDriver_Pipe_src\%SRC_DIR2%\BonDriver_Pipe.dll "%DST_DIR%" >nul
copy /v TvtPlay\TvtAudioStretchFilter_src\%SRC_DIR2%\TvtAudioStretchFilter.ax "%DST_DIR%" >nul
copy /v TvtPlay\TvtPlay_Readme.txt "%DST_DIR%\Plugins" >nul
copy /v NicoJK\%SRC_DIR2%\*.exe "%DST_DIR%\Plugins\NicoJK" >nul
copy /v NicoJK\%SRC_DIR2%\NicoJK.tvtp "%DST_DIR%\Plugins" >nul
copy /v NicoJK\NicoJK.ini "%DST_DIR%\Plugins" >nul
copy /v NicoJK\Readme.txt "%DST_DIR%\Plugins\NicoJK_Readme.txt" >nul
copy /v jkcnsl\bin\%CONFIG%\net8.0\win-%ARCH%\publish\jkcnsl.exe "%DST_DIR%" >nul
copy /v jkcnsl\Readme.txt "%DST_DIR%\jkcnsl_Readme.txt" >nul
copy /v TVCaptionMod2\src\%SRC_DIR2%\TVCaptionMod2.tvtp "%DST_DIR%\Plugins" >nul
copy /v TVCaptionMod2\TVCaptionMod2_Readme.txt "%DST_DIR%\Plugins" >nul
pushd TVTest
rem バージョン情報の取得
for /f "usebackq tokens=2*" %%i in (`findstr /r /c:"^#define VERSION_TEXT_A" src\TVTestVersion.h`) do set VERSION=%%~j
rem コミットハッシュの取得
for /f "usebackq tokens=*" %%i in (`git rev-parse --short HEAD`) do set GIT_HASH=%%i
popd
set ARCHIVE_NAME=%OUT_DIR%\TVTest_%VERSION%_%GIT_HASH%_%ARCH%
rem 7-Zipのインストールフォルダの検索
for /f "usebackq tokens=1,2*" %%i in (`reg query HKLM\Software\7-Zip /v Path`) do if "%%i" == "Path" set PATH=%%k;%PATH%
if exist "%ARCHIVE_NAME%.7z" del "%ARCHIVE_NAME%.7z"
rem アーカイブの作成
7z a "%ARCHIVE_NAME%.7z" ".\%DST_DIR%\*" -mx=9 -ms=on -myx=9
exit /b
:Help
echo %~nx0 [x86^|x64^|Both] [dynamic^|static] [Build^|Rebuild^|Clean] [Debug^|Release] [del]
exit /b
使い方
コマンドプロンプトでバッチファイルを実行するときに引数を指定します。
TVTest.bat [x86|x64|Both] [dynamic|static] [Build|Rebuild|Clean] [Debug|Release] [del]
上記はhelpを指定すると表示されます。
引数のデフォルト値は以下です。
TVTest.bat x86 dynamic Build Release
x86は32bit版、x64は64bit版、Bothは32bit版と64bit版の両方です。
dynamicは動的リンク、staticは静的リンクです。TVTestとサンプルプラグインにのみ有効です。
dynamicの代わりにMD、staticの代わりにMTを指定することもできます。
delはソースを削除します。ダウンロードし直す場合に指定します。
バッチファイルと同じフォルダにある TVTest\package に出力されます。
ソースのダウンロード先を変更する場合は「set CLONE_DIR=」にフォルダパスを書きます。
アーカイブの出力先を変更する場合は「set OUT_DIR=」にフォルダパスを書きます。
コメント
どうせならアップデートをチェックするバッチファイルなんてどうでしょう
例として「TVTest」なら以下のバッチでチェックできるはず
=========================================================================
cd TVTest
set RESULT=
for /f “usebackq tokens=*” %%i in (`git remote show origin`) do set RESULT=%RESULT%%%i
if /i “%RESULT:~-19%” == “(local out of date)” (
echo [33;1mTVTestが更新されています[0m
)
if /i “%RESULT:~-12%” == “(up to date)” (
echo [36;1mTVTestは更新されていません[0m
)
=========================================================================
判断しやすく表示を色分けしてみました
結果を色分けできるようにしたつもりですが、書き込んだら[の前のESCが消えちゃいました
ついでだから補足
「TVTest」の所を変数にしてサブルーチンにすれば複数のチェックが可能です