Skip to content

Commit 8718977

Browse files
committed
Initial commit for opus v1.5.2
0 parents  commit 8718977

9 files changed

Lines changed: 894 additions & 0 deletions

File tree

‎.dockerignore‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Keep the Docker build context small: only the Dockerfile and build-opus.ps1
2+
# are needed inside the image.
3+
.git
4+
.github
5+
examples
6+
artifacts
7+
*.zip
8+
SHA256SUMS.txt
9+
configure-*.log
10+
build-*.log
11+
README.md
12+
.gitignore

‎.gitattributes‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This repository targets Windows. Keep CRLF line endings on checkout.
2+
* text=auto eol=crlf
3+
4+
# The build script is invoked as a file by CI/Docker; CRLF is fine for pwsh.
5+
*.ps1 text eol=crlf
6+
7+
# Anything binary that might land here stays untouched.
8+
*.zip binary
9+
*.dll binary
10+
*.lib binary
11+
*.pdb binary
12+
*.exe binary

‎.github/workflows/build-opus.yml‎

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Build Opus (Windows)
2+
3+
# Builds Opus as a shared library (opus.dll + opus.lib) on a Windows runner and
4+
# uploads the public headers + binaries as zip artifacts -- the same zips the
5+
# Docker image produces, ready to publish for FreeSWITCH's w32 build to consume.
6+
#
7+
# Trigger manually (Actions tab -> "Build Opus (Windows)" -> Run workflow)
8+
# choosing the Opus tag, or push a tag like `opus-v1.5.2` to build it and attach
9+
# the zips to a GitHub Release.
10+
11+
on:
12+
workflow_dispatch:
13+
inputs:
14+
opus_version:
15+
description: 'Opus git tag to build (e.g. v1.5.2)'
16+
required: true
17+
default: 'v1.5.2'
18+
configs:
19+
description: 'Configurations to build (space-separated)'
20+
required: true
21+
default: 'Release Debug'
22+
platforms:
23+
description: 'Platforms to build (space-separated: x64, Win32, ARM64)'
24+
required: true
25+
default: 'x64 Win32'
26+
custom_modes:
27+
description: 'Enable Opus custom modes (adds opus_custom.h)'
28+
required: true
29+
default: 'OFF'
30+
type: choice
31+
options: [ 'OFF', 'ON' ]
32+
push:
33+
tags:
34+
- 'opus-v*' # e.g. push tag `opus-v1.5.2`
35+
36+
jobs:
37+
build:
38+
runs-on: windows-2022
39+
timeout-minutes: 90
40+
permissions:
41+
contents: write # needed to attach zips to a Release on tag push
42+
steps:
43+
- name: Checkout builder
44+
uses: actions/checkout@v4
45+
46+
- name: Resolve build parameters
47+
id: p
48+
shell: pwsh
49+
run: |
50+
if ($env:GITHUB_EVENT_NAME -eq 'push') {
51+
# tag form: opus-v1.5.2 -> Opus tag v1.5.2
52+
$ov = "$env:GITHUB_REF_NAME" -replace '^opus-', ''
53+
$cfg = 'Release Debug'
54+
$plat = 'x64 Win32'
55+
$cm = 'OFF'
56+
} else {
57+
$ov = '${{ inputs.opus_version }}'
58+
$cfg = '${{ inputs.configs }}'
59+
$plat = '${{ inputs.platforms }}'
60+
$cm = '${{ inputs.custom_modes }}'
61+
}
62+
"opus_version=$ov" >> $env:GITHUB_OUTPUT
63+
"configs=$cfg" >> $env:GITHUB_OUTPUT
64+
"platforms=$plat" >> $env:GITHUB_OUTPUT
65+
"custom_modes=$cm" >> $env:GITHUB_OUTPUT
66+
Write-Host "Building Opus $ov [$cfg] for [$plat] (custom modes: $cm)"
67+
68+
# windows-2022 ships Visual Studio 2022, CMake and Git; confirm the C++ toolset
69+
# is present via vswhere -- that plus cmake is all build-opus.ps1 needs.
70+
- name: Verify toolchain
71+
shell: pwsh
72+
run: |
73+
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
74+
$vs = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | Select-Object -First 1
75+
if (-not $vs) { throw "No Visual Studio install with the C++ toolset (VC.Tools.x86.x64) was found." }
76+
Write-Host "VS install : $vs"
77+
Write-Host "CMake : $(cmake --version | Select-Object -First 1)"
78+
Write-Host "Git : $(git --version)"
79+
80+
- name: Build Opus + package zips
81+
shell: pwsh
82+
env:
83+
OPUS_VERSION: ${{ steps.p.outputs.opus_version }}
84+
CONFIGS: ${{ steps.p.outputs.configs }}
85+
PLATFORMS: ${{ steps.p.outputs.platforms }}
86+
OPUS_CUSTOM_MODES: ${{ steps.p.outputs.custom_modes }}
87+
OUT_DIR: ${{ github.workspace }}\artifacts
88+
OPUS_BUILD_ROOT: C:\ob
89+
run: .\build-opus.ps1
90+
91+
- name: List artifacts
92+
shell: pwsh
93+
run: Get-ChildItem '${{ github.workspace }}\artifacts' | Format-Table Name, Length
94+
95+
- name: Upload zips
96+
uses: actions/upload-artifact@v4
97+
with:
98+
name: opus-${{ steps.p.outputs.opus_version }}
99+
path: |
100+
artifacts/*.zip
101+
artifacts/SHA256SUMS.txt
102+
artifacts/*.log
103+
if-no-files-found: error
104+
retention-days: 30
105+
106+
# On a tag push, also attach the zips to a GitHub Release for easy download.
107+
- name: Publish to Release
108+
if: github.event_name == 'push'
109+
uses: softprops/action-gh-release@v2
110+
with:
111+
files: |
112+
artifacts/*.zip
113+
artifacts/SHA256SUMS.txt

‎.gitignore‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Build outputs
2+
/artifacts/
3+
*.zip
4+
SHA256SUMS.txt
5+
configure-*.log
6+
build-*.log
7+
8+
# Opus source / build trees (when building natively in-tree)
9+
/ob/
10+
/opus/
11+
build-*/
12+
install-*/
13+
14+
# OS / editor cruft
15+
Thumbs.db
16+
.DS_Store

