BUILD.gn 2.3 KB
Newer Older
1 2 3 4
# 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.

K
Kaushik Iska 已提交
5
import("//build/compiled_action.gni")
6 7
import("//flutter/common/fuchsia_config.gni")
import("//flutter/tools/fuchsia/dart_kernel.gni")
K
Kaushik Iska 已提交
8
import("//third_party/dart/build/dart/dart_action.gni")
9

10
dart_kernel("shim_kernel") {
K
Kaushik Iska 已提交
11
  main_dart = "shim.dart"
12
  kernel_platform_files = "../kernel:kernel_platform_files"
K
Kaushik Iska 已提交
13
  product = false
14
  aot = true
K
Kaushik Iska 已提交
15
}
16

17
dart_kernel("shim_product_kernel") {
K
Kaushik Iska 已提交
18
  main_dart = "shim.dart"
19
  kernel_platform_files = "../kernel:kernel_platform_files"
K
Kaushik Iska 已提交
20 21
  product = true
  aot = true
22 23 24 25 26 27 28 29
}

template("create_aot_snapshot") {
  assert(defined(invoker.product), "The parameter 'product' must be defined")
  product_suffix = ""
  if (invoker.product) {
    product_suffix = "_product"
  }
K
Kaushik Iska 已提交
30
  compiled_action("${target_name}_assembly") {
31 32 33
    snapshot_assembly = "$target_gen_dir/aot${product_suffix}_vm_snapshot.S"

    # gen_snapshot only needs this to go through the motions of setting up an isolate.
34
    shim_target = ":shim${product_suffix}_kernel($host_toolchain)"
35
    shim_kernel = get_label_info(shim_target, "target_gen_dir") +
K
Kaushik Iska 已提交
36
                  "/shim${product_suffix}_kernel.dill"
37 38 39 40 41 42 43 44

    inputs = [
      shim_kernel,
    ]
    outputs = [
      snapshot_assembly,
    ]

K
Kaushik Iska 已提交
45 46 47
    deps = [
      shim_target,
    ]
48
    if (invoker.product) {
K
Kaushik Iska 已提交
49
      tool = gen_snapshot_product
50
    } else {
K
Kaushik Iska 已提交
51
      tool = gen_snapshot
52 53 54 55
    }

    args = [
      "--no_causal_async_stacks",
56
      "--lazy_async_stacks",
57 58 59 60 61 62 63 64
      "--deterministic",
      "--snapshot_kind=vm-aot-assembly",
      "--assembly=" + rebase_path(snapshot_assembly),
    ]

    # No asserts in debug or release product.
    # No asserts in release with flutter_profile=true (non-product)
    # Yes asserts in non-product debug.
65 66
    if (!invoker.product &&
        (!(flutter_runtime_mode == "profile") || is_debug)) {
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
      args += [ "--enable_asserts" ]
    }
    args += [ rebase_path(shim_kernel) ]
  }

  source_set(target_name) {
    deps = [
      ":${target_name}_assembly",
    ]

    sources = [
      "$target_gen_dir/aot${product_suffix}_vm_snapshot.S",
      "snapshot.h",
    ]
  }
}

create_aot_snapshot("dart_aot_snapshot_cc") {
  product = false
}

create_aot_snapshot("dart_aot_product_snapshot_cc") {
  product = true
}