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

5
import("$flutter_root/lib/ui/dart_ui.gni")
6
import("//build/compiled_action.gni")
7
import("//third_party/dart/utils/compile_platform.gni")
8

9
if (is_fuchsia) {
10
  import("//build/dart/dart_library.gni")
11
  import("//build/dart/toolchain.gni")
12 13
  import("//topaz/public/dart-pkg/fuchsia/sdk_ext.gni")
  import("//topaz/public/dart-pkg/zircon/sdk_ext.gni")
14
  import("//topaz/public/lib/ui/flutter/sdk_ext/sdk_ext.gni")
15
}
16 17 18 19 20 21 22 23 24 25 26

bindings_output_dir = "$root_gen_dir/sky/bindings"

copy("generate_dart_ui") {
  sources = dart_ui_files

  outputs = [
    "$bindings_output_dir/dart_ui/{{source_file_part}}",
  ]
}

27 28
compiled_action("generate_snapshot_bin") {
  tool = "//third_party/dart/runtime/bin:gen_snapshot"
29

30 31 32
  if (is_fuchsia || is_fuchsia_host) {
    platform_kernel = "$root_out_dir/flutter_runner_patched_sdk/platform_strong.dill"
  } else {
33 34
    platform_kernel = "$root_out_dir/flutter_patched_sdk/platform_strong.dill"
  }
35

36 37 38 39 40 41
  inputs = [
    platform_kernel,
  ]
  deps = [
    ":kernel_platform_files",
  ]
42

43 44 45 46 47 48 49 50 51 52 53
  vm_snapshot_data = "$target_gen_dir/vm_isolate_snapshot.bin"
  vm_snapshot_instructions = "$target_gen_dir/vm_snapshot_instructions.bin"
  isolate_snapshot_data = "$target_gen_dir/isolate_snapshot.bin"
  isolate_snapshot_instructions =
      "$target_gen_dir/isolate_snapshot_instructions.bin"
  outputs = [
    vm_snapshot_data,
    vm_snapshot_instructions,
    isolate_snapshot_data,
    isolate_snapshot_instructions,
  ]
54

55 56 57 58 59 60 61 62 63 64 65 66 67 68
  args = [
    "--strong",
    "--sync-async",
    "--reify-generic-functions",
    "--snapshot_kind=core",
    "--await_is_keyword",
    "--enable_mirrors=false",
    "--vm_snapshot_data=" + rebase_path(vm_snapshot_data),
    "--vm_snapshot_instructions=" + rebase_path(vm_snapshot_instructions),
    "--isolate_snapshot_data=" + rebase_path(isolate_snapshot_data),
    "--isolate_snapshot_instructions=" +
        rebase_path(isolate_snapshot_instructions),
    rebase_path(platform_kernel),
  ]
69

70 71 72 73 74 75
  if (is_debug) {
    args += [
      "--enable_asserts",
      "--enable_type_checks",
      "--error_on_bad_type",
      "--error_on_bad_override",
76 77
    ]
  }
78
}
79

80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
# Generates an assembly file defining a given symbol with the bytes from a
# binary file. Places the symbol in a text section if 'executable' is true,
# otherwise places the symbol in a read-only data section.
template("bin_to_assembly") {
  assert(defined(invoker.deps), "Must define deps")
  assert(defined(invoker.input), "Must define input binary file")
  assert(defined(invoker.output), "Must define output assembly file")
  assert(defined(invoker.symbol), "Must define symbol name")
  assert(defined(invoker.executable), "Must define boolean executable")

  action(target_name) {
    deps = invoker.deps
    script = "//third_party/dart/runtime/tools/bin_to_assembly.py"
    args = [
      "--input",
      rebase_path(invoker.input),
      "--output",
      rebase_path(invoker.output),
      "--symbol_name",
      invoker.symbol,
      "--target_os",
      current_os,
102
    ]
103 104 105 106 107 108
    if (invoker.executable) {
      args += [ "--executable" ]
    }
    inputs = [
      script,
      invoker.input,
109
    ]
110 111
    outputs = [
      invoker.output,
112 113 114 115
    ]
  }
}

116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
bin_to_assembly("vm_snapshot_data_assembly") {
  deps = [
    ":generate_snapshot_bin",
  ]
  input = "$target_gen_dir/vm_isolate_snapshot.bin"
  output = "$target_gen_dir/vm_snapshot_data.S"
  symbol = "kDartVmSnapshotData"
  executable = false
}

bin_to_assembly("vm_snapshot_instructions_assembly") {
  deps = [
    ":generate_snapshot_bin",
  ]
  input = "$target_gen_dir/vm_snapshot_instructions.bin"
  output = "$target_gen_dir/vm_snapshot_instructions.S"
  symbol = "kDartVmSnapshotInstructions"
  executable = true
}

bin_to_assembly("isolate_snapshot_data_assembly") {
  deps = [
    ":generate_snapshot_bin",
  ]
  input = "$target_gen_dir/isolate_snapshot.bin"
  output = "$target_gen_dir/isolate_snapshot_data.S"
  symbol = "kDartIsolateSnapshotData"
  executable = false
}

bin_to_assembly("isolate_snapshot_instructions_assembly") {
  deps = [
    ":generate_snapshot_bin",
  ]
  input = "$target_gen_dir/isolate_snapshot_instructions.bin"
  output = "$target_gen_dir/isolate_snapshot_instructions.S"
  symbol = "kDartIsolateSnapshotInstructions"
  executable = true
}

source_set("snapshot") {
  deps = [
    ":isolate_snapshot_data_assembly",
    ":isolate_snapshot_instructions_assembly",
    ":vm_snapshot_data_assembly",
    ":vm_snapshot_instructions_assembly",
  ]
  sources = [
    "$target_gen_dir/isolate_snapshot_data.S",
    "$target_gen_dir/isolate_snapshot_instructions.S",
    "$target_gen_dir/vm_snapshot_data.S",
    "$target_gen_dir/vm_snapshot_instructions.S",
  ]
}

171
compile_platform("non_strong_platform") {
172 173 174
  single_root_scheme = "org-dartlang-sdk"
  single_root_base = rebase_path("../../../")
  libraries_specification_uri = "org-dartlang-sdk:///flutter/lib/snapshot/libraries.json"
175 176 177 178 179 180 181

  outputs = [
    "$root_out_dir/flutter_patched_sdk/platform.dill",
    "$root_out_dir/flutter_patched_sdk/vm_outline.dill",
  ]

  args = [
182 183 184
    "--target=flutter",
    "dart:core",
  ]
185 186
}

187
compile_platform("strong_platform") {
188 189 190
  single_root_scheme = "org-dartlang-sdk"
  single_root_base = rebase_path("../../../")
  libraries_specification_uri = "org-dartlang-sdk:///flutter/lib/snapshot/libraries.json"
191 192 193 194 195 196 197

  outputs = [
    "$root_out_dir/flutter_patched_sdk/platform_strong.dill",
    "$root_out_dir/flutter_patched_sdk/vm_outline_strong.dill",
  ]

  args = [
198 199 200 201
    "--target=flutter",
    "--strong",
    "dart:core",
  ]
202 203
}

204 205 206 207 208 209 210 211 212 213 214 215 216 217
# Fuchsia's snapshot requires a different platform with extra dart: libraries.
if (is_fuchsia || is_fuchsia_host) {
  group("kernel_platform_files") {
    public_deps = [
      "//topaz/runtime/flutter_runner/kernel:kernel_platform_files"
    ]
  }
} else {
  group("kernel_platform_files") {
    public_deps = [
      ":non_strong_platform",
      ":strong_platform",
    ]
  }
218
}