Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
askmeaboutlo0m committed Jul 30, 2024
1 parent 0b36312 commit 62541c6
Show file tree
Hide file tree
Showing 8 changed files with 390 additions and 225 deletions.
34 changes: 33 additions & 1 deletion .github/actions/build-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ inputs:
description: Additional arguments to the Qt build script
type: string

ffmpeg_pre_build:
description: Command to run before building ffmpeg dependencies
type: string
ffmpeg_args:
description: Additional arguments to the ffmpeg dependencies build script
type: string

other_pre_build:
description: Command to run before building other dependencies
type: string
Expand All @@ -45,6 +52,14 @@ inputs:
description: Version of Qt to build
required: true
type: string
libx264:
description: Commit of libx264 to build
default: '31e19f92f00c7003fa115047ce50978bc98c3a0d'
type: string
ffmpeg:
description: Version of ffmpeg to build
default: '7.0.1'
type: string
libmicrohttpd:
description: Version of libmicrohttpd to build
default: 1.0.1
Expand Down Expand Up @@ -79,7 +94,7 @@ outputs:
description: >
A semicolon-separated list of all generated dependency trees suitable for
use with `CMAKE_PREFIX_PATH`
value: ${{ github.workspace }}/${{ inputs.path }}/qt;${{ github.workspace }}/${{ inputs.path }}/other
value: ${{ github.workspace }}/${{ inputs.path }}/qt;${{ github.workspace }}/${{ inputs.path }}/ffmpeg;${{ github.workspace }}/${{ inputs.path }}/other

runs:
using: composite
Expand All @@ -99,6 +114,23 @@ runs:
${{ inputs.qt_args }}
-P .github/scripts/build-qt.cmake
- uses: ./.github/actions/build-and-cache
with:
name: ffmpeg dependencies
cache_key: ffmpeg-${{ inputs.cache_key }}-${{ inputs.libx264 }}-${{ inputs.ffmpeg }}
path: ${{ inputs.path }}/ffmpeg
pre_build: ${{ inputs.ffmpeg_pre_build }}
build: >
cmake
-DBUILD_TYPE=${{ inputs.build_type }}
"-DLIBX264=${{ inputs.libx264 }}"
"-DFFMPEG=${{ inputs.ffmpeg }}"
"-DCMAKE_PREFIX_PATH=${{ github.workspace }}/${{ inputs.path }}/qt"
"-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/${{ inputs.path }}/ffmpeg"
"-DTARGET_ARCH=${{ inputs.target_arch }}"
${{ inputs.ffmpeg_args }}
-P .github/scripts/build-ffmpeg.cmake
- uses: ./.github/actions/build-and-cache
with:
name: other dependencies
Expand Down
116 changes: 116 additions & 0 deletions .github/scripts/build-ffmpeg.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# SPDX-License-Identifier: MIT
cmake_minimum_required(VERSION 3.19)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11 CACHE STRING "macOS deployment target")
list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_LIST_DIR}/cmake
${CMAKE_CURRENT_LIST_DIR}/../../cmake
)

