blob: b488557568d8219776ebf51f901186b3c36eb0d7 [file] [log] [blame]
Primiano Tucci3faad742018-05-16 19:30:48 +01001# 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
15import("../gn/perfetto.gni")
16import("../gn/wasm.gni")
17import("../protos/perfetto/trace_processor/proto_files.gni")
18
Primiano Tucci02c11762019-08-30 00:57:59 +020019# Prevent that this file is accidentally included in embedder builds.
20assert(enable_perfetto_ui)
21
Hector Dearman262cbe22018-05-31 13:28:21 +010022ui_dir = "$root_build_dir/ui"
Nicolò Mazzucato1ed43cb2019-07-30 16:25:17 +010023chrome_extension_dir = "$root_build_dir/chrome_extension"
Hector Dearman21fa9162018-06-22 14:50:29 +010024ui_gen_dir = "$target_out_dir/gen"
Primiano Tucci3faad742018-05-16 19:30:48 +010025nodejs_root = "../buildtools/nodejs"
26nodejs_bin = rebase_path("$nodejs_root/bin", root_build_dir)
27
28# +----------------------------------------------------------------------------+
29# | The outer "ui" target to just ninja -C out/xxx ui |
30# +----------------------------------------------------------------------------+
Primiano Tucci3552aaf2020-01-14 20:20:52 +000031
Primiano Tucci3faad742018-05-16 19:30:48 +010032group("ui") {
33 deps = [
Nicolò Mazzucato1ed43cb2019-07-30 16:25:17 +010034 ":chrome_extension_assets_dist",
35 ":chrome_extension_bundle_dist",
Primiano Tucci3552aaf2020-01-14 20:20:52 +000036 ":dist",
37 ":gen_dist_file_map",
38 ":service_worker_bundle_dist",
Hector Dearmanbf384922018-06-25 10:42:01 +010039 ":test_scripts",
Primiano Tucci3552aaf2020-01-14 20:20:52 +000040
41 # IMPORTANT: Only add deps here if they are NOT part of the production UI
42 # (e.g., tests, extensions, ...). Any UI dep should go in the
43 # |ui_dist_targets| list below. The only exception is the service worker
44 # target, that depends on that list.
Primiano Tucci3faad742018-05-16 19:30:48 +010045 ]
46}
47
Primiano Tucci3552aaf2020-01-14 20:20:52 +000048# The list of targets that produces dist/ files for the UI. This list is used
49# also by the gen_dist_file_map to generate the map of hashes of all UI files,
50# which is turn used by the service worker code for the offline caching.
51ui_dist_targets = [
52 ":assets_dist",
53 ":catapult_dist",
54 ":controller_bundle_dist",
55 ":engine_bundle_dist",
56 ":frontend_bundle_dist",
57 ":index_dist",
58 ":scss",
59 ":typefaces_dist",
60 ":wasm_dist",
61]
62
63# Buils the ui, but not service worker, tests and extensions.
64group("dist") {
65 deps = ui_dist_targets
66}
67
68# A minimal page to profile the WASM engine without the all UI.
Hector Dearman4c919612018-12-06 12:32:40 +000069group("query") {
70 deps = [
71 ":query_bundle_dist",
72 ":query_dist",
73 ":ui",
74 ]
75}
76
Primiano Tucci3faad742018-05-16 19:30:48 +010077# +----------------------------------------------------------------------------+
78# | Template used to run node binaries using the hermetic node toolchain. |
79# +----------------------------------------------------------------------------+
80template("node_bin") {
81 action(target_name) {
82 forward_variables_from(invoker,
83 [
84 "inputs",
85 "outputs",
Hector Dearman4274a382018-07-18 16:14:10 +010086 "depfile",
Primiano Tucci3faad742018-05-16 19:30:48 +010087 ])
Primiano Tucci2925e9d2020-01-27 10:15:58 +000088 deps = [ ":node_modules" ]
Primiano Tucci3faad742018-05-16 19:30:48 +010089 if (defined(invoker.deps)) {
90 deps += invoker.deps
91 }
92 script = "../gn/standalone/build_tool_wrapper.py"
93 _node_cmd = invoker.node_cmd
Hector Dearmanb06d4152018-05-31 16:55:04 +010094 args = []
95 if (defined(invoker.suppress_stdout) && invoker.suppress_stdout) {
96 args += [ "--suppress_stdout" ]
97 }
98 if (defined(invoker.suppress_stderr) && invoker.suppress_stderr) {
99 args += [ "--suppress_stderr" ]
100 }
101 args += [
102 "--path=$nodejs_bin",
103 "node",
104 rebase_path("node_modules/.bin/$_node_cmd", root_build_dir),
105 ] + invoker.args
Primiano Tucci3faad742018-05-16 19:30:48 +0100106 }
107}
108
109# +----------------------------------------------------------------------------+
Hector Dearman92aec392018-06-19 14:33:38 +0100110# | Template for "sorcery" the source map resolver. |
111# +----------------------------------------------------------------------------+
112template("sorcery") {
113 node_bin(target_name) {
114 assert(defined(invoker.input))
115 assert(defined(invoker.output))
116 forward_variables_from(invoker, [ "deps" ])
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000117 inputs = [ invoker.input ]
Hector Dearman92aec392018-06-19 14:33:38 +0100118 outputs = [
119 invoker.output,
120 invoker.output + ".map",
121 ]
122 node_cmd = "sorcery"
123 args = [
124 "-i",
125 rebase_path(invoker.input, root_build_dir),
126 "-o",
127 rebase_path(invoker.output, root_build_dir),
128 ]
129 }
130}
131
132# +----------------------------------------------------------------------------+
Hector Dearman6999adc2018-06-20 12:07:14 +0100133# | Template for bundling js |
134# +----------------------------------------------------------------------------+
135template("bundle") {
136 node_bin(target_name) {
137 assert(defined(invoker.input))
138 assert(defined(invoker.output))
139 forward_variables_from(invoker, [ "deps" ])
140 inputs = [
141 invoker.input,
142 "rollup.config.js",
143 ]
144 outputs = [
145 invoker.output,
146 invoker.output + ".map",
147 ]
148 node_cmd = "rollup"
149 args = [
150 "-c",
151 rebase_path("rollup.config.js", root_build_dir),
152 rebase_path(invoker.input, root_build_dir),
153 "-o",
154 rebase_path(invoker.output, root_build_dir),
155 "-f",
156 "iife",
157 "-m",
158 "--silent",
159 ]
160 }
161}
162
163# +----------------------------------------------------------------------------+
Primiano Tucci3faad742018-05-16 19:30:48 +0100164# | Bundles all *.js files together resolving CommonJS require() deps. |
165# +----------------------------------------------------------------------------+
166
167# Bundle together all js sources into a bundle.js file, that will ultimately be
168# included by the .html files.
Hector Dearman5f11e522018-05-31 16:54:28 +0100169
Hector Dearman81804d12018-07-10 11:38:15 +0100170bundle("frontend_bundle") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000171 deps = [ ":transpile_all_ts" ]
Hector Dearman81804d12018-07-10 11:38:15 +0100172 input = "$target_out_dir/frontend/index.js"
173 output = "$target_out_dir/frontend_bundle.js"
Hector Dearman5f11e522018-05-31 16:54:28 +0100174}
175
Nicolò Mazzucato1ed43cb2019-07-30 16:25:17 +0100176bundle("chrome_extension_bundle") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000177 deps = [ ":transpile_all_ts" ]
Nicolò Mazzucato1ed43cb2019-07-30 16:25:17 +0100178 input = "$target_out_dir/chrome_extension/index.js"
179 output = "$target_out_dir/chrome_extension_bundle.js"
180}
181
Hector Dearman81804d12018-07-10 11:38:15 +0100182bundle("controller_bundle") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000183 deps = [ ":transpile_all_ts" ]
Hector Dearman81804d12018-07-10 11:38:15 +0100184 input = "$target_out_dir/controller/index.js"
185 output = "$target_out_dir/controller_bundle.js"
Primiano Tucci3faad742018-05-16 19:30:48 +0100186}
187
Hector Dearman81804d12018-07-10 11:38:15 +0100188bundle("engine_bundle") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000189 deps = [ ":transpile_all_ts" ]
Hector Dearman81804d12018-07-10 11:38:15 +0100190 input = "$target_out_dir/engine/index.js"
191 output = "$target_out_dir/engine_bundle.js"
Hector Dearman21fa9162018-06-22 14:50:29 +0100192}
193
Primiano Tucci3552aaf2020-01-14 20:20:52 +0000194bundle("service_worker_bundle") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000195 deps = [ ":transpile_service_worker_ts" ]
Primiano Tucci3552aaf2020-01-14 20:20:52 +0000196 input = "$target_out_dir/service_worker/service_worker.js"
197 output = "$target_out_dir/service_worker.js"
198}
199
Hector Dearman4c919612018-12-06 12:32:40 +0000200bundle("query_bundle") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000201 deps = [ ":transpile_all_ts" ]
Hector Dearman4c919612018-12-06 12:32:40 +0000202 input = "$target_out_dir/query/index.js"
203 output = "$target_out_dir/query_bundle.js"
204}
205
Primiano Tucci3faad742018-05-16 19:30:48 +0100206# +----------------------------------------------------------------------------+
207# | Protobuf: gen rules to create .js and .d.ts files from protos. |
208# +----------------------------------------------------------------------------+
Primiano Tucci3faad742018-05-16 19:30:48 +0100209node_bin("protos_to_js") {
210 inputs = []
211 foreach(proto, trace_processor_protos) {
212 inputs += [ "../protos/perfetto/trace_processor/$proto.proto" ]
213 }
Nicolò Mazzucato1ed43cb2019-07-30 16:25:17 +0100214 inputs += [
215 "../protos/perfetto/config/perfetto_config.proto",
216 "../protos/perfetto/ipc/consumer_port.proto",
Nicolò Mazzucatoe67b2dc2019-09-18 10:14:55 +0100217 "../protos/perfetto/ipc/wire_protocol.proto",
Nicolò Mazzucato1ed43cb2019-07-30 16:25:17 +0100218 ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000219 outputs = [ "$ui_gen_dir/protos.js" ]
Primiano Tucci3faad742018-05-16 19:30:48 +0100220 node_cmd = "pbjs"
221 args = [
222 "-t",
223 "static-module",
224 "-w",
225 "commonjs",
226 "-p",
Primiano Tucci355b8c82019-08-29 08:37:51 +0200227 rebase_path("..", root_build_dir),
Primiano Tucci3faad742018-05-16 19:30:48 +0100228 "-o",
229 rebase_path(outputs[0], root_build_dir),
230 ] + rebase_path(inputs, root_build_dir)
231}
232
233# Protobuf.js requires to first generate .js files from the .proto and then
234# create .ts definitions for them.
235node_bin("protos_to_ts") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000236 deps = [ ":protos_to_js" ]
237 inputs = [ "$ui_gen_dir/protos.js" ]
238 outputs = [ "$ui_gen_dir/protos.d.ts" ]
Primiano Tucci3faad742018-05-16 19:30:48 +0100239 node_cmd = "pbts"
240 args = [
241 "-p",
Primiano Tucci355b8c82019-08-29 08:37:51 +0200242 rebase_path("..", root_build_dir),
Primiano Tucci3faad742018-05-16 19:30:48 +0100243 "-o",
244 rebase_path(outputs[0], root_build_dir),
245 rebase_path(inputs[0], root_build_dir),
246 ]
247}
248
249# +----------------------------------------------------------------------------+
250# | TypeScript: transpiles all *.ts into .js |
251# +----------------------------------------------------------------------------+
252
Hector Dearman4274a382018-07-18 16:14:10 +0100253# Builds all .ts sources in the repo under |src|.
Primiano Tucci3faad742018-05-16 19:30:48 +0100254node_bin("transpile_all_ts") {
Primiano Tucci3faad742018-05-16 19:30:48 +0100255 deps = [
256 ":dist_symlink",
257 ":protos_to_ts",
Hector Dearman21fa9162018-06-22 14:50:29 +0100258 ":wasm_gen",
Primiano Tucci3faad742018-05-16 19:30:48 +0100259 ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000260 inputs = [ "tsconfig.json" ]
Primiano Tucci3faad742018-05-16 19:30:48 +0100261 outputs = [
Hector Dearman81804d12018-07-10 11:38:15 +0100262 "$target_out_dir/frontend/index.js",
263 "$target_out_dir/engine/index.js",
264 "$target_out_dir/controller/index.js",
Hector Dearman4c919612018-12-06 12:32:40 +0000265 "$target_out_dir/query/index.js",
Nicolò Mazzucato1ed43cb2019-07-30 16:25:17 +0100266 "$target_out_dir/chrome_extension/index.js",
Primiano Tucci3faad742018-05-16 19:30:48 +0100267 ]
268
Hector Dearman4274a382018-07-18 16:14:10 +0100269 depfile = root_out_dir + "/tsc.d"
270 exec_script("../gn/standalone/glob.py",
271 [
272 "--root=" + rebase_path(".", root_build_dir),
273 "--filter=*.ts",
274 "--exclude=node_modules",
275 "--exclude=dist",
Primiano Tucci3552aaf2020-01-14 20:20:52 +0000276 "--exclude=service_worker",
Hector Dearman4274a382018-07-18 16:14:10 +0100277 "--deps=obj/ui/frontend/index.js",
278 "--output=" + rebase_path(depfile),
279 ],
280 "")
281
Primiano Tucci3faad742018-05-16 19:30:48 +0100282 node_cmd = "tsc"
283 args = [
284 "--project",
285 rebase_path(".", root_build_dir),
286 "--outDir",
Hector Dearman262cbe22018-05-31 13:28:21 +0100287 rebase_path(target_out_dir, root_build_dir),
Primiano Tucci3faad742018-05-16 19:30:48 +0100288 ]
289}
290
Primiano Tucci3552aaf2020-01-14 20:20:52 +0000291node_bin("transpile_service_worker_ts") {
292 deps = [
293 ":dist_symlink",
294 ":gen_dist_file_map",
295 ]
296 inputs = [
297 "tsconfig.json",
298 "src/service_worker/service_worker.ts",
299 ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000300 outputs = [ "$target_out_dir/service_worker/service_worker.js" ]
Primiano Tucci3552aaf2020-01-14 20:20:52 +0000301
302 node_cmd = "tsc"
303 args = [
304 "--project",
305 rebase_path("src/service_worker", root_build_dir),
306 "--outDir",
307 rebase_path(target_out_dir, root_build_dir),
308 ]
309}
310
Primiano Tucci3faad742018-05-16 19:30:48 +0100311# +----------------------------------------------------------------------------+
Primiano Tucci21b91bf2018-08-06 16:42:07 +0100312# | Build css. |
313# +----------------------------------------------------------------------------+
314
Hector Dearmanfcd63bc2018-10-11 11:40:43 +0100315scss_root = "src/assets/perfetto.scss"
316scss_srcs = [
Hector Dearman6177b752019-01-24 10:17:32 +0000317 "src/assets/typefaces.scss",
Hector Dearmanfcd63bc2018-10-11 11:40:43 +0100318 "src/assets/sidebar.scss",
319 "src/assets/topbar.scss",
320 "src/assets/record.scss",
321 "src/assets/common.scss",
Isabelle Taylorc2a13642019-08-06 14:14:59 +0100322 "src/assets/modal.scss",
Isabelle Taylor074881d2019-10-03 10:58:16 +0100323 "src/assets/details.scss",
Hector Dearmanfcd63bc2018-10-11 11:40:43 +0100324]
325
Primiano Tucci21b91bf2018-08-06 16:42:07 +0100326# Build css.
327node_bin("scss") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000328 deps = [ ":dist_symlink" ]
Hector Dearmanfcd63bc2018-10-11 11:40:43 +0100329 inputs = [ scss_root ] + scss_srcs
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000330 outputs = [ "$ui_dir/perfetto.css" ]
Primiano Tucci21b91bf2018-08-06 16:42:07 +0100331
332 node_cmd = "node-sass"
333 args = [
334 "--quiet",
Hector Dearmanfcd63bc2018-10-11 11:40:43 +0100335 rebase_path(scss_root, root_build_dir),
Primiano Tucci21b91bf2018-08-06 16:42:07 +0100336 rebase_path(outputs[0], root_build_dir),
337 ]
338}
339
340# +----------------------------------------------------------------------------+
Hector Dearman262cbe22018-05-31 13:28:21 +0100341# | Copy rules: create the final output directory. |
Primiano Tucci3faad742018-05-16 19:30:48 +0100342# +----------------------------------------------------------------------------+
Hector Dearman10641512018-07-04 10:38:53 +0100343copy("index_dist") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000344 sources = [ "index.html" ]
345 outputs = [ "$ui_dir/index.html" ]
Primiano Tucci3faad742018-05-16 19:30:48 +0100346}
347
Hector Dearman6177b752019-01-24 10:17:32 +0000348copy("typefaces_dist") {
349 sources = [
Hector Dearman6177b752019-01-24 10:17:32 +0000350 "../buildtools/typefaces/MaterialIcons.woff2",
351 "../buildtools/typefaces/Raleway-Regular.woff2",
352 "../buildtools/typefaces/Raleway-Thin.woff2",
Primiano Tucci32ea1032020-01-07 13:53:23 +0000353 "../buildtools/typefaces/RobotoCondensed-Light.woff2",
354 "../buildtools/typefaces/RobotoCondensed-Regular.woff2",
Hector Dearman6177b752019-01-24 10:17:32 +0000355 "../buildtools/typefaces/RobotoMono-Regular.woff2",
356 ]
357
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000358 outputs = [ "$ui_dir/assets/{{source_file_part}}" ]
Hector Dearman6177b752019-01-24 10:17:32 +0000359}
360
Hector Dearman4c919612018-12-06 12:32:40 +0000361copy("query_dist") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000362 sources = [ "query.html" ]
363 outputs = [ "$ui_dir/query.html" ]
Hector Dearman4c919612018-12-06 12:32:40 +0000364}
365
Michail Schwab20bab202018-08-02 18:17:44 -0400366copy("assets_dist") {
367 sources = [
Neda Topoljanac820b35e2019-11-26 13:09:08 +0000368 "src/assets/heap_profiler.png",
Hector Dearmanfcd63bc2018-10-11 11:40:43 +0100369 "src/assets/logo-3d.png",
370 "src/assets/logo.png",
Hector Dearmane97a4992019-02-13 10:49:27 +0000371 "src/assets/rec_atrace.png",
372 "src/assets/rec_battery_counters.png",
373 "src/assets/rec_board_voltage.png",
374 "src/assets/rec_cpu_coarse.png",
375 "src/assets/rec_cpu_fine.png",
376 "src/assets/rec_cpu_freq.png",
377 "src/assets/rec_cpu_voltage.png",
378 "src/assets/rec_cpu_wakeup.png",
379 "src/assets/rec_ftrace.png",
380 "src/assets/rec_lmk.png",
381 "src/assets/rec_logcat.png",
382 "src/assets/rec_long_trace.png",
383 "src/assets/rec_mem_hifreq.png",
384 "src/assets/rec_meminfo.png",
385 "src/assets/rec_one_shot.png",
386 "src/assets/rec_ps_stats.png",
387 "src/assets/rec_ring_buf.png",
388 "src/assets/rec_vmstat.png",
Hector Dearmanfcd63bc2018-10-11 11:40:43 +0100389 ] + [ scss_root ] + scss_srcs
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000390 outputs = [ "$ui_dir/assets/{{source_file_part}}" ]
Michail Schwab20bab202018-08-02 18:17:44 -0400391}
Nicolò Mazzucato1ed43cb2019-07-30 16:25:17 +0100392copy("chrome_extension_assets_dist") {
393 sources = [
394 "src/assets/logo-128.png",
395 "src/assets/logo.png",
396 "src/chrome_extension/manifest.json",
397 ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000398 outputs = [ "$chrome_extension_dir/{{source_file_part}}" ]
Nicolò Mazzucato1ed43cb2019-07-30 16:25:17 +0100399}
Hector Dearmandaca6cd2018-07-11 12:55:34 +0100400
Hector Dearman81804d12018-07-10 11:38:15 +0100401sorcery("frontend_bundle_dist") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000402 deps = [ ":frontend_bundle" ]
Hector Dearman81804d12018-07-10 11:38:15 +0100403 input = "$target_out_dir/frontend_bundle.js"
404 output = "$ui_dir/frontend_bundle.js"
Hector Dearman5f11e522018-05-31 16:54:28 +0100405}
406
Nicolò Mazzucato1ed43cb2019-07-30 16:25:17 +0100407sorcery("chrome_extension_bundle_dist") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000408 deps = [ ":chrome_extension_bundle" ]
Nicolò Mazzucato1ed43cb2019-07-30 16:25:17 +0100409 input = "$target_out_dir/chrome_extension_bundle.js"
410 output = "$chrome_extension_dir/chrome_extension_bundle.js"
411}
412
Hector Dearman81804d12018-07-10 11:38:15 +0100413sorcery("controller_bundle_dist") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000414 deps = [ ":controller_bundle" ]
Hector Dearman81804d12018-07-10 11:38:15 +0100415 input = "$target_out_dir/controller_bundle.js"
416 output = "$ui_dir/controller_bundle.js"
Hector Dearman262cbe22018-05-31 13:28:21 +0100417}
418
Hector Dearman81804d12018-07-10 11:38:15 +0100419sorcery("engine_bundle_dist") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000420 deps = [ ":engine_bundle" ]
Hector Dearman81804d12018-07-10 11:38:15 +0100421 input = "$target_out_dir/engine_bundle.js"
422 output = "$ui_dir/engine_bundle.js"
Hector Dearman21fa9162018-06-22 14:50:29 +0100423}
424
Primiano Tucci3552aaf2020-01-14 20:20:52 +0000425sorcery("service_worker_bundle_dist") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000426 deps = [ ":service_worker_bundle" ]
Primiano Tucci3552aaf2020-01-14 20:20:52 +0000427 input = "$target_out_dir/service_worker.js"
428 output = "$ui_dir/service_worker.js"
429}
430
Hector Dearman4c919612018-12-06 12:32:40 +0000431sorcery("query_bundle_dist") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000432 deps = [ ":query_bundle" ]
Hector Dearman4c919612018-12-06 12:32:40 +0000433 input = "$target_out_dir/query_bundle.js"
434 output = "$ui_dir/query_bundle.js"
435}
436
Hector Dearman10641512018-07-04 10:38:53 +0100437copy("wasm_dist") {
Primiano Tucci3faad742018-05-16 19:30:48 +0100438 deps = [
Hector Dearmane8450742018-08-31 14:36:51 +0100439 "//src/trace_processor:trace_processor.wasm($wasm_toolchain)",
Primiano Tucci1c752c12018-10-23 09:27:19 +0100440 "//tools/trace_to_text:trace_to_text.wasm($wasm_toolchain)",
Hector Dearman21fa9162018-06-22 14:50:29 +0100441 ]
442 sources = [
Hector Dearmane8450742018-08-31 14:36:51 +0100443 "$root_build_dir/wasm/trace_processor.wasm",
Primiano Tucci1c752c12018-10-23 09:27:19 +0100444 "$root_build_dir/wasm/trace_to_text.wasm",
Hector Dearman21fa9162018-06-22 14:50:29 +0100445 ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000446 outputs = [ "$ui_dir/{{source_file_part}}" ]
Hector Dearman21fa9162018-06-22 14:50:29 +0100447}
448
449copy("wasm_gen") {
450 deps = [
451 ":dist_symlink",
Primiano Tucci1c752c12018-10-23 09:27:19 +0100452
453 # trace_processor
Hector Dearmane8450742018-08-31 14:36:51 +0100454 "//src/trace_processor:trace_processor.d.ts($wasm_toolchain)",
455 "//src/trace_processor:trace_processor.js($wasm_toolchain)",
456 "//src/trace_processor:trace_processor.wasm($wasm_toolchain)",
Primiano Tucci1c752c12018-10-23 09:27:19 +0100457
458 # trace_to_text
459 "//tools/trace_to_text:trace_to_text.d.ts($wasm_toolchain)",
460 "//tools/trace_to_text:trace_to_text.js($wasm_toolchain)",
461 "//tools/trace_to_text:trace_to_text.wasm($wasm_toolchain)",
Primiano Tucci3faad742018-05-16 19:30:48 +0100462 ]
463 sources = [
Primiano Tucci1c752c12018-10-23 09:27:19 +0100464 # trace_processor
Hector Dearmane8450742018-08-31 14:36:51 +0100465 "$root_build_dir/wasm/trace_processor.d.ts",
466 "$root_build_dir/wasm/trace_processor.js",
467 "$root_build_dir/wasm/trace_processor.wasm",
Primiano Tucci1c752c12018-10-23 09:27:19 +0100468
469 # trace_to_text
470 "$root_build_dir/wasm/trace_to_text.d.ts",
471 "$root_build_dir/wasm/trace_to_text.js",
472 "$root_build_dir/wasm/trace_to_text.wasm",
Primiano Tucci3faad742018-05-16 19:30:48 +0100473 ]
Hector Dearmana824ba92018-09-19 17:51:25 +0100474 if (is_debug) {
Primiano Tucci1c752c12018-10-23 09:27:19 +0100475 sources += [
476 "$root_build_dir/wasm/trace_processor.wasm.map",
477 "$root_build_dir/wasm/trace_to_text.wasm.map",
478 ]
Hector Dearmana824ba92018-09-19 17:51:25 +0100479 }
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000480 outputs = [ "$ui_gen_dir/{{source_file_part}}" ]
Primiano Tucci3faad742018-05-16 19:30:48 +0100481}
482
Primiano Tucci1c752c12018-10-23 09:27:19 +0100483# Copy over the vulcanized legacy trace viewer.
484copy("catapult_dist") {
485 sources = [
486 "../buildtools/catapult_trace_viewer/catapult_trace_viewer.html",
487 "../buildtools/catapult_trace_viewer/catapult_trace_viewer.js",
488 ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000489 outputs = [ "$ui_dir/assets/{{source_file_part}}" ]
Primiano Tucci1c752c12018-10-23 09:27:19 +0100490}
491
Primiano Tucci3faad742018-05-16 19:30:48 +0100492# +----------------------------------------------------------------------------+
Deepanjan Royacf8c072018-07-13 11:37:04 -0400493# | Node JS: Creates a symlink in the out directory to node_modules. |
Primiano Tucci3faad742018-05-16 19:30:48 +0100494# +----------------------------------------------------------------------------+
495
496action("check_node_exists") {
497 script = "../gn/standalone/check_buildtool_exists.py"
Hector Dearman48783b12018-05-22 08:26:06 +0100498 args = [
499 nodejs_bin,
500 "--touch",
501 rebase_path("$target_out_dir/node_exists", ""),
502 ]
Primiano Tucci3faad742018-05-16 19:30:48 +0100503 inputs = []
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000504 outputs = [ "$target_out_dir/node_exists" ]
Primiano Tucci3faad742018-05-16 19:30:48 +0100505}
506
507# Creates a symlink from out/xxx/ui/node_modules -> ../../../ui/node_modules.
Hector Dearmanb06d4152018-05-31 16:55:04 +0100508# This allows to run rollup and other node tools from the out/xxx directory.
Primiano Tucci3faad742018-05-16 19:30:48 +0100509action("node_modules_symlink") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000510 deps = [ ":check_node_exists" ]
Hector Dearman6186c872018-05-31 13:28:48 +0100511
Primiano Tucci3faad742018-05-16 19:30:48 +0100512 script = "../gn/standalone/build_tool_wrapper.py"
Hector Dearman6186c872018-05-31 13:28:48 +0100513 stamp_file = "$target_out_dir/.$target_name.stamp"
Primiano Tucci3faad742018-05-16 19:30:48 +0100514 args = [
Hector Dearman6186c872018-05-31 13:28:48 +0100515 "--stamp",
516 rebase_path(stamp_file, root_build_dir),
Primiano Tucci3faad742018-05-16 19:30:48 +0100517 "/bin/ln",
518 "-fns",
Hector Dearmana817a062018-06-01 11:01:07 +0100519 rebase_path("node_modules", target_out_dir),
Hector Dearman6186c872018-05-31 13:28:48 +0100520 rebase_path("$target_out_dir/node_modules", root_build_dir),
521 ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000522 outputs = [ stamp_file ]
Primiano Tucci3faad742018-05-16 19:30:48 +0100523}
524
Hector Dearman6186c872018-05-31 13:28:48 +0100525group("node_modules") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000526 deps = [ ":node_modules_symlink" ]
Primiano Tucci3faad742018-05-16 19:30:48 +0100527}
528
529# Creates a symlink from //ui/dist -> ../../out/xxx/ui. Used only for
530# autocompletion in IDEs. The problem this is solving is that in tsconfig.json
531# we can't possibly know the path to ../../out/xxx for outDir. Instead, we set
532# outDir to "./dist" and create a symlink on the first build.
533action("dist_symlink") {
534 script = "../gn/standalone/build_tool_wrapper.py"
Hector Dearman262cbe22018-05-31 13:28:21 +0100535 stamp_file = "$target_out_dir/.$target_name.stamp"
Primiano Tucci3faad742018-05-16 19:30:48 +0100536 args = [
537 "--stamp",
538 rebase_path(stamp_file, root_build_dir),
539 "/bin/ln",
540 "-fns",
Hector Dearman262cbe22018-05-31 13:28:21 +0100541 rebase_path(target_out_dir, "."),
Primiano Tucci3faad742018-05-16 19:30:48 +0100542 rebase_path("dist", root_build_dir),
543 ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000544 inputs = [ "$root_build_dir" ]
545 outputs = [ stamp_file ]
Primiano Tucci3faad742018-05-16 19:30:48 +0100546}
Hector Dearmanbf384922018-06-25 10:42:01 +0100547
548group("test_scripts") {
549 deps = [
550 ":copy_tests_script",
551 ":copy_unittests_script",
552 ]
553}
554
555copy("copy_unittests_script") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000556 sources = [ "config/ui_unittests_template" ]
557 outputs = [ "$root_build_dir/ui_unittests" ]
Hector Dearmanbf384922018-06-25 10:42:01 +0100558}
559
560copy("copy_tests_script") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000561 sources = [ "config/ui_tests_template" ]
562 outputs = [ "$root_build_dir/ui_tests" ]
Hector Dearmanbf384922018-06-25 10:42:01 +0100563}
Primiano Tucci3552aaf2020-01-14 20:20:52 +0000564
565# This target generates an map containing all the UI subresources and their
566# hashes. This is used by the service worker code for offline caching.
567# This taarget needs to be kept at the end of the BUILD.gn file, because of the
568# get_target_outputs() call (fails otherwise due to GN's evaluation order).
569action("gen_dist_file_map") {
570 out_file_path = "$ui_gen_dir/dist_file_map.ts"
571
572 dist_files = []
573 foreach(target, ui_dist_targets) {
574 foreach(dist_file, get_target_outputs(target)) {
575 dist_files += [ rebase_path(dist_file, root_build_dir) ]
576 }
577 }
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000578 deps = [ ":dist" ]
Primiano Tucci3552aaf2020-01-14 20:20:52 +0000579 script = "../gn/standalone/write_ui_dist_file_map.py"
580 inputs = []
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000581 outputs = [ out_file_path ]
Primiano Tucci3552aaf2020-01-14 20:20:52 +0000582 args = [
583 "--out",
584 rebase_path(out_file_path, root_build_dir),
585 "--strip",
586 rebase_path(ui_dir, root_build_dir),
587 ] + dist_files
588}