BUILD.gn 7.5 KB
Newer Older
M
Michael Goderbauer 已提交
1
# Copyright 2013 The Flutter Authors. All rights reserved.
2 3 4 5 6 7
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

assert(is_ios)

import("//build/config/ios/ios_sdk.gni")
8 9 10 11 12
import("//flutter/build/darwin/ios_app.gni")
import("//flutter/common/config.gni")
import("//flutter/shell/gpu/gpu.gni")
import("//flutter/shell/platform/darwin/common/framework_shared.gni")
import("//flutter/testing/testing.gni")
13

14 15
_flutter_framework_dir = "$root_out_dir/Flutter.framework"

16 17 18 19
shell_gpu_configuration("ios_gpu_configuration") {
  enable_software = true
  enable_gl = true
  enable_vulkan = false
20
  enable_metal = shell_enable_metal
21 22
}

23 24 25 26 27
# The headers that will be copied to the Flutter.framework and be accessed
# from outside the Flutter engine source root.
_flutter_framework_headers = [
  "framework/Headers/Flutter.h",
  "framework/Headers/FlutterAppDelegate.h",
28
  "framework/Headers/FlutterCallbackCache.h",
29
  "framework/Headers/FlutterDartProject.h",
D
Dan Field 已提交
30
  "framework/Headers/FlutterEngine.h",
31
  "framework/Headers/FlutterHeadlessDartRunner.h",
32
  "framework/Headers/FlutterPlatformViews.h",
33
  "framework/Headers/FlutterPlugin.h",
34
  "framework/Headers/FlutterPluginAppLifeCycleDelegate.h",
35 36 37 38 39 40
  "framework/Headers/FlutterViewController.h",
]

_flutter_framework_headers_copy_dir = "$_flutter_framework_dir/Headers"

shared_library("create_flutter_framework_dylib") {
41 42 43 44
  visibility = [ ":*" ]

  output_name = "Flutter"

45 46
  ldflags = [ "-Wl,-install_name,@rpath/Flutter.framework/Flutter" ]

47 48
  public = _flutter_framework_headers

49 50 51
  cflags_objc = flutter_cflags_objc
  cflags_objcc = flutter_cflags_objcc

52 53
  sources = [
    "framework/Source/FlutterAppDelegate.mm",
G
gaaclarke 已提交
54
    "framework/Source/FlutterBinaryMessengerRelay.mm",
55
    "framework/Source/FlutterCallbackCache.mm",
56
    "framework/Source/FlutterCallbackCache_Internal.h",
57
    "framework/Source/FlutterDartProject.mm",
58
    "framework/Source/FlutterDartProject_Internal.h",
D
Dan Field 已提交
59 60
    "framework/Source/FlutterEngine.mm",
    "framework/Source/FlutterEngine_Internal.h",
61
    "framework/Source/FlutterHeadlessDartRunner.mm",
62 63
    "framework/Source/FlutterObservatoryPublisher.h",
    "framework/Source/FlutterObservatoryPublisher.mm",
64 65
    "framework/Source/FlutterOverlayView.h",
    "framework/Source/FlutterOverlayView.mm",
66 67
    "framework/Source/FlutterPlatformPlugin.h",
    "framework/Source/FlutterPlatformPlugin.mm",
68
    "framework/Source/FlutterPlatformViews.mm",
69
    "framework/Source/FlutterPlatformViews_Internal.h",
70
    "framework/Source/FlutterPlatformViews_Internal.mm",
71
    "framework/Source/FlutterPluginAppLifeCycleDelegate.mm",
72 73 74
    "framework/Source/FlutterTextInputDelegate.h",
    "framework/Source/FlutterTextInputPlugin.h",
    "framework/Source/FlutterTextInputPlugin.mm",
75 76 77
    "framework/Source/FlutterView.h",
    "framework/Source/FlutterView.mm",
    "framework/Source/FlutterViewController.mm",
78
    "framework/Source/FlutterViewController_Internal.h",
79 80
    "framework/Source/SemanticsObject.h",
    "framework/Source/SemanticsObject.mm",
81 82
    "framework/Source/accessibility_bridge.h",
    "framework/Source/accessibility_bridge.mm",
Y
Yegor 已提交
83 84
    "framework/Source/accessibility_text_entry.h",
    "framework/Source/accessibility_text_entry.mm",
85 86
    "framework/Source/platform_message_response_darwin.h",
    "framework/Source/platform_message_response_darwin.mm",
87 88
    "framework/Source/platform_message_router.h",
    "framework/Source/platform_message_router.mm",
89 90
    "framework/Source/vsync_waiter_ios.h",
    "framework/Source/vsync_waiter_ios.mm",
91 92 93 94 95 96
    "ios_context.h",
    "ios_context.mm",
    "ios_context_gl.h",
    "ios_context_gl.mm",
    "ios_context_software.h",
    "ios_context_software.mm",
97 98
    "ios_external_texture_gl.h",
    "ios_external_texture_gl.mm",
99 100
    "ios_render_target_gl.h",
    "ios_render_target_gl.mm",
101 102 103 104 105 106
    "ios_surface.h",
    "ios_surface.mm",
    "ios_surface_gl.h",
    "ios_surface_gl.mm",
    "ios_surface_software.h",
    "ios_surface_software.mm",
107 108
    "platform_view_ios.h",
    "platform_view_ios.mm",
109 110
    "rendering_api_selection.h",
    "rendering_api_selection.mm",
111
  ]
112

113 114
  sources += _flutter_framework_headers

115
  deps = [
116
    ":ios_gpu_configuration",
117 118 119 120 121 122 123 124 125
    "//flutter/common",
    "//flutter/flow",
    "//flutter/fml",
    "//flutter/lib/ui",
    "//flutter/runtime",
    "//flutter/runtime:libdart",
    "//flutter/shell/common",
    "//flutter/shell/platform/darwin/common",
    "//flutter/shell/platform/darwin/common:framework_shared",
126
    "//third_party/skia",
127 128
  ]

129
  public_configs = [ "//flutter:config" ]
130

131 132 133 134
  defines = [ "FLUTTER_FRAMEWORK=1" ]

  if (shell_enable_metal) {
    defines += [ "FLUTTER_SHELL_ENABLE_METAL=1" ]
135 136 137 138

    sources += [
      "ios_context_metal.h",
      "ios_context_metal.mm",
139 140
      "ios_external_texture_metal.h",
      "ios_external_texture_metal.mm",
141 142 143
      "ios_surface_metal.h",
      "ios_surface_metal.mm",
    ]
144
  }
145 146

  libs = [
147 148
    "CoreMedia.framework",
    "CoreVideo.framework",
149 150 151 152 153 154 155
    "UIKit.framework",
    "OpenGLES.framework",
    "AudioToolbox.framework",
    "QuartzCore.framework",
  ]
}

