|  | # Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file | 
|  | # for details. All rights reserved. Use of this source code is governed by a | 
|  | # BSD-style license that can be found in the LICENSE file. | 
|  |  | 
|  | import("../../build/dart/dart_action.gni") | 
|  | import("../../runtime/runtime_args.gni") | 
|  | import("../../sdk_args.gni") | 
|  | import("../aot_snapshot.gni") | 
|  | import("../application_snapshot.gni") | 
|  | import("../create_timestamp.gni") | 
|  |  | 
|  | group("kernel-service") { | 
|  | if (dart_snapshot_kind == "app-jit") { | 
|  | deps = [ ":copy_kernel-service_snapshot" ] | 
|  | } else { | 
|  | deps = [ ":kernel_service_dill" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | application_snapshot("kernel-service_snapshot") { | 
|  | main_dart = "../../pkg/vm/bin/kernel_service.dart" | 
|  | training_args = [ | 
|  | "--train", | 
|  |  | 
|  | # Force triple-slashes both on Windows and otherwise. | 
|  | # Becomes e.g. file:///full/path/to/file and "file:///C:/full/path/to/file. | 
|  | # Without the ', "/"' part, on Linux it would get four slashes. | 
|  | "file:///" + rebase_path("../../pkg/vm/bin/kernel_service.dart", "/"), | 
|  | ] | 
|  | output = "$root_gen_dir/kernel-service.dart.snapshot" | 
|  | } | 
|  |  | 
|  | copy("copy_kernel-service_snapshot") { | 
|  | deps = [ ":kernel-service_snapshot" ] | 
|  | sources = [ "$root_gen_dir/kernel-service.dart.snapshot" ] | 
|  | outputs = [ "$root_out_dir/kernel-service.dart.snapshot" ] | 
|  | } | 
|  |  | 
|  | create_timestamp_file("frontend_server_files_stamp") { | 
|  | path = rebase_path("../../pkg/frontend_server/lib") | 
|  | output = "$target_gen_dir/frontend_server_files.stamp" | 
|  | } | 
|  |  | 
|  | create_timestamp_file("ddc_files_stamp") { | 
|  | path = rebase_path("../../pkg/dev_compiler/lib") | 
|  | output = "$target_gen_dir/ddc_files.stamp" | 
|  | } | 
|  |  | 
|  | application_snapshot("frontend_server") { | 
|  | main_dart = "../../pkg/frontend_server/bin/frontend_server_starter.dart" | 
|  | deps = [ | 
|  | ":ddc_files_stamp", | 
|  | ":frontend_server_files_stamp", | 
|  | "../../runtime/vm:kernel_platform_files($host_toolchain)", | 
|  | ] | 
|  | sdk_root = rebase_path("$root_out_dir") | 
|  | training_args = [ | 
|  | "--train", | 
|  | "--sdk-root=$sdk_root/", | 
|  | "--platform=$sdk_root/vm_platform_strong.dill", | 
|  | rebase_path(main_dart), | 
|  | ] | 
|  | output = "$root_out_dir/frontend_server.dart.snapshot" | 
|  | } | 
|  |  | 
|  | aot_snapshot("frontend_server_aot") { | 
|  | main_dart = "../../pkg/frontend_server/bin/frontend_server_starter.dart" | 
|  | name = "frontend_server_aot" | 
|  | output = "$root_out_dir/frontend_server_aot.dart.snapshot" | 
|  |  | 
|  | # dartaotruntime has dart_product_config applied to it, so it is built in | 
|  | # product mode in both release and product builds, and is only built in debug | 
|  | # mode in debug builds. The following line ensures that the dartaotruntime and | 
|  | # frontend_server_aot snapshot in an SDK build are always compatible with | 
|  | # each other. | 
|  | force_product_mode = !dart_debug | 
|  | } | 
|  |  | 
|  | template("kernel_service_dill") { | 
|  | prebuilt_dart_action("kernel_service" + target_name + "_dill") { | 
|  | deps = [ | 
|  | "../../runtime/vm:kernel_platform_files($host_toolchain)", | 
|  | "../../runtime/vm:vm_platform", | 
|  | ] | 
|  | kernel_service_script = "../../pkg/vm/bin/kernel_service.dart" | 
|  | gen_kernel_script = "../../pkg/vm/bin/gen_kernel.dart" | 
|  |  | 
|  | inputs = [ | 
|  | gen_kernel_script, | 
|  | kernel_service_script, | 
|  | "$root_out_dir/vm_platform_strong.dill", | 
|  | ] | 
|  | output = "$root_gen_dir/kernel_service" + invoker.target_name + ".dill" | 
|  | outputs = [ output ] | 
|  |  | 
|  | depfile = "$root_gen_dir/kernel_service" + invoker.target_name + "_dill.d" | 
|  |  | 
|  | vm_args = [ | 
|  | "--depfile=" + rebase_path(depfile, root_build_dir), | 
|  | "--depfile_output_filename=" + rebase_path(output, root_build_dir), | 
|  |  | 
|  | # Ensure gen_kernel.dart will use this SDK hash when consuming/producing | 
|  | # kernel. | 
|  | "-Dsdk_hash=$sdk_hash", | 
|  | ] | 
|  |  | 
|  | script = gen_kernel_script | 
|  | scheme = "org-dartlang-kernel-service" | 
|  |  | 
|  | args = | 
|  | invoker.extra_args + [ | 
|  | # Ensure the compiled kernel-service will use this SDK hash when | 
|  | # consuming/producing kernel. | 
|  | "-Dsdk_hash=$sdk_hash", | 
|  |  | 
|  | "--packages=" + scheme + ":///.dart_tool/package_config.json", | 
|  | "--platform=" + rebase_path("$root_out_dir/vm_platform_strong.dill", | 
|  | root_build_dir), | 
|  | "--filesystem-root=" + rebase_path("../../"), | 
|  | "--filesystem-scheme=" + scheme, | 
|  | "--no-aot", | 
|  | "--no-embed-sources", | 
|  | "--output=" + rebase_path(output, root_build_dir), | 
|  | ] | 
|  | args += [ scheme + ":///pkg/vm/bin/kernel_service.dart" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | kernel_service_dill("") { | 
|  | extra_args = [] | 
|  | } |