Skip to content

Commit

Permalink
[alsa,fdk-aac,ffmpeg,libsrt,snappy,x265] Code cleanup, fix and use pk…
Browse files Browse the repository at this point in the history
…g-config (#39077)

- Setup and use pkg-config for ffmpeg dependencies.
microsoft/vcpkg#38011 (comment).
- Export actual c++ link libraries for fdk-aac via pkg-config. (Same
pattern as lerc, geos.)
- Rectify link libraries in pkg-config  for alsa, libsrt, snappy, x265.
- Burn-in dllimport for libsrt and x265.
- Pass detected STRIP to ffmpeg. Fixes
microsoft/vcpkg#36852.
  • Loading branch information
dg0yt authored Jun 6, 2024
1 parent a1bf9b7 commit 246adc3
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 162 deletions.
47 changes: 26 additions & 21 deletions 0006-fix-StaticFeatures.patch → 0004-dependencies.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
diff --git a/configure b/configure
index 6d3f31fc95..f5f4a769cc 100644
--- a/configure
+++ b/configure
@@ -6761,7 +6761,8 @@ if enabled libmfx; then
index 3243e23021..6d3f31fc95 100755
@@ -6630,7 +6630,7 @@ fi

enabled zlib && { check_pkg_config zlib zlib "zlib.h" zlibVersion ||
check_lib zlib zlib.h zlibVersion -lz; }
-enabled bzlib && check_lib bzlib bzlib.h BZ2_bzlibVersion -lbz2
+enabled bzlib && require_pkg_config bzlib bzip2 bzlib.h BZ2_bzlibVersion
enabled lzma && check_lib lzma lzma.h lzma_version_number -llzma

enabled zlib && test_exec $zlib_extralibs <<EOF && enable zlib_gzip
@@ -6757,7 +6757,8 @@ if enabled libmfx; then
fi

enabled libmodplug && require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load
Expand All @@ -12,16 +19,18 @@ index 6d3f31fc95..f5f4a769cc 100644
enabled libmysofa && { check_pkg_config libmysofa libmysofa mysofa.h mysofa_neighborhood_init_withstepdefine ||
require libmysofa mysofa.h mysofa_neighborhood_init_withstepdefine -lmysofa $zlib_extralibs; }
enabled libnpp && { check_lib libnpp npp.h nppGetLibVersion -lnppig -lnppicc -lnppc -lnppidei -lnppif ||
@@ -6805,7 +6806,7 @@ if enabled debug_configure; then
else
enabled libsnappy && require libsnappy snappy-c.h snappy_compress -lsnappy -lstdc++
fi
@@ -6793,8 +6794,8 @@ enabled libshaderc && require_pkg_config spirv_compiler "shaderc >= 2019.
enabled libshine && require_pkg_config libshine shine shine/layer3.h shine_encode_buffer
enabled libsmbclient && { check_pkg_config libsmbclient smbclient libsmbclient.h smbc_init ||
require libsmbclient libsmbclient.h smbc_init -lsmbclient; }
-enabled libsnappy && require libsnappy snappy-c.h snappy_compress -lsnappy -lstdc++
-enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr
+enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr -lm
+enabled libsnappy && require_pkg_config libsnappy snappy snappy-c.h snappy_compress
+enabled libsoxr && require libsoxr soxr.h soxr_create -lsoxr $libm_extralibs
enabled libssh && require_pkg_config libssh "libssh >= 0.6.0" libssh/sftp.h sftp_init
enabled libspeex && require_pkg_config libspeex speex speex/speex.h speex_decoder_init
enabled libsrt && require_pkg_config libsrt "srt >= 1.3.0" srt/srt.h srt_socket
@@ -6888,6 +6889,8 @@ enabled openal && { check_pkg_config openal "openal >= 1.1" "AL/al.h"
@@ -6884,6 +6885,8 @@ enabled openal && { check_pkg_config openal "openal >= 1.1" "AL/al.h"
enabled opencl && { check_pkg_config opencl OpenCL CL/cl.h clEnqueueNDRangeKernel ||
check_lib opencl OpenCL/cl.h clEnqueueNDRangeKernel -Wl,-framework,OpenCL ||
check_lib opencl CL/cl.h clEnqueueNDRangeKernel -lOpenCL ||
Expand All @@ -30,20 +39,16 @@ index 6d3f31fc95..f5f4a769cc 100644
die "ERROR: opencl not found"; } &&
{ test_cpp_condition "OpenCL/cl.h" "defined(CL_VERSION_1_2)" ||
test_cpp_condition "CL/cl.h" "defined(CL_VERSION_1_2)" ||
@@ -6914,6 +6917,7 @@ enabled openssl && { { check_pkg_config openssl "openssl >= 3.0.0" ope
check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto ||
check_lib openssl openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
+ check_lib openssl openssl/ssl.h OPENSSL_init_ssl -llibssl -llibcrypto -lws2_32 -lgdi32 -lcrypt32 -lAdvapi32 -lUser32||
die "ERROR: openssl not found"; }
enabled pocketsphinx && require_pkg_config pocketsphinx pocketsphinx pocketsphinx/pocketsphinx.h ps_init
enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/rk_mpi.h mpp_create &&
@@ -7215,7 +7219,7 @@ enabled amf &&
if enabled libc_iconv; then
@@ -7208,10 +7211,10 @@ enabled amf &&
"(AMF_VERSION_MAJOR << 48 | AMF_VERSION_MINOR << 32 | AMF_VERSION_RELEASE << 16 | AMF_VERSION_BUILD_NUM) >= 0x00010004001d0000"

# Funny iconv installations are not unusual, so check it after all flags have been set
-if enabled libc_iconv; then
+if enabled libc_iconv && disabled iconv; then
check_func_headers iconv.h iconv
elif enabled iconv; then
- check_func_headers iconv.h iconv || check_lib iconv iconv.h iconv -liconv
+ check_func_headers iconv.h iconv || check_lib iconv iconv.h iconv -liconv || check_lib iconv iconv.h iconv -liconv -llibcharset
+ check_func_headers iconv.h iconv || check_lib iconv iconv.h iconv -liconv || check_lib iconv iconv.h iconv -liconv -lcharset
fi

enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
40 changes: 0 additions & 40 deletions 0004-fix-debug-build.patch

This file was deleted.

6 changes: 1 addition & 5 deletions 0007-fix-lib-naming.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ diff --git a/configure b/configure
index d6c4388..75b96c3 100644
--- a/configure
+++ b/configure
@@ -4378,6 +4378,11 @@ msvc_common_flags(){
@@ -4378,6 +4378,7 @@ msvc_common_flags(){
-march=*) ;;
-lz) echo zlib.lib ;;
-lx264) echo libx264.lib ;;
+ -lx265) echo libx265.lib ;;
+ -lmp3lame) echo libmp3lame.lib ;;
+ -liconv) echo iconv.lib ;;
+ -llibcharset) echo charset.lib ;;
+ -lm) ;;
-lstdc++) ;;
-l*) echo ${flag#-l}.lib ;;
-LARGEADDRESSAWARE) echo $flag ;;
14 changes: 0 additions & 14 deletions 0009-Fix-fdk-detection.patch

