Skip to content

Commit 2cf072b

Browse files
clarkezoneduanqz
authored andcommitted
Windows: Switch UWP build to using winrt generated headers (flutter#24861)
* Switch build to using generated headers * Update DEPS to pick up newer buildroot * Only run hook on Windows
1 parent 24582f6 commit 2cf072b

6 files changed

Lines changed: 38 additions & 11 deletions

File tree

DEPS

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ allowed_hosts = [
9797
]
9898

9999
deps = {
100-
'src': 'https://github.com/flutter/buildroot.git' + '@' + 'd05290fdfb0b8d2aad3c60bf0b4a76f368616452',
100+
'src': 'https://github.com/flutter/buildroot.git' + '@' + '33358ba597f875f6646522fd4ea86c1b31404d77',
101101

102102
# Fuchsia compatibility
103103
#
@@ -658,5 +658,16 @@ hooks = [
658658
'python',
659659
'src/flutter/tools/run_third_party_dart.py',
660660
]
661+
},
662+
{
663+
# This must run whenever the cppwinrt dependency is updated
664+
# to regenerate winrt headers
665+
'name': 'Generate winrt headers',
666+
'pattern': '.',
667+
'condition': 'download_windows_deps',
668+
'action': [
669+
'python',
670+
'src/build/win/generate_winrt_headers.py',
671+
]
661672
}
662673
]

shell/platform/windows/BUILD.gn

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ config("relative_flutter_windows_headers") {
2121
include_dirs = [ "public" ]
2222
}
2323

24+
config("cppwinrt_defs") {
25+
# Use winrt headers generated by the cppwinrt tool rather than those shipped in the installed SDK.
26+
# The Windows metadata used to generate the headers does come from the installed SDK, by generating them rather than using the shipped ones
27+
# 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.
28+
# 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.
29+
#
30+
# Generated with command bin\cppwinrt.exe -in sdk -out generated
31+
# by src\build\win\generate_winrt_headers.py
32+
include_dirs = [ "..\..\..\..\third_party\cppwinrt\generated" ]
33+
}
34+
2435
# The headers are a separate source set since the client wrapper is allowed
2536
# to depend on the public headers, but none of the rest of the code.
2637
source_set("flutter_windows_headers") {
@@ -119,6 +130,11 @@ source_set("flutter_windows_source") {
119130
]
120131
}
121132

133+
if (target_os == "winuwp") {
134+
configs += [ ":cppwinrt_defs" ]
135+
cflags = [ "/EHsc" ]
136+
}
137+
122138
configs += [
123139
"//flutter/shell/platform/common:desktop_library_implementation",
124140
"//third_party/angle:gl_prototypes",

shell/platform/windows/angle_surface_manager.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include <vector>
99

1010
#ifdef WINUWP
11+
#include <third_party/cppwinrt/generated/winrt/Windows.UI.Composition.h>
1112
#include <windows.ui.core.h>
12-
#include <winrt/Windows.UI.Composition.h>
1313
#endif
1414

1515
#if defined(WINUWP) && defined(USECOREWINDOW)

shell/platform/windows/flutter_window_winuwp.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_UWP_FLUTTER_WINDOW_H_
66
#define FLUTTER_SHELL_PLATFORM_WINDOWS_UWP_FLUTTER_WINDOW_H_
77

8-
#include <winrt/Windows.Graphics.Display.h>
9-
#include <winrt/Windows.System.Profile.h>
10-
#include <winrt/Windows.UI.Input.h>
11-
#include <winrt/Windows.UI.ViewManagement.Core.h>
12-
8+
#include <third_party/cppwinrt/generated/winrt/Windows.Foundation.Collections.h>
9+
#include <third_party/cppwinrt/generated/winrt/Windows.Graphics.Display.h>
10+
#include <third_party/cppwinrt/generated/winrt/Windows.System.Profile.h>
11+
#include <third_party/cppwinrt/generated/winrt/Windows.UI.Composition.h>
12+
#include <third_party/cppwinrt/generated/winrt/Windows.UI.Core.h>
13+
#include <third_party/cppwinrt/generated/winrt/Windows.UI.Input.h>
14+
#include <third_party/cppwinrt/generated/winrt/Windows.UI.ViewManagement.Core.h>
1315
#include <windows.ui.core.h>
14-
#include <winrt/Windows.UI.Composition.h>
15-
#include <winrt/Windows.UI.Core.h>
1616

1717
#include "flutter/shell/platform/embedder/embedder.h"
1818
#include "flutter/shell/platform/windows/flutter_windows_view.h"

shell/platform/windows/task_runner_winuwp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include <windows.h>
99

10-
#include <winrt/Windows.UI.Core.h>
10+
#include <third_party/cppwinrt/generated/winrt/Windows.UI.Core.h>
1111

1212
#include <chrono>
1313
#include <functional>

shell/platform/windows/window_binding_handler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "flutter/shell/platform/windows/window_binding_handler_delegate.h"
1616

1717
#ifdef WINUWP
18-
#include <winrt/Windows.UI.Composition.h>
18+
#include <third_party/cppwinrt/generated/winrt/Windows.UI.Composition.h>
1919
#endif
2020

2121
namespace flutter {

0 commit comments

Comments
 (0)