BUILD.gn 7.2 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")
D
Dan Field 已提交
8
import("$flutter_root/build/darwin/ios_app.gni")
9
import("$flutter_root/common/config.gni")
10
import("$flutter_root/shell/gpu/gpu.gni")
11
import("$flutter_root/shell/platform/darwin/common/framework_shared.gni")
D
Dan Field 已提交
12
import("$flutter_root/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
  sources = [
    "framework/Source/FlutterAppDelegate.mm",
49
    "framework/Source/FlutterAppDelegate_Internal.h",
G
gaaclarke 已提交
50
    "framework/Source/FlutterBinaryMessengerRelay.mm",
51
    "framework/Source/FlutterCallbackCache.mm",
52
    "framework/Source/FlutterCallbackCache_Internal.h",
53
    "framework/Source/FlutterDartProject.mm",
54
    "framework/Source/FlutterDartProject_Internal.h",
D
Dan Field 已提交
55 56
    "framework/Source/FlutterEngine.mm",
    "framework/Source/FlutterEngine_Internal.h",
57
    "framework/Source/FlutterHeadlessDartRunner.mm",
58 59
    "framework/Source/FlutterObservatoryPublisher.h",
    "framework/Source/FlutterObservatoryPublisher.mm",
60 61
    "framework/Source/FlutterOverlayView.h",
    "framework/Source/FlutterOverlayView.mm",
62 63
    "framework/Source/FlutterPlatformPlugin.h",
    "framework/Source/FlutterPlatformPlugin.mm",
64
    "framework/Source/FlutterPlatformViews.mm",
65
    "framework/Source/FlutterPlatformViews_Internal.h",
66
    "framework/Source/FlutterPlatformViews_Internal.mm",
67
    "framework/Source/FlutterPluginAppLifeCycleDelegate.mm",
68 69 70
    "framework/Source/FlutterTextInputDelegate.h",
    "framework/Source/FlutterTextInputPlugin.h",
    "framework/Source/FlutterTextInputPlugin.mm",
71 72 73
    "framework/Source/FlutterView.h",
    "framework/Source/FlutterView.mm",
    "framework/Source/FlutterViewController.mm",
74
    "framework/Source/FlutterViewController_Internal.h",
75 76
    "framework/Source/accessibility_bridge.h",
    "framework/Source/accessibility_bridge.mm",
Y
Yegor 已提交
77 78
    "framework/Source/accessibility_text_entry.h",
    "framework/Source/accessibility_text_entry.mm",
79 80
    "framework/Source/platform_message_response_darwin.h",
    "framework/Source/platform_message_response_darwin.mm",
81 82
    "framework/Source/platform_message_router.h",
    "framework/Source/platform_message_router.mm",
83 84
    "framework/Source/vsync_waiter_ios.h",
    "framework/Source/vsync_waiter_ios.mm",
85 86
    "ios_external_texture_gl.h",
    "ios_external_texture_gl.mm",
87 88
    "ios_gl_context.h",
    "ios_gl_context.mm",
89 90
    "ios_gl_render_target.h",
    "ios_gl_render_target.mm",
91 92 93 94 95 96
    "ios_surface.h",
    "ios_surface.mm",
    "ios_surface_gl.h",
    "ios_surface_gl.mm",
    "ios_surface_software.h",
    "ios_surface_software.mm",
97 98 99
    "platform_view_ios.h",
    "platform_view_ios.mm",
  ]
100

101 102 103 104 105 106 107
  if (shell_enable_metal) {
    sources += [
      "ios_surface_metal.h",
      "ios_surface_metal.mm",
    ]
  }

108 109
  sources += _flutter_framework_headers

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

124
  public_configs = [ "$flutter_root:config" ]
125

126 127 128 129 130
  defines = [ "FLUTTER_FRAMEWORK=1" ]

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

  libs = [
133 134
    "CoreMedia.framework",
    "CoreVideo.framework",
135 136 137 138 139 140 141
    "UIKit.framework",
    "OpenGLES.framework",
    "AudioToolbox.framework",
    "QuartzCore.framework",
  ]
}

