Skip to content

Instantly share code, notes, and snippets.

@hcarty
Created May 24, 2017 18:59
Show Gist options
  • Save hcarty/9319d362ce8d3bd2d4d1da1ce19c2c68 to your computer and use it in GitHub Desktop.
Save hcarty/9319d362ce8d3bd2d4d1da1ce19c2c68 to your computer and use it in GitHub Desktop.
Notes on a potentially useful opam + jbuilder workflow

OCaml project workflow using opam and jbuilder

The basic idea is to use opam switches to setup per-OCaml-version shared tools (merlin, ocp-index/ocp-browser, ocp-indent) with project-local builds for everything else.

For example, a user would have a 4.04.1+flambda switch available with its own merlin, ocp-indent and other project-generic tooling.

Then a user would clone or create the project (let's call it Project A (PA)) they are working on. This project would use jbuilder as its build system and include appropriate *.opam files specifying dependencies.

A jbuilder init or jbuilder init-deps command could be available which would pull down the source code for all of PA's transitive dependencies, unpacking them under a local directory _vendor (or some other appropriate name). This _vendor directory could live within a switch-specific context. opam could/would be used to determine the appropriate dependencies to pull down. All of the depedencies would either use jbuilder as their build system or have appropriate jbuild configurations in their source tree to enable this approach.

jbuilder would know to include _vendor in the directories it crawls while looking for things to build.

If I understand how jbuilder works correctly, this should allow each project to have their own local, unique set of dependent libraries available without having to duplicate compilers and build tools per-project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment