[ENG-630] Windows ffmpeg + libheif custom build (#871)

* Initial Windows ffmpeg + libheif custom build

* Add build steps for most of ffmpeg deps

* FFmpeg deps and libheif

* Fix libheif build

* Fix libvpx and dlfcn + attempt to fix rav1e

* Rework the whole ffmpeg-windows build system
 - New system based on https://github.com/BtbN/FFmpeg-Builds
 - Add new ffmpeg-windows workflow
 - Rename macos ffmpeg workflow
 - Adapt macos setupt script due to above name change

* Forgot to update update the workflow name

* Strip all libs from debug symbols

* Add docs

* Add libde265 deps, required by libheif
 - Make x265, svtav1 and dav1d as shared deps (used by both ffmpeg and libheif)

* Add missing libheif to Linux setup script

* Fix libx265 build script

* Forgot to point x265 ninja install to the correct directory

* Remove libaom and libsvt-av1
 - dav1d and rav1d are our default AV1 decoders/encoders
 - Quote subshell executions
 - Make libweb shared

* Forgot to remove libaom and libsvt-av1 build steps

* Fix typo

* Try force webp to link against static libs

* Revert libwebp to a static build

* Dumb typo

* Modify windows script to download our ffmpeg build (WIP)

* Fix dlls output folder structure

* Fix dumb mistake

* Remove unused ffbuild_enabled

* Enable core's heif feature on Windows
 - Fix windows ffmpeg build not including the headers
 - Fix windows setupt script incorrect download loagic
 - Implement build_arg to pass which repo ref to use when cloning

* Fix windows setup script

* Fix workflow artifact path
 - Make ffmpeg-windows dockerfile respect the FFMPEG_VERSION env

* Fix Windows setup script incorrect logic for downloading ffmpeg builds

* Error out when workflow_runs is empty

* Fix dumb mistake

* Manually define ffmpeg version for windows script

* Fix ffmpeg windows build extract logic

* Fix prop access in windows setup script

* Revert back to a web request because nightly.link does a redirect before serving the artifact content

* Fix windows setup script

* Do not use nightly.link in Github CI

* Fix windows setup script

* Should finally fix window setup script
 - Update ffmpeg-windows deps
 - Should fix ffmpeg-windows failing to build due to mingw changes in new base image

* Fix libxz failing to build due to doxygen

* Fix windows setup-script not executing till the end

* Fix LASTEXITCODE not defined

* Remove libjxl, deps are not being compiled

* Fix dll and lib copy logic

* Move final copy dll logic to external script

* Use main for libjxl

* Change brotli from stable to main
 - Attempt to fix libjxl

* Attempt fix lib copy again

* Split copy_dll logic to avoid cache burst in docker

* Missing file

* Change how to export build files from shared deps

* Replace rsync with cp

* Fix copy

* Fix dir not existing

* Fix pkgconfig

* Remove superflous files from exported ffmpeg for windows
 - Adjust dav1d to not build tools and examples
 - Adjust windows setup-script to point linker to the libs directory

* Fix dav1d meson config args

* Fix dumb mistake

* WORK PLZ

* Fix .lib file location
 - Strip all dlls

* Formatter
This commit is contained in:
Vítor Vasconcellos 2023-06-10 16:23:37 +01:00 committed by GitHub
parent b12e954f4f
commit 1c7855ded6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 1895 additions and 117 deletions

View file

@ -1,7 +1,7 @@
ARG FAKE_DEPS="python311 perl5.34 gdk-pixbuf2 xorg-libsm xorg-libX11" \
FFMPEG_DEPS="aom bzip2 fontconfig freetype fribidi lame libgsm libheif libogg libopus libpng \
libtheora libvidstab libvorbis libvpx-devel lzo2 openjpeg rav1e soxr svt-av1 twolame webp x264 \
x265 XviD xz zimg zlib" \
libtheora libvorbis libvpx-devel openjpeg rav1e soxr svt-av1 twolame webp x264 x265 XviD xz zimg \
zlib" \
FFMPEG_VERSION=6.0
FROM vvasconcellos/osxcross:12.3-50e86eb-1 as base
@ -13,7 +13,7 @@ RUN tar -xf ffmpeg-${FFMPEG_VERSION}.tar.xz && rm ffmpeg-${FFMPEG_VERSION}.tar.x
WORKDIR /srv/ffmpeg-${FFMPEG_VERSION}
COPY ./ffmpeg-build-macos.sh ./
COPY --chmod=755 ./ffmpeg-build-macos.sh ./
# ---
FROM base as x86_64

View file

@ -7,7 +7,11 @@
# https://github.com/arthenica/ffmpeg-kit/blob/47f85fa9ea3f8c34f3c817b87d8667b61b87d0bc/scripts/apple/ffmpeg.sh
# https://github.com/zimbatm/ffmpeg-static/blob/3206c0d74cd129c2ddfc3e928dcd3ea317d54857/build.sh
set -euox pipefail
set -e # exit immediate if an error occurs in a pipeline
set -E # make commands inherit ERR trap
set -u # don't allow not set variables to be utilized
set -o pipefail # trace ERR through pipes
set -o errtrace # trace ERR through 'time command' and other functions
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <target-arch> <macos-version>" >&2
@ -110,6 +114,7 @@ trap 'rm -rf "$TARGET_DIR"' EXIT
--pkg-config-flags="--static" \
--extra-ldflags="-Bstatic -headerpad_max_install_names" \
--extra-ldexeflags="-Bstatic" \
--extra-cflags=-DLIBTWOLAME_STATIC \
--extra-cxxflags="-xc++-header" \
--disable-alsa \
--disable-cuda \
@ -160,6 +165,7 @@ trap 'rm -rf "$TARGET_DIR"' EXIT
--enable-cross-compile \
--enable-fontconfig \
--enable-gpl \
--enable-gray \
--enable-iconv \
--enable-inline-asm \
--enable-libaom \
@ -343,3 +349,6 @@ cp -av "${_macports_root}/include/libheif" "/${_framework}/Headers/"
# Copy all FFMPEG headers to framework
cp -av "${TARGET_DIR}/include/"* "/${_framework}/Headers/"
# Strip all libraries
"${TRIPLE}-strip" -S "/${_framework}/Libraries/"*.dylib

View file

@ -0,0 +1 @@
dlls

View file

@ -0,0 +1,242 @@
ARG FFMPEG_VERSION=6.0
FROM ghcr.io/btbn/ffmpeg-builds/base-win64:latest@sha256:69e7ee385c41ae4580161fbd1cf14e1d199a81c39e398e8421225d86d8f2d3f3 AS base
ENV TARGET=win64
FROM base AS layer-10-mingw
RUN --mount=src=scripts.d/10-mingw.sh,dst=/stage.sh run_stage /stage.sh
FROM base AS layer-10-mingw-std-threads
RUN --mount=src=scripts.d/10-mingw-std-threads.sh,dst=/stage.sh run_stage /stage.sh
FROM base AS layer-10
COPY --from=layer-10-mingw /opt/mingw/. /
COPY --from=layer-10-mingw /opt/mingw/. /opt/mingw
COPY --from=layer-10-mingw-std-threads $FFBUILD_PREFIX/. $FFBUILD_PREFIX
FROM layer-10 AS layer-20-zlib
RUN --mount=src=scripts.d/20-zlib.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-10 AS layer-20-bzip2
RUN --mount=src=scripts.d/20-bzip2.sh,dst=/stage.sh --mount=src=patches/bzip2,dst=/patches run_stage /stage.sh
FROM layer-10 AS layer-20
COPY --from=layer-20-zlib $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-20-bzip2 $FFBUILD_PREFIX/. $FFBUILD_PREFIX
FROM layer-20 AS layer-25-libogg
RUN --mount=src=scripts.d/25-libogg.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-20 AS layer-25-xz
RUN --mount=src=scripts.d/25-xz.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-20 AS layer-25
COPY --from=layer-25-libogg $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-25-xz $FFBUILD_PREFIX/. $FFBUILD_PREFIX
FROM layer-25 AS layer-45-brotli
RUN --mount=src=scripts.d/45-brotli.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-25 AS layer-45-libvorbis
RUN --mount=src=scripts.d/45-libvorbis.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-25 AS layer-45-opencl
RUN --mount=src=scripts.d/45-opencl.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-25 AS layer-45-vmaf
RUN --mount=src=scripts.d/45-vmaf.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-25 AS layer-45
COPY --from=layer-45-brotli $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-45-libvorbis $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-45-opencl $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-45-vmaf $FFBUILD_PREFIX/. $FFBUILD_PREFIX
FROM layer-45 AS layer-50-amf
RUN --mount=src=scripts.d/50-amf.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-dav1d
RUN --mount=src=scripts.d/50-dav1d.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-ffnvcodec
RUN --mount=src=scripts.d/50-ffnvcodec.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-kvazaar
RUN --mount=src=scripts.d/50-kvazaar.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-libjxl
RUN --mount=src=scripts.d/50-libjxl.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-libmp3lame
RUN --mount=src=scripts.d/50-libmp3lame.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-libopus
RUN --mount=src=scripts.d/50-libopus.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-libtheora
RUN --mount=src=scripts.d/50-libtheora.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-libvpx
RUN --mount=src=scripts.d/50-libvpx.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-libwebp
RUN --mount=src=scripts.d/50-libwebp.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-onevpl
RUN --mount=src=scripts.d/50-onevpl.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-openal
RUN --mount=src=scripts.d/50-openal.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-openjpeg
RUN --mount=src=scripts.d/50-openjpeg.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-rav1e
RUN --mount=src=scripts.d/50-rav1e.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-soxr
RUN --mount=src=scripts.d/50-soxr.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-twolame
RUN --mount=src=scripts.d/50-twolame.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-vulkan
RUN --mount=src=scripts.d/50-vulkan/45-vulkan.sh,dst=/stage.sh run_stage /stage.sh
RUN --mount=src=scripts.d/50-vulkan/50-shaderc.sh,dst=/stage.sh run_stage /stage.sh
RUN --mount=src=scripts.d/50-vulkan/55-spirv-cross.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-x264
RUN --mount=src=scripts.d/50-x264.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-x265
RUN --mount=src=scripts.d/50-x265.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-xvid
RUN --mount=src=scripts.d/50-xvid.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50-zimg
RUN --mount=src=scripts.d/50-zimg.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-45 AS layer-50
COPY --from=layer-50-amf $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-dav1d $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-dav1d /opt/dlls /opt/dlls
COPY --from=layer-50-ffnvcodec $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-kvazaar $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-libjxl $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-libmp3lame $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-libopus $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-libtheora $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-libvpx $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-libwebp $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-onevpl $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-openal $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-openjpeg $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-rav1e $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-rav1e /opt/dlls /opt/dlls
COPY --from=layer-50-soxr $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-twolame $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-vulkan $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-x264 $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-x265 $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-x265 /opt/dlls /opt/dlls
COPY --from=layer-50-xvid $FFBUILD_PREFIX/. $FFBUILD_PREFIX
COPY --from=layer-50-zimg $FFBUILD_PREFIX/. $FFBUILD_PREFIX
FROM layer-50 AS layer-99-libheif
RUN --mount=src=scripts.d/99-libheif.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-50 AS layer-99-ffmpeg
ARG FFMPEG_VERSION
ENV FFMPEG_VERSION="$FFMPEG_VERSION"
RUN --mount=src=scripts.d/99-ffmpeg.sh,dst=/stage.sh run_stage /stage.sh
FROM layer-50 AS layer-99
COPY --from=layer-50 /opt/dlls /opt/dlls
COPY --from=layer-99-libheif /opt/dlls /opt/dlls
COPY --from=layer-99-ffmpeg /opt/dlls /opt/dlls
RUN rm -rf /opt/dlls/share /opt/dlls/lib/pkgconfig /opt/dlls/lib/cmake
RUN cd /opt/dlls/bin \
&& find . -name '*.lib' -exec install -Dt ../lib/ -m a-rwx,u+rw,g+r,o+r {} + \
&& find . -name '*.lib' -delete \
&& find . -name '*.dll' -exec x86_64-w64-mingw32-strip -s {} \;
RUN find /opt/dlls -type d -delete || true
FROM scratch
COPY --from=layer-99 /opt/dlls /dlls

View file

@ -0,0 +1,25 @@
# FFMpeg DLLs for Windows
## Build instructions
To build the FFMpeg `DLLs` a `docker` or `podman` installation is required.
It is recomended to enable [`BuildKit`](https://docs.docker.com/build/buildkit/#getting-started) in docker.
Just run the following inside this directory:
```sh
$> docker build -o . .
```
or
```sh
$> podman build -o . .
```
After some time (it takes aroung 60min in Github CI) a directory named `dlls` will show up with the `DLLs` inside.
### How does the build process work?
This is a modified Dockerfile generate by using https://github.com/BtbN/FFmpeg-Builds
Thanks @BtbN for your great work

View file

@ -0,0 +1,24 @@
From cc9db1c519dc00966ba8d8cdb4328698dfff9f80 Mon Sep 17 00:00:00 2001
From: BtbN <btbn@btbn.de>
Date: Thu, 15 Apr 2021 21:38:32 +0200
Subject: [PATCH] Fall back to built-in vmaf model on load failure
---
aom_dsp/vmaf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/aom_dsp/vmaf.c b/aom_dsp/vmaf.c
index 219e27830..6625f05c1 100644
--- a/aom_dsp/vmaf.c
+++ b/aom_dsp/vmaf.c
@@ -37,6 +37,7 @@ void aom_init_vmaf_model(VmafModel **vmaf_model, const char *model_path) {
model_cfg.name = "vmaf";
if (vmaf_model_load_from_path(vmaf_model, &model_cfg, model_path)) {
+ if (vmaf_model_load(vmaf_model, &model_cfg, "vmaf_v0.6.1"))
vmaf_fatal_error("Failed to load VMAF model.");
}
}
--
2.25.1

View file

@ -0,0 +1,33 @@
diff -u bzlib.h.bak bzlib.h
--- bzlib.h.bak 2010-09-11 01:08:42.000000000 +0200
+++ bzlib.h 2013-02-06 04:03:34.782383139 +0100
@@ -82,7 +82,7 @@
# undef small
# endif
# ifdef BZ_EXPORT
-# define BZ_API(func) WINAPI func
+# define BZ_API(func) func
# define BZ_EXTERN extern
# else
/* import windows dll dynamically */
diff -u Makefile.bak Makefile
--- Makefile.bak 2010-09-11 00:46:02.000000000 +0200
+++ Makefile 2013-02-06 04:04:07.210382474 +0100
@@ -15,13 +15,13 @@
SHELL=/bin/sh
# To assist in cross-compiling
-CC=gcc
-AR=ar
-RANLIB=ranlib
+CC?=gcc
+AR?=ar
+RANLIB?=ranlib
LDFLAGS=
BIGFILES=-D_FILE_OFFSET_BITS=64
-CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
+CFLAGS:=-Wall -Winline -O2 -g $(BIGFILES) $(CFLAGS)
# Where you want it installed when you do 'make install'
PREFIX=/usr/local

View file

@ -0,0 +1,12 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/meganz/mingw-std-threads.git"
SCRIPT_COMMIT="6c2061b7da41d6aa1b2162ff4383ec3ece864bc6"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" mingw-std-threads
cd mingw-std-threads
mkdir -p "$FFBUILD_PREFIX"/include
cp *.h "$FFBUILD_PREFIX"/include
}

View file

@ -0,0 +1,45 @@
#!/bin/bash
SCRIPT_REPO="https://git.code.sf.net/p/mingw-w64/mingw-w64.git"
SCRIPT_COMMIT="9df2e604ddf16765410724716a8d1887ffc61fa9"
ffbuild_dockerbuild() {
retry-tool sh -c "rm -rf mingw && git clone '$SCRIPT_REPO' mingw"
cd mingw
git checkout "$SCRIPT_COMMIT"
cd mingw-w64-headers
unset CFLAGS
unset CXXFLAGS
unset LDFLAGS
unset PKG_CONFIG_LIBDIR
GCC_SYSROOT="$(${FFBUILD_CROSS_PREFIX}gcc -print-sysroot)"
local myconf=(
--prefix="$GCC_SYSROOT/usr/$FFBUILD_TOOLCHAIN"
--host="$FFBUILD_TOOLCHAIN"
--with-default-win32-winnt="0x601"
--with-default-msvcrt=ucrt
--enable-idl
)
./configure "${myconf[@]}"
make -j"$(nproc)"
make install DESTDIR="/opt/mingw"
cd ../mingw-w64-libraries/winpthreads
local myconf=(
--prefix="$GCC_SYSROOT/usr/$FFBUILD_TOOLCHAIN"
--host="$FFBUILD_TOOLCHAIN"
--with-pic
--disable-shared
--enable-static
)
./configure "${myconf[@]}"
make -j"$(nproc)"
make install DESTDIR="/opt/mingw"
}

View file

@ -0,0 +1,26 @@
#!/bin/bash
SCRIPT_REPO="git://sourceware.org/git/bzip2.git"
SCRIPT_REF="bzip2-1.0.8"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_REF" bzip2
cd bzip2
patch -p0 </patches/bzip2-1.0.8_brokenstuff.diff
make \
CC="${FFBUILD_CROSS_PREFIX}gcc" \
AR="${FFBUILD_CROSS_PREFIX}ar" \
LD="${FFBUILD_CROSS_PREFIX}ld" \
CXX="${FFBUILD_CROSS_PREFIX}g++" \
STRIP="${FFBUILD_CROSS_PREFIX}strip" \
PREFIX="$FFBUILD_PREFIX" \
RANLIB="${FFBUILD_CROSS_PREFIX}ranlib" \
libbz2.a \
-j"$(nproc)"
install -m644 -D bzlib.h "${FFBUILD_PREFIX}/include/bzlib.h"
install -m644 -D libbz2.a "${FFBUILD_PREFIX}/lib/libbz2.a"
}

