| # 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("gypi_contents.gni") |
| import("../runtime_args.gni") |
| |
| config("libdart_vm_config") { |
| if (defined(is_fuchsia) && is_fuchsia) { |
| libs = [ "magenta" ] |
| } else if (is_win) { |
| libs = [ |
| "advapi32.lib", |
| "shell32.lib", |
| "dbghelp.lib", |
| ] |
| } else { |
| libs = [ "dl" ] |
| if (!is_android) { |
| libs += [ "pthread" ] |
| } |
| if (is_linux) { |
| libs += [ "rt" ] |
| } |
| } |
| } |
| |
| static_library("libdart_platform") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| ] |
| public_configs = [ ":libdart_vm_config" ] |
| |
| sources = rebase_path(processed_gypis.platform_sources, ".", "../platform") |
| |
| include_dirs = [ ".." ] |
| } |
| |
| vm_sources_list = processed_gypis.vm_sources |
| |
| static_library("libdart_vm") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_maybe_precompiled_runtime_config", |
| ] |
| public_configs = [ ":libdart_vm_config" ] |
| set_sources_assignment_filter([ |
| "*_test.cc", |
| "*_test.h", |
| ]) |
| sources = vm_sources_list |
| include_dirs = [ ".." ] |
| } |
| |
| static_library("libdart_vm_precompiled_runtime") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_precompiled_runtime_config", |
| ] |
| public_configs = [ ":libdart_vm_config" ] |
| set_sources_assignment_filter([ |
| "*_test.cc", |
| "*_test.h", |
| ]) |
| sources = vm_sources_list |
| include_dirs = [ ".." ] |
| } |
| |
| static_library("libdart_vm_nosnapshot") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_no_snapshot_config", |
| ] |
| public_configs = [ ":libdart_vm_config" ] |
| set_sources_assignment_filter([ |
| "*_test.cc", |
| "*_test.h", |
| ]) |
| sources = vm_sources_list |
| include_dirs = [ ".." ] |
| } |
| |
| static_library("libdart_vm_nosnapshot_with_precompiler") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_precompiler_config", |
| "..:dart_no_snapshot_config", |
| ] |
| public_configs = [ ":libdart_vm_config" ] |
| set_sources_assignment_filter([ |
| "*_test.cc", |
| "*_test.h", |
| ]) |
| sources = vm_sources_list |
| include_dirs = [ ".." ] |
| } |
| |
| static_library("libdart_vm_with_precompiler") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_precompiler_config", |
| ] |
| public_configs = [ ":libdart_vm_config" ] |
| set_sources_assignment_filter([ |
| "*_test.cc", |
| "*_test.h", |
| ]) |
| sources = vm_sources_list |
| include_dirs = [ ".." ] |
| } |
| |
| 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}", |
| ] |
| } |
| } |
| |
| # 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") |
| |
| static_library("libdart_lib_nosnapshot") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_maybe_precompiled_runtime_config", |
| ] |
| deps = libdeps |
| sources = all_libsources + [ "bootstrap.cc" ] + liboutputs |
| include_dirs = [ ".." ] |
| } |
| static_library("libdart_lib_nosnapshot_with_precompiler") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_precompiler_config", |
| ] |
| deps = libdeps |
| sources = all_libsources + [ "bootstrap.cc" ] + liboutputs |
| include_dirs = [ ".." ] |
| } |
| static_library("libdart_lib_with_precompiler") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_precompiler_config", |
| ] |
| deps = libdeps |
| sources = all_libsources + [ "bootstrap_nocore.cc" ] |
| include_dirs = [ ".." ] |
| } |
| static_library("libdart_lib") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_maybe_precompiled_runtime_config", |
| ] |
| sources = all_libsources + [ "bootstrap_nocore.cc" ] |
| include_dirs = [ ".." ] |
| } |
| static_library("libdart_lib_precompiled_runtime") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_precompiled_runtime_config", |
| ] |
| sources = all_libsources + [ "bootstrap_nocore.cc" ] |
| include_dirs = [ ".." ] |
| } |
| } |
| |
| generate_core_libraries("core_libraries") { |
| sources = [ |
| [ |
| "async", |
| processed_gypis.async_sdk_sources, |
| "../../sdk/lib/async", |
| "async", |
| true, |
| processed_gypis.async_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "core", |
| processed_gypis.core_sdk_sources, |
| "../../sdk/lib/core", |
| "core", |
| true, |
| processed_gypis.core_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "collection", |
| processed_gypis.collection_sdk_sources, |
| "../../sdk/lib/collection", |
| "collection", |
| true, |
| processed_gypis.collection_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "convert", |
| processed_gypis.convert_sdk_sources, |
| "../../sdk/lib/convert", |
| "convert", |
| true, |
| processed_gypis.convert_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "developer", |
| processed_gypis.developer_sdk_sources, |
| "../../sdk/lib/developer", |
| "developer", |
| true, |
| processed_gypis.developer_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "_internal", |
| processed_gypis.internal_sdk_sources, |
| "../../sdk/lib/internal", |
| "internal", |
| true, |
| processed_gypis.internal_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "isolate", |
| processed_gypis.isolate_sdk_sources, |
| "../../sdk/lib/isolate", |
| "isolate", |
| true, |
| processed_gypis.isolate_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "math", |
| processed_gypis.math_sdk_sources, |
| "../../sdk/lib/math", |
| "math", |
| true, |
| processed_gypis.math_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "mirrors", |
| processed_gypis.mirrors_sdk_sources, |
| "../../sdk/lib/mirrors", |
| "mirrors", |
| true, |
| processed_gypis.mirrors_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "profiler", |
| processed_gypis.profiler_sdk_sources, |
| "../../sdk/lib/profiler", |
| "profiler", |
| false, |
| ], |
| [ |
| "typed_data", |
| processed_gypis.typed_data_sdk_sources, |
| "../../sdk/lib/typed_data", |
| "typed_data", |
| true, |
| processed_gypis.typed_data_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "_vmservice", |
| processed_gypis.vmservice_sdk_sources, |
| "../../sdk/lib/vmservice", |
| "vmservice", |
| true, |
| processed_gypis.vmservice_runtime_sources, |
| "../lib", |
| ], |
| ] |
| allsources = processed_gypis.allsources |
| } |
| |
| template("concatenate_patch") { |
| assert(defined(invoker.libsources), "Need a sources in $target_name") |
| assert(defined(invoker.output), "Need an output in $target_name") |
| |
| process_library_source(target_name) { |
| libsources = invoker.libsources |
| inputs = [] |
| output = invoker.output |
| script = "../tools/concatenate_patches.py" |
| args = [ |
| "--output", |
| rebase_path(output, root_build_dir), |
| ] |
| } |
| } |
| |
| template("generate_patched_sdk") { |
| assert(defined(invoker.libraries), "Need libraries in $target_name") |
| |
| concatenation_target_names = [] |
| |
| # Concatenate vm library patches. |
| foreach(library, invoker.libraries) { |
| name = library[0] |
| |
| target_output = "$target_gen_dir/patches/${name}_patch.dart" |
| concatenate_patch("concatenate_${name}_patch") { |
| libsources = rebase_path(library[1], ".", library[2]) |
| output = target_output |
| } |
| concatenation_target_names += [ ":concatenate_${name}_patch" ] |
| } |
| |
| # Build the patched sdk out of the concatenated patches and the special |
| # libraries. |
| action(target_name) { |
| deps = concatenation_target_names |
| if (!prebuilt_dart_exe_works) { |
| deps += [ "../bin:dart_bootstrap($host_toolchain)" ] |
| } |
| |
| patches_dir = "$target_gen_dir/patches" |
| patched_sdk_dir = "$root_out_dir/patched_sdk" |
| |
| script = "../../tools/patch_sdk.py" |
| |
| # We list the `patch_sdk.dart` tool here because the [script] (which is |
| # implicitly an input) will call it. |
| inputs = [ |
| "../../tools/patch_sdk.dart", |
| ] |
| depfile = "$root_out_dir/patched_sdk.d" |
| |
| outputs = [ |
| # Instead of listing all outputs we list a single well-known one. |
| "${patched_sdk_dir}/platform.dill", |
| ] |
| |
| args = [ "--quiet" ] |
| if (!prebuilt_dart_exe_works) { |
| dart_out_dir = get_label_info("../bin:dart_bootstrap($host_toolchain)", |
| "root_out_dir") |
| dart_bootstrap = |
| rebase_path("$dart_out_dir/dart_bootstrap$executable_suffix") |
| args += [ |
| "--dart-executable", |
| dart_bootstrap, |
| ] |
| } |
| args += [ |
| "vm", |
| rebase_path("../../sdk"), |
| rebase_path(patches_dir, root_build_dir), |
| rebase_path(patched_sdk_dir, root_build_dir), |
| rebase_path("../../.packages"), |
| ] |
| } |
| } |
| |
| generate_patched_sdk("patched_sdk") { |
| libraries = [ |
| [ |
| "async", |
| processed_gypis.async_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "collection", |
| processed_gypis.collection_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "convert", |
| processed_gypis.convert_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "core", |
| processed_gypis.core_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "developer", |
| processed_gypis.developer_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "internal", |
| processed_gypis.internal_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "isolate", |
| processed_gypis.isolate_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "math", |
| processed_gypis.math_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "mirrors", |
| processed_gypis.mirrors_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "profiler", |
| processed_gypis.profiler_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "typed_data", |
| processed_gypis.typed_data_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "vmservice", |
| processed_gypis.vmservice_runtime_sources, |
| "../lib", |
| ], |
| [ |
| "io", |
| processed_gypis.bin_io_sources, |
| "../bin", |
| ], |
| ] |
| } |