Skip to content

Commit 5013c8c

Browse files
committed
add --include-versions option
See bytecodealliance/wit-bindgen#1574 for details.
1 parent 073954b commit 5013c8c

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ serde = { version = "1.0.228", features = ["derive"] }
4848
toml = "1.1.0"
4949
# TODO: Switch back to upstream once
5050
# https://github.com/bytecodealliance/wit-bindgen/pull/1572 is merged:
51-
wit-bindgen-go = { git = "https://github.com/dicej/wit-bindgen", rev = "b163b3b5" }
51+
wit-bindgen-go = { git = "https://github.com/dicej/wit-bindgen", rev = "661ade1e" }
5252
wit-component = "0.245.1"
5353
wit-parser = "0.245.1"
5454
which = "8.0.2"
5555
dirs = "6.0.0"
56-

src/cmd_bindings.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub fn generate_bindings(
1212
output: Option<&Path>,
1313
pkg_name: Option<String>,
1414
export_pkg_name: Option<String>,
15+
include_versions: bool,
1516
) -> Result<()> {
1617
let mut files = Default::default();
1718

@@ -36,6 +37,7 @@ pub fn generate_bindings(
3637
format,
3738
pkg_name,
3839
export_pkg_name,
40+
include_versions,
3941
..Default::default()
4042
}
4143
.build()

src/command.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,15 @@ pub struct Bindings {
176176
/// default to that value.
177177
#[arg(long, requires = "pkg_name")]
178178
pub export_pkg_name: Option<String>,
179+
180+
/// When generating Go package names, include the WIT package version even
181+
/// if only one version of that package is referenced by the specified
182+
/// world.
183+
///
184+
/// By default, the version will only be included in the name if the world
185+
/// references more than one version of the WIT package.
186+
#[arg(long)]
187+
pub include_versions: bool,
179188
}
180189

181190
pub fn run<T: Into<OsString> + Clone, I: IntoIterator<Item = T>>(args: I) -> Result<()> {
@@ -268,5 +277,6 @@ fn bindings(wit_opts: WitOpts, bindings: Bindings) -> Result<()> {
268277
bindings.output.as_deref(),
269278
bindings.pkg_name,
270279
bindings.export_pkg_name,
280+
bindings.include_versions,
271281
)
272282
}

0 commit comments

Comments
 (0)