* [Caml-list] Conditional BuildDepends in OASIS
@ 2012-10-25 13:57 Dario Teixeira
2012-10-25 20:12 ` Anil Madhavapeddy
0 siblings, 1 reply; 8+ messages in thread
From: Dario Teixeira @ 2012-10-25 13:57 UTC (permalink / raw)
To: OCaml Mailing List; +Cc: pgocaml-general
Hi,
I'm in the process of oasifying PG'OCaml, and I've hit a snag.
By default PG'OCaml depends on ExtLib, but it's possible to
use Batteries instead. Below is a fragment of my (naïve) first
attempt at telling OASIS about this configuration option:
Flag "use_batteries"
Description: Use Batteries instead of ExtLib
Default: false
Library "pgocaml"
Path: src
Modules: PGOCaml
BuildTools: ocamlbuild, camlp4
BuildDepends: calendar
if flag(use_batteries)
BuildDepends+: batteries
ByteOpt+: -ppopt -DUSE_BATTERIES
NativeOpt+: -ppopt -DUSE_BATTERIES
else
BuildDepends+: extlib
The problem is that OASIS complains about BuildDepends being
placed inside a conditional. Is this an oversight, or are there good
reasons (and hopefully a standard workaround) for this limitation?
Thanks in advance!
Cheers,
Dario Teixeira
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Conditional BuildDepends in OASIS
2012-10-25 13:57 [Caml-list] Conditional BuildDepends in OASIS Dario Teixeira
@ 2012-10-25 20:12 ` Anil Madhavapeddy
2012-10-26 17:56 ` Dario Teixeira
0 siblings, 1 reply; 8+ messages in thread
From: Anil Madhavapeddy @ 2012-10-25 20:12 UTC (permalink / raw)
To: Dario Teixeira; +Cc: OCaml Mailing List, pgocaml-general
The Cohttp library generates sub-libraries which can be conditional
based on a flag (which has a portable functorised core, and then an
Async, Mirage or Lwt instance depending on what's available)
https://github.com/avsm/ocaml-cohttp/blob/master/_oasis
However, your use case seems a little different, as I presume the
external interface of pgocaml doesn't vary by your choice of Extlib
or Batteries?
Despite this, it might be easier just to define a "pgocaml.batteries"
and "pgocaml.extlib" and leave the choice with the user as to which
one they would like to select. You can make the dependency optional
at compile time so the package doesn't generated; e.g.
Library cohttp_lwt_unix
Build$: flag(lwt)
Install$: flag(lwt)
Path: lwt
Findlibname: lwt
FindlibParent: cohttp
BuildDepends: lwt.unix, uri, cohttp, lwt.ssl, lwt.syntax
Modules: Cohttp_lwt_unix, (etc...)
-anil
On 25 Oct 2012, at 06:57, Dario Teixeira <darioteixeira@yahoo.com> wrote:
> Hi,
>
> I'm in the process of oasifying PG'OCaml, and I've hit a snag.
> By default PG'OCaml depends on ExtLib, but it's possible to
> use Batteries instead. Below is a fragment of my (naïve) first
> attempt at telling OASIS about this configuration option:
>
>
> Flag "use_batteries"
> Description: Use Batteries instead of ExtLib
> Default: false
>
> Library "pgocaml"
> Path: src
> Modules: PGOCaml
> BuildTools: ocamlbuild, camlp4
> BuildDepends: calendar
> if flag(use_batteries)
> BuildDepends+: batteries
> ByteOpt+: -ppopt -DUSE_BATTERIES
> NativeOpt+: -ppopt -DUSE_BATTERIES
> else
> BuildDepends+: extlib
>
> The problem is that OASIS complains about BuildDepends being
>
> placed inside a conditional. Is this an oversight, or are there good
> reasons (and hopefully a standard workaround) for this limitation?
>
> Thanks in advance!
> Cheers,
> Dario Teixeira
>
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/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] Conditional BuildDepends in OASIS
2012-10-25 20:12 ` Anil Madhavapeddy
@ 2012-10-26 17:56 ` Dario Teixeira
2012-10-26 21:34 ` Anil Madhavapeddy
2012-10-30 22:57 ` [Caml-list] " Sylvain Le Gall
0 siblings, 2 replies; 8+ messages in thread
From: Dario Teixeira @ 2012-10-26 17:56 UTC (permalink / raw)
To: Anil Madhavapeddy; +Cc: OCaml Mailing List, pgocaml-general
Hi,
Thanks for the suggestions, Anil!
> However, your use case seems a little different, as I presume the
> external interface of pgocaml doesn't vary by your choice of Extlib
> or Batteries?
Indeed.
> Despite this, it might be easier just to define a "pgocaml.batteries"
> and "pgocaml.extlib" and leave the choice with the user as to which
> one they would like to select. You can make the dependency optional
> at compile time so the package doesn't generated; e.g.
>
> Library cohttp_lwt_unix
> Build$: flag(lwt)
> Install$: flag(lwt)
> Path: lwt
> Findlibname: lwt
> FindlibParent: cohttp
> BuildDepends: lwt.unix, uri, cohttp, lwt.ssl, lwt.syntax
> Modules: Cohttp_lwt_unix, (etc...)
That would be a satisfactory solution. I did run into a different problem, though.
I told OASIS that "pgocaml.batteries" and "pgocaml.extlib" should have "pgocaml"
as their findlib parent (fragment below). Unfortunately, OASIS complains that
library "pgocaml" does not exist. How would I tell OASIS that "pgocaml" is a
dummy library?
Flag "batteries"
Description: Use Batteries
Default: true
Library "pgocaml_batteries"
Build$: flag(batteries)
Install$: flag(batteries)
Path: src
Modules: PGOCaml
BuildDepends: calendar, batteries
ByteOpt+: -ppopt -DUSE_BATTERIES
NativeOpt+: -ppopt -DUSE_BATTERIES
FindlibParent: pgocaml
Findlibname: batteries
Thanks again for your attention!
Cheers,
Dario
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Conditional BuildDepends in OASIS
2012-10-26 17:56 ` Dario Teixeira
@ 2012-10-26 21:34 ` Anil Madhavapeddy
2012-10-30 22:57 ` [Caml-list] " Sylvain Le Gall
1 sibling, 0 replies; 8+ messages in thread
From: Anil Madhavapeddy @ 2012-10-26 21:34 UTC (permalink / raw)
To: Dario Teixeira; +Cc: OCaml Mailing List, pgocaml-general
On 26 Oct 2012, at 10:56, Dario Teixeira <darioteixeira@yahoo.com> wrote:
>
> That would be a satisfactory solution. I did run into a different problem, though.
> I told OASIS that "pgocaml.batteries" and "pgocaml.extlib" should have "pgocaml"
> as their findlib parent (fragment below). Unfortunately, OASIS complains that
> library "pgocaml" does not exist. How would I tell OASIS that "pgocaml" is a
> dummy library?
>
> Flag "batteries"
> Description: Use Batteries
> Default: true
>
> Library "pgocaml_batteries"
> Build$: flag(batteries)
> Install$: flag(batteries)
> Path: src
> Modules: PGOCaml
> BuildDepends: calendar, batteries
> ByteOpt+: -ppopt -DUSE_BATTERIES
> NativeOpt+: -ppopt -DUSE_BATTERIES
> FindlibParent: pgocaml
> Findlibname: batteries
You could just put a dummy library in place (which shouldn't be used by anything
since you don't have to mark a dependency of a findlib child on the parent
library, as far as I understand it.
However, is there a common subset of your code that is portable without either
Batteries or Extlib? Factoring that out into a core library that both of the
other ones depend on would make future ports (e.g., to Core or Lwt) easier.
Of course, this is easier said than done when dealing with replacement standard
libraries which redefine very common library functions! It's a lot easier when
factoring over I/O libraries like Lwt vs Async where a straightforward functor
abstraction exists.
-anil
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Caml-list] Re: Conditional BuildDepends in OASIS
2012-10-26 17:56 ` Dario Teixeira
2012-10-26 21:34 ` Anil Madhavapeddy
@ 2012-10-30 22:57 ` Sylvain Le Gall
2012-11-01 15:18 ` Dario Teixeira
1 sibling, 1 reply; 8+ messages in thread
From: Sylvain Le Gall @ 2012-10-30 22:57 UTC (permalink / raw)
To: caml-list
On 26-10-2012, Dario Teixeira <darioteixeira@yahoo.com> wrote:
> Hi,
>
>
> Thanks for the suggestions, Anil!
>
>> However, your use case seems a little different, as I presume the
>> external interface of pgocaml doesn't vary by your choice of Extlib
>> or Batteries?
>
> Indeed.
>
>> Despite this, it might be easier just to define a "pgocaml.batteries"
>> and "pgocaml.extlib" and leave the choice with the user as to which
>> one they would like to select. You can make the dependency optional
>> at compile time so the package doesn't generated; e.g.
>>
>> Library cohttp_lwt_unix
>> Build$: flag(lwt)
>> Install$: flag(lwt)
>> Path: lwt
>> Findlibname: lwt
>> FindlibParent: cohttp
>> BuildDepends: lwt.unix, uri, cohttp, lwt.ssl, lwt.syntax
>> Modules: Cohttp_lwt_unix, (etc...)
>
> That would be a satisfactory solution. I did run into a different problem, though.
> I told OASIS that "pgocaml.batteries" and "pgocaml.extlib" should have "pgocaml"
> as their findlib parent (fragment below). Unfortunately, OASIS complains that
> library "pgocaml" does not exist. How would I tell OASIS that "pgocaml" is a
> dummy library?
>
> Flag "batteries"
> Description: Use Batteries
> Default: true
>
> Library "pgocaml_batteries"
> Build$: flag(batteries)
> Install$: flag(batteries)
> Path: src
> Modules: PGOCaml
> BuildDepends: calendar, batteries
> ByteOpt+: -ppopt -DUSE_BATTERIES
> NativeOpt+: -ppopt -DUSE_BATTERIES
> FindlibParent: pgocaml
> Findlibname: batteries
>
Having pgocaml.batteries and pgocaml.extlib is the best solution,
depending on a flag is perfect. Congrat to have find it yourself ;-)
(don't forget to CC me directly if you want a quicker response, I am a
little bit overloaded and don't spend much time reading caml-list).
Concerning FindlibParent that complains about non-existing pgocaml, you
should use FindlibContainers rather than FindlibParent.
E.g:
Library "pgocaml_batteries"
Build$: flag(batteries)
Install$: flag(batteries)
Path: src
Modules: PGOCaml
BuildDepends: calendar, batteries
ByteOpt+: -ppopt -DUSE_BATTERIES
NativeOpt+: -ppopt -DUSE_BATTERIES
FindlibContainers: pgocaml
Findlibname: batteries
Containers are virtual by default...
Although, this something I am not proud of and in the upcoming oasis 0.4.0 everything
will go to "FindlibName: pgocaml.batteries" and OASIS will sort
parent/containers/library itself.
Cheers,
Sylvain Le Gall
--
My company: http://www.ocamlcore.com
Linkedin: http://fr.linkedin.com/in/sylvainlegall
Start an OCaml project here: http://forge.ocamlcore.org
OCaml blogs: http://planet.ocamlcore.org
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Re: Conditional BuildDepends in OASIS
2012-10-30 22:57 ` [Caml-list] " Sylvain Le Gall
@ 2012-11-01 15:18 ` Dario Teixeira
2012-11-02 0:56 ` Anil Madhavapeddy
0 siblings, 1 reply; 8+ messages in thread
From: Dario Teixeira @ 2012-11-01 15:18 UTC (permalink / raw)
To: Sylvain Le Gall, caml-list
Hi,
> Having pgocaml.batteries and pgocaml.extlib is the best solution,
> depending on a flag is perfect. Congrat to have find it yourself ;-)
> (don't forget to CC me directly if you want a quicker response, I am a
> little bit overloaded and don't spend much time reading caml-list).
>
> Concerning FindlibParent that complains about non-existing pgocaml, you
> should use FindlibContainers rather than FindlibParent.
Thank you Sylvain and Anil for your suggestions!
Using FindlibContainers does solve the virtual package problem, but
in the meantime I've run into a perplexing issue involving Camlp4.
Here's the relevant fragment from the _oasis file:
BuildTools: ocamlbuild, camlp4o
Flag "batteries"
Description: Use Batteries
Default: true
Library "pgocaml_batteries"
Build$: flag(batteries)
Install$: flag(batteries)
Path: src
Modules: PGOCaml
BuildDepends: calendar, csv, pcre, batteries, camlp4.macro
FindlibContainers: pgocaml
Findlibname: batteries
ByteOpt+: -ppopt -DUSE_BATTERIES
NativeOpt+: -ppopt -DUSE_BATTERIES
Library "pa_pgocaml_batteries"
Build$: flag(batteries)
Install$: flag(batteries)
Path: src
Modules: Pa_pgsql
BuildDepends: pgocaml.batteries, camlp4.macro, camlp4.quotations.o, camlp4.extend
FindlibContainers: pgocaml.batteries
FindlibName: syntax
ByteOpt+: -ppopt -DUSE_BATTERIES
NativeOpt+: -ppopt -DUSE_BATTERIES
The problem occurs during the compilation of pa_pgocaml_batteries.
OCamlbuild issues the command below to determine dependencies,
which is manifestly wrong, since there is a "-syntax camlp4o" missing.
ocamlfind ocamldep -package pcre -package extlib -package csv -package camlp4.quotations.o -package camlp4.macro -package camlp4.extend -package calendar -package batteries -modules src/pa_pgsql.ml > src/pa_pgsql.ml.depends
What I find perplexing is that the compilation of pgocaml_batteries had succeeded,
so the required "-syntax camlp4o" must have had been given then, though at first
glance I can see no applicable difference in their declarations.
Any idea on what's going on?
Thanks again for your time!
Cheers,
Dario
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Re: Conditional BuildDepends in OASIS
2012-11-01 15:18 ` Dario Teixeira
@ 2012-11-02 0:56 ` Anil Madhavapeddy
2012-11-02 18:08 ` Dario Teixeira
0 siblings, 1 reply; 8+ messages in thread
From: Anil Madhavapeddy @ 2012-11-02 0:56 UTC (permalink / raw)
To: Dario Teixeira; +Cc: Sylvain Le Gall, caml-list
On 1 Nov 2012, at 15:18, Dario Teixeira <darioteixeira@yahoo.com> wrote:
>
> Library "pa_pgocaml_batteries"
> Build$: flag(batteries)
> Install$: flag(batteries)
> Path: src
> Modules: Pa_pgsql
> BuildDepends: pgocaml.batteries, camlp4.macro, camlp4.quotations.o, camlp4.extend
> FindlibContainers: pgocaml.batteries
> FindlibName: syntax
> ByteOpt+: -ppopt -DUSE_BATTERIES
> NativeOpt+: -ppopt -DUSE_BATTERIES
>
> The problem occurs during the compilation of pa_pgocaml_batteries.
> OCamlbuild issues the command below to determine dependencies,
> which is manifestly wrong, since there is a "-syntax camlp4o" missing.
>
> ocamlfind ocamldep -package pcre -package extlib -package csv -package camlp4.quotations.o -package camlp4.macro -package camlp4.extend -package calendar -package batteries -modules src/pa_pgsql.ml > src/pa_pgsql.ml.depends
>
> What I find perplexing is that the compilation of pgocaml_batteries had succeeded,
> so the required "-syntax camlp4o" must have had been given then, though at first
> glance I can see no applicable difference in their declarations.
>
It's probably your _tags file that is missing a:
<**/*.ml>: syntax_camlp4o
for the syntax extension. OASIS doesn't fully support using syntax extensions yet, so you need to be careful to keep the _tags file manually in sync.
-anil
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Caml-list] Re: Conditional BuildDepends in OASIS
2012-11-02 0:56 ` Anil Madhavapeddy
@ 2012-11-02 18:08 ` Dario Teixeira
0 siblings, 0 replies; 8+ messages in thread
From: Dario Teixeira @ 2012-11-02 18:08 UTC (permalink / raw)
To: Anil Madhavapeddy; +Cc: Sylvain Le Gall, caml-list
Hi,
> It's probably your _tags file that is missing a:
>
> <**/*.ml>: syntax_camlp4o
>
> for the syntax extension. OASIS doesn't fully support using syntax
> extensions yet, so you need to be careful to keep the _tags file manually in
> sync.
Thanks Anil, you were spot on -- the problem was indeed in the _tags file.
Anyway, most of the process of oasifying PG'OCaml is now complete,
and I took the time also for a general cleanup of the project. The code
can be fetched from the SVN repo:
svn export svn://scm.ocamlcore.org/svn/pgocaml/branches/oasification
As discussed previously, the project can be compiled against Batteries
and/or ExtLib. Users should reference findlib package's pgocaml.batteries
and pgocaml.batteries.syntax if using Batteries, for example.
It would be very helpful if PG'OCaml users and packagers were to give
me some feedback concerning the new version. Most stuff is working,
there being only a few minor outstanding issues:
- To build the documentation, "make doc" has to be issued twice!
- The highlevel test isn't compiling. For some reason OASIS is
ignoring the BuildDepends directive.
- OASIS issues a warning during setup. This seems to be a known
bug in OASIS, however:
https://forge.ocamlcore.org/tracker/index.php?func=detail&aid=1043&group_id=54&atid=291
Best regards,
Dario Teixeira
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-11-02 18:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-25 13:57 [Caml-list] Conditional BuildDepends in OASIS Dario Teixeira
2012-10-25 20:12 ` Anil Madhavapeddy
2012-10-26 17:56 ` Dario Teixeira
2012-10-26 21:34 ` Anil Madhavapeddy
2012-10-30 22:57 ` [Caml-list] " Sylvain Le Gall
2012-11-01 15:18 ` Dario Teixeira
2012-11-02 0:56 ` Anil Madhavapeddy
2012-11-02 18:08 ` Dario Teixeira
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox