Skip to content

Commit

Permalink
WIP libvpx
Browse files Browse the repository at this point in the history
  • Loading branch information
askmeaboutlo0m committed Jul 31, 2024
1 parent 9fd0242 commit 871453c
Show file tree
Hide file tree
Showing 5 changed files with 405 additions and 249 deletions.
7 changes: 6 additions & 1 deletion .github/actions/build-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ inputs:
description: Commit of libx264 to build
default: '31e19f92f00c7003fa115047ce50978bc98c3a0d'
type: string
libvpx:
description: Version of libvpx to build
default: '1.14.1'
type: string
ffmpeg:
description: Version of ffmpeg to build
default: '7.0.1'
Expand Down Expand Up @@ -117,13 +121,14 @@ runs:
- uses: ./.github/actions/build-and-cache
with:
name: ffmpeg dependencies
cache_key: ffmpeg-${{ inputs.cache_key }}-${{ inputs.libx264 }}-${{ inputs.ffmpeg }}
cache_key: ffmpeg-${{ inputs.cache_key }}-${{ inputs.libx264 }}-${{ inputs.libvpx }}-${{ inputs.ffmpeg }}
path: ${{ inputs.path }}/ffmpeg
pre_build: ${{ inputs.ffmpeg_pre_build }}
build: >
cmake
-DBUILD_TYPE=${{ inputs.build_type }}
"-DLIBX264=${{ inputs.libx264 }}"
"-DLIBVPX=${{ inputs.libvpx }}"
"-DFFMPEG=${{ inputs.ffmpeg }}"
"-DCMAKE_PREFIX_PATH=${{ github.workspace }}/${{ inputs.path }}/qt"
"-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/${{ inputs.path }}/ffmpeg"
Expand Down
99 changes: 98 additions & 1 deletion .github/scripts/build-ffmpeg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ list(APPEND CMAKE_MODULE_PATH

set(LIBX264 "31e19f92f00c7003fa115047ce50978bc98c3a0d" CACHE STRING
"The commit of libx264 to build")
set(LIBVPX "1.14.1" CACHE STRING
"The version of libvpx to build")
set(FFMPEG "7.0.1" CACHE STRING
"The version of ffmpeg to build")
option(KEEP_ARCHIVES "Keep downloaded archives instead of deleting them" OFF)
Expand All @@ -18,6 +20,92 @@ set(TARGET_ARCH "x86_64" CACHE STRING

include(BuildDependency)

if(LIBVPX)
set(libvpx_configure_args
--disable-dependency-tracking
--disable-docs
--disable-examples
--disable-tools
--disable-unit-tests
--disable-vp8-decoder
--disable-vp9
--enable-pic
--enable-vp8-encoder
)

if(APPLE)
if(TARGET_ARCH STREQUAL "arm64")
list(PREPEND libvpx_configure_args --target=arm64-darwin20-gcc)
elseif(TARGET_ARCH STREQUAL "x86_64")
list(PREPEND libvpx_configure_args --target=x86_64-darwin20-gcc)
else()
message(FATAL_ERROR "Unhandled TARGET_ARCH '${TARGET_ARCH}'")
endif()
elseif(ANDROID)
if(TARGET_ARCH STREQUAL "arm32")
list(PREPEND libvpx_configure_args --target=armv7-android-gcc)
elseif(TARGET_ARCH STREQUAL "arm64")
list(PREPEND libvpx_configure_args --target=arm64-android-gcc)
else()
message(FATAL_ERROR "Unhandled TARGET_ARCH '${TARGET_ARCH}'")
endif()
elseif(WIN32)
if(TARGET_ARCH STREQUAL "x86")
list(PREPEND libvpx_configure_args --target=x86-win32-vs17)
elseif(TARGET_ARCH STREQUAL "x86_64")
list(PREPEND libvpx_configure_args --target=x86_64-win64-vs17)
else()
message(FATAL_ERROR "Unhandled TARGET_ARCH '${TARGET_ARCH}'")
endif()
elseif(UNIX)
if(TARGET_ARCH STREQUAL "x86")
list(PREPEND libvpx_configure_args --target=x86-linux-gcc)
elseif(TARGET_ARCH STREQUAL "x86_64")
list(PREPEND libvpx_configure_args --target=x86_64-linux-gcc)
else()
message(FATAL_ERROR "Unhandled TARGET_ARCH '${TARGET_ARCH}'")
endif()
else()
message(FATAL_ERROR "Unknown platform")
endif()

build_dependency(libvpx ${LIBVPX} ${BUILD_TYPE}
URL https://github.com/webmproject/libvpx/archive/refs/tags/v@version@.tar.gz
TARGET_ARCH "${TARGET_ARCH}"
VERSIONS
1.14.1
SHA384=42392dcae787ac556e66776a03bd064e0bb5795e7d763a6459edd2127e7ffae4aafe5c755d16ec4a4ab6e9785c27684c
ALL_PLATFORMS
AUTOMAKE
ASSIGN_PREFIX BROKEN_INSTALL
QUIRKS libvpx
ALL
${libvpx_configure_args}
PATCHES
ALL
patches/libvpx_configure.diff
)

# libvpx doesn't generate a pkg-config file on Windows
if(WIN32)
file(WRITE "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/vpx.pc"
"prefix=${CMAKE_INSTALL_PREFIX}\n"
"exec_prefix=\${prefix}\n"
"libdir=\${prefix}/lib\n"
"includedir=\${prefix}/include\n"
"\n"
"Name: vpx\n"
"Description: WebM Project VPx codec implementation\n"
"Version: ${LIBVPX}\n"
"Requires:\n"
"Conflicts:\n"
"Libs: -L\${libdir} -lvpx\n"
"Libs.private:\n"
"Cflags: -I\${includedir}\n"
)
endif()
endif()

if(LIBX264)
build_dependency(x264 ${LIBX264} ${BUILD_TYPE}
URL https://code.videolan.org/videolan/x264/-/archive/@version@/x264-@version@.tar.gz
Expand Down Expand Up @@ -45,6 +133,11 @@ endif()

if(FFMPEG)
set(ffmpeg_configure_args
# This referes to warnings in configure, not build warnings. Warnings
# include pretty important stuff like not including a requested encoder,
# so we want this to fail in that case so we actually notice instead of
# being left with an incomplete build.
--fatal-warnings
--enable-gpl
--enable-version3
--disable-doc
Expand All @@ -69,6 +162,7 @@ if(FFMPEG)
--disable-xlib
--disable-zlib
--enable-libx264
--enable-libvpx
--disable-encoders
--disable-decoders
--disable-muxers
Expand All @@ -81,7 +175,9 @@ if(FFMPEG)
--disable-devices
--disable-filters
--enable-encoder=libx264
--enable-encoder=libvpx_vp8
--enable-muxer=mp4
--enable-muxer=webm
)

if(ANDROID)
Expand Down Expand Up @@ -119,7 +215,8 @@ if(FFMPEG)
SHA384=25650331f409bf7efc09f0d859ce9a1a8e16fe429e4f9b2593743eb68e723b186559739e8b02aac83c6e5c96137fec7e
ALL_PLATFORMS
AUTOMAKE
ASSIGN_PREFIX FFMPEG_QUIRKS
ASSIGN_PREFIX
QUIRKS ffmpeg
PKG_CONFIG_PATH "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig"
ALL ${ffmpeg_configure_args}
PATCHES
Expand Down
20 changes: 14 additions & 6 deletions .github/scripts/cmake/BuildDependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ endfunction()
function(_build_automake build_type target_bits source_dir)
set(configure "${source_dir}/configure")
cmake_parse_arguments(
PARSE_ARGV 2 ARG "ASSIGN_HOST;ASSIGN_PREFIX;BROKEN_INSTALL;FFMPEG_QUIRKS;NEEDS_VC_WIN_TARGET;WIN32_CC_CL"
"INSTALL_TARGET;PKG_CONFIG_PATH;WIN32_CONFIGURE_COMMAND;WIN32_MAKE_COMMAND" "MAKE_FLAGS")
PARSE_ARGV 2 ARG "ASSIGN_HOST;ASSIGN_PREFIX;BROKEN_INSTALL;NEEDS_VC_WIN_TARGET;WIN32_CC_CL"
"INSTALL_TARGET;PKG_CONFIG_PATH;QUIRKS;WIN32_CONFIGURE_COMMAND;WIN32_MAKE_COMMAND" "MAKE_FLAGS")
_parse_flags("${build_type}" "${source_dir}" configure configure_flags env ${ARG_UNPARSED_ARGUMENTS})

if(NPROCS EQUAL 0 OR WIN32)
Expand All @@ -154,6 +154,8 @@ function(_build_automake build_type target_bits source_dir)
list(APPEND make_flags ${ARG_MAKE_FLAGS})
endif()

list(APPEND make_flags V=1)

list(APPEND env "MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}")

# https://developer.android.com/ndk/guides/other_build_systems#autoconf
Expand All @@ -162,10 +164,16 @@ function(_build_automake build_type target_bits source_dir)
android_env android_ffmpeg_flags abi "${CMAKE_ANDROID_NDK}"
"${CMAKE_ANDROID_ARCH_ABI}" "${ANDROID_PLATFORM}")
list(APPEND env ${android_env})
# ffmpeg's build system looks like autoconf, but isn't actually
if(ARG_FFMPEG_QUIRKS)
list(APPEND configure_flags ${android_ffmpeg_flags})
list(APPEND env "AS_FLAGS=--target=${abi}")
if(ARG_QUIRKS)
if(ARG_QUIRKS STREQUAL ffmpeg)
# ffmpeg's build system looks like autoconf, but isn't actually
list(APPEND configure_flags ${android_ffmpeg_flags})
list(APPEND env "AS_FLAGS=--target=${abi}")
elseif(ARG_QUIRKS STREQUAL libvpx)
# dito for libvpx, but a different kind of weirdw
else()
message(FATAL_ERROR "Unknown QUIRKS: '${ARG_QUIRKS}'")
endif()
else()
if(ARG_ASSIGN_HOST)
list(APPEND configure_flags "--host=${abi}")
Expand Down
39 changes: 39 additions & 0 deletions .github/scripts/patches/libvpx_configure.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Description: libvpx tries to run some shell scripts directly on Windows, which
in our CI just triggers the brilliant WSL shim binaries that do nothing but
moan about WSL not being installed. We have a working bash in our PATH though,
so we just run them with that instead.

--- a/configure
+++ b/configure
@@ -749,7 +749,7 @@
enable_feature solution
vs_version=${tgt_cc##vs}
VCPROJ_SFX=vcxproj
- gen_vcproj_cmd=${source_path}/build/make/gen_msvs_vcxproj.sh
+ gen_vcproj_cmd="bash ${source_path}/build/make/gen_msvs_vcxproj.sh"
enabled werror && gen_vcproj_cmd="${gen_vcproj_cmd} --enable-werror"
all_targets="${all_targets} solution"
INLINE="__inline"
--- a/libs.mk
+++ b/libs.mk
@@ -227,7 +227,7 @@

vpx.def: $(call enabled,CODEC_EXPORTS)
@echo " [CREATE] $@"
- $(qexec)$(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
+ $(qexec)bash $(SRC_PATH_BARE)/build/make/gen_msvs_def.sh\
--name=vpx\
--out=$@ $^
CLEAN-OBJS += vpx.def
--- a/solution.mk
+++ b/solution.mk
@@ -15,7 +15,7 @@

vpx.sln: $(wildcard *.$(VCPROJ_SFX))
@echo " [CREATE] $@"
- $(SRC_PATH_BARE)/build/make/gen_msvs_sln.sh \
+ bash $(SRC_PATH_BARE)/build/make/gen_msvs_sln.sh \
$(if $(filter vpx.$(VCPROJ_SFX),$^),$(VPX_RDEPS)) \
--dep=test_libvpx:gtest \
--ver=$(CONFIG_VS_VERSION)\

Loading

0 comments on commit 871453c

Please sign in to comment.