Skip to content

Commit 5e8dc87

Browse files
author
HeZhengQing
committed
Merge branch 'dev/4.6.2-win-ci' into dev/4.5.3
2 parents 39fff8b + 0bf599f commit 5e8dc87

8 files changed

Lines changed: 193 additions & 98 deletions

File tree

.github/ci/build/build_windows.bat

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ REM 'repo:string',
1010
REM 'base:string',
1111
REM 'arch:string'
1212
REM 'output:string'
13-
REM 'short_version:string'
14-
REM 'release_version:string'
1513
REM 'build_date:string(yyyyMMdd)',
1614
REM 'build_timestamp:string (yyyyMMdd_hhmm)',
1715
REM 'platform: string',
@@ -46,54 +44,68 @@ echo source_root: %source_root%
4644
echo output: C:\\tmp\\%project%_out
4745
echo build_date: %build_date%
4846
echo build_time: %build_time%
49-
echo release_version: %release_version%
50-
echo short_version: %short_version%
5147
echo pwd: %cd%
5248
echo sdk_url: %sdk_url%
5349

54-
55-
set zip_name=Agora_Native_SDK_for_Windows_FULL_DEFAULT.zip
56-
if %compile_project% EQU false goto SKIP_DOWNLOAD
57-
set zip_name=%sdk_url%
58-
:LOOP
59-
for /f "tokens=1* delims=</>" %%a in ("%zip_name%") do (
60-
set zip_name=%%a
61-
set part2=%%b
50+
REM If sdk_url has a value, replace the URL in install.ps1
51+
if not "%sdk_url%"=="" (
52+
if not "%sdk_url%"=="none" (
53+
echo "Replacing SDK URL in install.ps1"
54+
powershell -Command "(Get-Content windows\APIExample\install.ps1) -replace '\$agora_sdk = ''.*''', ('$agora_sdk = ''' + '%sdk_url%' + '''') | Set-Content windows\APIExample\install.ps1"
55+
)
6256
)
63-
if "%part2%" EQU "" goto END
64-
set zip_name=%part2%
65-
goto LOOP
66-
:END
67-
echo on
68-
echo zip_name: %zip_name%
69-
70-
dir
7157

72-
curl %sdk_url% -o %zip_name%
73-
REM python %WORKSPACE%\\artifactory_utils.py --action=download_file --file=%sdk_url%
74-
7z x ./%zip_name% -y
75-
dir
76-
rmdir /S /Q Agora_Native_SDK_for_Windows_FULL\demo
77-
del /F /Q Agora_Native_SDK_for_Windows_FULL\commits
78-
del /F /Q Agora_Native_SDK_for_Windows_FULL\package_size_report.txt
79-
:SKIP_DOWNLOAD
58+
REM Check compress_apiexample parameter
59+
if "%compress_apiexample%"=="" set compress_apiexample=false
60+
echo compress_apiexample: %compress_apiexample%
8061

62+
REM Check compile_project parameter
63+
if "%compile_project%"=="" set compile_project=false
64+
echo compile_project: %compile_project%
8165

82-
mkdir Agora_Native_SDK_for_Windows_FULL\samples
83-
mkdir Agora_Native_SDK_for_Windows_FULL\samples\API-example
84-
rmdir /S /Q windows\cicd
85-
del /F /Q windows\APIExample\ci.py
86-
xcopy /Y /E windows\APIExample Agora_Native_SDK_for_Windows_FULL\samples\API-example
87-
xcopy /Y /E windows\README.md Agora_Native_SDK_for_Windows_FULL\samples\API-example
88-
xcopy /Y /E windows\README.zh.md Agora_Native_SDK_for_Windows_FULL\samples\API-example
89-
rmdir /S /Q Agora_Native_SDK_for_Windows_FULL\samples\API-example\APIExample\APIExample
90-
dir Agora_Native_SDK_for_Windows_FULL\samples\API-example\APIExample
91-
7z a -tzip result.zip -r Agora_Native_SDK_for_Windows_FULL
92-
copy result.zip %WORKSPACE%\\withAPIExample_%BUILD_NUMBER%_%zip_name%
93-
del /F result.zip
94-
del /F %WORKSPACE%\\%zip_name%
66+
REM Package APIExample code (only when compress_apiexample=true)
67+
REM Run before compile so package content is not affected by compile
68+
set result_zip=APIExample_result.zip
69+
set des_path=%WORKSPACE%\Shengwang_APIExample_code_windows_%BUILD_NUMBER%.zip
70+
if "%compress_apiexample%"=="true" (
71+
echo "Packaging APIExample code..."
72+
73+
REM Compress windows\APIExample (code only) to zip
74+
echo "Compressing APIExample code package..."
75+
del /F /Q %result_zip% 2>nul
76+
7z a -tzip %result_zip% -r windows\APIExample
77+
if errorlevel 1 (
78+
echo 7z compression failed!
79+
exit /b 1
80+
)
81+
82+
REM Copy to WORKSPACE with new naming format
83+
echo "Copying %result_zip% to %des_path%"
84+
copy %result_zip% %des_path%
85+
if errorlevel 1 (
86+
echo copy failed!
87+
exit /b 1
88+
)
89+
90+
REM Clean up temporary zip in repo root
91+
del /F %result_zip%
92+
93+
echo "Complete: APIExample code package created"
94+
dir %WORKSPACE%\
95+
) else (
96+
echo "Skipping APIExample code packaging (compress_apiexample=false)"
97+
)
9598

96-
if %compile_project% EQU false goto FINAL
97-
cd Agora_Native_SDK_for_Windows_FULL\samples\API-example
98-
call cloud_build.bat
99-
:FINAL
99+
REM Compile project to generate executable (only when compile_project=true)
100+
if "%compile_project%"=="true" (
101+
echo "Compiling project to generate executable..."
102+
cd windows\APIExample
103+
call cloud_build.bat
104+
if %ERRORLEVEL% NEQ 0 (
105+
echo Build failed!
106+
exit /b %ERRORLEVEL%
107+
)
108+
cd ..\..
109+
) else (
110+
echo "Skipping project compilation (compile_project=false)"
111+
)

windows/APIExample/ci.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

windows/APIExample/cloud_build.bat

Lines changed: 77 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,81 @@
1+
@echo off
2+
setlocal enabledelayedexpansion
3+
14
echo "compile start..."
2-
call installThirdParty.bat
3-
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe" "APIExample.sln" /p:platform="Win32" /p:configuration="Release"
4-
7z a -tzip result.zip -r Release
55

6+
REM --- 1. Install Dependencies ---
7+
powershell.exe -ExecutionPolicy Bypass -File "%~dp0install.ps1"
8+
9+
REM --- 2. Find MSBuild ---
10+
set "MSBuildPath="
11+
set "vswhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
12+
13+
if exist "!vswhere!" (
14+
for /f "usebackq tokens=*" %%i in (`"!vswhere!" -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) do set "MSBuildPath=%%i"
15+
)
16+
17+
if not defined MSBuildPath (
18+
for %%p in (
19+
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe"
20+
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe"
21+
"C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe"
22+
) do if exist %%p set "MSBuildPath=%%p"
23+
)
24+
25+
if not defined MSBuildPath (
26+
echo Error: MSBuild not found.
27+
exit /b 1
28+
)
29+
30+
echo Using MSBuild at: "!MSBuildPath!"
31+
32+
REM --- 3. Build ---
33+
"!MSBuildPath!" "APIExample.sln" /p:platform="Win32" /p:configuration="Release"
34+
if %ERRORLEVEL% NEQ 0 (
35+
echo Build failed!
36+
exit /b %ERRORLEVEL%
37+
)
38+
39+
echo "compile done."
40+
41+
REM --- 4. Package (Clean Output) ---
42+
echo Preparing clean output directory...
43+
rmdir /S /Q Output 2>nul
44+
mkdir Output
45+
46+
REM Copy executables and DLLs from Release
47+
xcopy /Y /S Release\*.exe Output\ >nul 2>&1
48+
xcopy /Y /S Release\*.dll Output\ >nul 2>&1
49+
50+
REM Copy resources
51+
xcopy /Y /S /I APIExample\res Output\res >nul 2>&1
52+
xcopy /Y APIExample\*.ini Output\ >nul 2>&1
53+
54+
REM Copy SDK and ThirdParty DLLs (Agora uses sdk\x86 for Win32)
55+
xcopy /Y sdk\x86\*.dll Output\ >nul 2>&1
56+
xcopy /Y ThirdParty\libFFmpeg\*.dll Output\ >nul 2>&1
57+
58+
echo Packaging...
59+
set "result_zip=result.zip"
60+
del /F /Q !result_zip! 2>nul
61+
62+
REM Try 7z, fallback to PowerShell
63+
where 7z >nul 2>nul
64+
if %ERRORLEVEL% EQU 0 (
65+
7z a -tzip !result_zip! .\Output\* >nul
66+
) else (
67+
"C:\Program Files\7-Zip\7z.exe" a -tzip !result_zip! .\Output\* >nul 2>nul
68+
if %ERRORLEVEL% NEQ 0 (
69+
powershell -command "Compress-Archive -Path '.\Output\*' -DestinationPath '!result_zip!' -Force"
70+
)
71+
)
72+
73+
REM Copy to WORKSPACE with original naming format
674
set h=%time:~0,2%
775
set h=%h: =0%
8-
copy result.zip %WORKSPACE%\\APIExample_windows_%BUILD_NUMBER%_%date:~4,2%%date:~7,2%%h%%time:~3,2%_Release_exe.zip
9-
del /F result.zip
10-
echo "compile done."
76+
if not defined WORKSPACE set WORKSPACE=%~dp0
77+
copy !result_zip! "%WORKSPACE%\\APIExample_windows_%BUILD_NUMBER%_%date:~4,2%%date:~7,2%%h%%time:~3,2%_Release_exe.zip"
78+
del /F /Q !result_zip! 2>nul
79+
rmdir /S /Q Output 2>nul
80+
81+
echo Build and Package done.

windows/APIExample/install.ps1

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,72 @@ $agora_local_sdk = '../../sdk'
77
if (-not (Test-Path ThirdParty)){
88
echo "download $ThirdPartydes"
99
mkdir ThirdParty
10-
(New-Object System.Net.WebClient).DownloadFile($ThirdPartySrc,$ThirdPartyDes)
11-
Unblock-File $ThirdPartyDes
12-
Expand-Archive -Path $ThirdPartyDes -DestinationPath 'ThirdParty' -Force
13-
Remove-Item $ThirdPartyDes -Recurse
10+
(New-Object System.Net.WebClient).DownloadFile($ThirdPartysrc,$ThirdPartydes)
11+
Unblock-File $ThirdPartydes
12+
Expand-Archive -Path $ThirdPartydes -DestinationPath 'ThirdParty' -Force
13+
Remove-Item $ThirdPartydes -Recurse
1414
}
1515

16-
17-
1816
if (-not (Test-Path sdk)){
1917
if (Test-Path $agora_local_sdk){
2018
mkdir sdk
21-
mkdir sdk\x86
19+
mkdir sdk\x86
2220
mkdir sdk\x64
2321
mkdir sdk\high_level_api
2422
mkdir sdk\high_level_api\include
25-
Copy-Item $agora_local_sdk\x86\* sdk\x86 -Recurse
23+
Copy-Item $agora_local_sdk\x86\* sdk\x86 -Recurse
2624
Copy-Item $agora_local_sdk\x86_64\* sdk\x64 -Recurse
2725
Copy-Item $agora_local_sdk\high_level_api\include\* sdk\high_level_api\include -Recurse
2826
}else{
2927
echo "download $agora_des"
28+
echo "Downloading SDK from: $agora_sdk"
29+
3030
mkdir sdk
31-
mkdir sdk\x86
31+
mkdir sdk\x86
3232
mkdir sdk\x64
3333
mkdir sdk\high_level_api
3434
mkdir sdk\high_level_api\include
35-
(New-Object System.Net.WebClient).DownloadFile($agora_sdk,$agora_des)
36-
Unblock-File $agora_des
37-
Expand-Archive -Path $agora_des -DestinationPath . -Force
38-
Move-Item Agora_Native_SDK_for_Windows_FULL\sdk\x86\* sdk\x86
39-
Move-Item Agora_Native_SDK_for_Windows_FULL\sdk\x86_64\* sdk\x64
40-
Move-Item Agora_Native_SDK_for_Windows_FULL\sdk\high_level_api\include\* sdk\high_level_api\include
41-
Remove-Item $agora_des -Recurse -Force
42-
Remove-Item Agora_Native_SDK_for_Windows_FULL -Recurse -Force
35+
36+
# Use system temporary directory for extraction to avoid path length issues
37+
$tempBasePath = [System.IO.Path]::GetTempPath()
38+
$tempExtractPath = Join-Path $tempBasePath "RtcSdkExtract_$(Get-Random)"
39+
$tempZipPath = Join-Path $tempBasePath $agora_des
40+
41+
try {
42+
(New-Object System.Net.WebClient).DownloadFile($agora_sdk, $tempZipPath)
43+
Unblock-File $tempZipPath
44+
Expand-Archive -Path $tempZipPath -DestinationPath $tempExtractPath -Force
45+
46+
$extractedSdkPath = (Get-ChildItem -Path $tempExtractPath -Directory | Select-Object -First 1).FullName
47+
Move-Item (Join-Path $extractedSdkPath "sdk\x86\*") sdk\x86 -Force
48+
Move-Item (Join-Path $extractedSdkPath "sdk\x86_64\*") sdk\x64 -Force
49+
Move-Item (Join-Path $extractedSdkPath "sdk\high_level_api\include\*") sdk\high_level_api\include -Force
50+
}
51+
finally {
52+
# Clean up temporary files
53+
if (Test-Path $tempZipPath) { Remove-Item $tempZipPath -Force -ErrorAction SilentlyContinue }
54+
if (Test-Path $tempExtractPath) { Remove-Item $tempExtractPath -Recurse -Force -ErrorAction SilentlyContinue }
55+
}
4356
}
4457
}
4558

46-
47-
59+
# Validation: check each folder has at least one direct child (non-empty), output to console only
60+
$allOk = $true
61+
foreach ($dir in @("ThirdParty", "sdk\x86", "sdk\x64", "sdk\high_level_api\include")) {
62+
$p = Join-Path $PSScriptRoot $dir
63+
$n = 0
64+
if (Test-Path $p -PathType Container) {
65+
try { $n = (Get-ChildItem $p -ErrorAction SilentlyContinue).Count } catch { Write-Host "[FAIL] $dir | $_" -ForegroundColor Red; $allOk = $false; continue }
66+
}
67+
$ok = $n -ge 1
68+
if (-not $ok) { $allOk = $false }
69+
if ($ok) { Write-Host "[PASS] $dir (items=$n)" } else { Write-Host "[FAIL] $dir (items=$n)" }
70+
}
71+
if ($allOk) {
72+
Write-Host "Result: All passed."
73+
Write-Host "Dependencies are installed; you can proceed to the next step." -ForegroundColor Green
74+
} else {
75+
Write-Host "Result: Validation failed." -ForegroundColor Red
76+
Write-Host "Please check network and download, ensure ThirdParty and sdk are not empty, then retry." -ForegroundColor Red
77+
exit 1
78+
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
cd /d %~dp0
22

3-
powershell.exe -command ^
4-
"& {set-executionpolicy Remotesigned -Scope Process; ./'install.ps1'}"
3+
powershell.exe -Command "Unblock-File -Path '%~dp0install.ps1'"
4+
powershell.exe -File "%~dp0install.ps1"
5+
6+
pause

windows/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ To build and run the sample application, get an App ID:
3636
3737
You can directly run `APIExample/installThirdParty.bat` to automatically environment configuration.Once the configuration is complete, open the project with VS2017, select the x86 version to compile and run.
3838
39+
> If you run into permission or execution policy errors, try running as administrator, or adjust the local PowerShell execution policy and try again.
40+
3941
## Basic Scene
4042
4143

windows/README.zh.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
### 编译项目
4141
**这个开源示例项目使用了Agora RTC SDK,DirectShow SDK,MeidaPlayer SDK。**
4242
43-
你可以通过直接运行`APIExample/installThirdParty.bat`来自动进行依赖下载与环境配置。配置完成后使用vs2017打开项目,选择x86版本进行编译就可以运行了。
43+
你可以通过直接运行`APIExample/installThirdParty.bat`来自动进行依赖下载与环境配置。配置完成后使用vs2017打开项目,选择x86版本进行编译就可以运行了。
44+
45+
> 若遇权限或执行策略报错,可尝试以管理员运行,或调整本机 PowerShell 执行策略后再试。
4446
4547
## 基础场景
4648

windows/cicd/templates/build-Windows.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ jobs:
3030
steps:
3131
- script: echo "$(WindowsRTCSDK)" && ls
3232
- script: cd ${{ parameters.workingDirectory }} && installThirdParty.bat
33-
- script: cd ${{ parameters.workingDirectory }} && ls && python ci.py
34-
env:
35-
AGORA_APP_ID: $(agora.appId)
36-
3733
- task: VSBuild@1
3834
inputs:
3935
solution: '$(solution)'

0 commit comments

Comments
 (0)