samoht / assemblage

A collection of tools to manage the configuration of OCaml projects
54 stars 4 forks source link

fix ocamlfind query for syntax,preprocessor preds #118

Closed dsheets closed 10 years ago

dsheets commented 10 years ago

ocamlfind query with a combined directory and archive format gives wrong answers for syntax extensions which use packages that aren't syntax extensions (like cow). ocamlfind query will not correctly recursively descend and resolve the archive filenames and instead will append archive files for non-syntax packages to the directory of the present library. However, ocamlfind query will correctly return the directories where dependencies can be found and can return the archives listed as dependencies. Now, As_ocamlfind uses the directories as an include path and the archives as relative references. This works correctly if the package being used has all transitively dependent archives in the requires list in a partial order by dependency relation.

dsheets commented 10 years ago

This is a findlib bug and really should be fixed there. What's the process for reporting those? email Gerd?

dbuenzli commented 10 years ago

@dsheets thanks for the detailed analysis. Bug report: yes, according to this page.

dsheets commented 10 years ago

Here's the relevant portion of the META:

package "syntax" (
 description = "Syntax extension for COW"
 requires = "camlp4 str dyntype.syntax xmlm ezjsonm"
 archive(syntax, preprocessor) = "xmlm.cma str.cma pa_cow.cma ezjsonm.cma"
 archive(syntax, toploop) = "pa_cow.cma"
 exists_if = "pa_cow.cma"
)

And then:

$ ocamlfind query -r -predicates syntax,preprocessor -format "%d" cow.syntax

/home/dsheets/.opam/4.02.0+doc/lib/ocaml/camlp4
/home/dsheets/.opam/4.02.0+doc/lib/ocaml
/home/dsheets/.opam/4.02.0+doc/lib/type_conv
/home/dsheets/.opam/4.02.0+doc/lib/dyntype
/home/dsheets/.opam/4.02.0+doc/lib/xmlm
/home/dsheets/.opam/4.02.0+doc/lib/uutf
/home/dsheets/.opam/4.02.0+doc/lib/jsonm
/home/dsheets/.opam/4.02.0+doc/lib/ezjsonm
/home/dsheets/.opam/4.02.0+doc/lib/cow
$ ocamlfind query -r -predicates syntax,preprocessor -format "%a" cow.syntax

pa_type_conv.cma
pa_dyntype.cma
xmlm.cma
str.cma
pa_cow.cma
ezjsonm.cma
$ ocamlfind query -r -predicates syntax,preprocessor -format "%d/%a" cow.syntax

/home/dsheets/.opam/4.02.0+doc/lib/type_conv/pa_type_conv.cma
/home/dsheets/.opam/4.02.0+doc/lib/dyntype/pa_dyntype.cma
/home/dsheets/.opam/4.02.0+doc/lib/cow/xmlm.cma
/home/dsheets/.opam/4.02.0+doc/lib/cow/str.cma
/home/dsheets/.opam/4.02.0+doc/lib/cow/pa_cow.cma
/home/dsheets/.opam/4.02.0+doc/lib/cow/ezjsonm.cma

As far as I can tell, this makes it impossible to use ocamlfind to query the correct preprocessor command line parameters.

Thanks,

David Sheets

dbuenzli commented 10 years ago

Le jeudi, 28 août 2014 à 21:39, David Sheets a écrit :

As far as I can tell, this makes it impossible to use ocamlfind to query the correct preprocessor command line parameters.

Do you know if it would work if you use ocamlfind <tool> rather than ocamlfind query ? IIRC we had other examples that suggested it was hard (or impossible) to replicate's ocamlfind's behaviour only with query

Daniel

dsheets commented 10 years ago

Yes, it works with the tool directly when it's a compiler. There is no preprocessor tool available.

samoht commented 10 years ago

Merging this one as we need to compile cow.

dsheets commented 10 years ago

Didn't you say there was a way to do another query for the non-syntax archives that wouldn't require the closure in the META of composed syntax extensions?

samoht commented 10 years ago

Indeed, see https://github.com/samoht/assemblage/pull/119