What is the purpose of the _tags file with OCaml and how to interpret the contents?

From creating OCaml code that uses list view , I can use the _tags file to execute ocamlbuild with less build capabilities.

 $ cat _tags <**/*> : package(camlp4),syntax(camlp4o),package(pa_comprehension) 

From the Introduction of Batteries , I also need to have a _tags file to use the Batteries package.

 <*>: package(batteries) 

Why is the first example using <**/*> when the second example uses <*> ? In general, what is the purpose of the _tags file in ocamlbuild? Do you have good tutorials?

+5
source share
1 answer

The _tags file _tags in addition to myocamlbuild.ml forms the root of the ocamlbuild compilation ocamlbuild .

ocamlbuild is a very general tool that can compile anything. It is controlled by a solver, which, according to the task set by the user, finds a solution that can satisfy the goal. A solution is a chain of rules applied to files. Files can be tagged. Tags can change the rules. For example, it can add flags, such as enabling profiling or binding to a library.

A _tags file provides a mechanism for assigning tags to files and has a simple grammar:

  pattern ":" tag "," {tag}. 

What is to the left of : is actually a pattern or regular expression. Each file corresponding to the expression is assigned all the tags that are to the right of :

<**/*> means that for all files in this folder and for all subfolders there is a shortcut for this: true . <*> means for all files in this folder (without going to subfolders). Other examples: <*.ml> , <*.cmx> or <**/*.cma> (btw or can also be used to build a template).

OCamlbuild is documented in the OCaml Handbook , there is also a dump of the old wiki, with a lot of information.

But the fun part is that usually you don't need to know this to use OCaml. There is an OASIS tool that will automate all tasks and create a _tags file for you from a simple and high-level definition.

+6
source

Source: https://habr.com/ru/post/1214292/


All Articles