BUILD.gn 9.6 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
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")
12

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

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

22 23 24 25 26
# 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",
27
  "framework/Headers/FlutterCallbackCache.h",
28
  "framework/Headers/FlutterDartProject.h",
D
Dan Field 已提交
29
  "framework/Headers/FlutterEngine.h",
30
  "framework/Headers/FlutterHeadlessDartRunner.h",
31
  "framework/Headers/FlutterPlatformViews.h",
32
  "framework/Headers/FlutterPlugin.h",
33
  "framework/Headers/FlutterPluginAppLifeCycleDelegate.h",
34 35 36 37 38
  "framework/Headers/FlutterViewController.h",
]

_flutter_framework_headers_copy_dir = "$_flutter_framework_dir/Headers"

39 40
source_set("flutter_framework_source") {
  visibility = [ ":*" ]
41 42 43
  cflags_objc = flutter_cflags_objc
  cflags_objcc = flutter_cflags_objcc

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

109 110
  sources += _flutter_framework_headers

111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
  defines = [ "FLUTTER_FRAMEWORK=1" ]

  if (shell_enable_metal) {
    defines += [ "FLUTTER_SHELL_ENABLE_METAL=1" ]

    sources += [
      "ios_context_metal.h",
      "ios_context_metal.mm",
      "ios_external_texture_metal.h",
      "ios_external_texture_metal.mm",
      "ios_surface_metal.h",
      "ios_surface_metal.mm",
    ]
  }

126
  deps = [
127
    ":ios_gpu_configuration",
128 129 130 131 132 133 134 135 136
    "//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",
137
    "//flutter/shell/profiling:profiling",
138
    "//third_party/skia",
139 140
  ]

141
  public_configs = [ "//flutter:config" ]
142

143
  libs = [
144 145
    "CoreMedia.framework",
    "CoreVideo.framework",
146 147 148 149 150 151 152
    "UIKit.framework",
    "OpenGLES.framework",
    "AudioToolbox.framework",
    "QuartzCore.framework",
  ]
}

153 154 155
ios_test_flutter_path = rebase_path("$root_out_dir/libios_test_flutter.dylib")
platform_frameworks_path = "$ios_sdk_path/../../Library/Frameworks/"

156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
# For tests that rely on manual reference counting.
source_set("ios_test_flutter_mrc") {
  visibility = [ ":*" ]
  cflags = [
    "-fvisibility=default",
    "-F$platform_frameworks_path",
    "-mios-simulator-version-min=$ios_testing_deployment_target",
  ]
  sources = [
    "framework/Source/accessibility_bridge_test.mm",
  ]
  deps = [
    ":flutter_framework_source",
    "//flutter/shell/platform/darwin/common:framework_shared",
    "//flutter/third_party/tonic",
    "//flutter/third_party/txt",
    "//third_party/ocmock:ocmock",
    "//third_party/rapidjson",
    "//third_party/skia",
  ]
}

178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
# NOTE: This currently only supports simulator targets because of the install_name.
# TODO(54504): Switch the install_name and make the test runner copy the dynamic
#              library into the testing bundle.
shared_library("ios_test_flutter") {
  visibility = [ ":*" ]
  cflags = [
    "-fvisibility=default",
    "-F$platform_frameworks_path",
    "-fobjc-arc",
    "-mios-simulator-version-min=$ios_testing_deployment_target",
  ]
  ldflags = [
    "-F$platform_frameworks_path",
    "-Wl,-framework,XCTest",
    "-Wl,-install_name,$ios_test_flutter_path",
  ]
  configs -= [
    "//build/config/gcc:symbol_visibility_hidden",
    "//build/config:symbol_visibility_hidden",
  ]
  sources = [
    "framework/Source/FlutterBinaryMessengerRelayTest.mm",
    "framework/Source/FlutterEngineTest.mm",
    "framework/Source/FlutterPluginAppLifeCycleDelegateTest.m",
    "framework/Source/FlutterTextInputPluginTest.m",
    "framework/Source/FlutterViewControllerTest.mm",
    "framework/Source/SemanticsObjectTest.mm",
  ]
  deps = [
    ":flutter_framework_source",
208
    ":ios_test_flutter_mrc",
209
    "//flutter/shell/platform/darwin/common:framework_shared",
210 211
    "//flutter/third_party/tonic",
    "//flutter/third_party/txt",
212
    "//third_party/ocmock:ocmock",
213
    "//third_party/rapidjson",
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
    "//third_party/skia",
  ]
  public_configs = [ "//flutter:config" ]
}

