[mercury-users] Separate compilation for submodules.
Julien Fischer
juliensf at csse.unimelb.edu.au
Sun Jun 26 16:47:18 AEST 2011
Hi,
On Sat, 25 Jun 2011, Guillaume Yziquel wrote:
> I've been struggling a bit with submodules, and would appreciate if you
> could provide a small working example of how to do the following:
>
> I want a module A, and a submodule A.B. I would like to compile
> interfaces with mmc --make-int and mmc --make-short-int.
I don't recommend trying to use those options directly when trying to
build (parts of) multi-module programs. They exist mainly for the use
of mmake and mmc --make. Using them directly is likely to result in
inconsistencies amongst the generated files, e.g. because you forgot to
update rebuild the interface files when something changes.
> After that, I would like to compile them to C. I do not wish to use
> mmc --make.
Why not? It is the intended way of building multi-module Mercury programs.
(It can certainly do everything you want here.)
> I also want two separate files, a.m and a.b.m and I'd wish to use the
> :- include_module declaration.
>
> How can I do that cleanly? The module system is baffling me somewhat...
In file a.m:
:- module a.
:- interface.
:- include_module b.
:- type foo ---> foo.
:- end_module a.
In file a.b.m:
:- module a.b.
:- interface.
:- type bar ---> bar.
:- end_module b.
To build the C source files and interface files for the above modules
we have three choices:
(1) Do it manually (NOT RECOMMENDED)
(2) Use mmake
(3) Use mmc --make
For (1), we invoke the compiler as follows:
$ mmc --make-short-int a.m
$ mmc --make-short-int a.b.m.
$ mmc --make-priv-int a.m
$ mmc --make-int a.m
$ mmc --make-int a.b.m
$ mmc -C a.m
$ mmc -C a.b.m
For (2):
$ mmake a.depend
$ mmake a.int
$ mmake a.b.int
$ mmake a.c
$ mmake a.b.c
For (3):
$ mmc --make a.cs
$ mmc --make a.int
$ mmc --make a.b.int
mmc --make will place all generated intermediate files in a
subdirectory named "Mercury"; the C source files will be in the
subdirectory Mercury/cs and the interface files in the directory
Mercury/ints.
(The .cs target for mmc --make tells it to build all the C source files
required in order to build the program a.)
Julien.
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to: mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions: mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the users
mailing list