This repository has been archived by the owner on Mar 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
55 lines (52 loc) · 2.39 KB
/
build.ps1
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
param(
[string]$task
)
function LocateMsBuild {
param ()
$candidates = @(
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe",
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe",
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\15.0\Bin\MSBuild.exe",
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe"
)
for ($i = 0; $i -le $candidates.length; $i += 1) {
if (Test-Path $candidates[$i] -PathType Leaf) {
return $candidates[$i]
}
}
throw "Error: Could not find msbuild"
}
$msbuild = LocateMsBuild
if ($task -like "server") {
iex 'bazel build --cpu x86_32_windows --crosstool_top @windows_cc_config//:toolchain //server:app --verbose_failures'
exit $LASTEXITCODE
} elseif ($task -like "tsf-win32") {
iex 'bazel build --cpu x86_32_windows --crosstool_top @windows_cc_config//:toolchain //tsf:yptsf.dll --verbose_failures'
exit $LASTEXITCODE
} elseif ($task -like "tsf-win64") {
iex 'bazel build --cpu x64_windows --crosstool_top @windows_cc_config//:toolchain //tsf:yptsf.dll --verbose_failures'
exit $LASTEXITCODE
} elseif ($task -like "help") {
Write-Host "Usage: ./build.ps1 <command>"
} elseif ($task -like "predeploy") {
remove-item -Force -Recurse "./bundle" -ErrorAction Ignore
mkdir "./bundle"
cp -Force "./bazel-out/x86_32_windows-fastbuild/bin/tsf/yptsf.dll" -Destination "./bundle/lib32.dll"
cp -Force "./bazel-out/x64_windows-fastbuild/bin/tsf/yptsf.dll" -Destination "./bundle/lib64.dll"
cp -Force "./resource/icon.ico" -Destination "./bundle/"
} elseif ($task -like "startserver") {
iex "./bundle/app.exe"
Write-Host "Started Server."
} elseif ($task -like "quitserver") {
iex "./bundle/app.exe /q"
Write-Host "Quitted Server."
} elseif ($task -like "packserver") {
cp -Force -Recurse "./data" -Destination "./bundle"
cp -Force -Recurse "./bazel-out/x86_32_windows-fastbuild/bin/server/rime.dll" -Destination "./bundle/"
cp -Force -Recurse "./bazel-out/x86_32_windows-fastbuild/bin/server/app.exe" -Destination "./bundle/"
} elseif ($task -like "zip") {
Compress-Archive -Force -Path ./bundle/* -CompressionLevel Optimal -DestinationPath ./test.zip
} else {
Write-Host "Unknown command: $($task)"
exit -1
}