Chromium Code Reviews| Index: runtime/vm/BUILD.gn |
| diff --git a/runtime/vm/BUILD.gn b/runtime/vm/BUILD.gn |
| index d7edae646170d4cf3176eb580da4ab14c809fbe4..2bfbd1ffed0f2c8b6b573e74395a579834bcf59b 100644 |
| --- a/runtime/vm/BUILD.gn |
| +++ b/runtime/vm/BUILD.gn |
| @@ -60,6 +60,7 @@ vm_sources_list = exec_script("../../tools/gypi_to_gn.py", |
| static_library("libdart_vm") { |
| + deps = [":patched_sdk"] |
|
zra
2016/10/21 21:34:43
Why is this dependency here, but not on the analog
zra
2016/10/21 21:34:43
Also, we tend to put 'deps' below 'configs'.
Vyacheslav Egorov (Google)
2016/10/24 13:35:10
Done.
|
| configs += ["..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_maybe_precompiled_runtime_config"] |
| @@ -100,6 +101,7 @@ static_library("libdart_vm_precompiled_runtime") { |
| static_library("libdart_vm_nosnapshot") { |
| + deps = [":patched_sdk"] |
| configs += ["..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_maybe_precompiled_runtime_config", |
| @@ -128,6 +130,7 @@ static_library("libdart_vm_nosnapshot_precompiled_runtime") { |
| static_library("libdart_vm_nosnapshot_with_precompiler") { |
| + deps = [":patched_sdk"] |
| configs += ["..:dart_config", |
| "..:dart_maybe_product_config", |
| "..:dart_precompiler_config", |
| @@ -299,3 +302,114 @@ generate_core_libraries("core_libraries") { |
| ["_vmservice", "vmservice", true, "../../sdk/lib/vmservice", "../lib"], |
| ] |
| } |
| + |
| +group("patched_sdk") { |
| + template("concatenate_patch") { |
|
zra
2016/10/21 21:34:43
Optional: templates can use each other. Are there
Vyacheslav Egorov (Google)
2016/10/24 13:35:10
I have rewritten this code.
|
| + 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 a output in $target_name") |
|
zra
2016/10/21 21:34:43
an
Vyacheslav Egorov (Google)
2016/10/24 13:35:10
Done.
|
| + |
| + action(target_name) { |
| + visibility = [ ":*" ] |
| + output = invoker.output |
| + dir = invoker.dir |
| + libname = invoker.libname |
| + sources_gypi = "../${dir}/${libname}_sources.gypi" |
| + |
| + lib_sources_gypi = |
| + exec_script("../../tools/gypi_to_gn.py", |
| + [rebase_path(sources_gypi)], |
| + "scope", |
| + [sources_gypi]) |
| + lib_sources = |
| + rebase_path(lib_sources_gypi.sources, ".", "../${dir}") |
| + |
| + script = "../tools/concatenate_patches.py" |
| + |
| + inputs = [ script, sources_gypi ] |
| + inputs += lib_sources |
| + |
| + outputs = [ output ] |
| + |
| + args = [ "--output", rebase_path(output, root_build_dir)] |
| + args += rebase_path(lib_sources, root_build_dir) |
| + } |
| + } |
| + |
| + vm_libraries = [ "async", "collection", "convert", "core", "developer", |
|
zra
2016/10/21 21:34:43
I would re-structure this as a template that takes
Vyacheslav Egorov (Google)
2016/10/24 13:35:10
Done.
|
| + "internal", "isolate", "math", "mirrors", "profiler", |
| + "vmservice" ] |
| + concatenation_target_names = [] |
| + concatenation_files = [] |
| + |
| + # Concatenate vm library patches. |
|
zra
2016/10/21 21:34:43
Then you can de-dup the invocation of concatenate_
Vyacheslav Egorov (Google)
2016/10/24 13:35:10
Done.
|
| + foreach(name, vm_libraries) { |
| + target_name = "concatenate_${name}_patch" |
| + target_output = "$target_gen_dir/patches/${name}_patch.dart" |
| + concatenate_patch(target_name) { |
| + libname = name |
| + output = target_output |
| + dir = "lib" |
| + } |
| + concatenation_target_names += [ ":${target_name}" ] |
| + concatenation_files += [ target_output ] |
| + } |
| + |
| + # Concatenate io library patches. |
| + name = "io" |
| + target_name = "concatenate_${name}_patch" |
| + target_output = "$target_gen_dir/patches/${name}_patch.dart" |
| + concatenate_patch(target_name) { |
| + libname = name |
| + output = target_output |
| + dir = "bin" |
| + } |
| + concatenation_target_names += [ ":concatenate_io_patch" ] |
| + concatenation_files += [ target_output ] |
| + |
| + # Build the patched sdk out of the concatenated patches and the special |
| + # "runtime/bin/{builtin,nativewrappers}.dart" libraries". |
| + action("generate_patched_sdk") { |
| + deps = concatenation_target_names |
| + |
| + patches_dir = "$target_gen_dir/patches" |
| + patched_sdk_dir = "$target_gen_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_files.py", ["dart\$", "../../sdk/lib"], "list lines") |
|
zra
2016/10/21 21:34:43
If you only want .dart files, then tools/list_dart
Vyacheslav Egorov (Google)
2016/10/24 13:35:10
Done.
|
| + |
| + # We list the `patch_sdk.dart` tool here because the [script] (which is |
| + # implicitly an input) will call it. |
| + inputs = [ "../../tools/patch_sdk.dart" ] |
| + # These three 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/nativewrappers.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", |
| + ] |
| + |
| + args = [ |
| + "vm", |
| + rebase_path("../../sdk"), |
| + rebase_path(patches_dir, root_build_dir), |
| + rebase_path(patched_sdk_dir, root_build_dir), |
| + ] |
| + } |
| +} |