shared_library("create_flutter_framework_dylib") {
  visibility = [ ":*" ]

  output_name = "Flutter"

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

  public = _flutter_framework_headers

  deps = [
    ":flutter_framework_source",
  ]

  public_configs = [ "//flutter:config" ]
}

235
copy("copy_dylib") {
236 237
  visibility = [ ":*" ]

238 239
  sources = [
    "$root_out_dir/libFlutter.dylib",
240 241
  ]
  outputs = [
242
    "$_flutter_framework_dir/Flutter",
243
  ]
244 245

  deps = [
246
    ":create_flutter_framework_dylib",
247 248 249
  ]
}

250
action("copy_framework_info_plist") {
251
  script = "//flutter/build/copy_info_plist.py"
252
  visibility = [ ":*" ]
253 254 255 256 257 258
  sources = [
    "framework/Info.plist",
  ]
  outputs = [
    "$_flutter_framework_dir/Info.plist",
  ]
259 260 261
  args = [
    rebase_path(sources[0]),
    rebase_path(outputs[0]),
262
    "--bitcode=$flutter_enable_bitcode",
263
  ]
264 265
}

266
copy("copy_framework_module_map") {
267
  visibility = [ ":*" ]
268 269 270 271 272 273
  sources = [
    "framework/module.modulemap",
  ]
  outputs = [
    "$_flutter_framework_dir/Modules/module.modulemap",
  ]
274
}
275

276
action("copy_framework_headers") {
277
  script = "//flutter/sky/tools/install_framework_headers.py"
278
  visibility = [ ":*" ]
279 280
  sources = get_path_info(_flutter_framework_headers, "abspath") +
            framework_shared_headers
281
  outputs = []
282 283
  foreach(header, sources) {
    header_basename = get_path_info(header, "file")
284 285 286 287 288 289
    outputs += [ "$_flutter_framework_headers_copy_dir/$header_basename" ]
  }
  args = [
           "--location",
           rebase_path("$_flutter_framework_headers_copy_dir"),
           "--headers",
290
         ] + rebase_path(sources, "", "//")
291 292
}

293
copy("copy_framework_icu") {
294 295
  visibility = [ ":*" ]
  sources = [
296
    "//third_party/icu/flutter/icudtl.dat",
297
  ]
298 299 300
  outputs = [
    "$_flutter_framework_dir/{{source_file_part}}",
  ]
301 302
}

303
copy("copy_framework_podspec") {
304 305 306 307 308 309 310 311 312
  visibility = [ ":*" ]
  sources = [
    "framework/Flutter.podspec",
  ]
  outputs = [
    "$root_out_dir/Flutter.podspec",
  ]
}

313 314 315 316 317 318 319 320 321 322
copy("copy_license") {
  visibility = [ ":*" ]
  sources = [
    "//LICENSE",
  ]
  outputs = [
    "$root_out_dir/LICENSE",
  ]
}

323 324 325
shared_library("copy_and_verify_framework_headers") {
  visibility = [ ":*" ]
  include_dirs = [ "$_flutter_framework_headers_copy_dir" ]
326

327 328 329 330 331 332 333 334
  sources = [
    "framework/Source/FlutterUmbrellaImport.m",
  ]
  deps = [
    ":copy_framework_headers",
  ]
}

335
group("flutter_framework") {
336 337
  deps = [
    ":copy_and_verify_framework_headers",
338
    ":copy_dylib",
339 340 341 342
    ":copy_framework_icu",
    ":copy_framework_info_plist",
    ":copy_framework_module_map",
    ":copy_framework_podspec",
343
    ":copy_license",
344 345
  ]
}