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

assert(is_fuchsia)

import("//build/fuchsia/sdk.gni")
8
import("$flutter_root/common/config.gni")
9
import("$flutter_root/shell/gpu/gpu.gni")
D
Dan Field 已提交
10
import("$flutter_root/testing/testing.gni")
11
import("$flutter_root/tools/fuchsia/dart.gni")
12
import("$flutter_root/tools/fuchsia/fuchsia_archive.gni")
13 14
import("$flutter_root/tools/fuchsia/fuchsia_libs.gni")
import("$flutter_root/vulkan/config.gni")
15
import("engine_flutter_runner.gni")
16

17 18 19 20 21 22 23
shell_gpu_configuration("fuchsia_gpu_configuration") {
  enable_software = false
  enable_gl = false
  enable_vulkan = true
  enable_metal = false
}

24 25 26 27 28
# Things that explicitly being excluded:
# 1. Kernel snapshot framework mode.
# 2. Profiler symbols.

# Dependencies for flutter tooling
29
#
30 31
# While not required to run a flutter mod, these allow interacting
# with flutter via the fx tool and need to be built.
32
#
33 34 35 36 37
# This is only for builds in topaz tree.
flutter_tool_deps = []
if (!using_fuchsia_sdk) {
  flutter_tool_deps += [ "//third_party/dart-pkg/git/flutter/packages/flutter_tools:fuchsia_attach($host_toolchain)" ]
}
38

39 40 41
flutter_runner("jit") {
  output_name = "flutter_jit_runner"
  product = false
42 43

  extra_defines = []
44
  if (flutter_runtime_mode == "profile") {
45 46 47 48 49
    extra_defines += [ "FLUTTER_PROFILE" ]
  }

  if (enable_vulkan_validation_layers) {
    extra_defines += [ "VULKAN_VALIDATION_LAYERS_ENABLED" ]
50 51
  }

52 53 54 55 56
  extra_deps = [
                 "//third_party/dart/runtime:libdart_jit",
                 "//third_party/dart/runtime/platform:libdart_platform_jit",
               ] + flutter_tool_deps
}
57

58 59 60
flutter_runner("jit_product") {
  output_name = "flutter_jit_product_runner"
  product = true
61

62 63
  extra_defines = [ "DART_PRODUCT" ]

64 65 66 67
  if (enable_vulkan_validation_layers) {
    extra_defines += [ "VULKAN_VALIDATION_LAYERS_ENABLED" ]
  }

68 69 70 71 72 73
  extra_deps = [
    "//third_party/dart/runtime:libdart_jit_product",
    "//third_party/dart/runtime/platform:libdart_platform_jit_product",
  ]
}

74 75 76
flutter_runner("aot") {
  output_name = "flutter_aot_runner"
  product = false
77 78

  extra_defines = []
79
  if (flutter_runtime_mode == "profile") {
80
    extra_defines += [ "FLUTTER_PROFILE" ]
81
  }
82 83 84 85 86

  if (enable_vulkan_validation_layers) {
    extra_defines += [ "VULKAN_VALIDATION_LAYERS_ENABLED" ]
  }

87 88 89 90 91 92 93 94 95
  extra_deps = [
    "//third_party/dart/runtime:libdart_precompiled_runtime",
    "//third_party/dart/runtime/platform:libdart_platform_precompiled_runtime",
  ]
}

flutter_runner("aot_product") {
  output_name = "flutter_aot_product_runner"
  product = true
96

97
  extra_defines = [ "DART_PRODUCT" ]
98 99 100 101 102

  if (enable_vulkan_validation_layers) {
    extra_defines += [ "VULKAN_VALIDATION_LAYERS_ENABLED" ]
  }

103 104 105 106 107 108
  extra_deps = [
    "//third_party/dart/runtime:libdart_precompiled_runtime_product",
    "//third_party/dart/runtime/platform:libdart_platform_precompiled_runtime_product",
  ]
}

