Skip to content

Latest commit

 

History

64 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unic, a way to infer dependencies from an OCaml project

unic is a project that enables the analysis of an OCaml project (without relying on any particular build system such as dune) in order to construct a dependency graph for that project within a given context (such as that provided by opam). In this way, it is possible to identify dependencies that require object files which may have been compiled using what is known as the "host toolchain".

The aim is therefore to identify these dependencies and determine which opam packages they originate from, so as to inform the user what might need to be recompiled if they wish to build the project using a different "toolchain".

In this case, it is a solution that works well whenever one wishes to compile a unikernel using the Solo5 toolchain. Let us take the example of immuable. This project provides a unikernel as well as an executable (which should not be compiled with the Solo5 toolchain). One of the artefacts required for the unikernel is Documents, which is generated by mcrunch. You can then infer the dependencies and determine what needs to be recompiled using:

$ opam pin add https://git.robur.coop/robur/unic -y
$ git clone https://github.com/dinosaure/immuable
$ cd immuable
$ unic infer --recurse . --toolchain solo5 --exclude bin/ --ignore Documents \
  --prefer digestif.c --prefer checkseum.c
angstrom
bigstringaf
bin
bstr
cachet
carton
checkseum
cstruct
decompress
digestif
encore
faraday
fluxt
gmp
...

All that remains is for the user to find a way to recompile these opam packages using the Solo5 toolchain. If these packages use dune, simply vendorise them (i.e. retrieve them using opam source and specify a directory containing their source code using (vendored_dirs ...)).

Some other tools

unic offers other tools that can help you understand a project:

  • for example, you can inspect the configuration of an OCaml toolchain if you wish, using unic cfg
  • you can also extract the signature of an artefact using unic digest (useful for tracking the links between artefacts)
  • it is possible to qualify project's artefacts with unic qualify (based on their signatures) and, in particular, to identify what is missing
  • it is also possible to resolve (with unic resolve) missing modules using ocamlfind's packages
  • An introspection and search tool (unic info) is available to display an artefact (and its details) or to search for one
  • A tool for introspection and searching META files (unic meta) is also available

About

A tool to infer dependencies from an OCaml project

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages