Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support externs in rust without patch files (#521)
Dafny's `feat-rust` branch currently assumes all code is going into one crate. There are two options for adding additional Rust code that is manually-written (or generated from other sources :): 1. Pass the files as additional input files to `dafny`. 2. Post-process the output from `dafny` to declare the extra modules. #1 is cleaner, but requires that the Rust source files are not nested under folders to implicitly declare their ancestor modules. Since the design for Rust support so far has lots of these nested files, and we are hoping to eventually reuse the `smithy-rs` logic which generates such files, we're opting for #2 for now (although we do now use #1 for the StandardLibrary as a special case). Our approach so far has been to use patch files to add these extra declarations, but maintaining the patch files has been very painful in development, and we don't want to force `smithy-dafny` consumers to use them to create functional Rust libraries. Therefore this change adds automation to add the extra declarations. Since the extra declarations depend on the Smithy model, this is done in Java logic rather than Makefile or scripting. I've added an additional `patch-after-transpiling` command to the CLI, retroactively interpreting the existing single command as `generate`. The apache commons CLI library doesn't support this directly but it's pretty simple to handle subcommands ourselves. Also deleted all patch files for Rust. 🎉 Now test models can indicate they are benerated with `RUST_BENERATED=1` instead, which will make `make polymorph_rust` a no-op. Also fixed up the test models to work with the common set of declarations: some test models were missing their copy of `standard_library_conversions.rs`, and `Constructor` deviated from the config naming convention.
- Loading branch information