156
copy("copy_dylib") {
157 158
  visibility = [ ":*" ]

159 160
  sources = [
    "$root_out_dir/libFlutter.dylib",
161 162
  ]
  outputs = [
163
    "$_flutter_framework_dir/Flutter",
164
  ]
165 166

  deps = [
167
    ":create_flutter_framework_dylib",
168 169 170
  ]
}

171
action("copy_framework_info_plist") {
172
  script = "//flutter/build/copy_info_plist.py"
173
  visibility = [ ":*" ]
174 175 176 177 178 179
  sources = [
    "framework/Info.plist",
  ]
  outputs = [
    "$_flutter_framework_dir/Info.plist",
  ]
180 181 182
  args = [
    rebase_path(sources[0]),
    rebase_path(outputs[0]),
183
    "--bitcode=$flutter_enable_bitcode",
184
  ]
185 186
}

187
copy("copy_framework_module_map") {
188
  visibility = [ ":*" ]
189 190 191 192 193 194
  sources = [
    "framework/module.modulemap",
  ]
  outputs = [
    "$_flutter_framework_dir/Modules/module.modulemap",
  ]
195
}
196

197
action("copy_framework_headers") {
198
  script = "//flutter/sky/tools/install_framework_headers.py"
199
  visibility = [ ":*" ]
200 201
  sources = get_path_info(_flutter_framework_headers, "abspath") +
            framework_shared_headers
202
  outputs = []
203 204
  foreach(header, sources) {
    header_basename = get_path_info(header, "file")
205 206 207 208 209 210
    outputs += [ "$_flutter_framework_headers_copy_dir/$header_basename" ]
  }
  args = [
           "--location",
           rebase_path("$_flutter_framework_headers_copy_dir"),
           "--headers",
211
         ] + rebase_path(sources, "", "//")
212 213
}

214
copy("copy_framework_icu") {
215 216
  visibility = [ ":*" ]
  sources = [
217
    "//third_party/icu/flutter/icudtl.dat",
218
  ]
219 220 221
  outputs = [
    "$_flutter_framework_dir/{{source_file_part}}",
  ]
222 223
}

224
copy("copy_framework_podspec") {
225 226 227 228 229 230 231 232 233
  visibility = [ ":*" ]
  sources = [
    "framework/Flutter.podspec",
  ]
  outputs = [
    "$root_out_dir/Flutter.podspec",
  ]
}

234 235 236 237 238 239 240 241 242 243
copy("copy_license") {
  visibility = [ ":*" ]
  sources = [
    "//LICENSE",
  ]
  outputs = [
    "$root_out_dir/LICENSE",
  ]
}

244 245 246
shared_library("copy_and_verify_framework_headers") {
  visibility = [ ":*" ]
  include_dirs = [ "$_flutter_framework_headers_copy_dir" ]
247

248 249 250 251 252 253 254 255
  sources = [
    "framework/Source/FlutterUmbrellaImport.m",
  ]
  deps = [
    ":copy_framework_headers",
  ]
}

D
Dan Field 已提交
256 257 258 259 260 261 262 263 264 265 266 267 268
test_fixtures("flutter_tests_fixtures") {
  fixtures = []
}

ios_app("FlutterTests") {
  testonly = true

  info_plist = "FlutterTestsInfo.plist"

  sources = [
    "flutter_unittests.mm",
  ]

269
  libs = [ "Foundation.framework" ]
D
Dan Field 已提交
270 271 272 273 274 275 276 277

  deps = [
    ":flutter_tests_fixtures",
    "//flutter/runtime:libdart",
    "//flutter/testing",
  ]
}

278
group("flutter_framework") {
279 280
  deps = [
    ":copy_and_verify_framework_headers",
281
    ":copy_dylib",
282 283 284 285
    ":copy_framework_icu",
    ":copy_framework_info_plist",
    ":copy_framework_module_map",
    ":copy_framework_podspec",
286
    ":copy_license",
287 288
  ]
}