-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
also add `cargo component` to README and CI workflows
- Loading branch information
Showing
12 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build] | ||
target = "wasm32-unknown-unknown" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Cargo.lock | ||
src/bindings.rs |
10 changes: 10 additions & 0 deletions
10
test/fixture_projects/component_types/.vscode/settings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"rust-analyzer.check.overrideCommand": [ | ||
"cargo", | ||
"component", | ||
"check", | ||
"--workspace", | ||
"--all-targets", | ||
"--message-format=json" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Folder-specific settings | ||
// | ||
// For a full list of overridable settings, and general information on folder-specific settings, | ||
// see the documentation: https://zed.dev/docs/configuring-zed#settings-files | ||
{ | ||
"lsp": { | ||
"rust-analyzer": { | ||
"check": { | ||
"overrideCommand": [ | ||
"cargo", | ||
"component", | ||
"check", | ||
"--workspace", | ||
"--all-targets", | ||
"--message-format=json" | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "component-types" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
paste = "1.0.15" | ||
wit-bindgen-rt = { version = "0.33.0", features = ["bitflags"] } | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[profile.release] | ||
codegen-units = 1 | ||
opt-level = "s" | ||
debug = false | ||
strip = true | ||
lto = true | ||
|
||
[package.metadata.component] | ||
package = "fixtures:component-types" | ||
|
||
[package.metadata.component.dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Wasm component fixture to test converting types back and forth. | ||
|
||
Prerequisite: `cargo install cargo-component` | ||
|
||
To rebuild, run the following from this directory: | ||
``` | ||
cargo component build --release | ||
``` | ||
|
||
`mix test` will automatically compile the wasm file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#[allow(warnings)] | ||
mod bindings; | ||
|
||
use bindings::Guest; | ||
use paste::paste; | ||
|
||
macro_rules! id_function { | ||
($wasm_ty:ident, $rust_ty:ty) => { | ||
paste! { | ||
fn [<id_ $wasm_ty>](v: $rust_ty) -> $rust_ty { | ||
v | ||
} | ||
} | ||
}; | ||
} | ||
|
||
struct Component; | ||
impl Guest for Component { | ||
id_function!(bool, bool); | ||
} | ||
|
||
bindings::export!(Component with_types_in bindings); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package fixtures:component-types; | ||
|
||
world fixtures { | ||
export id-bool: func(v: bool) -> bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters