Skip to content
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

Resolving package versions #4629

Open
chenyan-dfinity opened this issue Jul 24, 2024 · 3 comments
Open

Resolving package versions #4629

chenyan-dfinity opened this issue Jul 24, 2024 · 3 comments

Comments

@chenyan-dfinity
Copy link
Contributor

chenyan-dfinity commented Jul 24, 2024

Currently, we use moc --package pkgname pkgpath to resolve package names, and this package name is global, which applies to all source code.

Consider the following library dependencies:

main.mo
import Lib1 "mo:lib1";
import Lib2 "mo:lib2";

and lib1 depends on a different version of lib2 than what's used in main.mo. Ideally, we should be able to say moc --package lib2 "path_used_by_main" when compiling main.mo, and --package lib2 "path_used_by_lib1" when compiling lib1.

If main.mo is our own code, we could say import Lib2 "mo:lib2V2" as a workaround, but if main.mo is another third-party dependency, we cannot do it.

@crusso
Copy link
Contributor

crusso commented Jul 24, 2024

Maybe we could order the bindings on the command line, so the rightmost binding is used for packages to the right of that one. Won't work for mutually recursive packages but are there any of those?

@chenyan-dfinity
Copy link
Contributor Author

Dependency cannot have cycles, at least no non-resolvable cycles. We can exclude that from CLI.

So you mean moc --package lib2 "lib2_v2" main.mo --package lib2 "lib2_v1" lib1.mo? Currently, is there a difference between moc main.mo and moc main.mo lib1.mo?

@crusso
Copy link
Contributor

crusso commented Jul 25, 2024

Currently the treatment of more than on .mo file is a hack and just appends the files, so let's ignore that.

Assuming just one .mo file to moc, I meant something like:
moc --package base ... --package lib2 "lib2V1" --package lib1 ... -package lib2 "Lib2V2" main.mo

The main.mo uses Lib2V2 for lib2 (the rightmost binding to the left of main.mo), but lib1 uses libs2V1 for lib2 (the rightmost binding to the left of lib1) and all use the same base.

Not sure that works though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants