caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Ocamlbuild question
@ 2011-05-19 10:50 Matthieu Dubuget
  2011-05-19 11:34 ` Gabriel Scherer
  0 siblings, 1 reply; 8+ messages in thread
From: Matthieu Dubuget @ 2011-05-19 10:50 UTC (permalink / raw)
  To: Caml Mailing List

Hello,

I'm trying to build xml-light using ocamlbuild (don't ask me why, I do 
not know myself…)

The standard way for building xml-light.cma is working (with a patch 
stolen from debian package):

> wget http://tech.motion-twin.com/zip/xml-light-2.2.zip
> unzip xml-light-2.2.zip
> cd xml-light
> sed -i -e 's/.mly.ml:/%mli %ml: %mly/' Makefile
> make xml-light.cma


> ...
>
> ocamlyacc xml_parser.mly
> ocamlc xml.mli
> ocamlc dtd.mli
> ocamlc xml_parser.mli
> ocamlc -c xml_parser.ml
> ocamllex xml_lexer.mll
> 228 states, 1162 transitions, table size 6016 bytes
> ocamlc xml_lexer.mli
> ocamlc -c xml_lexer.ml
> ocamlc -c dtd.ml
> ocamlc xmlParser.mli
> ocamlc -c xmlParser.ml
> ocamlc -c xml.ml
> ocamlc -o xml-light.cma -a xml_parser.cmo xml_lexer.cmo dtd.cmo 
> xmlParser.cmo xml.cmo

Here is my try with ocamlbuild:

> wget http://tech.motion-twin.com/zip/xml-light-2.2.zip
> unzip xml-light-2.2.zip
> cd xml-light
> for d in Xml_parser Xml_lexer Dtd XmlParser Xml;
> do echo "$d" >> xml-light.mllib;
> done
> ocamlbuild xml-light.cma
> ls _build/*.cmo

> ...
>
> Circular dependencies: "dtd.cmo" already seen in
> [ "xml.cmo"; "dtd.cmo"; "xml_parser.cmo" ]
>
> Compilation unsuccessful after building 22 targets (0 cached) in 00:00:00.
> _build/dtd.cmo _build/xml.cmo _build/xml_lexer.cmo 
> _build/xml_parser.cmo _build/xmlParser.cmo

I would like to understand the origin of the problem?

Salutations

Matthieu



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Ocamlbuild question
  2011-05-19 10:50 [Caml-list] Ocamlbuild question Matthieu Dubuget
@ 2011-05-19 11:34 ` Gabriel Scherer
  0 siblings, 0 replies; 8+ messages in thread
From: Gabriel Scherer @ 2011-05-19 11:34 UTC (permalink / raw)
  To: matthieu.dubuget; +Cc: Caml Mailing List

The problem is that xml-light has a weird module dependency graph.
xml.ml depends on Dtd, while dtd.ml and dtd.mli depend on Xml. I'm not
sure the way this is done, but I think it is very hackish. The way I
understand it (and I am probably wrong), xml.mli is first compiled as
an signature-alone module (without implementation; you may have .mli
without attached .ml), against which Dtd is compiled, then the xml.ml
file is compiled as a *different* Xml module (yes, this sounds crazy),
and it reuses the types from the xml.mli interface by casting them
using Obj.magic.

I don't know why this is done that way. I suppose this is some kind of
hack to have recursive modules without saying it. Anyway, it's much
too hackish for any reasonable dependency solver to understand. I
think keeping your old build script is probably the best solution
here. I don't know much about ocamlbuild plugin language, maybe it's
possible to override the default dependency solver completely to
provide your own build order (I know it's possible to change it by
adding constraints), but I don't think you would gain much by this
approach.



On Thu, May 19, 2011 at 12:50 PM, Matthieu Dubuget
<matthieu.dubuget@gmail.com> wrote:
> Hello,
>
> I'm trying to build xml-light using ocamlbuild (don't ask me why, I do not
> know myself…)
>
> The standard way for building xml-light.cma is working (with a patch stolen
> from debian package):
>
>> wget http://tech.motion-twin.com/zip/xml-light-2.2.zip
>> unzip xml-light-2.2.zip
>> cd xml-light
>> sed -i -e 's/.mly.ml:/%mli %ml: %mly/' Makefile
>> make xml-light.cma
>
>
>> ...
>>
>> ocamlyacc xml_parser.mly
>> ocamlc xml.mli
>> ocamlc dtd.mli
>> ocamlc xml_parser.mli
>> ocamlc -c xml_parser.ml
>> ocamllex xml_lexer.mll
>> 228 states, 1162 transitions, table size 6016 bytes
>> ocamlc xml_lexer.mli
>> ocamlc -c xml_lexer.ml
>> ocamlc -c dtd.ml
>> ocamlc xmlParser.mli
>> ocamlc -c xmlParser.ml
>> ocamlc -c xml.ml
>> ocamlc -o xml-light.cma -a xml_parser.cmo xml_lexer.cmo dtd.cmo
>> xmlParser.cmo xml.cmo
>
> Here is my try with ocamlbuild:
>
>> wget http://tech.motion-twin.com/zip/xml-light-2.2.zip
>> unzip xml-light-2.2.zip
>> cd xml-light
>> for d in Xml_parser Xml_lexer Dtd XmlParser Xml;
>> do echo "$d" >> xml-light.mllib;
>> done
>> ocamlbuild xml-light.cma
>> ls _build/*.cmo
>
>> ...
>>
>> Circular dependencies: "dtd.cmo" already seen in
>> [ "xml.cmo"; "dtd.cmo"; "xml_parser.cmo" ]
>>
>> Compilation unsuccessful after building 22 targets (0 cached) in 00:00:00.
>> _build/dtd.cmo _build/xml.cmo _build/xml_lexer.cmo _build/xml_parser.cmo
>> _build/xmlParser.cmo
>
> I would like to understand the origin of the problem?
>
> Salutations
>
> Matthieu
>
>
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Ocamlbuild question
  2009-02-13 16:06         ` Matthieu Dubuget
@ 2009-02-16 13:07           ` Matthieu Dubuget
  0 siblings, 0 replies; 8+ messages in thread
From: Matthieu Dubuget @ 2009-02-16 13:07 UTC (permalink / raw)
  To: caml-list

Matthieu Dubuget a écrit :
> Correction:
>
> Matthieu Dubuget a écrit :
>   
>> Thanks to Nicolas: the solution was:
>> - tag .oocamlfind files with "dont_link_with"
>>     
>
> In fact, tagging .oocamlfind files is not needed.
>
> The key point is to add "dont_link_with" when calling dep:
>   
>>> dep ["pkg_"^nm;"dont_link_with"][nm ^ ".oocamlfind"] 
>>>       

And I also had to add this in _tags file of the project's root directory:
<**/*.{ml,mli}>: dont_link_with

Salutations

Matt


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Ocamlbuild question
  2009-02-13 10:56       ` Matthieu Dubuget
@ 2009-02-13 16:06         ` Matthieu Dubuget
  2009-02-16 13:07           ` Matthieu Dubuget
  0 siblings, 1 reply; 8+ messages in thread
From: Matthieu Dubuget @ 2009-02-13 16:06 UTC (permalink / raw)
  To: caml-list

Correction:

Matthieu Dubuget a écrit :
> Thanks to Nicolas: the solution was:
> - tag .oocamlfind files with "dont_link_with"

In fact, tagging .oocamlfind files is not needed.

The key point is to add "dont_link_with" when calling dep:
> - and add "dont_link_with" in left part of dep:
> 
>> dep ["pkg_"^nm;"dont_link_with"][nm ^ ".oocamlfind"] 
> 
> Matt


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Ocamlbuild question
  2009-02-12 18:33     ` Matthieu Dubuget
@ 2009-02-13 10:56       ` Matthieu Dubuget
  2009-02-13 16:06         ` Matthieu Dubuget
  0 siblings, 1 reply; 8+ messages in thread