View file

@ -0,0 +1,26 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/madler/zlib.git"
SCRIPT_TAG="v1.2.13"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" zlib
cd zlib
local myconf=(
--prefix="$FFBUILD_PREFIX"
--static
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
export CC="${FFBUILD_CROSS_PREFIX}gcc"
export AR="${FFBUILD_CROSS_PREFIX}ar"
else
echo "Unknown target"
return 255
fi
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
}

View file

@ -0,0 +1,31 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/xiph/ogg.git"
SCRIPT_TAG="v1.3.5"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" ogg
cd ogg
./autogen.sh
local myconf=(
--prefix="$FFBUILD_PREFIX"
--disable-shared
--enable-static
--with-pic
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--host="$FFBUILD_TOOLCHAIN"
)
else
echo "Unknown target"
return 255
fi
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
}

View file

@ -0,0 +1,32 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/xz-mirror/xz.git"
SCRIPT_TAG="v5.4.3"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" xz
cd xz
./autogen.sh --no-po4a --no-doxygen
local myconf=(
--prefix="$FFBUILD_PREFIX"
--disable-symbol-versions
--disable-shared
--enable-static
--with-pic
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--host="$FFBUILD_TOOLCHAIN"
)
else
echo "Unknown target"
return 255
fi
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
}

View file

