Skip to content

Commit

Permalink
Attempt to generate interfaces again if generation fails
Browse files Browse the repository at this point in the history
  • Loading branch information
novafacing committed Apr 9, 2024
1 parent 8ad1156 commit 11f5322
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions simics-rs/simics-macro/src/interface/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1418,8 +1418,19 @@ pub fn interface_impl(args: TokenStream, input: TokenStream) -> TokenStream {
// Get the `name = ""` attribute
let input = parse_macro_input!(input as syn::ItemImpl);

if let Err(e) = CInterface::generate(&input, &name) {
return TokenStream::from(e.write_errors());
// Try three times to generate the interface, with a short delay between each
// attempt. For an unknown reason, disassembly/emission of the pyiface trampolines can fail.
//
// TODO: Disassemble these trampolines and emit the data in a more reliable way.
for i in 0..3 {
if let Err(e) = CInterface::generate(&input, &name) {
if i == 2 {
return TokenStream::from(e.write_errors());
}
std::thread::sleep(std::time::Duration::from_secs(1));
} else {
break;
}
}

let interface = Interface { input, name };
Expand Down

0 comments on commit 11f5322

Please sign in to comment.