From: Matthieu Dubuget @ 2009-02-13 10:56 UTC (permalink / raw)
  To: caml-list

Matthieu Dubuget a écrit :
> Matthieu Dubuget a écrit :
>   
>> Nicolas Pouillard a écrit :
>>     
>>> Excerpts from Matthieu Dubuget's message of Wed Feb 11 23:26:43 +0100 2009:
>>>   
>>>       
>>>> Hello,
>>>>
>>>> I'm trying to manage "internal" camlfind packages. I use "internal" with
>>>> the same meanning than in ocamlbuild documentation when speaking about
>>>> libraries.
>>>>
>>>> I want my camlfind packages to be re-installed if one of their
>>>> dependency was modified. For this, I wrote a simple rule, based on
>>>> %.iocamlfind files containing the files to install into findlib
>>>> directory. This rule also produces a stamp file : %.oocamlfind.
>>>>
>>>> I also want my camlfind package to be installed if they are needed by
>>>> another rule. For this, I do: dep ["pkg_"^nm][nm ^ ".oocamlfind"] for
>>>> each internal package.
>>>>
>>>> It seems to work ok: Suppose that package toto requires package tutu.
>>>> When I ask ocamlbuild toto.oocamlfind, the packages tutu is re-built if
>>>> needed. And if I modify one file of tutu, and then ask ocamlbuild to
>>>> generate toto.oocamlbuild, tutu is re-built and installed into findlib
>>>> directories. fine.
>>>>
>>>> BUT, when I'm producing a %.native from %.cmx, my dependencies (ie
>>>> %.oocamlfind files) are inserted in the command line...
>>>>
>>>> Here is an example:
>>>> ocamlfind ocamlopt -linkpkg -package mtsvrac -package log
>>>> logtest/test.cmx mtsvrac.oocamlfind log.oocamlfind -o logtest/test.native
>>>>
>>>> mtsvrac.oocamlfind and log.oocamlfind where added to the dependencies of
>>>> logtest/test.native.
>>>>
>>>> What would be the right solution to avoid this problem?
>>>> Is there something like a "dependency that should not be linked?"
>>>>     
>>>>         
>>> Hello,
>>>
>>> You should try to tag your .oocamlfind file with the dont_link_with tag.
>>>
>>> (this point certainly needs an entry in the FAQ...)
>>>
>>> Best regards,
>>>
>>>   
>>>       
>> It seems not to work – at least with ocaml 3.10.2 from godi.
>>
>>  I have:
>>
>>     
>>>> ocamlbuild -show-tags mtsvrac.oocamlfind
>>>> Tags for "mtsvrac.oocamlfind":
>>>> {. dont_link_with, extension:oocamlfind, file:mtsvrac.oocamlfind, quiet,
>>>>   traverse .}
>>>> Finished, 0 targets (0 cached) in 00:00:00.
>>>>         
>> and still
>>
>>     
>>>> ocamlopt.opt: don't know what to do with mtsvrac.oocamlfind.
>>>>         
>> I will check at home with 3.11
>>     
>
> Idem
>   

Thanks to Nicolas: the solution was:
- tag .oocamlfind files with "dont_link_with"
- and add "dont_link_with" in left part of dep:

> dep ["pkg_"^nm;"dont_link_with"][nm ^ ".oocamlfind"] 

