Skip to content

Commit 232a8ff

Browse files
emillonleostera
andauthored
Add a contributing guide (#479)
Co-authored-by: Leandro Ostera <[email protected]>
1 parent 8cc5632 commit 232a8ff

File tree

3 files changed

+59
-8
lines changed

3 files changed

+59
-8
lines changed

CONTRIBUTING.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Contributing
2+
3+
Thanks for contributing to UTop!
4+
5+
## Setting up local switches
6+
7+
UTop comes from a `dune-workspace.dev` file to test it across all supported
8+
versions.
9+
10+
Run `make create-switches` to create all the required switches.
11+
12+
Now you can run `dune` with the `--workspace dev-workspace.dev` flag to run
13+
the same command across all the workspaces. The `make
14+
all-supported-ocaml-versions` command will build the project with this setup.
15+
16+
## Compatibility Across Versions
17+
18+
Some code will be different from one version of OCaml to the next. If you find
19+
some that does, please abstract it away using the `UTop_compat` module.
20+
21+
For example, the `Load_path.get_paths ()` function has changed recently to
22+
return a record with shape `{ visible: string list; hidden: string list }`, but
23+
this function used to return a single `string list`.
24+
25+
Defining this function using pre-processor macros allows us to give the same
26+
function two different bodies on different version of the language.
27+
28+
```ocaml
29+
let get_load_path () =
30+
#if OCAML_VERSION >= (5, 2, 0)
31+
Load_path.((get_paths ()).visible)
32+
#else
33+
Load_path.get_paths ()
34+
#endif
35+
```

Makefile

+18-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ reinstall:
1717
$(MAKE) uninstall
1818
$(MAKE) install
1919

20-
2120
.PHONY: examples
2221
examples:
2322
dune build @examples
@@ -39,3 +38,21 @@ cinaps:
3938
clean:
4039
rm -rf _build *.install
4140
find . -name .merlin -delete
41+
42+
.PHONY: create-switches
43+
create-switches:
44+
opam switch create utop-412 4.12.0
45+
opam switch create utop-413 4.13.1
46+
opam switch create utop-414 4.14.1
47+
opam switch create utop-500 5.0.0
48+
opam switch create utop-510 5.1.0
49+
opam switch create utop-520 5.2.0+trunk
50+
51+
.PHONY: install-switches
52+
install-switches:
53+
opam install --switch utop-412 --deps-only --with-test -y .
54+
opam install --switch utop-413 --deps-only --with-test -y .
55+
opam install --switch utop-414 --deps-only --with-test -y .
56+
opam install --switch utop-500 --deps-only --with-test -y .
57+
opam install --switch utop-510 --deps-only --with-test -y .
58+
opam install --switch utop-520 --deps-only --with-test -y .

dune-workspace.dev

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
(lang dune 1.0)
2-
;; This file is used by `make all-supported-ocaml-versions`
3-
(context (opam (switch 4.02.3)))
4-
(context (opam (switch 4.03.0)))
5-
(context (opam (switch 4.04.2)))
6-
(context (opam (switch 4.05.0)))
7-
(context (opam (switch 4.06.1)))
8-
(context (opam (switch 4.07.0)))
2+
(context (opam (switch utop-411)))
3+
(context (opam (switch utop-412)))
4+
(context (opam (switch utop-413)))
5+
(context (opam (switch utop-414)))
6+
(context (opam (switch utop-500)))
7+
(context (opam (switch utop-510)))

0 commit comments

Comments
 (0)