@ -0,0 +1,16 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/google/brotli.git"
SCRIPT_COMMIT="ed1995b6bda19244070ab5d331111f16f67c8054"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" brotli
cd brotli
mkdir build && cd build
cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF ..
ninja -j"$(nproc)"
ninja install
}

View file

@ -0,0 +1,31 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/xiph/vorbis.git"
SCRIPT_TAG="v1.3.7"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" vorbis
cd vorbis
./autogen.sh
local myconf=(
--prefix="$FFBUILD_PREFIX"
--disable-shared
--enable-static
--disable-oggtest
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--host="$FFBUILD_TOOLCHAIN"
)
else
echo "Unknown target"
return 255
fi
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
}

View file

@ -0,0 +1,46 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/KhronosGroup/OpenCL-Headers.git"
SCRIPT_REPO2="https://github.com/KhronosGroup/OpenCL-ICD-Loader.git"
SCRIPT_TAG="v2023.04.17"
ffbuild_dockerbuild() {
mkdir opencl && cd opencl
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" headers
mkdir -p "$FFBUILD_PREFIX"/include/CL
cp -r headers/CL/* "$FFBUILD_PREFIX"/include/CL/.
git-mini-clone "$SCRIPT_REPO2" "$SCRIPT_TAG" loader
cd loader
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" \
-DOPENCL_ICD_LOADER_HEADERS_DIR="$FFBUILD_PREFIX"/include -DOPENCL_ICD_LOADER_BUILD_SHARED_LIBS=OFF \
-DOPENCL_ICD_LOADER_DISABLE_OPENCLON12=ON -DOPENCL_ICD_LOADER_PIC=ON \
-DOPENCL_ICD_LOADER_BUILD_TESTING=OFF -DBUILD_TESTING=OFF ..
make -j"$(nproc)"
make install
echo "prefix=$FFBUILD_PREFIX" >OpenCL.pc
echo "exec_prefix=\${prefix}" >>OpenCL.pc
echo "libdir=\${exec_prefix}/lib" >>OpenCL.pc
echo "includedir=\${prefix}/include" >>OpenCL.pc
echo >>OpenCL.pc
echo "Name: OpenCL" >>OpenCL.pc
echo "Description: OpenCL ICD Loader" >>OpenCL.pc
echo "Version: 9999" >>OpenCL.pc
echo "Cflags: -I\${includedir}" >>OpenCL.pc
if [[ $TARGET == linux* ]]; then
echo "Libs: -L\${libdir} -lOpenCL" >>OpenCL.pc
echo "Libs.private: -ldl" >>OpenCL.pc
elif [[ $TARGET == win* ]]; then
echo "Libs: -L\${libdir} -l:OpenCL.a" >>OpenCL.pc
echo "Libs.private: -lole32 -lshlwapi -lcfgmgr32" >>OpenCL.pc
fi
mkdir -p "$FFBUILD_PREFIX"/lib/pkgconfig
mv OpenCL.pc "$FFBUILD_PREFIX"/lib/pkgconfig/OpenCL.pc
}

View file

@ -0,0 +1,40 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/Netflix/vmaf.git"
SCRIPT_COMMIT="5ee0051cd7b1337e033558910c30525d73edfd76"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" vmaf
cd vmaf
# Kill build of unused and broken tools
echo > libvmaf/tools/meson.build
mkdir build && cd build
local myconf=(
--prefix="$FFBUILD_PREFIX"
--buildtype=release
--default-library=static
-Dbuilt_in_models=true
-Denable_tests=false
-Denable_docs=false
-Denable_avx512=true
-Denable_float=true
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--cross-file=/cross.meson
)
else
echo "Unknown target"
return 255
fi
meson "${myconf[@]}" ../libvmaf
ninja -j"$(nproc)"
ninja install
sed -i 's/Libs.private:/Libs.private: -lstdc++/; t; $ a Libs.private: -lstdc++' "$FFBUILD_PREFIX"/lib/pkgconfig/libvmaf.pc
}

View file

@ -0,0 +1,12 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git"
SCRIPT_COMMIT="bd5db31d3d8ea1fae7002dd903898599bdb7d97a"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" amf
cd amf
mkdir -p "$FFBUILD_PREFIX"/include
mv amf/public/include "$FFBUILD_PREFIX"/include/AMF
}

View file

@ -0,0 +1,41 @@
#!/bin/bash
SCRIPT_REPO="https://code.videolan.org/videolan/dav1d.git"
SCRIPT_TAG="1.2.1"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" dav1d
cd dav1d
mkdir build && cd build
local myconf=(
-Denable_docs=false
-Denable_tools=false
-Denable_tests=false
-Denable_examples=false
--prefix=/opt/dav1d
--buildtype=release
--default-library=shared
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--cross-file=/cross.meson
)
else
echo "Unknown target"
return 255
fi
meson "${myconf[@]}" ..
ninja -j"$(nproc)"
ninja install
sed -i "s@^prefix=/opt/dav1d\$@prefix=${FFBUILD_PREFIX}@" /opt/dav1d/lib/pkgconfig/dav1d.pc
cp -nav /opt/dav1d/* "${FFBUILD_PREFIX}/"
mkdir -p /opt/dlls/
cp -nav /opt/dav1d/* /opt/dlls/
rm -r /opt/dlls/lib/pkgconfig
}

View file

@ -0,0 +1,11 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/FFmpeg/nv-codec-headers.git"
SCRIPT_COMMIT="4fd7be29a431441ca31b8db0155875ae2ff4ed47"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" ffnvcodec
cd ffnvcodec
make PREFIX="$FFBUILD_PREFIX" install
}

View file

@ -0,0 +1,33 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/ultravideo/kvazaar.git"
SCRIPT_TAG="v2.2.0"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" kvazaar
cd kvazaar
./autogen.sh
local myconf=(
--prefix="$FFBUILD_PREFIX"
--disable-shared
--enable-static
--with-pic
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--host="$FFBUILD_TOOLCHAIN"
)
else
echo "Unknown target"
return 255
fi
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
echo "Cflags.private: -DKVZ_STATIC_LIB" >>"$FFBUILD_PREFIX"/lib/pkgconfig/kvazaar.pc
}

View file

@ -0,0 +1,32 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/strukturag/libde265.git"
SCRIPT_TAG="v1.0.11"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" libde265
cd libde265
autoreconf -i
local myconf=(
--prefix="$FFBUILD_PREFIX"
--disable-shared
--enable-static
--disable-dec265
--disable-sherlock265
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--host="$FFBUILD_TOOLCHAIN"
)
else
echo "Unknown target"
return 255
fi
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
}

View file

@ -0,0 +1,57 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/libjxl/libjxl.git"
SCRIPT_COMMIT="7263ec97397a8113cfa4012bf84ca4618198df3b"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" jxl
cd jxl
git submodule update --init --recursive --depth 1 --recommend-shallow third_party/{highway,skcms}
mkdir build && cd build
if [[ $TARGET == linux* ]]; then
# our glibc is too old(<2.25), and their detection fails for some reason
export CXXFLAGS="$CXXFLAGS -DVQSORT_GETRANDOM=0 -DVQSORT_SECURE_SEED=0"
elif [[ $TARGET == win* ]]; then
# Fix AVX2 related crash due to unaligned stack memory
export CXXFLAGS="$CXXFLAGS -Wa,-muse-unaligned-vector-move"
export CFLAGS="$CFLAGS -Wa,-muse-unaligned-vector-move"
fi
cmake -G Ninja \
-DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" \
-DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DBUILD_SHARED_LIBS=OFF \
-DJPEGXL_STATIC=OFF \
-DJPEGXL_ENABLE_TOOLS=OFF \
-DJPEGXL_ENABLE_VIEWERS=OFF \
-DJPEGXL_EMSCRIPTEN=OFF \
-DJPEGXL_ENABLE_DOXYGEN=OFF \
-DBUILD_TESTING=OFF \
-DJPEGXL_ENABLE_EXAMPLES=OFF \
-DJPEGXL_ENABLE_MANPAGES=OFF \
-DJPEGXL_ENABLE_JNI=OFF \
-DJPEGXL_ENABLE_PLUGINS=OFF \
-DJPEGXL_ENABLE_DEVTOOLS=OFF \
-DJPEGXL_ENABLE_BENCHMARK=OFF \
-DJPEGXL_BUNDLE_LIBPNG=OFF \
-DJPEGXL_ENABLE_SJPEG=OFF \
-DJPEGXL_FORCE_SYSTEM_BROTLI=ON \
..
ninja -j"$(nproc)"
ninja install
echo "Cflags.private: -DJXL_STATIC_DEFINE=1" >>"${FFBUILD_PREFIX}"/lib/pkgconfig/libjxl.pc
echo "Libs.private: -lstdc++" >>"${FFBUILD_PREFIX}"/lib/pkgconfig/libjxl.pc
echo "Cflags.private: -DJXL_STATIC_DEFINE=1" >>"${FFBUILD_PREFIX}"/lib/pkgconfig/libjxl_threads.pc
echo "Libs.private: -lstdc++" >>"${FFBUILD_PREFIX}"/lib/pkgconfig/libjxl_threads.pc
if [[ $TARGET == win* ]]; then
echo "Libs.private: -ladvapi32" >>"${FFBUILD_PREFIX}"/lib/pkgconfig/libjxl.pc
echo "Libs.private: -ladvapi32" >>"${FFBUILD_PREFIX}"/lib/pkgconfig/libjxl_threads.pc
fi
}

View file

@ -0,0 +1,37 @@
#!/bin/bash
SCRIPT_REPO="https://svn.code.sf.net/p/lame/svn/trunk/lame"
SCRIPT_REV="6507"
ffbuild_dockerbuild() {
retry-tool sh -c "rm -rf lame && svn checkout '${SCRIPT_REPO}@${SCRIPT_REV}' lame"
cd lame
autoreconf -i
local myconf=(
--prefix="$FFBUILD_PREFIX"
--disable-shared
--enable-static
--enable-nasm
--disable-gtktest
--disable-cpml
--disable-frontend
--disable-decoder
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--host="$FFBUILD_TOOLCHAIN"
)
else
echo "Unknown target"
return 255
fi
export CFLAGS="$CFLAGS -DNDEBUG"
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
}

View file

@ -0,0 +1,31 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/xiph/opus.git"
SCRIPT_TAG="v1.4"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" opus
cd opus
./autogen.sh
local myconf=(
--prefix="$FFBUILD_PREFIX"
--disable-shared
--enable-static
--disable-extra-programs
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--host="$FFBUILD_TOOLCHAIN"
)
else
echo "Unknown target"
return 255
fi
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
}

View file

@ -0,0 +1,36 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/xiph/theora.git"
SCRIPT_COMMIT="7180717276af1ebc7da15c83162d6c5d6203aabf"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" theora
cd theora
./autogen.sh
local myconf=(
--prefix="$FFBUILD_PREFIX"
--disable-shared
--enable-static
--with-pic
--disable-examples
--disable-oggtest
--disable-vorbistest
--disable-spec
--disable-doc
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--host="$FFBUILD_TOOLCHAIN"
)
else
echo "Unknown target"
return 255
fi
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
}

View file

@ -0,0 +1,53 @@
#!/bin/bash
SCRIPT_REPO="https://chromium.googlesource.com/webm/libvpx"
SCRIPT_TAG="v1.13.0"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" libvpx
cd libvpx
local myconf=(
--disable-shared
--enable-static
--enable-pic
--disable-examples
--disable-tools
--disable-docs
--disable-unit-tests
--enable-vp9-highbitdepth
--prefix="$FFBUILD_PREFIX"
)
if [[ $TARGET == win64 ]]; then
myconf+=(
--target=x86_64-win64-gcc
)
export CROSS="$FFBUILD_CROSS_PREFIX"
elif [[ $TARGET == win32 ]]; then
myconf+=(
--target=x86-win32-gcc
)
export CROSS="$FFBUILD_CROSS_PREFIX"
elif [[ $TARGET == linux64 ]]; then
myconf+=(
--target=x86_64-linux-gcc
)
export CROSS="$FFBUILD_CROSS_PREFIX"
elif [[ $TARGET == linuxarm64 ]]; then
myconf+=(
--target=arm64-linux-gcc
)
export CROSS="$FFBUILD_CROSS_PREFIX"
else
echo "Unknown target"
return 255
fi
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
# Work around strip breaking LTO symbol index
"$RANLIB" "$FFBUILD_PREFIX"/lib/libvpx.a
}

View file

@ -0,0 +1,40 @@
#!/bin/bash
SCRIPT_REPO="https://chromium.googlesource.com/webm/libwebp"
SCRIPT_TAG="v1.3.1-rc1"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" webp
cd webp
./autogen.sh
local myconf=(
--prefix="$FFBUILD_PREFIX"
--disable-shared
--enable-static
--with-pic
--enable-libwebpmux
--disable-libwebpextras
--disable-libwebpdemux
--disable-sdl
--disable-gl
--disable-png
--disable-jpeg
--disable-tiff
--disable-gif
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--host="$FFBUILD_TOOLCHAIN"
)
else
echo "Unknown target"
return 255
fi
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
}

View file

@ -0,0 +1,22 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/oneapi-src/oneVPL.git"
SCRIPT_TAG="v2023.3.0"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" onevpl
cd onevpl
mkdir build && cd build
cmake -GNinja -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" \
-DCMAKE_INSTALL_BINDIR="$FFBUILD_PREFIX"/bin -DCMAKE_INSTALL_LIBDIR="$FFBUILD_PREFIX"/lib \
-DBUILD_DISPATCHER=ON -DBUILD_DEV=ON \
-DBUILD_PREVIEW=OFF -DBUILD_TOOLS=OFF -DBUILD_TOOLS_ONEVPL_EXPERIMENTAL=OFF -DINSTALL_EXAMPLE_CODE=OFF \
-DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF ..
ninja -j"$(nproc)"
ninja install
rm -rf "$FFBUILD_PREFIX"/{etc,share}
}

View file

@ -0,0 +1,22 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/kcat/openal-soft.git"
SCRIPT_COMMIT="cd781b1511d437816aac65f89646bd80dbf7c040"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" openal
cd openal
mkdir cm_build && cd cm_build
cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" \
-DLIBTYPE=STATIC -DALSOFT_UTILS=OFF -DALSOFT_EXAMPLES=OFF ..
make -j"$(nproc)"
make install
echo "Libs.private: -lstdc++" >>"$FFBUILD_PREFIX"/lib/pkgconfig/openal.pc
if [[ $TARGET == win* ]]; then
echo "Libs.private: -lole32" >>"$FFBUILD_PREFIX"/lib/pkgconfig/openal.pc
fi
}

View file

@ -0,0 +1,15 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/uclouvain/openjpeg.git"
SCRIPT_COMMIT="1ee6d115e80036d1d38bad7f95a680bfc612c1bf"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" openjpeg
cd openjpeg
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DBUILD_SHARED_LIBS=OFF -DBUILD_PKGCONFIG_FILES=ON -DBUILD_CODEC=OFF -DWITH_ASTYLE=OFF -DBUILD_TESTING=OFF ..
make -j"$(nproc)"
make install
}

View file

@ -0,0 +1,49 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/xiph/rav1e.git"
SCRIPT_TAG="v0.6.6"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" rav1e
cd rav1e
local myconf=(
--prefix=/opt/rav1e
--library-type=cdylib
--release
)
if [[ -n "$FFBUILD_RUST_TARGET" ]]; then
unset PKG_CONFIG_LIBDIR
export CC="gcc"
export CXX="g++"
export TARGET_CC="${FFBUILD_CROSS_PREFIX}gcc"
export TARGET_CXX="${FFBUILD_CROSS_PREFIX}g++"
export CROSS_COMPILE=1
export TARGET_CFLAGS="$CFLAGS"
export TARGET_CXXFLAGS="$CFLAGS"
unset CFLAGS
unset CXXFLAGS
myconf+=(
--target="$FFBUILD_RUST_TARGET"
)
cat <<EOF >$CARGO_HOME/config.toml
[target.$FFBUILD_RUST_TARGET]
linker = "${FFBUILD_CROSS_PREFIX}gcc"
ar = "${FFBUILD_CROSS_PREFIX}ar"
EOF
fi
cargo cinstall -v "${myconf[@]}"
chmod 644 /opt/rav1e/lib/*rav1e*
sed -i "s@^prefix=/opt/rav1e\$@prefix=${FFBUILD_PREFIX}@" /opt/rav1e/lib/pkgconfig/rav1e.pc
cp -nav /opt/rav1e/* "${FFBUILD_PREFIX}/"
mkdir -p /opt/dlls/
cp -nav /opt/rav1e/* /opt/dlls/
rm -r /opt/dlls/lib/pkgconfig
}

View file

@ -0,0 +1,17 @@
#!/bin/bash
SCRIPT_REPO="https://git.code.sf.net/p/soxr/code"
SCRIPT_TAG="0.1.3"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" soxr
cd soxr
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DWITH_OPENMP=ON -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=OFF ..
make -j"$(nproc)"
make install
echo "Libs.private: -lgomp" >>"$FFBUILD_PREFIX"/lib/pkgconfig/soxr.pc
}

View file

@ -0,0 +1,35 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/njh/twolame.git"
SCRIPT_COMMIT="90b694b6125dbe23a346bd5607a7fb63ad2785dc"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" twolame
cd twolame
NOCONFIGURE=1 ./autogen.sh
touch doc/twolame.1
local myconf=(
--prefix="$FFBUILD_PREFIX"
--with-pic
--disable-shared
--enable-static
--disable-sndfile
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--host="$FFBUILD_TOOLCHAIN"
)
else
echo "Unknown target"
return 255
fi
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
sed -i 's/Cflags:/Cflags: -DLIBTWOLAME_STATIC/' "$FFBUILD_PREFIX"/lib/pkgconfig/twolame.pc
}

View file

@ -0,0 +1,25 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/KhronosGroup/Vulkan-Headers.git"
SCRIPT_COMMIT="v1.3.252"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" vkheaders
cd vkheaders
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" ..
make -j"$(nproc)"
make install
cat >"$FFBUILD_PREFIX"/lib/pkgconfig/vulkan.pc <<EOF
prefix=$FFBUILD_PREFIX
includedir=\${prefix}/include
Name: vulkan
Version: ${SCRIPT_COMMIT:1}
Description: Vulkan (Headers Only)
Cflags: -I\${includedir}
EOF
}

View file

@ -0,0 +1,37 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/google/shaderc.git"
SCRIPT_TAG="v2023.4"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" shaderc
cd shaderc
./utils/git-sync-deps
mkdir build && cd build
cmake -GNinja -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" \
-DSHADERC_SKIP_TESTS=ON -DSHADERC_SKIP_EXAMPLES=ON -DSHADERC_SKIP_COPYRIGHT_CHECK=ON \
-DENABLE_EXCEPTIONS=ON -DENABLE_CTEST=OFF -DENABLE_GLSLANG_BINARIES=OFF -DSPIRV_SKIP_EXECUTABLES=ON \
-DSPIRV_TOOLS_BUILD_STATIC=ON -DBUILD_SHARED_LIBS=OFF ..
ninja -j"$(nproc)"
ninja install
# for some reason, this does not get installed...
cp libshaderc_util/libshaderc_util.a "$FFBUILD_PREFIX"/lib
echo "Libs: -lstdc++" >>"$FFBUILD_PREFIX"/lib/pkgconfig/shaderc_combined.pc
echo "Libs: -lstdc++" >>"$FFBUILD_PREFIX"/lib/pkgconfig/shaderc_static.pc
cp "$FFBUILD_PREFIX"/lib/pkgconfig/{shaderc_combined,shaderc}.pc
if [[ $TARGET == win* ]]; then
rm -r "$FFBUILD_PREFIX"/bin "$FFBUILD_PREFIX"/lib/*.dll.a
elif [[ $TARGET == linux* ]]; then
rm -r "$FFBUILD_PREFIX"/bin "$FFBUILD_PREFIX"/lib/*.so*
else
echo "Unknown target"
return 255
fi
}

View file

@ -0,0 +1,37 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/KhronosGroup/SPIRV-Cross.git"
SCRIPT_TAG="sdk-1.3.250.0"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" spirv-cross
cd spirv-cross
VER_MAJ="$(grep 'set(spirv-cross-abi-major' CMakeLists.txt | sed -re 's/.* ([0-9]+)\)/\1/')"
VER_MIN="$(grep 'set(spirv-cross-abi-minor' CMakeLists.txt | sed -re 's/.* ([0-9]+)\)/\1/')"
VER_PCH="$(grep 'set(spirv-cross-abi-patch' CMakeLists.txt | sed -re 's/.* ([0-9]+)\)/\1/')"
VER_FULL="$VER_MAJ.$VER_MIN.$VER_PCH"
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" \
-DSPIRV_CROSS_SHARED=OFF -DSPIRV_CROSS_STATIC=ON -DSPIRV_CROSS_CLI=OFF -DSPIRV_CROSS_ENABLE_TESTS=OFF -DSPIRV_CROSS_FORCE_PIC=ON -DSPIRV_CROSS_ENABLE_CPP=OFF ..
make -j"$(nproc)"
make install
cat >"$FFBUILD_PREFIX"/lib/pkgconfig/spirv-cross-c-shared.pc <<EOF
prefix=$FFBUILD_PREFIX
exec_prefix=\${prefix}
libdir=\${prefix}/lib
sharedlibdir=\${prefix}/lib
includedir=\${prefix}/include/spirv_cross
Name: spirv-cross-c-shared
Description: C API for SPIRV-Cross
Version: $VER_FULL
Requires:
Libs: -L\${libdir} -L\${sharedlibdir} -lspirv-cross-c -lspirv-cross-glsl -lspirv-cross-hlsl -lspirv-cross-reflect -lspirv-cross-msl -lspirv-cross-util -lspirv-cross-core -lstdc++
Cflags: -I\${includedir}
EOF
}

View file

@ -0,0 +1,32 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/mirror/x264.git"
SCRIPT_COMMIT="eaa68fad9e5d201d42fde51665f2d137ae96baf0"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" x264
cd x264
local myconf=(
--disable-cli
--enable-static
--enable-pic
--disable-lavf
--disable-swscale
--prefix="$FFBUILD_PREFIX"
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--host="$FFBUILD_TOOLCHAIN"
--cross-prefix="$FFBUILD_CROSS_PREFIX"
)
else
echo "Unknown target"
return 255
fi
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
}

View file

@ -0,0 +1,62 @@
#!/bin/bash
SCRIPT_REPO="https://bitbucket.org/multicoreware/x265_git.git"
SCRIPT_COMMIT="34532bda12a3a3141880582aa186a59cd4538ae6"
ffbuild_dockerbuild() {
git clone "$SCRIPT_REPO" x265
cd x265
git checkout "$SCRIPT_COMMIT"
local common_config=(
-DCMAKE_INSTALL_PREFIX="/opt/x265"
-DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN"
-DCMAKE_BUILD_TYPE=Release
-DENABLE_CLI=OFF
-DCMAKE_ASM_NASM_FLAGS=-w-macro-params-legacy
)
mkdir 8bit 10bit 12bit
cmake -S source -B 12bit -G Ninja \
"${common_config[@]}" \
-DHIGH_BIT_DEPTH=ON \
-DEXPORT_C_API=OFF \
-DENABLE_SHARED=OFF \
-DENABLE_STATIC=ON \
-DMAIN12=ON
ninja -C 12bit -j"$(nproc)"
cmake -S source -B 10bit -G Ninja \
"${common_config[@]}" \
-DENABLE_HDRDENABLE_HDR10_PLUS=ON \
-DHIGH_BIT_DEPTH=ON \
-DEXPORT_C_API=OFF \
-DENABLE_SHARED=OFF \
-DENABLE_STATIC=ON
ninja -C 10bit -j"$(nproc)"
cmake -S source -B 8bit -G Ninja \
"${common_config[@]}" \
-DEXTRA_LIB='x265_main10.a;x265_main12.a' \
-DENABLE_HDRDENABLE_HDR10_PLUS=ON \
-DEXTRA_LINK_FLAGS=-L. \
-DENABLE_SHARED=ON \
-DENABLE_STATIC=OFF \
-DLINKED_10BIT=ON \
-DLINKED_12BIT=ON
ln -s ../10bit/libx265.a 8bit/libx265_main10.a
ln -s ../12bit/libx265.a 8bit/libx265_main12.a
ninja -C 8bit -j"$(nproc)"
ninja -C 8bit install
sed -ri 's/^(Libs.private:.*)$/\1 -lstdc++/' /opt/x265/lib/pkgconfig/x265.pc
sed -i "s@^prefix=/opt/x265\$@prefix=${FFBUILD_PREFIX}@" /opt/x265/lib/pkgconfig/x265.pc
cp -nav /opt/x265/* "${FFBUILD_PREFIX}/"
mkdir -p /opt/dlls/
cp -nav /opt/x265/* /opt/dlls/
rm -r /opt/dlls/lib/pkgconfig
}

View file

@ -0,0 +1,41 @@
#!/bin/bash
SCRIPT_REPO="http://svn.xvid.org/trunk/xvidcore"
SCRIPT_REV="2198"
ffbuild_dockerbuild() {
retry-tool sh -c "rm -rf xvid && svn checkout --username 'anonymous' --password '' '${SCRIPT_REPO}@${SCRIPT_REV}' xvid"
cd xvid
cd build/generic
# The original code fails on a two-digit major...
sed -i -e 's/GCC_MAJOR=.*/GCC_MAJOR=10/' \
-e 's/GCC_MINOR=.*/GCC_MINOR=0/' \
configure.in
./bootstrap.sh
local myconf=(
--prefix="$FFBUILD_PREFIX"
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--host="$FFBUILD_TOOLCHAIN"
)
else
echo "Unknown target"
return 255
fi
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
if [[ $TARGET == win* ]]; then
rm "$FFBUILD_PREFIX"/{bin/libxvidcore.dll,lib/libxvidcore.dll.a}
elif [[ $TARGET == linux* ]]; then
rm "$FFBUILD_PREFIX"/lib/libxvidcore.so*
fi
}