‎Dockerfile‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# escape=`
2+
#
3+
# Builds Opus on Windows as a SHARED library (opus.dll + opus.lib import library)
4+
# with CMake + the Visual C++ toolchain, and packages the public headers +
5+
# binaries into zip files that the FreeSWITCH mod_opus / mod_opusfile modules can
6+
# consume in place of building Opus from source in-tree.
7+
#
8+
# This image only contains the TOOLCHAIN. The actual Opus version is cloned at
9+
# `docker run` time from an env var, so you can produce a new release without
10+
# rebuilding the (slow, multi-GB) Visual Studio layer.
11+
#
12+
# Build the toolchain image once:
13+
# docker build -t opus-packaging .
14+
#
15+
# Produce zips for an Opus tag (writes to .\artifacts on the host):
16+
# docker run --rm --cpus 8 --memory 8g `
17+
# -e OPUS_VERSION=v1.5.2 `
18+
# -v ${PWD}\artifacts:C:\artifacts `
19+
# opus-packaging
20+
#
21+
# Requires Windows containers. The host must be able to run a Windows base image
22+
# of an equal-or-older build than the host (process isolation), otherwise run
23+
# with `--isolation=hyperv`.
24+
25+
ARG WINDOWS_BASE=mcr.microsoft.com/windows/servercore:ltsc2025
26+
FROM ${WINDOWS_BASE}
27+
28+
# The Visual Studio bootstrapper. aka.ms/vs/17/release installs the latest VS 2022
29+
# Build Tools.
30+
ARG VS_BOOTSTRAPPER_URL=https://aka.ms/vs/17/release/vs_buildtools.exe
31+
32+
SHELL ["powershell", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", "$ErrorActionPreference='Stop'; $ProgressPreference='SilentlyContinue';"]
33+
34+
# ---------------------------------------------------------------------------
35+
# 1. Visual Studio 2022 Build Tools: the C++ workload (MSVC v143 + Windows SDK).
36+
# build-opus.ps1 locates the install via vswhere (dropped by the bootstrapper)
37+
# and drives it through CMake's Visual Studio generator.
38+
# Exit code 3010 == success-but-reboot-required, which is fine in an image.
39+
# ---------------------------------------------------------------------------
40+
RUN Invoke-WebRequest -Uri $env:VS_BOOTSTRAPPER_URL -OutFile C:\vs_buildtools.exe; `
41+
Write-Host 'Installing Visual Studio Build Tools (this takes a while)...'; `
42+
$p = Start-Process -FilePath C:\vs_buildtools.exe -Wait -PassThru -ArgumentList `
43+
'--quiet','--wait','--norestart','--nocache', `
44+
'--installPath','C:\BuildTools', `
45+
'--add','Microsoft.VisualStudio.Workload.VCTools', `
46+
'--includeRecommended'; `
47+
if ($p.ExitCode -ne 0 -and $p.ExitCode -ne 3010) { throw "VS Build Tools install failed ($($p.ExitCode))" }; `
48+
Remove-Item C:\vs_buildtools.exe -Force
49+
50+
# ---------------------------------------------------------------------------
51+
# 2. Chocolatey, then Opus's two remaining prerequisites. Installed AFTER Visual
52+
# Studio so these small layers can be rebuilt without invalidating the cached
53+
# (slow) VS layer above.
54+
# - git : to clone the Opus source at the requested tag
55+
# - cmake : Opus's build system (>= 3.16)
56+
# ---------------------------------------------------------------------------
57+
RUN [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; `
58+
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
59+
60+
RUN choco install -y --no-progress git; `
61+
if ($LASTEXITCODE -ne 0) { throw "git install failed ($LASTEXITCODE)" }
62+
63+
RUN choco install -y --no-progress cmake --installargs 'ADD_CMAKE_TO_PATH=System'; `
64+
if ($LASTEXITCODE -ne 0) { throw "cmake install failed ($LASTEXITCODE)" }
65+
66+
# NOTE: do NOT set `ENV PATH` here. The Windows base image exports the variable as
67+
# `Path` (mixed case), but Docker's ${...} substitution is case-sensitive, so
68+
# `${PATH}` expands to empty and wipes C:\Windows\System32 from the path. The
69+
# choco/VS installers already register their dirs in the machine PATH (which
70+
# container processes inherit), and build-opus.ps1 prepends the tool dirs
71+
# defensively at runtime.
72+
73+
# ---------------------------------------------------------------------------
74+
# 3. Build driver.
75+
# ---------------------------------------------------------------------------
76+
COPY build-opus.ps1 C:\build-opus.ps1
77+
78+
# Defaults; override any of these with `docker run -e ...`.
79+
ENV OPUS_VERSION=v1.5.2 `
80+
CONFIGS="Release Debug" `
81+
PLATFORMS="x64 Win32" `
82+
PKG_PREFIX=opus `
83+
OUT_DIR=C:\artifacts `
84+
OPUS_REPO=https://gitlab.xiph.org/xiph/opus.git `
85+
OPUS_BUILD_ROOT=C:\ob `
86+
OPUS_CUSTOM_MODES=OFF
87+
88+
ENTRYPOINT ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", "C:\\build-opus.ps1"]

0 commit comments

Comments
 (0)