ocaml / ocamlbuild

The legacy OCamlbuild build manager
Other
121 stars 81 forks source link

MPR#6098: Global predicates #192

Open damiendoligez opened 7 years ago

damiendoligez commented 7 years ago

PR transferred from https://caml.inria.fr/mantis/view.php?id=6098 [original reporter: @danmey ]

In ocamlbuild we use _tags to associate predicate with list of tags. Sometimes it's useful to associate globally set tags, usually it's done in such way:

true: debug
<src/*>: package(foo)

here debug is universally global tag associated with any path in the source tree

Nothing stops us however say this:

debug
<src/*>: package(foo)

this has the following advantage: it syntactically restrict the tag to work only in global scope. It might be useful for example when mirroring the commandline options as tags:

copts(-O3)
lopts(foo.cma)
I(ocamlbuild)

If the tags where defined using predicate, it might be more difficult to support it in a sane way.

whitequark commented 7 years ago

Triage: this makes _tags ambiguous, and I don't see what improvement it brings anyway.

gasche commented 7 years ago

I have considered the need for a precidate/condition to put on the left of the column : that would have a non-boolean semantics: default: foo or global: foo. Currently some parts of ocamlbuild rely on true: ... in this way, and having a way to express the intent would be nicer. For example, having such a thing would let us consider having plugin-tags specified within _tags, instead of as a command-line flag (it would be more convenient for users; the idea is that we could parse the _tags file at plugin-build time and only care for a specific predicate, plugin: or something).

I never managed to get convinced enough by the idea to actually implement it. It is a sort of pragmatic compromise, where we accept to take some distance from the ideal/clean semantics of the _tags file, but in an arguably principled/elegant way. Unsure.