From d86ab60601253f3346517724a3b0e339f3eb1b7c Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Thu, 3 Aug 2023 13:21:35 -0700 Subject: [PATCH] [darwin] Move common targets to common/BUILD.gn (flutter/engine#44335) Previously, some common Darwin framework targets existed in: //flutter/shell/platform/darwin/BUILD.gn This moves all targets into: //flutter/shell/platform/darwin/common/BUILD.gn The framework_shared target has been renamed framework_common for consistency with the directory name, and flutter_channels_unittests has been renamed framework_common_unittests since it's a reasonable target for adding other tests of common framework code. We also de-duplicate targets with existing targets. * The `flutter_channels` target duplicates the existing `framework_shared` target. * The `common` target already includes the buffer conversions translation units, which are only used by the iOS embedder. No test changes since there are no semantic changes, just a restructuring of build targets. ## Pre-launch Checklist - [X] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [X] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [X] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [X] I listed at least one issue that this PR fixes in the description above. - [ ] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests. - [X] I updated/added relevant documentation (doc comments with `///`). - [X] I signed the [CLA]. - [X] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat --- engine/src/flutter/BUILD.gn | 2 +- .../flutter/shell/platform/darwin/BUILD.gn | 68 ------------------- .../shell/platform/darwin/common/BUILD.gn | 32 ++++++++- ...mework_shared.gni => framework_common.gni} | 2 +- .../shell/platform/darwin/graphics/BUILD.gn | 2 +- .../shell/platform/darwin/ios/BUILD.gn | 12 ++-- .../shell/platform/darwin/macos/BUILD.gn | 8 +-- engine/src/flutter/testing/run_tests.py | 2 +- 8 files changed, 43 insertions(+), 85 deletions(-) rename engine/src/flutter/shell/platform/darwin/common/{framework_shared.gni => framework_common.gni} (95%) diff --git a/engine/src/flutter/BUILD.gn b/engine/src/flutter/BUILD.gn index 46a1e76c8f..8bb4183c6f 100644 --- a/engine/src/flutter/BUILD.gn +++ b/engine/src/flutter/BUILD.gn @@ -187,7 +187,7 @@ group("unittests") { if (is_mac) { public_deps += [ "//flutter/impeller/golden_tests:impeller_golden_tests", - "//flutter/shell/platform/darwin:flutter_channels_unittests", + "//flutter/shell/platform/darwin/common:framework_common_unittests", "//flutter/third_party/spring_animation:spring_animation_unittests", ] } diff --git a/engine/src/flutter/shell/platform/darwin/BUILD.gn b/engine/src/flutter/shell/platform/darwin/BUILD.gn index 7ff997fa4f..c1db2da134 100644 --- a/engine/src/flutter/shell/platform/darwin/BUILD.gn +++ b/engine/src/flutter/shell/platform/darwin/BUILD.gn @@ -5,7 +5,6 @@ assert(is_mac || is_ios) import("//flutter/shell/platform/config.gni") -import("//flutter/testing/testing.gni") group("darwin") { if (is_ios) { @@ -18,70 +17,3 @@ group("darwin") { } } } - -source_set("flutter_channels") { - cflags_objc = flutter_cflags_objc - cflags_objcc = flutter_cflags_objcc - - sources = [ - "common/buffer_conversions.h", - "common/buffer_conversions.mm", - ] - - deps = [ "//flutter/fml" ] - - public_deps = [ ":flutter_channels_arc" ] - - public_configs = [ "//flutter:config" ] -} - -source_set("flutter_channels_arc") { - cflags_objc = flutter_cflags_objc_arc - cflags_objcc = flutter_cflags_objcc_arc - - sources = [ - "common/framework/Headers/FlutterBinaryMessenger.h", - "common/framework/Headers/FlutterChannels.h", - "common/framework/Headers/FlutterCodecs.h", - "common/framework/Headers/FlutterMacros.h", - "common/framework/Source/FlutterChannels.mm", - "common/framework/Source/FlutterCodecs.mm", - "common/framework/Source/FlutterStandardCodec.mm", - "common/framework/Source/FlutterStandardCodecHelper.cc", - "common/framework/Source/FlutterStandardCodec_Internal.h", - ] - - public = [ - "common/framework/Headers/FlutterBinaryMessenger.h", - "common/framework/Headers/FlutterChannels.h", - "common/framework/Headers/FlutterCodecs.h", - "common/framework/Headers/FlutterMacros.h", - "common/framework/Source/FlutterStandardCodec_Internal.h", - ] - - public_configs = [ "//flutter:config" ] - - deps = [ "//flutter/fml" ] -} - -test_fixtures("flutter_channels_fixtures") { - fixtures = [] -} - -executable("flutter_channels_unittests") { - testonly = true - - sources = [ - "common/framework/Source/flutter_codecs_unittest.mm", - "common/framework/Source/flutter_standard_codec_unittest.mm", - ] - - deps = [ - ":flutter_channels", - ":flutter_channels_fixtures", - "//flutter/testing", - "//third_party/dart/runtime:libdart_jit", - ] - - public_configs = [ "//flutter:config" ] -} diff --git a/engine/src/flutter/shell/platform/darwin/common/BUILD.gn b/engine/src/flutter/shell/platform/darwin/common/BUILD.gn index d7c0a0cf17..e359d1c332 100644 --- a/engine/src/flutter/shell/platform/darwin/common/BUILD.gn +++ b/engine/src/flutter/shell/platform/darwin/common/BUILD.gn @@ -2,8 +2,11 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +assert(is_mac || is_ios) + import("//flutter/common/config.gni") -import("framework_shared.gni") +import("//flutter/testing/testing.gni") +import("framework_common.gni") source_set("common") { cflags_objc = flutter_cflags_objc @@ -29,7 +32,7 @@ config("framework_relative_headers") { } # Framework code shared between iOS and macOS. -source_set("framework_shared") { +source_set("framework_common") { cflags_objc = flutter_cflags_objc_arc cflags_objcc = flutter_cflags_objcc_arc @@ -43,7 +46,7 @@ source_set("framework_shared") { "framework/Source/FlutterStandardCodec_Internal.h", ] - public = framework_shared_headers + public = framework_common_headers public += [ "framework/Source/FlutterNSBundleUtils.h" ] @@ -56,3 +59,26 @@ source_set("framework_shared") { deps = [ "//flutter/fml" ] } + +test_fixtures("framework_common_fixtures") { + fixtures = [] +} + +# Unit tests for channels. +executable("framework_common_unittests") { + testonly = true + + sources = [ + "framework/Source/flutter_codecs_unittest.mm", + "framework/Source/flutter_standard_codec_unittest.mm", + ] + + deps = [ + ":framework_common", + ":framework_common_fixtures", + "//flutter/testing", + "//third_party/dart/runtime:libdart_jit", + ] + + public_configs = [ "//flutter:config" ] +} diff --git a/engine/src/flutter/shell/platform/darwin/common/framework_shared.gni b/engine/src/flutter/shell/platform/darwin/common/framework_common.gni similarity index 95% rename from engine/src/flutter/shell/platform/darwin/common/framework_shared.gni rename to engine/src/flutter/shell/platform/darwin/common/framework_common.gni index 84f50a7da5..02bb8b7dfb 100644 --- a/engine/src/flutter/shell/platform/darwin/common/framework_shared.gni +++ b/engine/src/flutter/shell/platform/darwin/common/framework_common.gni @@ -2,7 +2,7 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -framework_shared_headers = +framework_common_headers = get_path_info([ "framework/Headers/FlutterMacros.h", "framework/Headers/FlutterBinaryMessenger.h", diff --git a/engine/src/flutter/shell/platform/darwin/graphics/BUILD.gn b/engine/src/flutter/shell/platform/darwin/graphics/BUILD.gn index fbb5a7a5b1..acb55214b3 100644 --- a/engine/src/flutter/shell/platform/darwin/graphics/BUILD.gn +++ b/engine/src/flutter/shell/platform/darwin/graphics/BUILD.gn @@ -23,7 +23,7 @@ source_set("graphics") { "//flutter/display_list", "//flutter/fml", "//flutter/shell/common", - "//flutter/shell/platform/darwin/common:framework_shared", + "//flutter/shell/platform/darwin/common:framework_common", ] if (impeller_supports_rendering) { diff --git a/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn b/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn index 6a62586420..dbff86b9bf 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn +++ b/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn @@ -9,7 +9,7 @@ import("//build/toolchain/clang.gni") import("//flutter/common/config.gni") import("//flutter/shell/config.gni") import("//flutter/shell/gpu/gpu.gni") -import("//flutter/shell/platform/darwin/common/framework_shared.gni") +import("//flutter/shell/platform/darwin/common/framework_common.gni") import("//flutter/testing/testing.gni") _flutter_framework_dir = "$root_out_dir/Flutter.framework" @@ -52,7 +52,7 @@ source_set("flutter_framework_source_arc") { ":flutter_framework_source", "//flutter/fml", "//flutter/shell/platform/common:common_cpp_input", - "//flutter/shell/platform/darwin/common:framework_shared", + "//flutter/shell/platform/darwin/common:framework_common", "//third_party/icu", ] public_configs = [ "//flutter:config" ] @@ -191,7 +191,7 @@ source_set("flutter_framework_source") { "//flutter/shell/common", "//flutter/shell/platform/common:common_cpp_input", "//flutter/shell/platform/darwin/common", - "//flutter/shell/platform/darwin/common:framework_shared", + "//flutter/shell/platform/darwin/common:framework_common", "//flutter/shell/platform/embedder:embedder_as_internal_library", "//flutter/shell/profiling:profiling", "//flutter/third_party/spring_animation", @@ -245,7 +245,7 @@ source_set("ios_test_flutter_mrc") { "//flutter/common:common", "//flutter/lib/ui:ui", "//flutter/shell/common:common", - "//flutter/shell/platform/darwin/common:framework_shared", + "//flutter/shell/platform/darwin/common:framework_common", "//flutter/shell/platform/embedder:embedder_as_internal_library", "//flutter/third_party/tonic", "//flutter/third_party/txt", @@ -311,7 +311,7 @@ shared_library("ios_test_flutter") { ":ios_test_flutter_mrc", "//flutter/common:common", "//flutter/lib/ui:ui", - "//flutter/shell/platform/darwin/common:framework_shared", + "//flutter/shell/platform/darwin/common:framework_common", "//flutter/shell/platform/embedder:embedder_as_internal_library", "//flutter/shell/platform/embedder:embedder_test_utils", "//flutter/third_party/spring_animation", @@ -400,7 +400,7 @@ action("copy_framework_headers") { script = "//flutter/sky/tools/install_framework_headers.py" visibility = [ ":*" ] sources = get_path_info(_flutter_framework_headers, "abspath") + - framework_shared_headers + framework_common_headers outputs = [] foreach(header, sources) { header_basename = get_path_info(header, "file") diff --git a/engine/src/flutter/shell/platform/darwin/macos/BUILD.gn b/engine/src/flutter/shell/platform/darwin/macos/BUILD.gn index 86f681b21f..ff20981740 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/BUILD.gn +++ b/engine/src/flutter/shell/platform/darwin/macos/BUILD.gn @@ -7,7 +7,7 @@ assert(is_mac) import("//build/config/mac/mac_sdk.gni") import("//flutter/build/zip_bundle.gni") import("//flutter/shell/gpu/gpu.gni") -import("//flutter/shell/platform/darwin/common/framework_shared.gni") +import("//flutter/shell/platform/darwin/common/framework_common.gni") import("//flutter/shell/platform/glfw/config.gni") import("//flutter/testing/testing.gni") @@ -121,7 +121,7 @@ source_set("flutter_framework_source") { "//flutter/shell/platform/common:common_cpp_enums", "//flutter/shell/platform/common:common_cpp_input", "//flutter/shell/platform/common:common_cpp_switches", - "//flutter/shell/platform/darwin/common:framework_shared", + "//flutter/shell/platform/darwin/common:framework_common", "//flutter/shell/platform/darwin/graphics:graphics", "//flutter/shell/platform/embedder:embedder_as_internal_library", "//third_party/skia", @@ -204,7 +204,7 @@ executable("flutter_desktop_darwin_unittests") { ":flutter_framework_source", "//flutter/shell/platform/common:common_cpp_accessibility", "//flutter/shell/platform/common:common_cpp_enums", - "//flutter/shell/platform/darwin/common:framework_shared", + "//flutter/shell/platform/darwin/common:framework_common", "//flutter/shell/platform/darwin/graphics", "//flutter/shell/platform/embedder:embedder_as_internal_library", "//flutter/shell/platform/embedder:embedder_test_utils", @@ -241,7 +241,7 @@ action("copy_framework_headers") { script = "//flutter/sky/tools/install_framework_headers.py" visibility = [ ":*" ] sources = get_path_info(_flutter_framework_headers, "abspath") + - framework_shared_headers + framework_common_headers outputs = [] foreach(header, sources) { header_basename = get_path_info(header, "file") diff --git a/engine/src/flutter/testing/run_tests.py b/engine/src/flutter/testing/run_tests.py index a73182a9cd..7f67c3aacb 100755 --- a/engine/src/flutter/testing/run_tests.py +++ b/engine/src/flutter/testing/run_tests.py @@ -418,7 +418,7 @@ def run_cc_tests(build_dir, executable_filter, coverage, capture_core_dump): unittests += [ # The accessibility library only supports Mac and Windows. make_test('accessibility_unittests'), - make_test('flutter_channels_unittests'), + make_test('framework_common_unittests'), make_test('spring_animation_unittests'), ]