Skip to content

Commit

Permalink
perf: Optimize the build process on the Windows platform.
Browse files Browse the repository at this point in the history
Optimize the build process on the Windows platform.
  • Loading branch information
AdachiAndShimamura committed Mar 19, 2024
1 parent c698a0b commit 34d3293
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ $WEBRTC_DIR="$WORK_DIR/libcs/dep/_google-webrtc"
$MSQUIC_DIR="$WORK_DIR/libcs/dep/_msquic"
$WEBRTC_OUT_DIR="$WEBRTC_DIR/src/out/release/obj"
$MSQUIC_OUT_DIR="$MSQUIC_DIR/build/windows/x64_schannel/obj/Release"
$WEB_FRONT="$WORK_DIR/libcs/web/front"

$env:CC="clang"
$env:CXX="clang++"
Expand All @@ -27,6 +28,7 @@ if (-not (Get-Module -Name VSSetup -ListAvailable)) {
Write-Host "安装VSSetup PowerShell插件"
Install-Module -Name VSSetup -AllowPrerelease -Force
}

Import-VisualStudioVars 2022 amd64

Set-Location $WORK_DIR
Expand Down Expand Up @@ -80,8 +82,41 @@ function complie_msquic{
}
}

function release_front{
Set-Location $WEB_FRONT
$npmCommand = Get-Command npm -ErrorAction SilentlyContinue

if ($null -ne $npmCommand) {
Write-Output "npm 命令可用,进行下一步"
} else {
Write-Output "npm 命令不可用,正在安装node.js"
winget install --id=OpenJS.NodeJS -e
}

if(Test-Path -Path "$WORK_DIR/libcs/client/web/dist"){
Remove-Item -Path "$WORK_DIR/libcs/client/web/dist" -Recurse -Force
}
if(Test-Path -Path "$WORK_DIR/libcs/server/web/dist"){
Remove-Item -Path "$WORK_DIR/libcs/server/web/dist" -Recurse -Force
}
if (Test-Path -Path "$WEB_FRONT/dist")
{
Remove-Item -Path "$WEB_FRONT/dist" -Recurse -Force
}
npm install
npm run "build:pro"

if (Test-Path -Path "$WEB_FRONT/dist")
{
Copy-Item -Path "$WEB_FRONT/dist" -Destination "$WORK_DIR/libcs/client/web/dist" -Recurse
Copy-Item -Path "$WEB_FRONT/dist" -Destination "$WORK_DIR/libcs/server/web/dist" -Recurse
Write-Host "web front编译完成"
}
}

function release_gt_lib{
release_front

Set-Location "$WORK_DIR/libcs"
Write-Host "开始编译gt server/client"
go build -tags release -trimpath -ldflags "-s -w" -buildmode=c-archive -o release/windows/gt.lib ./lib/export
Expand Down

0 comments on commit 34d3293

Please sign in to comment.