| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import("../../utils/invoke_dart.gni") |
| 6 |
| 5 # Currently paths here are hard coded for convenience in building Mojo/Flutter. | 7 # Currently paths here are hard coded for convenience in building Mojo/Flutter. |
| 6 declare_args() { | 8 declare_args() { |
| 7 # Specify the path to a host compatible version of the Dart SDK. | 9 # Specify the path to a host compatible version of the Dart SDK. |
| 8 # This SDK is used to compile the Observatory frontend sources. | 10 # This SDK is used to compile the Observatory frontend sources. |
| 9 dart_host_sdk = rebase_path("//third_party/dart-sdk/dart-sdk") | 11 dart_host_sdk = rebase_path("//third_party/dart-sdk/dart-sdk") |
| 10 | 12 |
| 11 # Specify the path to a host compatible version of pub. | 13 # Specify the path to a host compatible version of pub. |
| 12 # This is used to compile the Observatory frontend sources. | 14 # This is used to compile the Observatory frontend sources. |
| 15 # |
| 16 # The observatory build tool searches for pub first using this GN arg, then |
| 17 # for the checked-in SDK, and if that doesn't work, it uses the dart_bootstrap |
| 18 # built as part of the build to invoke pub. If this arg is set to a non-empty |
| 19 # string, we assume that there is no need for dart_bootstrap. If it is set to |
| 20 # "", then we assume that there may be a need for dart_bootstrap. |
| 13 dart_host_pub_exe = rebase_path("$dart_host_sdk/bin/pub") | 21 dart_host_pub_exe = rebase_path("$dart_host_sdk/bin/pub") |
| 14 } | 22 } |
| 15 | 23 |
| 24 # Construct arguments to the observatory tool for finding pub. |
| 25 pub_build_deps = [] |
| 26 pub_build_args = [] |
| 27 if (dart_host_pub_exe != "") { |
| 28 pub_build_args = [ |
| 29 "--pub-executable", |
| 30 dart_host_pub_exe, |
| 31 ] |
| 32 } else { |
| 33 pub_build_deps += [ "../bin:dart_bootstrap($host_toolchain)" ] |
| 34 |
| 35 dart_out_dir = |
| 36 get_label_info("../bin:dart_bootstrap($host_toolchain)", "root_out_dir") |
| 37 dart_bootstrap = |
| 38 rebase_path("$dart_out_dir/dart_bootstrap$dart_executable_suffix") |
| 39 |
| 40 pub_build_args = [ |
| 41 "--sdk=True", |
| 42 "--dart-executable", |
| 43 dart_bootstrap, |
| 44 ] |
| 45 } |
| 46 |
| 47 current_dir = rebase_path(".", "//") |
| 48 |
| 16 # Helper build rules for packaging the Dart observatory resources. | 49 # Helper build rules for packaging the Dart observatory resources. |
| 17 observatory_sources_gypi = | 50 observatory_sources_gypi = |
| 18 exec_script("../../tools/gypi_to_gn.py", | 51 exec_script("../../tools/gypi_to_gn.py", |
| 19 [ rebase_path("../observatory/observatory_sources.gypi") ], | 52 [ rebase_path("../observatory/observatory_sources.gypi") ], |
| 20 "scope", | 53 "scope", |
| 21 [ "../observatory/observatory_sources.gypi" ]) | 54 [ "../observatory/observatory_sources.gypi" ]) |
| 22 | 55 |
| 23 copy("copy_observatory") { | 56 copy("copy_observatory") { |
| 24 sources = rebase_path(observatory_sources_gypi.sources, "", ".") | 57 sources = rebase_path(observatory_sources_gypi.sources, "", ".") |
| 25 outputs = [ | 58 outputs = [ |
| 26 "$root_gen_dir/observatory_copy/{{source_root_relative_dir}}/{{source_file_p
art}}", | 59 "$root_gen_dir/observatory_copy/{{source_root_relative_dir}}/{{source_file_p
art}}", |
| 27 ] | 60 ] |
| 28 } | 61 } |
| 29 | 62 |
| 30 action("write_observatory_pubspec_yaml") { | 63 action("write_observatory_pubspec_yaml") { |
| 31 deps = [ | 64 deps = [ ":copy_observatory" ] + pub_build_deps |
| 32 ":copy_observatory", | |
| 33 ] | |
| 34 | |
| 35 script = "../../tools/observatory_tool.py" | |
| 36 | 65 |
| 37 inputs = [ | 66 inputs = [ |
| 38 rebase_path("pubspec.yaml"), | 67 rebase_path("pubspec.yaml"), |
| 39 ] | 68 ] |
| 40 | 69 |
| 41 current_dir = rebase_path(".", "//") | 70 script = "../../tools/observatory_tool.py" |
| 42 args = [ | 71 args = |
| 43 "--silent=True", | 72 pub_build_args + [ |
| 44 "--pub-executable", | 73 "--silent=True", |
| 45 dart_host_pub_exe, | 74 "--directory", |
| 46 "--directory", | 75 rebase_path("$root_gen_dir/observatory_copy/$current_dir/"), |
| 47 rebase_path("$root_gen_dir/observatory_copy/$current_dir/"), | 76 "--command", |
| 48 "--command", | 77 "rewrite", |
| 49 "rewrite", | 78 rebase_path("../observatory/pubspec.yaml"), |
| 50 rebase_path("../observatory/pubspec.yaml"), | 79 rebase_path("$root_gen_dir/observatory_copy/$current_dir/pubspec.yaml"), |
| 51 rebase_path("$root_gen_dir/observatory_copy/$current_dir/pubspec.yaml"), | 80 "../../third_party/", |
| 52 "../../third_party/", | 81 rebase_path("../../third_party/"), |
| 53 rebase_path("../../third_party/"), | 82 ] |
| 54 ] | |
| 55 | 83 |
| 56 outputs = [ | 84 outputs = [ |
| 57 "$root_gen_dir/observatory_copy/$current_dir/pubspec.yaml", | 85 "$root_gen_dir/observatory_copy/$current_dir/pubspec.yaml", |
| 58 ] | 86 ] |
| 59 } | 87 } |
| 60 | 88 |
| 61 action("copy_observatory_deps") { | 89 action("copy_observatory_deps") { |
| 62 deps = [ | 90 deps = [ ":write_observatory_pubspec_yaml" ] + pub_build_deps |
| 63 ":write_observatory_pubspec_yaml", | 91 |
| 92 inputs = [ |
| 93 "$root_gen_dir/observatory_copy/$current_dir/pubspec.yaml", |
| 64 ] | 94 ] |
| 65 | 95 |
| 66 script = "../../tools/observatory_tool.py" | 96 script = "../../tools/observatory_tool.py" |
| 67 | 97 args = pub_build_args + [ |
| 68 current_dir = rebase_path(".", "//") | 98 "--silent=True", |
| 69 inputs = [ | 99 "--stamp", |
| 70 script, | 100 rebase_path( |
| 71 "$root_gen_dir/observatory_copy/$current_dir/pubspec.yaml", | 101 "$root_gen_dir/observatory_copy/$current_dir/packages.stamp"), |
| 72 ] | 102 "--directory", |
| 73 | 103 rebase_path("$root_gen_dir/observatory_copy/$current_dir/"), |
| 74 args = [ | 104 "--command", |
| 75 "--silent=True", | 105 "get", |
| 76 "--pub-executable", | 106 ] |
| 77 dart_host_pub_exe, | |
| 78 "--stamp", | |
| 79 rebase_path("$root_gen_dir/observatory_copy/$current_dir/packages.stamp"), | |
| 80 "--directory", | |
| 81 rebase_path("$root_gen_dir/observatory_copy/$current_dir/"), | |
| 82 "--command", | |
| 83 "get", | |
| 84 ] | |
| 85 | 107 |
| 86 outputs = [ | 108 outputs = [ |
| 87 "$root_gen_dir/observatory_copy/$current_dir/packages.stamp", | 109 "$root_gen_dir/observatory_copy/$current_dir/packages.stamp", |
| 88 ] | 110 ] |
| 89 } | 111 } |
| 90 | 112 |
| 91 action("pub_build_observatory") { | 113 action("pub_build_observatory") { |
| 92 current_dir = rebase_path(".", "//") | 114 deps = [ |
| 115 ":copy_observatory", |
| 116 ":copy_observatory_deps", |
| 117 ] + pub_build_deps |
| 118 |
| 93 sources = rebase_path(observatory_sources_gypi.sources, | 119 sources = rebase_path(observatory_sources_gypi.sources, |
| 94 "", | 120 "", |
| 95 "$root_gen_dir/observatory_copy/$current_dir") | 121 "$root_gen_dir/observatory_copy/$current_dir") |
| 96 | 122 |
| 97 deps = [ | 123 inputs = |
| 98 ":copy_observatory", | 124 sources + [ "$root_gen_dir/observatory_copy/$current_dir/packages.stamp" ] |
| 99 ":copy_observatory_deps", | |
| 100 ] | |
| 101 | 125 |
| 102 script = "../../tools/observatory_tool.py" | 126 script = "../../tools/observatory_tool.py" |
| 103 | 127 args = pub_build_args + [ |
| 104 inputs = [ | 128 "--silent=True", |
| 105 script, | 129 "--directory", |
| 106 "$root_gen_dir/observatory_copy/$current_dir/packages.stamp", | 130 rebase_path("$root_gen_dir/observatory_copy/$current_dir/"), |
| 107 ] | 131 "--command", |
| 108 inputs += sources | 132 "build", |
| 109 | 133 rebase_path("$root_out_dir/observatory/build"), |
| 110 args = [ | 134 ] |
| 111 "--silent=True", | |
| 112 "--pub-executable", | |
| 113 dart_host_pub_exe, | |
| 114 "--directory", | |
| 115 rebase_path("$root_gen_dir/observatory_copy/$current_dir/"), | |
| 116 "--command", | |
| 117 "build", | |
| 118 rebase_path("$root_out_dir/observatory/build"), | |
| 119 ] | |
| 120 | 135 |
| 121 outputs = [ | 136 outputs = [ |
| 122 "$root_out_dir/observatory/build/web/main.dart.js", | 137 "$root_out_dir/observatory/build/web/main.dart.js", |
| 123 ] | 138 ] |
| 124 } | 139 } |
| 125 | 140 |
| 126 action("deploy_observatory") { | 141 action("deploy_observatory") { |
| 127 deps = [ | 142 deps = [ ":pub_build_observatory" ] + pub_build_deps |
| 128 ":pub_build_observatory", | |
| 129 ] | |
| 130 | 143 |
| 131 script = "../../tools/observatory_tool.py" | 144 script = "../../tools/observatory_tool.py" |
| 132 | 145 |
| 133 inputs = [ | 146 inputs = [ |
| 134 script, | 147 script, |
| 135 "$root_out_dir/observatory/build/web/main.dart.js", | 148 "$root_out_dir/observatory/build/web/main.dart.js", |
| 136 ] | 149 ] |
| 137 | 150 |
| 138 args = [ | 151 args = pub_build_args + [ |
| 139 "--silent=True", | 152 "--silent=True", |
| 140 "--pub-executable", | 153 "--directory", |
| 141 dart_host_pub_exe, | 154 rebase_path("$root_out_dir/observatory"), |
| 142 "--directory", | 155 "--command", |
| 143 rebase_path("$root_out_dir/observatory"), | 156 "deploy", |
| 144 "--command", | 157 ] |
| 145 "deploy", | |
| 146 ] | |
| 147 | 158 |
| 148 outputs = [ | 159 outputs = [ |
| 149 "$root_out_dir/observatory/deployed/web/main.dart.js", | 160 "$root_out_dir/observatory/deployed/web/main.dart.js", |
| 150 ] | 161 ] |
| 151 } | 162 } |
| 152 | 163 |
| 153 template("observatory_archive") { | 164 template("observatory_archive") { |
| 154 assert(defined(invoker.inner_namespace), | 165 assert(defined(invoker.inner_namespace), |
| 155 "Need inner_namespace in $target_name") | 166 "Need inner_namespace in $target_name") |
| 156 assert(defined(invoker.outer_namespace), | 167 assert(defined(invoker.outer_namespace), |
| 157 "Need outer_namespace in $target_name") | 168 "Need outer_namespace in $target_name") |
| 158 enable_compression = false | 169 enable_compression = false |
| 159 if (defined(invoker.compress) && invoker.compress) { | 170 if (defined(invoker.compress) && invoker.compress) { |
| 160 enable_compression = true | 171 enable_compression = true |
| 161 } | 172 } |
| 162 action(target_name) { | 173 action(target_name) { |
| 163 deps = [ | 174 deps = [ |
| 164 ":deploy_observatory", | 175 ":deploy_observatory", |
| 165 ] | 176 ] |
| 166 | 177 |
| 167 script = "../tools/create_archive.py" | |
| 168 | |
| 169 inputs = [ | 178 inputs = [ |
| 170 script, | |
| 171 "$root_out_dir/observatory/deployed/web/main.dart.js", | 179 "$root_out_dir/observatory/deployed/web/main.dart.js", |
| 172 ] | 180 ] |
| 173 | 181 |
| 174 inner_namespace = invoker.inner_namespace | 182 inner_namespace = invoker.inner_namespace |
| 175 outer_namespace = invoker.outer_namespace | 183 outer_namespace = invoker.outer_namespace |
| 176 output_name = target_name | 184 output_name = target_name |
| 185 |
| 186 script = "../tools/create_archive.py" |
| 177 args = [ | 187 args = [ |
| 178 "--output", | 188 "--output", |
| 179 rebase_path("$root_gen_dir/observatory/${output_name}.cc"), | 189 rebase_path("$root_gen_dir/observatory/${output_name}.cc"), |
| 180 "--tar_output", | 190 "--tar_output", |
| 181 rebase_path("$root_gen_dir/observatory/${output_name}.tar"), | 191 rebase_path("$root_gen_dir/observatory/${output_name}.tar"), |
| 182 "--outer_namespace", | 192 "--outer_namespace", |
| 183 outer_namespace, | 193 outer_namespace, |
| 184 "--inner_namespace", | 194 "--inner_namespace", |
| 185 inner_namespace, | 195 inner_namespace, |
| 186 "--name", | 196 "--name", |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 232 |
| 223 source_set("standalone_observatory_archive") { | 233 source_set("standalone_observatory_archive") { |
| 224 deps = [ | 234 deps = [ |
| 225 ":standalone_archive_observatory", | 235 ":standalone_archive_observatory", |
| 226 ] | 236 ] |
| 227 | 237 |
| 228 sources = [ | 238 sources = [ |
| 229 rebase_path("$root_gen_dir/observatory/standalone_archive_observatory.cc"), | 239 rebase_path("$root_gen_dir/observatory/standalone_archive_observatory.cc"), |
| 230 ] | 240 ] |
| 231 } | 241 } |
| OLD | NEW |