|  | # Copyright (c) 2017, 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. | 
|  |  | 
|  | # This GN file contains build rules for assembling the Dart SDK. There are | 
|  | # two possible variants: the "Full" SDK, and the "Platform" SDK. If you want | 
|  | # to make a new subset of the Full SDK, make it the same way we make | 
|  | # the Platform SDK. | 
|  | # | 
|  | # Warning: | 
|  | # If you need to copy something into dart-sdk/lib/foo in addition to the stuff | 
|  | # copied there by :copy_libraries, then you must depend on ":copy_libraries", | 
|  | # or ":copy_libraries" may delete/overwrite your addition, and the build will | 
|  | # fail. | 
|  |  | 
|  | import("../build/dart/copy_tree.gni") | 
|  | import("../runtime/runtime_args.gni") | 
|  | import("../sdk_args.gni") | 
|  |  | 
|  | declare_args() { | 
|  | # Build a SDK with less stuff. It excludes dart2js, ddc, and web libraries. | 
|  | dart_platform_sdk = true | 
|  |  | 
|  | # Whether to include dart2native in the "create_sdk" target. | 
|  | include_dart2native = false | 
|  |  | 
|  | # Path to stripped dart binaries relative to build output directory. | 
|  | dart_stripped_binary = "dart" | 
|  | dart_precompiled_runtime_stripped_binary = "dart_precompiled_runtime" | 
|  | gen_snapshot_stripped_binary = "gen_snapshot" | 
|  | } | 
|  |  | 
|  | # The directory layout of the SDK is as follows: | 
|  | # | 
|  | # ..dart-sdk/ | 
|  | # ....bin/ | 
|  | # ......dart or dart.exe (executable) | 
|  | # ......dart.lib (import library for VM native extensions on Windows) | 
|  | # ......dartaotruntime or dartaotruntime.exe (executable) | 
|  | # ......dartdoc | 
|  | # ......dartfmt | 
|  | # ......dart2native (if `include_dart2native` and not on ia32) | 
|  | # ......dart2js | 
|  | # ......dartanalyzer | 
|  | # ......dartdevc | 
|  | # ......utils/gen_snapshot or utils/gen_snapshot.exe (if `include_dart2native` and not on ia32) | 
|  | # ......pub | 
|  | # ......snapshots/ | 
|  | # ........analysis_server.dart.snapshot | 
|  | # ........dart2js.dart.snapshot | 
|  | # ........dartanalyzer.dart.snapshot | 
|  | # ........dartdev.dart.snapshot | 
|  | # ........dartdoc.dart.snapshot | 
|  | # ........dartfmt.dart.snapshot | 
|  | # ........dartdevc.dart.snapshot | 
|  | # ........gen_kernel.dart.snapshot (if `include_dart2native` and not on ia32) | 
|  | # ........dart2native.dart.snapshot (if `include_dart2native` and not on ia32) | 
|  | # ........kernel_worker.dart.snapshot | 
|  | # ........pub.dart.snapshot | 
|  | # ........frontend_server.dart.snapshot | 
|  | # ......resources/ | 
|  | # ........dartdoc/ | 
|  | # ...........packages | 
|  | # ..........resources/ | 
|  | # ..........templates/ | 
|  | # ......model/ | 
|  | # ........lexeme/ | 
|  | # ..........idx2word.json | 
|  | # ..........model.tflite | 
|  | # ..........word2idx.json | 
|  | # ....include/ | 
|  | # ......dart_api.h | 
|  | # ......dart_native_api.h | 
|  | # ......dart_tools_api.h | 
|  | # ....lib/ | 
|  | # ......libraries.json | 
|  | # ......_internal/ | 
|  | # ........strong.sum | 
|  | # ........dart2js_platform.dill | 
|  | # ........dart2js_server_platform.dill | 
|  | # ........dart2js_platform_strong.dill | 
|  | # ........dart2js_server_platform_strong.dill | 
|  | # ........vm_platform_strong.dill | 
|  | # ........dev_compiler/ | 
|  | # ......async/ | 
|  | # ......collection/ | 
|  | # ......convert/ | 
|  | # ......core/ | 
|  | # ......html/ | 
|  | # ......_http/ | 
|  | # ......internal/ | 
|  | # ......io/ | 
|  | # ......isolate/ | 
|  | # ......js/ | 
|  | # ......js_util/ | 
|  | # ......math/ | 
|  | # ......mirrors/ | 
|  | # ......typed_data/ | 
|  | # ......wasm/ | 
|  | # ......api_readme.md | 
|  |  | 
|  | # Scripts that go under bin/ | 
|  | _platform_sdk_scripts = [ | 
|  | "dartanalyzer", | 
|  | "dartfmt", | 
|  | "pub", | 
|  | ] | 
|  |  | 
|  | _full_sdk_scripts = [ | 
|  | "dart2js", | 
|  | "dartanalyzer", | 
|  | "dartdevc", | 
|  | "dartfmt", | 
|  | "pub", | 
|  | ] | 
|  |  | 
|  | # Scripts not ending in _sdk that go under bin/ | 
|  | _scripts = [ "dartdoc" ] | 
|  |  | 
|  | # Snapshots that go under bin/snapshots | 
|  | _platform_sdk_snapshots = [ | 
|  | [ | 
|  | "dartanalyzer", | 
|  | "../utils/dartanalyzer:generate_dartanalyzer_snapshot", | 
|  | ], | 
|  | [ | 
|  | "dartdev", | 
|  | "../utils/dartdev", | 
|  | ], | 
|  | [ | 
|  | "dartdoc", | 
|  | "../utils/dartdoc", | 
|  | ], | 
|  | [ | 
|  | "dartfmt", | 
|  | "../utils/dartfmt", | 
|  | ], | 
|  | [ | 
|  | "pub", | 
|  | "../utils/pub", | 
|  | ], | 
|  | ] | 
|  | if (include_dart2native && dart_target_arch != "ia32") { | 
|  | _platform_sdk_snapshots += [ [ | 
|  | "dart2native", | 
|  | "../utils/dart2native:generate_dart2native_snapshot", | 
|  | ] ] | 
|  | } | 
|  | if (create_kernel_service_snapshot) { | 
|  | _platform_sdk_snapshots += [ [ | 
|  | "kernel-service", | 
|  | "../utils/kernel-service:kernel-service_snapshot", | 
|  | ] ] | 
|  | } | 
|  | if (dart_target_arch != "arm") { | 
|  | _platform_sdk_snapshots += [ [ | 
|  | "analysis_server", | 
|  | "../utils/analysis_server", | 
|  | ] ] | 
|  | } | 
|  |  | 
|  | _full_sdk_snapshots = [ | 
|  | [ | 
|  | "dart2js", | 
|  | "../utils/compiler:dart2js", | 
|  | ], | 
|  | [ | 
|  | "dartanalyzer", | 
|  | "../utils/dartanalyzer:generate_dartanalyzer_snapshot", | 
|  | ], | 
|  | [ | 
|  | "dartdev", | 
|  | "../utils/dartdev", | 
|  | ], | 
|  | [ | 
|  | "dartdevc", | 
|  | "../utils/dartdevc", | 
|  | ], | 
|  | [ | 
|  | "dartdoc", | 
|  | "../utils/dartdoc", | 
|  | ], | 
|  | [ | 
|  | "dartfmt", | 
|  | "../utils/dartfmt", | 
|  | ], | 
|  | [ | 
|  | "kernel_worker", | 
|  | "../utils/bazel:kernel_worker", | 
|  | ], | 
|  | [ | 
|  | "pub", | 
|  | "../utils/pub", | 
|  | ], | 
|  | [ | 
|  | "frontend_server", | 
|  | "../utils/kernel-service:frontend_server", | 
|  | ], | 
|  | ] | 
|  | if (include_dart2native && dart_target_arch != "ia32") { | 
|  | _full_sdk_snapshots += [ [ | 
|  | "dart2native", | 
|  | "../utils/dart2native:generate_dart2native_snapshot", | 
|  | ] ] | 
|  | } | 
|  | if (create_kernel_service_snapshot) { | 
|  | _full_sdk_snapshots += [ [ | 
|  | "kernel-service", | 
|  | "../utils/kernel-service:kernel-service_snapshot", | 
|  | ] ] | 
|  | } | 
|  | if (dart_target_arch != "arm") { | 
|  | _full_sdk_snapshots += [ [ | 
|  | "analysis_server", | 
|  | "../utils/analysis_server", | 
|  | ] ] | 
|  | } | 
|  |  | 
|  | # Libraries that go under lib/ | 
|  | _full_sdk_libraries = [ | 
|  | "_internal", | 
|  | "async", | 
|  | "cli", | 
|  | "collection", | 
|  | "convert", | 
|  | "core", | 
|  | "developer", | 
|  | "ffi", | 
|  | "html", | 
|  | "_http", | 
|  | "indexed_db", | 
|  | "internal", | 
|  | "io", | 
|  | "isolate", | 
|  | "js", | 
|  | "js_util", | 
|  | "math", | 
|  | "mirrors", | 
|  | "svg", | 
|  | "typed_data", | 
|  | "wasm", | 
|  | "web_audio", | 
|  | "web_gl", | 
|  | "web_sql", | 
|  | ] | 
|  |  | 
|  | # Apps running on the platform SDK shouldn't be using Dart4Web libraries, but | 
|  | # the analyzer and dartdoc expect all the library sources to be present. | 
|  | # | 
|  | # _platform_sdk_libraries = [ | 
|  | #   "_internal", | 
|  | #   "async", | 
|  | #   "cli", | 
|  | #   "collection", | 
|  | #   "convert", | 
|  | #   "core", | 
|  | #   "developer", | 
|  | #   "html", | 
|  | #   "_http", | 
|  | #   "internal", | 
|  | #   "io", | 
|  | #   "isolate", | 
|  | #   "math", | 
|  | #   "mirrors", | 
|  | #   "typed_data", | 
|  | # ] | 
|  | _platform_sdk_libraries = _full_sdk_libraries | 
|  |  | 
|  | # From here down to the copy_trees() invocation, we collect all the information | 
|  | # about trees that need to be copied in the list of scopes, copy_tree_specs. | 
|  | copy_tree_specs = [] | 
|  |  | 
|  | # This rule copies dartdoc templates to | 
|  | # bin/resources/dartdoc/templates | 
|  | copy_tree_specs += [ | 
|  | { | 
|  | target = "copy_dartdoc_templates" | 
|  | visibility = [ ":copy_dartdoc_files" ] | 
|  | source = "../third_party/pkg/dartdoc/lib/templates" | 
|  | dest = "$root_out_dir/dart-sdk/bin/resources/dartdoc/templates" | 
|  | ignore_patterns = "{}" | 
|  | }, | 
|  | ] | 
|  |  | 
|  | # This rule copies dartdoc resources to | 
|  | # bin/resources/dartdoc/resources | 
|  | copy_tree_specs += [ | 
|  | { | 
|  | target = "copy_dartdoc_resources" | 
|  | visibility = [ ":copy_dartdoc_files" ] | 
|  | source = "../third_party/pkg/dartdoc/lib/resources" | 
|  | dest = "$root_out_dir/dart-sdk/bin/resources/dartdoc/resources" | 
|  | ignore_patterns = "{}" | 
|  | }, | 
|  | ] | 
|  |  | 
|  | # This loop generates rules to copy libraries to lib/ | 
|  | foreach(library, _full_sdk_libraries) { | 
|  | copy_tree_specs += [ | 
|  | { | 
|  | target = "copy_${library}_library" | 
|  | visibility = [ | 
|  | ":copy_platform_sdk_libraries", | 
|  | ":copy_full_sdk_libraries", | 
|  | ] | 
|  | source = "lib/$library" | 
|  | dest = "$root_out_dir/dart-sdk/lib/$library" | 
|  | ignore_patterns = "*.svn,doc,*.py,*.gypi,*.sh,.gitignore" | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | if (is_win) { | 
|  | copy_tree_specs += [ | 
|  | { | 
|  | target = "copy_7zip" | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | deps = [ ":copy_libraries" ] | 
|  | source = "../third_party/7zip" | 
|  | dest = "$root_out_dir/dart-sdk/lib/_internal/pub/asset/7zip" | 
|  | ignore_patterns = ".svn" | 
|  | }, | 
|  | ] | 
|  | } | 
|  |  | 
|  | if (target_cpu == "x64") { | 
|  | copy_tree_specs += [ | 
|  | { | 
|  | target = "copy_language_model" | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | deps = [ ":copy_libraries" ] | 
|  | source = "../pkg/analysis_server/language_model" | 
|  | dest = "$root_out_dir/dart-sdk/bin/model" | 
|  | ignore_patterns = "{}" | 
|  | }, | 
|  | ] | 
|  | if (is_linux || is_android) { | 
|  | copy_tree_specs += [ | 
|  | { | 
|  | target = "copy_libtensorflowlite_c" | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | deps = [ ":copy_libraries" ] | 
|  | source = "../third_party/pkg/tflite_native/lib/src/blobs" | 
|  | dest = "$root_out_dir/dart-sdk/bin/snapshots" | 
|  | ignore_patterns = "*.dll,*mac64.so" | 
|  | }, | 
|  | ] | 
|  | } | 
|  | if (is_mac) { | 
|  | copy_tree_specs += [ | 
|  | { | 
|  | target = "copy_libtensorflowlite_c" | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | deps = [ ":copy_libraries" ] | 
|  | source = "../third_party/pkg/tflite_native/lib/src/blobs" | 
|  | dest = "$root_out_dir/dart-sdk/bin/snapshots" | 
|  | ignore_patterns = "*.dll,*linux64.so" | 
|  | }, | 
|  | ] | 
|  | } | 
|  | if (is_win) { | 
|  | copy_tree_specs += [ | 
|  | { | 
|  | target = "copy_libtensorflowlite_c" | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | deps = [ ":copy_libraries" ] | 
|  | source = "../third_party/pkg/tflite_native/lib/src/blobs" | 
|  | dest = "$root_out_dir/dart-sdk/bin/snapshots" | 
|  | ignore_patterns = "*.so" | 
|  | }, | 
|  | ] | 
|  | } | 
|  | } | 
|  |  | 
|  | # This generates targets for everything in copy_tree_specs. The targets have the | 
|  | # same name as the "target" fields in the scopes of copy_tree_specs. | 
|  | copy_trees("copy_trees") { | 
|  | sources = copy_tree_specs | 
|  | } | 
|  |  | 
|  | # Copies the Dart VM binary into bin/ | 
|  | if (target_os != current_os && target_os == "fuchsia") { | 
|  | # In the Fuchsia build, this has to use a symlink for two reasons. | 
|  | # First, it makes the lookup of shared libraries relative to $ORIGIN | 
|  | # (Linux) or @loader_path (macOS) find the libraries where they are, | 
|  | # since those lookups use the directory of the symlink target rather | 
|  | # than of the link itself (as they would for a copy or hard link). | 
|  | # Second, when the dart binary is built as a "variant" (e.g. with a | 
|  | # sanitizer), then $root_out_dir/dart is itself a symlink to the real | 
|  | # binary in the selected variant toolchain's $root_out_dir and since | 
|  | # the "copy" tool is actually a hard link rather than a copy, it will | 
|  | # make a link to the symlink rather than the symlink's target, and the | 
|  | # relative symlink interpreted from a different containing directory | 
|  | # will not find the actual binary. | 
|  | action("copy_dart") { | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | dart_label = "../runtime/bin:dart" | 
|  | deps = [ dart_label ] | 
|  | dart_out = get_label_info(dart_label, "root_out_dir") | 
|  | sources = [ "$dart_out/$dart_stripped_binary" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/bin/$dart_stripped_binary" ] | 
|  | script = "/bin/ln" | 
|  | args = [ | 
|  | "-snf", | 
|  | rebase_path(sources[0], get_path_info(outputs[0], "dir")), | 
|  | rebase_path(outputs[0]), | 
|  | ] | 
|  | } | 
|  | } else { | 
|  | copy("copy_dart") { | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | deps = [ "../runtime/bin:dart" ] | 
|  | dart_out = get_label_info("../runtime/bin:dart", "root_out_dir") | 
|  | if (is_win) { | 
|  | sources = [ "$dart_out/dart.exe" ] | 
|  | } else { | 
|  | sources = [ "$dart_out/$dart_stripped_binary" ] | 
|  | } | 
|  | if (is_win) { | 
|  | sources += [ "$dart_out/dart.lib" ] | 
|  | } | 
|  | outputs = [ "$root_out_dir/dart-sdk/bin/{{source_file_part}}" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | copy("copy_dartaotruntime") { | 
|  | deps = [ "../runtime/bin:dart_precompiled_runtime" ] | 
|  | dartaotruntime_out = | 
|  | get_label_info("../runtime/bin:dart_precompiled_runtime", "root_out_dir") | 
|  | if (is_win) { | 
|  | sources = [ "$dartaotruntime_out/dart_precompiled_runtime.exe" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/bin/dartaotruntime.exe" ] | 
|  | } else { | 
|  | sources = | 
|  | [ "$dartaotruntime_out/$dart_precompiled_runtime_stripped_binary" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/bin/dartaotruntime" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | copy("copy_gen_snapshot") { | 
|  | deps = [ "../runtime/bin:gen_snapshot" ] | 
|  | gen_snapshot_out = | 
|  | get_label_info("../runtime/bin:gen_snapshot", "root_out_dir") | 
|  | if (is_win) { | 
|  | sources = [ "$gen_snapshot_out/gen_snapshot.exe" ] | 
|  | } else { | 
|  | sources = [ "$gen_snapshot_out/$gen_snapshot_stripped_binary" ] | 
|  | } | 
|  | outputs = [ "$root_out_dir/dart-sdk/bin/utils/{{source_file_part}}" ] | 
|  | } | 
|  |  | 
|  | copy("copy_dart2native") { | 
|  | deps = [ | 
|  | ":copy_dartaotruntime", | 
|  | ":copy_gen_kernel_snapshot", | 
|  | ":copy_gen_snapshot", | 
|  | ] | 
|  | ext = "" | 
|  | if (is_win) { | 
|  | ext = ".bat" | 
|  | } | 
|  | sources = [ "bin/dart2native$ext" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/bin/{{source_file_part}}" ] | 
|  | } | 
|  |  | 
|  | copy("copy_gen_kernel_snapshot") { | 
|  | deps = [ "../utils/gen_kernel" ] | 
|  | sources = [ "$root_gen_dir/gen_kernel.dart.snapshot" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/bin/snapshots/{{source_file_part}}" ] | 
|  | } | 
|  |  | 
|  | # A template for copying the things in _platform_sdk_scripts and | 
|  | # _full_sdk_scripts into bin/ | 
|  | template("copy_sdk_script") { | 
|  | assert(defined(invoker.name), "copy_sdk_script must define 'name'") | 
|  | name = invoker.name | 
|  | ext = "" | 
|  | if (is_win) { | 
|  | ext = ".bat" | 
|  | } | 
|  | copy(target_name) { | 
|  | visibility = [ | 
|  | ":copy_platform_sdk_scripts", | 
|  | ":copy_full_sdk_scripts", | 
|  | ] | 
|  | sources = [ "bin/${name}_sdk$ext" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/bin/$name$ext" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | foreach(sdk_script, _full_sdk_scripts) { | 
|  | copy_sdk_script("copy_${sdk_script}_script") { | 
|  | name = sdk_script | 
|  | } | 
|  | } | 
|  |  | 
|  | foreach(script, _scripts) { | 
|  | copy("copy_${script}_script") { | 
|  | visibility = [ | 
|  | ":copy_platform_sdk_scripts", | 
|  | ":copy_full_sdk_scripts", | 
|  | ] | 
|  | ext = "" | 
|  | if (is_win) { | 
|  | ext = ".bat" | 
|  | } | 
|  | sources = [ "bin/$script$ext" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/bin/{{source_file_part}}" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | # This is the main target for copying scripts in _platform_sdk_scripts to bin/ | 
|  | group("copy_platform_sdk_scripts") { | 
|  | visibility = [ ":create_platform_sdk" ] | 
|  | public_deps = [] | 
|  | foreach(sdk_script, _platform_sdk_scripts) { | 
|  | public_deps += [ ":copy_${sdk_script}_script" ] | 
|  | } | 
|  | foreach(script, _scripts) { | 
|  | public_deps += [ ":copy_${script}_script" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | # This is the main target for copying scripts in _full_sdk_scripts to bin/ | 
|  | group("copy_full_sdk_scripts") { | 
|  | visibility = [ ":create_full_sdk" ] | 
|  | public_deps = [] | 
|  | foreach(sdk_script, _full_sdk_scripts) { | 
|  | public_deps += [ ":copy_${sdk_script}_script" ] | 
|  | } | 
|  | foreach(script, _scripts) { | 
|  | public_deps += [ ":copy_${script}_script" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | # This loop generates "copy" targets that put snapshots into bin/snapshots | 
|  | foreach(snapshot, _full_sdk_snapshots) { | 
|  | root = root_gen_dir | 
|  |  | 
|  | # The frontend_server is output to root_out_dir so that it doesn't conflict | 
|  | # with the flutter snapshot by the same name under root_gen_dir. | 
|  | if (snapshot[0] == "frontend_server") { | 
|  | root = root_out_dir | 
|  | } | 
|  | copy("copy_${snapshot[0]}_snapshot") { | 
|  | visibility = [ | 
|  | ":copy_platform_sdk_snapshots", | 
|  | ":copy_full_sdk_snapshots", | 
|  | ] | 
|  | deps = [ snapshot[1] ] | 
|  | sources = [ "$root/${snapshot[0]}.dart.snapshot" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/bin/snapshots/{{source_file_part}}" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | # This is the main rule for copying snapshots from _platform_sdk_snapshots to | 
|  | # bin/snapshots | 
|  | group("copy_platform_sdk_snapshots") { | 
|  | visibility = [ ":create_platform_sdk" ] | 
|  | public_deps = [] | 
|  | foreach(snapshot, _platform_sdk_snapshots) { | 
|  | public_deps += [ ":copy_${snapshot[0]}_snapshot" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | # This is the main rule for copying snapshots from _full_sdk_snapshots to | 
|  | # bin/snapshots | 
|  | group("copy_full_sdk_snapshots") { | 
|  | visibility = [ ":create_full_sdk" ] | 
|  | public_deps = [] | 
|  | foreach(snapshot, _full_sdk_snapshots) { | 
|  | public_deps += [ ":copy_${snapshot[0]}_snapshot" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | # This rule writes the .packages file for dartdoc resources. | 
|  | write_file("$root_out_dir/dart-sdk/bin/resources/dartdoc/.packages", | 
|  | "dartdoc:.") | 
|  |  | 
|  | # This is the main rule for copying the files that dartdoc needs. | 
|  | group("copy_dartdoc_files") { | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | public_deps = [ | 
|  | ":copy_dartdoc_resources", | 
|  | ":copy_dartdoc_templates", | 
|  | ] | 
|  | } | 
|  |  | 
|  | # This rule copies analyzer summaries to lib/_internal | 
|  | copy("copy_analysis_summaries") { | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | deps = [ | 
|  | ":copy_libraries", | 
|  | "../utils/dartanalyzer:generate_summary_strong", | 
|  | ] | 
|  | sources = [ "$root_gen_dir/strong.sum" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}" ] | 
|  | } | 
|  |  | 
|  | # This rule copies dill files to lib/_internal. | 
|  | copy("copy_vm_dill_files") { | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | deps = [ | 
|  | ":copy_libraries", | 
|  | "../runtime/vm:kernel_platform_files", | 
|  | ] | 
|  | sources = [ "$root_out_dir/vm_platform_strong.dill" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}" ] | 
|  | } | 
|  |  | 
|  | copy("copy_abi_dill_files") { | 
|  | visibility = [ ":create_sdk_with_abi_versions" ] | 
|  | sources = [ "../tools/abiversions" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/lib/_internal/abiversions" ] | 
|  | } | 
|  |  | 
|  | copy("copy_dart2js_dill_files") { | 
|  | visibility = [ ":create_full_sdk" ] | 
|  | deps = [ | 
|  | ":copy_libraries", | 
|  | "../utils/compiler:compile_dart2js_platform", | 
|  | "../utils/compiler:compile_dart2js_server_platform", | 
|  | ] | 
|  | sources = [ | 
|  | "$root_out_dir/dart2js_platform.dill", | 
|  | "$root_out_dir/dart2js_server_platform.dill", | 
|  | ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}" ] | 
|  | } | 
|  |  | 
|  | # This rule copies ddc summaries to lib/_internal | 
|  | copy("copy_dev_compiler_summary") { | 
|  | visibility = [ ":copy_dev_compiler_sdk" ] | 
|  | deps = [ | 
|  | ":copy_libraries", | 
|  | "../utils/dartdevc:dartdevc_platform", | 
|  | ] | 
|  | sources = [ "$root_out_dir/ddc_sdk.dill" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}" ] | 
|  | } | 
|  |  | 
|  | # This rule copies DDK's JS SDK and require.js to lib/dev_compiler/kernel/amd. | 
|  | copy("copy_dev_compiler_js_amd_kernel") { | 
|  | visibility = [ ":copy_dev_compiler_js" ] | 
|  | deps = [ "../utils/dartdevc:dartdevc_kernel_sdk" ] | 
|  | gen_dir = | 
|  | get_label_info("../utils/dartdevc:dartdevc_kernel_sdk", "target_gen_dir") | 
|  | sources = [ | 
|  | "$gen_dir/kernel/amd/dart_sdk.js", | 
|  | "$gen_dir/kernel/amd/dart_sdk.js.map", | 
|  | "../third_party/requirejs/require.js", | 
|  | ] | 
|  | outputs = [ | 
|  | "$root_out_dir/dart-sdk/lib/dev_compiler/kernel/amd/{{source_file_part}}", | 
|  | ] | 
|  | } | 
|  |  | 
|  | # This rule copies DDK's JS SDK to lib/dev_compiler/kernel/common. | 
|  | copy("copy_dev_compiler_js_common_kernel") { | 
|  | visibility = [ ":copy_dev_compiler_js" ] | 
|  | deps = [ "../utils/dartdevc:dartdevc_kernel_sdk" ] | 
|  | gen_dir = | 
|  | get_label_info("../utils/dartdevc:dartdevc_kernel_sdk", "target_gen_dir") | 
|  | sources = [ | 
|  | "$gen_dir/kernel/common/dart_sdk.js", | 
|  | "$gen_dir/kernel/common/dart_sdk.js.map", | 
|  | "../pkg/dev_compiler/lib/js/common/run.js", | 
|  | ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/lib/dev_compiler/kernel/common/{{source_file_part}}" ] | 
|  | } | 
|  |  | 
|  | # This rule copies DDK's JS SDK to lib/dev_compiler/kernel/es6. | 
|  | copy("copy_dev_compiler_js_es6_kernel") { | 
|  | visibility = [ ":copy_dev_compiler_js" ] | 
|  | deps = [ "../utils/dartdevc:dartdevc_kernel_sdk" ] | 
|  | gen_dir = | 
|  | get_label_info("../utils/dartdevc:dartdevc_kernel_sdk", "target_gen_dir") | 
|  | sources = [ | 
|  | "$gen_dir/kernel/es6/dart_sdk.js", | 
|  | "$gen_dir/kernel/es6/dart_sdk.js.map", | 
|  | ] | 
|  | outputs = [ | 
|  | "$root_out_dir/dart-sdk/lib/dev_compiler/kernel/es6/{{source_file_part}}", | 
|  | ] | 
|  | } | 
|  |  | 
|  | # Copies all of the JS artifacts needed by DDC. | 
|  | group("copy_dev_compiler_js") { | 
|  | visibility = [ | 
|  | ":copy_dev_compiler_sdk", | 
|  | ":copy_dev_compiler_tools", | 
|  | ] | 
|  | public_deps = [ | 
|  | ":copy_dev_compiler_js_amd_kernel", | 
|  | ":copy_dev_compiler_js_common_kernel", | 
|  | ":copy_dev_compiler_js_es6_kernel", | 
|  | ] | 
|  | } | 
|  |  | 
|  | # This rule copies tools to go along with ddc. | 
|  | copy("copy_dev_compiler_tools") { | 
|  | visibility = [ ":copy_dev_compiler_sdk" ] | 
|  | deps = [ | 
|  | ":copy_dev_compiler_js", | 
|  | "../utils/dartdevc:stack_trace_mapper", | 
|  | ] | 
|  | dart_out = | 
|  | get_label_info("../utils/dartdevc:stack_trace_mapper", "root_out_dir") | 
|  | sources = [ "$dart_out/dev_compiler/build/web/dart_stack_trace_mapper.js" ] | 
|  | outputs = | 
|  | [ "$root_out_dir/dart-sdk/lib/dev_compiler/web/{{source_file_part}}" ] | 
|  | } | 
|  |  | 
|  | # This is the main rule for copying ddc's dependencies to lib/ | 
|  | group("copy_dev_compiler_sdk") { | 
|  | visibility = [ ":create_full_sdk" ] | 
|  | public_deps = [ | 
|  | ":copy_dev_compiler_js", | 
|  | ":copy_dev_compiler_summary", | 
|  | ":copy_dev_compiler_tools", | 
|  | ] | 
|  | } | 
|  |  | 
|  | # This rule copies header files to include/ | 
|  | copy("copy_headers") { | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | sources = [ | 
|  | "../runtime/include/dart_api.h", | 
|  | "../runtime/include/dart_native_api.h", | 
|  | "../runtime/include/dart_tools_api.h", | 
|  | ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/include/{{source_file_part}}" ] | 
|  | } | 
|  |  | 
|  | # This rule copies libraries.json files to lib/ | 
|  | copy("copy_libraries_specification") { | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | sources = [ "lib/libraries.json" ] | 
|  | deps = [ ":copy_libraries" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/lib/{{source_file_part}}" ] | 
|  | } | 
|  |  | 
|  | # This is the main rule to copy libraries in _platform_sdk_libraries to lib/ | 
|  | group("copy_platform_sdk_libraries") { | 
|  | visibility = [ | 
|  | ":create_platform_sdk", | 
|  | ":copy_libraries", | 
|  | ] | 
|  | public_deps = [] | 
|  | foreach(library, _platform_sdk_libraries) { | 
|  | public_deps += [ ":copy_${library}_library" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | # This is the main rule to copy libraries in _full_sdk_libraries to lib/ | 
|  | group("copy_full_sdk_libraries") { | 
|  | visibility = [ | 
|  | ":create_full_sdk", | 
|  | ":copy_libraries", | 
|  | ] | 
|  | public_deps = [] | 
|  | foreach(library, _full_sdk_libraries) { | 
|  | public_deps += [ ":copy_${library}_library" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | group("copy_libraries") { | 
|  | if (dart_platform_sdk) { | 
|  | public_deps = [ ":copy_platform_sdk_libraries" ] | 
|  | } else { | 
|  | public_deps = [ ":copy_full_sdk_libraries" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | # This rule writes the version file. | 
|  | action("write_version_file") { | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | inputs = [ | 
|  | "../tools/VERSION", | 
|  | "$default_git_folder/logs/HEAD", | 
|  | ] | 
|  | output = "$root_out_dir/dart-sdk/version" | 
|  | outputs = [ output ] | 
|  | script = "../tools/write_version_file.py" | 
|  | args = [ | 
|  | "--output", | 
|  | rebase_path(output), | 
|  | ] | 
|  | } | 
|  |  | 
|  | # This rule writes the revision file. | 
|  | action("write_revision_file") { | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | inputs = [ "$default_git_folder/logs/HEAD" ] | 
|  | output = "$root_out_dir/dart-sdk/revision" | 
|  | outputs = [ output ] | 
|  | script = "../tools/write_revision_file.py" | 
|  | args = [ | 
|  | "--output", | 
|  | rebase_path(output), | 
|  | ] | 
|  | } | 
|  |  | 
|  | # Copy libraries.dart to lib/_internal/libraries.dart for backwards | 
|  | # compatibility. | 
|  | # | 
|  | # TODO(sigmund): stop copying libraries.dart. Old versions (<=0.25.1-alpha.4) | 
|  | # of the analyzer package do not support the new location of this file. We | 
|  | # should be able to remove the old file once we release a newer version of | 
|  | # analyzer and popular frameworks have migrated to use it. | 
|  | copy("copy_libraries_dart") { | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | deps = [ ":copy_libraries" ] | 
|  | sources = [ "lib/_internal/sdk_library_metadata/lib/libraries.dart" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}" ] | 
|  | } | 
|  |  | 
|  | # This rule copies the README file. | 
|  | copy("copy_readme") { | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | sources = [ "../README.dart-sdk" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/README" ] | 
|  | } | 
|  |  | 
|  | # This rule copies the LICENSE file. | 
|  | copy("copy_license") { | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | sources = [ "../LICENSE" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/LICENSE" ] | 
|  | } | 
|  |  | 
|  | # This rule generates a custom dartdoc_options.yaml file. | 
|  | action("write_dartdoc_options") { | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | inputs = [ "$default_git_folder/logs/HEAD" ] | 
|  | output = "$root_out_dir/dart-sdk/dartdoc_options.yaml" | 
|  | outputs = [ output ] | 
|  | script = "../tools/write_dartdoc_options_file.py" | 
|  | args = [ | 
|  | "--output", | 
|  | rebase_path(output), | 
|  | ] | 
|  | } | 
|  |  | 
|  | # This rule copies the API readme file to lib/ | 
|  | copy("copy_api_readme") { | 
|  | visibility = [ ":create_common_sdk" ] | 
|  | sources = [ "api_readme.md" ] | 
|  | outputs = [ "$root_out_dir/dart-sdk/lib/api_readme.md" ] | 
|  | } | 
|  |  | 
|  | # Parts common to both platform and full SDKs. | 
|  | group("create_common_sdk") { | 
|  | visibility = [ ":create_sdk" ] | 
|  | public_deps = [ | 
|  | ":copy_analysis_summaries", | 
|  | ":copy_api_readme", | 
|  | ":copy_dart", | 
|  | ":copy_dartdoc_files", | 
|  | ":copy_headers", | 
|  | ":copy_libraries_dart", | 
|  | ":copy_libraries_specification", | 
|  | ":copy_license", | 
|  | ":copy_readme", | 
|  | ":copy_vm_dill_files", | 
|  | ":write_dartdoc_options", | 
|  | ":write_revision_file", | 
|  | ":write_version_file", | 
|  | ] | 
|  |  | 
|  | # We do not support AOT on ia32 and should therefore not add the | 
|  | # dart2native script (since there is no AOT compiler/runtime available) | 
|  | if (include_dart2native && dart_target_arch != "ia32") { | 
|  | public_deps += [ ":copy_dart2native" ] | 
|  | } | 
|  |  | 
|  | if (is_win) { | 
|  | public_deps += [ ":copy_7zip" ] | 
|  | } | 
|  | if (target_cpu == "x64") { | 
|  | public_deps += [ | 
|  | ":copy_language_model", | 
|  | ":copy_libtensorflowlite_c", | 
|  | ] | 
|  | } | 
|  | } | 
|  |  | 
|  | # Parts specific to the platform SDK. | 
|  | group("create_platform_sdk") { | 
|  | visibility = [ ":create_sdk" ] | 
|  | public_deps = [ | 
|  | ":copy_platform_sdk_libraries", | 
|  | ":copy_platform_sdk_scripts", | 
|  | ":copy_platform_sdk_snapshots", | 
|  | ] | 
|  | } | 
|  |  | 
|  | # Parts specific to the full SDK. | 
|  | group("create_full_sdk") { | 
|  | visibility = [ ":create_sdk" ] | 
|  |  | 
|  | public_deps = [ | 
|  | ":copy_dart2js_dill_files", | 
|  | ":copy_dev_compiler_sdk", | 
|  | ":copy_full_sdk_libraries", | 
|  | ":copy_full_sdk_scripts", | 
|  | ":copy_full_sdk_snapshots", | 
|  | ] | 
|  | } | 
|  |  | 
|  | # The main target to depend on from ../BUILD.gn | 
|  | group("create_sdk") { | 
|  | public_deps = [ ":create_common_sdk" ] | 
|  | if (dart_platform_sdk) { | 
|  | public_deps += [ ":create_platform_sdk" ] | 
|  | } else { | 
|  | public_deps += [ ":create_full_sdk" ] | 
|  | } | 
|  | } | 
|  |  | 
|  | # Same as create_sdk, but with abi version files. | 
|  | group("create_sdk_with_abi_versions") { | 
|  | public_deps = [ | 
|  | ":copy_abi_dill_files", | 
|  | ":create_sdk", | 
|  | ] | 
|  | } |