Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 1 | # Copyright (C) 2018 The Android Open Source Project |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | import("../gn/perfetto.gni") |
| 16 | import("../gn/wasm.gni") |
| 17 | import("../protos/perfetto/trace_processor/proto_files.gni") |
| 18 | |
Hector Dearman | 262cbe2 | 2018-05-31 13:28:21 +0100 | [diff] [blame] | 19 | ui_dir = "$root_build_dir/ui" |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 20 | ui_gen_dir = "$target_out_dir/gen" |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 21 | nodejs_root = "../buildtools/nodejs" |
| 22 | nodejs_bin = rebase_path("$nodejs_root/bin", root_build_dir) |
| 23 | |
| 24 | # +----------------------------------------------------------------------------+ |
| 25 | # | The outer "ui" target to just ninja -C out/xxx ui | |
| 26 | # +----------------------------------------------------------------------------+ |
| 27 | group("ui") { |
| 28 | deps = [ |
Michail Schwab | 20bab20 | 2018-08-02 18:17:44 -0400 | [diff] [blame] | 29 | ":assets_dist", |
Primiano Tucci | 1c752c1 | 2018-10-23 09:27:19 +0100 | [diff] [blame] | 30 | ":catapult_dist", |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 31 | ":controller_bundle_dist", |
| 32 | ":engine_bundle_dist", |
| 33 | ":frontend_bundle_dist", |
Hector Dearman | 1064151 | 2018-07-04 10:38:53 +0100 | [diff] [blame] | 34 | ":index_dist", |
Primiano Tucci | 21b91bf | 2018-08-06 16:42:07 +0100 | [diff] [blame] | 35 | ":scss", |
Hector Dearman | bf38492 | 2018-06-25 10:42:01 +0100 | [diff] [blame] | 36 | ":test_scripts", |
Hector Dearman | 1064151 | 2018-07-04 10:38:53 +0100 | [diff] [blame] | 37 | ":wasm_dist", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 38 | ] |
| 39 | } |
| 40 | |
Hector Dearman | 4c91961 | 2018-12-06 12:32:40 +0000 | [diff] [blame] | 41 | group("query") { |
| 42 | deps = [ |
| 43 | ":query_bundle_dist", |
| 44 | ":query_dist", |
| 45 | ":ui", |
| 46 | ] |
| 47 | } |
| 48 | |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 49 | # +----------------------------------------------------------------------------+ |
| 50 | # | Template used to run node binaries using the hermetic node toolchain. | |
| 51 | # +----------------------------------------------------------------------------+ |
| 52 | template("node_bin") { |
| 53 | action(target_name) { |
| 54 | forward_variables_from(invoker, |
| 55 | [ |
| 56 | "inputs", |
| 57 | "outputs", |
Hector Dearman | 4274a38 | 2018-07-18 16:14:10 +0100 | [diff] [blame] | 58 | "depfile", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 59 | ]) |
| 60 | deps = [ |
| 61 | ":node_modules", |
| 62 | ] |
| 63 | if (defined(invoker.deps)) { |
| 64 | deps += invoker.deps |
| 65 | } |
| 66 | script = "../gn/standalone/build_tool_wrapper.py" |
| 67 | _node_cmd = invoker.node_cmd |
Hector Dearman | b06d415 | 2018-05-31 16:55:04 +0100 | [diff] [blame] | 68 | args = [] |
| 69 | if (defined(invoker.suppress_stdout) && invoker.suppress_stdout) { |
| 70 | args += [ "--suppress_stdout" ] |
| 71 | } |
| 72 | if (defined(invoker.suppress_stderr) && invoker.suppress_stderr) { |
| 73 | args += [ "--suppress_stderr" ] |
| 74 | } |
| 75 | args += [ |
| 76 | "--path=$nodejs_bin", |
| 77 | "node", |
| 78 | rebase_path("node_modules/.bin/$_node_cmd", root_build_dir), |
| 79 | ] + invoker.args |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 80 | } |
| 81 | } |
| 82 | |
| 83 | # +----------------------------------------------------------------------------+ |
Hector Dearman | 92aec39 | 2018-06-19 14:33:38 +0100 | [diff] [blame] | 84 | # | Template for "sorcery" the source map resolver. | |
| 85 | # +----------------------------------------------------------------------------+ |
| 86 | template("sorcery") { |
| 87 | node_bin(target_name) { |
| 88 | assert(defined(invoker.input)) |
| 89 | assert(defined(invoker.output)) |
| 90 | forward_variables_from(invoker, [ "deps" ]) |
| 91 | inputs = [ |
| 92 | invoker.input, |
| 93 | ] |
| 94 | outputs = [ |
| 95 | invoker.output, |
| 96 | invoker.output + ".map", |
| 97 | ] |
| 98 | node_cmd = "sorcery" |
| 99 | args = [ |
| 100 | "-i", |
| 101 | rebase_path(invoker.input, root_build_dir), |
| 102 | "-o", |
| 103 | rebase_path(invoker.output, root_build_dir), |
| 104 | ] |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | # +----------------------------------------------------------------------------+ |
Hector Dearman | 6999adc | 2018-06-20 12:07:14 +0100 | [diff] [blame] | 109 | # | Template for bundling js | |
| 110 | # +----------------------------------------------------------------------------+ |
| 111 | template("bundle") { |
| 112 | node_bin(target_name) { |
| 113 | assert(defined(invoker.input)) |
| 114 | assert(defined(invoker.output)) |
| 115 | forward_variables_from(invoker, [ "deps" ]) |
| 116 | inputs = [ |
| 117 | invoker.input, |
| 118 | "rollup.config.js", |
| 119 | ] |
| 120 | outputs = [ |
| 121 | invoker.output, |
| 122 | invoker.output + ".map", |
| 123 | ] |
| 124 | node_cmd = "rollup" |
| 125 | args = [ |
| 126 | "-c", |
| 127 | rebase_path("rollup.config.js", root_build_dir), |
| 128 | rebase_path(invoker.input, root_build_dir), |
| 129 | "-o", |
| 130 | rebase_path(invoker.output, root_build_dir), |
| 131 | "-f", |
| 132 | "iife", |
| 133 | "-m", |
| 134 | "--silent", |
| 135 | ] |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | # +----------------------------------------------------------------------------+ |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 140 | # | Bundles all *.js files together resolving CommonJS require() deps. | |
| 141 | # +----------------------------------------------------------------------------+ |
| 142 | |
| 143 | # Bundle together all js sources into a bundle.js file, that will ultimately be |
| 144 | # included by the .html files. |
Hector Dearman | 5f11e52 | 2018-05-31 16:54:28 +0100 | [diff] [blame] | 145 | |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 146 | bundle("frontend_bundle") { |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 147 | deps = [ |
| 148 | ":transpile_all_ts", |
| 149 | ] |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 150 | input = "$target_out_dir/frontend/index.js" |
| 151 | output = "$target_out_dir/frontend_bundle.js" |
Hector Dearman | 5f11e52 | 2018-05-31 16:54:28 +0100 | [diff] [blame] | 152 | } |
| 153 | |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 154 | bundle("controller_bundle") { |
Hector Dearman | 5f11e52 | 2018-05-31 16:54:28 +0100 | [diff] [blame] | 155 | deps = [ |
| 156 | ":transpile_all_ts", |
| 157 | ] |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 158 | input = "$target_out_dir/controller/index.js" |
| 159 | output = "$target_out_dir/controller_bundle.js" |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 160 | } |
| 161 | |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 162 | bundle("engine_bundle") { |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 163 | deps = [ |
| 164 | ":transpile_all_ts", |
| 165 | ] |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 166 | input = "$target_out_dir/engine/index.js" |
| 167 | output = "$target_out_dir/engine_bundle.js" |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 168 | } |
| 169 | |
Hector Dearman | 4c91961 | 2018-12-06 12:32:40 +0000 | [diff] [blame] | 170 | bundle("query_bundle") { |
| 171 | deps = [ |
| 172 | ":transpile_all_ts", |
| 173 | ] |
| 174 | input = "$target_out_dir/query/index.js" |
| 175 | output = "$target_out_dir/query_bundle.js" |
| 176 | } |
| 177 | |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 178 | # +----------------------------------------------------------------------------+ |
| 179 | # | Protobuf: gen rules to create .js and .d.ts files from protos. | |
| 180 | # +----------------------------------------------------------------------------+ |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 181 | node_bin("protos_to_js") { |
| 182 | inputs = [] |
| 183 | foreach(proto, trace_processor_protos) { |
| 184 | inputs += [ "../protos/perfetto/trace_processor/$proto.proto" ] |
| 185 | } |
Hector Dearman | f5fd1e1 | 2018-06-12 18:23:49 +0100 | [diff] [blame] | 186 | inputs += [ "../protos/perfetto/config/perfetto_config.proto" ] |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 187 | outputs = [ |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 188 | "$ui_gen_dir/protos.js", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 189 | ] |
| 190 | node_cmd = "pbjs" |
| 191 | args = [ |
| 192 | "-t", |
| 193 | "static-module", |
| 194 | "-w", |
| 195 | "commonjs", |
| 196 | "-p", |
| 197 | rebase_path("../protos", root_build_dir), |
| 198 | "-o", |
| 199 | rebase_path(outputs[0], root_build_dir), |
| 200 | ] + rebase_path(inputs, root_build_dir) |
| 201 | } |
| 202 | |
| 203 | # Protobuf.js requires to first generate .js files from the .proto and then |
| 204 | # create .ts definitions for them. |
| 205 | node_bin("protos_to_ts") { |
| 206 | deps = [ |
| 207 | ":protos_to_js", |
| 208 | ] |
| 209 | inputs = [ |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 210 | "$ui_gen_dir/protos.js", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 211 | ] |
| 212 | outputs = [ |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 213 | "$ui_gen_dir/protos.d.ts", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 214 | ] |
| 215 | node_cmd = "pbts" |
| 216 | args = [ |
| 217 | "-p", |
| 218 | rebase_path("../protos", root_build_dir), |
| 219 | "-o", |
| 220 | rebase_path(outputs[0], root_build_dir), |
| 221 | rebase_path(inputs[0], root_build_dir), |
| 222 | ] |
| 223 | } |
| 224 | |
| 225 | # +----------------------------------------------------------------------------+ |
| 226 | # | TypeScript: transpiles all *.ts into .js | |
| 227 | # +----------------------------------------------------------------------------+ |
| 228 | |
Hector Dearman | 4274a38 | 2018-07-18 16:14:10 +0100 | [diff] [blame] | 229 | # Builds all .ts sources in the repo under |src|. |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 230 | node_bin("transpile_all_ts") { |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 231 | deps = [ |
| 232 | ":dist_symlink", |
| 233 | ":protos_to_ts", |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 234 | ":wasm_gen", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 235 | ] |
Hector Dearman | 4274a38 | 2018-07-18 16:14:10 +0100 | [diff] [blame] | 236 | inputs = [ |
| 237 | "tsconfig.json", |
| 238 | ] |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 239 | outputs = [ |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 240 | "$target_out_dir/frontend/index.js", |
| 241 | "$target_out_dir/engine/index.js", |
| 242 | "$target_out_dir/controller/index.js", |
Hector Dearman | 4c91961 | 2018-12-06 12:32:40 +0000 | [diff] [blame] | 243 | "$target_out_dir/query/index.js", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 244 | ] |
| 245 | |
Hector Dearman | 4274a38 | 2018-07-18 16:14:10 +0100 | [diff] [blame] | 246 | depfile = root_out_dir + "/tsc.d" |
| 247 | exec_script("../gn/standalone/glob.py", |
| 248 | [ |
| 249 | "--root=" + rebase_path(".", root_build_dir), |
| 250 | "--filter=*.ts", |
| 251 | "--exclude=node_modules", |
| 252 | "--exclude=dist", |
| 253 | "--deps=obj/ui/frontend/index.js", |
| 254 | "--output=" + rebase_path(depfile), |
| 255 | ], |
| 256 | "") |
| 257 | |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 258 | node_cmd = "tsc" |
| 259 | args = [ |
| 260 | "--project", |
| 261 | rebase_path(".", root_build_dir), |
| 262 | "--outDir", |
Hector Dearman | 262cbe2 | 2018-05-31 13:28:21 +0100 | [diff] [blame] | 263 | rebase_path(target_out_dir, root_build_dir), |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 264 | ] |
| 265 | } |
| 266 | |
| 267 | # +----------------------------------------------------------------------------+ |
Primiano Tucci | 21b91bf | 2018-08-06 16:42:07 +0100 | [diff] [blame] | 268 | # | Build css. | |
| 269 | # +----------------------------------------------------------------------------+ |
| 270 | |
Hector Dearman | fcd63bc | 2018-10-11 11:40:43 +0100 | [diff] [blame] | 271 | scss_root = "src/assets/perfetto.scss" |
| 272 | scss_srcs = [ |
| 273 | "src/assets/sidebar.scss", |
| 274 | "src/assets/topbar.scss", |
| 275 | "src/assets/record.scss", |
| 276 | "src/assets/common.scss", |
| 277 | ] |
| 278 | |
Primiano Tucci | 21b91bf | 2018-08-06 16:42:07 +0100 | [diff] [blame] | 279 | # Build css. |
| 280 | node_bin("scss") { |
| 281 | deps = [ |
| 282 | ":dist_symlink", |
| 283 | ] |
Hector Dearman | fcd63bc | 2018-10-11 11:40:43 +0100 | [diff] [blame] | 284 | inputs = [ scss_root ] + scss_srcs |
Primiano Tucci | 21b91bf | 2018-08-06 16:42:07 +0100 | [diff] [blame] | 285 | outputs = [ |
| 286 | "$ui_dir/perfetto.css", |
| 287 | ] |
| 288 | |
| 289 | node_cmd = "node-sass" |
| 290 | args = [ |
| 291 | "--quiet", |
Hector Dearman | fcd63bc | 2018-10-11 11:40:43 +0100 | [diff] [blame] | 292 | rebase_path(scss_root, root_build_dir), |
Primiano Tucci | 21b91bf | 2018-08-06 16:42:07 +0100 | [diff] [blame] | 293 | rebase_path(outputs[0], root_build_dir), |
| 294 | ] |
| 295 | } |
| 296 | |
| 297 | # +----------------------------------------------------------------------------+ |
Hector Dearman | 262cbe2 | 2018-05-31 13:28:21 +0100 | [diff] [blame] | 298 | # | Copy rules: create the final output directory. | |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 299 | # +----------------------------------------------------------------------------+ |
Hector Dearman | 1064151 | 2018-07-04 10:38:53 +0100 | [diff] [blame] | 300 | copy("index_dist") { |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 301 | sources = [ |
| 302 | "index.html", |
| 303 | ] |
| 304 | outputs = [ |
Hector Dearman | 262cbe2 | 2018-05-31 13:28:21 +0100 | [diff] [blame] | 305 | "$ui_dir/index.html", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 306 | ] |
| 307 | } |
| 308 | |
Hector Dearman | 4c91961 | 2018-12-06 12:32:40 +0000 | [diff] [blame] | 309 | copy("query_dist") { |
| 310 | sources = [ |
| 311 | "query.html", |
| 312 | ] |
| 313 | outputs = [ |
| 314 | "$ui_dir/query.html", |
| 315 | ] |
| 316 | } |
| 317 | |
Michail Schwab | 20bab20 | 2018-08-02 18:17:44 -0400 | [diff] [blame] | 318 | copy("assets_dist") { |
| 319 | sources = [ |
Hector Dearman | fcd63bc | 2018-10-11 11:40:43 +0100 | [diff] [blame] | 320 | "src/assets/logo-3d.png", |
| 321 | "src/assets/logo.png", |
| 322 | ] + [ scss_root ] + scss_srcs |
Michail Schwab | 20bab20 | 2018-08-02 18:17:44 -0400 | [diff] [blame] | 323 | outputs = [ |
Hector Dearman | 7cf6b10 | 2018-08-09 17:30:57 +0100 | [diff] [blame] | 324 | "$ui_dir/assets/{{source_file_part}}", |
Michail Schwab | 20bab20 | 2018-08-02 18:17:44 -0400 | [diff] [blame] | 325 | ] |
| 326 | } |
Hector Dearman | daca6cd | 2018-07-11 12:55:34 +0100 | [diff] [blame] | 327 | |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 328 | sorcery("frontend_bundle_dist") { |
Hector Dearman | 262cbe2 | 2018-05-31 13:28:21 +0100 | [diff] [blame] | 329 | deps = [ |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 330 | ":frontend_bundle", |
Hector Dearman | 262cbe2 | 2018-05-31 13:28:21 +0100 | [diff] [blame] | 331 | ] |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 332 | input = "$target_out_dir/frontend_bundle.js" |
| 333 | output = "$ui_dir/frontend_bundle.js" |
Hector Dearman | 5f11e52 | 2018-05-31 16:54:28 +0100 | [diff] [blame] | 334 | } |
| 335 | |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 336 | sorcery("controller_bundle_dist") { |
Hector Dearman | 5f11e52 | 2018-05-31 16:54:28 +0100 | [diff] [blame] | 337 | deps = [ |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 338 | ":controller_bundle", |
Hector Dearman | 5f11e52 | 2018-05-31 16:54:28 +0100 | [diff] [blame] | 339 | ] |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 340 | input = "$target_out_dir/controller_bundle.js" |
| 341 | output = "$ui_dir/controller_bundle.js" |
Hector Dearman | 262cbe2 | 2018-05-31 13:28:21 +0100 | [diff] [blame] | 342 | } |
| 343 | |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 344 | sorcery("engine_bundle_dist") { |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 345 | deps = [ |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 346 | ":engine_bundle", |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 347 | ] |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 348 | input = "$target_out_dir/engine_bundle.js" |
| 349 | output = "$ui_dir/engine_bundle.js" |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 350 | } |
| 351 | |
Hector Dearman | 4c91961 | 2018-12-06 12:32:40 +0000 | [diff] [blame] | 352 | sorcery("query_bundle_dist") { |
| 353 | deps = [ |
| 354 | ":query_bundle", |
| 355 | ] |
| 356 | input = "$target_out_dir/query_bundle.js" |
| 357 | output = "$ui_dir/query_bundle.js" |
| 358 | } |
| 359 | |
Hector Dearman | 1064151 | 2018-07-04 10:38:53 +0100 | [diff] [blame] | 360 | copy("wasm_dist") { |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 361 | deps = [ |
Hector Dearman | e845074 | 2018-08-31 14:36:51 +0100 | [diff] [blame] | 362 | "//src/trace_processor:trace_processor.wasm($wasm_toolchain)", |
Primiano Tucci | 1c752c1 | 2018-10-23 09:27:19 +0100 | [diff] [blame] | 363 | "//tools/trace_to_text:trace_to_text.wasm($wasm_toolchain)", |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 364 | ] |
| 365 | sources = [ |
Hector Dearman | e845074 | 2018-08-31 14:36:51 +0100 | [diff] [blame] | 366 | "$root_build_dir/wasm/trace_processor.wasm", |
Primiano Tucci | 1c752c1 | 2018-10-23 09:27:19 +0100 | [diff] [blame] | 367 | "$root_build_dir/wasm/trace_to_text.wasm", |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 368 | ] |
| 369 | outputs = [ |
| 370 | "$ui_dir/{{source_file_part}}", |
| 371 | ] |
| 372 | } |
| 373 | |
| 374 | copy("wasm_gen") { |
| 375 | deps = [ |
| 376 | ":dist_symlink", |
Primiano Tucci | 1c752c1 | 2018-10-23 09:27:19 +0100 | [diff] [blame] | 377 | |
| 378 | # trace_processor |
Hector Dearman | e845074 | 2018-08-31 14:36:51 +0100 | [diff] [blame] | 379 | "//src/trace_processor:trace_processor.d.ts($wasm_toolchain)", |
| 380 | "//src/trace_processor:trace_processor.js($wasm_toolchain)", |
| 381 | "//src/trace_processor:trace_processor.wasm($wasm_toolchain)", |
Primiano Tucci | 1c752c1 | 2018-10-23 09:27:19 +0100 | [diff] [blame] | 382 | |
| 383 | # trace_to_text |
| 384 | "//tools/trace_to_text:trace_to_text.d.ts($wasm_toolchain)", |
| 385 | "//tools/trace_to_text:trace_to_text.js($wasm_toolchain)", |
| 386 | "//tools/trace_to_text:trace_to_text.wasm($wasm_toolchain)", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 387 | ] |
| 388 | sources = [ |
Primiano Tucci | 1c752c1 | 2018-10-23 09:27:19 +0100 | [diff] [blame] | 389 | # trace_processor |
Hector Dearman | e845074 | 2018-08-31 14:36:51 +0100 | [diff] [blame] | 390 | "$root_build_dir/wasm/trace_processor.d.ts", |
| 391 | "$root_build_dir/wasm/trace_processor.js", |
| 392 | "$root_build_dir/wasm/trace_processor.wasm", |
Primiano Tucci | 1c752c1 | 2018-10-23 09:27:19 +0100 | [diff] [blame] | 393 | |
| 394 | # trace_to_text |
| 395 | "$root_build_dir/wasm/trace_to_text.d.ts", |
| 396 | "$root_build_dir/wasm/trace_to_text.js", |
| 397 | "$root_build_dir/wasm/trace_to_text.wasm", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 398 | ] |
Hector Dearman | a824ba9 | 2018-09-19 17:51:25 +0100 | [diff] [blame] | 399 | if (is_debug) { |
Primiano Tucci | 1c752c1 | 2018-10-23 09:27:19 +0100 | [diff] [blame] | 400 | sources += [ |
| 401 | "$root_build_dir/wasm/trace_processor.wasm.map", |
| 402 | "$root_build_dir/wasm/trace_to_text.wasm.map", |
| 403 | ] |
Hector Dearman | a824ba9 | 2018-09-19 17:51:25 +0100 | [diff] [blame] | 404 | } |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 405 | outputs = [ |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 406 | "$ui_gen_dir/{{source_file_part}}", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 407 | ] |
| 408 | } |
| 409 | |
Primiano Tucci | 1c752c1 | 2018-10-23 09:27:19 +0100 | [diff] [blame] | 410 | # Copy over the vulcanized legacy trace viewer. |
| 411 | copy("catapult_dist") { |
| 412 | sources = [ |
| 413 | "../buildtools/catapult_trace_viewer/catapult_trace_viewer.html", |
| 414 | "../buildtools/catapult_trace_viewer/catapult_trace_viewer.js", |
| 415 | ] |
| 416 | outputs = [ |
| 417 | "$ui_dir/assets/{{source_file_part}}", |
| 418 | ] |
| 419 | } |
| 420 | |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 421 | # +----------------------------------------------------------------------------+ |
Deepanjan Roy | acf8c07 | 2018-07-13 11:37:04 -0400 | [diff] [blame] | 422 | # | Node JS: Creates a symlink in the out directory to node_modules. | |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 423 | # +----------------------------------------------------------------------------+ |
| 424 | |
| 425 | action("check_node_exists") { |
| 426 | script = "../gn/standalone/check_buildtool_exists.py" |
Hector Dearman | 48783b1 | 2018-05-22 08:26:06 +0100 | [diff] [blame] | 427 | args = [ |
| 428 | nodejs_bin, |
| 429 | "--touch", |
| 430 | rebase_path("$target_out_dir/node_exists", ""), |
| 431 | ] |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 432 | inputs = [] |
| 433 | outputs = [ |
Hector Dearman | 48783b1 | 2018-05-22 08:26:06 +0100 | [diff] [blame] | 434 | "$target_out_dir/node_exists", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 435 | ] |
| 436 | } |
| 437 | |
| 438 | # Creates a symlink from out/xxx/ui/node_modules -> ../../../ui/node_modules. |
Hector Dearman | b06d415 | 2018-05-31 16:55:04 +0100 | [diff] [blame] | 439 | # This allows to run rollup and other node tools from the out/xxx directory. |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 440 | action("node_modules_symlink") { |
| 441 | deps = [ |
| 442 | ":check_node_exists", |
| 443 | ] |
Hector Dearman | 6186c87 | 2018-05-31 13:28:48 +0100 | [diff] [blame] | 444 | |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 445 | script = "../gn/standalone/build_tool_wrapper.py" |
Hector Dearman | 6186c87 | 2018-05-31 13:28:48 +0100 | [diff] [blame] | 446 | stamp_file = "$target_out_dir/.$target_name.stamp" |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 447 | args = [ |
Hector Dearman | 6186c87 | 2018-05-31 13:28:48 +0100 | [diff] [blame] | 448 | "--stamp", |
| 449 | rebase_path(stamp_file, root_build_dir), |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 450 | "/bin/ln", |
| 451 | "-fns", |
Hector Dearman | a817a06 | 2018-06-01 11:01:07 +0100 | [diff] [blame] | 452 | rebase_path("node_modules", target_out_dir), |
Hector Dearman | 6186c87 | 2018-05-31 13:28:48 +0100 | [diff] [blame] | 453 | rebase_path("$target_out_dir/node_modules", root_build_dir), |
| 454 | ] |
| 455 | outputs = [ |
| 456 | stamp_file, |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 457 | ] |
| 458 | } |
| 459 | |
Hector Dearman | 6186c87 | 2018-05-31 13:28:48 +0100 | [diff] [blame] | 460 | group("node_modules") { |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 461 | deps = [ |
| 462 | ":node_modules_symlink", |
| 463 | ] |
| 464 | } |
| 465 | |
| 466 | # Creates a symlink from //ui/dist -> ../../out/xxx/ui. Used only for |
| 467 | # autocompletion in IDEs. The problem this is solving is that in tsconfig.json |
| 468 | # we can't possibly know the path to ../../out/xxx for outDir. Instead, we set |
| 469 | # outDir to "./dist" and create a symlink on the first build. |
| 470 | action("dist_symlink") { |
| 471 | script = "../gn/standalone/build_tool_wrapper.py" |
Hector Dearman | 262cbe2 | 2018-05-31 13:28:21 +0100 | [diff] [blame] | 472 | stamp_file = "$target_out_dir/.$target_name.stamp" |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 473 | args = [ |
| 474 | "--stamp", |
| 475 | rebase_path(stamp_file, root_build_dir), |
| 476 | "/bin/ln", |
| 477 | "-fns", |
Hector Dearman | 262cbe2 | 2018-05-31 13:28:21 +0100 | [diff] [blame] | 478 | rebase_path(target_out_dir, "."), |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 479 | rebase_path("dist", root_build_dir), |
| 480 | ] |
| 481 | inputs = [ |
| 482 | "$root_build_dir", |
| 483 | ] |
| 484 | outputs = [ |
| 485 | stamp_file, |
| 486 | ] |
| 487 | } |
Hector Dearman | bf38492 | 2018-06-25 10:42:01 +0100 | [diff] [blame] | 488 | |
| 489 | group("test_scripts") { |
| 490 | deps = [ |
| 491 | ":copy_tests_script", |
| 492 | ":copy_unittests_script", |
| 493 | ] |
| 494 | } |
| 495 | |
| 496 | copy("copy_unittests_script") { |
| 497 | sources = [ |
| 498 | "config/ui_unittests_template", |
| 499 | ] |
| 500 | outputs = [ |
| 501 | "$root_build_dir/ui_unittests", |
| 502 | ] |
| 503 | } |
| 504 | |
| 505 | copy("copy_tests_script") { |
| 506 | sources = [ |
| 507 | "config/ui_tests_template", |
| 508 | ] |
| 509 | outputs = [ |
| 510 | "$root_build_dir/ui_tests", |
| 511 | ] |
| 512 | } |