Skip to content
This repository has been archived by the owner on Dec 11, 2024. It is now read-only.

Fix transitive dependency case #45

Merged
merged 9 commits into from
Aug 21, 2024
Merged

Fix transitive dependency case #45

merged 9 commits into from
Aug 21, 2024

Conversation

afsalthaj
Copy link
Contributor

@afsalthaj afsalthaj commented Jun 9, 2024

https://github.com/afsalthaj/testwasmrpc/tree/transitive_dependency

The above tested code has caller, callee (and a callee2 which isn't significant here)

And the following scenarios have been tested with this change

  • caller depends on callee-stub
  • callee in turn depends on caller-stub
  • caller depends on caller-stub itself (just to see we are not regressing this fix that was done earlier - it shouldn't)
  • Multiple runs of cargo make build-flow after code changes (i.e, adding imports and adding actual usage) is also done. Multiple runs are important as there are state changes after the first run.

The PR #42 hasn't tried to solve transitive dependency case, and it looks like much more easier than the direct-cyclic dependency case. There is no logical intervention into the direct cyclic dependency fix in this PR, still I have included that in the test case.

@afsalthaj
Copy link
Contributor Author

Testing in progress

@@ -295,6 +310,7 @@ pub fn add_stub_dependency(args: AddStubDependencyArgs) -> anyhow::Result<()> {
// If stub generated world points to the destination world (meaning the destination still owns the world for which the stub is generated),
// we re-generation of stub with inlined types and copy the inlined stub to the destination
if dest_owns_stub_world(&world_name, &destination_wit_root) {
dbg!("Is destination owning stub world");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove once testing is finished

@afsalthaj afsalthaj changed the title Start fixing transitive dependency case Fix transitive dependency case Jun 9, 2024
@afsalthaj afsalthaj marked this pull request as ready for review June 9, 2024 08:58

if internal::is_invalid_dependency(&destination_wit_root, &parsed) {
println!(
"Skipping the copy of cyclic dependencies {} to the the same as {}",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix this message


// For those dependencies we add to the source, if they, by any chance, imports from the skipped/invalid dependencies (basically they are destination_wit package itself)
// we simply replace. This is the reasoning
// The dependencies we import never logically end up using these imports in the WIT files.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make the comment more clear

Copy link

@nicoburniske nicoburniske left a comment

Choose a reason for hiding this comment

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

Minor comment

Ok(re.replace_all(&read_data, "").to_string())
}

pub fn get_file_name(path: &PathBuf) -> anyhow::Result<String> {

Choose a reason for hiding this comment

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

Not blocking at all, but there's no need to use String here, we can just use the PathBuf. I think we'd need to update the enum case WitAction::WriteWit to use PathBuf as a field instead of String.

Copy link
Contributor

Choose a reason for hiding this comment

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

and take &Path as input

@vigoo vigoo merged commit 13f700c into main Aug 21, 2024
2 checks passed
@vigoo vigoo deleted the cyclic_dep_try_2 branch August 21, 2024 08:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants