-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
60 lines (50 loc) · 2.33 KB
/
Copy pathbuild.ps1
File metadata and controls
60 lines (50 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
param(
[string]$PythonExecutable = "python"
)
$ErrorActionPreference = "Stop"
$repositoryRoot = $PSScriptRoot
$buildRoot = Join-Path $repositoryRoot "build"
$binaryOutput = Join-Path $buildRoot "binary"
$workOutput = Join-Path $buildRoot "pyinstaller"
$distRoot = Join-Path $repositoryRoot "dist"
$productName = "構文エラー解析ツール_Windows"
$productDirectory = Join-Path $distRoot $productName
$archivePath = Join-Path $distRoot "$productName.zip"
foreach ($target in @($buildRoot, $distRoot)) {
$resolvedParent = [System.IO.Path]::GetFullPath((Split-Path $target -Parent))
if ($resolvedParent -ne [System.IO.Path]::GetFullPath($repositoryRoot)) {
throw "ビルド出力先がリポジトリ外です: $target"
}
}
& $PythonExecutable -c "import tkinter; interpreter = tkinter.Tcl(); print(interpreter.eval('info library'))"
if ($LASTEXITCODE -ne 0) {
throw "Tcl/Tkを利用できるPythonが必要です。"
}
& $PythonExecutable -m PyInstaller `
--noconfirm `
--clean `
--distpath $binaryOutput `
--workpath $workOutput `
(Join-Path $repositoryRoot "syntax_error_helper.spec")
if ($LASTEXITCODE -ne 0) {
throw "PyInstallerの実行に失敗しました。"
}
$executablePath = Join-Path $binaryOutput "構文エラー解析ツール.exe"
if (-not (Test-Path -LiteralPath $executablePath -PathType Leaf)) {
throw "配布用実行ファイルが生成されませんでした。"
}
if (Test-Path -LiteralPath $productDirectory) {
Remove-Item -LiteralPath $productDirectory -Recurse -Force
}
if (Test-Path -LiteralPath $archivePath) {
Remove-Item -LiteralPath $archivePath -Force
}
New-Item -ItemType Directory -Path $productDirectory | Out-Null
Copy-Item -LiteralPath $executablePath -Destination $productDirectory
Copy-Item -LiteralPath (Join-Path $repositoryRoot "distribution\はじめに.txt") -Destination $productDirectory
Copy-Item -LiteralPath (Join-Path $repositoryRoot "LICENSE") -Destination (Join-Path $productDirectory "LICENSE.txt")
Copy-Item -LiteralPath (Join-Path $repositoryRoot "examples") -Destination $productDirectory -Recurse
Compress-Archive -LiteralPath $productDirectory -DestinationPath $archivePath -CompressionLevel Optimal
Write-Host "ビルドが完了しました。"
Write-Host "配布フォルダー: $productDirectory"
Write-Host "BOOTH登録用ZIP: $archivePath"