2020-12-14 12:59:15 +03:00
|
|
|
# Building and installing the Catala language
|
2020-06-02 11:26:30 +03:00
|
|
|
|
|
|
|
## Requirements
|
|
|
|
|
2021-09-27 22:06:14 +03:00
|
|
|
### With Docker
|
|
|
|
|
|
|
|
The Catala compiler is written using OCaml. The repository provides a `Dockerfile`
|
|
|
|
to build a Docker image with all the dependencies required to build the Catala compiler.
|
|
|
|
|
|
|
|
Start by installing Docker: https://docs.docker.com/get-docker/
|
|
|
|
|
|
|
|
Then build the Docker image:
|
|
|
|
|
|
|
|
docker build . -t catala
|
|
|
|
|
|
|
|
Finally, start a `bash` shell inside a new container created from the newly built image:
|
|
|
|
|
|
|
|
docker run -it -v $PWD:$PWD -w $PWD --name catala catala bash
|
|
|
|
|
2021-10-29 16:19:17 +03:00
|
|
|
### With nix
|
|
|
|
|
|
|
|
The repository provides nix files to build or develop the catala compiler.
|
|
|
|
|
|
|
|
Once [nix is installed](https://nixos.org/manual/nix/stable/#ch-installing-binary),
|
|
|
|
it is possible to enter a development shell:
|
|
|
|
|
|
|
|
nix-shell
|
|
|
|
|
|
|
|
or to build the Catala compiler, documentation and runtime library:
|
|
|
|
|
|
|
|
nix-build release.nix
|
|
|
|
|
|
|
|
Dependencies not yet in nixpkgs (`bindlib` and `unionFind` at the moment of writing)
|
|
|
|
are hardcoded inside the `.nix` directory. The `default.nix` should be compatible with
|
|
|
|
nixpkgs, if it finds a maintainer.
|
|
|
|
|
|
|
|
### With opam
|
2021-09-27 22:06:14 +03:00
|
|
|
|
2020-12-14 12:59:15 +03:00
|
|
|
The Catala compiler is written using OCaml. First, you have to install `opam`,
|
|
|
|
OCaml's distribution and package manager. Follow the [instructions on the `opam`
|
2021-03-02 20:27:39 +03:00
|
|
|
website](https://opam.ocaml.org/doc/Install.html).
|
2020-06-02 11:26:30 +03:00
|
|
|
|
2021-03-02 20:27:39 +03:00
|
|
|
Next, you will need to use the correct version of OCaml. Catala has been tested
|
2021-03-23 12:59:43 +03:00
|
|
|
with OCaml compiler versions that are at least 4.12.0. To switch to OCaml 4.12.0.,
|
2020-12-14 12:59:15 +03:00
|
|
|
just use:
|
2020-06-02 11:26:30 +03:00
|
|
|
|
2021-03-23 12:59:43 +03:00
|
|
|
opam switch 4.12.0
|
2020-06-02 11:26:30 +03:00
|
|
|
|
2021-03-23 12:59:43 +03:00
|
|
|
If you get a `No switch 4.12.0 is currently installed` error message, follow
|
|
|
|
the hint and enter `opam switch create 4.12.0`.
|
2020-12-14 12:59:15 +03:00
|
|
|
|
2021-09-27 22:06:14 +03:00
|
|
|
## Dependencies
|
|
|
|
|
2021-03-02 20:27:39 +03:00
|
|
|
Next, install all the OCaml packages that Catala depend on, as well as some
|
2020-12-14 12:59:15 +03:00
|
|
|
git submodules, with
|
2020-06-02 11:26:30 +03:00
|
|
|
|
2020-12-21 20:15:53 +03:00
|
|
|
make dependencies
|
2020-06-02 11:26:30 +03:00
|
|
|
|
2021-05-22 23:55:41 +03:00
|
|
|
This should ensure everything is set up for developing on the Catala compiler!
|
2020-06-02 11:26:30 +03:00
|
|
|
|
|
|
|
Other features for generation of files and literate programming also require
|
|
|
|
the following executables to be present
|
|
|
|
|
2021-11-07 00:26:36 +03:00
|
|
|
man2html virtualenv python3 rsync colordiff pygmentize
|
2020-06-02 11:26:30 +03:00
|
|
|
|
|
|
|
please install them if they're not here. On a Debian distribution, this can be
|
|
|
|
done with
|
|
|
|
|
2021-11-07 00:26:36 +03:00
|
|
|
sudo apt install python3-dev python3-setuptools python3-pygments man2html rsync colordiff
|
2020-06-02 11:26:30 +03:00
|
|
|
sudo python3 -m pip install --upgrade pip
|
|
|
|
sudo python3 -m pip install virtualenv
|
|
|
|
|
|
|
|
On ArchLinux :
|
|
|
|
|
2021-01-16 20:06:22 +03:00
|
|
|
sudo pacman -S python-virtualenv man2html rsync colordiff
|
2020-06-02 11:26:30 +03:00
|
|
|
|
2020-12-14 12:59:15 +03:00
|
|
|
## Build
|
2020-06-02 11:26:30 +03:00
|
|
|
|
|
|
|
The project is distributed as a Dune artifact. Use standard dune commands to build
|
|
|
|
and install the library. Makefile aliases are here to help you: running
|
|
|
|
|
|
|
|
make build
|
|
|
|
|
|
|
|
builds the compiler from its OCaml sources.
|
|
|
|
|
2020-12-14 12:59:15 +03:00
|
|
|
## Install
|
|
|
|
|
2021-03-02 20:27:39 +03:00
|
|
|
The installation of the Catala compiler is handled through `opam`. Since the
|
|
|
|
Catala compiler is not yet published to the `opam` repository, you can install
|
|
|
|
a local version from this Git repository by using
|
2020-12-14 12:59:15 +03:00
|
|
|
|
|
|
|
opam install ./
|
|
|
|
|
2021-03-02 20:27:39 +03:00
|
|
|
To uninstall, use
|
|
|
|
|
2020-12-14 12:59:15 +03:00
|
|
|
opam unpin catala
|
2020-06-02 11:26:30 +03:00
|
|
|
|
|
|
|
### Generating website assets
|
|
|
|
|
|
|
|
The Catala website features assets generated by the Catala compiler. They are
|
2021-03-02 20:27:39 +03:00
|
|
|
needed to build the website. To produce them, simply run
|
2020-12-14 12:59:15 +03:00
|
|
|
|
|
|
|
make website-assets
|
|
|
|
|
2021-03-02 20:27:39 +03:00
|
|
|
Then, use a helper script to copy them over to the `assets` directory of the
|
2020-12-14 12:59:15 +03:00
|
|
|
Catala website.
|
2020-06-02 11:26:30 +03:00
|
|
|
|
|
|
|
./generate_website_assets.sh <path-to-catala-website>/assets
|
|
|
|
|
|
|
|
You will need the `man2html` executable to generate the HTML versions of the man
|
|
|
|
pages, as well as the `rsync` executable to transfer files (preferred to `cp`)
|
|
|
|
because it also works with a remote server.
|
|
|
|
|
|
|
|
## Syntax highlighting
|
|
|
|
|
|
|
|
The Catala language also comes with syntax highlighting to
|
|
|
|
ease program development. The syntax highlighting is done
|
|
|
|
with the [Iro](https://eeyo.io/iro/) compiler that allows
|
|
|
|
writing the syntax only once, and then export it to formats
|
|
|
|
understood by various IDE. Currently, two syntax
|
|
|
|
highlighting plugins are under version control.
|
|
|
|
|
|
|
|
### Atom
|
|
|
|
|
|
|
|
To get Catala syntax highlighting in Atom, simply enter from
|
|
|
|
the root of the repository, depending on the language you want to use :
|
|
|
|
|
|
|
|
make atom_fr
|
2021-03-02 20:27:39 +03:00
|
|
|
|
2020-06-02 11:26:30 +03:00
|
|
|
or
|
|
|
|
|
|
|
|
make atom_en
|
|
|
|
|
|
|
|
You can now reload Atom and check that you have syntax highlighting on any `.catala` file.
|
|
|
|
|
2020-08-19 00:16:27 +03:00
|
|
|
### VSCode
|
|
|
|
|
|
|
|
To get Catala syntax highlighting in VSCode, simply enter from
|
|
|
|
the root of the repository, depending on the language you want to use :
|
|
|
|
|
|
|
|
make vscode_fr
|
2021-03-02 20:27:39 +03:00
|
|
|
|
2020-08-19 00:16:27 +03:00
|
|
|
or
|
|
|
|
|
|
|
|
make vscode_en
|
|
|
|
|
|
|
|
You can now reload VSCode and check that you have syntax highlighting on any `.catala` file.
|
|
|
|
|
2020-06-02 11:26:30 +03:00
|
|
|
### Pygments
|
|
|
|
|
|
|
|
Pygments is a Python-based versatile lexer for various
|
|
|
|
programming languages. To use a version of Pygments
|
|
|
|
augmented with the Catala plugin, simply enter
|
|
|
|
|
2021-03-02 20:27:39 +03:00
|
|
|
sudo make pygments
|
2020-06-02 11:26:30 +03:00
|
|
|
|
|
|
|
This will execute the
|
2021-05-09 23:55:50 +03:00
|
|
|
script `syntax_highlighting/fr/pygments/set_up_pygments.sh`,
|
|
|
|
`syntax_highlighting/pl/pygments/set_up_pygments.sh` and
|
2020-12-14 12:59:15 +03:00
|
|
|
`syntax_highlighting/en/pygments/set_up_pygments.sh`.
|
2020-06-02 11:26:30 +03:00
|
|
|
|
2021-03-02 20:27:39 +03:00
|
|
|
The scripts patch your `pigmentize` executable, used for instance by the `minted` LaTeX package.
|
|
|
|
It will now point to the Catala-enabled version with the appropriate `catala_*` lexer.
|