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
    "framework/Source/FlutterAppDelegate_Internal.h",
G
gaaclarke 已提交
47
    "framework/Source/FlutterBinaryMessengerRelay.mm",
48
    "framework/Source/FlutterCallbackCache.mm",
49
    "framework/Source/FlutterCallbackCache_Internal.h",
50
    "framework/Source/FlutterDartProject.mm",
51
    "framework/Source/FlutterDartProject_Internal.h",
D
Dan Field 已提交
52 53
    "framework/Source/FlutterEngine.mm",
    "framework/Source/FlutterEngine_Internal.h",
54
    "framework/Source/FlutterHeadlessDartRunner.mm",
55 56
    "framework/Source/FlutterObservatoryPublisher.h",
    "framework/Source/FlutterObservatoryPublisher.mm",
57 58
    "framework/Source/FlutterOverlayView.h",
    "framework/Source/FlutterOverlayView.mm",
59 60
    "framework/Source/FlutterPlatformPlugin.h",
    "framework/Source/FlutterPlatformPlugin.mm",
61
    "framework/Source/FlutterPlatformViews.mm",
62
    "framework/Source/FlutterPlatformViews_Internal.h",
63
    "framework/Source/FlutterPlatformViews_Internal.mm",
64
    "framework/Source/FlutterPluginAppLifeCycleDelegate.mm",
65 66 67
    "framework/Source/FlutterTextInputDelegate.h",
    "framework/Source/FlutterTextInputPlugin.h",
    "framework/Source/FlutterTextInputPlugin.mm",
68 69 70
    "framework/Source/FlutterView.h",
    "framework/Source/FlutterView.mm",
    "framework/Source/FlutterViewController.mm",
71
    "framework/Source/FlutterViewController_Internal.h",
72 73
    "framework/Source/accessibility_bridge.h",
    "framework/Source/accessibility_bridge.mm",
Y
Yegor 已提交
74 75
    "framework/Source/accessibility_text_entry.h",
    "framework/Source/accessibility_text_entry.mm",
76 77
    "framework/Source/platform_message_response_darwin.h",
    "framework/Source/platform_message_response_darwin.mm",
78 79
    "framework/Source/platform_message_router.h",
    "framework/Source/platform_message_router.mm",
80 81
    "framework/Source/vsync_waiter_ios.h",
    "framework/Source/vsync_waiter_ios.mm",
82 83
    "ios_external_texture_gl.h",
    "ios_external_texture_gl.mm",
84 85
    "ios_gl_context.h",
    "ios_gl_context.mm",
86 87
    "ios_gl_render_target.h",
    "ios_gl_render_target.mm",
88 89 90 91 92 93
    "ios_surface.h",
    "ios_surface.mm",
    "ios_surface_gl.h",
    "ios_surface_gl.mm",
    "ios_surface_software.h",
    "ios_surface_software.mm",
94 95 96
    "platform_view_ios.h",
    "platform_view_ios.mm",
  ]
97

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

105 106
  sources += _flutter_framework_headers

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

259
group("flutter_framework") {
260 261 262 263 264 265 266
  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",
267
    ":copy_license",
268 269
  ]
}