Skip to content

Commit 8ce6684

Browse files
committed
Add OHOS Windows build flow and Intel diagnostics
1 parent 61afd1e commit 8ce6684

16 files changed

Lines changed: 1418 additions & 70 deletions

File tree

‎ffmpeg/cmake/verify-install.cmake‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,47 @@ if(NOT AVCODEC_VERSION_HEADER MATCHES "#define LIBAVCODEC_VERSION_MAJOR[ \t]+62"
3333
message(FATAL_ERROR "QtAVCore requires FFmpeg 8 / libavcodec major 62")
3434
endif()
3535

36+
if(TRIPLET MATCHES "ohos")
37+
if(NOT EXISTS "${PREFIX}/include/libavutil/hwcontext_oh.h")
38+
message(FATAL_ERROR "OHOS FFmpeg is missing its OHCodec hardware-context header")
39+
endif()
40+
41+
find_program(QTAV_OHOS_LLVM_NM
42+
NAMES llvm-nm llvm-nm.exe
43+
HINTS "$ENV{OHOS_SDK_ROOT}/native/llvm/bin"
44+
NO_DEFAULT_PATH
45+
)
46+
if(NOT QTAV_OHOS_LLVM_NM)
47+
find_program(QTAV_OHOS_LLVM_NM NAMES llvm-nm llvm-nm.exe)
48+
endif()
49+
if(NOT QTAV_OHOS_LLVM_NM)
50+
message(FATAL_ERROR "llvm-nm is required to verify the OHCodec archive")
51+
endif()
52+
53+
execute_process(
54+
COMMAND "${QTAV_OHOS_LLVM_NM}" "${PREFIX}/lib/libavcodec.a"
55+
RESULT_VARIABLE QTAV_OHOS_NM_RESULT
56+
OUTPUT_VARIABLE QTAV_OHOS_AVCODEC_SYMBOLS
57+
ERROR_VARIABLE QTAV_OHOS_NM_ERROR
58+
)
59+
if(NOT QTAV_OHOS_NM_RESULT EQUAL 0)
60+
message(FATAL_ERROR
61+
"Could not inspect the OHOS libavcodec archive: ${QTAV_OHOS_NM_ERROR}"
62+
)
63+
endif()
64+
foreach(QTAV_OHOS_CODEC_SYMBOL IN ITEMS
65+
ff_h264_oh_decoder
66+
ff_hevc_oh_decoder
67+
)
68+
if(NOT QTAV_OHOS_AVCODEC_SYMBOLS MATCHES
69+
"(^|[\r\n])[^\r\n]*${QTAV_OHOS_CODEC_SYMBOL}([\r\n]|$)")
70+
message(FATAL_ERROR
71+
"OHOS FFmpeg was built without ${QTAV_OHOS_CODEC_SYMBOL}"
72+
)
73+
endif()
74+
endforeach()
75+
endif()
76+
3677
file(READ "${PREFIX}/include/libplacebo/config.h" LIBPLACEBO_CONFIG)
3778
if(NOT LIBPLACEBO_CONFIG MATCHES "#define PL_HAVE_VULKAN 1")
3879
message(FATAL_ERROR "libplacebo was built without Vulkan support")

‎ffmpeg/ports/ffmpeg/portfile.cmake‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ if("qtav-player" IN_LIST FEATURES)
9999
string(APPEND OPTIONS " --enable-lto --enable-small --disable-iamf")
100100
endif()
101101

102+
# OHCodec is a target capability rather than a generally selectable FFmpeg
103+
# feature. vcpkg currently models the OHOS triplet through its Linux platform
104+
# path, so key this policy from the explicit triplet marker instead of enabling
105+
# OHCodec for every Linux or arm64 build.
106+
if(VCPKG_TARGET_IS_OHOS)
107+
string(APPEND OPTIONS " --enable-ohcodec")
108+
else()
109+
string(APPEND OPTIONS " --disable-ohcodec")
110+
endif()
111+
102112
if(VCPKG_TARGET_IS_MINGW)
103113
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
104114
string(APPEND OPTIONS " --target-os=mingw32")

‎ffmpeg/ports/ffmpeg/vcpkg.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ffmpeg",
33
"version": "8.1.2",
4-
"port-version": 5,
4+
"port-version": 6,
55
"description": [
66
"A library to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created.",
77
"FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation. It is also highly portable: FFmpeg compiles, runs, and passes our testing infrastructure FATE across Linux, Mac OS X, Microsoft Windows, the BSDs, Solaris, etc. under a wide variety of build environments, machine architectures, and configurations."

‎ffmpeg/scripts/build-ohos.ps1‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
[CmdletBinding()]
2+
param(
3+
[string]$SdkRoot,
4+
[string]$InstallRoot,
5+
[string]$WorkRoot
6+
)
7+
8+
Set-StrictMode -Version Latest
9+
$ErrorActionPreference = 'Stop'
10+
11+
. (Join-Path $PSScriptRoot 'ohos-windows-common.ps1')
12+
13+
Assert-QtavOhosWindowsHost
14+
15+
$ProjectRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
16+
$VcpkgRoot = Join-Path $ProjectRoot 'vcpkg'
17+
$Triplet = 'arm64-ohos-23-static'
18+
if (-not $InstallRoot) {
19+
$InstallRoot = Join-Path $ProjectRoot "build/$Triplet/vcpkg_installed"
20+
}
21+
if (-not $WorkRoot) {
22+
$WorkRoot = Join-Path $ProjectRoot "build/$Triplet/vcpkg-work"
23+
}
24+
$InstallRoot = [IO.Path]::GetFullPath($InstallRoot)
25+
$WorkRoot = [IO.Path]::GetFullPath($WorkRoot)
26+
if ($WorkRoot -match '\s') {
27+
throw 'The FFmpeg OHOS work root must not contain spaces. Pass -WorkRoot with a space-free path.'
28+
}
29+
30+
$ResolvedSdkRoot = Resolve-QtavOhosSdkRoot -SdkRoot $SdkRoot
31+
$EffectiveSdkRoot = Use-QtavOhosSdkWithoutSpaces `
32+
-SdkRoot $ResolvedSdkRoot `
33+
-AliasRoot (Join-Path $WorkRoot 'ohos-sdk')
34+
$Tools = Enable-QtavOhosWindowsBuildTools -SdkRoot $EffectiveSdkRoot
35+
36+
if (-not (Test-Path (Join-Path $VcpkgRoot 'bootstrap-vcpkg.bat'))) {
37+
throw 'vcpkg submodule is missing; run: git submodule update --init ffmpeg/vcpkg'
38+
}
39+
40+
New-Item -ItemType Directory -Path $WorkRoot -Force | Out-Null
41+
$env:OHOS_SDK_ROOT = $EffectiveSdkRoot
42+
$env:VCPKG_DISABLE_METRICS = '1'
43+
44+
Write-Host "Triplet: $Triplet"
45+
Write-Host "OHOS SDK: $EffectiveSdkRoot"
46+
Write-Host "Install root: $InstallRoot"
47+
Write-Host "Work root: $WorkRoot"
48+
49+
$VcpkgExe = Join-Path $VcpkgRoot 'vcpkg.exe'
50+
if (-not (Test-Path -LiteralPath $VcpkgExe -PathType Leaf)) {
51+
& (Join-Path $VcpkgRoot 'bootstrap-vcpkg.bat') -disableMetrics
52+
if ($LASTEXITCODE -ne 0) { throw 'vcpkg bootstrap failed' }
53+
}
54+
55+
$VcpkgArguments = @(
56+
'install'
57+
"--x-manifest-root=$ProjectRoot"
58+
"--x-install-root=$InstallRoot"
59+
"--x-buildtrees-root=$(Join-Path $WorkRoot 'buildtrees')"
60+
"--x-packages-root=$(Join-Path $WorkRoot 'packages')"
61+
"--downloads-root=$(Join-Path $WorkRoot 'downloads')"
62+
"--triplet=$Triplet"
63+
"--overlay-ports=$ProjectRoot/ports"
64+
"--overlay-triplets=$ProjectRoot/triplets"
65+
)
66+
& $VcpkgExe @VcpkgArguments
67+
if ($LASTEXITCODE -ne 0) { throw 'OHOS dependency build failed' }
68+
69+
$CMakeArguments = @(
70+
"-DINSTALL_ROOT=$InstallRoot"
71+
"-DTRIPLET=$Triplet"
72+
'-P'
73+
(Join-Path $ProjectRoot 'cmake/verify-install.cmake')
74+
)
75+
& $Tools.CMake @CMakeArguments
76+
if ($LASTEXITCODE -ne 0) { throw 'OHOS dependency verification failed' }
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
function Assert-QtavOhosWindowsHost {
2+
if ($env:OS -ne 'Windows_NT') {
3+
throw 'This OHOS PowerShell entry point can run only on Windows.'
4+
}
5+
if (-not [Environment]::Is64BitOperatingSystem) {
6+
throw 'The OHOS build requires 64-bit Windows.'
7+
}
8+
if (-not [Environment]::Is64BitProcess) {
9+
throw 'Run the OHOS build from a 64-bit PowerShell process.'
10+
}
11+
}
12+
13+
function Resolve-QtavOhosSdkRoot {
14+
param(
15+
[string]$SdkRoot
16+
)
17+
18+
$Candidates = @()
19+
if ($SdkRoot) {
20+
$Candidates += $SdkRoot
21+
}
22+
if ($env:OHOS_SDK_ROOT) {
23+
$Candidates += $env:OHOS_SDK_ROOT
24+
}
25+
if ($env:OHOS_NDK) {
26+
$Candidates += Split-Path -Parent $env:OHOS_NDK
27+
}
28+
if ($env:DEVECO_SDK_HOME) {
29+
$Candidates += Join-Path $env:DEVECO_SDK_HOME 'default/openharmony'
30+
}
31+
if (${env:ProgramFiles}) {
32+
$Candidates += Join-Path ${env:ProgramFiles} `
33+
'Huawei/DevEco Studio/sdk/default/openharmony'
34+
}
35+
36+
foreach ($Candidate in $Candidates | Select-Object -Unique) {
37+
if (-not $Candidate) {
38+
continue
39+
}
40+
$Toolchain = Join-Path $Candidate 'native/build/cmake/ohos.toolchain.cmake'
41+
if (Test-Path -LiteralPath $Toolchain -PathType Leaf) {
42+
return (Resolve-Path -LiteralPath $Candidate).Path
43+
}
44+
}
45+
46+
throw @'
47+
The OpenHarmony native SDK was not found. Pass -SdkRoot with the directory
48+
that contains native/, or set OHOS_SDK_ROOT or DEVECO_SDK_HOME.
49+
'@
50+
}
51+
52+
function Use-QtavOhosSdkWithoutSpaces {
53+
param(
54+
[Parameter(Mandatory)]
55+
[string]$SdkRoot,
56+
57+
[Parameter(Mandatory)]
58+
[string]$AliasRoot
59+
)
60+
61+
if ($SdkRoot -notmatch '\s') {
62+
return $SdkRoot
63+
}
64+
65+
$AliasRoot = [IO.Path]::GetFullPath($AliasRoot)
66+
$AliasParent = Split-Path -Parent $AliasRoot
67+
New-Item -ItemType Directory -Path $AliasParent -Force | Out-Null
68+
69+
if (Test-Path -LiteralPath $AliasRoot) {
70+
$Alias = Get-Item -LiteralPath $AliasRoot -Force
71+
if (-not ($Alias.Attributes -band [IO.FileAttributes]::ReparsePoint)) {
72+
throw "OHOS SDK alias exists but is not a junction: $AliasRoot"
73+
}
74+
$AliasTarget = @($Alias.Target) | Select-Object -First 1
75+
if (-not $AliasTarget) {
76+
throw "Could not resolve the OHOS SDK junction target: $AliasRoot"
77+
}
78+
$ResolvedAliasTarget = [IO.Path]::GetFullPath($AliasTarget).TrimEnd('\')
79+
$ResolvedSdkRoot = [IO.Path]::GetFullPath($SdkRoot).TrimEnd('\')
80+
if (-not $ResolvedAliasTarget.Equals(
81+
$ResolvedSdkRoot,
82+
[StringComparison]::OrdinalIgnoreCase)) {
83+
throw @"
84+
OHOS SDK alias already points to a different SDK:
85+
alias: $AliasRoot
86+
target: $ResolvedAliasTarget
87+
Remove the alias or choose a different -WorkRoot before changing SDKs.
88+
"@
89+
}
90+
} else {
91+
New-Item -ItemType Junction -Path $AliasRoot -Target $SdkRoot | Out-Null
92+
}
93+
94+
$AliasedToolchain = Join-Path $AliasRoot `
95+
'native/build/cmake/ohos.toolchain.cmake'
96+
if (-not (Test-Path -LiteralPath $AliasedToolchain -PathType Leaf)) {
97+
throw "The aliased OHOS toolchain is not readable: $AliasedToolchain"
98+
}
99+
return $AliasRoot
100+
}
101+
102+
function Enable-QtavOhosWindowsBuildTools {
103+
param(
104+
[Parameter(Mandatory)]
105+
[string]$SdkRoot
106+
)
107+
108+
$BuildTools = Join-Path $SdkRoot 'native/build-tools/cmake/bin'
109+
$CMake = Join-Path $BuildTools 'cmake.exe'
110+
$Ninja = Join-Path $BuildTools 'ninja.exe'
111+
if (-not (Test-Path -LiteralPath $CMake -PathType Leaf)) {
112+
$CMakeCommand = Get-Command cmake.exe -CommandType Application `
113+
-ErrorAction SilentlyContinue | Select-Object -First 1
114+
if (-not $CMakeCommand) {
115+
throw 'cmake.exe was not found in the OHOS SDK or on PATH.'
116+
}
117+
$CMake = $CMakeCommand.Source
118+
}
119+
if (-not (Test-Path -LiteralPath $Ninja -PathType Leaf)) {
120+
$NinjaCommand = Get-Command ninja.exe -CommandType Application `
121+
-ErrorAction SilentlyContinue | Select-Object -First 1
122+
if (-not $NinjaCommand) {
123+
throw 'ninja.exe was not found in the OHOS SDK or on PATH.'
124+
}
125+
$Ninja = $NinjaCommand.Source
126+
}
127+
128+
$ToolDirectories = @(
129+
(Split-Path -Parent $CMake)
130+
(Split-Path -Parent $Ninja)
131+
(Join-Path $SdkRoot 'native/llvm/bin')
132+
) | Select-Object -Unique
133+
$PathEntries = $env:PATH -split [IO.Path]::PathSeparator
134+
foreach ($ToolDirectory in $ToolDirectories) {
135+
if ($PathEntries -notcontains $ToolDirectory) {
136+
$env:PATH = "$ToolDirectory$([IO.Path]::PathSeparator)$env:PATH"
137+
}
138+
}
139+
140+
return [pscustomobject]@{
141+
CMake = $CMake
142+
Ninja = $Ninja
143+
}
144+
}

0 commit comments

Comments
 (0)