109
template("jit_runner") {
110 111
  product = defined(invoker.product) && invoker.product

112 113
  product_suffix = ""

114 115
  if (product) {
    product_suffix = "_product"
116 117
  }

118
  fuchsia_archive(target_name) {
119 120
    snapshot_label = "kernel:kernel_core_snapshot${product_suffix}"
    snapshot_gen_dir = get_label_info(snapshot_label, "target_gen_dir")
121 122 123

    deps = [
      ":jit${product_suffix}",
124
      snapshot_label,
125 126
    ]

127
    if (!product) {
128 129
      deps += [
        "$flutter_root/shell/platform/fuchsia/runtime/dart/profiler_symbols:flutter_jit_runner",
130
        observatory_target,
131
      ]
132 133
    }

134 135
    binary = "flutter_jit${product_suffix}_runner"

136 137
    meta_dir = "$flutter_root/shell/platform/fuchsia/flutter/meta"

138
    resources = [
K
Kaushik Iska 已提交
139 140 141 142 143 144
      {
        path = rebase_path("//third_party/icu/common/icudtl.dat")
        dest = "icudtl.dat"
      },
    ]

145 146 147
    if (!product) {
      resources += [
        {
148
          path = rebase_path(observatory_archive_file)
149 150
          dest = "observatory.tar"
        },
151 152 153 154 155 156 157 158
        {
          path = rebase_path(
                  get_label_info(
                      "$flutter_root/shell/platform/fuchsia/runtime/dart/profiler_symbols:flutter_jit_runner",
                      "target_gen_dir") +
                  "/flutter_jit_runner.dartprofilersymbols")
          dest = "flutter_jit_runner.dartprofilersymbols"
        },
159 160 161
      ]
    }

K
Kaushik Iska 已提交
162
    resources += [
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
      {
        path = rebase_path(
                "$snapshot_gen_dir/vm_isolate_snapshot${product_suffix}.bin")
        dest = "vm_snapshot_data.bin"
      },
      {
        path = rebase_path(
                "$snapshot_gen_dir/vm_snapshot_instructions${product_suffix}.bin")
        dest = "vm_snapshot_instructions.bin"
      },
      {
        path = rebase_path(
                "$snapshot_gen_dir/isolate_snapshot${product_suffix}.bin")
        dest = "isolate_core_snapshot_data.bin"
      },
      {
        path = rebase_path(
                "$snapshot_gen_dir/isolate_snapshot_instructions${product_suffix}.bin")
        dest = "isolate_core_snapshot_instructions.bin"
      },
    ]

185 186 187 188 189 190 191 192 193 194
    _vulkan_icds = []
    _libs = common_libs
    if (enable_vulkan_validation_layers) {
      _libs += vulkan_validation_libs
      _vulkan_icds += vulkan_icds
    }

    resources += _vulkan_icds

    libraries = _libs
195

196
    meta = [
197
      {
198 199
        path = rebase_path("meta/flutter_jit${product_suffix}_runner.cmx")
        dest = "flutter_jit${product_suffix}_runner.cmx"
200
      },
201 202 203
    ]
  }
}
204

205 206 207 208 209 210 211
template("aot_runner") {
  product = defined(invoker.product) && invoker.product
  product_suffix = ""
  if (product) {
    product_suffix = "_product"
  }

212
  fuchsia_archive(target_name) {
213 214 215 216 217
    deps = [
      ":aot${product_suffix}",
    ]

    if (!product) {
218 219
      deps += [
        "$flutter_root/shell/platform/fuchsia/runtime/dart/profiler_symbols:flutter_aot_runner",
220
        observatory_target,
221
      ]
222 223
    }

224 225
    meta_dir = "$flutter_root/shell/platform/fuchsia/flutter/meta"

226 227 228
    binary = "flutter_aot${product_suffix}_runner"

    resources = [
229
      {
230 231
        path = rebase_path("//third_party/icu/common/icudtl.dat")
        dest = "icudtl.dat"
232
      },
233 234
    ]

235 236 237
    if (!product) {
      resources += [
        {
238
          path = rebase_path(observatory_archive_file)
239 240
          dest = "observatory.tar"
        },
241 242 243 244 245 246 247 248
        {
          path = rebase_path(
                  get_label_info(
                      "$flutter_root/shell/platform/fuchsia/runtime/dart/profiler_symbols:flutter_aot_runner",
                      "target_gen_dir") +
                  "/flutter_aot_runner.dartprofilersymbols")
          dest = "flutter_aot_runner.dartprofilersymbols"
        },
249 250 251
      ]
    }

252 253 254 255 256 257 258 259 260 261
    _vulkan_icds = []
    _libs = common_libs
    if (enable_vulkan_validation_layers) {
      _libs += vulkan_validation_libs
      _vulkan_icds += vulkan_icds
    }

    resources += _vulkan_icds

    libraries = _libs
262

263 264
    meta = [
      {
265 266
        path = rebase_path("meta/flutter_aot${product_suffix}_runner.cmx")
        dest = "flutter_aot${product_suffix}_runner.cmx"
267
      },
268 269
    ]
  }
270
}
271

