| # 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("../../utils/invoke_dart.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" ] |
| |
| platform_headers_gypi = |
| exec_script("../../tools/gypi_to_gn.py", |
| [ rebase_path("../platform/platform_headers.gypi") ], |
| "scope", |
| [ "../platform/platform_headers.gypi" ]) |
| platform_headers = |
| rebase_path(platform_headers_gypi.sources, ".", "../platform") |
| |
| platform_sources_gypi = |
| exec_script("../../tools/gypi_to_gn.py", |
| [ rebase_path("../platform/platform_sources.gypi") ], |
| "scope", |
| [ "../platform/platform_sources.gypi" ]) |
| platform_sources = |
| rebase_path(platform_sources_gypi.sources, ".", "../platform") |
| |
| sources = platform_headers + platform_sources |
| include_dirs = [ ".." ] |
| } |
| |
| vm_sources_list = exec_script("../../tools/gypi_to_gn.py", |
| [ rebase_path("vm_sources.gypi") ], |
| "scope", |
| [ "vm_sources.gypi" ]) |
| |
| 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.sources |
| include_dirs = [ ".." ] |
| } |
| |
| static_library("libdart_vm_noopt") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_precompiler_config", |
| "..:dart_maybe_precompiled_runtime_config", |
| ] |
| public_configs = [ ":libdart_vm_config" ] |
| set_sources_assignment_filter([ |
| "*_test.cc", |
| "*_test.h", |
| ]) |
| sources = vm_sources_list.sources |
| 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.sources |
| include_dirs = [ ".." ] |
| } |
| |
| static_library("libdart_vm_nosnapshot") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_maybe_precompiled_runtime_config", |
| "..:dart_no_snapshot_config", |
| ] |
| public_configs = [ ":libdart_vm_config" ] |
| set_sources_assignment_filter([ |
| "*_test.cc", |
| "*_test.h", |
| ]) |
| sources = vm_sources_list.sources |
| include_dirs = [ ".." ] |
| } |
| |
| static_library("libdart_vm_nosnapshot_precompiled_runtime") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_precompiled_runtime_config", |
| "..:dart_no_snapshot_config", |
| ] |
| public_configs = [ ":libdart_vm_config" ] |
| set_sources_assignment_filter([ |
| "*_test.cc", |
| "*_test.h", |
| ]) |
| sources = vm_sources_list.sources |
| 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.sources |
| include_dirs = [ ".." ] |
| } |
| |
| template("process_library_source") { |
| assert(defined(invoker.filename), "Need filename in $target_name") |
| assert(defined(invoker.output), "Need output in $target_name") |
| assert(defined(invoker.path), "Need path in $target_name") |
| action(target_name) { |
| visibility = [ ":*" ] # Only targets in this file can see this. |
| filename = invoker.filename |
| path = invoker.path |
| |
| lib_sources_gypi = |
| exec_script("../../tools/gypi_to_gn.py", |
| [ rebase_path("${path}/${filename}_sources.gypi") ], |
| "scope", |
| [ "${path}/${filename}_sources.gypi" ]) |
| lib_sources = rebase_path(lib_sources_gypi.sources, ".", path) |
| |
| script = invoker.script |
| inputs = invoker.inputs + [ script ] |
| inputs += lib_sources |
| outputs = [ |
| invoker.output, |
| ] |
| args = invoker.args + rebase_path(lib_sources, root_build_dir) |
| } |
| } |
| |
| template("generate_library_source") { |
| assert(defined(invoker.libname), "Need libname in $target_name") |
| assert(defined(invoker.filename), "Need a filename in $target_name") |
| assert(defined(invoker.kind), "Need kind in $target_name") |
| assert(defined(invoker.output), "Need output in $target_name") |
| assert(defined(invoker.path), "Need path in $target_name") |
| |
| process_library_source(target_name) { |
| libname = invoker.libname |
| filename = invoker.filename |
| kind = invoker.kind |
| output = invoker.output |
| path = invoker.path |
| script = "../tools/gen_library_src_paths.py" |
| inputs = [ |
| "../lib/libgen_in.cc", |
| ] |
| 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 pairs of strings. |
| # The pairs of strings mean the following. |
| # library name, file name |
| # e.g. for the "internal" library named "dart:_internal", |
| # with sources listed at sdk/lib/internal/internal_sources.gypi and |
| # lib/internal_sources.gypi, we have: ["_internal", "internal"] |
| # |
| # 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_nosnapshot and libdart_lib. |
| template("generate_core_libraries") { |
| assert(defined(invoker.sources), "Need sources in $target_name") |
| liboutputs = [] |
| libsources = [] |
| libdeps = [] |
| foreach(lib, invoker.sources) { |
| libname = lib[0] |
| filename = lib[1] |
| do_patch = lib[2] |
| source_path = lib[3] |
| generate_library_source("generate_${filename}_cc_file") { |
| libname = libname |
| filename = filename |
| kind = "source" |
| path = source_path |
| output = "$target_gen_dir/${filename}_gen.cc" |
| } |
| if (do_patch) { |
| patch_path = lib[4] |
| generate_library_source("generate_${filename}_patch_cc_file") { |
| libname = libname |
| filename = filename |
| kind = "patch" |
| path = patch_path |
| output = "$target_gen_dir/${filename}_patch_gen.cc" |
| } |
| } |
| lib_sources_gypi = { |
| } |
| lib_sources_gypi = |
| exec_script("../../tools/gypi_to_gn.py", |
| [ rebase_path("../lib/${filename}_sources.gypi") ], |
| "scope", |
| [ "../lib/${filename}_sources.gypi" ]) |
| libsources += rebase_path(lib_sources_gypi.sources, ".", "../lib") |
| 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" ] |
| } |
| } |
| |
| static_library("libdart_lib_nosnapshot") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_maybe_precompiled_runtime_config", |
| ] |
| deps = libdeps |
| sources = libsources + [ "bootstrap.cc" ] + liboutputs |
| include_dirs = [ ".." ] |
| } |
| static_library("libdart_lib_nosnapshot_precompiled_runtime") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_precompiled_runtime_config", |
| ] |
| deps = libdeps |
| sources = 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 = libsources + [ "bootstrap.cc" ] + liboutputs |
| include_dirs = [ ".." ] |
| } |
| static_library("libdart_lib") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_maybe_precompiled_runtime_config", |
| ] |
| sources = libsources + [ "bootstrap_nocore.cc" ] |
| include_dirs = [ ".." ] |
| } |
| static_library("libdart_lib_precompiled_runtime") { |
| configs += [ |
| "..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_precompiled_runtime_config", |
| ] |
| sources = libsources + [ "bootstrap_nocore.cc" ] |
| include_dirs = [ ".." ] |
| } |
| } |
| |
| generate_core_libraries("core_libraries") { |
| sources = [ |
| [ |
| "async", |
| "async", |
| true, |
| "../../sdk/lib/async", |
| "../lib", |
| ], |
| [ |
| "core", |
| "core", |
| true, |
| "../../sdk/lib/core", |
| "../lib", |
| ], |
| [ |
| "collection", |
| "collection", |
| true, |
| "../../sdk/lib/collection", |
| "../lib", |
| ], |
| [ |
| "convert", |
| "convert", |
| true, |
| "../../sdk/lib/convert", |
| "../lib", |
| ], |
| [ |
| "developer", |
| "developer", |
| true, |
| "../../sdk/lib/developer", |
| "../lib", |
| ], |
| [ |
| "_internal", |
| "internal", |
| true, |
| "../../sdk/lib/internal", |
| "../lib", |
| ], |
| [ |
| "isolate", |
| "isolate", |
| true, |
| "../../sdk/lib/isolate", |
| "../lib", |
| ], |
| [ |
| "math", |
| "math", |
| true, |
| "../../sdk/lib/math", |
| "../lib", |
| ], |
| [ |
| "mirrors", |
| "mirrors", |
| true, |
| "../../sdk/lib/mirrors", |
| "../lib", |
| ], |
| [ |
| "profiler", |
| "profiler", |
| false, |
| "../../sdk/lib/profiler", |
| ], |
| [ |
| "typed_data", |
| "typed_data", |
| false, |
| "../lib", |
| ], |
| [ |
| "_vmservice", |
| "vmservice", |
| true, |
| "../../sdk/lib/vmservice", |
| "../lib", |
| ], |
| ] |
| } |
| |
| template("concatenate_patch") { |
| assert(defined(invoker.libname), "Need a name in $target_name") |
| assert(defined(invoker.dir), "Need a dir in $target_name") |
| assert(defined(invoker.output), "Need an output in $target_name") |
| |
| process_library_source(target_name) { |
| output = invoker.output |
| path = "../${invoker.dir}" |
| filename = invoker.libname |
| script = "../tools/concatenate_patches.py" |
| args = [ |
| "--output", |
| rebase_path(output, root_build_dir), |
| ] |
| inputs = [] |
| } |
| } |
| |
| if (!defined(is_fuchsia) || !is_fuchsia) { |
| template("generate_patched_sdk") { |
| assert(defined(invoker.libraries), "Need libraries in $target_name") |
| |
| concatenation_target_names = [] |
| concatenation_files = [] |
| |
| # Concatenate vm library patches. |
| foreach(library, invoker.libraries) { |
| name = library[1] |
| |
| target_output = "$target_gen_dir/patches/${name}_patch.dart" |
| concatenate_patch("concatenate_${name}_patch") { |
| libname = name |
| dir = library[0] |
| output = target_output |
| } |
| concatenation_target_names += [ ":concatenate_${name}_patch" ] |
| concatenation_files += [ target_output ] |
| } |
| |
| # Build the patched sdk out of the concatenated patches and the special |
| # libraries. |
| action(target_name) { |
| deps = [ "../bin:dart_bootstrap($host_toolchain)" ] + |
| concatenation_target_names |
| |
| patches_dir = "$target_gen_dir/patches" |
| patched_sdk_dir = "$root_out_dir/patched_sdk" |
| |
| script = "../../tools/patch_sdk.py" |
| |
| # We list all files which make up the sdk (modulo patches) and get them back |
| # as a GN list object. |
| shared_sdk_sources = exec_script("../../tools/list_dart_files.py", |
| [ "../../sdk/lib" ], |
| "list lines") |
| |
| # We list the `patch_sdk.dart` tool here because the [script] (which is |
| # implicitly an input) will call it. |
| inputs = [ |
| "../../tools/patch_sdk.dart", |
| ] |
| |
| # Files below are not patches, they will not be in [concatenation_files] but |
| # the `patch_sdk.dart` script will copy them into the patched sdk. |
| inputs += [ |
| "../lib/typed_data.dart", |
| "../bin/builtin.dart", |
| "../bin/vmservice/vmservice_io.dart", |
| "../bin/vmservice/loader.dart", |
| "../bin/vmservice/server.dart", |
| ] |
| |
| # Add all the normal sdk sources. |
| inputs += shared_sdk_sources |
| |
| # Add all the concatenated patch files. |
| inputs += concatenation_files |
| |
| outputs = [ |
| # Instead of listing all outputs we list a single well-known one. |
| "${patched_sdk_dir}/lib/core/core.dart", |
| ] |
| |
| dart_out_dir = get_label_info("../bin:dart_bootstrap($host_toolchain)", |
| "root_out_dir") |
| dart_bootstrap = |
| rebase_path("$dart_out_dir/dart_bootstrap$dart_executable_suffix") |
| |
| args = [ |
| "--dart-executable", |
| dart_bootstrap, |
| "vm", |
| rebase_path("../../sdk"), |
| rebase_path(patches_dir, root_build_dir), |
| rebase_path(patched_sdk_dir, root_build_dir), |
| ] |
| } |
| } |
| |
| generate_patched_sdk("patched_sdk") { |
| libraries = [ |
| [ |
| "lib", |
| "async", |
| ], |
| [ |
| "lib", |
| "collection", |
| ], |
| [ |
| "lib", |
| "convert", |
| ], |
| [ |
| "lib", |
| "core", |
| ], |
| [ |
| "lib", |
| "developer", |
| ], |
| [ |
| "lib", |
| "internal", |
| ], |
| [ |
| "lib", |
| "isolate", |
| ], |
| [ |
| "lib", |
| "math", |
| ], |
| [ |
| "lib", |
| "mirrors", |
| ], |
| [ |
| "lib", |
| "profiler", |
| ], |
| [ |
| "lib", |
| "vmservice", |
| ], |
| [ |
| "bin", |
| "io", |
| ], |
| ] |
| } |
| } |