Skip to content

Commit 30c4aad

Browse files
committed
test: build libmpv on CI
use upstream build script
1 parent c5f2961 commit 30c4aad

7 files changed

Lines changed: 132 additions & 93 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 80 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,77 @@ permissions:
1010
contents: write
1111

1212
jobs:
13+
libmpv:
14+
name: Build ${{ matrix.platform }} libmpv
15+
runs-on: ubuntu-24.04
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- platform: Win32
21+
arch: i686
22+
wine: wine32
23+
- platform: x64
24+
arch: x86_64
25+
wine: wine64
26+
env:
27+
TARGET: ${{ matrix.arch }}-w64-mingw32
28+
RUST_TARGET: ${{ matrix.arch }}-pc-windows-gnu
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v7
32+
with:
33+
submodules: recursive
34+
35+
- name: Install upstream build tools
36+
run: |
37+
rustup target add "$RUST_TARGET"
38+
sudo dpkg --add-architecture i386
39+
sudo apt-get update
40+
sudo apt-get install --no-install-recommends -y ccache g++-mingw-w64 gcc-multilib python3-pip nasm ninja-build pkgconf ${{ matrix.wine }} wine
41+
python -m pip install meson
42+
43+
- name: Install upstream Meson wraps
44+
working-directory: mpv
45+
run: |
46+
mkdir -p subprojects
47+
meson wrap install mujs
48+
meson subprojects download
49+
50+
- name: Build with upstream MinGW recipe
51+
working-directory: mpv
52+
run: |
53+
./ci/build-mingw64.sh
54+
./ci/build-mingw64.sh meson pack
55+
56+
- name: Print mpv Meson log
57+
if: failure()
58+
working-directory: mpv
59+
run: |
60+
if [ -f mingw_build/meson-logs/meson-log.txt ]; then
61+
tail -n 250 mingw_build/meson-logs/meson-log.txt
62+
fi
63+
64+
- name: Collect and test libmpv
65+
run: |
66+
test -f mpv/mingw_build/libmpv-2.dll
67+
cp mpv/mingw_build/libmpv-2.dll mpv/artifact/mpv-2.dll
68+
"$TARGET-gcc-posix" -I mpv/include scripts/smoke-libmpv.c -o mpv/artifact/smoke-libmpv.exe
69+
cd mpv/artifact
70+
wine ./smoke-libmpv.exe ./mpv-2.dll
71+
rm smoke-libmpv.exe
72+
73+
- name: Upload libmpv runtime
74+
uses: actions/upload-artifact@v7
75+
with:
76+
name: libmpv-${{ matrix.platform }}
77+
if-no-files-found: error
78+
path: mpv/artifact/*.dll
79+
1380
release:
1481
name: Build and package Windows component
1582
runs-on: windows-2025-vs2026
83+
needs: libmpv
1684

1785
steps:
1886
- name: Checkout
@@ -27,6 +95,18 @@ jobs:
2795
vs-version: '[18.0,19.0)'
2896
msbuild-architecture: x64
2997

98+
- name: Download Win32 libmpv runtime
99+
uses: actions/download-artifact@v8
100+
with:
101+
name: libmpv-Win32
102+
path: artifacts/runtime/Win32
103+
104+
- name: Download x64 libmpv runtime
105+
uses: actions/download-artifact@v8
106+
with:
107+
name: libmpv-x64
108+
path: artifacts/runtime/x64
109+
30110
- name: Configure vcpkg cache
31111
uses: lukka/run-vcpkg@v11.6
32112
with:
@@ -59,18 +139,6 @@ jobs:
59139
msbuild .\src\foo_mpv.sln /m /t:Build
60140
/p:Configuration=Release /p:Platform=x64 /v:minimal
61141
62-
- name: Download Win32 libmpv
63-
shell: pwsh
64-
run: >-
65-
.\scripts\download-libmpv.ps1 -Architecture i686
66-
-Destination .\artifacts\runtime\Win32\mpv-2.dll
67-
68-
- name: Download x64 libmpv
69-
shell: pwsh
70-
run: >-
71-
.\scripts\download-libmpv.ps1 -Architecture x86_64
72-
-Destination .\artifacts\runtime\x64\mpv-2.dll
73-
74142
- name: Package component
75143
shell: pwsh
76144
run: |

‎.gitmodules‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
path = vcpkg
66
url = https://github.com/microsoft/vcpkg.git
77
branch = master
8+
[submodule "mpv"]
9+
path = mpv
10+
url = https://github.com/mpv-player/mpv.git

‎README.md‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,6 @@ mpv video player UI element for foobar2000.
1818
- Mouse and keyboard input mostly supported thorough `mpv/input.conf` (editable in the UI).
1919
- Optional update notification via [foo_acfu](https://acfu.3dyd.com/home/)
2020

21-
### Building
22-
23-
Visual Studio configurations are provided for both 32-bit (`Win32`) and 64-bit
24-
(`x64`) foobar2000. Install the matching vcpkg dependencies before building:
25-
26-
```powershell
27-
.\scripts\install-dependencies.ps1 -Triplet x86-mpv
28-
.\scripts\install-dependencies.ps1 -Triplet x64-mpv
29-
msbuild .\src\foo_mpv.sln /m /p:Configuration=Release /p:Platform=Win32
30-
msbuild .\src\foo_mpv.sln /m /p:Configuration=Release /p:Platform=x64
31-
```
32-
33-
Release packages contain the Win32 component at the archive root and x64
34-
overrides in the `x64` directory, allowing one `.fb2k-component` file to work
35-
with either foobar2000 architecture. The GitHub release workflow downloads the
36-
matching libmpv runtimes and creates this package with
37-
`scripts/package-component.ps1`.
38-
3921
### Configuration
4022

4123
The component is not a decoder, you will need to make sure foobar2000 can play the audio from whichever video files you want to play first. For anything not supported by default, you can install and configure the [ffmpeg decoder wrapper component](https://www.foobar2000.org/components/view/foo_input_ffmpeg).

‎mpv‎

Submodule mpv added at 41f6a64

‎scripts/download-libmpv.ps1‎

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

‎scripts/package-component.ps1‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ foreach ($path in @($packageZip, $package, $symbols)) {
4646
New-Item -ItemType Directory -Path (Join-Path $stagingRoot 'mpv') -Force | Out-Null
4747
New-Item -ItemType Directory -Path (Join-Path $stagingRoot 'x64\mpv') -Force | Out-Null
4848
Copy-Item -LiteralPath $Win32Dll -Destination (Join-Path $stagingRoot 'foo_mpv.dll')
49-
Copy-Item -LiteralPath $Win32Libmpv -Destination (Join-Path $stagingRoot 'mpv\mpv-2.dll')
49+
Get-ChildItem -LiteralPath (Split-Path -Parent $Win32Libmpv) -Filter '*.dll' -File |
50+
Copy-Item -Destination (Join-Path $stagingRoot 'mpv')
5051
Copy-Item -LiteralPath $oscScript -Destination (Join-Path $stagingRoot 'mpv\osc.lua')
5152
Copy-Item -LiteralPath $X64Dll -Destination (Join-Path $stagingRoot 'x64\foo_mpv.dll')
52-
Copy-Item -LiteralPath $X64Libmpv -Destination (Join-Path $stagingRoot 'x64\mpv\mpv-2.dll')
53+
Get-ChildItem -LiteralPath (Split-Path -Parent $X64Libmpv) -Filter '*.dll' -File |
54+
Copy-Item -Destination (Join-Path $stagingRoot 'x64\mpv')
5355

5456
Compress-Archive -Path (Join-Path $stagingRoot '*') -DestinationPath $packageZip
5557
Move-Item -LiteralPath $packageZip -Destination $package

‎scripts/smoke-libmpv.c‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <windows.h>
2+
#include <mpv/client.h>
3+
#include <stdio.h>
4+
5+
int main(int argc, char **argv)
6+
{
7+
if (argc != 2)
8+
return 2;
9+
10+
HMODULE dll = LoadLibraryExA(argv[1], NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
11+
if (!dll) {
12+
fprintf(stderr, "LoadLibraryEx failed: %lu\n", GetLastError());
13+
return 1;
14+
}
15+
16+
mpv_handle *(*create)(void) = (void *)GetProcAddress(dll, "mpv_create");
17+
int (*set_option_string)(mpv_handle *, const char *, const char *) =
18+
(void *)GetProcAddress(dll, "mpv_set_option_string");
19+
int (*initialize)(mpv_handle *) = (void *)GetProcAddress(dll, "mpv_initialize");
20+
void (*terminate_destroy)(mpv_handle *) =
21+
(void *)GetProcAddress(dll, "mpv_terminate_destroy");
22+
if (!create || !set_option_string || !initialize || !terminate_destroy) {
23+
fprintf(stderr, "libmpv is missing a required export\n");
24+
return 1;
25+
}
26+
27+
mpv_handle *handle = create();
28+
if (!handle) {
29+
fprintf(stderr, "mpv_create failed\n");
30+
return 1;
31+
}
32+
int result = set_option_string(handle, "vo", "null");
33+
if (result >= 0)
34+
result = set_option_string(handle, "ao", "null");
35+
if (result >= 0)
36+
result = initialize(handle);
37+
terminate_destroy(handle);
38+
FreeLibrary(dll);
39+
if (result < 0) {
40+
fprintf(stderr, "mpv_initialize failed: %d\n", result);
41+
return 1;
42+
}
43+
return 0;
44+
}

0 commit comments

Comments
 (0)