compute path equivalence correctly
I created a rule to produce file ./foo.mlpack, but ocamlbuild failed to produce it. Eventually I determined it is because it doesn't realize this is equilvalent to foo.mlpack.
Probably this is the source of the issue:
# Ocamlbuild_pack.Pathname.compare "./foo" "foo";;
- : int = -1
In my opinion, Pathname.t should be abstract. A build system is a good example of where file paths should be treated with greater rigor (for example as done in phat).
I agree that it would be nice if Path were abstract; the change would be hard to manage in terms of backward compatibility, though. One solution may be to provide another pathname module that is abstract, and and gradually convert the code in ocamlbuild itself and in plugins.
OCamlbuild has path normalization functions that should erase the difference between those two paths. Calling Pathname.normalize on the path argument of your static_file function should be enough -- and more portable than your current approach.
I did check out Path.normalize, but this made me not use it:
# Pathname.normalize "../lib";;
Exception: (Failure "Pathname.normalize_list: .. is forbidden here").
I would need to use Pathname.parent to get my desired overall functionality, but that returns exactly the above string:
# Pathname.parent "lib";;
- : string = "../lib"
So it all seems a bit fragile as I'm sure my solution is too.