OSDN Git Service

Merge branch 'master' of https://github.com/hengband/hengband
[hengbandforosx/hengbandosx.git] / Build-Windows-Release-Package.ps1
1 Param(
2     # パッケージに付加するバージョン
3     [parameter(Mandatory = $true)][string]$Version
4 )
5
6 # とりあえず Visual Studio Community 2019 用の MSBuild.exe にパスを通す
7 # 他の環境でビルドを実行する方法は要調査・検討
8 $msbuild_path = 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin'
9 $Env:Path = $msbuild_path + ";" + $Env:Path
10
11
12 function BuildPackage ($package_name, $package_unique_files, $build_conf) {
13     # バイナリをリビルド
14     MSBuild.exe .\Hengband\Hengband.sln /t:Rebuild /p:Configuration=$build_conf
15
16     if ($LASTEXITCODE -ne 0) {
17         # ビルド失敗ならスクリプトを中断する
18         exit
19     }
20
21     # 作業用テンポラリフォルダ
22     $tempDir = New-TemporaryFile | ForEach-Object { Remove-Item $_; New-Item $_ -ItemType Directory }
23
24     $hengbandDir = Join-Path $tempDir $package_name
25     New-Item $hengbandDir -ItemType Directory
26
27     # 必要なファイルをコピーして、その中で不要になりえるものを削除
28     Copy-Item -Verbose -Path .\Hengband.exe, .\readme_angband -Destination $hengbandDir
29     Copy-Item -Verbose -Path $package_unique_files -Destination $hengbandDir
30     Copy-Item -Verbose -Recurse -Path .\lib -Destination $hengbandDir -Exclude Makefile.am, *.raw, .gitattributes
31     Copy-Item -Verbose -Path .\lib\apex\h_scores.raw -Destination $hengbandDir\lib\apex
32     Remove-Item -Verbose -Exclude delete.me -Recurse -Path $hengbandDir\lib\save\*, $hengbandDir\lib\user\*
33     Remove-Item -Verbose -Exclude music.cfg -Path $hengbandDir\lib\xtra\music\*
34
35     # zipアーカイブ作成
36     $package_path = Join-Path $(Get-Location) "${package_name}.zip"
37     Get-ChildItem -Path $tempDir | Compress-Archive -Force -Verbose -DestinationPath $package_path
38
39     # 作業用テンポラリフォルダ削除
40     $tempDir | Where-Object { Test-Path $_ } | ForEach-Object { Get-ChildItem $_ -File -Recurse | Remove-Item; $_ } | Remove-Item -Recurse
41 }
42
43 # 日本語版
44 BuildPackage -package_name Hengband-$Version-jp -package_unique_files .\readme.md, .\autopick.txt -build_conf Release
45 # 英語版
46 BuildPackage -package_name Hengband-$Version-en -package_unique_files .\readme_eng.md, .\autopick_eng.txt -build_conf English-Release