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 = [ |
| 290 | "src/assets", |
| 291 | ] |
| 292 | outputs = [ |
| 293 | "$ui_dir/assets/", |
| 294 | ] |
| 295 | } |
Hector Dearman | daca6cd | 2018-07-11 12:55:34 +0100 | [diff] [blame] | 296 | |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 297 | sorcery("frontend_bundle_dist") { |
Hector Dearman | 262cbe2 | 2018-05-31 13:28:21 +0100 | [diff] [blame] | 298 | deps = [ |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 299 | ":frontend_bundle", |
Hector Dearman | 262cbe2 | 2018-05-31 13:28:21 +0100 | [diff] [blame] | 300 | ] |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 301 | input = "$target_out_dir/frontend_bundle.js" |
| 302 | output = "$ui_dir/frontend_bundle.js" |
Hector Dearman | 5f11e52 | 2018-05-31 16:54:28 +0100 | [diff] [blame] | 303 | } |
| 304 | |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 305 | sorcery("controller_bundle_dist") { |
Hector Dearman | 5f11e52 | 2018-05-31 16:54:28 +0100 | [diff] [blame] | 306 | deps = [ |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 307 | ":controller_bundle", |
Hector Dearman | 5f11e52 | 2018-05-31 16:54:28 +0100 | [diff] [blame] | 308 | ] |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 309 | input = "$target_out_dir/controller_bundle.js" |
| 310 | output = "$ui_dir/controller_bundle.js" |
Hector Dearman | 262cbe2 | 2018-05-31 13:28:21 +0100 | [diff] [blame] | 311 | } |
| 312 | |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 313 | sorcery("engine_bundle_dist") { |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 314 | deps = [ |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 315 | ":engine_bundle", |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 316 | ] |
Hector Dearman | 81804d1 | 2018-07-10 11:38:15 +0100 | [diff] [blame] | 317 | input = "$target_out_dir/engine_bundle.js" |
| 318 | output = "$ui_dir/engine_bundle.js" |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 319 | } |
| 320 | |
Hector Dearman | 1064151 | 2018-07-04 10:38:53 +0100 | [diff] [blame] | 321 | copy("wasm_dist") { |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 322 | deps = [ |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 323 | "//src/trace_processor:trace_processor.wasm($wasm_toolchain)", |
| 324 | ] |
| 325 | sources = [ |
| 326 | "$root_build_dir/wasm/trace_processor.wasm", |
| 327 | ] |
| 328 | outputs = [ |
| 329 | "$ui_dir/{{source_file_part}}", |
| 330 | ] |
| 331 | } |
| 332 | |
| 333 | copy("wasm_gen") { |
| 334 | deps = [ |
| 335 | ":dist_symlink", |
| 336 | "//src/trace_processor:trace_processor.d.ts($wasm_toolchain)", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 337 | "//src/trace_processor:trace_processor.js($wasm_toolchain)", |
| 338 | "//src/trace_processor:trace_processor.wasm($wasm_toolchain)", |
| 339 | ] |
| 340 | sources = [ |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 341 | "$root_build_dir/wasm/trace_processor.d.ts", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 342 | "$root_build_dir/wasm/trace_processor.js", |
| 343 | "$root_build_dir/wasm/trace_processor.wasm", |
| 344 | ] |
| 345 | outputs = [ |
Hector Dearman | 21fa916 | 2018-06-22 14:50:29 +0100 | [diff] [blame] | 346 | "$ui_gen_dir/{{source_file_part}}", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 347 | ] |
| 348 | } |
| 349 | |
| 350 | # +----------------------------------------------------------------------------+ |
Deepanjan Roy | acf8c07 | 2018-07-13 11:37:04 -0400 | [diff] [blame] | 351 | # | Node JS: Creates a symlink in the out directory to node_modules. | |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 352 | # +----------------------------------------------------------------------------+ |
| 353 | |
| 354 | action("check_node_exists") { |
| 355 | script = "../gn/standalone/check_buildtool_exists.py" |
Hector Dearman | 48783b1 | 2018-05-22 08:26:06 +0100 | [diff] [blame] | 356 | args = [ |
| 357 | nodejs_bin, |
| 358 | "--touch", |
| 359 | rebase_path("$target_out_dir/node_exists", ""), |
| 360 | ] |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 361 | inputs = [] |
| 362 | outputs = [ |
Hector Dearman | 48783b1 | 2018-05-22 08:26:06 +0100 | [diff] [blame] | 363 | "$target_out_dir/node_exists", |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 364 | ] |
| 365 | } |
| 366 | |
| 367 | # Creates a symlink from out/xxx/ui/node_modules -> ../../../ui/node_modules. |
Hector Dearman | b06d415 | 2018-05-31 16:55:04 +0100 | [diff] [blame] | 368 | # 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] | 369 | action("node_modules_symlink") { |
| 370 | deps = [ |
| 371 | ":check_node_exists", |
| 372 | ] |
Hector Dearman | 6186c87 | 2018-05-31 13:28:48 +0100 | [diff] [blame] | 373 | |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 374 | script = "../gn/standalone/build_tool_wrapper.py" |
Hector Dearman | 6186c87 | 2018-05-31 13:28:48 +0100 | [diff] [blame] | 375 | stamp_file = "$target_out_dir/.$target_name.stamp" |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 376 | args = [ |
Hector Dearman | 6186c87 | 2018-05-31 13:28:48 +0100 | [diff] [blame] | 377 | "--stamp", |
| 378 | rebase_path(stamp_file, root_build_dir), |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 379 | "/bin/ln", |
| 380 | "-fns", |
Hector Dearman | a817a06 | 2018-06-01 11:01:07 +0100 | [diff] [blame] | 381 | rebase_path("node_modules", target_out_dir), |
Hector Dearman | 6186c87 | 2018-05-31 13:28:48 +0100 | [diff] [blame] | 382 | rebase_path("$target_out_dir/node_modules", root_build_dir), |
| 383 | ] |
| 384 | outputs = [ |
| 385 | stamp_file, |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 386 | ] |
| 387 | } |
| 388 | |
Hector Dearman | 6186c87 | 2018-05-31 13:28:48 +0100 | [diff] [blame] | 389 | group("node_modules") { |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 390 | deps = [ |
| 391 | ":node_modules_symlink", |
| 392 | ] |
| 393 | } |
| 394 | |
| 395 | # Creates a symlink from //ui/dist -> ../../out/xxx/ui. Used only for |
| 396 | # autocompletion in IDEs. The problem this is solving is that in tsconfig.json |
| 397 | # we can't possibly know the path to ../../out/xxx for outDir. Instead, we set |
| 398 | # outDir to "./dist" and create a symlink on the first build. |
| 399 | action("dist_symlink") { |
| 400 | script = "../gn/standalone/build_tool_wrapper.py" |
Hector Dearman | 262cbe2 | 2018-05-31 13:28:21 +0100 | [diff] [blame] | 401 | stamp_file = "$target_out_dir/.$target_name.stamp" |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 402 | args = [ |
| 403 | "--stamp", |
| 404 | rebase_path(stamp_file, root_build_dir), |
| 405 | "/bin/ln", |
| 406 | "-fns", |
Hector Dearman | 262cbe2 | 2018-05-31 13:28:21 +0100 | [diff] [blame] | 407 | rebase_path(target_out_dir, "."), |
Primiano Tucci | 3faad74 | 2018-05-16 19:30:48 +0100 | [diff] [blame] | 408 | rebase_path("dist", root_build_dir), |
| 409 | ] |
| 410 | inputs = [ |
| 411 | "$root_build_dir", |
| 412 | ] |
| 413 | outputs = [ |
| 414 | stamp_file, |
| 415 | ] |
| 416 | } |
Hector Dearman | bf38492 | 2018-06-25 10:42:01 +0100 | [diff] [blame] | 417 | |
| 418 | group("test_scripts") { |
| 419 | deps = [ |
| 420 | ":copy_tests_script", |
| 421 | ":copy_unittests_script", |
| 422 | ] |
| 423 | } |
| 424 | |
| 425 | copy("copy_unittests_script") { |
| 426 | sources = [ |
| 427 | "config/ui_unittests_template", |
| 428 | ] |
| 429 | outputs = [ |
| 430 | "$root_build_dir/ui_unittests", |
| 431 | ] |
| 432 | } |
| 433 | |
| 434 | copy("copy_tests_script") { |
| 435 | sources = [ |
| 436 | "config/ui_tests_template", |
| 437 | ] |
| 438 | outputs = [ |
| 439 | "$root_build_dir/ui_tests", |
| 440 | ] |
| 441 | } |