| # 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. |
| |
| import("//flutter/lib/snapshot/toolchain.gni") |
| import("//flutter/lib/ui/dart_ui.gni") |
| |
| target_is_fuchsia = target_os == "fuchsia" |
| |
| if (target_is_fuchsia) { |
| import("//apps/mozart/lib/flutter/sdk_ext/sdk_ext.gni") |
| import("//lib/fidl/dart/sdk_ext/sdk_ext.gni") |
| } |
| |
| 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}}", |
| ] |
| } |
| |
| action("generate_snapshot_bin") { |
| if (target_is_fuchsia) { |
| snapshot_dart = "snapshot_fuchsia.dart" |
| } else { |
| snapshot_dart = "snapshot.dart" |
| } |
| |
| deps = [ |
| ":generate_dart_ui", |
| "//dart/runtime/bin:gen_snapshot($dart_host_toolchain)", |
| ] |
| inputs = [ |
| "//dart/runtime/tools/create_snapshot_bin.py", |
| snapshot_dart, |
| ] + dart_ui_files |
| |
| 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, |
| ] |
| |
| rebased_dart_ui_path = rebase_path(dart_ui_path) |
| |
| gen_snapshot_dir = |
| get_label_info("//dart/runtime/bin:gen_snapshot($dart_host_toolchain)", |
| "root_out_dir") |
| script = "//dart/runtime/tools/create_snapshot_bin.py" |
| |
| args = [ |
| "--executable", |
| rebase_path("$gen_snapshot_dir/gen_snapshot"), |
| "--package_root", |
| rebase_path("$root_gen_dir"), |
| "--script", |
| rebase_path(snapshot_dart), |
| "--snapshot_kind", |
| "core", |
| "--vm_output_bin", |
| rebase_path(vm_snapshot_data, root_build_dir), |
| "--vm_instructions_output_bin", |
| rebase_path(vm_snapshot_instructions, root_build_dir), |
| "--isolate_output_bin", |
| rebase_path(isolate_snapshot_data, root_build_dir), |
| "--isolate_instructions_output_bin", |
| rebase_path(isolate_snapshot_instructions, root_build_dir), |
| "--url_mapping=dart:ui,$rebased_dart_ui_path", |
| ] |
| |
| if (target_is_fuchsia) { |
| inputs += fidl_dart_sdk_ext_files + mozart_dart_sdk_ext_files |
| fidl_internal_path = rebase_path(fidl_dart_sdk_ext_lib) |
| mozart_internal_path = rebase_path(mozart_dart_sdk_ext_lib) |
| args += [ |
| "--url_mapping=dart:fidl.internal,$fidl_internal_path", |
| "--url_mapping=dart:mozart.internal,$mozart_internal_path", |
| ] |
| } |
| } |
| |
| # 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 = "//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, |
| ] |
| if (invoker.executable) { |
| args += [ "--executable" ] |
| } |
| inputs = [ |
| script, |
| invoker.input, |
| ] |
| outputs = [ |
| invoker.output, |
| ] |
| } |
| } |
| |
| 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 = "kDartIsolateCoreSnapshotData" |
| 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 = "kDartIsolateCoreSnapshotInstructions" |
| 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", |
| ] |
| } |