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

Generate bindings at compile-time #173

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Generate bindings at compile-time #173

wants to merge 1 commit into from

Conversation

dcoles
Copy link
Collaborator

@dcoles dcoles commented Oct 13, 2024

This replaces the generate-bindings script with a build.rs script for flipperzero-sys that downloads the latest SDK and uses that to generate Rust bindings.

There's a couple of reasons for this change:

  • Supporting multiple SDK versions (even after flipper-firmware-1.0.0 there can be incompatible SDK changes)
  • Supporting multiple targets (currently we only really support the f7 target, but there is also a f18 build)
  • Supporting alternate firmware (while not the primary focus of this crate, it should be a possibility)

@dcoles dcoles requested review from str4d and JarvisCraft October 13, 2024 08:57
@dcoles dcoles force-pushed the build-sys branch 2 times, most recently from 3c5af11 to 62fcd55 Compare October 13, 2024 09:01
@dcoles
Copy link
Collaborator Author

dcoles commented Oct 13, 2024

Uploading for initial review and testing.

Edit: Converting to Draft since the build isn't working on Linux.
Now building on Linux. 😀

@dcoles dcoles force-pushed the build-sys branch 4 times, most recently from 8c1b65f to 05b6426 Compare October 13, 2024 09:51
@dcoles dcoles marked this pull request as draft October 13, 2024 09:54
@dcoles dcoles force-pushed the build-sys branch 2 times, most recently from 62c8b6c to db5c3e8 Compare October 13, 2024 10:18
@dcoles dcoles marked this pull request as ready for review October 13, 2024 10:20
@JarvisCraft
Copy link
Contributor

JarvisCraft commented Oct 13, 2024

I think that we should provide a way to build the crate offline from scratch.
Some build systems and distros (for instance, nixpkgs of NixOS) are quite restrictive towards internet access during the build phase and thus may be unlucky trying to build the crate depending on internet download during build.rs evaluation.

What I see as the requirement for this PR is a way to have:

  1. Some default source of truth available with the crate itself (i.e. not requiring internet access during build).
  2. Opt-in ability to override via local path (this can actually be enough to not implement point 1).
  3. Opt-in ability to override it either via upstream flipperzero repo download (what you do in this PR);

So ideally I would like to see either:

Mode Default Envs (alternatively, a crate feature) Behavior Works offline
Pre-built None of the following Uses something predefined, e.g. our pre-generated bindings.rs, as done now
Local path ⛔ / ✅ (if we decide to get rid of Pre-built) FLIPPER_SDK_PATH Generates bindings from the local SDK installation
Download FLIPPER_SDK_VERSION, FLIPPER_TOOLCHAIN_VERSION, maybe explicit internet access opt-in flag Downloads the SDK by the given coordinates (by the way, I suggest adding the ability to override BUILDS_URL for the sake of custom SDKs / forks)

@dcoles dcoles linked an issue Oct 14, 2024 that may be closed by this pull request
@dcoles dcoles force-pushed the build-sys branch 10 times, most recently from c48cfdc to ec19984 Compare October 14, 2024 09:42
This replaces the `generate-bindings` script with a `build.rs` script
for `flipperzero-sys` that downloads the latest SDK and uses that to
generate Rust bindings.

Fixes: #41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for multiple SDK versions and targets
2 participants