-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recompile generated code after elixir-thrift dep.update #138
Comments
I would like to add support for having the compiler task write a "manifest" that would track its generated files. That would gives us a mechanism to clean and regenerate output files. This would also be useful in the event that our code generator changes the names of the output files that it generates. Separately, we could consider some sort of "version" that ties the generated files to a specific revision of the code generator. Some possible options:
|
Where would the manifest file reside, the project root? How would it handle manual compile.thrift invocations alongside automatic ones? Like would it append to the manifest? How do you clean out that stuff when you no longer use a particular .thrift file? We could store metadata in generated files as comments at the top of the file. # generated_at: 2017-01-1 12:34:56
# thrift_version: abc123
# etc... Determining the thrift version is still an interesting problem. I like the idea of using the beam version. There are several modules under Elixir.Thrift.* though, would we need to check them all? What if we look at the modification times of our beam files, rather than the version? Effectively: find . -name "Elixir.Thrift.*.beam" -exec stat -f %m {} \; | sort | tail -n1 And when we do the stale check, take the most recent modification from those + the .thrift file in question. Kind of hacky though. But it would be nice to have something that works for us during development and also for end users, without having to remember to bump version numbers. |
The convention is to use I don't have specific answers to your other questions yet. We'll need to prototype the different approaches to see which works for all of our use cases. The standard manifest / |
This is signifiant rewrite of the compiler task to support manifests, making us a better mix citizen and adding support for `mix clean`-based file cleanup. Our manifest is written as a binary-encoded Erlang term to give us the most forward-compatible file format. At the moment, we only store a manifest version number and the list of generated files, but we may expand this in the future to include additional dependency information such as the "version" of the code that was used to generate these files. See #138 for a more detailed discussion.
We now determine "staleness" based on a manifest version and the package's version. This should work well for most users once we ship regular releases, but during development the package version number doesn't change often enough to trigger rebuilds when they might be necessary. Possible options:
I think (2) is reasonable, but it comes at the cost of more code paths. Probably worth it? |
I looked into including the git revision in the manifest header. It's a little bit trickier than I expected, but it's definitely possible. After hunting around the mix code a bit more, I'm left with the question as to whether we should:
I haven't been able to find any other way to extract version/revision information in a way that's available for all of our use cases. |
The current thrift.compile logic only recompiles output files based on their last_modified timestamp relative to their respective input files. However they may also need to be regenerated if elixir-thrift itself has changed. For example the client and server have generated user modules interoperating with static modules like Thrift.Client.BinaryFramed. If the latter changes, we need to make sure the former changes as well.
The text was updated successfully, but these errors were encountered: