Closed hannesm closed 9 years ago
If you use topkg
along with topkg-ext
it has support to for having a %%VERSION%%
substituted in your source file for making a distribution. It will also correctly watermark if you pin the package.
For a simple example simply see uutf's pkg
, simply substitute appropriate values in config.ml
and change build.ml
to match what you need to install. The opam
instruction should then something along these lines. For pin
to work you need to make sure that you have a git
pin, and I'm not sure it works with the insane mixed-mode
pins as the git dir is not there iirc.
@dbuenzli thanks! this is great. but how do I access this version inside of my library?
Anywhere in your sources the sequence %%VERSION%%
gets replaced by the version.
thx. I found that. it works for a package with git://
in url in my repository, but it doesn't seem to work with local git pins. anyways, the case I wanted to cover is now covered... thanks a lot! :)
For local git pins you need a pin in non-mixed mode, in mixed-mode the .git
dir is not present in the build directory which means that you can't access the current git state.
For a local pin simply use something like opam pin add -kgit PKG dir#HEAD
or #branch
if you don't want opam to pickup whathever is checked out in your local repo.
otherwise I'm always confused which rev my running clients were using... (also, clean or dirty).. requires some build system hackery unfortunately