From 57a401ae32522101f00fcf507da3ca2baa1973c7 Mon Sep 17 00:00:00 2001 From: James Clarke Date: Thu, 11 Mar 2021 21:52:53 -0800 Subject: [PATCH] Windows: Switch UWP build to using winrt generated headers (#24861) * Switch build to using generated headers * Update DEPS to pick up newer buildroot * Only run hook on Windows --- DEPS | 13 ++++++++++++- shell/platform/windows/BUILD.gn | 16 ++++++++++++++++ shell/platform/windows/angle_surface_manager.cc | 2 +- shell/platform/windows/flutter_window_winuwp.h | 14 +++++++------- shell/platform/windows/task_runner_winuwp.h | 2 +- shell/platform/windows/window_binding_handler.h | 2 +- 6 files changed, 38 insertions(+), 11 deletions(-) diff --git a/DEPS b/DEPS index e1c50568a00de..05d132a227334 100644 --- a/DEPS +++ b/DEPS @@ -97,7 +97,7 @@ allowed_hosts = [ ] deps = { - 'src': 'https://github.com/flutter/buildroot.git' + '@' + 'd05290fdfb0b8d2aad3c60bf0b4a76f368616452', + 'src': 'https://github.com/flutter/buildroot.git' + '@' + '33358ba597f875f6646522fd4ea86c1b31404d77', # Fuchsia compatibility # @@ -658,5 +658,16 @@ hooks = [ 'python', 'src/flutter/tools/run_third_party_dart.py', ] + }, + { + # This must run whenever the cppwinrt dependency is updated + # to regenerate winrt headers + 'name': 'Generate winrt headers', + 'pattern': '.', + 'condition': 'download_windows_deps', + 'action': [ + 'python', + 'src/build/win/generate_winrt_headers.py', + ] } ] diff --git a/shell/platform/windows/BUILD.gn b/shell/platform/windows/BUILD.gn index b3d5f4f60f433..c023e6d3fb350 100644 --- a/shell/platform/windows/BUILD.gn +++ b/shell/platform/windows/BUILD.gn @@ -21,6 +21,17 @@ config("relative_flutter_windows_headers") { include_dirs = [ "public" ] } +config("cppwinrt_defs") { + # Use winrt headers generated by the cppwinrt tool rather than those shipped in the installed SDK. + # The Windows metadata used to generate the headers does come from the installed SDK, by generating them rather than using the shipped ones + # the latest cppwinrt compatibility fixes can be derived. For example, clang support is broken in the winrt headers shipped in SDK 10.0.19041.0. + # By generating them in the flutter toolchain using the SDK 10.0.19041.0 metadata and the latest version of the cppwinrt tool, that SDK version can be supported. + # + # Generated with command bin\cppwinrt.exe -in sdk -out generated + # by src\build\win\generate_winrt_headers.py + include_dirs = [ "..\..\..\..\third_party\cppwinrt\generated" ] +} + # The headers are a separate source set since the client wrapper is allowed # to depend on the public headers, but none of the rest of the code. source_set("flutter_windows_headers") { @@ -119,6 +130,11 @@ source_set("flutter_windows_source") { ] } + if (target_os == "winuwp") { + configs += [ ":cppwinrt_defs" ] + cflags = [ "/EHsc" ] + } + configs += [ "//flutter/shell/platform/common:desktop_library_implementation", "//third_party/angle:gl_prototypes", diff --git a/shell/platform/windows/angle_surface_manager.cc b/shell/platform/windows/angle_surface_manager.cc index a7c6907faac19..cf952998eee60 100644 --- a/shell/platform/windows/angle_surface_manager.cc +++ b/shell/platform/windows/angle_surface_manager.cc @@ -8,8 +8,8 @@ #include #ifdef WINUWP +#include #include -#include #endif #if defined(WINUWP) && defined(USECOREWINDOW) diff --git a/shell/platform/windows/flutter_window_winuwp.h b/shell/platform/windows/flutter_window_winuwp.h index 5fc9df821f960..927ec98490b23 100644 --- a/shell/platform/windows/flutter_window_winuwp.h +++ b/shell/platform/windows/flutter_window_winuwp.h @@ -5,14 +5,14 @@ #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_UWP_FLUTTER_WINDOW_H_ #define FLUTTER_SHELL_PLATFORM_WINDOWS_UWP_FLUTTER_WINDOW_H_ -#include -#include -#include -#include - +#include +#include +#include +#include +#include +#include +#include #include -#include -#include #include "flutter/shell/platform/embedder/embedder.h" #include "flutter/shell/platform/windows/flutter_windows_view.h" diff --git a/shell/platform/windows/task_runner_winuwp.h b/shell/platform/windows/task_runner_winuwp.h index 654dd0e54dc97..d411a4c2c383a 100644 --- a/shell/platform/windows/task_runner_winuwp.h +++ b/shell/platform/windows/task_runner_winuwp.h @@ -7,7 +7,7 @@ #include -#include +#include #include #include diff --git a/shell/platform/windows/window_binding_handler.h b/shell/platform/windows/window_binding_handler.h index 0716b55c7c4d8..749fda203f56c 100644 --- a/shell/platform/windows/window_binding_handler.h +++ b/shell/platform/windows/window_binding_handler.h @@ -15,7 +15,7 @@ #include "flutter/shell/platform/windows/window_binding_handler_delegate.h" #ifdef WINUWP -#include +#include #endif namespace flutter {