This file was deleted.

15 changes: 0 additions & 15 deletions 0011-Fix-x265-detection.patch

This file was deleted.

17 changes: 0 additions & 17 deletions 0015-Fix-xml2-detection.patch

This file was deleted.

14 changes: 0 additions & 14 deletions 0022-fix-iconv.patch

This file was deleted.

22 changes: 0 additions & 22 deletions 0023-fix-qsv-init.patch

This file was deleted.

34 changes: 21 additions & 13 deletions portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ vcpkg_from_github(
0001-create-lib-libraries.patch
0002-fix-msvc-link.patch #upstreamed in future version
0003-fix-windowsinclude.patch
0004-fix-debug-build.patch
0004-dependencies.patch
0005-fix-nasm.patch #upstreamed in future version
0006-fix-StaticFeatures.patch
0007-fix-lib-naming.patch
0009-Fix-fdk-detection.patch
0011-Fix-x265-detection.patch
0012-Fix-ssl-110-detection.patch
0013-define-WINVER.patch
0015-Fix-xml2-detection.patch
0020-fix-aarch64-libswscale.patch
0022-fix-iconv.patch
0040-ffmpeg-add-av_stream_get_first_dts-for-chromium.patch # Do not remove this patch. It is required by chromium
0041-add-const-for-opengl-definition.patch
)
Expand Down Expand Up @@ -154,10 +149,18 @@ if(VCPKG_DETECTED_CMAKE_RANLIB)
list(APPEND prog_env "${RANLIB_path}")
endif()

