blob: 5a8a5d19c54dd5e140594aa0ef6dbd2eb167747d [file] [log] [blame]
# 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.
assert(is_win)
import("//flutter/shell/platform/glfw/config.gni")
import("//flutter/testing/testing.gni")
_public_headers = [ "public/flutter_windows.h" ]
config("relative_angle_headers") {
include_dirs = [ "//third_party/angle/include" ]
}
# Any files that are built by clients (client_wrapper code, library headers for
# implementations using this shared code, etc.) include the public headers
# assuming they are in the include path. This configuration should be added to
# any such code that is also built by GN to make the includes work.
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") {
public = _public_headers
public_deps = [ "//flutter/shell/platform/common:common_cpp_library_headers" ]
configs +=
[ "//flutter/shell/platform/common:desktop_library_implementation" ]
public_configs =
[ "//flutter/shell/platform/common:relative_flutter_library_headers" ]
}
source_set("flutter_windows_source") {
# Common Windows sources.
sources = [
"angle_surface_manager.cc",
"angle_surface_manager.h",
"cursor_handler.cc",
"cursor_handler.h",
"external_texture_gl.cc",
"external_texture_gl.h",
"flutter_key_map.cc",
"flutter_project_bundle.cc",
"flutter_project_bundle.h",
"flutter_windows.cc",
"flutter_windows_engine.cc",
"flutter_windows_engine.h",
"flutter_windows_texture_registrar.cc",
"flutter_windows_texture_registrar.h",
"flutter_windows_view.cc",
"flutter_windows_view.h",
"keyboard_handler_base.h",
"keyboard_key_channel_handler.cc",
"keyboard_key_channel_handler.h",
"keyboard_key_embedder_handler.cc",
"keyboard_key_embedder_handler.h",
"keyboard_key_handler.cc",
"keyboard_key_handler.h",
"platform_handler.cc",
"platform_handler.h",
"system_utils.h",
"task_runner.h",
"text_input_plugin.cc",
"text_input_plugin.h",
"window_binding_handler.h",
"window_binding_handler_delegate.h",
"window_state.h",
]
# Target-specific sources.
if (target_os == "winuwp") {
sources += [
"display_helper_winuwp.cc",
"display_helper_winuwp.h",
"flutter_window_winuwp.cc",
"flutter_window_winuwp.h",
"flutter_windows_winuwp.cc",
"game_pad_cursor_winuwp.cc",
"game_pad_cursor_winuwp.h",
"game_pad_winuwp.cc",
"game_pad_winuwp.h",
"platform_handler_winuwp.cc",
"platform_handler_winuwp.h",
"system_utils_winuwp.cc",
"task_runner_winuwp.cc",
"task_runner_winuwp.h",
]
} else {
sources += [
"dpi_utils_win32.cc",
"dpi_utils_win32.h",
"flutter_window_win32.cc",
"flutter_window_win32.h",
"flutter_windows_win32.cc",
"platform_handler_win32.cc",
"platform_handler_win32.h",
"system_utils_win32.cc",
"task_runner_win32.cc",
"task_runner_win32.h",
"task_runner_win32_window.cc",
"task_runner_win32_window.h",
"text_input_manager_win32.cc",
"text_input_manager_win32.h",
"window_proc_delegate_manager_win32.cc",
"window_proc_delegate_manager_win32.h",
"window_win32.cc",
"window_win32.h",
]
libs = [
"dwmapi.lib",
"imm32.lib",
]
}
if (target_os == "winuwp") {
configs += [ ":cppwinrt_defs" ]
cflags = [ "/EHsc" ]
}
configs += [
"//flutter/shell/platform/common:desktop_library_implementation",
"//third_party/angle:gl_prototypes",
]
public_configs = [ ":relative_angle_headers" ]
if (target_os == "winuwp") {
defines = [
"_SILENCE_CLANG_COROUTINE_MESSAGE",
"FLUTTER_ENGINE_NO_PROTOTYPES",
]
} else {
defines = [ "FLUTTER_ENGINE_NO_PROTOTYPES" ]
}
public_deps = [ ":string_conversion" ]
deps = [
":flutter_windows_headers",
"//flutter/shell/platform/common:common_cpp",
"//flutter/shell/platform/common:common_cpp_input",
"//flutter/shell/platform/common:common_cpp_switches",
"//flutter/shell/platform/common/client_wrapper:client_wrapper",
"//flutter/shell/platform/embedder:embedder_as_internal_library",
"//flutter/shell/platform/windows/client_wrapper:client_wrapper_windows",
"//flutter/third_party/accessibility",
"//third_party/angle:libEGL_static", # the order of libEGL_static and
# libGLESv2_static is important.. if
# reversed, will cause a linker error
# DllMain already defined in
# LIBCMTD.lib
"//third_party/angle:libGLESv2_static",
"//third_party/rapidjson",
]
}
# String encoding conversion utilities.
source_set("string_conversion") {
sources = [
"string_conversion.cc",
"string_conversion.h",
]
if (target_os == "winuwp") {
cflags = [ "/EHsc" ]
}
}
copy("publish_headers_windows") {
sources = _public_headers
outputs = [ "$root_out_dir/{{source_file_part}}" ]
# The Windows header assumes the presence of the common headers.
deps = [ "//flutter/shell/platform/common:publish_headers" ]
}
shared_library("flutter_windows") {
deps = [ ":flutter_windows_source" ]
public_configs = [ "//flutter:config" ]
}
shared_library("flutter_windows_winuwp") {
deps = [ ":flutter_windows_source" ]
libs = [ "windowsapp.lib" ]
public_configs = [ "//flutter:config" ]
}
test_fixtures("flutter_windows_fixtures") {
fixtures = []
}
executable("flutter_windows_unittests") {
testonly = true
if (target_os == "winuwp") {
libs = [
"windowsapp.lib",
"user32.lib",
]
}
# Common Windows test sources.
sources = [
# "flutter_project_bundle_unittests.cc", //TODO failing due to switches test failing. Blocked on https://github.com/flutter/flutter/issues/74153
# "flutter_windows_engine_unittests.cc", //TODO failing to send / receive platform message get plugins working first. Blocked on https://github.com/flutter/flutter/issues/74155
"string_conversion_unittests.cc",
"system_utils_unittests.cc",
"testing/engine_modifier.h",
]
# Target-specific sources.
if (target_os == "winuwp") {
sources += [ "uwptool_utils_unittests.cc" ]
# TODO(clarkezone) add UWP tests
# https://github.com/flutter/flutter/issues/70197
} else {
sources += [
# TODO move first two tests to common once above TODO's unblocked.
"dpi_utils_win32_unittests.cc",
"flutter_project_bundle_unittests.cc",
"flutter_window_win32_unittests.cc",
"flutter_windows_engine_unittests.cc",
"flutter_windows_texture_registrar_unittests.cc",
"keyboard_key_channel_handler_unittests.cc",
"keyboard_key_embedder_handler_unittests.cc",
"keyboard_key_handler_unittests.cc",
"testing/flutter_window_win32_test.cc",
"testing/flutter_window_win32_test.h",
"testing/mock_window_binding_handler.cc",
"testing/mock_window_binding_handler.h",
"testing/mock_window_win32.cc",
"testing/mock_window_win32.h",
"text_input_plugin_unittest.cc",
"window_proc_delegate_manager_win32_unittests.cc",
"window_win32_unittests.cc",
]
}
public_configs = [ "//flutter:config" ]
deps = [
":flutter_windows_fixtures",
":flutter_windows_headers",
":flutter_windows_source",
"//flutter/shell/platform/common:common_cpp",
"//flutter/shell/platform/embedder:embedder_as_internal_library",
"//flutter/shell/platform/embedder:embedder_test_utils",
"//flutter/testing",
"//third_party/rapidjson",
]
if (target_os == "winuwp") {
deps += [ ":uwptool_utils" ]
}
}
shared_library("flutter_windows_glfw") {
deps = [ "//flutter/shell/platform/glfw:flutter_glfw" ]
public_configs = [ "//flutter:config" ]
}
group("windows_glfw") {
deps = [
":flutter_windows",
":flutter_windows_glfw",
"//flutter/shell/platform/glfw:publish_headers_glfw",
"//flutter/shell/platform/glfw/client_wrapper:publish_wrapper_glfw",
]
}
group("windows") {
if (target_os == "winuwp") {
deps = [
":flutter_windows_winuwp",
":publish_headers_windows",
":uwptool",
"//flutter/shell/platform/windows/client_wrapper:publish_wrapper_windows",
]
} else {
deps = [
":flutter_windows",
":publish_headers_windows",
"//flutter/shell/platform/windows/client_wrapper:publish_wrapper_windows",
]
}
if (build_glfw_shell) {
deps += [ ":windows_glfw" ]
}
}
# uwptool utilities.
source_set("uwptool_utils") {
if (target_os == "winuwp") {
configs += [ ":cppwinrt_defs" ]
cflags = [ "/EHsc" ]
}
sources = [
"uwptool_commands.cc",
"uwptool_commands.h",
"uwptool_utils.cc",
"uwptool_utils.h",
]
deps = [ ":string_conversion" ]
}
# Command-line tool used by the flutter tool that serves a similar purpose to
# adb for Android or libimobiledevice for iOS apps. Supports installing,
# uninstalling, launching apps.
executable("uwptool") {
if (target_os == "winuwp") {
configs += [ ":cppwinrt_defs" ]
cflags = [ "/EHsc" ]
libs = [
"windowsapp.lib",
"user32.lib",
]
}
sources = [ "uwptool_main.cc" ]
deps = [
":string_conversion",
":uwptool_utils",
"//flutter/fml:command_line",
]
}