View file

@ -0,0 +1,32 @@
#!/bin/bash
SCRIPT_REPO="https://github.com/sekrit-twc/zimg.git"
SCRIPT_COMMIT="332aaac5e99de46ddd5663092779742ec1958b11"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_COMMIT" zimg
cd zimg
git submodule update --init --recursive --depth=1
./autogen.sh
local myconf=(
--prefix="$FFBUILD_PREFIX"
--disable-shared
--enable-static
--with-pic
)
if [[ $TARGET == win* || $TARGET == linux* ]]; then
myconf+=(
--host="$FFBUILD_TOOLCHAIN"
)
else
echo "Unknown target"
return 255
fi
./configure "${myconf[@]}"
make -j"$(nproc)"
make install
}

View file

@ -0,0 +1,89 @@
#!/bin/bash
SCRIPT_REPO='https://github.com/FFmpeg/FFmpeg.git'
SCRIPT_BRANCH="release/${FFMPEG_VERSION:-6.0}"
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_BRANCH" ffmpeg
cd ffmpeg
./configure \
--cpu="x86_64" \
--arch='x86_64' \
--prefix="/opt/dlls" \
--target-os=mingw32 \
--pkg-config=pkg-config \
--pkg-config-flags="--static" \
--cross-prefix="$FFBUILD_CROSS_PREFIX" \
--disable-alsa \
--disable-debug \
--disable-doc \
--disable-indevs \
--disable-libplacebo \
--disable-neon-clobber-test \
--disable-network \
--disable-outdevs \
--disable-postproc \
--disable-programs \
--disable-schannel \
--disable-static \
--disable-v4l2-m2m \
--disable-vaapi \
--disable-vdpau \
--disable-w32threads \
--disable-xmm-clobber-test \
--enable-amf \
--enable-avcodec \
--enable-avfilter \
--enable-avformat \
--enable-bzlib \
--enable-cuda-llvm \
--enable-ffnvcodec \
--enable-gpl \
--enable-gray \
--enable-inline-asm \
--enable-libdav1d \
--enable-libjxl \
--enable-libkvazaar \
--enable-libmp3lame \
--enable-libopenjpeg \
--enable-libopus \
--enable-librav1e \
--enable-libshaderc \
--enable-libsoxr \
--enable-libtheora \
--enable-libtwolame \
--enable-libvmaf \
--enable-libvorbis \
--enable-libvpl \
--enable-libvpx \
--enable-libwebp \
--enable-libx264 \
--enable-libx265 \
--enable-libxvid \
--enable-libzimg \
--enable-lzma \
--enable-openal \
--enable-opencl \
--enable-opengl \
--enable-pic \
--enable-postproc \
--enable-pthreads \
--enable-shared \
--enable-small \
--enable-swscale \
--enable-version3 \
--enable-vulkan \
--enable-zlib \
--enable-cross-compile \
--extra-cflags='-DLIBTWOLAME_STATIC' \
--extra-cxxflags='' \
--extra-ldflags='-pthread' \
--extra-ldexeflags='' \
--extra-libs='-lgomp -lstdc++'
make -j"$(nproc)" V=1
make PREFIX="/opt/dlls" install
}

