-
Notifications
You must be signed in to change notification settings - Fork 39
feature(cargo-miden): parse local path
Miden dependencies from Cargo.toml
#485
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c67e870
feature(cargo-miden): parse Miden dependencies from `Cargo.toml`
greenhat 388162f
refactor: parse `[package.metadata.miden]` from `Package`
greenhat 3e1b77c
test: uncomment compiled note script execution in
greenhat 9aa5cac
chore: use `serde` and `toml` workspace dependencies in `cargo-miden`
greenhat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -90,9 +90,14 @@ fn rust_sdk_p2id_note_script() { | |
.map(|s| s.to_string()) | ||
.collect(); | ||
dbg!(env::current_dir().unwrap().display()); | ||
let outputs = cargo_miden::run(args.into_iter(), cargo_miden::OutputType::Masm) | ||
.expect("Failed to compile the basic-wallet package"); | ||
let masp_path: PathBuf = outputs.first().unwrap().clone(); | ||
let build_output = cargo_miden::run(args.into_iter(), cargo_miden::OutputType::Masm) | ||
.expect("Failed to compile the basic-wallet package") | ||
.expect("'cargo miden build' for basic-wallet should return Some(CommandOutput)") | ||
.unwrap_build_output(); // Use the new method | ||
let masp_path = match build_output { | ||
cargo_miden::BuildOutput::Masm { artifact_path } => artifact_path, | ||
other => panic!("Expected Masm output for basic-wallet, got {:?}", other), | ||
}; | ||
dbg!(&masp_path); | ||
|
||
// | ||
|
@@ -163,46 +168,14 @@ fn rust_sdk_cross_ctx_account() { | |
|
||
#[test] | ||
fn rust_sdk_cross_ctx_note() { | ||
// Build cross-ctx-account package | ||
let args: Vec<String> = [ | ||
"cargo", | ||
"miden", | ||
"build", | ||
"--manifest-path", | ||
"../rust-apps-wasm/rust-sdk/cross-ctx-account/Cargo.toml", | ||
"--lib", | ||
"--release", | ||
// Use the target dir of this test's cargo project to avoid issues running tests in parallel | ||
// i.e. avoid using the same target dir as the basic-wallet test (see above) | ||
"--target-dir", | ||
"../rust-apps-wasm/rust-sdk/cross-ctx-note/target", | ||
] | ||
.iter() | ||
.map(|s| s.to_string()) | ||
.collect(); | ||
dbg!(env::current_dir().unwrap().display()); | ||
|
||
let outputs = cargo_miden::run(args.into_iter(), cargo_miden::OutputType::Masm) | ||
.expect("Failed to compile the cross-ctx-account package for cross-ctx-note"); | ||
let masp_path: PathBuf = outputs.first().unwrap().clone(); | ||
|
||
dbg!(&masp_path); | ||
|
||
let _ = env_logger::builder().is_test(true).try_init(); | ||
|
||
let config = WasmTranslationConfig::default(); | ||
|
||
let mut builder = CompilerTestBuilder::rust_source_cargo_miden( | ||
"../rust-apps-wasm/rust-sdk/cross-ctx-note", | ||
config, | ||
[ | ||
"-l".into(), | ||
"std".into(), | ||
"-l".into(), | ||
"base".into(), | ||
"--link-library".into(), | ||
masp_path.clone().into_os_string().into_string().unwrap().into(), | ||
], | ||
["-l".into(), "std".into(), "-l".into(), "base".into()], | ||
); | ||
builder.with_entrypoint(FunctionIdent { | ||
module: Ident::new(Symbol::intern("miden:base/[email protected]"), SourceSpan::default()), | ||
|
@@ -215,10 +188,12 @@ fn rust_sdk_cross_ctx_note() { | |
test.expect_masm(expect_file![format!("../../expected/rust_sdk/{artifact_name}.masm")]); | ||
let package = test.compiled_package(); | ||
let mut exec = Executor::new(vec![]); | ||
let account_package = | ||
Arc::new(Package::read_from_bytes(&std::fs::read(masp_path).unwrap()).unwrap()); | ||
exec.dependency_resolver_mut() | ||
.add(account_package.digest(), account_package.into()); | ||
for dep_path in test.dependencies { | ||
let account_package = | ||
Arc::new(Package::read_from_bytes(&std::fs::read(dep_path).unwrap()).unwrap()); | ||
exec.dependency_resolver_mut() | ||
.add(account_package.digest(), account_package.into()); | ||
} | ||
exec.with_dependencies(&package.manifest.dependencies).unwrap(); | ||
let trace = exec.execute(&package.unwrap_program(), &test.session); | ||
} | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Any particular reason for this change? Most of the flags we pass are constant strings.
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 names of the dependencies (Miden package filenames) that passed via
--link-library
option. They are parsed from our section inCargo.toml
.