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 (microsoft#39077)

- Setup and use pkg-config for ffmpeg dependencies.
microsoft#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#36852.
  • Loading branch information
dg0yt authored Jun 6, 2024
1 parent 2b99134 commit 2017886
Show file tree
Hide file tree
Showing 36 changed files with 304 additions and 290 deletions.
12 changes: 12 additions & 0 deletions ports/alsa/libdl.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/configure.ac b/configure.ac
index 7a152a4..324adf8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -261,6 +261,7 @@ HAVE_LIBDL=
if test "$have_libdl" = "yes"; then
AC_SEARCH_LIBS([dlsym], [dl], [HAVE_LIBDL="yes"])
if test "$HAVE_LIBDL" = "yes" ; then
+ ALSA_DEPLIBS="$ALSA_DEPLIBS -ldl"
AC_DEFINE([HAVE_LIBDL], 1, [Have libdl])
fi
else
1 change: 1 addition & 0 deletions ports/alsa/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ vcpkg_from_github(
HEAD_REF master
PATCHES
fix-plugin-dir.patch
libdl.diff
${ALSA_VERSION_SCRIPT_PATCH}
)

Expand Down
2 changes: 1 addition & 1 deletion ports/alsa/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "alsa",
"version": "1.2.11",
"port-version": 1,
"port-version": 2,
"description": "The Advanced Linux Sound Architecture (ALSA) - library",
"homepage": "https://www.alsa-project.org/",
"license": "LGPL-2.1-or-later",
Expand Down
20 changes: 20 additions & 0 deletions ports/fdk-aac/cxx-linkage-pkgconfig.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4db8c7e..da3297c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -528,6 +528,15 @@ if(FDK_AAC_INSTALL_PKGCONFIG_MODULE)
set(LIBS_PUBLIC "-lm")
endif()
endif()
+ foreach(lib IN LISTS CMAKE_CXX_IMPLICIT_LINK_LIBRARIES)
+ if(lib IN_LIST CMAKE_C_IMPLICIT_LINK_LIBRARIES)
+ continue()
+ elseif(EXISTS "${lib}")
+ string(APPEND LIBS_PRIVATE " ${CMAKE_LINK_LIBRARY_FILE_FLAG}${lib}")
+ else()
+ string(APPEND LIBS_PRIVATE " ${CMAKE_LINK_LIBRARY_FLAG}${lib}")
+ endif()
+ endforeach()
configure_file(fdk-aac.pc.in fdk-aac.pc @ONLY)
install(
FILES
21 changes: 15 additions & 6 deletions ports/fdk-aac/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,43 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS FEATURES
he-aac HE_AAC
)

set(legal_notes "NOTICE")
if(HE_AAC)
vcpkg_from_github(
REPO mstorsjo/fdk-aac
REF v2.0.2
SHA512 616207e85035d1659a2b7808ca6ec02ef53c1c4b39eb280fe861f82a4cf548e5db2ac381c496bad37dfc2b8c6677fe704d9fd8449e43d1f93d3e636239e0191b
HEAD_REF master
OUT_SOURCE_PATH SOURCE_PATH
PATCHES
cxx-linkage-pkgconfig.patch
)
else()
list(PREPEND legal_notes "README.fedora")
vcpkg_from_gitlab(
GITLAB_URL https://gitlab.freedesktop.org/
REPO wtaymans/fdk-aac-stripped
REF 585981a49f2186b0d2e47c64bf6b5abf539395f8 # corresponds to v2.0.2 tag in mstorsjo/fdk-aac GitHub repository
REF 529b87452cd33d45e1d0a5066d20b64f10b38845 # corresponds to v2.0.2 tag in mstorsjo/fdk-aac GitHub repository
HEAD_REF stripped4
SHA512 e0e56396ed0be427302ed4b54fc6e8dc522a172c288b7c1ec40cc3a9ceb13518ca7bbb874bc71b88b2a91e0bbbe4ad0bab6910efa1db63d91e6370976641bac4
SHA512 0c37f8fd1bd0e817d2b3970138bef5b2a7a3150ab1a772273c8f5cba09be04afa2f31780f0ea063dd786a71844aa4cb5821349a4bcc5ebe70e827c3561eda2a9
OUT_SOURCE_PATH SOURCE_PATH
PATCHES
cxx-linkage-pkgconfig.patch
)
endif()

vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS_RELEASE -DBUILD_PROGRAMS=OFF
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DBUILD_PROGRAMS=OFF
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/${PORT}")
vcpkg_fixup_pkgconfig()
vcpkg_copy_pdbs()
vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/NOTICE")

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

list(TRANSFORM legal_notes PREPEND "${SOURCE_PATH}/")
vcpkg_install_copyright(FILE_LIST ${legal_notes})
2 changes: 1 addition & 1 deletion ports/fdk-aac/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fdk-aac",
"version-semver": "2.0.2",
"port-version": 3,
"port-version": 4,
"description": "A standalone Third-Party Modified Version of the Fraunhofer FDK AAC Codec Library for Android. Uses a fork without HE-AAC, HE-AACv2, or xHE-AAC support to avoid patent licensing and GPL compatibility issues when built without the he-aac option.",
"homepage": "https://gitlab.freedesktop.org/wtaymans/fdk-aac-stripped",
"license": "FDK-AAC",
Expand Down
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 ports/ffmpeg/0004-fix-debug-build.patch

This file was deleted.

6 changes: 1 addition & 5 deletions ports/ffmpeg/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 ports/ffmpeg/0009-Fix-fdk-detection.patch

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

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

This file was deleted.

Loading

0 comments on commit 2017886

Please sign in to comment.