Matt




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Ocamlbuild question
  2009-02-12 17:32   ` Matthieu Dubuget
@ 2009-02-12 18:33     ` Matthieu Dubuget
  2009-02-13 10:56       ` Matthieu Dubuget
  0 siblings, 1 reply; 8+ messages in thread
From: Matthieu Dubuget @ 2009-02-12 18:33 UTC (permalink / raw)
  To: caml-list; +Cc: Nicolas Pouillard

Matthieu Dubuget a écrit :
> Nicolas Pouillard a écrit :
>> Excerpts from Matthieu Dubuget's message of Wed Feb 11 23:26:43 +0100 2009:
>>   
>>> Hello,
>>>
>>> I'm trying to manage "internal" camlfind packages. I use "internal" with
>>> the same meanning than in ocamlbuild documentation when speaking about
>>> libraries.
>>>
>>> I want my camlfind packages to be re-installed if one of their
>>> dependency was modified. For this, I wrote a simple rule, based on
>>> %.iocamlfind files containing the files to install into findlib
>>> directory. This rule also produces a stamp file : %.oocamlfind.
>>>
>>> I also want my camlfind package to be installed if they are needed by
>>> another rule. For this, I do: dep ["pkg_"^nm][nm ^ ".oocamlfind"] for
>>> each internal package.
>>>
>>> It seems to work ok: Suppose that package toto requires package tutu.
>>> When I ask ocamlbuild toto.oocamlfind, the packages tutu is re-built if
>>> needed. And if I modify one file of tutu, and then ask ocamlbuild to
>>> generate toto.oocamlbuild, tutu is re-built and installed into findlib
>>> directories. fine.
>>>
>>> BUT, when I'm producing a %.native from %.cmx, my dependencies (ie
>>> %.oocamlfind files) are inserted in the command line...
>>>
>>> Here is an example:
>>> ocamlfind ocamlopt -linkpkg -package mtsvrac -package log
>>> logtest/test.cmx mtsvrac.oocamlfind log.oocamlfind -o logtest/test.native
>>>
>>> mtsvrac.oocamlfind and log.oocamlfind where added to the dependencies of
>>> logtest/test.native.
>>>
>>> What would be the right solution to avoid this problem?
>>> Is there something like a "dependency that should not be linked?"
>>>     
>> Hello,
>>
>> You should try to tag your .oocamlfind file with the dont_link_with tag.
>>
>> (this point certainly needs an entry in the FAQ...)
>>
>> Best regards,
>>
>>   
> 
> It seems not to work – at least with ocaml 3.10.2 from godi.
> 
>  I have:
> 
>>> ocamlbuild -show-tags mtsvrac.oocamlfind
>>> Tags for "mtsvrac.oocamlfind":
>>> {. dont_link_with, extension:oocamlfind, file:mtsvrac.oocamlfind, quiet,
>>>   traverse .}
>>> Finished, 0 targets (0 cached) in 00:00:00.
> 
> and still
> 
>>> ocamlopt.opt: don't know what to do with mtsvrac.oocamlfind.
> 
> I will check at home with 3.11

Idem

> 
> Thanks
> 
> Salutations
> 
> Matt
> 
> 
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Ocamlbuild question
  2009-02-12 16:00 ` [Caml-list] " Nicolas Pouillard
@ 2009-02-12 17:32   ` Matthieu Dubuget
  2009-02-12 18:33     ` Matthieu Dubuget
  0 siblings, 1 reply; 8+ messages in thread
From: Matthieu Dubuget @ 2009-02-12 17:32 UTC (permalink / raw)
  To: Nicolas Pouillard, caml-list

Nicolas Pouillard a écrit :
> Excerpts from Matthieu Dubuget's message of Wed Feb 11 23:26:43 +0100 2009:
>   
>> Hello,
>>
>> I'm trying to manage "internal" camlfind packages. I use "internal" with
>> the same meanning than in ocamlbuild documentation when speaking about
>> libraries.
>>
>> I want my camlfind packages to be re-installed if one of their
>> dependency was modified. For this, I wrote a simple rule, based on
>> %.iocamlfind files containing the files to install into findlib
>> directory. This rule also produces a stamp file : %.oocamlfind.
>>
>> I also want my camlfind package to be installed if they are needed by
>> another rule. For this, I do: dep ["pkg_"^nm][nm ^ ".oocamlfind"] for
>> each internal package.
>>
>> It seems to work ok: Suppose that package toto requires package tutu.
>> When I ask ocamlbuild toto.oocamlfind, the packages tutu is re-built if
>> needed. And if I modify one file of tutu, and then ask ocamlbuild to
>> generate toto.oocamlbuild, tutu is re-built and installed into findlib
>> directories. fine.
>>
>> BUT, when I'm producing a %.native from %.cmx, my dependencies (ie
>> %.oocamlfind files) are inserted in the command line...
>>
>> Here is an example:
>> ocamlfind ocamlopt -linkpkg -package mtsvrac -package log
>> logtest/test.cmx mtsvrac.oocamlfind log.oocamlfind -o logtest/test.native
>>
>> mtsvrac.oocamlfind and log.oocamlfind where added to the dependencies of
>> logtest/test.native.
>>
>> What would be the right solution to avoid this problem?
>> Is there something like a "dependency that should not be linked?"
>>     
>
> Hello,
>
> You should try to tag your .oocamlfind file with the dont_link_with tag.
>
> (this point certainly needs an entry in the FAQ...)
>
> Best regards,
>
>   

