BUILD.gn 7.9 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 9 10 11
import("//flutter/common/fuchsia_config.gni")
import("//flutter/tools/fuchsia/dart.gni")
import("//flutter/tools/fuchsia/fuchsia_archive.gni")
import("//flutter/tools/fuchsia/fuchsia_libs.gni")
12

13 14 15 16
template("runner") {
  assert(defined(invoker.product), "The parameter 'product' must be defined")
  assert(defined(invoker.output_name),
         "The parameter 'output_name' must be defined")
17

18 19
  invoker_output_name = invoker.output_name
  extra_defines = invoker.extra_defines
20
  extra_deps = invoker.extra_deps
21

22 23
  executable(target_name) {
    output_name = invoker_output_name
24 25 26 27 28 29 30 31 32 33 34 35 36 37

    sources = [
      "builtin_libraries.cc",
      "builtin_libraries.h",
      "dart_component_controller.cc",
      "dart_component_controller.h",
      "dart_runner.cc",
      "dart_runner.h",
      "logging.h",
      "main.cc",
      "service_isolate.cc",
      "service_isolate.h",
    ]

38 39 40 41
    defines = extra_defines

    dart_deps = []
    if (!invoker.product) {
42 43
      dart_deps += [
        "//third_party/dart/runtime/bin:dart_io_api",
44
        "//flutter/shell/platform/fuchsia/runtime/dart/utils:utils",
45
      ]
46
    } else {
47 48
      dart_deps += [
        "//third_party/dart/runtime/bin:dart_io_api_product",
49
        "//flutter/shell/platform/fuchsia/runtime/dart/utils:utils_product",
50
      ]
51 52 53
    }

    deps = [
54 55 56 57
             "//flutter/common",
             "//flutter/fml",
             "//flutter/shell/platform/fuchsia/dart-pkg/fuchsia",
             "//flutter/shell/platform/fuchsia/dart-pkg/zircon",
D
Dan Field 已提交
58
             "$fuchsia_sdk_root/pkg:async",
59
             "$fuchsia_sdk_root/pkg:async-cpp",
D
Dan Field 已提交
60
             "$fuchsia_sdk_root/pkg:async-default",
61 62
             "$fuchsia_sdk_root/pkg:async-loop",
             "$fuchsia_sdk_root/pkg:async-loop-cpp",
D
Dan Field 已提交
63
             "$fuchsia_sdk_root/pkg:async-loop-default",
64
             "$fuchsia_sdk_root/pkg:fidl_cpp",
65
             "$fuchsia_sdk_root/pkg:sys_cpp",
66
             "$fuchsia_sdk_root/pkg:syslog",
67 68
             "$fuchsia_sdk_root/pkg:trace",
             "$fuchsia_sdk_root/pkg:trace-provider-so",
69
             "$fuchsia_sdk_root/pkg:vfs_cpp",
70
             "//flutter/third_party/tonic",
71 72 73 74 75 76 77 78 79 80 81
           ] + dart_deps + extra_deps
  }
}

runner("dart_jit_runner_bin") {
  output_name = "dart_jit_runner"
  product = false
  extra_defines = []
  if (flutter_runtime_mode == "profile") {
    extra_defines += [ "FLUTTER_PROFILE" ]
  }
82 83 84 85
  extra_deps = [
    "//third_party/dart/runtime:libdart_jit",
    "//third_party/dart/runtime/platform:libdart_platform_jit",
  ]
86 87 88 89 90 91
}

runner("dart_jit_product_runner_bin") {
  output_name = "dart_jit_product_runner"
  product = true
  extra_defines = [ "DART_PRODUCT" ]
92 93 94 95
  extra_deps = [
    "//third_party/dart/runtime:libdart_jit_product",
    "//third_party/dart/runtime/platform:libdart_platform_jit_product",
  ]
96 97
}

98 99 100 101 102 103 104
runner("dart_aot_runner_bin") {
  output_name = "dart_aot_runner"
  product = false
  extra_defines = [ "AOT_RUNTIME" ]
  if (flutter_runtime_mode == "profile") {
    extra_defines += [ "FLUTTER_PROFILE" ]
  }
105 106 107 108 109
  extra_deps = [
    "embedder:dart_aot_snapshot_cc",
    "//third_party/dart/runtime:libdart_precompiled_runtime",
    "//third_party/dart/runtime/platform:libdart_platform_precompiled_runtime",
  ]
110 111 112 113 114 115 116 117 118
}

runner("dart_aot_product_runner_bin") {
  output_name = "dart_aot_product_runner"
  product = true
  extra_defines = [
    "AOT_RUNTIME",
    "DART_PRODUCT",
  ]
119 120 121 122 123
  extra_deps = [
    "embedder:dart_aot_product_snapshot_cc",
    "//third_party/dart/runtime:libdart_precompiled_runtime_product",
    "//third_party/dart/runtime/platform:libdart_platform_precompiled_runtime_product",
  ]
124 125
}

