From f935a6d1d979bab06fc5a6cec0cde1bf25425ec1 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Mon, 8 Aug 2022 17:04:40 -0700 Subject: [PATCH] [Windows] Fix dllimport issue in unit tests (flutter/engine#35246) In flutter/engine#35106, I landed a parameter type fix for the declaration of FlutterDesktopEngineGetTextureRegistrar in our public Windows C API. I also added a unit test that called this function. That function (and all others) in our public Windows API is marked FLUTTER_EXPORT, which resolves to __declspec(dllexport) or __declspec(dllimport) depending on whether FLUTTER_DESKTOP_LIBRARY is defined. It can be defined by adding the following build config: //flutter/shell/platform/common:desktop_library_implementation If the function is marked as an import, we get linker warnings that we're importing a function that's defined in the same executable image. This patch resolves this by marking the functions as export. An alternative fix would be to support a third macro resolution that resolves to nothing in the presence of some definition like FLUTTER_NO_EXPORT; however, since flutter_export.h is a public header, I'd prefer not to complicate it further, and this is a unit test that can't be linked against either way. Issue: https://github.com/flutter/flutter/issues/109184 Original issue: https://github.com/flutter/flutter/issues/86617 See: https://github.com/flutter/engine/blob/main/shell/platform/common/public/flutter_export.h See: https://github.com/flutter/engine/blob/61c0051a635b28adb51297faaca1ba98e7300116/shell/platform/common/BUILD.gn#L8-L10 No new tests since this simply fixes a link warning message in unit tests. --- engine/src/flutter/shell/platform/windows/BUILD.gn | 3 +++ 1 file changed, 3 insertions(+) diff --git a/engine/src/flutter/shell/platform/windows/BUILD.gn b/engine/src/flutter/shell/platform/windows/BUILD.gn index c83e5f2fdb..09597e3218 100644 --- a/engine/src/flutter/shell/platform/windows/BUILD.gn +++ b/engine/src/flutter/shell/platform/windows/BUILD.gn @@ -205,6 +205,9 @@ executable("flutter_windows_unittests") { "window_unittests.cc", ] + configs += + [ "//flutter/shell/platform/common:desktop_library_implementation" ] + public_configs = [ "//flutter:config" ] deps = [