Skip to content

Commit 7e71d36

Browse files
committed
chore: update wit-bindgen-go to git revision
Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com>
1 parent 3b214e3 commit 7e71d36

4 files changed

Lines changed: 23 additions & 14 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ anyhow = { workspace = true}
3838
clap = { version = "4.5.53", features = ["derive"] }
3939
regex = "1.12.2"
4040
wat = { version = "1.243.0"}
41-
wit-bindgen-go = "0.51.0"
41+
# TODO: Update once v0.52.0 releases
42+
wit-bindgen-go = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "da3f633daf32937823f276046bc20bffbeabb3dc" }
4243
wit-component = "0.244.0"
4344
wit-parser = "0.244.0"

src/bindings.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::common::{make_path_absolute, parse_wit};
22
use anyhow::Result;
33
use std::path::{Path, PathBuf};
44

5+
#[allow(clippy::too_many_arguments)]
56
pub fn generate_bindings(
67
wit_path: &[impl AsRef<Path>],
78
world: Option<&str>,
@@ -10,6 +11,7 @@ pub fn generate_bindings(
1011
generate_stubs: bool,
1112
should_format: bool,
1213
output: Option<&Path>,
14+
mod_name: Option<String>,
1315
) -> Result<()> {
1416
let (resolve, world) = parse_wit(wit_path, world, features, all_features)?;
1517
let mut files = Default::default();
@@ -23,6 +25,7 @@ pub fn generate_bindings(
2325
wit_bindgen_go::Opts {
2426
generate_stubs,
2527
format,
28+
mod_name,
2629
..Default::default()
2730
}
2831
.build()

src/command.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,6 @@ pub struct Componentize {
6868
pub mod_path: Option<PathBuf>,
6969
}
7070

71-
pub fn run<T: Into<OsString> + Clone, I: IntoIterator<Item = T>>(args: I) -> Result<()> {
72-
let options = Options::parse_from(args);
73-
match options.command {
74-
Command::Componentize(opts) => componentize(options.common, opts),
75-
Command::Bindings(opts) => bindings(options.common, opts),
76-
}
77-
}
78-
7971
#[derive(Parser)]
8072
pub struct Bindings {
8173
/// Output directory for bindings (or current directory if `None`).
@@ -88,9 +80,23 @@ pub struct Bindings {
8880
#[arg(long)]
8981
pub generate_stubs: bool,
9082

91-
#[arg(long)]
9283
/// Whether or not `gofmt` should be used (if present) to format generated code.
84+
#[arg(long)]
9385
pub format: bool,
86+
87+
/// The name of the Go module housing the generated bindings (or "wit_component" if `None`).
88+
///
89+
/// This option is used if the generated bindings will be used as a library.
90+
#[arg(long)]
91+
pub mod_name: Option<String>,
92+
}
93+
94+
pub fn run<T: Into<OsString> + Clone, I: IntoIterator<Item = T>>(args: I) -> Result<()> {
95+
let options = Options::parse_from(args);
96+
match options.command {
97+
Command::Componentize(opts) => componentize(options.common, opts),
98+
Command::Bindings(opts) => bindings(options.common, opts),
99+
}
94100
}
95101

96102
fn componentize(common: Common, componentize: Componentize) -> Result<()> {
@@ -124,5 +130,6 @@ fn bindings(common: Common, bindings: Bindings) -> Result<()> {
124130
bindings.generate_stubs,
125131
bindings.format,
126132
bindings.output.as_deref(),
133+
bindings.mod_name,
127134
)
128135
}

0 commit comments

Comments
 (0)