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