caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: moosotc@gmail.com
To: David Allsopp <dra-news@metastack.com>
Cc: Gabriel Scherer <gabriel.scherer@gmail.com>,
	 caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Interface(.mli) location
Date: Tue, 09 Aug 2016 21:38:35 +0300	[thread overview]
Message-ID: <87r39xbxec.fsf@gmail.com> (raw)
In-Reply-To: <E51C5B015DBD1348A1D85763337FB6D9013504E136@Remus.metastack.local> (David Allsopp's message of "Tue, 9 Aug 2016 18:33:13 +0000")

David Allsopp <dra-news@metastack.com> writes:

> moosotc@gmail.com wrote:
>> David Allsopp <dra-news@metastack.com> writes:
>> 
>> > moosotc@gmail.com wrote:
>> >> David Allsopp <dra-news@metastack.com> writes:
>> >> > moosotc@gmail.com wrote:
>> >> >> Gabriel Scherer <gabriel.scherer@gmail.com> writes:
>> >> >>
>> >> >> > It is correct that ocamldep assumes that the .ml and .mli of a
>> >> >> > given module are at the same place, but this is not the case for
>> >> >> > the rest of the compilation chain, which is either concerned
>> >> >> > with single source files (a .ml file or a .mli file) or with
>> >> >> > "compilation units" (a .cmo and .cmi files passed together,
>> >> >> > independently of where their source files were). In particular,
>> >> >> > all type-checking tools do look in -I directories to find .cmi
>> >> >> > files for the dependencies of the module being compiled (and at
>> >> >> > this stage
>> >> they do not care for .mli files).
>> >> >>
>> >> >> But the script seems to (somewhat) contradict this, i.e. after
>> >> >> `ocamlc -I d -c a.ml' ocamlc ignores the presence of .mli inside
>> >> >> subdirectory d/, producing both .cmi/.cmo when when compiling a.ml.
>> >> >
>> >> > The -I option specifies extra directories for compiled files only,
>> >> > so it's correct that the compiler ignores d/a.mli.
>> >>
>> >> After sending the first post I've realized that: ocamlc -c d/a.mli
>> >> was forgotten, but even after adding that to the script things do not
>> >> change, i.e. following compilation of a.ml with -I d where d contains
>> >> a.cmi still produces both a.cmo and a.cmi in the top-level directory.
>> >
>> > Indeed - but that's the correct documented behaviour, even if not
>> > necessarily the ideal. There are various things you can do:
>> >
>> > a) Delete ./a.cmi as part of your build procedure. This isn't ideal,
>> > though, because you lose the type-checking against d/a.cmi
>> > b) Have an empty ./a.mli but never compile it - the compiler will then
>> > unify ./a.cmo against d/a.cmi. This isn't ideal because having a
>> > source file which you don't expect to compile will confuse dependency
>> > generators and automatic build rules.
>> > c) Implement a new option in the compiler driver which suppresses the
>> > automatic generation of .cmi files (e.g. ocamlc -c -I d -no-cmi a.ml)
>> 
>> d) Make the compiler skip generation of .cmi if it sees one in the -I
>>    directories?
>
> Of course, there is a dirty option e) if you have a.mli and a.cmi in
> directory d as before:
>
> ocamlc -intf-suffix .ml -I d -c a.ml
>
> will use the .cmi in d and not generate one in the current directory...
>

It's hairier than that when you think about -o (i.e. outputs go to the
specific build directory instead of the source tree)

-- 
mailto:moosotc@gmail.com

  reply	other threads:[~2016-08-09 18:38 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-08 16:09 moosotc
2016-08-08 17:03 ` Gabriel Scherer
2016-08-08 17:12   ` Gerd Stolpmann
2016-08-08 17:16   ` moosotc
2016-08-08 18:30     ` David Allsopp
2016-08-08 18:57       ` moosotc
2016-08-08 19:39         ` David Allsopp
2016-08-08 19:59           ` moosotc
2016-08-08 22:54             ` David Allsopp
2016-08-09  8:45               ` SF Markus Elfring
2016-08-09 16:26                 ` David Allsopp
2016-08-09 17:55                   ` SF Markus Elfring
2016-08-09 10:56               ` moosotc
2016-08-09 11:43                 ` moosotc
2016-08-09 11:46                   ` moosotc
2016-08-09 18:08                     ` David Allsopp
2016-08-09 18:35                       ` moosotc
2016-08-09 18:59                         ` David Allsopp
2016-08-09 19:55                           ` moosotc
2016-08-10  8:20                             ` David Allsopp
2016-08-10 10:38                               ` moosotc
2016-08-09 18:33             ` David Allsopp
2016-08-09 18:38               ` moosotc [this message]
2016-08-09 19:02                 ` David Allsopp
2016-08-09  9:22           ` SF Markus Elfring
2016-08-09 16:32             ` David Allsopp
2016-08-09 18:10               ` SF Markus Elfring
2016-08-09 18:26                 ` David Allsopp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r39xbxec.fsf@gmail.com \
    --to=moosotc@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=dra-news@metastack.com \
    --cc=gabriel.scherer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).