View file

@ -0,0 +1,37 @@
#!/bin/bash
SCRIPT_REPO='https://github.com/strukturag/libheif.git'
SCRIPT_TAG='v1.16.2'
ffbuild_dockerbuild() {
git-mini-clone "$SCRIPT_REPO" "$SCRIPT_TAG" libheif
cd libheif
mkdir build && cd build
cmake \
-GNinja \
-DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX='/opt/dlls' \
-DCMAKE_INSTALL_BINDIR='/opt/dlls/bin' \
-DCMAKE_INSTALL_LIBDIR='/opt/dlls/lib' \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TESTING=OFF \
-DWITH_EXAMPLES=OFF \
-DWITH_FUZZERS=OFF \
-DWITH_REDUCED_VISIBILITY=ON \
-DWITH_DEFLATE_HEADER_COMPRESSION=ON \
-DWITH_AOM_DECODER_PLUGIN=OFF \
-DWITH_AOM_ENCODER_PLUGIN=OFF \
-DWITH_DAV1D_PLUGIN=OFF \
-DWITH_LIBDE265_PLUGIN=OFF \
-DWITH_RAV1E_PLUGIN=OFF \
-DWITH_SvtEnc_PLUGIN=OFF \
-DWITH_X265_PLUGIN=OFF \
..
ninja -j"$(nproc)"
ninja install
}

