A Rust client implementation of the Motoko package manger.
If you have many packages from github, you may get rate limited from github. You can create a personal access token, and put the token in the GITHUB_TOKEN environment variable to get a much higher limit.
- Cache directory:
~/.mops/, stores the Motoko compiler binary and library dependencies downloaded from mops or github. It can be changed by using the--cache-dirflag. - Project root directory: The first occurance of
mops.tomlfrom the current directory to its parent directories. Ifmops.tomlis missing, the current directory is the root directory, and amops.tomlwill be auto-generated. - Main Motoko file:
mops-cli build <main_file>. If<main_file>is omitted, will usemain.moorMain.mo. - Build artifacts: Stored in
<root_directory>/target/<name>/<name>.wasm, where<name>can be specified bymops-cli build --name <name>. If--nameis omitted,<name>will be the filename of the main Motoko file. If the filename isMain.moormain.mo,<name>will be the parent directory name. If anything fails, we usewasmas the default<name>. - Compiler flags:
--release --idl --stable-types --public-metadata candid:service -o target/<name>/<name>.wasm --package <from_mops_lock>. If extra arguments are passed viamops-cli build -- <moc_args>, the default flags will be dropped, except-o and --packageflags. If<moc_args>contains-o, the default-oflag will be dropped.
import Backend "ic:ryjl3-tyaaa-aaaaa-aaaba-cai"adds the following section
[[canister]]
canister_id = "ryjl3-tyaaa-aaaaa-aaaba-cai"import Backend "canister:backend"can be configured as
[[canister]]
name = "backend"
canister_id = "ryjl3-tyaaa-aaaaa-aaaba-cai"import Type "./BackendType"can be generated by
[[canister]]
candid = "Backend.did"
output = "BackendType.mo"Differences from the node client
mops.tomlcan be auto-generated frommain.moif the packages are all on mops.- Similar to
cargo build,mops buildgenerates amops.lockfile that records the precise dependencies of the project. Note that the lock file format is different from the node client. mops buildcan automatically download external dependencies specified inmops.lock, without the need to runmops install.- The downloaded packages are stored globally at
$HOME/.mops, similar to cargo. - Overall, users can run
mops build main.modirectly without any setup.
- Resolving package versions. Currently, we choose the largest version when package names collide, and errors out when we cannot decide on the version of a package. We need compiler support to allow the same package name to apply to different modules, and follow semantic versioning. The base library also need to follow semantic versioning.
- Removing a dependency doesn't remove the entries in
mops.lock