Skip to content

Commit

Permalink
[ffmpeg]Fix debug build in Windows. (#7476)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackBoosY authored and cbezault committed Aug 6, 2019
1 parent 1a2dd08 commit 31ae6a0
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 32 deletions.
2 changes: 1 addition & 1 deletion ports/ffmpeg/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: ffmpeg
Version: 4.1-8
Version: 4.1-9
Homepage: https://ffmpeg.org
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
30 changes: 30 additions & 0 deletions ports/ffmpeg/fix-debug-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/configure b/configure
index 7c5b8a1..181fc47 100644
--- a/configure
+++ b/configure
@@ -3906,6 +3906,9 @@ for opt do
--libfuzzer=*)
libfuzzer_path="$optval"
;;
+ --debug)
+ enable debug_configure
+ ;;
*)
optname="${opt%%=*}"
optname="${optname#--}"
@@ -6037,8 +6040,13 @@ 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 lzma && check_lib lzma lzma.h lzma_version_number -llzma
+if enabled debug_configure; then
+ enabled bzlib && check_lib bzlib bzlib.h BZ2_bzlibVersion -lbz2d
+ enabled lzma && check_lib lzma lzma.h lzma_version_number -llzmad
+else
+ enabled bzlib && check_lib bzlib bzlib.h BZ2_bzlibVersion -lbz2
+ enabled lzma && check_lib lzma lzma.h lzma_version_number -llzma
+fi

# On some systems dynamic loading requires no extra linker flags
check_lib libdl dlfcn.h "dlopen dlsym" || check_lib libdl dlfcn.h "dlopen dlsym" -ldl
70 changes: 39 additions & 31 deletions ports/ffmpeg/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ vcpkg_extract_source_archive_ex(
fix_windowsinclude-in-ffmpegexe-1.patch
fix_windowsinclude-in-ffmpegexe-2.patch
fix_libvpx_windows_linking.patch
fix-debug-build.patch
)

if (${SOURCE_PATH} MATCHES " ")
Expand All @@ -25,7 +26,7 @@ endif()
vcpkg_find_acquire_program(YASM)
get_filename_component(YASM_EXE_PATH ${YASM} DIRECTORY)

if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
if(VCPKG_TARGET_IS_WINDOWS)
set(SEP ";")
#We're assuming that if we're building for Windows we're using MSVC
set(INCLUDE_VAR "INCLUDE")
Expand All @@ -36,7 +37,7 @@ else()
set(LIB_PATH_VAR "LIBRARY_PATH")
endif()

if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
if(VCPKG_TARGET_IS_WINDOWS)
set(ENV{PATH} "$ENV{PATH};${YASM_EXE_PATH}")

set(BUILD_SCRIPT ${CMAKE_CURRENT_LIST_DIR}\\build.sh)
Expand Down Expand Up @@ -162,44 +163,51 @@ endif()

message(STATUS "Building Options: ${OPTIONS}")

if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
if(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_CRT_LINKAGE STREQUAL "dynamic")
set(OPTIONS_DEBUG "${OPTIONS_DEBUG} --extra-cflags=-MDd --extra-cxxflags=-MDd")
set(OPTIONS_DEBUG "${OPTIONS_DEBUG} --extra-cflags=-MDd --extra-cxxflags=-MDd --debug")
set(OPTIONS_RELEASE "${OPTIONS_RELEASE} --extra-cflags=-MD --extra-cxxflags=-MD")
else()
set(OPTIONS_DEBUG "${OPTIONS_DEBUG} --extra-cflags=-MTd --extra-cxxflags=-MTd")
set(OPTIONS_DEBUG "${OPTIONS_DEBUG} --extra-cflags=-MTd --extra-cxxflags=-MTd --debug")
set(OPTIONS_RELEASE "${OPTIONS_RELEASE} --extra-cflags=-MT --extra-cxxflags=-MT")
endif()
endif()

set(ENV_LIB_PATH "$ENV{${LIB_PATH_VAR}}")
set(ENV{${LIB_PATH_VAR}} "${CURRENT_INSTALLED_DIR}/lib${SEP}${ENV_LIB_PATH}")

message(STATUS "Building ${_csc_PROJECT_PATH} for Release")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
vcpkg_execute_required_process(
COMMAND ${BASH} --noprofile --norc "${BUILD_SCRIPT}"
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" # BUILD DIR
"${SOURCE_PATH}" # SOURCE DIR
"${CURRENT_PACKAGES_DIR}" # PACKAGE DIR
"${OPTIONS} ${OPTIONS_RELEASE}"
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
LOGNAME build-${TARGET_TRIPLET}-rel
)

set(ENV{${LIB_PATH_VAR}} "${CURRENT_INSTALLED_DIR}/debug/lib${SEP}${ENV_LIB_PATH}")

message(STATUS "Building ${_csc_PROJECT_PATH} for Debug")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
vcpkg_execute_required_process(
COMMAND ${BASH} --noprofile --norc "${BUILD_SCRIPT}"
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" # BUILD DIR
"${SOURCE_PATH}" # SOURCE DIR
"${CURRENT_PACKAGES_DIR}/debug" # PACKAGE DIR
"${OPTIONS} ${OPTIONS_DEBUG}"
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME build-${TARGET_TRIPLET}-dbg
)
# Relase build
if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL release)
message(STATUS "Building Relase Options: ${OPTIONS_RELEASE}")
set(ENV{${LIB_PATH_VAR}} "${CURRENT_INSTALLED_DIR}/lib${SEP}${ENV_LIB_PATH}")
message(STATUS "Building ${_csc_PROJECT_PATH} for Release")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
vcpkg_execute_required_process(
COMMAND ${BASH} --noprofile --norc "${BUILD_SCRIPT}"
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel" # BUILD DIR
"${SOURCE_PATH}" # SOURCE DIR
"${CURRENT_PACKAGES_DIR}" # PACKAGE DIR
"${OPTIONS} ${OPTIONS_RELEASE}"
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
LOGNAME build-${TARGET_TRIPLET}-rel
)
endif()

# Debug build
if (NOT VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL debug)
message(STATUS "Building Debug Options: ${OPTIONS_DEBUG}")
set(ENV{${LIB_PATH_VAR}} "${CURRENT_INSTALLED_DIR}/debug/lib${SEP}${ENV_LIB_PATH}")
message(STATUS "Building ${_csc_PROJECT_PATH} for Debug")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
vcpkg_execute_required_process(
COMMAND ${BASH} --noprofile --norc "${BUILD_SCRIPT}"
"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg" # BUILD DIR
"${SOURCE_PATH}" # SOURCE DIR
"${CURRENT_PACKAGES_DIR}/debug" # PACKAGE DIR
"${OPTIONS} ${OPTIONS_DEBUG}"
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME build-${TARGET_TRIPLET}-dbg
)
endif()

file(GLOB DEF_FILES ${CURRENT_PACKAGES_DIR}/lib/*.def ${CURRENT_PACKAGES_DIR}/debug/lib/*.def)

Expand Down

0 comments on commit 31ae6a0

Please sign in to comment.