|Anonymous | Login | Signup for a new account||2013-12-05 16:15 CET|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0006161||OCaml||OCamlbuild (the tool)||public||2013-09-05 15:11||2013-09-06 14:43|
|Target Version||Fixed in Version|
|Summary||0006161: add "context" flag in _tags for multi-directories projects|
|Description||I propose to add a "context" flag in the _tags file.|
The syntax would be something like:
<mysubdir> : context (dirA,dirB)
and would have the same effects this in myocamlbuild.ml:
Pathname.define_context mysubdir ["dirA";"dirB"]
This is much better that using the "include" tag which include a directory everywhere and is not very clean in many cases!
|Tags||No tags attached.|
There is some pressure to add a lot of things in `_tags` because editing that file is more convenient than adding stuff to myocamlbuild.ml. Some of those ideas are good, some of those ideas are bad, and some feels like "may be nice, but may turn out to be a mistake in a few months".
For now, my personal filter is "does it respect the existing semantics of _tags file?". Now there are several non-conflicting interpretations of what this existing semantics may be -- in decreasing order of strictness:
(1) A way to attach tags to an arbitrary subset of the ocamlbuild targets matching some predicate
(2) A way to *influence manipulation* (but not necessarily through the tagset->flag mapping machinery) of the ocamlbuild targets matching some predicate
(3) A general way to configure ocamlbuild's behavior, restricted by a bizarre syntax
Option (1) is the strictest and consistent with almost all tags existing today. Option (2) is supported by the "traverse", "include" and "non_hygienic"/"precious". Option (3) is what led to horrible hacks such as "true: use_menhir".
A feature that falls into use-case (1) and has a clear utility is immediately confirmed: yes, we want that and feel free to help us by providing a patch. A feature that falls into use-case (3) is highly suspect -- my current entirely personal opinion is that it is a bad idea. A feature falling into use-case (2) is on hold: it may be a good idea, but it could also lead us down the slope, into the junkyard were no sane design is possible anymore.
Yours falls into case (2). It is a *reasonable* extension of the "include" and "traverse" mechanism, but it's still not the core purpose of the _tags file. I will happily accept a good patch that does this, but will concentrate my own contribution time on things that feel more convincing.
edited on: 2013-09-06 15:44
I agree with your position and actually, the semantic of the "include" is very bizarre : if you add "<A> : include" in some _tags file, it will add "-I xxx/A" in all your project !
(where "xxx" is the relative path from the _tags file to the ocamlbuild root directory).
Usually, this is not what we need : we want to express the fact that "a given set of files need to add "-I A" options to the ocaml compilers.
This is very similar to the "package" parametric tags, so my wish fall more in Option (1) than Option (2).
I tried to write a plugin inspired from the package plugin as described on http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild. [^] I added the following code in the dispatch function/section After_rules:
let list_subdirs dir =
let rec list_dirs dirs dir =
if Sys.is_directory dir then (
(* printf "dir = %s, context = %a @." dir (print_list pp_print_string) context; *)
let dirs = dir::dirs in
Array.fold_left (fun dirs d -> list_dirs dirs (dir ^ "/" ^ d)) dirs (Sys.readdir dir)
) else dirs in
List.fold_left list_dirs  (List.filter (fun d -> d <> "_build") & Array.to_list & Sys.readdir ".")
List.iter begin fun dir ->
flag ["ocaml"; "compile"; "context_"^dir] & S[A"-I"; A dir];
flag ["ocaml"; "ocamldep"; "context_"^dir] & S[A"-I"; A dir];
flag ["ocaml"; "doc"; "context_"^dir] & S[A"-I"; A dir];
end (list_subdirs ())
It almost works except but fail when calling the "menhir" command because the menhir rule add the "--ocamlc" options only the include dirs obtained from the include flag (cf ocamlbuild/ocaml_tools.ml).
|That's a good point.|
|2013-09-05 15:11||daweil||New Issue|
|2013-09-05 15:32||gasche||Note Added: 0010316|
|2013-09-05 15:33||gasche||Status||new => acknowledged|
|2013-09-06 14:37||daweil||Note Added: 0010319|
|2013-09-06 14:43||gasche||Note Added: 0010320|
|2013-09-06 15:44||daweil||Note Edited: 0010319||View Revisions|
|Copyright © 2000 - 2011 MantisBT Group|