272 273 274 275 276 277 278 279
aot_runner("flutter_aot_runner") {
  product = false
}

aot_runner("flutter_aot_product_runner") {
  product = true
}

280 281 282
jit_runner("flutter_jit_runner") {
  product = false
}
283 284 285 286

jit_runner("flutter_jit_product_runner") {
  product = true
}
287

D
Dan Field 已提交
288 289 290 291
test_fixtures("flutter_runner_fixtures") {
  fixtures = []
}

292 293 294 295 296 297
executable("flutter_runner_unittests") {
  testonly = true

  output_name = "flutter_runner_tests"

  sources = [
298 299 300 301
    "accessibility_bridge.cc",
    "accessibility_bridge.h",
    "accessibility_bridge_unittest.cc",
    "flutter_runner_fakes.h",
302 303 304
    "fuchsia_intl.cc",
    "fuchsia_intl.h",
    "fuchsia_intl_unittest.cc",
305
    "logging.h",
306 307
    "loop.cc",
    "loop.h",
308 309 310 311 312
    "platform_view.cc",
    "platform_view.h",
    "platform_view_unittest.cc",
    "surface.cc",
    "surface.h",
313 314 315 316 317 318
    "task_observers.cc",
    "task_observers.h",
    "task_runner_adapter.cc",
    "task_runner_adapter.h",
    "thread.cc",
    "thread.h",
319 320 321 322
    "vsync_recorder.cc",
    "vsync_recorder.h",
    "vsync_waiter.cc",
    "vsync_waiter.h",
323
    "vsync_waiter_unittests.cc",
324 325
  ]

326
  # This is needed for //third_party/googletest for linking zircon symbols.
327 328 329
  libs = [ "//fuchsia/sdk/$host_os/arch/$target_cpu/sysroot/lib/libzircon.so" ]

  deps = [
330
    ":aot",
D
Dan Field 已提交
331
    ":flutter_runner_fixtures",
332 333 334 335 336 337 338 339
    "//build/fuchsia/fidl:fuchsia.accessibility.semantics",
    "//build/fuchsia/pkg:async-loop-cpp",
    "//build/fuchsia/pkg:async-loop-default",
    "//build/fuchsia/pkg:scenic_cpp",
    "//build/fuchsia/pkg:sys_cpp_testing",
    "//flutter/lib/ui",
    "//flutter/shell/common",
    "//flutter/shell/platform/fuchsia/runtime/dart/utils",
340
    "//flutter/testing",
341 342
    "//third_party/dart/runtime:libdart_jit",
    "//third_party/dart/runtime/platform:libdart_platform_jit",
343 344 345
  ]
}

346
fuchsia_archive("flutter_runner_tests") {
347 348 349 350 351 352 353 354
  testonly = true

  deps = [
    ":flutter_runner_unittests",
  ]

  binary = "$target_name"

355 356 357 358 359 360 361
  resources = [
    {
      path = rebase_path("//third_party/icu/common/icudtl.dat")
      dest = "icudtl.dat"
    },
  ]

362 363
  meta_dir = "$flutter_root/shell/platform/fuchsia/flutter/meta"

364 365
  libraries = common_libs

366 367
  meta = [
    {
368
      path = rebase_path("meta/$target_name.cmx")
369 370 371 372
      dest = "$target_name.cmx"
    },
  ]
}