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