View file

@ -58,7 +58,7 @@ WORKDIR /srv
# Setup macports
RUN osxcross-macports --help
LABEL org.opencontainers.image.title="alpine-osxcross" \
LABEL org.opencontainers.image.title="osxcross" \
# Version is macOS SDK version + osxcross commit hash
org.opencontainers.image.version="12.3-50e86eb" \
org.opencontainers.image.authors="Vítor Vasconcellos <vasconcellos.dev@gmail.com>, Spacedrive <support@spacedrive.com>" \

View file

@ -1,3 +1,5 @@
# Set default value of 0 for external command exit code
$LASTEXITCODE = 0
# Enables strict mode, which causes PowerShell to treat uninitialized variables, undefined functions, and other common errors as terminating errors.
$ErrorActionPreference = if ($env:CI) { 'Stop' } else { 'Inquire' }
Set-StrictMode -Version Latest
@ -62,12 +64,16 @@ function Add-DirectoryToPath($directory) {
Reset-Path
}
$ghUrl = 'https://api.github.com/repos'
$sdGhPath = 'spacedriveapp/spacedrive'
function Invoke-RestMethodGithub {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string]$Uri,
[string]$Method = 'GET',
[string]$OutFile = $null,
[hashtable]$Headers = @{},
[string]$UserAgent = 'PowerShell'
)
@ -82,6 +88,7 @@ function Invoke-RestMethodGithub {
$params = @{
Uri = $Uri
Method = $Method
OutFile = $OutFile
Headers = $Headers
UserAgent = $UserAgent
}
@ -89,6 +96,25 @@ function Invoke-RestMethodGithub {
Invoke-RestMethod @params
}
function DownloadArtifact {
param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$ArtifactPath,
[string]$OutFile
)
try {
Invoke-RestMethodGithub -Uri "$ghUrl/$sdGhPath/actions/artifacts/$($($ArtifactPath -split '/')[3])/zip" -OutFile $OutFile
} catch {
# nightly.link is a workaround for the lack of a public GitHub API to download artifacts from a workflow run
# https://github.com/actions/upload-artifact/issues/51
# Use it when running in environments that are not authenticated with GitHub
Write-Host 'Failed to download artifact from Github, falling back to nightly.link' -ForegroundColor Yellow
Invoke-RestMethodGithub -Uri "https://nightly.link/${sdGhPath}/${ArtifactPath}" -OutFile $OutFile
}
}
# Reset PATH to ensure the script doesn't have stale Path entries
Reset-Path
@ -106,6 +132,8 @@ $wingetValidExit = 0, -1978335189, -1978335153, -1978335135
# See https://github.com/spacedriveapp/spacedrive/issues/677
$llvmVersion = [Version]'15.0.7'
$ffmpegVersion = '6.0'
# Change CWD to project root
Set-Location $projectRoot
Remove-Item -Force -ErrorAction SilentlyContinue -Path "$projectRoot\.cargo\config"
@ -134,6 +162,8 @@ https://learn.microsoft.com/windows/package-manager/winget/
'@
}
# TODO: Check system winget version is greater or equal to v1.4.10052
# Check connectivity to GitHub
$ProgressPreference = 'SilentlyContinue'
if (-not ((Test-NetConnection -ComputerName 'github.com' -Port 80).TcpTestSucceeded)) {
@ -144,6 +174,7 @@ https://learn.microsoft.com/windows/package-manager/winget/
Write-Host
Read-Host 'Press Enter to continue'
# TODO: Force update Visual Studio build tools
Write-Host
Write-Host 'Installing Visual Studio Build Tools...' -ForegroundColor Yellow
Write-Host 'This will take some time as it involves downloading several gigabytes of data....' -ForegroundColor Cyan
@ -263,11 +294,11 @@ New-Item -Force -ErrorAction SilentlyContinue -ItemType Directory -Path "$projec
# --
Write-Host
Write-Host 'Retrieving protobuf version...' -ForegroundColor Yellow
Write-Host 'Retrieving protobuf build...' -ForegroundColor Yellow
$filename = $null
$downloadUri = $null
$releasesUri = 'https://api.github.com/repos/protocolbuffers/protobuf/releases'
$releasesUri = "${ghUrl}/protocolbuffers/protobuf/releases"
$filenamePattern = '*-win64.zip'
$releases = Invoke-RestMethodGithub -Uri $releasesUri
@ -287,7 +318,7 @@ if (-not ($filename -and $downloadUri)) {
Exit-WithError "Couldn't find a protobuf compiler installer"
}
Write-Host 'Dowloading protobuf zip...' -ForegroundColor Yellow
Write-Host "Dowloading protobuf zip from ${downloadUri}..." -ForegroundColor Yellow
Start-BitsTransfer -TransferType Download -Source $downloadUri -Destination "$temp\protobuf.zip"
Write-Host 'Expanding protobuf zip...' -ForegroundColor Yellow
@ -296,74 +327,77 @@ Remove-Item -Force -ErrorAction SilentlyContinue -Path "$temp\protobuf.zip"
# --
Write-Host
Write-Host 'Retrieving ffmpeg version...' -ForegroundColor Yellow
Write-Host "Retrieving ffmpeg-${ffmpegVersion} build..." -ForegroundColor Yellow
# Run first to update packages
cargo metadata --format-version 1 | Out-Null
$page = 1
while ($page -gt 0) {
$success = ''
Invoke-RestMethodGithub -Uri `
"${ghUrl}/${sdGhPath}/actions/workflows/ffmpeg-windows.yml/runs?page=$page&per_page=100&status=success" `
| ForEach-Object {
if (-not $_.workflow_runs) {
Exit-WithError "Error: $_"
}
# Get ffmpeg-sys-next version
$ffmpegVersion = (cargo metadata --format-version 1 | ConvertFrom-Json).packages.dependencies | Where-Object {
$_.name -like 'ffmpeg-sys-next'
} | Select-Object -ExpandProperty 'req' | ForEach-Object {
$_ -replace '[~^<>=!*]+', ''
} | Sort-Object -Unique | Select-Object -Last 1
$_.workflow_runs | ForEach-Object {
$artifactPath = (
(Invoke-RestMethod -Uri ($_.artifacts_url | Out-String) -Method Get).artifacts `
| Where-Object {
$_.name -eq "ffmpeg-${ffmpegVersion}-x86_64"
} | ForEach-Object {
$id = $_.id
$workflowRunId = $_.workflow_run.id
"suites/${workflowRunId}/artifacts/${id}"
} | Select-Object -First 1
)
if ($LASTEXITCODE -ne 0) {
Exit-WithError 'Failed to get ffmpeg-sys-next version'
}
$filename = $null
$downloadUri = $null
$releasesUri = 'https://api.github.com/repos/GyanD/codexffmpeg/releases'
$filenamePattern = '*-full_build-shared.zip'
# Downloads a build of ffmpeg from GitHub compatible with the declared ffmpeg-sys-next version
$releases = Invoke-RestMethodGithub -Uri $releasesUri
$version = $ffmpegVersion
while (-not ($filename -and $downloadUri) -and $version) {
for ($i = 0; $i -lt $releases.Count; $i++) {
$release = $releases[$i]
if ($release.tag_name -eq $version) {
foreach ($asset in $release.assets) {
if ($asset.name -like $filenamePattern) {
$filename = $asset.name
$downloadUri = $asset.browser_download_url
$i = $releases.Count
break
try {
if ([string]::IsNullOrEmpty($artifactPath)) {
throw 'Empty argument'
}
# Download and extract the artifact
Write-Host "Dowloading ffmpeg-${ffmpegVersion} zip from artifact ${artifactPath}..." -ForegroundColor Yellow
DownloadArtifact -ArtifactPath $artifactPath -OutFile "$temp/ffmpeg.zip"
Write-Host "Expanding ffmpeg-${ffmpegVersion} zip..." -ForegroundColor Yellow
Expand-Archive "$temp/ffmpeg.zip" "$projectRoot\target\Frameworks" -Force
Remove-Item -Force -ErrorAction SilentlyContinue -Path "$temp/ffmpeg.zip"
$success = 'yes'
break
} catch {
$errorMessage = $_.Exception.Message
Write-Host "Error: $errorMessage" -ForegroundColor Red
Write-Host 'Failed to download ffmpeg artifact release, trying again in 1sec...'
Start-Sleep -Seconds 1
continue
}
}
}
$version = $version -replace '\.?\d+$'
if ($success -eq 'yes') {
break
}
$page++
Write-Output 'ffmpeg artifact not found, trying again in 1sec...'
Start-Sleep -Seconds 1
}
if (-not ($filename -and $downloadUri)) {
Exit-WithError "Couldn't find a ffmpeg installer for version: $ffmpegVersion"
if ($success -ne 'yes') {
Exit-WithError 'Failed to download ffmpeg files'
}
Write-Host 'Dowloading ffmpeg zip...' -ForegroundColor Yellow
Start-BitsTransfer -TransferType Download -Source $downloadUri -Destination "$temp\ffmpeg.zip"
Write-Host 'Expanding ffmpeg zip...' -ForegroundColor Yellow
# FFmpeg zip contains a subdirectory with the same name as the zip file
Expand-Archive -Force -Path "$temp\ffmpeg.zip" -DestinationPath "$temp"
Remove-Item -Force -ErrorAction SilentlyContinue -Path "$temp\ffmpeg.zip"
$ffmpegDir = "$temp\$([System.IO.Path]::GetFileNameWithoutExtension($fileName))"
$proc = Start-Process -PassThru -Wait -FilePath 'Robocopy.exe' -Verb RunAs -ArgumentList `
"`"$ffmpegDir`" `"$projectRoot\target\Frameworks`" /E /NS /NC /NFL /NDL /NP /NJH /NJS"
# https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy#exit-return-codes
if ($proc.ExitCode -ge 8) {
Exit-WithError 'Failed to copy ffmpeg files'
}
Remove-Item -Force -ErrorAction SilentlyContinue -Recurse -Path "$ffmpegDir"
@(
'[env]',
"PROTOC = `"$("$projectRoot\target\Frameworks\bin\protoc" -replace '\\', '\\')`"",
"FFMPEG_DIR = `"$("$projectRoot\target\Frameworks" -replace '\\', '\\')`"",
'',
'[target.x86_64-pc-windows-msvc]',
"rustflags = [`"-L $("$projectRoot\target\Frameworks\lib" -replace '\\', '\\')`"]",
'',
(Get-Content "$projectRoot\.cargo\config.toml" -Encoding utf8)
) | Out-File -Force -Encoding utf8 -FilePath "$projectRoot\.cargo\config"

View file

@ -6,6 +6,9 @@ if [ "${CI:-}" = "true" ]; then
set -x
fi
# Force xz to use multhreaded extraction
export XZ_OPT='-T0'
SYSNAME="$(uname)"
FFMPEG_VERSION='6.0'
@ -144,7 +147,7 @@ if [ "$SYSNAME" = "Linux" ]; then
DEBIAN_TAURI_DEPS="libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf"
# FFmpeg dependencies
DEBIAN_FFMPEG_DEPS="libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev ffmpeg"
DEBIAN_FFMPEG_DEPS="libheif-dev libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev ffmpeg"
# Webkit2gtk requires gstreamer plugins for video playback to work
DEBIAN_VIDEO_DEPS="gstreamer1.0-libav gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly"
@ -168,7 +171,7 @@ if [ "$SYSNAME" = "Linux" ]; then
ARCH_VIDEO_DEPS="gst-libav gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly"
# FFmpeg dependencies
ARCH_FFMPEG_DEPS="ffmpeg"
ARCH_FFMPEG_DEPS="libheif ffmpeg"
# Bindgen dependencies - it's used by a dependency of Spacedrive
ARCH_BINDGEN_DEPS="clang"
@ -196,7 +199,7 @@ if [ "$SYSNAME" = "Linux" ]; then
FEDORA_OPENSSL_SYS_DEPS="perl-FindBin perl-File-Compare perl-IPC-Cmd perl-File-Copy"
# FFmpeg dependencies
FEDORA_FFMPEG_DEPS="ffmpeg ffmpeg-devel"
FEDORA_FFMPEG_DEPS="libheif-devel ffmpeg ffmpeg-devel"
# Webkit2gtk requires gstreamer plugins for video playback to work
FEDORA_VIDEO_DEPS="gstreamer1-plugin-libav gstreamer1-plugins-base gstreamer1-plugins-good gstreamer1-plugins-good-extras gstreamer1-plugins-bad-free gstreamer1-plugins-bad-free-extras gstreamer1-plugins-ugly-free"
@ -275,7 +278,7 @@ elif [ "$SYSNAME" = "Darwin" ]; then
_page=1
while [ $_page -gt 0 ]; do
# TODO: Filter only actions triggered by the main branch
_success=$(gh_curl "${_gh_url}/${_sd_gh_path}/actions/workflows/ffmpeg.yml/runs?page=${_page}&per_page=100&status=success" \
_success=$(gh_curl "${_gh_url}/${_sd_gh_path}/actions/workflows/ffmpeg-macos.yml/runs?page=${_page}&per_page=100&status=success" \
| jq -r '. as $raw | .workflow_runs | if length == 0 then error("Error: \($raw)") else .[] | .artifacts_url end' \
| while IFS= read -r _artifacts_url; do
if _artifact_path="$(
@ -289,10 +292,16 @@ elif [ "$SYSNAME" = "Darwin" ]; then
)" -r \
'. as $raw | .artifacts | if length == 0 then error("Error: \($raw)") else .[] | select(.name == "ffmpeg-\($version)-\($arch)") | "suites/\(.workflow_run.id)/artifacts/\(.id)" end'
)"; then
# nightly.link is a workaround for the lack of a public GitHub API to download artifacts from a workflow run
# https://github.com/actions/upload-artifact/issues/51
# TODO: Use Github's private API when running on CI
if curl -LSs "https://nightly.link/${_sd_gh_path}/${_artifact_path}" | tar -xOf- | XZ_OPT='-T0' tar -xJf- -C "$_frameworks_dir"; then
if {
gh_curl "${_gh_url}/${_sd_gh_path}/actions/artifacts/$(echo "$_artifact_path" | awk -F/ '{print $4}')/zip" \
| tar -xOf- | tar -xJf- -C "$_frameworks_dir"
} 2>/dev/null; then
printf 'yes'
exit
# nightly.link is a workaround for the lack of a public GitHub API to download artifacts from a workflow run
# https://github.com/actions/upload-artifact/issues/51
# Use it when running in evironments that are not authenticated with github
elif curl -LSs "https://nightly.link/${_sd_gh_path}/${_artifact_path}" | tar -xOf- | tar -xJf- -C "$_frameworks_dir"; then
printf 'yes'
exit
fi
@ -333,18 +342,30 @@ elif [ "$SYSNAME" = "Darwin" ]; then
# Workaround while https://github.com/tauri-apps/tauri/pull/3934 is not merged
echo "Download patched tauri cli.js build..."
case "$_arch" in
x86_64)
_artifact_url="https://nightly.link/${_sd_gh_path}/actions/artifacts/702683038.zip"
;;
arm64)
_artifact_url="https://nightly.link/${_sd_gh_path}/actions/artifacts/702683035.zip"
;;
*)
err "Unsupported architecture: $_arch"
;;
esac
curl -LSs "$_artifact_url" | tar -xf- -C "${_frameworks_dir}/bin"
(
case "$_arch" in
x86_64)
_artifact_id="702683038"
;;
arm64)
_artifact_id="702683035"
;;
*)
err "Unsupported architecture: $_arch"
;;
esac
if ! {
gh_curl "${_gh_url}/${_sd_gh_path}/actions/artifacts/${_artifact_id}/zip" \
| tar -xf- -C "${_frameworks_dir}/bin"
} 2>/dev/null; then
# nightly.link is a workaround for the lack of a public GitHub API to download artifacts from a workflow run
# https://github.com/actions/upload-artifact/issues/51
# Use it when running in evironments that are not authenticated with github
curl -LSs "https://nightly.link/${_sd_gh_path}/actions/artifacts/${_artifact_id}.zip" \
| tar -xf- -C "${_frameworks_dir}/bin"
fi
)
echo "Download protobuf build"
_page=1

View file

@ -1,4 +1,4 @@
name: Build ffmpeg
name: Build ffmpeg macos
on:
push:

55
.github/workflows/ffmpeg-windows.yml vendored Normal file
View file

@ -0,0 +1,55 @@
name: Build ffmpeg windows
on:
push:
paths:
- '.github/workflows/ffmpeg-windows.yml'
- '.github/scripts/ffmpeg-windows/**'
branches:
- main
pull_request:
paths:
- '.github/workflows/ffmpeg-windows.yml'
- '.github/scripts/ffmpeg-windows/**'
workflow_dispatch:
# Cancel previous runs of the same workflow on the same branch.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FFMPEG_VERSION: '6.0'
jobs:
build-ffmpeg-windows:
name: Build ffmpeg for windows
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
install: true
platforms: linux/amd64
driver-opts: |
image=moby/buildkit:master
network=host
- name: Build ffmpeg
run: |
set -euxo pipefail
cd .github/scripts/ffmpeg-windows
docker build --build-arg FFMPEG_VERSION=$FFMPEG_VERSION -o . .
- name: Publish ffmpeg x86_64
uses: actions/upload-artifact@v3
with:
name: ffmpeg-${{ env.FFMPEG_VERSION }}-x86_64
path: .github/scripts/ffmpeg-windows/dlls/*
if-no-files-found: error

View file

@ -1,29 +0,0 @@
FROM debian:stable-slim
# Arguments and labels
ARG USER=spaceboy
LABEL org.opencontainers.image.title="Spacedrive Server"
LABEL org.opencontainers.image.source="https://github.com/spacedriveapp/spacedrive"
# Install dependencies
RUN apt-get update && apt-get install -y libavdevice-dev libavfilter-dev libavformat-dev libavcodec-dev libavutil-dev
# Copy the compiled server CLI into the container
COPY ./server /sdserver
# Expose webserver
EXPOSE 8080
# Create the data directory to store the database
RUN mkdir /data
ENV DATA_DIR /data
# Drop privledges to non-root user
RUN groupadd -g 1001 $USER && \
adduser --system --no-create-home --shell /usr/sbin/nologin --uid 1001 --gid 1001 $USER && \
chown -R $USER /data && \
chmod -R 770 /data
USER $USER
# Run the CLI when the container is started
ENTRYPOINT [ "/sdserver" ]

View file

@ -0,0 +1,86 @@
ARG REPO_REF=main
ARG DEBIAN_FRONTEND=noninteractive
#--
FROM debian:bookworm as base
ARG DEBIAN_FRONTEND
ADD https://gist.githubusercontent.com/HeavenVolkoff/ff7b77b9087f956b8df944772e93c071/raw \
/etc/apt/apt.conf.d/99docker-apt-config
RUN rm -f /etc/apt/apt.conf.d/docker-clean; \
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
apt-get update && apt-get upgrade
#--
FROM base as build
ARG DEBIAN_FRONTEND
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
apt-get install build-essential git sudo unzip wget
RUN wget -qO- https://get.pnpm.io/install.sh | env SHELL=bash PNPM_HOME=/usr/share/pnpm sh -
ENV PNPM_HOME="/usr/share/pnpm" \
PATH="/usr/share/pnpm:$PATH"
RUN pnpm env use --global latest
RUN wget -qO- https://sh.rustup.rs | sh -s -- -yq --profile minimal
ENV PATH="/root/.cargo/bin:$PATH"
WORKDIR /srv
RUN git init spacedrive
RUN git -C spacedrive remote add origin https://github.com/spacedriveapp/spacedrive.git
RUN git -C spacedrive fetch --depth=1 origin "$REPO_REF"
RUN git -C spacedrive config advice.detachedHead false
RUN git -C spacedrive checkout FETCH_HEAD
WORKDIR /srv/spacedrive
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
env CI=true .github/scripts/setup-system.sh
RUN --mount=type=cache,target=/root/.cache/prisma/binaries/cli/ \
pnpm prep
RUN cargo build --release -p server
#--
FROM base
ENV TZ=UTC \
PUID=1000 \
PGID=1000 \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
TMPDIR=/tmp \
LANGUAGE=en \
DATA_DIR=/data
RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \
apt-get install ffmpeg
COPY --chmod=755 entrypoint.sh /usr/bin/
COPY --from=build /srv/spacedrive/target/release/server /usr/bin/
# Expose webserver
EXPOSE 8080
# Create the data directory to store the database
VOLUME [ "/data" ]
# Run the CLI when the container is started
ENTRYPOINT [ "server" ]
LABEL org.opencontainers.image.title="Spacedrive Server" \
org.opencontainers.image.source="https://github.com/spacedriveapp/spacedrive"

View file

@ -0,0 +1,39 @@
#!/usr/bin/env sh
set -eu
# Shortcircuit for non-default commands.
# The last part inside the "{}" is a workaround for the following bug in ash/dash:
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=874264
if [ -n "${1:-}" ] && [ "${1#-}" = "${1}" ] \
&& [ -n "$(command -v -- "${1}")" ] \
&& { ! [ -f "${1}" ] || [ -x "${1}" ]; }; then
exec "$@"
fi
if [ "$(id -u)" -ne 0 ]; then
echo "This container requires executing as root for initial setup, privilages are dropped after" 1>&2
exit 1
fi
echo "Configure unprivileged user"
addgroup --system --gid "${PGID}" spacedrive
adduser --system --disabled-password \
--uid "${PUID}" \
--home /var/empty \
--gecos 'Spacedrive system account' \
--ingroup spacedrive \
spacedrive
passwd -l spacedrive
if [ -n "${TZ:-}" ]; then
echo "Set Timezone to $TZ"
rm -f /etc/localtime
ln -s "/usr/share/zoneinfo/${TZ}" /etc/localtime
echo "$TZ" >/etc/timezone
fi
echo "Fix spacedrive's directories permissions"
chown -R "${PUID}:${PGID}" /data
exec su spacedrive -s /bin/server -- "$@"

View file

@ -91,7 +91,6 @@ strum_macros = "0.24"
hex = "0.4.3"
int-enum = "0.4.0"
[target.'cfg(windows)'.dependencies.winapi-util]
version = "0.1.5"

View file

@ -270,7 +270,6 @@ async fn handle_file(
"webp" => "image/webp",
// PDF document
"pdf" => "application/pdf",
// HEIF/HEIC images
"heif" | "heifs" => "image/heif,image/heif-sequence",
"heic" | "heics" => "image/heic,image/heic-sequence",

View file

@ -125,7 +125,7 @@ pub struct ThumbnailerJobStep {
}
// TOOD(brxken128): validate avci and avcs
#[cfg(all(feature = "heif", target_os = "macos"))]
#[cfg(all(feature = "heif", not(target_os = "linux")))]
const HEIF_EXTENSIONS: [&str; 7] = ["heif", "heifs", "heic", "heics", "avif", "avci", "avcs"];
pub async fn generate_image_thumbnail<P: AsRef<Path>>(
@ -134,7 +134,7 @@ pub async fn generate_image_thumbnail<P: AsRef<Path>>(
) -> Result<(), Box<dyn Error>> {
// Webp creation has blocking code
let webp = block_in_place(|| -> Result<Vec<u8>, Box<dyn Error>> {
#[cfg(all(feature = "heif", target_os = "macos"))]
#[cfg(all(feature = "heif", not(target_os = "linux")))]
let img = {
let ext = file_path
.as_ref()
@ -151,7 +151,7 @@ pub async fn generate_image_thumbnail<P: AsRef<Path>>(
}
};
#[cfg(not(all(feature = "heif", target_os = "macos")))]
#[cfg(not(all(feature = "heif", not(target_os = "linux"))))]
let img = image::open(file_path)?;
let (w, h) = img.dimensions();
@ -199,13 +199,13 @@ pub const fn can_generate_thumbnail_for_video(video_extension: &VideoExtension)
pub const fn can_generate_thumbnail_for_image(image_extension: &ImageExtension) -> bool {
use ImageExtension::*;
#[cfg(all(feature = "heif", target_os = "macos"))]
#[cfg(all(feature = "heif", not(target_os = "linux")))]
let res = matches!(
image_extension,
Jpg | Jpeg | Png | Webp | Gif | Heic | Heics | Heif | Heifs | Avif
);
#[cfg(not(all(feature = "heif", target_os = "macos")))]
#[cfg(not(all(feature = "heif", not(target_os = "linux"))))]
let res = matches!(image_extension, Jpg | Jpeg | Png | Webp | Gif);
res