[opam-devel] glob patterns and variables in opam files

Louis Gesbert louis.gesbert at ocamlpro.com
Mon Jun 8 03:33:45 BST 2015


These are good remarks, there is room for improvement here.

> In my install command, I'd like to do something like "cp _build/*
> %{foo:lib}%". However, AFAICT there is no way to make opam interpret the
> glob pattern. For now, I'm putting the command in a shell script and having
> opam call that shell script. That's slightly roundabout, and I'm wondering
> if I can avoid it.

I'm quite wary of adding more interpretation to the handling of scripts, it's good to keep them as simple as possible, avoiding another layer or make-like tools. We could, however, provide a nicer way to provide shell interpretation, or running the script from a sub-directory though (the only way for that is `["sh "cd subdir/ && cmd"]`).

So currently, if you want to do it directly from the opam file, you're limited to:

    [ "sh" "-c" "cp _build/* %{foo:lib}%" ]

> Also in the above I'm using the package name "foo" explicitly. Is there any
> way to combine with %{name}%? I effectively want %{%{name}%:lib}%, but
> nested variables don't work.

Unqualified variables default to the current package (e.g. "name", "installed" are short for "foo:name", "foo:installed"), unless that clashes with a global variable. This is unfortunately the case for the "lib" variable; I'd be open to a better design (allow ":lib" ? "_:lib" ? Make it mandatory for all vars to avoid ambiguity ?)

I'm afraid you're stuck with 'foo:name' at the moment, but I agree it's not ideal.

Ideas to improve on these welcome!

Louis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.ocaml.org/pipermail/opam-devel/attachments/20150608/e796bc0a/attachment.sig>


More information about the opam-devel mailing list