-
Notifications
You must be signed in to change notification settings - Fork 11
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
build: one cargo workspace for the repo #133
Conversation
@@ -51,6 +51,7 @@ where | |||
/// - Deserialize whatever bytes we can import from the host after calling the host function | |||
/// - Return a `Result` of the deserialized output type `O` | |||
#[inline(always)] | |||
#[allow(improper_ctypes_definitions)] | |||
pub fn host_call<I, O>( | |||
f: unsafe extern "C" fn(usize, usize) -> DoubleUSize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gives a warning that u128 is not an ffi safe interface. Since our CI requires that clippy passes with no warnings, this became blocking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is a funny one. It's helpful to allow 32-bit or 64-bit builds but it would be invalid with u128. I'm not aware of a type that include the first two but not the other. Reasonable to ignore I think
@@ -159,26 +160,3 @@ macro_rules! try_ptr { | |||
} | |||
}}; | |||
} | |||
|
|||
#[cfg(test)] | |||
pub mod tests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests were never being run.
If they are worth keeping, should they be moved into the host
crate and only run when the feature flag error_as_host
is not enabled? I don't totally understand the utility since it seems like we always have error_as_host
enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests seem reasonable enough to me, I probably would try to keep them.
If we always use the feature flag though, I don't see a reason not to remove that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay I was confused. This is about the default behavior of passing a string into wasm_error!()
.
By default this will produce a WasmErrorInner::Guest("my error")
, in hdi
it follows this behavior. When the error_as_host
feature is enabled, it will produce a WasmErrorInner:Host("my error")
, in holochain
and holochain_wasmer_host
it follows this behavior.
Because the wasm_error!()
is defined in crates/common
, I moved both this test and the mirroring test (in crates/host/src/guest.rs
) into crates/common/src/result.rs
. I put each test behind the feature flags required for their behavior. Let me know if that looks good.
@@ -6,18 +6,14 @@ export WASMER_BACKTRACE=1 | |||
|
|||
# static tests | |||
cargo fmt --check | |||
( cd test && cargo fmt --check ) | |||
( cd crates/guest && cargo fmt --check ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crates/guest
and test
are now in the root workspace, so no need to check separately
cargo clippy -- --deny warnings | ||
( cd test && cargo clippy -- --deny warnings ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test
is now in the root workspace
cargo test --no-default-features --features error_as_host,wasmer_sys_prod ${1-} -- --nocapture | ||
|
||
# test that everything builds | ||
cargo build --release --manifest-path test/test_wasm/Cargo.toml --target wasm32-unknown-unknown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are redundant -- we don't need to run them for each feature flag.
@@ -34,9 +34,6 @@ name = "test" | |||
crate-type = ["cdylib", "rlib"] | |||
path = "src/test.rs" | |||
|
|||
[profile.release] | |||
debug = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to the workspace-level cargo.toml so it is actually applied
@@ -372,48 +372,3 @@ impl ModuleCache { | |||
Ok(module) | |||
} | |||
} | |||
|
|||
#[cfg(test)] | |||
mod tests { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved these into crates/host/src/module/wasmer_sys.rs
to avoid the clippy warning "warning: private item shadows public glob re-export". I don't totally understand it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some naming clash with a pub use a_module::*
. We had masses of these in Holochain at some point with the endless re-exports for "convenience" that ended up causing headaches with where types actually lived. This seems fine here
…same level within "test-crates" dir
… wasms used for tests vs actual test implementations
test-crates/wasm_core/Cargo.toml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed test_wasm
to wasm_core
to use the same directory and crate naming schema as the other wasm crates. Intended to clarify that this is an example wasm that is used in tests, not actually tests.
test-crates/tests/src/test.rs
Outdated
@@ -391,7 +391,7 @@ pub mod tests { | |||
match err { | |||
Err(runtime_error) => assert_eq!( | |||
WasmError { | |||
file: "src/wasm.rs".into(), | |||
file: "test-crates/wasm_core/src/wasm.rs".into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different file path since this is part of the root workspace now.
test-crates/wasm_memory/src/wasm.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All formatting changes
test-crates/wasm_io/src/wasm.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All formatting changes
test-crates/wasm_core/src/wasm.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All formatting changes
scripts/bump_version.sh
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not being used.
// i.e. "test-crates\\wasm_core\\src/wasm.rs" | ||
// | ||
// To remedy this we normalize the formatting here. | ||
file: file!().replace('\\', "/").to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only issue I found noting this: rust-lang/libs-team#503
Alternatively we could just keep the inconsistent path formatting. Or I could use a real "path canonicalization" lib instead of a replace().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Genuinely wasn't sure it would work out going this far with the change, but it looks like it's come out really nicely.
I'm going to check this out and give it a look just to make sure it looks like it does in my head after the review but really just a couple of minor comments :)
Yeah looks great locally! Possible the |
…kspace for shared deps" This reverts commit 21d0d6a.
…crate where it is defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice! Thank you taking this on :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! ❤️
Resolves #124