BUILD.gn 7.1 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
import("$flutter_root/common/config.gni")
9
import("$flutter_root/shell/gpu/gpu.gni")
10
import("$flutter_root/shell/platform/darwin/common/framework_shared.gni")
11

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

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

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

_flutter_framework_headers_copy_dir = "$_flutter_framework_dir/Headers"

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

  output_name = "Flutter"

  sources = [
    "framework/Source/FlutterAppDelegate.mm",
46 47
    "framework/Source/FlutterAppDelegate_Internal.h",
    "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/accessibility_bridge.h",
    "framework/Source/accessibility_bridge.mm",
Y
Yegor 已提交
73 74
    "framework/Source/accessibility_text_entry.h",
    "framework/Source/accessibility_text_entry.mm",
75 76
    "framework/Source/platform_message_response_darwin.h",
    "framework/Source/platform_message_response_darwin.mm",
77 78
    "framework/Source/platform_message_router.h",
    "framework/Source/platform_message_router.mm",
79 80
    "framework/Source/vsync_waiter_ios.h",
    "framework/Source/vsync_waiter_ios.mm",
81 82
    "ios_external_texture_gl.h",
    "ios_external_texture_gl.mm",
83 84
    "ios_gl_context.h",
    "ios_gl_context.mm",
85 86
    "ios_gl_render_target.h",
    "ios_gl_render_target.mm",
87 88 89 90 91 92
    "ios_surface.h",
    "ios_surface.mm",
    "ios_surface_gl.h",
    "ios_surface_gl.mm",
    "ios_surface_software.h",
    "ios_surface_software.mm",
93 94 95
    "platform_view_ios.h",
    "platform_view_ios.mm",
  ]
96

97 98 99 100 101 102 103
  if (shell_enable_metal) {
    sources += [
      "ios_surface_metal.h",
      "ios_surface_metal.mm",
    ]
  }

104 105
  sources += _flutter_framework_headers

106
  deps = [
107
    ":ios_gpu_configuration",
J
Jason Simmons 已提交
108
    "$flutter_root/common",
109 110 111
    "$flutter_root/flow",
    "$flutter_root/fml",
    "$flutter_root/lib/ui",
112
    "$flutter_root/runtime",
113
    "$flutter_root/runtime:libdart",
114 115
    "$flutter_root/shell/common",
    "$flutter_root/shell/platform/darwin/common",
116
    "$flutter_root/shell/platform/darwin/common:framework_shared",
117
    "//third_party/skia",
118 119
  ]

120
  public_configs = [ "$flutter_root:config" ]
121

122 123 124 125 126
  defines = [ "FLUTTER_FRAMEWORK=1" ]

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

  libs = [
129 130
    "CoreMedia.framework",
    "CoreVideo.framework",
131 132 133 134 135 136 137
    "UIKit.framework",
    "OpenGLES.framework",
    "AudioToolbox.framework",
    "QuartzCore.framework",
  ]
}

138
copy("copy_framework_dylib") {
139
  visibility = [ ":*" ]
140

141 142 143 144 145 146
  sources = [
    "$root_out_dir/libFlutter.dylib",
  ]
  outputs = [
    "$_flutter_framework_dir/Flutter",
  ]
147 148

  deps = [
149
    ":create_flutter_framework_dylib",
150 151 152
  ]
}

153
action("copy_dylib_and_update_framework_install_name") {
154 155
  visibility = [ ":*" ]
  stamp_file = "$root_out_dir/flutter_install_name_stamp"
156
  script = "$flutter_root/sky/tools/change_install_name.py"
157

158 159 160 161 162 163
  inputs = [
    "$_flutter_framework_dir/Flutter",
  ]
  outputs = [
    stamp_file,
  ]
164 165 166 167 168 169 170 171 172 173 174

  args = [
    "--dylib",
    rebase_path("$_flutter_framework_dir/Flutter"),
    "--install_name",
    "@rpath/Flutter.framework/Flutter",
    "--stamp",
    rebase_path(stamp_file),
  ]

  deps = [
175
    ":copy_framework_dylib",
176 177 178
  ]
}

179
copy("copy_framework_info_plist") {
180
  visibility = [ ":*" ]
181 182 183 184 185 186
  sources = [
    "framework/Info.plist",
  ]
  outputs = [
    "$_flutter_framework_dir/Info.plist",
  ]
187 188
}

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

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

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

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

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

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

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

258
group("flutter_framework") {
259 260 261 262 263 264 265
  deps = [
    ":copy_and_verify_framework_headers",
    ":copy_dylib_and_update_framework_install_name",
    ":copy_framework_icu",
    ":copy_framework_info_plist",
    ":copy_framework_module_map",
    ":copy_framework_podspec",
266
    ":copy_license",
267 268
  ]
}