Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# moonbit removed from language matrix for now - causing CI failures
lang: [c, rust, csharp, cpp]
lang: [c, rust, csharp, cpp, go]
exclude:
# For now csharp doesn't work on macos, so exclude it from testing.
- os: macos-latest
Expand Down
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ wit-bindgen-rust = { path = "crates/rust", version = "0.49.0" }
wit-bindgen-csharp = { path = 'crates/csharp', version = '0.49.0' }
wit-bindgen-markdown = { path = 'crates/markdown', version = '0.49.0' }
wit-bindgen-moonbit = { path = 'crates/moonbit', version = '0.49.0' }
wit-bindgen-go = { path = 'crates/go', version = '0.49.0' }
wit-bindgen = { path = 'crates/guest-rust', version = '0.49.0', default-features = false }
wit-bindgen-test = { path = 'crates/test', version = '0.49.0' }

Expand All @@ -64,6 +65,7 @@ wit-bindgen-cpp = { workspace = true, features = ['clap'], optional = true }
wit-bindgen-markdown = { workspace = true, features = ['clap'], optional = true }
wit-bindgen-moonbit = { workspace = true, features = ['clap'], optional = true }
wit-bindgen-csharp = { workspace = true, features = ['clap'], optional = true }
wit-bindgen-go = { workspace = true, features = ['clap'], optional = true }
wit-bindgen-test = { workspace = true }
wit-component = { workspace = true }
wasm-encoder = { workspace = true }
Expand All @@ -84,7 +86,7 @@ c = ['dep:wit-bindgen-c']
cpp = ['dep:wit-bindgen-cpp']
rust = ['dep:wit-bindgen-rust']
markdown = ['dep:wit-bindgen-markdown']
go = []
go = ['dep:wit-bindgen-go']
csharp = ['dep:wit-bindgen-csharp']
csharp-mono = ['csharp']
moonbit = ['dep:wit-bindgen-moonbit']
Expand Down
13 changes: 8 additions & 5 deletions ci/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const CRATES_TO_PUBLISH: &[&str] = &[
"wit-bindgen-csharp",
"wit-bindgen-markdown",
"wit-bindgen-moonbit",
"wit-bindgen-go",
"wit-bindgen-rust-macro",
"wit-bindgen-rt",
"wit-bindgen",
Expand Down Expand Up @@ -65,11 +66,13 @@ fn main() {
bump_version(&krate, &crates, name == "bump-patch");
}
// update the lock file
assert!(Command::new("cargo")
.arg("fetch")
.status()
.unwrap()
.success());
assert!(
Command::new("cargo")
.arg("fetch")
.status()
.unwrap()
.success()
);
}

"publish" => {
Expand Down
11 changes: 10 additions & 1 deletion crates/core/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,12 @@ pub fn guest_export_needs_post_return(resolve: &Resolve, func: &Function) -> boo
.unwrap_or(false)
}

pub fn guest_export_params_have_allocations(resolve: &Resolve, func: &Function) -> bool {
func.params
.iter()
.any(|(_, t)| needs_deallocate(resolve, &t, Deallocate::Lists))
}

fn needs_deallocate(resolve: &Resolve, ty: &Type, what: Deallocate) -> bool {
match ty {
Type::String => true,
Expand Down Expand Up @@ -1134,7 +1140,10 @@ impl<'a, B: Bindgen> Generator<'a, B> {
for (param_name, ty) in func.params.iter() {
let Some(types) = flat_types(self.resolve, ty, Some(max_flat_params))
else {
panic!("failed to flatten types during direct parameter lifting ('{param_name}' in func '{}')", func.name);
panic!(
"failed to flatten types during direct parameter lifting ('{param_name}' in func '{}')",
func.name
);
};
for _ in 0..types.len() {
self.emit(&Instruction::GetArg { nth: offset });
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub trait InterfaceGenerator<'a> {
fn type_record(&mut self, id: TypeId, name: &str, record: &Record, docs: &Docs);
fn type_resource(&mut self, id: TypeId, name: &str, docs: &Docs);
fn type_flags(&mut self, id: TypeId, name: &str, flags: &Flags, docs: &Docs);
fn type_tuple(&mut self, id: TypeId, name: &str, flags: &Tuple, docs: &Docs);
fn type_tuple(&mut self, id: TypeId, name: &str, tuple: &Tuple, docs: &Docs);
fn type_variant(&mut self, id: TypeId, name: &str, variant: &Variant, docs: &Docs);
fn type_option(&mut self, id: TypeId, name: &str, payload: &Type, docs: &Docs);
fn type_result(&mut self, id: TypeId, name: &str, result: &Result_, docs: &Docs);
Expand Down
19 changes: 19 additions & 0 deletions crates/go/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "wit-bindgen-go"
edition = "2024"
version = { workspace = true }
repository = { workspace = true }
license = { workspace = true }
rust-version = "1.85.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this (and edition above) also be set to { workspace = true }?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, for publication to crates.io, I think this'll want description + homepage like other crates

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add description and homepage.

Can this (and edition above) also be set to { workspace = true }?

I'm using let chaining, which requires edition 2024. I can convert that code if needed; are we not ready to start using 2024 in this project, yet?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to keep the repo in sync myself. We don't have a msrv policy in this repo, though, so I think it's fine to just bump the workspace to 1.84 and the 2024 edition


[dependencies]
wit-bindgen-core = { workspace = true }
wit-component = { workspace = true }
wasm-encoder = { workspace = true }
wasm-metadata = { workspace = true }
anyhow = { workspace = true }
heck = { workspace = true }
clap = { workspace = true, optional = true }

[features]
clap = ['dep:clap', 'wit-bindgen-core/clap']
Loading
Loading