mojo-ts: Support dependencies between mojom targets
We do this by changing three things: 1. Set `composite` to `true`. From Typescript docs: ``` The composite option enforces certain constraints which make it possible for build tools to quickly determine if a project has been built yet. ``` This results in the TypeScript compiler generating two new files for each mojom target: - Declaration files (.d.ts) which in the Mojo case describes the exported Mojo interface. - tsBuildInfo files (.tsbuildinfo) which store incremental compilation information as a part of composite projects which enables faster building of larger TypeScript codebases. 2. Adding `references` to tsconfigs, to tell the compile that a target depends on other targets. 3. Adding `/// <reference>` to non-es-modules files, to tell the compiler which files that file references. Somewhat surprisingly adding `references` to the tsconfig was not enough. This results in: 1. Each mojom target getting compiled only once, independent of how many other targets depend on it. 2. The compiler complaining if we forget to add a mojom target to `references` and if we forget to add `/// <reference>`s for files in non-es-modules files. 3. When compiling a mojom target, the compiler only attempts to compile the specific target i.e. it doesn't try to compile its dependencies. It's up to ninja to trigger the compilation of dependencies. If a dependent target hasn't been compiled yet, the compiler will throw an error. This ensures that we don't accidentally forget dependencies in our generated bindings. The upside of this, is that compilation order is controlled by gn and ninja. The downside is that we need to run an instance of the compiler for each target and we don't get to take advantage of the --build flag, which changes the compiler to act more like an orchestrator than a simple compiler. Bug: 1002798 Change-Id: I831aaaa9a0f159d6e90b9ec698ba5cc1f7653c4d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274387Reviewed-by:Ken Rockot <rockot@google.com> Commit-Queue: Giovanni Ortuño Urquidi <ortuno@chromium.org> Cr-Commit-Position: refs/heads/master@{#784318}
Showing
Please register or sign in to comment