port build from jbuilder to dune

This commit is contained in:
Anil Madhavapeddy 2019-01-14 18:50:32 +00:00 committed by Jérémie Dimino
parent ea38850e60
commit 641af3fd63
21 changed files with 97 additions and 105 deletions

View File

@ -1,3 +1,8 @@
dev
---
* Port build to dune from jbuilder (@avsm)
2.2.0 (2018-07-15) 2.2.0 (2018-07-15)
------------------ ------------------

View File

@ -2,15 +2,15 @@ INSTALL_ARGS := $(if $(PREFIX),--prefix $(PREFIX),)
.PHONY: all .PHONY: all
all: all:
jbuilder build @install dune build
.PHONY: install .PHONY: install
install: install:
jbuilder install $(INSTALL_ARGS) dune install $(INSTALL_ARGS)
.PHONY: uninstall .PHONY: uninstall
uninstall: uninstall:
jbuilder uninstall $(INSTALL_ARGS) dune uninstall $(INSTALL_ARGS)
.PHONY: reinstall .PHONY: reinstall
reinstall: reinstall:
@ -20,15 +20,15 @@ reinstall:
.PHONY: examples .PHONY: examples
examples: examples:
jbuilder build @examples dune build @examples
.PHONY: test .PHONY: test
test: test:
jbuilder runtest dune runtest
.PHONY: all-supported-ocaml-versions .PHONY: all-supported-ocaml-versions
all-supported-ocaml-versions: all-supported-ocaml-versions:
jbuilder build --workspace jbuild-workspace.dev dune build --workspace dune-workspace.dev
.PHONY: cinaps .PHONY: cinaps
cinaps: cinaps:

View File

@ -27,7 +27,7 @@ Dependencies
------------ ------------
* [OCaml](http://caml.inria.fr/ocaml/) (>= 4.02.3) * [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) * [findlib](http://projects.camlcity.org/projects/findlib.html) (>= 1.4.0)
* [cppo](http://mjambon.com/cppo.html) (>= 1.0.1) * [cppo](http://mjambon.com/cppo.html) (>= 1.0.1)
* [react](http://erratique.ch/software/react) * [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 Creating a custom utop-enabled toplevel
--------------------------------------- ---------------------------------------
### With jbuilder ### With Dune
The recommended way to build a custom utop toplevel is via 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: `UTop_main.main`. For instance write the following `myutop.ml` file:
```ocaml ```ocaml
let () = UTop_main.main () let () = UTop_main.main ()
``` ```
and the following jbuild file: and the following dune file:
```scheme ```scheme
(executable (executable
((name myutop) (name myutop)
(link_flags (-linkall)) (link_flags -linkall)
(libraries (utop)))) (libraries utop))
``` ```
then to build the toplevel, run: 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 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 If you want to include more libraries in your custom utop, simply add
them to the `(libraries ...)` field. 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: following fields to the executable stanza:
```scheme ```scheme
(public_name myutop) (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 version of the executable, as currently native toplevels are not fully
suported. suported.
[jbuilder]: https://github.com/janestreet/jbuilder [dune]: https://github.com/ocaml/dune
### Manually, with ocamlfind ### Manually, with ocamlfind

12
dune Normal file
View File

@ -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
dune-workspace.dev Normal file
View File

@ -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)))

View File

@ -1,3 +1,3 @@
To build the custom toplevel in this directory, run: To build the custom toplevel in this directory, run:
$ jbuilder myutop.bc $ dune build myutop.bc

View File

@ -0,0 +1,5 @@
(executable
(name myutop)
(flags :standard -safe-string)
(link_flags -linkall)
(libraries utop))

View File

@ -1,7 +0,0 @@
(jbuild_version 1)
(executable
((name myutop)
(flags (:standard -safe-string))
(link_flags (-linkall))
(libraries (utop))))

5
examples/interact/dune Normal file
View File

@ -0,0 +1,5 @@
(executable
(name test_program)
(flags :standard -safe-string)
(link_flags -linkall)
(libraries utop))

View File

@ -1,7 +0,0 @@
(jbuild_version 1)
(executable
((name test_program)
(flags (:standard -safe-string))
(link_flags (-linkall))
(libraries (utop))))

14
jbuild
View File

@ -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))))

View File

@ -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)))

3
man/dune Normal file
View File

@ -0,0 +1,3 @@
(install
(section man)
(files utop.1 utop-full.1 utoprc.5))

View File

@ -1,5 +0,0 @@
(jbuild_version 1)
(install
((section man)
(files (utop.1 utop-full.1 utoprc.5))))

12
src/lib/dune Normal file
View File

@ -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)

View File

@ -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))

20
src/top/dune Normal file
View File

@ -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
src/top/expunge/dune Normal file
View File

@ -0,0 +1,4 @@
(executable
(name expunge)
(flags :standard -safe-string)
(libraries unix))

View File

@ -1,6 +0,0 @@
(jbuild_version 1)
(executable
((name expunge)
(flags (:standard -safe-string))
(libraries (unix))))

View File

@ -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)))))

View File

@ -6,8 +6,8 @@ homepage: "https://github.com/ocaml-community/utop"
bug-reports: "https://github.com/ocaml-community/utop/issues" bug-reports: "https://github.com/ocaml-community/utop/issues"
dev-repo: "https://github.com/ocaml-community/utop.git" dev-repo: "https://github.com/ocaml-community/utop.git"
build: [ build: [
["jbuilder" "subst"] {pinned} ["dune" "subst"] {pinned}
["jbuilder" "build" "-p" name "-j" jobs] ["dune" "build" "-p" name "-j" jobs]
] ]
depends: [ depends: [
"base-unix" "base-unix"
@ -19,7 +19,7 @@ depends: [
"camomile" "camomile"
"react" {>= "1.0.0"} "react" {>= "1.0.0"}
"cppo" {build & >= "1.1.2"} "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"] available: [ocaml-version >= "4.03.0"]