From 34d329379870ee562a2f40b102a73b9899fd4fc3 Mon Sep 17 00:00:00 2001 From: AdachiAndShimamura Date: Tue, 19 Mar 2024 12:54:30 +0800 Subject: [PATCH] perf: Optimize the build process on the Windows platform. Optimize the build process on the Windows platform. --- build.ps1 | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/build.ps1 b/build.ps1 index 566a614c..399c55d0 100644 --- a/build.ps1 +++ b/build.ps1 @@ -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++" @@ -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 @@ -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