• Home
  • Raw
  • Download

Lines Matching +full:fast +full:- +full:json +full:- +full:stable +full:- +full:stringify

7 //      http://www.apache.org/licenses/LICENSE-2.0
19 // - The build process for the whole UI and the chrome extension.
20 // - The HTTP dev-server with live-reload capabilities.
21 // The reason why this is a hand-rolled script rather than a conventional build
22 // system is keeping incremental build fast and maintaining the set of
24 // The only way to keep incremental build fast (i.e. O(seconds) for the
25 // edit-one-line -> reload html cycles) is to run both the TypeScript compiler
26 // and the rollup bundler in --watch mode. Any other attempt, leads to O(10s)
27 // incremental-build times.
28 // This script allows mixing build tools that support --watch mode (tsc and
29 // rollup) and auto-triggering-on-file-change rules via node-watch.
31 // just runs all the build tasks serially. It doesn't to do any mtime-based
32 // check, it always re-runs all the tasks.
33 // When invoked with --watch, it mounts a pipeline of tasks based on node-watch
34 // and runs them together with tsc --watch and rollup --watch.
38 // +----------------+ +-----------------------------+
39 // | protos/*.proto |----->| pbjs out/tsc/gen/protos.js |--+
40 // +----------------+ +-----------------------------+ |
41 // +-----------------------------+ |
42 // | pbts out/tsc/gen/protos.d.ts|<-+
43 // +-----------------------------+
45 // V +-------------------------+
46 // +---------+ +-----+ | out/tsc/frontend/*.js |
47 // | ui/*.ts |------------->| tsc |-> +-------------------------+ +--------+
48 // +---------+ +-----+ | out/tsc/controller/*.js |-->| rollup |
49 // ^ +-------------------------+ +--------+
50 // +------------+ | out/tsc/engine/*.js | |
51 // +-----------+ |*.wasm.js | +-------------------------+ |
52 // |ninja *.cc |->|*.wasm.d.ts | |
53 // +-----------+ |*.wasm |-----------------+ |
54 // +------------+ | |
56 // +-----------+ +------+ +------------------------------------------------+
57 // | ui/*.scss |->| scss |--->| Final out/dist/ dir |
58 // +-----------+ +------+ +------------------------------------------------+
59 // +----------------------+ | +----------+ +---------+ +--------------------+|
61 // +----------------------+ | | *.css | |*.wasm | +--------------------+|
62 // | buildtools/typefaces |-->| | *.png | +---------+ | engine_bundle.js ||
63 // +----------------------+ | | *.woff2 | +--------------------+|
65 // +----------------------+ | +----------+ +--------------------+|
66 // +------------------------------------------------+
74 const fswatch = require('node-watch'); // Like fs.watch(), but works on Linux.
97 // out/xxx/ -> outDir : Root build dir, for both ninja/wasm and UI.
98 // ui/ -> outUiDir : UI dir. All outputs from this script.
99 // tsc/ -> outTscDir : Transpiled .ts -> .js.
100 // gen/ -> outGenDir : Auto-generated .ts/.js (e.g. protos).
101 // dist/ -> outDistRootDir : Only index.html and service_worker.js
102 // v1.2/ -> outDistDir : JS bundles and assets
130 {r: /.*\/dist\/.+\/(?!manifest\.json).*/, f: genServiceWorkerManifestJson},
143 parser.add_argument('--out', {help: 'Output directory'});
144 parser.add_argument('--minify-js', {
148 parser.add_argument('--watch', '-w', {action: 'store_true'});
149 parser.add_argument('--serve', '-s', {action: 'store_true'});
150 parser.add_argument('--serve-host', {help: '--serve bind host'});
151 parser.add_argument('--serve-port', {help: '--serve bind port', type: 'int'});
152 parser.add_argument('--verbose', '-v', {action: 'store_true'});
153 parser.add_argument('--no-build', '-n', {action: 'store_true'});
154 parser.add_argument('--no-wasm', '-W', {action: 'store_true'});
155 parser.add_argument('--run-unittests', '-t', {action: 'store_true'});
156 parser.add_argument('--run-integrationtests', '-T', {action: 'store_true'});
157 parser.add_argument('--debug', '-d', {action: 'store_true'});
158 parser.add_argument('--bigtrace', {action: 'store_true'});
159 parser.add_argument('--open-perfetto-trace', {action: 'store_true'});
160 parser.add_argument('--interactive', '-i', {action: 'store_true'});
161 parser.add_argument('--rebaseline', '-r', {action: 'store_true'});
162 parser.add_argument('--no-depscheck', {action: 'store_true'});
163 parser.add_argument('--cross-origin-isolation', {action: 'store_true'});
164 parser.add_argument('--test-filter', '-f', {
167 parser.add_argument('--no-override-gn-args', {action: 'store_true'});
173 cfg.outUiTestArtifactsDir = ensureDir(pjoin(cfg.outDir, 'ui-test-artifacts'));
176 const proc = exec('python3', [VERSION_SCRIPT, '--stdout'], {stdout: 'pipe'});
220 process.exit(130); // 130 -> Same behavior of bash when killed by SIGINT.
225 const installBuildDeps = pjoin(ROOT_DIR, 'tools/install-build-deps');
227 let args = [installBuildDeps, `--check-only=${checkDepsPath}`, '--ui'];
230 const result = childProcess.spawnSync('arch', ['-arm64', 'true']);
235 '-arch',
248 // Enqueue empty task. This is needed only for --no-build --serve. The HTTP
254 updateSymlinks(); // Links //ui/out -> //out/xxx/ui/
292 // - Notifies the HTTP live reload clients.
293 // - Regenerates the ServiceWorker file map.
301 console.log('In case of execution error, re-run without --no-build.');
306 const secs = Math.ceil((Date.now() - tStart) / 1000);
325 // -----------
327 // -----------
331 '--rootDir',
333 '--verbose',
334 '--runInBand',
335 '--detectOpenHandles',
336 '--forceExit',
337 '--projects',
341 args.push('-t', cfg.testFilter);
344 args.push('--watchAll');
353 // First copy the html as-is into the dist/v1.2.3/ directory. This is
355 // ui.perfetto.dev/v1.2.3/ to skip the auto-update and channel logic.
360 // --release_map=xxx.json argument, to populate this with multiple channels.
361 const versionMap = JSON.stringify({'stable': cfg.version}); property
362 const bodyRegex = /data-perfetto_version='[^']*'/;
363 html = html.replace(bodyRegex, `data-perfetto_version='${versionMap}'`);
402 args.unshift('--quiet');
426 // Can't put --no-comments here - The comments are load bearing for
429 '--no-beautify',
430 '--force-number',
431 '--no-delimited',
432 '--no-verify',
433 '-t',
434 'static-module',
435 '-w',
437 '-p',
439 '-o',
448 const pbtsArgs = ['--no-comments', '-p', ROOT_DIR, '-o', dstTs, dstJs];
461 const args = [GEN_IMPORTS_SCRIPT, inputDir, '--out', dstTs];
469 [VERSION_SCRIPT, '--ts_out', pjoin(cfg.outGenDir, 'perfetto_version.ts')];
474 // /ui/out -> /out/ui.
477 // /ui/src/gen -> /out/ui/ui/tsc/gen)
480 // /out/ui/test/data -> /test/data (For UI tests).
485 // Creates a out/dist_version -> out/dist/v1.2.3 symlink, so rollup config
505 const gnArgs = ['gen', `--args=${gnVars}`, cfg.outDir];
509 const ninjaArgs = ['-C', cfg.outDir];
532 const args = ['--project', pjoin(ROOT_DIR, project)];
535 args.push('--watch', '--preserveWatchOutput');
545 const args = ['-c', rcfg, '--no-indent'];
547 args.push('--environment', 'ENABLE_BIGTRACE:true');
550 args.push('--environment', 'ENABLE_OPEN_PERFETTO_TRACE:true');
553 args.push('--environment', `MINIFY_JS:${cfg.minifyJs}`);
555 args.push(...(cfg.verbose ? [] : ['--silent']));
557 // --waitForBundleInput is sadly quite busted so it is required ts
559 args.push('--watch', '--no-watch.clearScreen');
572 const skipRegex = /(\.map|manifest\.json|index.html)$/;
577 manifest.resources[relPath] = 'sha256-' + b64;
579 const manifestJson = JSON.stringify(manifest, null, 2);
580 fs.writeFileSync(pjoin(cfg.outDistDir, 'manifest.json'), manifestJson);
597 // Implements the Server-Side-Events protocol.
599 'Content-Type': 'text/event-stream',
600 'Connection': 'keep-alive',
601 'Cache-Control': 'no-cache',
624 res.end('403 Forbidden - Request path outside of the repo root');
631 res.end(JSON.stringify(err));
644 'Content-Type': cType,
645 'Content-Length': data.length,
646 'Last-Modified': fs.statSync(absPath).mtime.toUTCString(),
647 'Cache-Control': 'no-cache',
650 head['Cross-Origin-Opener-Policy'] = 'same-origin';
651 head['Cross-Origin-Embedder-Policy'] = 'require-corp';
680 // Server-Side-Event to the live_reload.ts script.
691 pjoin(ROOT_DIR, 'ui/src/assets/logo-128.png'),
692 pjoin(cfg.outExtDir, 'logo-128.png'),
695 pjoin(ROOT_DIR, 'ui/src/chrome_extension/manifest.json'),
696 pjoin(cfg.outExtDir, 'manifest.json'),
700 // -----------------------
702 // -----------------------
722 const ms = (new Date(Date.now() - tStart)).toISOString().slice(17, -1);
744 // RULES. If --watch is used, it also installs a fswatch() and re-triggers the
801 // ------------------------------------------
803 // ------------------------------------------
810 this.identity = JSON.stringify([this.func.name, this.args]);
855 'cp', path.relative(ROOT_DIR, src), '->', path.relative(ROOT_DIR, dst));