Skip to content

Commit

Permalink
port build from jbuilder to dune
Browse files Browse the repository at this point in the history
  • Loading branch information
avsm authored and jeremiedimino committed Jan 15, 2019
1 parent ea38850 commit 641af3f
Show file tree
Hide file tree
Showing 21 changed files with 97 additions and 105 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
dev
---

* Port build to dune from jbuilder (@avsm)

2.2.0 (2018-07-15)
------------------

Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),)

.PHONY: all
all:
jbuilder build @install
dune build

.PHONY: install
install:
jbuilder install $(INSTALL_ARGS)
dune install $(INSTALL_ARGS)

.PHONY: uninstall
uninstall:
jbuilder uninstall $(INSTALL_ARGS)
dune uninstall $(INSTALL_ARGS)

.PHONY: reinstall
reinstall:
Expand All @@ -20,15 +20,15 @@ reinstall:

.PHONY: examples
examples:
jbuilder build @examples
dune build @examples

.PHONY: test
test:
jbuilder runtest
dune runtest

.PHONY: all-supported-ocaml-versions
all-supported-ocaml-versions:
jbuilder build --workspace jbuild-workspace.dev
dune build --workspace dune-workspace.dev

.PHONY: cinaps
cinaps:
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Dependencies
------------

* [OCaml](http://caml.inria.fr/ocaml/) (>= 4.02.3)
* [Jbuilder](http://github.com/janestreet/jbuilder)
* [Dune](http://github.com/ocaml/dune)
* [findlib](http://projects.camlcity.org/projects/findlib.html) (>= 1.4.0)
* [cppo](http://mjambon.com/cppo.html) (>= 1.0.1)
* [react](http://erratique.ch/software/react)
Expand Down Expand Up @@ -209,29 +209,29 @@ It shall point to the directory `stublibs` inside your ocaml installation.
Creating a custom utop-enabled toplevel
---------------------------------------

### With jbuilder
### With Dune

The recommended way to build a custom utop toplevel is via
[jbuilder][jbuilder]. The entry point of the custom utop must call
[Dune][dune]. The entry point of the custom utop must call
`UTop_main.main`. For instance write the following `myutop.ml` file:

```ocaml
let () = UTop_main.main ()
```

and the following jbuild file:
and the following dune file:

```scheme
(executable
((name myutop)
(link_flags (-linkall))
(libraries (utop))))
(name myutop)
(link_flags -linkall)
(libraries utop))
```

then to build the toplevel, run:

```
$ jbuilder myutop.bc
$ dune myutop.bc
```

Note the `-linkall` in the link flags. By default OCaml doesn't link
Expand All @@ -241,19 +241,19 @@ the user is going to use so you must link everything.
If you want to include more libraries in your custom utop, simply add
them to the `(libraries ...)` field.

Additionally, if you want to install this topevel, add the two
Additionally, if you want to install this toplevel, add the two
following fields to the executable stanza:

```scheme
(public_name myutop)
(modes (byte))
(modes byte)
```

The `(modes ...)` field is to tell jbuilder to install the byte-code
The `(modes ...)` field is to tell dune to install the byte-code
version of the executable, as currently native toplevels are not fully
suported.

[jbuilder]: https://github.com/janestreet/jbuilder
[dune]: https://github.com/ocaml/dune

### Manually, with ocamlfind

Expand Down
12 changes: 12 additions & 0 deletions dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(install
(section share)
(files utoprc-dark utoprc-light))

(install
(section share_root)
(files
(src/top/utop.el as emacs/site-lisp/utop.el)))

(alias
(name examples)
(deps examples/custom-utop/myutop.bc examples/interact/test_program.bc))
8 changes: 8 additions & 0 deletions dune-workspace.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(lang dune 1.0)
;; This file is used by `make all-supported-ocaml-versions`
(context (opam (switch 4.02.3)))
(context (opam (switch 4.03.0)))
(context (opam (switch 4.04.2)))
(context (opam (switch 4.05.0)))
(context (opam (switch 4.06.1)))
(context (opam (switch 4.07.0)))
2 changes: 1 addition & 1 deletion examples/custom-utop/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
To build the custom toplevel in this directory, run:

$ jbuilder myutop.bc
$ dune build myutop.bc
5 changes: 5 additions & 0 deletions examples/custom-utop/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(executable
(name myutop)
(flags :standard -safe-string)
(link_flags -linkall)
(libraries utop))
7 changes: 0 additions & 7 deletions examples/custom-utop/jbuild

This file was deleted.

5 changes: 5 additions & 0 deletions examples/interact/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(executable
(name test_program)
(flags :standard -safe-string)
(link_flags -linkall)
(libraries utop))
7 changes: 0 additions & 7 deletions examples/interact/jbuild

This file was deleted.

14 changes: 0 additions & 14 deletions jbuild

This file was deleted.

7 changes: 0 additions & 7 deletions jbuild-workspace.dev

This file was deleted.

3 changes: 3 additions & 0 deletions man/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(install
(section man)
(files utop.1 utop-full.1 utoprc.5))
5 changes: 0 additions & 5 deletions man/jbuild

This file was deleted.

12 changes: 12 additions & 0 deletions src/lib/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(library
(name uTop)
(public_name utop)
(wrapped false)
(flags :standard -safe-string)
(modes byte)
(libraries compiler-libs.toplevel findlib.top lambda-term threads)
(preprocess
(action
(run %{bin:cppo} -V OCAML:%{ocaml_version} %{input-file}))))

(ocamllex uTop_lexer)
12 changes: 0 additions & 12 deletions src/lib/jbuild

This file was deleted.

20 changes: 20 additions & 0 deletions src/top/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(executables
(names utop)
(libraries utop)
(flags :standard -safe-string)
(link_flags -linkall))

(rule
(targets utop-expunged.bc)
(deps utop.bc)
(action
(run %{exe:expunge/expunge.exe} %{bin:ocamlobjinfo} %{ocaml_where} %{deps}
%{targets} %{lib:compiler-libs.common:ocamlcommon.cma}
%{lib:compiler-libs.bytecomp:ocamlbytecomp.cma}
%{lib:compiler-libs.toplevel:ocamltoplevel.cma})))

(install
(section bin)
(files
(utop-expunged.bc as utop)
(utop.bc as utop-full)))
4 changes: 4 additions & 0 deletions src/top/expunge/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(executable
(name expunge)
(flags :standard -safe-string)
(libraries unix))
6 changes: 0 additions & 6 deletions src/top/expunge/jbuild

This file was deleted.

24 changes: 0 additions & 24 deletions src/top/jbuild

This file was deleted.

8 changes: 4 additions & 4 deletions utop.opam
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ homepage: "https://github.com/ocaml-community/utop"
bug-reports: "https://github.com/ocaml-community/utop/issues"
dev-repo: "https://github.com/ocaml-community/utop.git"
build: [
["jbuilder" "subst"] {pinned}
["jbuilder" "build" "-p" name "-j" jobs]
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs]
]
depends: [
"base-unix"
Expand All @@ -19,7 +19,7 @@ depends: [
"camomile"
"react" {>= "1.0.0"}
"cppo" {build & >= "1.1.2"}
"jbuilder" {build & >= "1.0+beta9"}
"dune" {build & >= "1.7"}
]
build-test: [["jbuilder" "runtest" "-p" name "-j" jobs]]
build-test: [["dune" "runtest" "-p" name "-j" jobs]]
available: [ocaml-version >= "4.03.0"]

0 comments on commit 641af3f

Please sign in to comment.