set(LIBX264 "31e19f92f00c7003fa115047ce50978bc98c3a0d" CACHE STRING
"The commit of libx264 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)
option(KEEP_SOURCE_DIRS "Keep source directories instead of deleting them" OFF)
option(KEEP_BINARY_DIRS "Keep build directories instead of deleting them" OFF)
set(TARGET_ARCH "x86_64" CACHE STRING
"Target architecture (x86, x86_64, arm32, arm64)")

include(BuildDependency)

if(LIBX264)
build_dependency(x264 ${LIBX264} ${BUILD_TYPE}
URL https://code.videolan.org/videolan/x264/-/archive/@version@/x264-@version@.tar.gz
TARGET_ARCH "${TARGET_ARCH}"
VERSIONS
31e19f92f00c7003fa115047ce50978bc98c3a0d
SHA384=bed835fcf11b4befa8341661b996c4f51842dfee6f7f87c9c2e767cebca0b7871a7f59435b4e92d89c2b13a659d1d737
ALL_PLATFORMS
AUTOMAKE
ASSIGN_PREFIX WIN32_CC_CL
ALL
--enable-static
--enable-pic
--disable-lavf
--disable-swscale
--disable-avs
--disable-ffms
--disable-gpac
--disable-lsmash
--disable-bashcompletion
--disable-cli
--enable-strip
)
endif()

if(FFMPEG)
set(ffmpeg_configure_args
--enable-gpl
--enable-version3
--disable-doc
--disable-autodetect
--disable-programs
--disable-avdevice
--disable-avfilter
--disable-swresample
--disable-postproc
--disable-alsa
--disable-appkit
--disable-avfoundation
--disable-bzlib
--disable-coreimage
--disable-iconv
--disable-lzma
--disable-metal
--disable-sndio
--disable-schannel
--disable-sdl2
--disable-securetransport
--disable-xlib
--disable-zlib
--enable-libx264
--disable-encoders
--disable-decoders
--disable-muxers
--disable-demuxers
--disable-parsers
--disable-bsfs
--disable-protocols
--disable-indevs
--disable-outdevs
--disable-devices
--disable-filters
--enable-encoder=libx264
--enable-muxer=mp4
)
if(WIN32)
list(PREPEND ffmpeg_configure_args
--toolchain=msvc
--arch=${TARGET_ARCH}
)
endif()

build_dependency(ffmpeg ${FFMPEG} ${BUILD_TYPE}
URL https://ffmpeg.org/releases/ffmpeg-@version@.tar.xz
TARGET_ARCH "${TARGET_ARCH}"
VERSIONS
7.0.1
SHA384=25650331f409bf7efc09f0d859ce9a1a8e16fe429e4f9b2593743eb68e723b186559739e8b02aac83c6e5c96137fec7e
ALL_PLATFORMS
AUTOMAKE
ASSIGN_PREFIX
PKG_CONFIG_PATH "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig"
ALL ${ffmpeg_configure_args}
PATCHES
ALL
patches/ffmpeg_configure.diff
)
endif()


# https://code.videolan.org/videolan/x264/-/archive/31e19f92f00c7003fa115047ce50978bc98c3a0d/x264-31e19f92f00c7003fa115047ce50978bc98c3a0d.tar.gz
# ./configure --enable-static --enable-pic --disable-lavf --disable-swscale --disable-avs --disable-ffms --disable-gpac --disable-lsmash --disable-bashcompletion --enable-strip --disable-cli --prefix=/home/carsten/Development/prefix


# https://ffmpeg.org/releases/ffmpeg-7.0.1.tar.xz
# ./configure --enable-gpl --enable-version3 --disable-doc --disable-autodetect --disable-programs --disable-avdevice --disable-avfilter --disable-swresample --disable-postproc --disable-alsa --disable-appkit --disable-avfoundation --disable-bzlib --disable-coreimage --disable-iconv --disable-lzma --disable-metal --disable-sndio --disable-schannel --disable-sdl2 --disable-securetransport --disable-xlib --disable-zlib --enable-libx264 --disable-encoders --disable-decoders --disable-muxers --disable-demuxers --disable-parsers --disable-bsfs --disable-protocols --disable-indevs --disable-outdevs --disable-devices --disable-filters --enable-encoder=libx264 --enable-muxer=mp4 --prefix=/home/carsten/Development/prefix
2 changes: 2 additions & 0 deletions .github/scripts/build-qt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ if(OPENSSL)
CONFIGURATOR "Configure"
ASSIGN_PREFIX BROKEN_INSTALL NEEDS_VC_WIN_TARGET
MAKE_FLAGS ${OPENSSL_MAKE_FLAGS}
WIN32_CONFIGURE_COMMAND perl
WIN32_MAKE_COMMAND nmake
INSTALL_TARGET install_sw
ENV ${OPENSSL_ENV}
ALL shared no-tests ${OPENSSL_FLAGS}
Expand Down
34 changes: 28 additions & 6 deletions .github/scripts/cmake/BuildDependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@ endfunction()

function(_build_automake build_type target_bits source_dir)
set(configure "${source_dir}/configure")
cmake_parse_arguments(PARSE_ARGV 2 ARG "ASSIGN_PREFIX;BROKEN_INSTALL;NEEDS_VC_WIN_TARGET" "INSTALL_TARGET" "MAKE_FLAGS")
cmake_parse_arguments(
PARSE_ARGV 2 ARG "ASSIGN_PREFIX;BROKEN_INSTALL;NEEDS_VC_WIN_TARGET;WIN32_CC_CL"
"INSTALL_TARGET;PKG_CONFIG_PATH;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)
unset(make_flags)
set(make_flags "V=1")
else()
set(make_flags "-j${NPROCS}")
endif()
Expand All @@ -161,6 +163,13 @@ function(_build_automake build_type target_bits source_dir)
list(APPEND configure_flags --host "${abi}")
endif()

if(ARG_PKG_CONFIG_PATH)
# pkg-config chokes on backslashes in PKG_CONFIG_PATH, so convert those
# to forward slashes. TO_CMAKE_PATH does that, despite its odd name.
file(TO_CMAKE_PATH "${ARG_PKG_CONFIG_PATH}" pkg_config_path)
list(APPEND env "PKG_CONFIG_PATH=${pkg_config_path}")
endif()

# OpenSSL has a terrible configurator that only accepts `--prefix=foo` and
# does not bail out when it receives a bogus argument, so if you send
# `--prefix foo` it will just install to its default prefix!
Expand Down Expand Up @@ -189,13 +198,26 @@ function(_build_automake build_type target_bits source_dir)
set(install install)
endif()

# On Windows, the only usable thing here is OpenSSL's pseudo-automake Perl
# script. Shebangs don't work on Windows, so we have to run it explicitly.
# Windows needs special care because shebangs don't work there and it has
# both GNU Make, which regular autoconf uses, and Microsoft's nmake, which
# OpenSSL uses. They are mutually incompatible of course.
if(WIN32)
set(make "nmake")
if(ARG_WIN32_CC_CL)
list(APPEND env "CC=cl")
endif()
if(ARG_WIN32_CONFIGURE_COMMAND)
set(winconfigure "${ARG_WIN32_CONFIGURE_COMMAND}")
else()
set(winconfigure "bash")
endif()
if(ARG_WIN32_MAKE_COMMAND)
set(make "${ARG_WIN32_MAKE_COMMAND}")
else()
set(make "make")
endif()
execute_process(
COMMAND "${CMAKE_COMMAND}" -E env ${env}
perl "${configure}" ${prefix} ${configure_flags}
"${winconfigure}" "${configure}" ${prefix} ${configure_flags}
COMMAND_ECHO STDOUT
WORKING_DIRECTORY "${source_dir}"
COMMAND_ERROR_IS_FATAL ANY
Expand Down
16 changes: 16 additions & 0 deletions .github/scripts/patches/ffmpeg_configure.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Description: Trying to build ffmpeg on Windows dies with some weird cmd syntax
error. I've tried to make it use bash instead, since that's apparently what
it wants to use, but no luck. This is a random workaround I found at
https://trac.ffmpeg.org/ticket/9360 that seems to work okay.

--- a/configure
+++ b/configure
@@ -5018,7 +5018,7 @@
else
_ident=$($_cc --version 2>/dev/null | head -n1 | tr -d '\r')
fi
- _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | awk '\''/including/ { sub(/^.*file: */, ""); gsub(/\\/, "/"); if (!match($$0, / /)) print "$@:", $$0 }'\'' > $(@:.o=.d)'
+ _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< 2>&1 | grep "^Note:.*file:" | sed -e "s^.*file: *^$@: ^" | tr \\\\ / > $(@:.o=.d)'
_DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
_cflags_speed="-O2"
_cflags_size="-O1"
Loading

0 comments on commit 62541c6

Please sign in to comment.