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