Build engine TUs with C++20. (#174471)
The changes:
* Creating a bit-mask with different enum values is now a warning. Fixed
offending instances.
* `char8_t` is a different type. Fixed those instances.
* Disabling modules in Objective-C requires bypassing the driver.
* Aggregate initialization fails when there are other constructors for
structs. Added explicit constructors.
* `gn format` doesn't seem to be run on erstwhile buildroot GN files.
Fixes the formatting. But can back this out since it is technically
unrelated to C++20.
diff --git a/DEPS b/DEPS
index 49f805a..d452b41 100644
--- a/DEPS
+++ b/DEPS
@@ -256,7 +256,7 @@
Var('chromium_git') + '/vulkan-deps' + '@' + '938de304bdcb33049ec39ce45f16223eb6a960b6',
'engine/src/flutter/third_party/flatbuffers':
- Var('chromium_git') + '/external/github.com/google/flatbuffers' + '@' + '0a80646371179f8a7a5c1f42c31ee1d44dcf6709',
+ Var('chromium_git') + '/external/github.com/google/flatbuffers' + '@' + '067bfdbde9b10c1beb5d6b02d67ae9db8b96f736',
'engine/src/flutter/third_party/icu':
Var('chromium_git') + '/chromium/deps/icu.git' + '@' + '1b2e3e8a421efae36141a7b932b41e315b089af8',
diff --git a/engine/src/build/config/compiler/BUILD.gn b/engine/src/build/config/compiler/BUILD.gn
index 800a6a6..cb987dd 100644
--- a/engine/src/build/config/compiler/BUILD.gn
+++ b/engine/src/build/config/compiler/BUILD.gn
@@ -116,6 +116,7 @@
} else if (!is_ios && !is_wasm && !is_qnx) {
cflags += [
"-fstack-protector",
+
# 8 is the default, but make this explicit here so that we don't have to
# go hunting for the flag name if we ever want a value that is
# different from the default.
@@ -300,7 +301,8 @@
if (wasm_use_workers) {
cflags += [ "-sWASM_WORKERS=1" ]
ldflags += [ "-sWASM_WORKERS=1" ]
- } if (wasm_shared_memory) {
+ }
+ if (wasm_shared_memory) {
cflags += [ "-sSHARED_MEMORY=1" ]
ldflags += [ "-sSHARED_MEMORY=1" ]
}
@@ -356,9 +358,7 @@
# Linux/Android common flags setup.
# ---------------------------------
if (is_linux || is_android || is_qnx) {
- cflags += [
- "-fPIC",
- ]
+ cflags += [ "-fPIC" ]
if (!is_qnx) {
cflags += [
@@ -382,7 +382,7 @@
if (target_cpu == "arm64") {
qnx_arch_flags += [
"-V",
- "gcc_ntoaarch64le"
+ "gcc_ntoaarch64le",
]
} else {
assert(false, "Unknown QNX architecture")
@@ -474,20 +474,55 @@
# Fuchsia-specific flags setup.
# -----------------------------
if (is_fuchsia) {
- configs = ["//flutter/tools/fuchsia/gn-sdk/src/config:compiler"]
+ configs = [ "//flutter/tools/fuchsia/gn-sdk/src/config:compiler" ]
}
asmflags = cflags
}
+# C++ modules (available and enabled by default in C++20 and above) are
+# prohibited by the style guide.
+config("cxx_disable_modules") {
+ disable_modules_flags = [
+ "-fno-modules",
+
+ # Some Clang versions do not disable ObjC modules (as tested by
+ # __has_feature(objc_modules)) when just -fno-modules is present.
+ "-Xclang",
+ "-fno-cxx-modules",
+ ]
+ cflags_c = disable_modules_flags
+ cflags_cc = disable_modules_flags
+ cflags_objc = disable_modules_flags
+ cflags_objcc = disable_modules_flags
+}
+
config("cxx_version_default") {
if (is_win) {
- cc_std = [ "/std:c++17" ]
+ cc_std = [ "/std:c++20" ]
} else {
- cc_std = [ "-std=c++17" ]
+ cc_std = [ "-std=c++20" ]
}
+
+ configs = [ ":cxx_disable_modules" ]
+
cflags_cc = cc_std
cflags_objcc = cc_std
+
+ # The following corrections are only in place for targets that have opted into
+ # the default version. These targets have not had to opportunity to upgrade to
+ # a newer version. Targets that have explicitly opted into the newer version
+ # must fix the errors they run into.
+
+ if (is_clang) {
+ extra_warning_flags_cc = [
+ # TODO(174665): Third-party dependency (Angle) needs to patched to work
+ # around this.
+ "-Wno-deprecated-this-capture",
+ ]
+ cflags_cc += extra_warning_flags_cc
+ cflags_objcc += extra_warning_flags_cc
+ }
}
config("cxx_version_11") {
@@ -528,6 +563,8 @@
}
cflags_cc = cc_std
cflags_objcc = cc_std
+
+ configs = [ ":cxx_disable_modules" ]
}
config("compiler_arm_fpu") {
@@ -575,8 +612,10 @@
# Add libcxx[abi]/include via cflags_cc, cflags_objcc to apply to
# C++/Obj-C++ only. Adding them via include_dirs is problematic for Swift,
# whose core libraries expect the Apple SDK C++ headers, module.modulemap.
- _libcxx_include = rebase_path("//flutter/third_party/libcxx/include", root_build_dir)
- _libcxxabi_include = rebase_path("//flutter/third_party/libcxxabi/include", root_build_dir)
+ _libcxx_include =
+ rebase_path("//flutter/third_party/libcxx/include", root_build_dir)
+ _libcxxabi_include =
+ rebase_path("//flutter/third_party/libcxxabi/include", root_build_dir)
cflags_cc += [
"-nostdinc++",
"-I" + _libcxx_include,
@@ -604,9 +643,7 @@
ldflags += [ "-nostdlib" ]
- ldflags += [
- "-Wl,--warn-shared-textrel",
- ]
+ ldflags += [ "-Wl,--warn-shared-textrel" ]
libs += [
"c",
@@ -639,7 +676,7 @@
# Fuchsia standard library setup.
if (is_fuchsia) {
- configs = ["//flutter/tools/fuchsia/gn-sdk/src/config:runtime_library"]
+ configs = [ "//flutter/tools/fuchsia/gn-sdk/src/config:runtime_library" ]
}
}
@@ -653,6 +690,7 @@
if (is_qnx) {
default_warning_flags_cc += [ "-fpermissive" ]
}
+
if (is_win) {
default_warning_flags += [
# Permanent.
@@ -1013,9 +1051,7 @@
# On WASM we don't want to fully deoptimize the debug build because the
# compiled binary will have some functions with too many local variables
# and Chrome will reject it.
- cflags = [
- "-O1",
- ]
+ cflags = [ "-O1" ]
ldflags = common_optimize_on_ldflags
} else {
cflags = [ "-O0" ]
@@ -1112,6 +1148,7 @@
"-Wshorten-64-to-32",
"-Wimplicit-int-conversion",
"-Wsign-compare",
+
# Avoid bugs of the form `if (size_t i = size; i >= 0; --i)` while
# fixing types to be sign-correct.
"-Wtautological-unsigned-zero-compare",
diff --git a/engine/src/flutter/build/secondary/flutter/third_party/flatbuffers/BUILD.gn b/engine/src/flutter/build/secondary/flutter/third_party/flatbuffers/BUILD.gn
index a5aba29..a760add 100644
--- a/engine/src/flutter/build/secondary/flutter/third_party/flatbuffers/BUILD.gn
+++ b/engine/src/flutter/build/secondary/flutter/third_party/flatbuffers/BUILD.gn
@@ -15,11 +15,12 @@
"$_src_root/include/flatbuffers/allocator.h",
"$_src_root/include/flatbuffers/array.h",
"$_src_root/include/flatbuffers/base.h",
- "$_src_root/include/flatbuffers/bfbs_generator.h",
"$_src_root/include/flatbuffers/buffer.h",
"$_src_root/include/flatbuffers/buffer_ref.h",
+ "$_src_root/include/flatbuffers/code_generator.h",
"$_src_root/include/flatbuffers/default_allocator.h",
"$_src_root/include/flatbuffers/detached_buffer.h",
+ "$_src_root/include/flatbuffers/file_manager.h",
"$_src_root/include/flatbuffers/flatbuffer_builder.h",
"$_src_root/include/flatbuffers/flatbuffers.h",
"$_src_root/include/flatbuffers/flex_flat_util.h",
@@ -62,18 +63,28 @@
"$_src_root/grpc/src/compiler/swift_generator.h",
"$_src_root/grpc/src/compiler/ts_generator.cc",
"$_src_root/grpc/src/compiler/ts_generator.h",
+ "$_src_root/include/codegen/idl_namer.h",
+ "$_src_root/include/codegen/namer.h",
+ "$_src_root/include/codegen/python.cc",
+ "$_src_root/include/codegen/python.h",
"$_src_root/include/flatbuffers/code_generators.h",
"$_src_root/src/annotated_binary_text_gen.cpp",
"$_src_root/src/annotated_binary_text_gen.h",
"$_src_root/src/bfbs_gen.h",
"$_src_root/src/bfbs_gen_lua.cpp",
"$_src_root/src/bfbs_gen_lua.h",
+ "$_src_root/src/bfbs_gen_nim.cpp",
+ "$_src_root/src/bfbs_gen_nim.h",
"$_src_root/src/bfbs_namer.h",
"$_src_root/src/binary_annotator.cpp",
"$_src_root/src/binary_annotator.h",
"$_src_root/src/code_generators.cpp",
+ "$_src_root/src/file_binary_writer.cpp",
+ "$_src_root/src/file_name_saving_file_manager.cpp",
+ "$_src_root/src/file_writer.cpp",
"$_src_root/src/flatc.cpp",
"$_src_root/src/flatc_main.cpp",
+ "$_src_root/src/idl_gen_binary.cpp",
"$_src_root/src/idl_gen_cpp.cpp",
"$_src_root/src/idl_gen_csharp.cpp",
"$_src_root/src/idl_gen_dart.cpp",
@@ -83,8 +94,8 @@
"$_src_root/src/idl_gen_java.cpp",
"$_src_root/src/idl_gen_json_schema.cpp",
"$_src_root/src/idl_gen_kotlin.cpp",
+ "$_src_root/src/idl_gen_kotlin_kmp.cpp",
"$_src_root/src/idl_gen_lobster.cpp",
- "$_src_root/src/idl_gen_lua.cpp",
"$_src_root/src/idl_gen_php.cpp",
"$_src_root/src/idl_gen_python.cpp",
"$_src_root/src/idl_gen_rust.cpp",
diff --git a/engine/src/flutter/display_list/dl_paint.cc b/engine/src/flutter/display_list/dl_paint.cc
index 76a682e..ccec201 100644
--- a/engine/src/flutter/display_list/dl_paint.cc
+++ b/engine/src/flutter/display_list/dl_paint.cc
@@ -13,8 +13,6 @@
draw_style_(static_cast<unsigned>(DlDrawStyle::kDefaultStyle)),
stroke_cap_(static_cast<unsigned>(DlStrokeCap::kDefaultCap)),
stroke_join_(static_cast<unsigned>(DlStrokeJoin::kDefaultJoin)),
- is_anti_alias_(false),
- is_invert_colors_(false),
color_(color),
stroke_width_(kDefaultWidth),
stroke_miter_(kDefaultMiter) {}
diff --git a/engine/src/flutter/display_list/dl_paint.h b/engine/src/flutter/display_list/dl_paint.h
index 843900d..adaa018 100644
--- a/engine/src/flutter/display_list/dl_paint.h
+++ b/engine/src/flutter/display_list/dl_paint.h
@@ -221,12 +221,12 @@
union {
struct {
- unsigned blend_mode_ : kBlendModeBits;
- unsigned draw_style_ : kDrawStyleBits;
- unsigned stroke_cap_ : kStrokeCapBits;
- unsigned stroke_join_ : kStrokeJoinBits;
- unsigned is_anti_alias_ : 1;
- unsigned is_invert_colors_ : 1;
+ unsigned blend_mode_ : kBlendModeBits = {};
+ unsigned draw_style_ : kDrawStyleBits = {};
+ unsigned stroke_cap_ : kStrokeCapBits = {};
+ unsigned stroke_join_ : kStrokeJoinBits = {};
+ unsigned is_anti_alias_ : 1 = {};
+ unsigned is_invert_colors_ : 1 = {};
};
};
diff --git a/engine/src/flutter/fml/file_unittest.cc b/engine/src/flutter/fml/file_unittest.cc
index 647f82b..6e55d1c 100644
--- a/engine/src/flutter/fml/file_unittest.cc
+++ b/engine/src/flutter/fml/file_unittest.cc
@@ -343,7 +343,7 @@
TEST(FileTest, FileTestsSupportsUnicode) {
fml::ScopedTemporaryDirectory dir;
ASSERT_TRUE(dir.fd().is_valid());
- const char* filename = u8"äëïöüテスト☃";
+ const auto* filename = reinterpret_cast<const char*>(u8"äëïöüテスト☃");
auto fd =
fml::OpenFile(dir.fd(), filename, true, fml::FilePermission::kWrite);
ASSERT_TRUE(fd.is_valid());
diff --git a/engine/src/flutter/impeller/golden_tests/vulkan_screenshotter.mm b/engine/src/flutter/impeller/golden_tests/vulkan_screenshotter.mm
index 0315fdf..6f6702d 100644
--- a/engine/src/flutter/impeller/golden_tests/vulkan_screenshotter.mm
+++ b/engine/src/flutter/impeller/golden_tests/vulkan_screenshotter.mm
@@ -62,7 +62,8 @@
&CGColorSpaceRelease);
CGBitmapInfo bitmap_info =
texture->GetTextureDescriptor().format == PixelFormat::kB8G8R8A8UNormInt
- ? kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little
+ ? static_cast<uint32_t>(kCGImageAlphaPremultipliedFirst) |
+ static_cast<uint32_t>(kCGBitmapByteOrder32Little)
: kCGImageAlphaPremultipliedLast;
CGContextPtr context(
CGBitmapContextCreate(
diff --git a/engine/src/flutter/impeller/renderer/backend/vulkan/vk.h b/engine/src/flutter/impeller/renderer/backend/vulkan/vk.h
index f1c129d..a688985 100644
--- a/engine/src/flutter/impeller/renderer/backend/vulkan/vk.h
+++ b/engine/src/flutter/impeller/renderer/backend/vulkan/vk.h
@@ -69,6 +69,9 @@
}
#define VULKAN_HPP_NO_EXCEPTIONS
+// The spaceship operator behaves differently on 32-bit platforms.
+#define VULKAN_HPP_NO_SPACESHIP_OPERATOR
+
#include "vulkan/vulkan.hpp" // IWYU pragma: keep.
static_assert(VK_HEADER_VERSION >= 215, "Vulkan headers must not be too old.");
diff --git a/engine/src/flutter/shell/platform/common/client_wrapper/standard_message_codec_unittests.cc b/engine/src/flutter/shell/platform/common/client_wrapper/standard_message_codec_unittests.cc
index afe7247..df4420a 100644
--- a/engine/src/flutter/shell/platform/common/client_wrapper/standard_message_codec_unittests.cc
+++ b/engine/src/flutter/shell/platform/common/client_wrapper/standard_message_codec_unittests.cc
@@ -134,22 +134,22 @@
TEST(StandardMessageCodec, CanEncodeAndDecodeString) {
std::vector<uint8_t> bytes = {0x07, 0x0b, 0x68, 0x65, 0x6c, 0x6c, 0x6f,
0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64};
- CheckEncodeDecode(EncodableValue(u8"hello world"), bytes);
+ CheckEncodeDecode(EncodableValue("hello world"), bytes);
}
TEST(StandardMessageCodec, CanEncodeAndDecodeStringWithNonAsciiCodePoint) {
std::vector<uint8_t> bytes = {0x07, 0x05, 0x68, 0xe2, 0x98, 0xba, 0x77};
- CheckEncodeDecode(EncodableValue(u8"h\u263Aw"), bytes);
+ CheckEncodeDecode(EncodableValue("h\u263Aw"), bytes);
}
TEST(StandardMessageCodec, CanEncodeAndDecodeStringWithNonBMPCodePoint) {
std::vector<uint8_t> bytes = {0x07, 0x06, 0x68, 0xf0, 0x9f, 0x98, 0x82, 0x77};
- CheckEncodeDecode(EncodableValue(u8"h\U0001F602w"), bytes);
+ CheckEncodeDecode(EncodableValue("h\U0001F602w"), bytes);
}
TEST(StandardMessageCodec, CanEncodeAndDecodeEmptyString) {
std::vector<uint8_t> bytes = {0x07, 0x00};
- CheckEncodeDecode(EncodableValue(u8""), bytes);
+ CheckEncodeDecode(EncodableValue(""), bytes);
}
TEST(StandardMessageCodec, CanEncodeAndDecodeList) {
diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm
index 3340c35..e65dc4a 100644
--- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm
+++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm
@@ -3812,8 +3812,10 @@
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
// Draw the pixel on `point` in the context.
- CGContextRef context = CGBitmapContextCreate(
- pixel, 1, 1, 8, 4, colorSpace, kCGBitmapAlphaInfoMask & kCGImageAlphaPremultipliedLast);
+ CGContextRef context =
+ CGBitmapContextCreate(pixel, 1, 1, 8, 4, colorSpace,
+ static_cast<uint32_t>(kCGBitmapAlphaInfoMask) &
+ static_cast<uint32_t>(kCGImageAlphaPremultipliedLast));
CGContextTranslateCTM(context, -point.x, -point.y);
[view.layer renderInContext:context];
diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm
index 8f3aae4..c830c35 100644
--- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm
+++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTest.mm
@@ -939,7 +939,8 @@
CGEventRef cgEventDiscreteShift =
CGEventCreateScrollWheelEvent(NULL, kCGScrollEventUnitPixel, 1, 0);
CGEventSetType(cgEventDiscreteShift, kCGEventScrollWheel);
- CGEventSetFlags(cgEventDiscreteShift, kCGEventFlagMaskShift | flutter::kModifierFlagShiftLeft);
+ CGEventSetFlags(cgEventDiscreteShift, static_cast<uint64_t>(kCGEventFlagMaskShift) |
+ static_cast<uint64_t>(flutter::kModifierFlagShiftLeft));
CGEventSetIntegerValueField(cgEventDiscreteShift, kCGScrollWheelEventIsContinuous, 0);
CGEventSetIntegerValueField(cgEventDiscreteShift, kCGScrollWheelEventDeltaAxis2,
0); // scroll_delta_x
diff --git a/engine/src/flutter/shell/platform/glfw/BUILD.gn b/engine/src/flutter/shell/platform/glfw/BUILD.gn
index 59735b5..1983854 100644
--- a/engine/src/flutter/shell/platform/glfw/BUILD.gn
+++ b/engine/src/flutter/shell/platform/glfw/BUILD.gn
@@ -73,6 +73,8 @@
"IOKit.framework",
]
}
+
+ cflags_cc = [ "-Wno-deprecated-declarations" ]
}
test_fixtures("flutter_glfw_fixtures") {
diff --git a/engine/src/flutter/shell/platform/linux/BUILD.gn b/engine/src/flutter/shell/platform/linux/BUILD.gn
index 42da463..b4b161c 100644
--- a/engine/src/flutter/shell/platform/linux/BUILD.gn
+++ b/engine/src/flutter/shell/platform/linux/BUILD.gn
@@ -75,6 +75,12 @@
include_dirs = [ "public" ]
}
+config("disable_warnings") {
+ warning_flags = [ "-Wno-deprecated-volatile" ]
+ cflags = warning_flags
+ cflags_cc = warning_flags
+}
+
source_set("flutter_linux_sources") {
public = _public_headers + [
"fl_binary_messenger_private.h",
@@ -99,6 +105,8 @@
configs += [ "//flutter/shell/platform/linux/config:gtk" ]
+ public_configs = [ ":disable_warnings" ]
+
sources = [
"fl_accessible_node.cc",
"fl_accessible_text_field.cc",
diff --git a/engine/src/flutter/shell/platform/windows/BUILD.gn b/engine/src/flutter/shell/platform/windows/BUILD.gn
index 97c2599..4f49f5d 100644
--- a/engine/src/flutter/shell/platform/windows/BUILD.gn
+++ b/engine/src/flutter/shell/platform/windows/BUILD.gn
@@ -125,6 +125,8 @@
"text_input_manager.h",
"text_input_plugin.cc",
"text_input_plugin.h",
+ "wchar_util.cc",
+ "wchar_util.h",
"window_binding_handler.h",
"window_binding_handler_delegate.h",
"window_manager.cc",
diff --git a/engine/src/flutter/shell/platform/windows/direct_manipulation.cc b/engine/src/flutter/shell/platform/windows/direct_manipulation.cc
index f65e0e1..19bc332 100644
--- a/engine/src/flutter/shell/platform/windows/direct_manipulation.cc
+++ b/engine/src/flutter/shell/platform/windows/direct_manipulation.cc
@@ -8,6 +8,7 @@
#include "flutter/shell/platform/windows/direct_manipulation.h"
#include "flutter/shell/platform/windows/flutter_window.h"
+#include "flutter/shell/platform/windows/wchar_util.h"
#include "flutter/shell/platform/windows/window_binding_handler_delegate.h"
#define RETURN_IF_FAILED(operation) \
@@ -259,7 +260,7 @@
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
reinterpret_cast<LPWSTR>(&message), 0, NULL);
- FML_LOG(ERROR) << message;
+ FML_LOG(ERROR) << WCharBufferToString(message);
}
}
}
diff --git a/engine/src/flutter/shell/platform/windows/flutter_project_bundle.cc b/engine/src/flutter/shell/platform/windows/flutter_project_bundle.cc
index 87cd0b4..b63dad5 100644
--- a/engine/src/flutter/shell/platform/windows/flutter_project_bundle.cc
+++ b/engine/src/flutter/shell/platform/windows/flutter_project_bundle.cc
@@ -69,11 +69,11 @@
return UniqueAotDataPtr(nullptr, nullptr);
}
if (!std::filesystem::exists(aot_library_path_)) {
- FML_LOG(ERROR) << "Can't load AOT data from "
- << aot_library_path_.u8string() << "; no such file.";
+ FML_LOG(ERROR) << "Can't load AOT data from " << aot_library_path_
+ << "; no such file.";
return UniqueAotDataPtr(nullptr, nullptr);
}
- std::string path_string = aot_library_path_.u8string();
+ std::string path_string = aot_library_path_.string();
FlutterEngineAOTDataSource source = {};
source.type = kFlutterEngineAOTDataSourceTypeElfPath;
source.elf_path = path_string.c_str();
diff --git a/engine/src/flutter/shell/platform/windows/flutter_windows_engine.cc b/engine/src/flutter/shell/platform/windows/flutter_windows_engine.cc
index bb7a7c7..8753ecc 100644
--- a/engine/src/flutter/shell/platform/windows/flutter_windows_engine.cc
+++ b/engine/src/flutter/shell/platform/windows/flutter_windows_engine.cc
@@ -274,8 +274,8 @@
FML_LOG(ERROR) << "Missing or unresolvable paths to assets.";
return false;
}
- std::string assets_path_string = project_->assets_path().u8string();
- std::string icu_path_string = project_->icu_path().u8string();
+ std::string assets_path_string = project_->assets_path().string();
+ std::string icu_path_string = project_->icu_path().string();
if (embedder_api_.RunsAOTCompiledDartCode()) {
aot_data_ = project_->LoadAotData(embedder_api_);
if (!aot_data_) {
diff --git a/engine/src/flutter/shell/platform/windows/host_window.cc b/engine/src/flutter/shell/platform/windows/host_window.cc
index 41f8552..c2bcfea 100644
--- a/engine/src/flutter/shell/platform/windows/host_window.cc
+++ b/engine/src/flutter/shell/platform/windows/host_window.cc
@@ -11,6 +11,7 @@
#include "flutter/shell/platform/windows/flutter_window.h"
#include "flutter/shell/platform/windows/flutter_windows_view_controller.h"
#include "flutter/shell/platform/windows/rect_helper.h"
+#include "flutter/shell/platform/windows/wchar_util.h"
#include "flutter/shell/platform/windows/window_manager.h"
namespace {
@@ -317,8 +318,9 @@
window_class.lpszClassName = kWindowClassName;
if (!RegisterClassEx(&window_class)) {
- FML_LOG(ERROR) << "Cannot register window class " << kWindowClassName
- << ": " << GetLastErrorAsString();
+ FML_LOG(ERROR) << "Cannot register window class "
+ << WCharBufferToString(kWindowClassName) << ": "
+ << GetLastErrorAsString();
return nullptr;
}
}
diff --git a/engine/src/flutter/shell/platform/windows/wchar_util.cc b/engine/src/flutter/shell/platform/windows/wchar_util.cc
new file mode 100644
index 0000000..d6c85b1
--- /dev/null
+++ b/engine/src/flutter/shell/platform/windows/wchar_util.cc
@@ -0,0 +1,42 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "flutter/shell/platform/windows/wchar_util.h"
+
+#include <dwmapi.h>
+
+namespace flutter {
+
+std::string WCharBufferToString(const wchar_t* wstr) {
+ if (!wstr) {
+ return "";
+ }
+
+ int buffer_size = WideCharToMultiByte(CP_UTF8, //
+ 0, //
+ wstr, //
+ -1, //
+ nullptr, //
+ 0, //
+ nullptr, //
+ nullptr //
+ );
+ if (buffer_size <= 0) {
+ return "";
+ }
+
+ std::string result(buffer_size - 1, 0);
+ WideCharToMultiByte(CP_UTF8, //
+ 0, //
+ wstr, //
+ -1, //
+ result.data(), //
+ buffer_size, //
+ nullptr, //
+ nullptr //
+ );
+ return result;
+}
+
+} // namespace flutter
diff --git a/engine/src/flutter/shell/platform/windows/wchar_util.h b/engine/src/flutter/shell/platform/windows/wchar_util.h
new file mode 100644
index 0000000..ed527f4
--- /dev/null
+++ b/engine/src/flutter/shell/platform/windows/wchar_util.h
@@ -0,0 +1,29 @@
+// Copyright 2013 The Flutter Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_WCHAR_UTIL_H_
+#define FLUTTER_SHELL_PLATFORM_WINDOWS_WCHAR_UTIL_H_
+
+#include <string>
+
+namespace flutter {
+
+//------------------------------------------------------------------------------
+/// @brief Convert a null terminated wchar_t buffer to a std::string using
+/// Windows utilities.
+///
+/// The reliance on wchar_t buffers is problematic on C++20 since
+/// their interop with standard library components has been
+/// deprecated/removed.
+///
+/// @param[in] wstr The null terminated buffer.
+///
+/// @return The converted string if conversion is possible. Empty string
+/// otherwise.
+///
+std::string WCharBufferToString(const wchar_t* wstr);
+
+} // namespace flutter
+
+#endif // FLUTTER_SHELL_PLATFORM_WINDOWS_WCHAR_UTIL_H_
diff --git a/engine/src/flutter/sky/packages/sky_engine/LICENSE b/engine/src/flutter/sky/packages/sky_engine/LICENSE
index 0b43ac3..a7bd977 100644
--- a/engine/src/flutter/sky/packages/sky_engine/LICENSE
+++ b/engine/src/flutter/sky/packages/sky_engine/LICENSE
@@ -34764,6 +34764,22 @@
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
--------------------------------------------------------------------------------
+flatbuffers
+
+Copyright 2023 Google Inc. All rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+--------------------------------------------------------------------------------
cpu_features
Copyright 2023 Google LLC
@@ -34972,6 +34988,22 @@
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
--------------------------------------------------------------------------------
+flatbuffers
+
+Copyright 2024 Google Inc. All rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+--------------------------------------------------------------------------------
skia
Copyright 2024 Google LLC
diff --git a/engine/src/flutter/third_party/accessibility/ax/ax_node_position_unittest.cc b/engine/src/flutter/third_party/accessibility/ax/ax_node_position_unittest.cc
index 0d028c2..f3efb84 100644
--- a/engine/src/flutter/third_party/accessibility/ax/ax_node_position_unittest.cc
+++ b/engine/src/flutter/third_party/accessibility/ax/ax_node_position_unittest.cc
@@ -113,6 +113,16 @@
struct ExpandToEnclosingTextBoundaryTestParam {
ExpandToEnclosingTextBoundaryTestParam() = default;
+ ExpandToEnclosingTextBoundaryTestParam(
+ ax::mojom::TextBoundary p_boundary,
+ AXRangeExpandBehavior p_expand_behavior,
+ std::string p_expected_anchor_position,
+ std::string p_expected_focus_position)
+ : boundary(p_boundary),
+ expand_behavior(p_expand_behavior),
+ expected_anchor_position(std::move(p_expected_anchor_position)),
+ expected_focus_position(std::move(p_expected_focus_position)) {}
+
// Required by GTest framework.
ExpandToEnclosingTextBoundaryTestParam(
const ExpandToEnclosingTextBoundaryTestParam& other) = default;
@@ -157,6 +167,15 @@
struct CreatePositionAtTextBoundaryTestParam {
CreatePositionAtTextBoundaryTestParam() = default;
+ CreatePositionAtTextBoundaryTestParam(ax::mojom::TextBoundary p_boundary,
+ ax::mojom::MoveDirection p_direction,
+ AXBoundaryBehavior p_boundary_behavior,
+ std::string p_expected_text_position)
+ : boundary(p_boundary),
+ direction(p_direction),
+ boundary_behavior(p_boundary_behavior),
+ expected_text_position(std::move(p_expected_text_position)) {}
+
// Required by GTest framework.
CreatePositionAtTextBoundaryTestParam(
const CreatePositionAtTextBoundaryTestParam& other) = default;
@@ -203,6 +222,16 @@
struct TextNavigationTestParam {
TextNavigationTestParam() = default;
+ TextNavigationTestParam(
+ std::function<TestPositionType(const TestPositionType&)> p_TestMethod,
+ AXNode::AXID p_start_node_id,
+ int p_start_offset,
+ std::vector<std::string> p_expectations)
+ : TestMethod(std::move(p_TestMethod)),
+ start_node_id(p_start_node_id),
+ start_offset(p_start_offset),
+ expectations(std::move(p_expectations)) {}
+
// Required by GTest framework.
TextNavigationTestParam(const TextNavigationTestParam& other) = default;
TextNavigationTestParam& operator=(const TextNavigationTestParam& other) =
diff --git a/engine/src/flutter/tools/templater/templater_main.cc b/engine/src/flutter/tools/templater/templater_main.cc
index 4cd0f23..c803d72 100644
--- a/engine/src/flutter/tools/templater/templater_main.cc
+++ b/engine/src/flutter/tools/templater/templater_main.cc
@@ -51,7 +51,7 @@
rendered_template.size()};
auto current_dir =
- fml::OpenDirectory(std::filesystem::current_path().u8string().c_str(),
+ fml::OpenDirectory(std::filesystem::current_path().string().c_str(),
false, fml::FilePermission::kReadWrite);
if (!current_dir.is_valid()) {
FML_LOG(ERROR) << "Could not open current directory.";
diff --git a/engine/src/flutter/txt/tests/paragraph_unittests.cc b/engine/src/flutter/txt/tests/paragraph_unittests.cc
index aff36e4..d3d64ee 100644
--- a/engine/src/flutter/txt/tests/paragraph_unittests.cc
+++ b/engine/src/flutter/txt/tests/paragraph_unittests.cc
@@ -19,6 +19,7 @@
namespace flutter {
namespace testing {
+[[maybe_unused]]
static const std::string kEmojiFontFile =
#if FML_OS_MACOSX
"Apple Color Emoji.ttc";
@@ -26,6 +27,7 @@
"NotoColorEmoji.ttf";
#endif
+[[maybe_unused]]
static const std::string kEmojiFontName =
#if FML_OS_MACOSX
"Apple Color Emoji";