diff --git a/CHANGES.md b/CHANGES.md index 329b2dc..901df90 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +dev +--- + +* Port build to dune from jbuilder (@avsm) + 2.2.0 (2018-07-15) ------------------ diff --git a/Makefile b/Makefile index a5f761f..93b4f0c 100644 --- a/Makefile +++ b/Makefile @@ -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: @@ -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: diff --git a/README.md b/README.md index 127f098..f3f48cd 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 @@ -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 diff --git a/dune b/dune new file mode 100644 index 0000000..f921a24 --- /dev/null +++ b/dune @@ -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)) diff --git a/dune-workspace.dev b/dune-workspace.dev new file mode 100644 index 0000000..59b0386 --- /dev/null +++ b/dune-workspace.dev @@ -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))) diff --git a/examples/custom-utop/README.md b/examples/custom-utop/README.md index d356a18..a21faba 100644 --- a/examples/custom-utop/README.md +++ b/examples/custom-utop/README.md @@ -1,3 +1,3 @@ To build the custom toplevel in this directory, run: - $ jbuilder myutop.bc + $ dune build myutop.bc diff --git a/examples/custom-utop/dune b/examples/custom-utop/dune new file mode 100644 index 0000000..3da237b --- /dev/null +++ b/examples/custom-utop/dune @@ -0,0 +1,5 @@ +(executable + (name myutop) + (flags :standard -safe-string) + (link_flags -linkall) + (libraries utop)) diff --git a/examples/custom-utop/jbuild b/examples/custom-utop/jbuild deleted file mode 100644 index 3da432d..0000000 --- a/examples/custom-utop/jbuild +++ /dev/null @@ -1,7 +0,0 @@ -(jbuild_version 1) - -(executable - ((name myutop) - (flags (:standard -safe-string)) - (link_flags (-linkall)) - (libraries (utop)))) diff --git a/examples/interact/dune b/examples/interact/dune new file mode 100644 index 0000000..335158a --- /dev/null +++ b/examples/interact/dune @@ -0,0 +1,5 @@ +(executable + (name test_program) + (flags :standard -safe-string) + (link_flags -linkall) + (libraries utop)) diff --git a/examples/interact/jbuild b/examples/interact/jbuild deleted file mode 100644 index abe396f..0000000 --- a/examples/interact/jbuild +++ /dev/null @@ -1,7 +0,0 @@ -(jbuild_version 1) - -(executable - ((name test_program) - (flags (:standard -safe-string)) - (link_flags (-linkall)) - (libraries (utop)))) diff --git a/jbuild b/jbuild deleted file mode 100644 index 2b60363..0000000 --- a/jbuild +++ /dev/null @@ -1,14 +0,0 @@ -(jbuild_version 1) - -(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)))) diff --git a/jbuild-workspace.dev b/jbuild-workspace.dev deleted file mode 100644 index 2273ba1..0000000 --- a/jbuild-workspace.dev +++ /dev/null @@ -1,7 +0,0 @@ -;; This file is used by `make all-supported-ocaml-versions` -(context ((switch 4.02.3))) -(context ((switch 4.03.0))) -(context ((switch 4.04.2))) -(context ((switch 4.05.0))) -(context ((switch 4.06.1))) -(context ((switch 4.07.0))) diff --git a/man/dune b/man/dune new file mode 100644 index 0000000..92c62cc --- /dev/null +++ b/man/dune @@ -0,0 +1,3 @@ +(install + (section man) + (files utop.1 utop-full.1 utoprc.5)) diff --git a/man/jbuild b/man/jbuild deleted file mode 100644 index 43df3e6..0000000 --- a/man/jbuild +++ /dev/null @@ -1,5 +0,0 @@ -(jbuild_version 1) - -(install - ((section man) - (files (utop.1 utop-full.1 utoprc.5)))) diff --git a/src/lib/dune b/src/lib/dune new file mode 100644 index 0000000..316a558 --- /dev/null +++ b/src/lib/dune @@ -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) diff --git a/src/lib/jbuild b/src/lib/jbuild deleted file mode 100644 index 62139eb..0000000 --- a/src/lib/jbuild +++ /dev/null @@ -1,12 +0,0 @@ -(jbuild_version 1) - -(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} ${<}))))) - -(ocamllex (uTop_lexer)) diff --git a/src/top/dune b/src/top/dune new file mode 100644 index 0000000..7ce5a75 --- /dev/null +++ b/src/top/dune @@ -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))) diff --git a/src/top/expunge/dune b/src/top/expunge/dune new file mode 100644 index 0000000..b354c7a --- /dev/null +++ b/src/top/expunge/dune @@ -0,0 +1,4 @@ +(executable + (name expunge) + (flags :standard -safe-string) + (libraries unix)) diff --git a/src/top/expunge/jbuild b/src/top/expunge/jbuild deleted file mode 100644 index 0080610..0000000 --- a/src/top/expunge/jbuild +++ /dev/null @@ -1,6 +0,0 @@ -(jbuild_version 1) - -(executable - ((name expunge) - (flags (:standard -safe-string)) - (libraries (unix)))) diff --git a/src/top/jbuild b/src/top/jbuild deleted file mode 100644 index d58293a..0000000 --- a/src/top/jbuild +++ /dev/null @@ -1,24 +0,0 @@ -(jbuild_version 1) - -(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} - ${<} - ${@} - ${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))))) diff --git a/utop.opam b/utop.opam index f33f3cb..1825151 100644 --- a/utop.opam +++ b/utop.opam @@ -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" @@ -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"]