If you want just to use moc
, you can install the moc
binary into your nix
environment with
$ nix-env -i -f . -A moc
To enter a shell with the necessary dependencies available, use
$ nix-shell
Within this shell you can run
make
insrc/
to build all binaries,make moc
insrc/
to build just themoc
binary,make DUNE_OPTS=--watch moc
to keep rebuilding as source files are changingmake
inrts/
to build the Motoko runtimemake
intest/
to run the test suite.
This invokes dune
under the hood, which will, as a side effect, also create
.merlin
files for integration with Merlin, the Ocaml Language Server
A good way to check that everything is fine, i.e. if this will pass CI, is to run
$ nix-build --no-out-link
We make frequent releases, at least weekly. The steps to make a release (say, version 0.4.2) are:
-
Make sure that the top section of
Changelog.md
has a title like== 0.4.2 (2020-04-01)
with today’s date.
-
Look at
git log --first-parent 0.4.1..HEAD
and check that everything relevant is mentioned in the changelog section, and possibly clean it up a bit, curating the information for the target audience. -
git commit -a -m "Releasing 0.4.2"
-
Create a PR from this commit, and label it
automerge-squash
. Mergify will merge it into master without additional approval, within 2 or 3 minutes. -
git switch master; git pull
. The release commit should be yourHEAD
-
git tag 0.4.2 -m "Motoko 0.4.2"
-
git branch -f release 0.4.2
-
git push origin release 0.4.2
The release
branch should thus always reference the latest release commit.
You can get a development environment without having to use nix-shell
(although installing all required tools without nix is out of scope).
- Use your system’s package manager to install
ocaml
(4.07) andopam
- Install the packages:
opam install num vlq yojson menhir stdio js_of_ocaml js_of_ocaml-ppx ppx_inline_test atdgen wasm obelisk
- Install into your
PATH
various command line tools used by, in particular, the test suite:nix-env -i -f . -A wasmtime nix-env -i -f . -A filecheck nix-env -i -f . -A wabt nix-env -i -f . -A drun nix-env -i -f . -A ic-run
- Building the Motoko runtime without nix is tricky. But you can run
to get
nix-shell --run 'make -C rts'
rts/mo-rts.wasm
. - Add
./bin
to your$PATH
so that the testsuite will find the build products (see./bin/wrapper.sh
for details).
- Build with profiling within nix-shell (TODO: How to do with dune)
make -C src clean make BUILD=p.native -C src moc
- Run
moc
as normal, e.g.this should dump amoc -g -c foo.mo -o foo.wasm
gmon.out
file in the current directory. - Create the report, e.g. using
(Note that you have to run this in the directory with
gprof --graph src/moc
gmon.out
, but pass it the path to the binary.)
When the .cabal
file of a Haskell package is changed you need to make sure the
corresponding .nix
file (stored in nix/generated/
) is kept in sync with it. These files are automatically generated; run
nix-shell nix/generate.nix
to update.
Don't worry if you forget to update the default.nix
file, the CI job
check-generated
checks if these files are in sync and fail with a diff if
they aren't.