Don't set __MINGW32__

This took me a few hours of non-stop headaches to figure out. Apparently
deep inside of Wine's headers having __MINGW32__ defined will cause some
GUIDs to be defined slightly differently. This normally wouldn't cause
issues, but when including `shellobj.h` or `objbase.h` this results in
multiple definition linking errors that are basically impossible to
diagnose.
This commit is contained in:
Robbert van der Helm
2020-12-05 02:30:53 +01:00
parent d87afa99e0
commit 76ad377522
6 changed files with 13 additions and 33 deletions
+5 -9
View File
@@ -31,7 +31,7 @@ compiler_options = [
'-fvisibility-inlines-hidden',
# Disable the use of concepts in Boost.Asio until Boost 1.73 gets released
# https://github.com/boostorg/asio/issues/312
'-DBOOST_ASIO_DISABLE_CONCEPTS'
'-DBOOST_ASIO_DISABLE_CONCEPTS',
]
with_bitbridge = get_option('with-bitbridge')
@@ -176,6 +176,7 @@ if with_vst3
vst3_sdk_native_dep = declare_dependency(
link_with : vst3_sdk_native,
include_directories : vst3_include_dir,
compile_args : vst3_compiler_options,
)
# And another dependency for the host SDK for our Wine host applications
@@ -192,14 +193,9 @@ if with_vst3
endif
vst3_wine_compiler_options = [
# Removes some MSVC-isms for us
'-D__MINGW32__',
# We don't need all of this stuff from `Windows.h`, and it only causes more
# issues
# Some stuff from `windows.h` results in conflicting definitions
'-DNOMINMAX',
'-DNOSERVICE',
'-DNOMCX',
'-DWIN32_LEAN_AND_MEAN',
'-DWINE_NOWINSOCK',
]
vst3_base_wine_64bit = static_library(
'vst3_base_wine_64bit',
@@ -268,7 +264,7 @@ if with_vst3
# This does mean that we now have a lot of defines in our code, but the
# alternative would be patching every location in the SDK where they include
# `windows.h`
compile_args : vst3_wine_compiler_options,
compile_args : vst3_compiler_options + vst3_wine_compiler_options,
)
endif
endif
-3
View File
@@ -23,13 +23,11 @@
// it's running under a WIN32 environment. If anyone knows a better way to do
// this, please let me know!
#pragma push_macro("__MINGW32__")
#pragma push_macro("WIN32")
#pragma push_macro("_WIN32")
#pragma push_macro("__WIN32__")
#pragma push_macro("_WIN64")
#undef __MINGW32__
#undef WIN32
#undef _WIN32
#undef __WIN32__
@@ -44,7 +42,6 @@
#include <boost/asio/basic_socket_streambuf.hpp>
// #include <boost/asio/detail/timer_queue_ptime.hpp>
#pragma pop_macro("__MINGW32__")
#pragma pop_macro("WIN32")
#pragma pop_macro("_WIN32")
#pragma pop_macro("__WIN32__")
-4
View File
@@ -20,10 +20,6 @@
#ifndef NOMINMAX
#define NOMINMAX
#define NOSERVICE
#define NOMCX
#define NOIMM
#define WIN32_LEAN_AND_MEAN
#endif
#include <vestige/aeffectx.h>
#include <windows.h>
-4
View File
@@ -22,10 +22,6 @@
#ifndef NOMINMAX
#define NOMINMAX
#define NOSERVICE
#define NOMCX
#define NOIMM
#define WIN32_LEAN_AND_MEAN
#endif
#include <vestige/aeffectx.h>
#include <windows.h>
-4
View File
@@ -23,10 +23,6 @@
#ifndef NOMINMAX
#define NOMINMAX
#define NOSERVICE
#define NOMCX
#define NOIMM
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
+8 -9
View File
@@ -25,11 +25,14 @@ fi
find "$sdk_directory" -type f \( -iname '*.h' -or -iname '*.cpp' \) -print0 |
xargs -0 sed -i -E 's/^#include <(Windows.h|ShlObj.h)>$/#include <\L\1\E>/'
# We're building with `WIN32_LEAN_AND_MEAN` because some of the definitions in
# there conflict with the C standard library as provided by GCC. This also
# excludes the shell API, which the VST3 SDK uses to open URLs.
sed -i "s/^#include <windows.h>$/#include <windows.h> \\/\\/ patched for yabridge\\
#include <shellapi.h>/" "$sdk_directory/public.sdk/source/common/openurl.cpp"
# Use the attributes and types from GCC
sed -i 's/defined(__MINGW32__)/defined(__WINE__)/g' "$sdk_directory/pluginterfaces/base/ftypes.h"
# There are some more places where the SDK includes better compatibility with
# GCC that we can use
# NOTE: We should **not** define __MINGW32__ globally, since that also breaks
# Wine's headers in headache inducing ways
sed -i 's/defined(__MINGW32__)/defined(__WINE__)/g' "$sdk_directory/public.sdk/source/common/systemclipboard_win32.cpp"
# Use the string manipulation functions from the C standard library
sed -i 's/\bSMTG_OS_WINDOWS\b/0/g;s/\bSMTG_OS_LINUX\b/1/g' "$sdk_directory/base/source/fstring.cpp"
@@ -61,10 +64,6 @@ replace_char16 "using ConverterFacet = std::codecvt_utf8_utf16<char16_t>;" "$sdk
replace_char16 "using Converter = std::wstring_convert<ConverterFacet, char16_t>;" "$sdk_directory/base/source/fstring.cpp"
replace_char16 "using Converter = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>;" "$sdk_directory/pluginterfaces/base/ustring.cpp"
# The definitions of long doesn't match up between platforms, and the mingw
# version here is trying to do something funky
sed -i 's/\b__MINGW32__\b/__NOPE__/g' "$sdk_directory/pluginterfaces/base/funknown.cpp"
# libstdc++fs doesn't work under Winelib, for whatever reason that might be.
# We'll patch the Win32 module loading to use Boost.Filesystem instead.
sed -i 's/^#include <\(experimental\/\)\?filesystem>$/#include <boost\/filesystem.hpp>/' "$sdk_directory/public.sdk/source/vst/hosting/module_win32.cpp"