Skip to content

Commit

Permalink
Add libass and MT Only
Browse files Browse the repository at this point in the history
  • Loading branch information
System233 committed Dec 5, 2024
1 parent a750108 commit 26dba63
Show file tree
Hide file tree
Showing 21 changed files with 457 additions and 114 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ jobs:
pkgconf
yasm
nasm
libtool
bison
automake
autoconf
- name: Remove MSYS2 link
shell: msys2 {0}
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ url = https://github.com/webmproject/libwebp.git
[submodule "libvpx"]
path = libvpx
url = https://github.com/webmproject/libvpx.git
[submodule "libass"]
path = libass
url = https://github.com/libass/libass.git
[submodule "fribidi"]
path = fribidi
url = https://github.com/fribidi/fribidi.git
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@ All builds include the following libraries:
- [openexr](https://github.com/AcademySoftwareFoundation/openexr.git)
- [freetype](https://gitlab.freedesktop.org/freetype/freetype.git)
- [harfbuzz](https://github.com/harfbuzz/harfbuzz.git)
- [libass](https://github.com/libass/libass.git)
- [fribidi](https://github.com/fribidi/fribidi.git)
- [SDL2](https://github.com/libsdl-org/SDL.git)
- [libvpx](https://github.com/webmproject/libvpx.git)
- [libwebp](https://github.com/webmproject/libwebp.git)
- [x264](https://code.videolan.org/videolan/x264.git) (GPL builds only)
- [x265](https://bitbucket.org/multicoreware/x265_git.git) (GPL builds only)


## License

- The scripts in this repository are licensed under the **MIT License**.
Expand Down
2 changes: 2 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ This release contains FFmpeg builds, compiled with MSVC (Microsoft Visual C++) v
- [openexr](https://github.com/AcademySoftwareFoundation/openexr.git)
- [freetype](https://gitlab.freedesktop.org/freetype/freetype.git)
- [harfbuzz](https://github.com/harfbuzz/harfbuzz.git)
- [libass](https://github.com/libass/libass.git)
- [fribidi](https://github.com/fribidi/fribidi.git)
- [SDL2](https://github.com/libsdl-org/SDL.git)
- [libvpx](https://github.com/webmproject/libvpx.git)
- [libwebp](https://github.com/webmproject/libwebp.git)
Expand Down
2 changes: 0 additions & 2 deletions build-ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ shift 1
cd $SRC_DIR

if [ $BUILD_TYPE == "static" ]; then
CFLAGS="$CFLAGS -MT"
TYPE_ARGS="--enable-static --pkg-config-flags=--static"
else
CFLAGS="$CFLAGS -MD"
TYPE_ARGS="--enable-shared"
fi
if [[ $BUILD_ARCH =~ arm ]]; then
Expand Down
33 changes: 33 additions & 0 deletions build-libass.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
# Copyright (c) 2024 System233
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT

set -e -x
echo SET test
SRC_DIR=$(pwd)

export TOOLCHAIN_SRCDIR="$(pwd)/toolchain"
export AR=win-ar
export RANLIB=win-ranlib
export PATH=$TOOLCHAIN_SRCDIR:$PATH

echo -e "\n[Build fribidi]"
cd $SRC_DIR/fribidi
NOCONFIGURE=1 ./autogen.sh
FRIBIDI_CFLAGS="-DHAVE_STRINGIZE"
CFLAGS="$FRIBIDI_CFLAGS" ./configure "--host=${BUILD_ARCH}-windows" --prefix=$INSTALL_PREFIX --disable-shared --enable-static --disable-dependency-tracking
make -C lib fribidi-unicode-version.h CFLAGS="$FRIBIDI_CFLAGS"
make -C lib gen CFLAGS="$FRIBIDI_CFLAGS"
make -C lib install -j$(nproc) CFLAGS="$CFLAGS $FRIBIDI_CFLAGS"
make install-data-am


echo -e "\n[Build libass]"
cd $SRC_DIR/libass
NOCONFIGURE=1 ./autogen.sh
CFLAGS="$CFLAGS" ./configure "--host=${BUILD_ARCH}-windows" --prefix=$INSTALL_PREFIX --disable-shared --enable-static --disable-asm --disable-dependency-tracking
make install -j$(nproc)
make install-data-am

2 changes: 1 addition & 1 deletion build-make-dep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SRC_DIR=$(pwd)/$1
shift 1
cd $SRC_DIR
if [ -e ./configure ]; then
./configure $@
CFLAGS="$CFLAGS" ./configure $@
fi
make -j$(nproc)
make ${INSTALL_TARGET:-install} PREFIX=$INSTALL_PREFIX
10 changes: 0 additions & 10 deletions build-meson-dep.cmd

This file was deleted.

17 changes: 0 additions & 17 deletions build-meson-dep.sh

This file was deleted.

97 changes: 48 additions & 49 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fi
shift 3 || true
FF_ARGS=$@

for dep in libharfbuzz libfreetype sdl libjxl libvpx libwebp; do
for dep in libharfbuzz libfreetype sdl libjxl libvpx libwebp libass; do
if grep -q "enable-${dep}" FFmpeg/configure; then
export ENABLE_${dep^^}=1
# FF_ARGS="$FF_ARGS --enable-$dep"
Expand All @@ -33,9 +33,10 @@ add_ffargs() {
}

apply-patch() {
GIT_CMD="git -C $1 apply ../patches/$2 --ignore-whitespace"
if ! $GIT_CMD -R --check; then
$GIT_CMD --ignore-whitespace
GIT_CMD="git -C $1 apply $(pwd)/patches/$2 --ignore-whitespace"
if ! $GIT_CMD -R --check 2>/dev/null; then
echo Apply $2 for $1
$GIT_CMD
else
echo Skip $2 for $1
fi
Expand All @@ -45,42 +46,6 @@ apply-patch zlib zlib.patch
apply-patch FFmpeg ffmpeg.patch
apply-patch harfbuzz harfbuzz.patch

# --enable-libfribidi --enable-libass
# ./build-meson-dep.sh fribidi -Ddocs=false
# ./build-meson-dep.sh libass

if [ "$BUILD_LICENSE" == "gpl" ]; then

apply-patch x265_git x265_git-${BUILD_TYPE}.patch

if [ "$BUILD_TYPE" == "static" ]; then
X265_ARGS="-DSTATIC_LINK_CRT=ON"
ENABLE_SHARED=OFF
else
X265_ARGS="-DSTATIC_LINK_CRT=OFF"
ENABLE_SHARED=ON
fi

if [ "$BUILD_ARCH" == arm ]; then
apply-patch x265_git x265_git-arm.patch
fi

git -C x265_git fetch --tags
./build-cmake-dep.sh x265_git/source -DCMAKE_SYSTEM_NAME=Windows -DENABLE_SHARED=$ENABLE_SHARED -DENABLE_CLI=OFF $X265_ARGS
add_ffargs "--enable-libx265"

if [ "$BUILD_TYPE" == "shared" ]; then
apply-patch x264 x264-${BUILD_TYPE}.patch
fi
if [[ "$BUILD_ARCH" =~ arm ]]; then
X264_ARGS="--disable-asm"
fi

INSTALL_TARGET=install-lib-${BUILD_TYPE} ./build-make-dep.sh x264 --enable-${BUILD_TYPE} $X264_ARGS
add_ffargs "--enable-libx264"

fi

./build-make-dep.sh nv-codec-headers

./build-cmake-dep.sh zlib -DZLIB_BUILD_EXAMPLES=OFF
Expand All @@ -96,6 +61,14 @@ if [ -n "$ENABLE_LIBHARFBUZZ" ]; then
add_ffargs "--enable-libharfbuzz"
fi

if [ -n "$ENABLE_LIBASS" ]; then
# apply-patch fribidi fribidi.patch
./build-libass.sh
add_ffargs "--enable-libass"
fi



if [ -n "$ENABLE_SDL" ]; then
./build-cmake-dep.sh SDL
add_ffargs "--enable-sdl"
Expand All @@ -116,9 +89,6 @@ if [ -n "$ENABLE_LIBJXL" ]; then

fi

# libvpx AR=lib ARFLAGS= CC=cl CXX=cl LD=link STRIP=false ./configure --as=yasm --disable-optimizations --disable-dependency-tracking --disable-runtime-cpu-detect --disable-thumb --disable-neon
# AR=lib ARFLAGS= CC=cl CXX=cl LD=link STRIP=false ./configure --target=armv7-win32-vs17 --as=yasm --disable-optimizations --disable-dependency-tracking --disable-runtime-cpu-detect --disable-thumb --disable-neon --enable-external-build --enable-static-msvcrt

if [ -n "$ENABLE_LIBVPX" ]; then
case $BUILD_ARCH in
amd64) libvpx_target=x86_64-win64-vs17 ;;
Expand All @@ -127,12 +97,9 @@ if [ -n "$ENABLE_LIBVPX" ]; then
arm64) libvpx_target=arm64-win64-vs17 ;;
esac

if [ "$BUILD_TYPE" == "static" ]; then
LIBVPX_ARGS="--enable-static-msvcrt"
fi
LIBVPX_ARGS="--enable-static-msvcrt"
apply-patch libvpx libvpx.patch
export
AS=yasm AR=lib ARFLAGS= CC=cl CXX=cl LD=link STRIP=false target= ./build-make-dep.sh libvpx --target=$libvpx_target --as=yasm --disable-optimizations --disable-dependency-tracking --disable-runtime-cpu-detect --disable-thumb --disable-neon --enable-external-build --disable-unit-tests --disable-decode-perf-tests --disable-encode-perf-tests --disable-tools --disable-examples $LIBVPX_ARGS
CFLAGS="" AS=yasm AR=lib ARFLAGS= CC=cl CXX=cl LD=link STRIP=false target= ./build-make-dep.sh libvpx --target=$libvpx_target --as=yasm --disable-optimizations --disable-dependency-tracking --disable-runtime-cpu-detect --disable-thumb --disable-neon --enable-external-build --disable-unit-tests --disable-decode-perf-tests --disable-encode-perf-tests --disable-tools --disable-examples $LIBVPX_ARGS
add_ffargs "--enable-libvpx"
fi

Expand All @@ -141,5 +108,37 @@ if [ -n "$ENABLE_LIBWEBP" ]; then
add_ffargs "--enable-libwebp"
fi

if [ "$BUILD_LICENSE" == "gpl" ]; then

apply-patch x265_git x265_git-${BUILD_TYPE}.patch

if [ "$BUILD_TYPE" == "static" ]; then
X265_ARGS="-DSTATIC_LINK_CRT=ON"
ENABLE_SHARED=OFF
else
X265_ARGS="-DSTATIC_LINK_CRT=OFF"
ENABLE_SHARED=ON
fi

if [ "$BUILD_ARCH" == arm ]; then
apply-patch x265_git x265_git-arm.patch
fi

git -C x265_git fetch --tags
./build-cmake-dep.sh x265_git/source -DCMAKE_SYSTEM_NAME=Windows -DENABLE_SHARED=$ENABLE_SHARED -DENABLE_CLI=OFF $X265_ARGS
add_ffargs "--enable-libx265"

if [ "$BUILD_TYPE" == "shared" ]; then
apply-patch x264 x264-${BUILD_TYPE}.patch
fi
if [[ "$BUILD_ARCH" =~ arm ]]; then
X264_ARGS="--disable-asm"
fi

INSTALL_TARGET=install-lib-${BUILD_TYPE} ./build-make-dep.sh x264 --enable-${BUILD_TYPE} $X264_ARGS
add_ffargs "--enable-libx264"

fi

./build-ffmpeg.sh FFmpeg $FF_ARGS
./relocate_prefix.sh
./reprefix.sh
2 changes: 2 additions & 0 deletions env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ export BUILD_ARCH=${1:-$VSCMD_ARG_TGT_ARCH}
export BUILD_TYPE=${2:-shared}
export BUILD_LICENSE=${3:-gpl}

export CFLAGS="-MT"
export CMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded"
export CC=cl
export CXX=cl
1 change: 1 addition & 0 deletions fribidi
Submodule fribidi added at 68162b
1 change: 1 addition & 0 deletions libass
Submodule libass added at e46aed
14 changes: 0 additions & 14 deletions meson/win_arm.ini

This file was deleted.

14 changes: 0 additions & 14 deletions meson/win_arm64.ini

This file was deleted.

64 changes: 64 additions & 0 deletions patches/fribidi.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
diff --git a/Makefile.am b/Makefile.am
index 8c516fb..88827ef 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,11 +4,11 @@
ACLOCAL_AMFLAGS = -I m4

## The order of subdirs is important, don't change without a reason.
-SUBDIRS = gen.tab lib bin doc test
+SUBDIRS = lib bin doc test

EXTRA_DIST = autogen.sh ChangeLog.old \
meson.build meson_options.txt bin/meson.build doc/meson.build \
- gen.tab/meson.build lib/meson.build test/meson.build \
+ lib/meson.build test/meson.build \
test/test-runner.py test/unicode-conformance/meson.build \
README.md

diff --git a/configure.ac b/configure.ac
index 9be44d0..7abb3d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -168,7 +168,6 @@ AC_SUBST(ENABLE_SHARED_FALSE)
AC_CONFIG_FILES([fribidi.pc
lib/fribidi-config.h
Makefile
- gen.tab/Makefile
lib/Makefile
bin/Makefile
doc/Makefile
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 22b680a..8dcbfd0 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -56,28 +56,11 @@ libfribidi_la_SOURCES = \

libfribidi_la_CPPFLAGS = @FRIBIDI_CPPFLAGS@ -DFRIBIDI_BUILD

-GENERATEDSOURCES = \
- fribidi-unicode-version.h \
- arabic-shaping.tab.i \
- bidi-type.tab.i \
- joining-type.tab.i \
- mirroring.tab.i \
- brackets.tab.i \
- brackets-type.tab.i
-
-BUILT_SOURCES = \
- $(GENERATEDSOURCES) \
- fribidi-config.h

-$(GENERATEDSOURCES):
- @(cd $(top_builddir)/gen.tab && \
- $(MAKE) $(AM_MAKEFLAGS) $@) && \
- (test -f $@ || mv $(top_builddir)/gen.tab/$@ .)
+BUILT_SOURCES = fribidi-config.h

# re-generate all built sources:
gen:
- @(cd $(top_builddir)/gen.tab && \
- $(MAKE) $(AM_MAKEFLAGS) $@) && \
$(RM) $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) $(BUILT_SOURCES)

File renamed without changes.
7 changes: 0 additions & 7 deletions setup-env.sh

This file was deleted.

Loading

0 comments on commit 26dba63

Please sign in to comment.