-
Notifications
You must be signed in to change notification settings - Fork 109
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
[pyth_oracle] Improve build.rs robustness and expose types. #343
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very cool.
println!("cargo:rustc-link-search=./program/c/target"); | ||
// Cargo exposes ENV variables for feature flags that can be used to determine whether to do a | ||
// self-contained build that compiles the C components automatically. | ||
if std::env::var("CARGO_FEATURE_LIBRARY").is_ok() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any reason not to do this for both build paths? this seems like a great simplification of the current build process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason, this is the correct way to do it. But I wasn't sure how many things would break and this was a safe small PR to get a review on. I can make it the default and check anywhere that might break / has been relying on relative paths. I just didn't plan to do it in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get this merged and I can make it the default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, please fix ci
This PR adds a feature flag,
library
to thepyth-oracle
program. When toggled on, the library exposes its account types for use as a library instead of a standalone program. When the flag is enabled, thebuild.rs
script will also switch to execute the C compilation as well. The artefacts are output within the Rust target sandbox rather than into the relative source directory (./program/c/target
).The benefit of this:
Rather than fully switch to this, the feature flag is added so any existing reliance on the current build method continues to work. The primary reason I wanted this is because I am relying on
pyth-sdk-rs
and I found it very hard to tell exactly what is different there versus the accounts defined within the contract. With this feature flag it is possible for me to enforce extra constraints inpyth-sdk-rs
that prevent the libraries going out of sync and highlights the differences in a testable way.See the associated PR for context.