| # Copyright (c) 2014, 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/executable_suffix.gni") | 
 | import("../../build/prebuilt_dart_sdk.gni") | 
 | import("../../sdk/lib/async/async_sources.gni") | 
 | import("../../sdk/lib/collection/collection_sources.gni") | 
 | import("../../sdk/lib/convert/convert_sources.gni") | 
 | import("../../sdk/lib/core/core_sources.gni") | 
 | import("../../sdk/lib/developer/developer_sources.gni") | 
 | import("../../sdk/lib/internal/internal_sources.gni") | 
 | import("../../sdk/lib/isolate/isolate_sources.gni") | 
 | import("../../sdk/lib/math/math_sources.gni") | 
 | import("../../sdk/lib/mirrors/mirrors_sources.gni") | 
 | import("../../sdk/lib/profiler/profiler_sources.gni") | 
 | import("../../sdk/lib/typed_data/typed_data_sources.gni") | 
 | import("../../sdk/lib/vmservice/vmservice_sources.gni") | 
 | import("../../utils/compile_platform.gni") | 
 | import("../bin/io_sources.gni") | 
 | import("../bin/cli_sources.gni") | 
 | import("../lib/async_sources.gni") | 
 | import("../lib/collection_sources.gni") | 
 | import("../lib/convert_sources.gni") | 
 | import("../lib/core_sources.gni") | 
 | import("../lib/developer_sources.gni") | 
 | import("../lib/internal_sources.gni") | 
 | import("../lib/isolate_sources.gni") | 
 | import("../lib/math_sources.gni") | 
 | import("../lib/mirrors_sources.gni") | 
 | import("../lib/profiler_sources.gni") | 
 | import("../lib/typed_data_sources.gni") | 
 | import("../lib/vmservice_sources.gni") | 
 | import("../runtime_args.gni") | 
 | import("compiler/compiler_sources.gni") | 
 | import("vm_sources.gni") | 
 |  | 
 | config("libdart_vm_config") { | 
 |   if (is_fuchsia) { | 
 |     libs = [ "zircon" ] | 
 |   } else if (is_win) { | 
 |     libs = [ | 
 |       "advapi32.lib", | 
 |       "shell32.lib", | 
 |       "dbghelp.lib", | 
 |     ] | 
 |   } else { | 
 |     libs = [ "dl" ] | 
 |     if (!is_android) { | 
 |       libs += [ "pthread" ] | 
 |     } | 
 |     if (is_linux) { | 
 |       libs += [ "rt" ] | 
 |     } | 
 |   } | 
 | } | 
 |  | 
 | template("build_libdart_vm") { | 
 |   extra_configs = [] | 
 |   if (defined(invoker.extra_configs)) { | 
 |     extra_configs += invoker.extra_configs | 
 |   } | 
 |   source_set(target_name) { | 
 |     configs += [ | 
 |                  "..:dart_arch_config", | 
 |                  "..:dart_config", | 
 |                ] + extra_configs | 
 |     if (is_fuchsia) { | 
 |       configs -= [ "//build/config:symbol_visibility_hidden" ] | 
 |       deps = [ | 
 |         # TODO(US-399): Remove time_service specific code when it is no longer | 
 |         # necessary. | 
 |         "//garnet/public/lib/app/cpp", | 
 |         "//garnet/public/lib/time_zone/fidl", | 
 |  | 
 |         # TODO(zra): When the platform-specific timeline code is moved out to | 
 |         # the embedder, this can go away. | 
 |         "//zircon/public/lib/fbl", | 
 |         "//zircon/public/lib/trace-engine", | 
 |       ] | 
 |     } | 
 |     public_configs = [ ":libdart_vm_config" ] | 
 |     set_sources_assignment_filter([ | 
 |                                     "*_test.cc", | 
 |                                     "*_test.h", | 
 |                                   ]) | 
 |     sources = vm_sources + rebase_path(compiler_sources, ".", "./compiler/") | 
 |     include_dirs = [ ".." ] | 
 |   } | 
 | } | 
 |  | 
 | build_libdart_vm("libdart_vm_jit") { | 
 |   extra_configs = [ | 
 |     "..:dart_maybe_product_config", | 
 |     "..:dart_os_config", | 
 |   ] | 
 | } | 
 |  | 
 | build_libdart_vm("libdart_vm_jit_product") { | 
 |   extra_configs = [ | 
 |     "..:dart_product_config", | 
 |     "..:dart_os_config", | 
 |   ] | 
 | } | 
 |  | 
 | build_libdart_vm("libdart_vm_precompiled_runtime") { | 
 |   extra_configs = [ | 
 |     "..:dart_maybe_product_config", | 
 |     "..:dart_precompiled_runtime_config", | 
 |     "..:dart_os_config", | 
 |   ] | 
 | } | 
 |  | 
 | build_libdart_vm("libdart_vm_precompiled_runtime_product") { | 
 |   extra_configs = [ | 
 |     "..:dart_product_config", | 
 |     "..:dart_precompiled_runtime_config", | 
 |     "..:dart_os_config", | 
 |   ] | 
 | } | 
 |  | 
 | build_libdart_vm("libdart_vm_nosnapshot") { | 
 |   extra_configs = [ | 
 |     "..:dart_maybe_product_config", | 
 |     "..:dart_no_snapshot_config", | 
 |     "..:dart_os_config", | 
 |   ] | 
 | } | 
 |  | 
 | build_libdart_vm("libdart_vm_nosnapshot_with_precompiler") { | 
 |   extra_configs = [ | 
 |     "..:dart_maybe_product_config", | 
 |     "..:dart_precompiler_config", | 
 |     "..:dart_no_snapshot_config", | 
 |     "..:dart_os_config", | 
 |   ] | 
 | } | 
 |  | 
 | build_libdart_vm("libdart_vm_nosnapshot_with_precompiler_product") { | 
 |   extra_configs = [ | 
 |     "..:dart_product_config", | 
 |     "..:dart_precompiler_config", | 
 |     "..:dart_no_snapshot_config", | 
 |     "..:dart_os_config", | 
 |   ] | 
 | } | 
 |  | 
 | build_libdart_vm("libdart_vm_nosnapshot_with_precompiler_fuchsia") { | 
 |   extra_configs = [ | 
 |     "..:dart_maybe_product_config", | 
 |     "..:dart_precompiler_config", | 
 |     "..:dart_no_snapshot_config", | 
 |     "..:dart_os_fuchsia_config", | 
 |   ] | 
 | } | 
 |  | 
 | build_libdart_vm("libdart_vm_nosnapshot_with_precompiler_product_fuchsia") { | 
 |   extra_configs = [ | 
 |     "..:dart_product_config", | 
 |     "..:dart_precompiler_config", | 
 |     "..:dart_no_snapshot_config", | 
 |     "..:dart_os_fuchsia_config", | 
 |   ] | 
 | } | 
 |  | 
 | build_libdart_vm("libdart_vm_with_precompiler") { | 
 |   extra_configs = [ | 
 |     "..:dart_maybe_product_config", | 
 |     "..:dart_precompiler_config", | 
 |     "..:dart_os_config", | 
 |   ] | 
 | } | 
 |  | 
 | build_libdart_vm("libdart_vm_with_precompiler_product") { | 
 |   extra_configs = [ | 
 |     "..:dart_product_config", | 
 |     "..:dart_precompiler_config", | 
 |     "..:dart_os_config", | 
 |   ] | 
 | } | 
 |  | 
 | template("process_library_source") { | 
 |   assert(defined(invoker.libsources), "Need libsources in $target_name") | 
 |   assert(defined(invoker.output), "Need output in $target_name") | 
 |   action(target_name) { | 
 |     visibility = [ ":*" ]  # Only targets in this file can see this. | 
 |     libsources = invoker.libsources | 
 |  | 
 |     script = invoker.script | 
 |     inputs = invoker.inputs + libsources | 
 |     outputs = [ | 
 |       invoker.output, | 
 |     ] | 
 |     args = invoker.args + rebase_path(libsources, root_build_dir) | 
 |   } | 
 | } | 
 |  | 
 | template("generate_library_source") { | 
 |   assert(defined(invoker.libname), "Need libname in $target_name") | 
 |   assert(defined(invoker.libsources), "Need libsources in $target_name") | 
 |   assert(defined(invoker.kind), "Need kind in $target_name") | 
 |   assert(defined(invoker.output), "Need output in $target_name") | 
 |  | 
 |   process_library_source(target_name) { | 
 |     libname = invoker.libname | 
 |     libsources = invoker.libsources | 
 |     kind = invoker.kind | 
 |     script = "../tools/gen_library_src_paths.py" | 
 |     inputs = [ | 
 |       "../lib/libgen_in.cc", | 
 |     ] | 
 |     output = invoker.output | 
 |     args = [ | 
 |       "--output", | 
 |       rebase_path(invoker.output, root_build_dir), | 
 |       "--input_cc", | 
 |       rebase_path("../lib/libgen_in.cc", root_build_dir), | 
 |       "--include", | 
 |       "vm/bootstrap.h", | 
 |       "--var_name", | 
 |       "dart::Bootstrap::${libname}_${kind}_paths_", | 
 |       "--library_name", | 
 |       "dart:${libname}", | 
 |     ] | 
 |   } | 
 | } | 
 |  | 
 | template("build_libdart_lib") { | 
 |   extra_configs = [] | 
 |   if (defined(invoker.extra_configs)) { | 
 |     extra_configs += invoker.extra_configs | 
 |   } | 
 |   extra_deps = [] | 
 |   if (defined(invoker.extra_deps)) { | 
 |     extra_deps += invoker.extra_deps | 
 |   } | 
 |   extra_sources = [] | 
 |   if (defined(invoker.extra_sources)) { | 
 |     extra_sources += invoker.extra_sources | 
 |   } | 
 |   source_set(target_name) { | 
 |     configs += [ | 
 |                  "..:dart_arch_config", | 
 |                  "..:dart_config", | 
 |                ] + extra_configs | 
 |     if (is_fuchsia) { | 
 |       configs -= [ "//build/config:symbol_visibility_hidden" ] | 
 |     } | 
 |     deps = extra_deps | 
 |     sources = extra_sources | 
 |     include_dirs = [ ".." ] | 
 |   } | 
 | } | 
 |  | 
 | # This templates expects invoker.sources to be a list of lists. | 
 | # The lists contain the following information about each library: | 
 | #   library name (string) | 
 | #   library sources (list of strings) | 
 | #   library source base path (string) | 
 | #   filename (string) | 
 | #   do_patch (boolean) | 
 | # | 
 | # If do_patch is true, the lists additionally contains | 
 | #   patch sources (list of strings) | 
 | #   patch source base path (string) | 
 | # | 
 | # The template iterates over the list, and generates generate_library_source | 
 | # actions for each. After that, it generates targets to compile the generated | 
 | # sources to make libdart_lib_*. | 
 | template("generate_core_libraries") { | 
 |   assert(defined(invoker.sources), "Need sources in $target_name") | 
 |   assert(defined(invoker.allsources), "Need allsources in $target_name") | 
 |   liboutputs = [] | 
 |   libdeps = [] | 
 |   foreach(lib, invoker.sources) { | 
 |     libname = lib[0] | 
 |     filename = lib[3] | 
 |     do_patch = lib[4] | 
 |     generate_library_source("generate_${filename}_cc_file") { | 
 |       libname = libname | 
 |       libsources = rebase_path(lib[1], ".", lib[2]) | 
 |       kind = "source" | 
 |       output = "$target_gen_dir/${filename}_gen.cc" | 
 |     } | 
 |     if (do_patch) { | 
 |       generate_library_source("generate_${filename}_patch_cc_file") { | 
 |         libname = libname | 
 |         libsources = rebase_path(lib[5], ".", lib[6]) | 
 |         kind = "patch" | 
 |         output = "$target_gen_dir/${filename}_patch_gen.cc" | 
 |       } | 
 |     } | 
 |  | 
 |     liboutputs += [ "$target_gen_dir/${filename}_gen.cc" ] | 
 |     libdeps += [ ":generate_${filename}_cc_file" ] | 
 |     if (do_patch) { | 
 |       liboutputs += [ "$target_gen_dir/${filename}_patch_gen.cc" ] | 
 |       libdeps += [ ":generate_${filename}_patch_cc_file" ] | 
 |     } | 
 |   } | 
 |  | 
 |   all_libsources = rebase_path(invoker.allsources, ".", "../lib") | 
 |  | 
 |   build_libdart_lib("libdart_lib_nosnapshot_with_precompiler") { | 
 |     extra_configs = [ | 
 |       "..:dart_maybe_product_config", | 
 |       "..:dart_precompiler_config", | 
 |       "..:dart_os_config", | 
 |     ] | 
 |     extra_deps = libdeps | 
 |     extra_sources = all_libsources + [ "bootstrap.cc" ] + liboutputs | 
 |   } | 
 |  | 
 |   build_libdart_lib("libdart_lib_nosnapshot_with_precompiler_product") { | 
 |     extra_configs = [ | 
 |       "..:dart_product_config", | 
 |       "..:dart_precompiler_config", | 
 |       "..:dart_os_config", | 
 |     ] | 
 |     extra_deps = libdeps | 
 |     extra_sources = all_libsources + [ "bootstrap.cc" ] + liboutputs | 
 |   } | 
 |  | 
 |   build_libdart_lib("libdart_lib_nosnapshot_with_precompiler_fuchsia") { | 
 |     extra_configs = [ | 
 |       "..:dart_maybe_product_config", | 
 |       "..:dart_precompiler_config", | 
 |       "..:dart_os_fuchsia_config", | 
 |     ] | 
 |     extra_deps = libdeps | 
 |     extra_sources = all_libsources + [ "bootstrap.cc" ] + liboutputs | 
 |   } | 
 |  | 
 |   build_libdart_lib("libdart_lib_nosnapshot_with_precompiler_product_fuchsia") { | 
 |     extra_configs = [ | 
 |       "..:dart_product_config", | 
 |       "..:dart_precompiler_config", | 
 |       "..:dart_os_fuchsia_config", | 
 |     ] | 
 |     extra_deps = libdeps | 
 |     extra_sources = all_libsources + [ "bootstrap.cc" ] + liboutputs | 
 |   } | 
 |  | 
 |   build_libdart_lib("libdart_lib_with_precompiler") { | 
 |     extra_configs = [ | 
 |       "..:dart_maybe_product_config", | 
 |       "..:dart_precompiler_config", | 
 |       "..:dart_os_config", | 
 |     ] | 
 |     extra_deps = libdeps | 
 |     extra_sources = all_libsources + [ "bootstrap_nocore.cc" ] | 
 |   } | 
 |  | 
 |   build_libdart_lib("libdart_lib_with_precompiler_product") { | 
 |     extra_configs = [ | 
 |       "..:dart_product_config", | 
 |       "..:dart_precompiler_config", | 
 |       "..:dart_os_config", | 
 |     ] | 
 |     extra_deps = libdeps | 
 |     extra_sources = all_libsources + [ "bootstrap_nocore.cc" ] | 
 |   } | 
 |  | 
 |   build_libdart_lib("libdart_lib_jit") { | 
 |     extra_configs = [ | 
 |       "..:dart_maybe_product_config", | 
 |       "..:dart_os_config", | 
 |     ] | 
 |     extra_sources = all_libsources + [ "bootstrap_nocore.cc" ] | 
 |   } | 
 |  | 
 |   build_libdart_lib("libdart_lib_jit_product") { | 
 |     extra_configs = [ | 
 |       "..:dart_product_config", | 
 |       "..:dart_os_config", | 
 |     ] | 
 |     extra_sources = all_libsources + [ "bootstrap_nocore.cc" ] | 
 |   } | 
 |  | 
 |   build_libdart_lib("libdart_lib_precompiled_runtime") { | 
 |     extra_configs = [ | 
 |       "..:dart_maybe_product_config", | 
 |       "..:dart_precompiled_runtime_config", | 
 |       "..:dart_os_config", | 
 |     ] | 
 |     extra_sources = all_libsources + [ "bootstrap_nocore.cc" ] | 
 |   } | 
 |  | 
 |   build_libdart_lib("libdart_lib_precompiled_runtime_product") { | 
 |     extra_configs = [ | 
 |       "..:dart_product_config", | 
 |       "..:dart_precompiled_runtime_config", | 
 |       "..:dart_os_config", | 
 |     ] | 
 |     extra_sources = all_libsources + [ "bootstrap_nocore.cc" ] | 
 |   } | 
 | } | 
 |  | 
 | generate_core_libraries("core_libraries") { | 
 |   sources = [ | 
 |     [ | 
 |       "async", | 
 |       async_sdk_sources, | 
 |       "../../sdk/lib/async", | 
 |       "async", | 
 |       true, | 
 |       async_runtime_sources, | 
 |       "../lib", | 
 |     ], | 
 |     [ | 
 |       "collection", | 
 |       collection_sdk_sources, | 
 |       "../../sdk/lib/collection", | 
 |       "collection", | 
 |       true, | 
 |       collection_runtime_sources, | 
 |       "../lib", | 
 |     ], | 
 |     [ | 
 |       "convert", | 
 |       convert_sdk_sources, | 
 |       "../../sdk/lib/convert", | 
 |       "convert", | 
 |       true, | 
 |       convert_runtime_sources, | 
 |       "../lib", | 
 |     ], | 
 |     [ | 
 |       "core", | 
 |       core_sdk_sources, | 
 |       "../../sdk/lib/core", | 
 |       "core", | 
 |       true, | 
 |       core_runtime_sources, | 
 |       "../lib", | 
 |     ], | 
 |     [ | 
 |       "developer", | 
 |       developer_sdk_sources, | 
 |       "../../sdk/lib/developer", | 
 |       "developer", | 
 |       true, | 
 |       developer_runtime_sources, | 
 |       "../lib", | 
 |     ], | 
 |     [ | 
 |       "_internal", | 
 |       internal_sdk_sources, | 
 |       "../../sdk/lib/internal", | 
 |       "internal", | 
 |       true, | 
 |       internal_runtime_sources, | 
 |       "../lib", | 
 |     ], | 
 |     [ | 
 |       "isolate", | 
 |       isolate_sdk_sources, | 
 |       "../../sdk/lib/isolate", | 
 |       "isolate", | 
 |       true, | 
 |       isolate_runtime_sources, | 
 |       "../lib", | 
 |     ], | 
 |     [ | 
 |       "math", | 
 |       math_sdk_sources, | 
 |       "../../sdk/lib/math", | 
 |       "math", | 
 |       true, | 
 |       math_runtime_sources, | 
 |       "../lib", | 
 |     ], | 
 |     [ | 
 |       "mirrors", | 
 |       mirrors_sdk_sources, | 
 |       "../../sdk/lib/mirrors", | 
 |       "mirrors", | 
 |       true, | 
 |       mirrors_runtime_sources, | 
 |       "../lib", | 
 |     ], | 
 |     [ | 
 |       "profiler", | 
 |       profiler_sdk_sources, | 
 |       "../../sdk/lib/profiler", | 
 |       "profiler", | 
 |       false, | 
 |     ], | 
 |     [ | 
 |       "typed_data", | 
 |       typed_data_sdk_sources, | 
 |       "../../sdk/lib/typed_data", | 
 |       "typed_data", | 
 |       true, | 
 |       typed_data_runtime_sources, | 
 |       "../lib", | 
 |     ], | 
 |     [ | 
 |       "_vmservice", | 
 |       vmservice_sdk_sources, | 
 |       "../../sdk/lib/vmservice", | 
 |       "vmservice", | 
 |       true, | 
 |       vmservice_runtime_sources, | 
 |       "../lib", | 
 |     ], | 
 |   ] | 
 |   allsources = async_runtime_sources + collection_runtime_sources + | 
 |                convert_runtime_sources + core_runtime_sources + | 
 |                developer_runtime_sources + internal_runtime_sources + | 
 |                isolate_runtime_sources + math_runtime_sources + | 
 |                mirrors_runtime_sources + profiler_runtime_sources + | 
 |                typed_data_runtime_sources + vmservice_runtime_sources | 
 | } | 
 |  | 
 | compile_platform("vm_legacy_platform") { | 
 |   sources = [ | 
 |     "../../sdk/lib/libraries.json", | 
 |   ] | 
 |  | 
 |   outputs = [ | 
 |     "$root_out_dir/vm_platform.dill", | 
 |     "$root_out_dir/vm_outline.dill", | 
 |   ] | 
 |  | 
 |   inputs = [ | 
 |     "../../sdk/lib/libraries.yaml", | 
 |   ] | 
 |  | 
 |   args = [ "dart:core" ] | 
 | } | 
 |  | 
 | compile_platform("vm_platform") { | 
 |   sources = [ | 
 |     "../../sdk/lib/libraries.json", | 
 |   ] | 
 |  | 
 |   outputs = [ | 
 |     "$root_out_dir/vm_platform_strong.dill", | 
 |     "$root_out_dir/vm_outline_strong.dill", | 
 |   ] | 
 |  | 
 |   args = [ | 
 |     "--strong-mode", | 
 |     "dart:core", | 
 |   ] | 
 | } | 
 |  | 
 | group("kernel_platform_files") { | 
 |   public_deps = [ | 
 |     ":vm_legacy_platform", | 
 |     ":vm_platform", | 
 |   ] | 
 | } |