Skip to content

Commit

Permalink
Port to jbuilder
Browse files Browse the repository at this point in the history
This also ports the PPX to ocaml-migrate-parsetree.

The work in this commit, and the preceding one, was done by Andrew Ray
(@andrewray) in #374. These two commits are just a more blame-friendly
version; the detailed history is visible #374.

Some number of follow-on commits will probably be needed to fully
stabilize and finalize the port. Also, this commit breaks some packages
that depend on Lwt incorrectly. We will probably take steps to break
them more softly than is being done by this commit alone.

Builds on 4.05 are temporarily disabled, due to jbuilder not working
with the 4.05 betas. We will address this by building on trunk later.

This port disables coverage via Bisect completely (#319). We will
restore that in follow-on work; in the meantime, we expect few enough
edits to the test suite to be made that we can run the test suite with
coverage in a separate branch that does not yet have this commit, and
cherry-pick commits over if any development of the test suite occurs.

The build system produced by this commit is a bit of a chimera: it
adopts jbuilder without adopting modern packaging best practices. We
need to do the latter slowly, to avoid breaking projects that depend on
Lwt without proper warning (#293). Work along this direction had already
started (#301, #338, #370), and this jbuilder port will make it easier
to continue.

The port also pre-emptively solves a lot of other issues with the build
system. See the pull request for any issue links, to be added over the
coming days.

Maintainer's note: squash and summary done by Anton Bachin (@aantron).
  • Loading branch information
andrewray authored and aantron committed Jun 8, 2017
1 parent 138128c commit 2163fb1
Show file tree
Hide file tree
Showing 75 changed files with 1,014 additions and 1,569 deletions.
15 changes: 6 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
_build
src/unix/lwt_config.ml
src/unix/lwt_config.h
src/unix/lwt_unix_jobs_generated.ml
src/unix/jobs-unix/
setup.data
setup.log
setup.exe
setup-dev.exe
_opam
src/unix/lwt_config
src/jbuild-ignore

# Coverage analysis.
bisect*.out
_coverage/

# For local work, tests, etc.
scratch/

# Autogenerated by jbuider
.merlin
*.install
9 changes: 6 additions & 3 deletions .jenkins.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
opam pin add --no-action lwt .
opam install camlp4
opam install ssl lablgtk react conf-libev
opam install ocamlbuild uchar
opam install --deps-only lwt
opam install --verbose lwt

do_build_doc () {
rm -rf _build/lwt-api.wikidocdir
./setup-dev.exe -build lwt-api.wikidocdir/index.wiki
rm -rf doc/api
# generate wikidoc documentation
make doc-api-wiki
# copy manual pages and api documentation
cp -Rf doc/*.wiki ${MANUAL_SRC_DIR}
cp -Rf _build/lwt-api.wikidocdir/*.wiki ${API_DIR}
cp -Rf doc/api/wiki/*.wiki ${API_DIR}
}

do_remove () {
Expand Down
9 changes: 0 additions & 9 deletions .merlin

This file was deleted.

4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ matrix:
env: COMPILER=4.03
- os: linux
env: COMPILER=4.04
- os: linux
env: COMPILER=4.05
#- os: linux
# env: COMPILER=4.05
- os: linux
env: COMPILER=4.04 FLAMBDA=yes
- os: linux
Expand Down
134 changes: 134 additions & 0 deletions META.lwt.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#
# This file has been copied from _build/default/META.lwt then
# modified to add exists_if clauses to support optional
# compilation and the camlp4 syntax extension packages have
# been given appropriate predicates.
#

version = "dev"
description = "Monadic promises and concurrent I/O"
requires = "bytes result"
archive(byte) = "lwt.cma"
archive(native) = "lwt.cmxa"
plugin(byte) = "lwt.cma"
plugin(native) = "lwt.cmxs"
package "log" (
directory = "log"
version = "dev"
description = "Logger for Lwt"
requires = "bytes lwt result"
archive(byte) = "lwt_log.cma"
archive(native) = "lwt_log.cmxa"
plugin(byte) = "lwt_log.cma"
plugin(native) = "lwt_log.cmxs"
exists_if = "lwt_log.cma"
)
package "ppx" (
directory = "ppx"
version = "dev"
description = "Lwt PPX syntax extension"
requires(ppx_driver) = "compiler-libs
compiler-libs.common
ocaml-migrate-parsetree
ppx_tools_versioned"
archive(ppx_driver,byte) = "ppx_lwt.cma"
archive(ppx_driver,native) = "ppx_lwt.cmxa"
plugin(ppx_driver,byte) = "ppx_lwt.cma"
plugin(ppx_driver,native) = "ppx_lwt.cmxs"
exists_if = "ppx_lwt.cma"
# This is what jbuilder uses to find out the runtime dependencies of
# a preprocessor
ppx_runtime_deps = "bytes lwt result"
# This line makes things transparent for people mixing preprocessors
# and normal dependencies
requires(-ppx_driver) = "lwt.ppx.deprecated-ppx-method"
package "deprecated-ppx-method" (
version = "dev"
description = "glue package for the deprecated method of using ppx"
requires = "bytes lwt result"
ppx(-ppx_driver,-custom_ppx) = "./ppx.exe --as-ppx"
exists_if = "ppx_lwt.cma"
)
)
package "preemptive" (
directory = "preemptive"
version = "dev"
description = "Preemptive thread support for Lwt"
requires = "bigarray
bytes
lwt
lwt.log
lwt.unix
result
threads
threads.posix
unix"
archive(byte) = "lwt_preemptive.cma"
archive(native) = "lwt_preemptive.cmxa"
plugin(byte) = "lwt_preemptive.cma"
plugin(native) = "lwt_preemptive.cmxs"
exists_if = "lwt_preemptive.cma"
)
package "simple-top" (
directory = "simple-top"
version = "dev"
description = "Lwt-OCaml top level integration (deprecated; use utop)"
requires = "bigarray
bytes
compiler-libs
compiler-libs.common
lwt
lwt.log
lwt.unix
result
unix"
archive(byte) = "lwt_simple_top.cma"
archive(native) = "lwt_simple_top.cmxa"
plugin(byte) = "lwt_simple_top.cma"
plugin(native) = "lwt_simple_top.cmxs"
exists_if = "lwt_simple_top.cma"
)
package "syntax" (
directory = "syntax"
version = "dev"
description = "Camlp4 syntax for Lwt (deprecated; use lwt.ppx)"
requires = "camlp4 lwt.syntax.options"
archive(syntax, preprocessor) = "lwt_syntax.cma"
archive(syntax, toploop) = "lwt_syntax.cma"
archive(syntax, preprocessor, native) = "lwt_syntax.cmxa"
archive(syntax, preprocessor, native, plugin) = "lwt_syntax.cmxs"
exists_if = "lwt_syntax.cma"
package "log" (
directory = "log"
version = "dev"
description = "Camlp4 syntax for Lwt logging (deprecated; use lwt.ppx)"
requires = "camlp4 lwt.syntax.options"
archive(syntax, preprocessor) = "lwt_syntax_log.cma"
archive(syntax, toploop) = "lwt_syntax_log.cma"
archive(syntax, preprocessor, native) = "lwt_syntax_log.cmxa"
archive(syntax, preprocessor, native, plugin) = "lwt_syntax_log.cmxs"
exists_if = "lwt_syntax_log.cma"
)
package "options" (
directory = "options"
version = "dev"
description = "Options for Lwt Camlp4 syntax extension (deprecated; use lwt.ppx)"
requires = "camlp4"
archive(syntax, preprocessor) = "lwt_syntax_options.cma"
archive(syntax, toploop) = "lwt_syntax_options.cma"
archive(syntax, preprocessor, native) = "lwt_syntax_options.cmxa"
archive(syntax, preprocessor, native, plugin) = "lwt_syntax_options.cmxs"
exists_if = "lwt_syntax_options.cma"
)
)
package "unix" (
directory = "unix"
version = "dev"
description = "Unix support for Lwt"
requires = "bigarray bytes lwt lwt.log result unix"
archive(byte) = "lwt_unix.cma"
archive(native) = "lwt_unix.cmxa"
plugin(byte) = "lwt_unix.cma"
plugin(native) = "lwt_unix.cmxs"
exists_if = "lwt_unix.cma"
)
84 changes: 41 additions & 43 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,70 +9,68 @@
OCAMLFIND_IGNORE_DUPS_IN = $(shell ocamlfind query compiler-libs)
export OCAMLFIND_IGNORE_DUPS_IN

# Set to setup.exe for the release
SETUP := setup-dev.exe

# Default rule
default: build

# Setup for the development version
setup-dev.exe: _oasis setup.ml
grep -v '^#' setup.ml > setup_dev.ml
ocamlfind ocamlopt -o $@ -linkpkg -package ocamlbuild,oasis.dynrun setup_dev.ml || \
ocamlfind ocamlc -o $@ -linkpkg -package ocamlbuild,oasis.dynrun setup_dev.ml || true
rm -f setup_dev.*

# Setup for the release
setup.exe: setup.ml
ocamlopt.opt -o $@ $< || ocamlopt -o $@ $< || ocamlc -o $@ $<
rm -f setup.cmx setup.cmi setup.o setup.obj setup.cmo
# build the usual development packages
build: check-config
jbuilder build \
--only-packages lwt \
@install

setup: $(SETUP)
# build everything
all: check-config
jbuilder build @install

build: $(SETUP) setup.data
./$(SETUP) -build $(BUILDFLAGS)
# run all tests
test: check-config
jbuilder runtest

doc: $(SETUP) setup.data build
./$(SETUP) -doc $(DOCFLAGS)
# configuration
check-config:
@[ -f src/jbuild-ignore ] && [ -f src/unix/lwt_config ] && echo "LWT configuration OK" || cat src/util/config-warn

doc-api: $(SETUP) setup.data build
./$(SETUP) -build lwt-api.docdir/index.html
default-config:
ocaml src/util/configure.ml -use-libev false -use-camlp4 false

test: $(SETUP) setup.data build clean-coverage
./$(SETUP) -test $(TESTFLAGS)
# Use jbuilder/odoc to generate static html documentation.
# Currenty requires ocaml 4.03.0 to install odoc.
doc:
jbuilder build @doc

all: $(SETUP)
./$(SETUP) -all $(ALLFLAGS)
# Build HTML documentation with ocamldoc
doc-api-html: all
make -C doc api/html/index.html

install: $(SETUP) setup.data
./$(SETUP) -install $(INSTALLFLAGS)
# Build wiki documentation with wikidoc
# requires ocaml 4.03.0 and pinning the repo
# https://github.com/ocsigen/wikidoc
doc-api-wiki: all
make -C doc api/wiki/index.wiki

uninstall: $(SETUP) setup.data
./$(SETUP) -uninstall $(UNINSTALLFLAGS)
install:
jbuilder install

reinstall: $(SETUP) setup.data
./$(SETUP) -reinstall $(REINSTALLFLAGS)
uninstall:
jbuilder uninstall

clean: $(SETUP) clean-coverage
./$(SETUP) -clean $(CLEANFLAGS)
reinstall:
jbuilder uninstall
jbuilder install

distclean: $(SETUP)
./$(SETUP) -distclean $(DISTCLEANFLAGS)
rm -rf setup*.exe
clean:
rm -fr _build
rm -f *.install
rm -fr doc/api
rm -f src/jbuild-ignore src/unix/lwt_config

clean-coverage:
rm -rf bisect*.out
rm -rf _coverage/

configure: $(SETUP)
./$(SETUP) -configure $(CONFIGUREFLAGS)

setup.data: $(SETUP)
./$(SETUP) -configure $(CONFIGUREFLAGS)

coverage: test
bisect-ppx-report -I _build/ -html _coverage/ bisect*.out
bisect-ppx-report -text - -summary-only bisect*.out
@echo See _coverage/index.html

.PHONY: default setup build doc test all install uninstall reinstall clean distclean configure coverage
.PHONY: default build doc test all install uninstall reinstall clean coverage
Loading

0 comments on commit 2163fb1

Please sign in to comment.