caml-list - the Caml user's mailing list
 help / Atom feed
* [Caml-list] How to use -map , -no-alias-deps and friends?
@ 2019-07-31 21:18 Ian Zimmerman
  2019-07-31 21:52 ` Nicolás Ojeda Bär
  2019-07-31 22:08 ` [Caml-list] How to use -map , -no-alias-deps and friends? Florian Angeletti
  0 siblings, 2 replies; 14+ messages in thread
From: Ian Zimmerman @ 2019-07-31 21:18 UTC (permalink / raw)
  To: Caml Mailinglist

I'm having hellish time with them.

I'm trying to build a simple library Aaa; let's assume bytecode only at
this point.  It should make available submodules like Aaa.Strutils,
Aaa.Listutils et cetera from other packages, yet when building the
library I want cross-module references look like Strutils , Listutils et
cetera.  This seems to be precisely the situation these knobs were meant
for; and yet I just cannot make it work.

It doesn't help that the two pieces of the manual explaining this,
namely sections 14.2 and 8.9, are in less than perfect alignment: 8.9
seems to suggest that the "map" file should be Aaa.ml (ie. an
implementation file), and that there should be no corresponding
interface file, but 14.2 shows -map mylib.mli passed to ocamldep.

Here's my latest attempt.  First, the Makefile:

#! /usr/bin/make -f

SHELL = /bin/sh
PATH != eval "`opam env`" ; echo "$${PATH}"
export PATH

OCAMLFLAGS = -no-alias-deps -w -49   # add other options for ocamlc here

# The list of object files for AAA
AAA_SUBMODULES != echo Aaa__*.ml
AAA_INTERFACES = $(AAA_SUBMODULES:.ml=.mli)

AAA_NATIVEOBJS != ./linkorder.sh native Aaa $(AAA_SUBMODULES) $(AAA_INTERFACES)
AAA_BYTEOBJS != ./linkorder.sh byte Aaa $(AAA_SUBMODULES) $(AAA_INTERFACES)

.PHONY: byte native

byte: Aaa.cma

native: Aaa.cmxa

Aaa.cma: $(AAA_BYTEOBJS) Aaa.cmo
		ocamlc -a -o Aaa.cma $(OCAMLFLAGS) $(AAA_BYTEOBJS) Aaa.cmo

Aaa.cmxa: $(AAA_NATIVEOBJS) Aaa.cmx
		ocamlopt -a -o Aaa.cmxa $(OCAMLFLAGS) $(AAA_NATIVEOBJS) Aaa.cmx

# Common rules
.SUFFIXES: .ml .mli .cmo .cmi .cmx

.ml.cmo:
		ocamlc $(OCAMLFLAGS) -open Aaa -c $<

.ml.cmx:
		ocamlopt $(OCAMLFLAGS) -open Aaa -c $<

Aaa.cmo: Aaa.ml
		ocamlc $(OCAMLFLAGS) -c Aaa.ml

Aaa.cmx: Aaa.ml
		ocamlopt $(OCAMLFLAGS) -c Aaa.ml

.mli.cmi:
		ocamlc $(OCAMLFLAGS) -open Aaa -c $<

# Dependencies
.depend: Makefile $(AAA_INTERFACES) $(AAA_SUBMODULES) Aaa.ml
		ocamldep -map Aaa.ml $(AAA_INTERFACES) $(AAA_SUBMODULES) -as-map Aaa.ml > .depend

include .depend

# Test suite
RunTests: Aaa.cma RunTests.ml
		ocamlfind ocamlc -package qcheck-core -package qcheck-core.runner -o RunTests -linkpkg Aaa.cma RunTests.ml

.PHONY: clean test

test: RunTests
		./RunTests

clean:
		rm -f *.cma *.cmxa *.cmo *.o *.cmx *.cmi .depend RunTests

# makefile ends here

Here's Aaa.ml:

module Colorspec = Aaa__Colorspec
module Exnutils = Aaa__Exnutils
module HashedString = Aaa__HashedString
module Ioutils = Aaa__Ioutils
module Listutils = Aaa__Listutils
module Resultx = Aaa__Resultx
module Sm = Aaa__Sm
module Strutils = Aaa__Strutils

... and in this iteration, there is no Aaa.mli.

This produces the following output:

 matica!91 aaa$ make
Fatal error: exception Failure("Aaa.mli : empty map file or parse error")
Fatal error: exception Failure("Aaa.mli : empty map file or parse error")
ocamldep -map Aaa.ml Aaa__Colorspec.mli Aaa__Exnutils.mli Aaa__HashedString.mli Aaa__Ioutils.mli Aaa__Listutils.mli Aaa__Resultx.mli Aaa__Sm.mli Aaa__Strutils.mli Aaa__Colorspec.ml Aaa__Exnutils.ml Aaa__HashedString.ml Aaa__Ioutils.ml Aaa__Listutils.ml Aaa__Resultx.ml Aaa__Sm.ml Aaa__Strutils.ml -as-map Aaa.ml > .depend
Fatal error: exception Failure("Aaa.mli : empty map file or parse error")
Fatal error: exception Failure("Aaa.mli : empty map file or parse error")
ocamlc -no-alias-deps -w -49    -c Aaa.ml
ocamlc -a -o Aaa.cma -no-alias-deps -w -49     Aaa.cmo
 matica!92 aaa$ ls
Aaa.cma		   Aaa__Colorspec.mli	  Aaa__Ioutils.ml     Aaa__Resultx.mli	 LICENSE	   install.sh
Aaa.cmi		   Aaa__Exnutils.ml	  Aaa__Ioutils.mli    Aaa__Sm.ml	 META		   linkorder.sh
Aaa.cmo		   Aaa__Exnutils.mli	  Aaa__Listutils.ml   Aaa__Sm.mli	 Makefile
Aaa.ml		   Aaa__HashedString.ml   Aaa__Listutils.mli  Aaa__Strutils.ml	 ORIGINAL_VERSION
Aaa__Colorspec.ml  Aaa__HashedString.mli  Aaa__Resultx.ml     Aaa__Strutils.mli  RunTests.ml

So, an archive file gets created, but obviously doesn't contain any real
code.

Virtual hugs for setting me on the right path.

-- 
Please don't Cc: me privately on mailing lists and Usenet,
if you also post the followup to the list or newsgroup.
To reply privately _only_ on Usenet and on broken lists
which rewrite From, fetch the TXT record for no-use.mooo.com.

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

end of thread, back to index

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-31 21:18 [Caml-list] How to use -map , -no-alias-deps and friends? Ian Zimmerman
2019-07-31 21:52 ` Nicolás Ojeda Bär
2019-08-06 18:48   ` Ian Zimmerman
2019-08-07 20:32     ` [Caml-list] opam and dune [Was: How to use -map] Ian Zimmerman
2019-08-08  1:39       ` Rudi Grinberg
2019-08-08 17:48         ` Hendrik Boom
2019-08-08 17:54           ` Rudi Grinberg
2019-08-08 19:38             ` Daniel Bünzli
2019-11-15  0:32         ` Ian Zimmerman
2019-08-08 18:05       ` Yawar Amin
2019-08-08 19:03         ` Josh Berdine
2019-07-31 22:08 ` [Caml-list] How to use -map , -no-alias-deps and friends? Florian Angeletti
2019-07-31 23:15   ` Ian Zimmerman
2019-08-01  9:40     ` Florian Angeletti

caml-list - the Caml user's mailing list

Archives are clonable: git clone --mirror https://inbox.ocaml.org/caml-list

AGPL code for this site: git clone https://public-inbox.org/ public-inbox