It seems not to work – at least with ocaml 3.10.2 from godi.

 I have:

>> ocamlbuild -show-tags mtsvrac.oocamlfind
>> Tags for "mtsvrac.oocamlfind":
>> {. dont_link_with, extension:oocamlfind, file:mtsvrac.oocamlfind, quiet,
>>   traverse .}
>> Finished, 0 targets (0 cached) in 00:00:00.

and still

>> ocamlopt.opt: don't know what to do with mtsvrac.oocamlfind.

I will check at home with 3.11

Thanks

Salutations

Matt




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Caml-list] Ocamlbuild question
  2009-02-11 22:26 Matthieu Dubuget
@ 2009-02-12 16:00 ` Nicolas Pouillard
  2009-02-12 17:32   ` Matthieu Dubuget
  0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Pouillard @ 2009-02-12 16:00 UTC (permalink / raw)
  To: Matthieu Dubuget; +Cc: caml-list

Excerpts from Matthieu Dubuget's message of Wed Feb 11 23:26:43 +0100 2009:
> Hello,
> 
> I'm trying to manage "internal" camlfind packages. I use "internal" with
> the same meanning than in ocamlbuild documentation when speaking about
> libraries.
> 
> I want my camlfind packages to be re-installed if one of their
> dependency was modified. For this, I wrote a simple rule, based on
> %.iocamlfind files containing the files to install into findlib
> directory. This rule also produces a stamp file : %.oocamlfind.
> 
> I also want my camlfind package to be installed if they are needed by
> another rule. For this, I do: dep ["pkg_"^nm][nm ^ ".oocamlfind"] for
> each internal package.
> 
> It seems to work ok: Suppose that package toto requires package tutu.
> When I ask ocamlbuild toto.oocamlfind, the packages tutu is re-built if
> needed. And if I modify one file of tutu, and then ask ocamlbuild to
> generate toto.oocamlbuild, tutu is re-built and installed into findlib
> directories. fine.
> 
> BUT, when I'm producing a %.native from %.cmx, my dependencies (ie
> %.oocamlfind files) are inserted in the command line...
> 
> Here is an example:
> ocamlfind ocamlopt -linkpkg -package mtsvrac -package log
> logtest/test.cmx mtsvrac.oocamlfind log.oocamlfind -o logtest/test.native
> 
> mtsvrac.oocamlfind and log.oocamlfind where added to the dependencies of
> logtest/test.native.
> 
> What would be the right solution to avoid this problem?
> Is there something like a "dependency that should not be linked?"

Hello,

You should try to tag your .oocamlfind file with the dont_link_with tag.

(this point certainly needs an entry in the FAQ...)

Best regards,

-- 
Nicolas Pouillard


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-05-19 11:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-19 10:50 [Caml-list] Ocamlbuild question Matthieu Dubuget
2011-05-19 11:34 ` Gabriel Scherer
  -- strict thread matches above, loose matches on Subject: below --
2009-02-11 22:26 Matthieu Dubuget
2009-02-12 16:00 ` [Caml-list] " Nicolas Pouillard
2009-02-12 17:32   ` Matthieu Dubuget
2009-02-12 18:33     ` Matthieu Dubuget
2009-02-13 10:56       ` Matthieu Dubuget
2009-02-13 16:06         ` Matthieu Dubuget
2009-02-16 13:07           ` Matthieu Dubuget

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).