126 127 128 129 130 131 132 133 134 135 136 137 138
template("aot_runner_package") {
  assert(defined(invoker.product), "The parameter 'product' must be defined")
  product_suffix = ""
  if (invoker.product) {
    product_suffix = "_product"
  }
  fuchsia_archive(target_name) {
    deps = [
      ":dart_aot${product_suffix}_runner_bin",
    ]
    if (!invoker.product) {
      deps += [
        "vmservice:vmservice_snapshot",
139
        "//flutter/shell/platform/fuchsia/runtime/dart/profiler_symbols:dart_aot_runner",
140 141 142 143 144 145 146 147 148

        # TODO(kaushikiska): Figure out how to get the profiler symbols for `libdart_precompiled_runtime`
        # "//topaz/runtime/dart/profiler_symbols:libdart_precompiled_runtime",
        observatory_target,
      ]
    }

    binary = "dart_aot${product_suffix}_runner"

149
    meta_dir = "//flutter/shell/platform/fuchsia/dart_runner/meta"
150 151 152 153 154 155 156 157

    meta = [
      {
        path = rebase_path("meta/dart_aot${product_suffix}_runner.cmx")
        dest = "dart_aot${product_suffix}_runner.cmx"
      },
    ]

158 159
    libraries = common_libs

160 161
    resources = []
    if (!invoker.product) {
162
      vmservice_snapshot = rebase_path(
163
              get_label_info("vmservice:vmservice_snapshot", "target_gen_dir") +
164
              "/vmservice_snapshot.so")
165 166
      dart_profiler_symbols = rebase_path(
              get_label_info(
167
                  "//flutter/shell/platform/fuchsia/runtime/dart/profiler_symbols:dart_aot_runner",
168 169 170
                  "target_gen_dir") + "/dart_aot_runner.dartprofilersymbols")

      inputs = [
171
        vmservice_snapshot,
172 173 174 175 176 177
        observatory_archive_file,
        dart_profiler_symbols,
      ]

      resources += [
        {
178 179
          path = vmservice_snapshot
          dest = "vmservice_snapshot.so"
180 181 182 183 184 185 186 187 188 189 190 191 192 193
        },
        {
          path = rebase_path(observatory_archive_file)
          dest = "observatory.tar"
        },
        {
          path = dart_profiler_symbols
          dest = "dart_aot_runner.dartprofilersymbols"
        },
      ]
    }
  }
}

194 195 196 197 198 199 200
template("jit_runner_package") {
  assert(defined(invoker.product), "The parameter 'product' must be defined")
  product_suffix = ""
  if (invoker.product) {
    product_suffix = "_product"
  }

201
  fuchsia_archive(target_name) {
202
    deps = [
203
      ":dart_jit${product_suffix}_runner_bin",
204
      "kernel:kernel_core_snapshot${product_suffix}",
205 206 207
    ]

    if (!invoker.product) {
208
      deps += [
209
        "//flutter/shell/platform/fuchsia/runtime/dart/profiler_symbols:dart_jit_runner",
210 211
        observatory_target,
      ]
212 213 214 215
    }

    binary = "dart_jit${product_suffix}_runner"

216
    meta_dir = "//flutter/shell/platform/fuchsia/dart_runner/meta"
217 218 219 220 221

    libraries = common_libs

    resources = [
      {
222 223
        path =
            rebase_path("$target_gen_dir/kernel/vm_data${product_suffix}.bin")
224 225 226 227
        dest = "vm_snapshot_data.bin"
      },
      {
        path = rebase_path(
228
                "$target_gen_dir/kernel/vm_instructions${product_suffix}.bin")
229 230 231 232
        dest = "vm_snapshot_instructions.bin"
      },
      {
        path = rebase_path(
233
                "$target_gen_dir/kernel/isolate_data${product_suffix}.bin")
234 235 236 237
        dest = "isolate_core_snapshot_data.bin"
      },
      {
        path = rebase_path(
238
                "$target_gen_dir/kernel/isolate_instructions${product_suffix}.bin")
239 240 241 242 243 244 245
        dest = "isolate_core_snapshot_instructions.bin"
      },
    ]

    if (!invoker.product) {
      resources += [
        {
246
          path = rebase_path(observatory_archive_file)
247 248
          dest = "observatory.tar"
        },
249 250 251
        {
          path = rebase_path(
                  get_label_info(
252
                      "//flutter/shell/platform/fuchsia/runtime/dart/profiler_symbols:dart_jit_runner",
253 254 255
                      "target_gen_dir") + "/dart_jit_runner.dartprofilersymbols")
          dest = "dart_jit_runner.dartprofilersymbols"
        },
256 257 258 259 260 261 262 263
      ]
    }

    meta = [
      {
        path = rebase_path("meta/dart_jit${product_suffix}_runner.cmx")
        dest = "dart_jit${product_suffix}_runner.cmx"
      },
264 265 266
    ]
  }
}
267

268 269 270 271 272 273 274 275
aot_runner_package("dart_aot_runner") {
  product = false
}

aot_runner_package("dart_aot_product_runner") {
  product = true
}

276 277 278 279 280 281 282
jit_runner_package("dart_jit_runner") {
  product = false
}

jit_runner_package("dart_jit_product_runner") {
  product = true
}