Skip to content

Commit

Permalink
Windows: Switch UWP build to using winrt generated headers (flutter#2…
Browse files Browse the repository at this point in the history
…4861)

* Switch build to using generated headers

* Update DEPS to pick up newer buildroot

* Only run hook on Windows
  • Loading branch information
clarkezone authored Mar 12, 2021
1 parent 31ec057 commit 57a401a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 11 deletions.
13 changes: 12 additions & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down Expand Up @@ -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',
]
}
]
16 changes: 16 additions & 0 deletions shell/platform/windows/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/windows/angle_surface_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <vector>

#ifdef WINUWP
#include <third_party/cppwinrt/generated/winrt/Windows.UI.Composition.h>
#include <windows.ui.core.h>
#include <winrt/Windows.UI.Composition.h>
#endif

#if defined(WINUWP) && defined(USECOREWINDOW)
Expand Down
14 changes: 7 additions & 7 deletions shell/platform/windows/flutter_window_winuwp.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_UWP_FLUTTER_WINDOW_H_
#define FLUTTER_SHELL_PLATFORM_WINDOWS_UWP_FLUTTER_WINDOW_H_

#include <winrt/Windows.Graphics.Display.h>
#include <winrt/Windows.System.Profile.h>
#include <winrt/Windows.UI.Input.h>
#include <winrt/Windows.UI.ViewManagement.Core.h>

#include <third_party/cppwinrt/generated/winrt/Windows.Foundation.Collections.h>
#include <third_party/cppwinrt/generated/winrt/Windows.Graphics.Display.h>
#include <third_party/cppwinrt/generated/winrt/Windows.System.Profile.h>
#include <third_party/cppwinrt/generated/winrt/Windows.UI.Composition.h>
#include <third_party/cppwinrt/generated/winrt/Windows.UI.Core.h>
#include <third_party/cppwinrt/generated/winrt/Windows.UI.Input.h>
#include <third_party/cppwinrt/generated/winrt/Windows.UI.ViewManagement.Core.h>
#include <windows.ui.core.h>
#include <winrt/Windows.UI.Composition.h>
#include <winrt/Windows.UI.Core.h>

#include "flutter/shell/platform/embedder/embedder.h"
#include "flutter/shell/platform/windows/flutter_windows_view.h"
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/windows/task_runner_winuwp.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <windows.h>

#include <winrt/Windows.UI.Core.h>
#include <third_party/cppwinrt/generated/winrt/Windows.UI.Core.h>

#include <chrono>
#include <functional>
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/windows/window_binding_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "flutter/shell/platform/windows/window_binding_handler_delegate.h"

#ifdef WINUWP
#include <winrt/Windows.UI.Composition.h>
#include <third_party/cppwinrt/generated/winrt/Windows.UI.Composition.h>
#endif

namespace flutter {
Expand Down

0 comments on commit 57a401a

Please sign in to comment.