caml-list - the Caml user's mailing list
 help / color / mirror / 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:07 ` [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

* Re: [Caml-list] How to use -map , -no-alias-deps and friends?
  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:47   ` Ian Zimmerman
  2019-07-31 22:07 ` [Caml-list] How to use -map , -no-alias-deps and friends? Florian Angeletti
  1 sibling, 1 reply; 14+ messages in thread
From: Nicolás Ojeda Bär @ 2019-07-31 21:52 UTC (permalink / raw)
  To: Ian Zimmerman; +Cc: Caml Mailinglist

Dear Ian,

The short answer is: "use dune". I don't think anyone actually
compiles with modules aliases by hand, it is tricky, and dune really
makes it a breeze.

If regardless of that you want to figure it out, I would suggest you
forget your Makefile and try to reduce the example to the absolute
minimum (say, a library with a single module) and figure out which
steps are necessary to compile by hand. As far as I remember, the
manual, while brief, is correct (ocamldep -map will accept both an .ml
or an .mli).

Best wishes,
--
Nicolás OJEDA BÄR
nicolas.ojeda.bar@lexifi.com
https://www.lexifi.com

On Wed, Jul 31, 2019 at 11:18 PM Ian Zimmerman <itz@very.loosely.org> wrote:
>
> 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

* Re: [Caml-list] How to use -map , -no-alias-deps and friends?
  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-07-31 22:07 ` Florian Angeletti
  2019-07-31 23:14   ` Ian Zimmerman
  1 sibling, 1 reply; 14+ messages in thread
From: Florian Angeletti @ 2019-07-31 22:07 UTC (permalink / raw)
  To: caml-list

Dear Ian,

As far as I can see your invocation of ocamldep in the .depend target is 
mostly fine. You may want to add `-open Aaa` too (another minor issue 
here is that `-as-map` is a global flag and does not take an argument) . 
The problem seems to come from your undisclosed linkorder script.

Note than another option to compute .depend and the link order is to use 
`codept` (available on opam) with the `-no-alias-deps` flag, which 
removes the need of declaring any map file by hand.

— octachron.

On 31/07/2019 23:18, Ian Zimmerman wrote:
> 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.
>


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

* Re: [Caml-list] How to use -map , -no-alias-deps and friends?
  2019-07-31 22:07 ` [Caml-list] How to use -map , -no-alias-deps and friends? Florian Angeletti
@ 2019-07-31 23:14   ` Ian Zimmerman
  2019-08-01  9:40     ` Florian Angeletti
  0 siblings, 1 reply; 14+ messages in thread
From: Ian Zimmerman @ 2019-07-31 23:14 UTC (permalink / raw)
  To: caml-list

On 2019-08-01 00:07, Florian Angeletti wrote:

> As far as I can see your invocation of ocamldep in the .depend target
> is mostly fine. You may want to add `-open Aaa` too (another minor
> issue here is that `-as-map` is a global flag and does not take an
> argument) . The problem seems to come from your undisclosed linkorder
> script.

As you probably suspect, linkorder.sh uses ocamldep too, taking only the
submodule names (ie. excluding Aaa.ml and Aaa.mli).

> Note than another option to compute .depend and the link order is to
> use `codept` (available on opam) with the `-no-alias-deps` flag, which
> removes the need of declaring any map file by hand.

That is very interesting, and probably the best option for this style of
aliasing.  Meanwhile I was able to quickly make it work with -pack ; do
I understand correctly that the only significant drawback is linking all
the submodules from any program requesting the library?

-- 
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

* Re: [Caml-list] How to use -map , -no-alias-deps and friends?
  2019-07-31 23:14   ` Ian Zimmerman
@ 2019-08-01  9:40     ` Florian Angeletti
  0 siblings, 0 replies; 14+ messages in thread
From: Florian Angeletti @ 2019-08-01  9:40 UTC (permalink / raw)
  To: caml-list

The drawbacks of packing are essentially the size of the packed module, 
and the coarser induced dependencies indeed.

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

* Re: [Caml-list] How to use -map , -no-alias-deps and friends?
  2019-07-31 21:52 ` Nicolás Ojeda Bär
@ 2019-08-06 18:47   ` Ian Zimmerman
  2019-08-07 20:32     ` [Caml-list] opam and dune [Was: How to use -map] Ian Zimmerman
  0 siblings, 1 reply; 14+ messages in thread
From: Ian Zimmerman @ 2019-08-06 18:47 UTC (permalink / raw)
  To: caml-list

On 2019-07-31 21:52, Nicolás Ojeda Bär wrote:

> The short answer is: "use dune". I don't think anyone actually
> compiles with modules aliases by hand, it is tricky, and dune really
> makes it a breeze.

I just looked at dune documentation to see if it has improved since last
time, and sadly no it hasn't.  There is still no one page that might say
"These are the files you must create, and this is what to put into
them."

So, for now, I'm sticking with Makefiles. :-P

-- 
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

* [Caml-list] opam and dune [Was: How to use -map]
  2019-08-06 18:47   ` Ian Zimmerman
@ 2019-08-07 20:32     ` Ian Zimmerman
  2019-08-08  1:38       ` Rudi Grinberg
  2019-08-08 18:05       ` Yawar Amin
  0 siblings, 2 replies; 14+ messages in thread
From: Ian Zimmerman @ 2019-08-07 20:32 UTC (permalink / raw)
  To: caml-list

On 2019-08-06 11:47, Ian Zimmerman wrote:

> So, for now, I'm sticking with Makefiles. :-P

I decided to give dune a try, mostly to give myself an excuse to
procrastinate with other projects.  After some rough going but being
able to figure it out, I hit what seems like an impassable strait.

dune generates the $package.opam file, therefore that file should not be
on version control.  _But_ then "opam pin ." insists on getting that
very file from the version control repo, instead of using the local one:

 matica!179 aaa$ opam pin .
[NOTE] Package aaa is already pinned to git+file:///home/itz/git/aaa#master (version 0.0.8~dev).
[aaa.0.0.8~dev] no changes from git+file:///home/itz/git/aaa#master
[WARNING] aaa's opam file has uncommitted changes, using the versioned one
aaa is now pinned to git+file:///home/itz/git/aaa#master (version 0.0.8~dev)
The following actions will be performed:
  - install aaa 0.0.8~dev*
Do you want to continue? [Y/n] y
[aaa.0.0.8~dev] synchronised from git+file:///home/itz/git/aaa#master

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The compilation of aaa failed at "/home/itz/.local/packages/opam/opam-init/hooks/sandbox.sh build dune
        subst".

#=== ERROR while compiling aaa.0.0.8~dev ======================================#
# context     2.0.4 | linux/x86_64 | ocaml-base-compiler.4.07.1 | pinned(git+file:///home/itz/git/aaa#master#193ad3bd)
# path        ~/.local/packages/opam/default/.opam-switch/build/aaa.0.0.8~dev
# command     ~/.local/packages/opam/opam-init/hooks/sandbox.sh build dune subst
# exit-code   1
# env-file    ~/.local/packages/opam/log/aaa-10257-b76d46.env
# output-file ~/.local/packages/opam/log/aaa-10257-b76d46.out
### output ###
# Error: No <package>.opam files found.



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build aaa 0.0.8~dev
+- 
- No changes have been performed

So how do you get around this?

-- 
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

* Re: [Caml-list] opam and dune [Was: How to use -map]
  2019-08-07 20:32     ` [Caml-list] opam and dune [Was: How to use -map] Ian Zimmerman
@ 2019-08-08  1:38       ` Rudi Grinberg
  2019-08-08 17:48         ` Hendrik Boom
  2019-11-15  0:32         ` Ian Zimmerman
  2019-08-08 18:05       ` Yawar Amin
  1 sibling, 2 replies; 14+ messages in thread
From: Rudi Grinberg @ 2019-08-08  1:38 UTC (permalink / raw)
  To: Ian Zimmerman; +Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 2692 bytes --]

For now the .opam file needs to be in version control. It's not ideal that
we need to check in generated files, so hopefully this problem will be
addressed in opam. If this truely bothers you, you can always disable the
opam file generation and write your opam file manually.

On Thu, Aug 8, 2019 at 3:33 AM Ian Zimmerman <itz@very.loosely.org> wrote:

> On 2019-08-06 11:47, Ian Zimmerman wrote:
>
> > So, for now, I'm sticking with Makefiles. :-P
>
> I decided to give dune a try, mostly to give myself an excuse to
> procrastinate with other projects.  After some rough going but being
> able to figure it out, I hit what seems like an impassable strait.
>
> dune generates the $package.opam file, therefore that file should not be
> on version control.  _But_ then "opam pin ." insists on getting that
> very file from the version control repo, instead of using the local one:
>
>  matica!179 aaa$ opam pin .
> [NOTE] Package aaa is already pinned to
> git+file:///home/itz/git/aaa#master (version 0.0.8~dev).
> [aaa.0.0.8~dev] no changes from git+file:///home/itz/git/aaa#master
> [WARNING] aaa's opam file has uncommitted changes, using the versioned one
> aaa is now pinned to git+file:///home/itz/git/aaa#master (version
> 0.0.8~dev)
> The following actions will be performed:
>   - install aaa 0.0.8~dev*
> Do you want to continue? [Y/n] y
> [aaa.0.0.8~dev] synchronised from git+file:///home/itz/git/aaa#master
>
> <><> Processing actions
> <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
> [ERROR] The compilation of aaa failed at
> "/home/itz/.local/packages/opam/opam-init/hooks/sandbox.sh build dune
>         subst".
>
> #=== ERROR while compiling aaa.0.0.8~dev
> ======================================#
> # context     2.0.4 | linux/x86_64 | ocaml-base-compiler.4.07.1 |
> pinned(git+file:///home/itz/git/aaa#master#193ad3bd)
> # path
> ~/.local/packages/opam/default/.opam-switch/build/aaa.0.0.8~dev
> # command     ~/.local/packages/opam/opam-init/hooks/sandbox.sh build dune
> subst
> # exit-code   1
> # env-file    ~/.local/packages/opam/log/aaa-10257-b76d46.env
> # output-file ~/.local/packages/opam/log/aaa-10257-b76d46.out
> ### output ###
> # Error: No <package>.opam files found.
>
>
>
> <><> Error report
> <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
> +- The following actions failed
> | - build aaa 0.0.8~dev
> +-
> - No changes have been performed
>
> So how do you get around this?
>
> --
> 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.
>

[-- Attachment #2: Type: text/html, Size: 3644 bytes --]

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

* Re: [Caml-list] opam and dune [Was: How to use -map]
  2019-08-08  1:38       ` Rudi Grinberg
@ 2019-08-08 17:48         ` Hendrik Boom
  2019-08-08 17:53           ` Rudi Grinberg
  2019-11-15  0:32         ` Ian Zimmerman
  1 sibling, 1 reply; 14+ messages in thread
From: Hendrik Boom @ 2019-08-08 17:48 UTC (permalink / raw)
  To: caml-list

On Thu, Aug 08, 2019 at 08:38:38AM +0700, Rudi Grinberg wrote:
> For now the .opam file needs to be in version control. It's not ideal that
> we need to check in generated files, so hopefully this problem will be
> addressed in opam. If this truely bothers you, you can always disable the
> opam file generation and write your opam file manually.

Is this a bootstrapping issue?  If so, having a generated file in 
version control is likely an inevitability. 

-- hendrik


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

* Re: [Caml-list] opam and dune [Was: How to use -map]
  2019-08-08 17:48         ` Hendrik Boom
@ 2019-08-08 17:53           ` Rudi Grinberg
  2019-08-08 19:38             ` Daniel Bünzli
  0 siblings, 1 reply; 14+ messages in thread
From: Rudi Grinberg @ 2019-08-08 17:53 UTC (permalink / raw)
  To: caml-list, Hendrik Boom

[-- Attachment #1: Type: text/plain, Size: 458 bytes --]

> Is this a bootstrapping issue? If so, having a generated file in
> version control is likely an inevitability.

The issue could be avoided if we could teach opam that some .opam files are generated. For example, opam could ask dune to build all .opam files with $ dune builld @opam. If we wanted something more build system agnostic, we could also just check-in a list of all package file names. Opam could then ask the $build-system to build all of them.

[-- Attachment #2: Type: text/html, Size: 775 bytes --]

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

* Re: [Caml-list] opam and dune [Was: How to use -map]
  2019-08-07 20:32     ` [Caml-list] opam and dune [Was: How to use -map] Ian Zimmerman
  2019-08-08  1:38       ` Rudi Grinberg
@ 2019-08-08 18:05       ` Yawar Amin
  2019-08-08 19:03         ` Josh Berdine
  1 sibling, 1 reply; 14+ messages in thread
From: Yawar Amin @ 2019-08-08 18:05 UTC (permalink / raw)
  To: Ian Zimmerman; +Cc: Ocaml Mailing List

[-- Attachment #1: Type: text/plain, Size: 2714 bytes --]

Checking in generated build system files is fairly common practice now.
Lots of build systems/package managers have 'lockfiles' that are generated
to help with reproducible builds. These need to be checked in. In fact I
think opam has two different ways of generating 'lockfiles'.

Regards,

Yawar

On Wed, Aug 7, 2019 at 4:32 PM Ian Zimmerman <itz@very.loosely.org> wrote:

> On 2019-08-06 11:47, Ian Zimmerman wrote:
>
> > So, for now, I'm sticking with Makefiles. :-P
>
> I decided to give dune a try, mostly to give myself an excuse to
> procrastinate with other projects.  After some rough going but being
> able to figure it out, I hit what seems like an impassable strait.
>
> dune generates the $package.opam file, therefore that file should not be
> on version control.  _But_ then "opam pin ." insists on getting that
> very file from the version control repo, instead of using the local one:
>
>  matica!179 aaa$ opam pin .
> [NOTE] Package aaa is already pinned to
> git+file:///home/itz/git/aaa#master (version 0.0.8~dev).
> [aaa.0.0.8~dev] no changes from git+file:///home/itz/git/aaa#master
> [WARNING] aaa's opam file has uncommitted changes, using the versioned one
> aaa is now pinned to git+file:///home/itz/git/aaa#master (version
> 0.0.8~dev)
> The following actions will be performed:
>   - install aaa 0.0.8~dev*
> Do you want to continue? [Y/n] y
> [aaa.0.0.8~dev] synchronised from git+file:///home/itz/git/aaa#master
>
> <><> Processing actions
> <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
> [ERROR] The compilation of aaa failed at
> "/home/itz/.local/packages/opam/opam-init/hooks/sandbox.sh build dune
>         subst".
>
> #=== ERROR while compiling aaa.0.0.8~dev
> ======================================#
> # context     2.0.4 | linux/x86_64 | ocaml-base-compiler.4.07.1 |
> pinned(git+file:///home/itz/git/aaa#master#193ad3bd)
> # path
> ~/.local/packages/opam/default/.opam-switch/build/aaa.0.0.8~dev
> # command     ~/.local/packages/opam/opam-init/hooks/sandbox.sh build dune
> subst
> # exit-code   1
> # env-file    ~/.local/packages/opam/log/aaa-10257-b76d46.env
> # output-file ~/.local/packages/opam/log/aaa-10257-b76d46.out
> ### output ###
> # Error: No <package>.opam files found.
>
>
>
> <><> Error report
> <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
> +- The following actions failed
> | - build aaa 0.0.8~dev
> +-
> - No changes have been performed
>
> So how do you get around this?
>
> --
> 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.
>

[-- Attachment #2: Type: text/html, Size: 3722 bytes --]

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

* Re: [Caml-list] opam and dune [Was: How to use -map]
  2019-08-08 18:05       ` Yawar Amin
@ 2019-08-08 19:03         ` Josh Berdine
  0 siblings, 0 replies; 14+ messages in thread
From: Josh Berdine @ 2019-08-08 19:03 UTC (permalink / raw)
  To: Ocaml Mailing List

[-- Attachment #1: Type: text/plain, Size: 3614 bytes --]

FWIW, there is a very similar stumbling block when working on a pinned 
package that has an opam file in the opam repo but not in the package's 
own source repo. In this case the problem does not have anything to do 
with whether the opam file is generated or not, and is independent of 
dune.

This situation arises if e.g. you `opam pin --dev` (or pin a local git 
clone of) such a package, and then make source changes that also require 
changes to the opam file. At that point, opam uses the opam file from 
the opam repo whether or not there is a local one (that is not in source 
control).

Perhaps this situation is too uncommon to warrant the time to address 
it, but I have hit it and don't know a satisfactory work-around.

Cheers, Josh

On 8 Aug 2019, at 19:05, Yawar Amin wrote:

> Checking in generated build system files is fairly common practice 
> now.
> Lots of build systems/package managers have 'lockfiles' that are 
> generated
> to help with reproducible builds. These need to be checked in. In fact 
> I
> think opam has two different ways of generating 'lockfiles'.
>
> Regards,
>
> Yawar
>
> On Wed, Aug 7, 2019 at 4:32 PM Ian Zimmerman <itz@very.loosely.org> 
> wrote:
>
>> On 2019-08-06 11:47, Ian Zimmerman wrote:
>>
>>> So, for now, I'm sticking with Makefiles. :-P
>>
>> I decided to give dune a try, mostly to give myself an excuse to
>> procrastinate with other projects.  After some rough going but being
>> able to figure it out, I hit what seems like an impassable strait.
>>
>> dune generates the $package.opam file, therefore that file should not 
>> be
>> on version control.  _But_ then "opam pin ." insists on getting that
>> very file from the version control repo, instead of using the local 
>> one:
>>
>>  matica!179 aaa$ opam pin .
>> [NOTE] Package aaa is already pinned to
>> git+file:///home/itz/git/aaa#master (version 0.0.8~dev).
>> [aaa.0.0.8~dev] no changes from git+file:///home/itz/git/aaa#master
>> [WARNING] aaa's opam file has uncommitted changes, using the 
>> versioned one
>> aaa is now pinned to git+file:///home/itz/git/aaa#master (version
>> 0.0.8~dev)
>> The following actions will be performed:
>>   - install aaa 0.0.8~dev*
>> Do you want to continue? [Y/n] y
>> [aaa.0.0.8~dev] synchronised from git+file:///home/itz/git/aaa#master
>>
>> <><> Processing actions
>> <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
>> [ERROR] The compilation of aaa failed at
>> "/home/itz/.local/packages/opam/opam-init/hooks/sandbox.sh build dune
>>         subst".
>>
>> #=== ERROR while compiling aaa.0.0.8~dev
>> ======================================#
>> # context     2.0.4 | linux/x86_64 | ocaml-base-compiler.4.07.1 |
>> pinned(git+file:///home/itz/git/aaa#master#193ad3bd)
>> # path
>> ~/.local/packages/opam/default/.opam-switch/build/aaa.0.0.8~dev
>> # command     ~/.local/packages/opam/opam-init/hooks/sandbox.sh build 
>> dune
>> subst
>> # exit-code   1
>> # env-file    ~/.local/packages/opam/log/aaa-10257-b76d46.env
>> # output-file ~/.local/packages/opam/log/aaa-10257-b76d46.out
>> ### output ###
>> # Error: No <package>.opam files found.
>>
>>
>>
>> <><> Error report
>> <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
>> +- The following actions failed
>> | - build aaa 0.0.8~dev
>> +-
>> - No changes have been performed
>>
>> So how do you get around this?
>>
>> --
>> 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.
>>



[-- Attachment #2: Type: text/html, Size: 5124 bytes --]

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

* Re: [Caml-list] opam and dune [Was: How to use -map]
  2019-08-08 17:53           ` Rudi Grinberg
@ 2019-08-08 19:38             ` Daniel Bünzli
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel Bünzli @ 2019-08-08 19:38 UTC (permalink / raw)
  To: Hendrik Boom, Rudi Grinberg, caml-list

On 8 August 2019 at 19:53:53, Rudi Grinberg (rudi.grinberg@gmail.com) wrote:

> The issue could be avoided if we could teach opam that some .opam files are generated.  
> For example, opam could ask dune to build all .opam files with $ dune builld @opam. If we  
> wanted something more build system agnostic, we could also just check-in a list of all  
> package file names. Opam could then ask the $build-system to build all of them.

See https://github.com/ocaml/opam/issues/3797. 

Best, 

D



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

* Re: [Caml-list] opam and dune [Was: How to use -map]
  2019-08-08  1:38       ` Rudi Grinberg
  2019-08-08 17:48         ` Hendrik Boom
@ 2019-11-15  0:32         ` Ian Zimmerman
  1 sibling, 0 replies; 14+ messages in thread
From: Ian Zimmerman @ 2019-11-15  0:32 UTC (permalink / raw)
  To: caml-list

On 2019-08-08 08:38, Rudi Grinberg wrote:

> For now the .opam file needs to be in version control. It's not ideal that
> we need to check in generated files, so hopefully this problem will be
> addressed in opam. 

>! If this truely bothers you, you can always disable the opam file
>! generation and write your opam file manually.

How?  The manual doesn't say, as far as I can see.  In fact, it doesn't
say how to _enable_ it either, or that it is on by default.  The entire
subsection of the manual called "Generating opam files" consists of some
example syntax from a dune file.

This is why I have been resisting the dune wave: the doc too often loses
view of the forest.

-- 
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, other threads:[~2019-11-15  0:32 UTC | newest]

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:47   ` Ian Zimmerman
2019-08-07 20:32     ` [Caml-list] opam and dune [Was: How to use -map] Ian Zimmerman
2019-08-08  1:38       ` Rudi Grinberg
2019-08-08 17:48         ` Hendrik Boom
2019-08-08 17:53           ` 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:07 ` [Caml-list] How to use -map , -no-alias-deps and friends? Florian Angeletti
2019-07-31 23:14   ` Ian Zimmerman
2019-08-01  9:40     ` Florian Angeletti

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).