Skip to content

Commit

Permalink
Reorganize darwin for shared ios/macOS (#9255)
Browse files Browse the repository at this point in the history
When the macOS framework was initially landed, it included some iOS code
using a localized hack. This reorganizes the code structure to clearly
indicate which files are shared between iOS and macOS, vs. those that
are platform-specific.
  • Loading branch information
stuartmorgan authored Jun 17, 2019
1 parent 9da409c commit e00ac47
Show file tree
Hide file tree
Showing 32 changed files with 88 additions and 116 deletions.
20 changes: 10 additions & 10 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -656,17 +656,23 @@ FILE: ../../../flutter/shell/platform/darwin/common/buffer_conversions.h
FILE: ../../../flutter/shell/platform/darwin/common/buffer_conversions.mm
FILE: ../../../flutter/shell/platform/darwin/common/command_line.h
FILE: ../../../flutter/shell/platform/darwin/common/command_line.mm
FILE: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h
FILE: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h
FILE: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h
FILE: ../../../flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterChannels.mm
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterCodecs.mm
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodec.mm
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/FlutterStandardCodec_Internal.h
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/flutter_codecs_unittest.mm
FILE: ../../../flutter/shell/platform/darwin/common/framework/Source/flutter_standard_codec_unittest.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Flutter.podspec
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/Flutter.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterAppDelegate.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterBinaryMessenger.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterCallbackCache.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterChannels.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterCodecs.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterDartProject.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterHeadlessDartRunner.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterMacros.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlatformViews.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h
Expand All @@ -677,8 +683,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDele
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate_Internal.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache_Internal.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterChannels.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterCodecs.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
Expand All @@ -695,8 +699,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatfor
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate_internal.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterStandardCodec.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterStandardCodec_Internal.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm
Expand All @@ -709,8 +711,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_text_entry.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/flutter_codecs_unittest.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/flutter_standard_codec_unittest.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/platform_message_router.h
Expand Down
37 changes: 10 additions & 27 deletions shell/platform/darwin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
assert(is_mac || is_ios)

import("$flutter_root/testing/testing.gni")
import("framework_shared.gni")

group("darwin") {
if (is_ios) {
Expand All @@ -24,14 +23,14 @@ source_set("flutter_channels") {
sources = [
"common/buffer_conversions.h",
"common/buffer_conversions.mm",
"ios/framework/Headers/FlutterBinaryMessenger.h",
"ios/framework/Headers/FlutterChannels.h",
"ios/framework/Headers/FlutterCodecs.h",
"ios/framework/Headers/FlutterMacros.h",
"ios/framework/Source/FlutterChannels.mm",
"ios/framework/Source/FlutterCodecs.mm",
"ios/framework/Source/FlutterStandardCodec.mm",
"ios/framework/Source/FlutterStandardCodec_Internal.h",
"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/FlutterStandardCodec_Internal.h",
]

deps = [
Expand All @@ -46,22 +45,6 @@ source_set("flutter_channels") {
public_configs = [ "$flutter_root:config" ]
}

# Framework code shared between iOS and macOS.
source_set("framework_shared") {
sources = [
"ios/framework/Source/FlutterChannels.mm",
"ios/framework/Source/FlutterCodecs.mm",
"ios/framework/Source/FlutterStandardCodec.mm",
"ios/framework/Source/FlutterStandardCodec_Internal.h",
]

public = framework_shared_headers

defines = [ "FLUTTER_FRAMEWORK" ]

public_configs = [ "$flutter_root:config" ]
}

test_fixtures("flutter_channels_fixtures") {
fixtures = []
}
Expand All @@ -70,8 +53,8 @@ executable("flutter_channels_unittests") {
testonly = true

sources = [
"ios/framework/Source/flutter_codecs_unittest.mm",
"ios/framework/Source/flutter_standard_codec_unittest.mm",
"common/framework/Source/flutter_codecs_unittest.mm",
"common/framework/Source/flutter_standard_codec_unittest.mm",
]

deps = [
Expand Down
28 changes: 28 additions & 0 deletions shell/platform/darwin/common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("framework_shared.gni")

source_set("common") {
sources = [
"buffer_conversions.h",
Expand All @@ -22,3 +24,29 @@ source_set("common") {

public_configs = [ "$flutter_root:config" ]
}

# Shared framework headers end up in the same folder as platform-specific
# framework headers when consumed by clients, so the include paths assume they
# are next to each other.
config("framework_relative_headers") {
include_dirs = [ "framework/Headers" ]
}

# Framework code shared between iOS and macOS.
source_set("framework_shared") {
sources = [
"framework/Source/FlutterChannels.mm",
"framework/Source/FlutterCodecs.mm",
"framework/Source/FlutterStandardCodec.mm",
"framework/Source/FlutterStandardCodec_Internal.h",
]

public = framework_shared_headers

defines = [ "FLUTTER_FRAMEWORK" ]

public_configs = [
"$flutter_root:config",
":framework_relative_headers",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterChannels.h"
#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"

#pragma mark - Basic message channel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterCodecs.h"
#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h"

@implementation FlutterBinaryCodec
+ (instancetype)sharedInstance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERSTANDARDCODECINTERNAL_H_
#define SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERSTANDARDCODECINTERNAL_H_
#ifndef SHELL_PLATFORM_DARWIN_COMMON_FRAMEWORK_SOURCE_FLUTTERSTANDARDCODECINTERNAL_H_
#define SHELL_PLATFORM_DARWIN_COMMON_FRAMEWORK_SOURCE_FLUTTERSTANDARDCODECINTERNAL_H_

#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterCodecs.h"
#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h"

typedef NS_ENUM(NSInteger, FlutterStandardField) {
FlutterStandardFieldNil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterCodecs.h"
#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h"
#include "gtest/gtest.h"

TEST(FlutterStringCodec, CanEncodeAndDecodeNil) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterCodecs.h"
#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterCodecs.h"
#include "gtest/gtest.h"

void checkEncodeDecode(id value, NSData* expectedEncoding) {
Expand Down
12 changes: 12 additions & 0 deletions shell/platform/darwin/common/framework_shared.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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.

framework_shared_headers =
get_path_info([
"framework/Headers/FlutterMacros.h",
"framework/Headers/FlutterBinaryMessenger.h",
"framework/Headers/FlutterChannels.h",
"framework/Headers/FlutterCodecs.h",
],
"abspath")
15 changes: 0 additions & 15 deletions shell/platform/darwin/framework_shared.gni

This file was deleted.

19 changes: 7 additions & 12 deletions shell/platform/darwin/ios/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ assert(is_ios)
import("//build/config/ios/ios_sdk.gni")
import("$flutter_root/common/config.gni")
import("$flutter_root/shell/gpu/gpu.gni")
import("$flutter_root/shell/platform/darwin/common/framework_shared.gni")

_flutter_framework_dir = "$root_out_dir/Flutter.framework"

Expand All @@ -22,14 +23,10 @@ shell_gpu_configuration("ios_gpu_configuration") {
_flutter_framework_headers = [
"framework/Headers/Flutter.h",
"framework/Headers/FlutterAppDelegate.h",
"framework/Headers/FlutterBinaryMessenger.h",
"framework/Headers/FlutterCallbackCache.h",
"framework/Headers/FlutterChannels.h",
"framework/Headers/FlutterCodecs.h",
"framework/Headers/FlutterDartProject.h",
"framework/Headers/FlutterEngine.h",
"framework/Headers/FlutterHeadlessDartRunner.h",
"framework/Headers/FlutterMacros.h",
"framework/Headers/FlutterPlatformViews.h",
"framework/Headers/FlutterPlugin.h",
"framework/Headers/FlutterPluginAppLifeCycleDelegate.h",
Expand All @@ -49,8 +46,6 @@ shared_library("create_flutter_framework_dylib") {
"framework/Source/FlutterAppDelegate_Internal.h",
"framework/Source/FlutterCallbackCache.mm",
"framework/Source/FlutterCallbackCache_Internal.h",
"framework/Source/FlutterChannels.mm",
"framework/Source/FlutterCodecs.mm",
"framework/Source/FlutterDartProject.mm",
"framework/Source/FlutterDartProject_Internal.h",
"framework/Source/FlutterEngine.mm",
Expand All @@ -66,8 +61,6 @@ shared_library("create_flutter_framework_dylib") {
"framework/Source/FlutterPlatformViews_Internal.h",
"framework/Source/FlutterPlatformViews_Internal.mm",
"framework/Source/FlutterPluginAppLifeCycleDelegate.mm",
"framework/Source/FlutterStandardCodec.mm",
"framework/Source/FlutterStandardCodec_Internal.h",
"framework/Source/FlutterTextInputDelegate.h",
"framework/Source/FlutterTextInputPlugin.h",
"framework/Source/FlutterTextInputPlugin.mm",
Expand Down Expand Up @@ -120,6 +113,7 @@ shared_library("create_flutter_framework_dylib") {
"$flutter_root/runtime:libdart",
"$flutter_root/shell/common",
"$flutter_root/shell/platform/darwin/common",
"$flutter_root/shell/platform/darwin/common:framework_shared",
"//third_party/skia",
]

Expand Down Expand Up @@ -205,17 +199,18 @@ copy("copy_framework_module_map") {
action("copy_framework_headers") {
script = "$flutter_root/sky/tools/install_framework_headers.py"
visibility = [ ":*" ]
sources = _flutter_framework_headers
sources = get_path_info(_flutter_framework_headers, "abspath") +
framework_shared_headers
outputs = []
foreach(header, _flutter_framework_headers) {
header_basename = rebase_path(header, "framework/headers")
foreach(header, sources) {
header_basename = get_path_info(header, "file")
outputs += [ "$_flutter_framework_headers_copy_dir/$header_basename" ]
}
args = [
"--location",
rebase_path("$_flutter_framework_headers_copy_dir"),
"--headers",
] + rebase_path(_flutter_framework_headers)
] + rebase_path(sources, "", "//")
}

copy("copy_framework_icu") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERPLATFORMPLUGIN_H_

#include "flutter/fml/memory/weak_ptr.h"
#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterChannels.h"
#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h"

@interface FlutterPlatformPlugin : NSObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include "FlutterPlatformViews_Internal.h"
#include "flutter/fml/platform/darwin/scoped_nsobject.h"
#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterChannels.h"
#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"

namespace flutter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "flutter/flow/embedded_views.h"
#include "flutter/fml/platform/darwin/scoped_nsobject.h"
#include "flutter/shell/common/shell.h"
#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterBinaryMessenger.h"
#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterChannels.h"
#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h"
#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlatformViews.h"

// A UIView that is used as the parent for embedded UIViews.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import <UIKit/UIKit.h>

#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterChannels.h"
#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h"

@interface FlutterTextInputPlugin : NSObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "flutter/fml/platform/darwin/scoped_nsobject.h"
#include "flutter/lib/ui/semantics/custom_accessibility_action.h"
#include "flutter/lib/ui/semantics/semantics_node.h"
#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterChannels.h"
#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h"
#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h"
#include "third_party/skia/include/core/SkMatrix44.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "flutter/fml/memory/weak_ptr.h"
#include "flutter/fml/platform/darwin/scoped_block.h"
#include "flutter/lib/ui/window/platform_message.h"
#include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterBinaryMessenger.h"
#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h"

namespace flutter {

Expand Down
4 changes: 2 additions & 2 deletions shell/platform/darwin/macos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ assert(is_mac)

import("//build/config/mac/mac_sdk.gni")
import("$flutter_root/common/config.gni")
import("$flutter_root/shell/platform/darwin/framework_shared.gni")
import("$flutter_root/shell/platform/darwin/common/framework_shared.gni")
import("$flutter_root/shell/platform/glfw/config.gni")

group("macos") {
Expand Down Expand Up @@ -60,7 +60,7 @@ shared_library("create_flutter_framework_dylib") {
sources += _flutter_framework_headers

deps = [
"$flutter_root/shell/platform/darwin:framework_shared",
"$flutter_root/shell/platform/darwin/common:framework_shared",
"$flutter_root/shell/platform/embedder:embedder",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if defined(FLUTTER_FRAMEWORK)
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterMacros.h"
#else
#import "FlutterMacros.h"
#endif

/**
* Protocol for views owned by FLEViewController to handle context changes, specifically relating to
Expand Down
Loading

0 comments on commit e00ac47

Please sign in to comment.