142
copy("copy_dylib") {
143 144
  visibility = [ ":*" ]

145 146
  sources = [
    "$root_out_dir/libFlutter.dylib",
147 148
  ]
  outputs = [
149
    "$_flutter_framework_dir/Flutter",
150
  ]
151 152

  deps = [
153
    ":create_flutter_framework_dylib",
154 155 156
  ]
}

157 158
action("copy_framework_info_plist") {
  script = "$flutter_root/build/copy_info_plist.py"
159
  visibility = [ ":*" ]
160 161 162 163 164 165
  sources = [
    "framework/Info.plist",
  ]
  outputs = [
    "$_flutter_framework_dir/Info.plist",
  ]
166 167 168
  args = [
    rebase_path(sources[0]),
    rebase_path(outputs[0]),
169
    "--bitcode=$flutter_enable_bitcode",
170
  ]
171 172
}

173
copy("copy_framework_module_map") {
174
  visibility = [ ":*" ]
175 176 177 178 179 180
  sources = [
    "framework/module.modulemap",
  ]
  outputs = [
    "$_flutter_framework_dir/Modules/module.modulemap",
  ]
181
}
182

183 184
action("copy_framework_headers") {
  script = "$flutter_root/sky/tools/install_framework_headers.py"
185
  visibility = [ ":*" ]
186 187
  sources = get_path_info(_flutter_framework_headers, "abspath") +
            framework_shared_headers
188
  outputs = []
189 190
  foreach(header, sources) {
    header_basename = get_path_info(header, "file")
191 192 193 194 195 196
    outputs += [ "$_flutter_framework_headers_copy_dir/$header_basename" ]
  }
  args = [
           "--location",
           rebase_path("$_flutter_framework_headers_copy_dir"),
           "--headers",
197
         ] + rebase_path(sources, "", "//")
198 199
}

200
copy("copy_framework_icu") {
201 202
  visibility = [ ":*" ]
  sources = [
203
    "//third_party/icu/flutter/icudtl.dat",
204
  ]
205 206 207
  outputs = [
    "$_flutter_framework_dir/{{source_file_part}}",
  ]
208 209
}

210
copy("copy_framework_podspec") {
211 212 213 214 215 216 217 218 219
  visibility = [ ":*" ]
  sources = [
    "framework/Flutter.podspec",
  ]
  outputs = [
    "$root_out_dir/Flutter.podspec",
  ]
}

220 221 222 223 224 225 226 227 228 229
copy("copy_license") {
  visibility = [ ":*" ]
  sources = [
    "//LICENSE",
  ]
  outputs = [
    "$root_out_dir/LICENSE",
  ]
}

230 231 232
shared_library("copy_and_verify_framework_headers") {
  visibility = [ ":*" ]
  include_dirs = [ "$_flutter_framework_headers_copy_dir" ]
233

234 235 236 237 238 239 240 241
  sources = [
    "framework/Source/FlutterUmbrellaImport.m",
  ]
  deps = [
    ":copy_framework_headers",
  ]
}

D
Dan Field 已提交
242 243 244 245 246 247 248 249 250 251 252 253 254
test_fixtures("flutter_tests_fixtures") {
  fixtures = []
}

ios_app("FlutterTests") {
  testonly = true

  info_plist = "FlutterTestsInfo.plist"

  sources = [
    "flutter_unittests.mm",
  ]

255
  libs = [ "Foundation.framework" ]
D
Dan Field 已提交
256 257 258 259 260 261 262 263

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

264
group("flutter_framework") {
265 266
  deps = [
    ":copy_and_verify_framework_headers",
267
    ":copy_dylib",
268 269 270 271
    ":copy_framework_icu",
    ":copy_framework_info_plist",
    ":copy_framework_module_map",
    ":copy_framework_podspec",
272
    ":copy_license",
273 274
  ]
}