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