Rahix / avr-hal

embedded-hal abstractions for AVR microcontrollers
Apache License 2.0
1.23k stars 216 forks source link

treewide: Apply changes for new svd2rust API #545

Open Rahix opened 1 month ago

Rahix commented 1 month ago

As avr-device is upgrading to use svd2rust version 0.33.1 (see https://github.com/Rahix/avr-device/pull/155), there are some significant changes in the generated API. We have to adapt the HAL code to use the new API whereever relevant. This PR is a preview of what will change.

The following major changes are necessary:

Fortunately, these changes can be trivially automated from rustc error messages using the following script:

cargo build --message-format json 2>/dev/null \
  | jq '.message.children[].spans[] | {file: .file_name, line: .line_start, col: (.text[0].highlight_start - 1), insert: .suggested_replacement}' 2>/dev/null \
  | jq -r '"sed -ri '"'"'" + (.line | tostring) + "s/^(.{" + (.col | tostring) + "})/\\1" + .insert + "/'"'"' $(cd ../..; realpath " + .file + ")"' \
  | sort | uniq | bash