xref: /aosp_15_r20/external/google-cloud-java/owl-bot-postprocessor/synthtool/protos/README.md (revision 55e87721aa1bc457b326496a7ca40f3ea1a63287)
1# Synthtool and Autosynth Protocol
2
3**Synthtool** generates client library source code according to the currrent
4state of the source repo, and upstream repos like
5[googleapis/googleapis](https://github.com/googleapis/googleapis).
6
7**Autosynth** periodically runs Synthtool for each client library source repo.
8Additionally, it repeatedly runs Synthtool in a binary search pattern to
9discover which upstream change triggered a change in the generate code.
10
11The proto files in this directory define the interface between.
12
13![Diagram of Synthtool and Autosynth](./diagram.png)
14
15**Synthtool** generates a file called `synth.metadata`, which contains a
16json-encoded instance of the `Metadata` class defined in [metadata.proto](./metadata.proto).  `synth.metadata` tells Autosynth which git repos were pulled
17by Synthtool while generating the library's source code.
18
19**Autosynth** consumes `synth.metadata`.  Before invoking Synthtool again, it
20observes which repos Synthtool used during the last generation, and
21fetches them in advance.  Autosynth tells Synthtool where to find those repos
22by generating a `preconfig.json` file.
23
24The `preconfig.json` file contains a Preconfig message as defined in
25[preconfig.proto](./preconfig.proto).  Autosynth sets the environment variable
26`SYNTHTOOL_PRECONFIG_FILE` to the path of the `preconfig.json` file so that
27Synthtool can find it.
28
29Here's a sample `preconfig.json` file:
30```
31{
32  "preclonedRepos": {
33    "https://github.com/googleapis/google-cloud-dotnet.git": "/tmpfs/src/git/autosynth/working_repo",
34    "https://github.com/googleapis/googleapis.git": "/tmpfs/tmp/tmp4pusokpm/googleapis"
35  }
36}
37```