Skip to content
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

feat: macro recompile trigger #1061

Merged
merged 5 commits into from
Jul 26, 2023
Merged

Conversation

segfault-magnet
Copy link
Contributor

closes: #1060

The solution (until Rust has an official way of doing it) is to call include_bytes inside your macro. This is detected by the compiler and it will watch the path for changes.

I've assigned it to a const _: &[u8] = include_bytes!(...) and it seems it gets optimized away.

Couldn't find a trace of the JSON file in the resulting executable (even under debug build).

So we might have gotten away with a no-downsides hack.

Tested via a separate e2e suite. Didn't include it in the PR since it would require compiling the whole SDK twice during testing.

Checklist

  • I have linked to any relevant issues.
  • I have updated the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary labels.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@segfault-magnet segfault-magnet added the bug Something isn't working label Jul 25, 2023
@segfault-magnet segfault-magnet self-assigned this Jul 25, 2023
@segfault-magnet segfault-magnet changed the title Feat/macro recompile trigger feat: macro recompile trigger Jul 25, 2023
Br1ght0ne
Br1ght0ne previously approved these changes Jul 25, 2023
Copy link
Contributor

@Br1ght0ne Br1ght0ne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome engineering, LGTM! Maybe we should open a related issue for removing this later. Doesn't seem like rust-lang/rust#99515 will land any time soon, though. :)

@segfault-magnet
Copy link
Contributor Author

Awesome engineering, LGTM! Maybe we should open a related issue for removing this later. Doesn't seem like rust-lang/rust#99515 will land any time soon, though. :)

Made an issue here

hal3e
hal3e previously approved these changes Jul 26, 2023
Copy link
Contributor

@hal3e hal3e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Left an optional nit.

packages/fuels-code-gen/src/utils/source.rs Outdated Show resolved Hide resolved
@segfault-magnet segfault-magnet dismissed stale reviews from hal3e and Br1ght0ne via 786c0e3 July 26, 2023 09:59
Copy link
Member

@digorithm digorithm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool. Hacky, yes, but very cool 🤠

@segfault-magnet segfault-magnet merged commit ff74fc7 into master Jul 26, 2023
@segfault-magnet segfault-magnet deleted the feat/macro_recompile_trigger branch July 26, 2023 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

abigen and setup_program_test macros don't detect file changes
4 participants