Run cargo add in c2rust-instrument --set-runtime to add c2rust-analysis-rt automatically
#562
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, in #554, the
c2rust-analysis-rtruntime must be added as an (optional) dependency in the instrumented crate. This runscargo add c2rust-analysis-rt --optionalso that it is automatically added and up-to-date when instrumenting. This also adds an optional--runtime ${runtime}argument toc2rust-instrument. If it is given, thencargo add c2rust-analysis-rt --optional --path ${runtime} --offlineis run. Thus, it works well both whenc2rust-analysis-rtis already on your machine and you're developing locally, as well as a user who would downloadc2rust-analysis-rtfrom crates.io. Note thatcargo addis only run when--set-runtimeis passed, so this is off by default, and must be opted-into.Another, more complex, option is to copy the
Cargo.tomlto aCargo.instrument.toml, add thec2rust-analysis-rtdependency there, and the run with--manifest-path Cargo.instrument.toml. However, that's more complex, and not allcargocommands uniformly take a--manifest-pathargument, and there's no environment variable for that, which would be seamlessly inherited.