-
Notifications
You must be signed in to change notification settings - Fork 8
/
aot-build.ps1
67 lines (58 loc) · 1.53 KB
/
aot-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
56
57
58
59
60
61
62
63
64
65
66
67
param(
[ValidateSet("win-x64", "linux-x64", "osx-x64")][string]$Runtime,
[string]$CppCompiler = "clang",
[string]$PublishDir
)
$Framework = "net7.0"
$ExeName = "Game"
if ($Runtime -eq "") {
if ($IsWindows -or $null -eq $IsWindows) {
$Runtime = "win-x64"
$msvc = $true
}
elseif ($IsMacOS) {
$Runtime = "osx-x64"
}
else {
$Runtime = "linux-x64"
$linuxBuild = $true
}
}
if ($PublishDir -eq "") {
$PublishDir = "publish/$Runtime"
}
if (!$msvc) {
$env:CppCompilerAndLinker = $CppCompiler
}
$dotnetArgs = @(
"run", "--no-launch-profile",
"--project", "./src/NitroSharp.ShaderCompiler/NitroSharp.ShaderCompiler.csproj",
"./src/NitroSharp/Graphics/Shaders", "./bin/obj/NitroSharp/Shaders.Generated"
)
dotnet($dotnetArgs)
$dotnetArgs = @(
"publish", "src/Game/Game.csproj",
"-r", "$Runtime",
"-c", "Release"
)
dotnet($dotnetArgs)
Remove-Item -Path $PublishDir -Recurse -ErrorAction SilentlyContinue
Copy-Item -Path bin/Release/Game/$Framework/$Runtime/publish -Destination $PublishDir `
-Recurse -Container -Force -Exclude *.pdb,*.deps.json,*.runtimeconfig.json
if ($linuxBuild) {
$stripArgs = @("$PublishDir/$ExeName", "--strip-all")
if (Get-Command wsl -ErrorAction SilentlyContinue) {
& wsl strip $stripArgs
}
else {
& strip $stripArgs
}
}
function dotnet($dotnetArgs) {
if ($IsWindows -and $linuxBuild) {
& bash --login -c "dotnet $dotnetArgs"
}
else {
& dotnet $dotnetArgs
}
}