Skip to content

Commit

Permalink
[Windows] Fix dllimport issue in unit tests (flutter#35246)
Browse files Browse the repository at this point in the history
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: flutter#109184
Original issue: flutter#86617

See: https://github.com/flutter/engine/blob/main/shell/platform/common/public/flutter_export.h
See: https://github.com/flutter/engine/blob/a51c7638e702b086dffaae3ce92f52130a2c23ff/shell/platform/common/BUILD.gn#L8-L10

No new tests since this simply fixes a link warning message in unit tests.
  • Loading branch information
cbracken authored Aug 9, 2022
1 parent d138190 commit 9bfbc54
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions shell/platform/windows/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ executable("flutter_windows_unittests") {
"window_unittests.cc",
]

configs +=
[ "//flutter/shell/platform/common:desktop_library_implementation" ]

public_configs = [ "//flutter:config" ]

deps = [
Expand Down

0 comments on commit 9bfbc54

Please sign in to comment.