if(VCPKG_DETECTED_CMAKE_STRIP)
get_filename_component(STRIP_path "${VCPKG_DETECTED_CMAKE_STRIP}" DIRECTORY)
get_filename_component(STRIP_filename "${VCPKG_DETECTED_CMAKE_STRIP}" NAME)
set(ENV{STRIP} "${STRIP_filename}")
string(APPEND OPTIONS " --strip=${STRIP_filename}")
list(APPEND prog_env "${STRIP_path}")
endif()

list(REMOVE_DUPLICATES prog_env)
vcpkg_add_to_path(PREPEND ${prog_env})

# More? OBJCC STRIP BIN2C
# More? OBJCC BIN2C

file(REMOVE_RECURSE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")

Expand Down Expand Up @@ -256,11 +259,6 @@ else()
set(ENABLE_SWSCALE OFF)
endif()

set(STATIC_LINKAGE OFF)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(STATIC_LINKAGE ON)
endif()

if ("alsa" IN_LIST FEATURES)
set(OPTIONS "${OPTIONS} --enable-alsa")
else()
Expand Down Expand Up @@ -599,7 +597,7 @@ if(VCPKG_TARGET_IS_UWP)
string(APPEND OPTIONS " --extra-ldflags=-APPCONTAINER --extra-ldflags=WindowsApp.lib")
endif()

set(OPTIONS_DEBUG "--debug --disable-optimizations")
set(OPTIONS_DEBUG "--disable-optimizations")
set(OPTIONS_RELEASE "--enable-optimizations")

set(OPTIONS "${OPTIONS} ${OPTIONS_CROSS}")
Expand All @@ -614,6 +612,8 @@ elseif(VCPKG_TARGET_IS_WINDOWS)
set(OPTIONS "${OPTIONS} --extra-cflags=-DHAVE_UNISTD_H=0")
endif()

vcpkg_find_acquire_program(PKGCONFIG)
set(OPTIONS "${OPTIONS} --pkg-config=${PKGCONFIG}")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(OPTIONS "${OPTIONS} --pkg-config-flags=--static")
endif()
Expand Down Expand Up @@ -653,12 +653,16 @@ if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")

configure_file("${CMAKE_CURRENT_LIST_DIR}/build.sh.in" "${BUILD_DIR}/build.sh" @ONLY)

z_vcpkg_setup_pkgconfig_path(CONFIG RELEASE)

vcpkg_execute_required_process(
COMMAND "${SHELL}" ./build.sh
WORKING_DIRECTORY "${BUILD_DIR}"
LOGNAME "build-${TARGET_TRIPLET}-rel"
SAVE_LOG_FILES ffbuild/config.log
)

z_vcpkg_restore_pkgconfig_path()
endif()

# Debug build
Expand Down Expand Up @@ -692,12 +696,16 @@ if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")

configure_file("${CMAKE_CURRENT_LIST_DIR}/build.sh.in" "${BUILD_DIR}/build.sh" @ONLY)

z_vcpkg_setup_pkgconfig_path(CONFIG DEBUG)

vcpkg_execute_required_process(
COMMAND "${SHELL}" ./build.sh
WORKING_DIRECTORY "${BUILD_DIR}"
LOGNAME "build-${TARGET_TRIPLET}-dbg"
SAVE_LOG_FILES ffbuild/config.log
)

z_vcpkg_restore_pkgconfig_path()
endif()

if(VCPKG_TARGET_IS_WINDOWS)
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ffmpeg",
"version": "6.1.1",
"port-version": 6,
"port-version": 7,
"description": [
"a library to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created.",
"FFmpeg is the leading multimedia framework, able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created. It supports the most obscure ancient formats up to the cutting edge. No matter if they were designed by some standards committee, the community or a corporation. It is also highly portable: FFmpeg compiles, runs, and passes our testing infrastructure FATE across Linux, Mac OS X, Microsoft Windows, the BSDs, Solaris, etc. under a wide variety of build environments, machine architectures, and configurations."
Expand Down

0 comments on commit 246adc3

Please sign in to comment.