From 790e16cebda8164a4d547d65d47273e1432c5524 Mon Sep 17 00:00:00 2001
From: Nirbheek Chauhan <nirbheek@centricular.com>
Date: Tue, 23 Jun 2020 03:19:49 +0530
Subject: [PATCH] cerbero: Fix loading of rsvg, ttmlsubs, resindvd under MSVC

We were setting `objc` as `[]` in the native file, because of which
meson was auto-detecting it and finding it inside the MSYS-MinGW env.
Then it was using that (instead of the MSVC compiler) to search for
libraries inside `dependency()` and picked the GCC-compatible import
libraries (`.dll.a`) for all dependencies, such as cairo, pango,
libxml2, fontconfig, etc.

The MSVC linker tried its best to chug along and mostly succeeded, but
possibly due to format incompatibilities between `.dll.a` and `.lib`
import library formats or bugs in GCC and/or MSVC, this led to the
linker getting confused and looking for some libxml2 symbols both
inside cairo *and* libxml2 DLLs, and doing the same for some cairo
symbols too.

For example, it was looking for `xmlDocGetRootElement` and
`cairo_create` in both `libxml2-2.dll` and *also* in `libcairo-2.dll`.

Since in PE images multiple references to the same symbol in different
DLLs is allowed and all these references must be resolved at runtime,
this was a runtime error not a build-time error. The same thing was
also happening to resindvd.

Oh, also re-enable resindvd which was accidentally disabled on MSVC
when it was supposed to be disabled on UWP.

Closes https://gitlab.freedesktop.org/gstreamer/cerbero/-/issues/277

Part-of: <https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/525>
---
 cerbero/build/build.py             | 8 ++++----
 recipes/gst-plugins-bad-1.0.recipe | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/cerbero/build/build.py b/cerbero/build/build.py
index f115d17f6..7e01e93c1 100644
--- a/cerbero/build/build.py
+++ b/cerbero/build/build.py
@@ -848,8 +848,8 @@ class Meson (Build, ModifyEnvBase) :
 
         cc = build_env.pop('CC')
         cxx = build_env.pop('CXX')
-        objc = build_env.pop('OBJC', [])
-        objcxx = build_env.pop('OBJCXX', [])
+        objc = build_env.pop('OBJC', ['false'])
+        objcxx = build_env.pop('OBJCXX', ['false'])
         ar = build_env.pop('AR')
         # We currently don't set the pre-processor or the linker when building with meson
         build_env.pop('CPP', None)
@@ -929,8 +929,8 @@ class Meson (Build, ModifyEnvBase) :
             cc = self.config.mingw_env_for_build_system['CC']
             cxx = self.config.mingw_env_for_build_system['CXX']
             ar = self.config.mingw_env_for_build_system['AR']
-            objc = cc
-            objcxx = cxx
+            objc = false
+            objcxx = false
         elif self.config.platform == Platform.DARWIN:
             cc = ['clang']
             cxx = ['clang++']
diff --git a/recipes/gst-plugins-bad-1.0.recipe b/recipes/gst-plugins-bad-1.0.recipe
index bfe02ca35..0daf97340 100644
--- a/recipes/gst-plugins-bad-1.0.recipe
+++ b/recipes/gst-plugins-bad-1.0.recipe
@@ -485,7 +485,7 @@ class Recipe(custom.GStreamer):
                 (self.config.target_platform == Platform.IOS and self.config.target_arch != Architecture.ARM64):
             self.disable_plugin('vulkan', 'vulkan', library_name='vulkan')
 
-        if self.using_msvc() or self.config.target_platform in (Platform.ANDROID, Platform.IOS):
+        if self.using_uwp() or self.config.target_platform in (Platform.ANDROID, Platform.IOS):
             self.disable_plugin('resindvd', 'dvd', dep='libdvdnav')
 
         # dtls plugin needs openssl, and we pick up the system openssl if on
-- 
GitLab