OLD | NEW |
1 # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 config("libdart_vm_config") { | 5 config("libdart_vm_config") { |
6 if (defined(is_fuchsia) && is_fuchsia) { | 6 if (defined(is_fuchsia) && is_fuchsia) { |
7 libs = [ "magenta" ] | 7 libs = [ "magenta" ] |
8 } else if (is_win) { | 8 } else if (is_win) { |
9 libs = [ | 9 libs = [ |
10 "advapi32.lib", | 10 "advapi32.lib", |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 ] | 141 ] |
142 public_configs = [ ":libdart_vm_config" ] | 142 public_configs = [ ":libdart_vm_config" ] |
143 set_sources_assignment_filter([ | 143 set_sources_assignment_filter([ |
144 "*_test.cc", | 144 "*_test.cc", |
145 "*_test.h", | 145 "*_test.h", |
146 ]) | 146 ]) |
147 sources = vm_sources_list.sources | 147 sources = vm_sources_list.sources |
148 include_dirs = [ ".." ] | 148 include_dirs = [ ".." ] |
149 } | 149 } |
150 | 150 |
151 template("generate_library_source") { | 151 template("process_library_source") { |
152 assert(defined(invoker.libname), "Need libname in $target_name") | 152 assert(defined(invoker.filename), "Need filename in $target_name") |
153 assert(defined(invoker.filename), "Need a filename in $target_name") | |
154 assert(defined(invoker.kind), "Need kind in $target_name") | |
155 assert(defined(invoker.output), "Need output in $target_name") | 153 assert(defined(invoker.output), "Need output in $target_name") |
156 assert(defined(invoker.path), "Need path in $target_name") | 154 assert(defined(invoker.path), "Need path in $target_name") |
157 action(target_name) { | 155 action(target_name) { |
158 visibility = [ ":*" ] # Only targets in this file can see this. | 156 visibility = [ ":*" ] # Only targets in this file can see this. |
159 libname = invoker.libname | |
160 filename = invoker.filename | 157 filename = invoker.filename |
161 kind = invoker.kind | |
162 path = invoker.path | 158 path = invoker.path |
163 | 159 |
164 lib_sources_gypi = | 160 lib_sources_gypi = |
165 exec_script("../../tools/gypi_to_gn.py", | 161 exec_script("../../tools/gypi_to_gn.py", |
166 [ rebase_path("${path}/${filename}_sources.gypi") ], | 162 [ rebase_path("${path}/${filename}_sources.gypi") ], |
167 "scope", | 163 "scope", |
168 [ "${path}/${filename}_sources.gypi" ]) | 164 [ "${path}/${filename}_sources.gypi" ]) |
169 lib_sources = rebase_path(lib_sources_gypi.sources, ".", path) | 165 lib_sources = rebase_path(lib_sources_gypi.sources, ".", path) |
170 | 166 |
171 script = "../tools/gen_library_src_paths.py" | 167 script = invoker.script |
172 inputs = [ | 168 inputs = invoker.inputs + [ script ] |
173 "../tools/gen_library_src_paths.py", | |
174 "../lib/libgen_in.cc", | |
175 ] | |
176 inputs += lib_sources | 169 inputs += lib_sources |
177 outputs = [ | 170 outputs = [ |
178 invoker.output, | 171 invoker.output, |
179 ] | 172 ] |
180 args = [ | 173 args = invoker.args + rebase_path(lib_sources, root_build_dir) |
181 "--output", | |
182 rebase_path(invoker.output, root_build_dir), | |
183 "--input_cc", | |
184 rebase_path("../lib/libgen_in.cc", root_build_dir), | |
185 "--include", | |
186 "vm/bootstrap.h", | |
187 "--var_name", | |
188 "dart::Bootstrap::${libname}_${kind}_paths_", | |
189 "--library_name", | |
190 "dart:${libname}", | |
191 ] + rebase_path(lib_sources, root_build_dir) | |
192 } | 174 } |
193 } | 175 } |
194 | 176 |
| 177 template("generate_library_source") { |
| 178 assert(defined(invoker.libname), "Need libname in $target_name") |
| 179 assert(defined(invoker.filename), "Need a filename in $target_name") |
| 180 assert(defined(invoker.kind), "Need kind in $target_name") |
| 181 assert(defined(invoker.output), "Need output in $target_name") |
| 182 assert(defined(invoker.path), "Need path in $target_name") |
| 183 |
| 184 process_library_source(target_name) { |
| 185 libname = invoker.libname |
| 186 filename = invoker.filename |
| 187 kind = invoker.kind |
| 188 output = invoker.output |
| 189 path = invoker.path |
| 190 script = "../tools/gen_library_src_paths.py" |
| 191 inputs = [ |
| 192 "../lib/libgen_in.cc", |
| 193 ] |
| 194 args = [ |
| 195 "--output", |
| 196 rebase_path(invoker.output, root_build_dir), |
| 197 "--input_cc", |
| 198 rebase_path("../lib/libgen_in.cc", root_build_dir), |
| 199 "--include", |
| 200 "vm/bootstrap.h", |
| 201 "--var_name", |
| 202 "dart::Bootstrap::${libname}_${kind}_paths_", |
| 203 "--library_name", |
| 204 "dart:${libname}", |
| 205 ] |
| 206 } |
| 207 } |
| 208 |
195 # This templates expects invoker.sources to be a list of pairs of strings. | 209 # This templates expects invoker.sources to be a list of pairs of strings. |
196 # The pairs of strings mean the following. | 210 # The pairs of strings mean the following. |
197 # library name, file name | 211 # library name, file name |
198 # e.g. for the "internal" library named "dart:_internal", | 212 # e.g. for the "internal" library named "dart:_internal", |
199 # with sources listed at sdk/lib/internal/internal_sources.gypi and | 213 # with sources listed at sdk/lib/internal/internal_sources.gypi and |
200 # lib/internal_sources.gypi, we have: ["_internal", "internal"] | 214 # lib/internal_sources.gypi, we have: ["_internal", "internal"] |
201 # | 215 # |
202 # The template iterates over the list, and generates generate_library_source | 216 # The template iterates over the list, and generates generate_library_source |
203 # actions for each. After that, it generates targets to compile the generated | 217 # actions for each. After that, it generates targets to compile the generated |
204 # sources to make libdart_lib_nosnapshot and libdart_lib. | 218 # sources to make libdart_lib_nosnapshot and libdart_lib. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 ], | 388 ], |
375 [ | 389 [ |
376 "_vmservice", | 390 "_vmservice", |
377 "vmservice", | 391 "vmservice", |
378 true, | 392 true, |
379 "../../sdk/lib/vmservice", | 393 "../../sdk/lib/vmservice", |
380 "../lib", | 394 "../lib", |
381 ], | 395 ], |
382 ] | 396 ] |
383 } | 397 } |
| 398 |
| 399 template("concatenate_patch") { |
| 400 assert(defined(invoker.libname), "Need a name in $target_name") |
| 401 assert(defined(invoker.dir), "Need a dir in $target_name") |
| 402 assert(defined(invoker.output), "Need an output in $target_name") |
| 403 |
| 404 process_library_source(target_name) { |
| 405 output = invoker.output |
| 406 path = "../${invoker.dir}" |
| 407 filename = invoker.libname |
| 408 script = "../tools/concatenate_patches.py" |
| 409 args = [ |
| 410 "--output", |
| 411 rebase_path(output, root_build_dir), |
| 412 ] |
| 413 inputs = [] |
| 414 } |
| 415 } |
| 416 |
| 417 template("generate_patched_sdk") { |
| 418 assert(defined(invoker.libraries), "Need libraries in $target_name") |
| 419 |
| 420 concatenation_target_names = [] |
| 421 concatenation_files = [] |
| 422 |
| 423 # Concatenate vm library patches. |
| 424 foreach(library, invoker.libraries) { |
| 425 name = library[1] |
| 426 |
| 427 target_output = "$target_gen_dir/patches/${name}_patch.dart" |
| 428 concatenate_patch("concatenate_${name}_patch") { |
| 429 libname = name |
| 430 dir = library[0] |
| 431 output = target_output |
| 432 } |
| 433 concatenation_target_names += [ ":concatenate_${name}_patch" ] |
| 434 concatenation_files += [ target_output ] |
| 435 } |
| 436 |
| 437 # Build the patched sdk out of the concatenated patches and the special |
| 438 # libraries. |
| 439 action(target_name) { |
| 440 deps = concatenation_target_names |
| 441 |
| 442 patches_dir = "$target_gen_dir/patches" |
| 443 patched_sdk_dir = "$target_gen_dir/patched_sdk" |
| 444 |
| 445 script = "../../tools/patch_sdk.py" |
| 446 |
| 447 # We list all files which make up the sdk (modulo patches) and get them back |
| 448 # as a GN list object. |
| 449 shared_sdk_sources = exec_script("../../tools/list_dart_files.py", |
| 450 [ "../../sdk/lib" ], |
| 451 "list lines") |
| 452 |
| 453 # We list the `patch_sdk.dart` tool here because the [script] (which is |
| 454 # implicitly an input) will call it. |
| 455 inputs = [ |
| 456 "../../tools/patch_sdk.dart", |
| 457 ] |
| 458 |
| 459 # Files below are not patches, they will not be in [concatenation_files] but |
| 460 # the `patch_sdk.dart` script will copy them into the patched sdk. |
| 461 inputs += [ |
| 462 "../lib/typed_data.dart", |
| 463 "../bin/builtin.dart", |
| 464 "../bin/vmservice/vmservice_io.dart", |
| 465 "../bin/vmservice/loader.dart", |
| 466 "../bin/vmservice/server.dart", |
| 467 ] |
| 468 |
| 469 # Add all the normal sdk sources. |
| 470 inputs += shared_sdk_sources |
| 471 |
| 472 # Add all the concatenated patch files. |
| 473 inputs += concatenation_files |
| 474 |
| 475 outputs = [ |
| 476 # Instead of listing all outputs we list a single well-known one. |
| 477 "${patched_sdk_dir}/lib/core/core.dart", |
| 478 ] |
| 479 |
| 480 args = [ |
| 481 "vm", |
| 482 rebase_path("../../sdk"), |
| 483 rebase_path(patches_dir, root_build_dir), |
| 484 rebase_path(patched_sdk_dir, root_build_dir), |
| 485 ] |
| 486 } |
| 487 } |
| 488 |
| 489 generate_patched_sdk("patched_sdk") { |
| 490 libraries = [ |
| 491 [ |
| 492 "lib", |
| 493 "async", |
| 494 ], |
| 495 [ |
| 496 "lib", |
| 497 "collection", |
| 498 ], |
| 499 [ |
| 500 "lib", |
| 501 "convert", |
| 502 ], |
| 503 [ |
| 504 "lib", |
| 505 "core", |
| 506 ], |
| 507 [ |
| 508 "lib", |
| 509 "developer", |
| 510 ], |
| 511 [ |
| 512 "lib", |
| 513 "internal", |
| 514 ], |
| 515 [ |
| 516 "lib", |
| 517 "isolate", |
| 518 ], |
| 519 [ |
| 520 "lib", |
| 521 "math", |
| 522 ], |
| 523 [ |
| 524 "lib", |
| 525 "mirrors", |
| 526 ], |
| 527 [ |
| 528 "lib", |
| 529 "profiler", |
| 530 ], |
| 531 [ |
| 532 "lib", |
| 533 "vmservice", |
| 534 ], |
| 535 [ |
| 536 "bin", |
| 537 "io", |
| 538 ], |
| 539 ] |
| 540 } |
OLD | NEW |