From eaf66ea329a2b9740cce64fecbe9000b088fe16c Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 14 Nov 2012 07:46:44 -0800 Subject: [PATCH] Dynamically link the runtime for FFMS2 and FFmpeg --- aegisub/build/BuildTasks/BuildTasks.fs | 2 +- aegisub/build/ffmpeg/dynamic_msvcrt.h | 34 ++++++++++++++++++++++++++ aegisub/build/ffmpeg/ffmpeg.vcxproj | 7 ++++-- aegisub/build/ffms2/ffms2.vcxproj | 21 +++++++--------- 4 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 aegisub/build/ffmpeg/dynamic_msvcrt.h diff --git a/aegisub/build/BuildTasks/BuildTasks.fs b/aegisub/build/BuildTasks/BuildTasks.fs index f4514a16b..7d9ebfbd3 100644 --- a/aegisub/build/BuildTasks/BuildTasks.fs +++ b/aegisub/build/BuildTasks/BuildTasks.fs @@ -77,7 +77,7 @@ type ShellWrapper(props : Map) = this.EnvironmentVariables <- [| "CC=cl"; "CPP=cl -E"; - "CFLAGS=-nologo"; + "CFLAGS=-nologo" "PATH=" + props.["MsysBasePath"] + "\\bin;" + props.["NativeExecutablePath"]; "INCLUDE=" + props.["AegisubSourceBase"] + "//include;" + props.["IncludePath"]; "LIB=" + props.["AegisubLibraryDir"] + ";" + props.["LibraryPath"]; diff --git a/aegisub/build/ffmpeg/dynamic_msvcrt.h b/aegisub/build/ffmpeg/dynamic_msvcrt.h new file mode 100644 index 000000000..74c15cd65 --- /dev/null +++ b/aegisub/build/ffmpeg/dynamic_msvcrt.h @@ -0,0 +1,34 @@ +// Copyright (c) 2012, Thomas Goyne +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// +// Aegisub Project http://www.aegisub.org/ + +// FFmpeg/libav replace these standard library functions with their own +// implementations by #defining them to avpriv_fn, which results in them +// being declared as __declspec(dllimport) when dynamically linking the +// runtime. To fix this, redeclare them correctly. + +#include +#include +#include + +// Disable the inconsistent dll linkage warning since that's the entire +// point of this +#pragma warning( push ) +#pragma warning( disable: 4273 ) +int avpriv_snprintf(char *s, size_t n, const char *fmt, ...); +int avpriv_vsnprintf(char *s, size_t n, const char *fmt, va_list ap); +double avpriv_strtod(const char *nptr, char **endptr); +#pragma warning( pop ) + diff --git a/aegisub/build/ffmpeg/ffmpeg.vcxproj b/aegisub/build/ffmpeg/ffmpeg.vcxproj index 5f970bf9e..7bba8d9ed 100644 --- a/aegisub/build/ffmpeg/ffmpeg.vcxproj +++ b/aegisub/build/ffmpeg/ffmpeg.vcxproj @@ -36,8 +36,8 @@ - --enable-debug --disable-stripping - --disable-debug + --enable-debug --disable-stripping --extra-cflags=-MDd + --disable-debug --extra-cflags=-MD --disable-avfilter --disable-avresample @@ -61,6 +61,9 @@ --enable-runtime-cpudetect --enable-static --extra-cflags=-D_SYSCRT + --extra-cflags=-wd4005 + --extra-cflags=-wd4189 + --extra-cflags=-FI$(MSBuildThisFileDirectory)dynamic_msvcrt.h --toolchain=msvc $(CfgEnableDebug) diff --git a/aegisub/build/ffms2/ffms2.vcxproj b/aegisub/build/ffms2/ffms2.vcxproj index 5cb0f3968..8f4872b84 100644 --- a/aegisub/build/ffms2/ffms2.vcxproj +++ b/aegisub/build/ffms2/ffms2.vcxproj @@ -56,18 +56,6 @@ - - - MultiThreaded - - - - - - MultiThreaded - - - @@ -90,4 +78,13 @@ + + + + {f934ab7b-186b-4e96-b20c-a58c38c1b819} + + + {10f22a5a-dd9e-44a1-ba2e-2a9a7c78b0ee} + +