Skip to content

Commit 48d27f1

Browse files
committed
ci: build with subrandr on mingw64 and msys2
1 parent e0bd9a3 commit 48d27f1

File tree

4 files changed

+52
-5
lines changed

4 files changed

+52
-5
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
wine: wine32
4545
- target: x86_64-w64-mingw32
4646
wine: wine64
47+
rustc-target: x86_64-pc-windows-gnu
4748
steps:
4849
- uses: actions/checkout@v4
4950

@@ -64,6 +65,11 @@ jobs:
6465
sudo apt-get update
6566
sudo apt-get install --no-install-recommends -y ccache g++-mingw-w64 gcc-multilib meson nasm ninja-build pkgconf ${{ matrix.wine }} wine
6667
68+
- name: Install Rust toolchain
69+
uses: dtolnay/rust-toolchain@stable
70+
with:
71+
targets: ${{ matrix.rustc-target }}
72+
6773
- name: Install Meson Wraps
6874
run: |
6975
mkdir subprojects -p
@@ -74,6 +80,7 @@ jobs:
7480
./ci/build-mingw64.sh
7581
env:
7682
TARGET: ${{ matrix.target }}
83+
RUSTC_TARGET: ${{ matrix.rustc-target }}
7784

7885
- name: Build with meson
7986
id: build
@@ -566,6 +573,7 @@ jobs:
566573
uchardet:p
567574
vapoursynth:p
568575
vulkan-devel:p
576+
rust:p
569577
570578
- name: Build with meson
571579
id: build

ci/build-common.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,20 @@ common_args="--werror \
33
-Dtests=true \
44
"
55

6+
build_subrandr() {
7+
local target="$2"
8+
local prefix="$1"
9+
10+
if [[ -n "$target" ]]; then
11+
target_arg="--target $target"
12+
else
13+
target_arg=""
14+
fi
15+
16+
git clone --depth=1 https://github.com/afishhh/subrandr.git
17+
pushd subrandr
18+
cargo xtask install $target_arg --prefix "$prefix"
19+
popd
20+
}
21+
622
export CFLAGS="$CFLAGS -Wno-error=deprecated -Wno-error=deprecated-declarations -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3"

ci/build-mingw64.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ _luajit () {
275275
}
276276
_luajit_mark=lib/libluajit-5.1.a
277277

278+
_subrandr () {
279+
RUSTFLAGS="-L$prefix_dir/lib" build_subrandr "$prefix_dir" "$RUSTC_TARGET"
280+
}
281+
_subrandr_mark=lib/libsubrandr.dll.a
282+
278283
for x in iconv zlib shaderc spirv-cross nv-headers dav1d; do
279284
build_if_missing $x
280285
done
@@ -285,6 +290,12 @@ fi
285290
for x in ffmpeg libplacebo freetype fribidi harfbuzz libass luajit; do
286291
build_if_missing $x
287292
done
293+
if [[ -n "$RUSTC_TARGET" ]]; then
294+
build_if_missing subrandr
295+
subrandr_enabled="-Dsubrandr=enabled"
296+
else
297+
subrandr_enabled=""
298+
fi
288299

289300
## mpv
290301

@@ -302,7 +313,8 @@ meson setup $build --cross-file "$prefix_dir/crossfile" $common_args \
302313
-Dmujs:werror=false \
303314
-Dmujs:default_library=static \
304315
-Dlua=luajit \
305-
-D{shaderc,spirv-cross,d3d11,javascript}=enabled
316+
-D{shaderc,spirv-cross,d3d11,javascript}=enabled \
317+
$subrandr_enabled
306318
meson compile -C $build
307319

308320
if [ "$2" = pack ]; then
@@ -319,7 +331,7 @@ if [ "$2" = pack ]; then
319331
pushd artifact/tmp
320332
dlls=(
321333
libgcc_*.dll lib{ssp,stdc++,winpthread}-[0-9]*.dll # compiler runtime
322-
av*.dll sw*.dll postproc-[0-9]*.dll lib{ass,freetype,fribidi,harfbuzz,iconv,placebo}-[0-9]*.dll
334+
av*.dll sw*.dll {postproc,subrandr}-[0-9]*.dll lib{ass,freetype,fribidi,harfbuzz,iconv,placebo}-[0-9]*.dll
323335
lib{shaderc_shared,spirv-cross-c-shared,dav1d}.dll zlib1.dll
324336
)
325337
if [[ -f vulkan-1.dll ]]; then

ci/build-msys2.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,20 @@ args=(
88
-D{egl-angle-lib,egl-angle-win32,pdf-build,rubberband,win32-smtc}=enabled
99
)
1010

11-
[[ "$SYS" == "clang64" ]] && args+=(
12-
-Db_sanitize=address,undefined
13-
)
11+
if [[ "$SYS" == "clang64" ]]; then
12+
args+=(
13+
-Db_sanitize=address,undefined
14+
)
15+
else # sanitizers are not supported on stable rust yet so clang64 is excluded
16+
echo "::group::Building subrandr"
17+
build_subrandr "$PWD/subrandr_prefix"
18+
echo "::endgroup::"
19+
export PKG_CONFIG_PATH="$PWD/subrandr_prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
20+
mkdir build
21+
# make sure mpv.com will be able to find the DLL
22+
cp subrandr_prefix/bin/subrandr-[0-9]*.dll build
23+
args+=(-Dsubrandr=enabled)
24+
fi
1425

1526
meson setup build $common_args "${args[@]}"
1627
meson compile -C build

0 commit comments

Comments
 (0)