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

Add ability to customize bindings output path without BC breaks. #330

Closed

Conversation

gcoguiec
Copy link

@gcoguiec gcoguiec commented Sep 3, 2024

Hi!

Thank you for the fantastic work on cargo-component!

This is PR is an alternative proposal to #316 that aims to address #315 in a backward-compatible manner.

What could be added to this PR furthermore?

  • Test cases
  • Documentation update

How to change bindings output path using code in this PR

  1. Move the component declaration to a dedicated module of your choosing (here wasi):
// src/wasi.rs
pub mod bindings;

use bindings::Guest;

struct Component;

impl Guest for Component {
  ...
}

bindings::export!(Component with_types_in bindings);

(component declaration stays the same)

  1. Register the new wasi module inside your lib:
// src/lib.rs
#[cfg(target_os = "wasi")] // ymmv
pub mod wasi;
  1. Change bindings generation path to src/wasi/bindings.rs by adding a metadata inside the Cargo.toml manifest:
# Cargo.toml
[package.metadata.component.bindings]
path = "src/wasi/bindings.rs"

This way, we don't break current behaviour while allowing the bindings output path to change.

@gcoguiec gcoguiec closed this Oct 14, 2024
@gcoguiec gcoguiec deleted the configurable-bindings-path branch October 14, 2024 23:49
@gcoguiec gcoguiec restored the configurable-bindings-path branch October 14, 2024 23:49
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.

1 participant