caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] releasing and publishing an OCaml program
@ 2015-10-16 18:24 David CHEMOUIL
  2015-10-16 19:29 ` Basile Starynkevitch
  0 siblings, 1 reply; 6+ messages in thread
From: David CHEMOUIL @ 2015-10-16 18:24 UTC (permalink / raw)
  To: caml-list

Hi,

I am looking for a self-contained, to the point, documentation or 
tutorial detailing steps, or even commands and scripts to run in order 
to release and publish an OCaml-programmed piece of software.

I guess it partly depends on one's way to develop and organize his or 
her code base. Still I also guess there are common steps followed by a 
fair amount of people.

As far as we are concerned for our project, we rely on OCaml code 
solely, plus Opam-installed tools (e.g. Menhir) and libraries; plus 
Oasis and Ocamlbuild. Our development is hosted on a Git repo.

So common tasks we'd like to automate are quite simple: adding the 
commit number and/or a build number in the OCaml source code (e.g. to 
display it when running the program), to display a git tag corresponding 
perhaps to a human-readable version number, publishing the progam on 
Opam, maybe even publishing a compiled version as a Debian package... As 
far as possible we'd like to avoid reinventing the wheel as well as 
duplicating information already present in a file (e.g. the _oasis file 
contains some data).

After some web searching, I was able to find real projects as examples 
as well as some partial (good) tutorials but it would be nice if there 
was a single documentation or bunch of scripts to address these rather 
common requirements.

Best

dc

-- 
David Chemouil // Onera/DTIM Toulouse // tel:+33-5-6225-2936
<http://www.onera.fr/staff/david-chemouil>


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

* Re: [Caml-list] releasing and publishing an OCaml program
  2015-10-16 18:24 [Caml-list] releasing and publishing an OCaml program David CHEMOUIL
@ 2015-10-16 19:29 ` Basile Starynkevitch
  2015-10-17  7:22   ` Gabriel Scherer
  0 siblings, 1 reply; 6+ messages in thread
From: Basile Starynkevitch @ 2015-10-16 19:29 UTC (permalink / raw)
  To: David CHEMOUIL, caml-list

On 10/16/2015 08:24 PM, David CHEMOUIL wrote:
> Hi,
>
> I am looking for a self-contained, to the point, documentation or 
> tutorial detailing steps, or even commands and scripts to run in order 
> to release and publish an OCaml-programmed piece of software.

>
> So common tasks we'd like to automate are quite simple: adding the 
> commit number and/or a build number in the OCaml source code (e.g. to 
> display it when running the program),

This is not specific to Ocaml. It is a matter of build process.

Assuming a Linux system, you might have some rule in your Makefile 
similar to the (untested) one below:

ML_SOURCES=$(wildcard [a-z]*.ml)
ML_INTERFACES=$(wildcard [a-z]*.mli)
MD5SUM= md5sum

_timestamp.ml:
     date +'let my_timestamp="%c";;' > _timestamp.tmp

     (echo -n 'let my_lastgitcommit ="' ; \
        git log --format=oneline --abbrev=12 --abbrev-commit -q  \
          | head -1 | tr -d '\n\r\f\"' ; \
        echo '";;') >> _timestamp.tmp
     (echo -n 'let my_checksum ="'; cat $(sort $(ML_SOURCES)) $(sort 
$(ML_INTERFACES))| $(MD5SUM) | cut -d' ' -f1 | tr -d '\n\r\f\"\\' ; echo 
'";') >> _timestamp.tmp
     mv _timestamp.tmp _timestamp.ml

Cheers

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***


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

* Re: [Caml-list] releasing and publishing an OCaml program
  2015-10-16 19:29 ` Basile Starynkevitch
@ 2015-10-17  7:22   ` Gabriel Scherer
  2015-10-17 17:25     ` Ashish Agarwal
  2015-10-17 19:42     ` ygrek
  0 siblings, 2 replies; 6+ messages in thread
From: Gabriel Scherer @ 2015-10-17  7:22 UTC (permalink / raw)
  To: Basile Starynkevitch; +Cc: David CHEMOUIL, caml users

For reference, an ocamlbuild version would look like this:

open Ocamlbuild_plugin

let () = dispatch (function
  | After_rules ->
     rule "version file"
          ~prod:"version.ml"
          ~doc:"generate a file with version information:
                Version.commit is the HEAD commit at the time of building,
                Version.tag is the name of the last git tag"
          (fun _env _build ->
           let trim = "tr -d '\r\n'" in
           let commit = run_and_read ("git rev-parse HEAD |" ^ trim) in
           let tag = run_and_read ("git describe --abbrev=0 --tags |" ^ trim) in
           let code = Printf.sprintf
                        "let commit = %S\n\
                         let tag = %S\n"
                        commit tag in
           Echo ([code], "version.ml");
          )
  | _ -> ()
);;

On Fri, Oct 16, 2015 at 9:29 PM, Basile Starynkevitch
<basile@starynkevitch.net> wrote:
> On 10/16/2015 08:24 PM, David CHEMOUIL wrote:
>>
>> Hi,
>>
>> I am looking for a self-contained, to the point, documentation or tutorial
>> detailing steps, or even commands and scripts to run in order to release and
>> publish an OCaml-programmed piece of software.
>
>
>>
>> So common tasks we'd like to automate are quite simple: adding the commit
>> number and/or a build number in the OCaml source code (e.g. to display it
>> when running the program),
>
>
> This is not specific to Ocaml. It is a matter of build process.
>
> Assuming a Linux system, you might have some rule in your Makefile similar
> to the (untested) one below:
>
> ML_SOURCES=$(wildcard [a-z]*.ml)
> ML_INTERFACES=$(wildcard [a-z]*.mli)
> MD5SUM= md5sum
>
> _timestamp.ml:
>     date +'let my_timestamp="%c";;' > _timestamp.tmp
>
>     (echo -n 'let my_lastgitcommit ="' ; \
>        git log --format=oneline --abbrev=12 --abbrev-commit -q  \
>          | head -1 | tr -d '\n\r\f\"' ; \
>        echo '";;') >> _timestamp.tmp
>     (echo -n 'let my_checksum ="'; cat $(sort $(ML_SOURCES)) $(sort
> $(ML_INTERFACES))| $(MD5SUM) | cut -d' ' -f1 | tr -d '\n\r\f\"\\' ; echo
> '";') >> _timestamp.tmp
>     mv _timestamp.tmp _timestamp.ml
>
> Cheers
>
> --
> Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
> email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
> 8, rue de la Faiencerie, 92340 Bourg La Reine, France
> *** opinions {are only mine, sont seulement les miennes} ***
>
>
>
> --
> 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] 6+ messages in thread

* Re: [Caml-list] releasing and publishing an OCaml program
  2015-10-17  7:22   ` Gabriel Scherer
@ 2015-10-17 17:25     ` Ashish Agarwal
  2015-10-17 19:42     ` ygrek
  1 sibling, 0 replies; 6+ messages in thread
From: Ashish Agarwal @ 2015-10-17 17:25 UTC (permalink / raw)
  To: Gabriel Scherer; +Cc: Basile Starynkevitch, David CHEMOUIL, caml users

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

I have this in my OMake files:

if $(test -e .git)
  GIT_COMMIT = 'Some "$(shell git rev-parse HEAD)"'
  export
else
  GIT_COMMIT = 'None'
  export

I also define VERSION manually, but ideally I should extract the version
from my opam file.

Given those, I use m4 as follows to generate an About module for most of my
projects.

m4 -D VERSION=$(VERSION) -D GIT_COMMIT=$(GIT_COMMIT) about.ml.m4 > about.ml

$ cat about.ml.m4
(** General information about this project. *)

(** Version: [VERSION] *)
let version = "VERSION"

(** Git commit if known: [GIT_COMMIT] *)
let git_commit = GIT_COMMIT



On Sat, Oct 17, 2015 at 3:22 AM, Gabriel Scherer <gabriel.scherer@gmail.com>
wrote:

> For reference, an ocamlbuild version would look like this:
>
> open Ocamlbuild_plugin
>
> let () = dispatch (function
>   | After_rules ->
>      rule "version file"
>           ~prod:"version.ml"
>           ~doc:"generate a file with version information:
>                 Version.commit is the HEAD commit at the time of building,
>                 Version.tag is the name of the last git tag"
>           (fun _env _build ->
>            let trim = "tr -d '\r\n'" in
>            let commit = run_and_read ("git rev-parse HEAD |" ^ trim) in
>            let tag = run_and_read ("git describe --abbrev=0 --tags |" ^
> trim) in
>            let code = Printf.sprintf
>                         "let commit = %S\n\
>                          let tag = %S\n"
>                         commit tag in
>            Echo ([code], "version.ml");
>           )
>   | _ -> ()
> );;
>
> On Fri, Oct 16, 2015 at 9:29 PM, Basile Starynkevitch
> <basile@starynkevitch.net> wrote:
> > On 10/16/2015 08:24 PM, David CHEMOUIL wrote:
> >>
> >> Hi,
> >>
> >> I am looking for a self-contained, to the point, documentation or
> tutorial
> >> detailing steps, or even commands and scripts to run in order to
> release and
> >> publish an OCaml-programmed piece of software.
> >
> >
> >>
> >> So common tasks we'd like to automate are quite simple: adding the
> commit
> >> number and/or a build number in the OCaml source code (e.g. to display
> it
> >> when running the program),
> >
> >
> > This is not specific to Ocaml. It is a matter of build process.
> >
> > Assuming a Linux system, you might have some rule in your Makefile
> similar
> > to the (untested) one below:
> >
> > ML_SOURCES=$(wildcard [a-z]*.ml)
> > ML_INTERFACES=$(wildcard [a-z]*.mli)
> > MD5SUM= md5sum
> >
> > _timestamp.ml:
> >     date +'let my_timestamp="%c";;' > _timestamp.tmp
> >
> >     (echo -n 'let my_lastgitcommit ="' ; \
> >        git log --format=oneline --abbrev=12 --abbrev-commit -q  \
> >          | head -1 | tr -d '\n\r\f\"' ; \
> >        echo '";;') >> _timestamp.tmp
> >     (echo -n 'let my_checksum ="'; cat $(sort $(ML_SOURCES)) $(sort
> > $(ML_INTERFACES))| $(MD5SUM) | cut -d' ' -f1 | tr -d '\n\r\f\"\\' ; echo
> > '";') >> _timestamp.tmp
> >     mv _timestamp.tmp _timestamp.ml
> >
> > Cheers
> >
> > --
> > Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
> > email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
> > 8, rue de la Faiencerie, 92340 Bourg La Reine, France
> > *** opinions {are only mine, sont seulement les miennes} ***
> >
> >
> >
> > --
> > 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
>
> --
> 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
>

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

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

* Re: [Caml-list] releasing and publishing an OCaml program
  2015-10-17  7:22   ` Gabriel Scherer
  2015-10-17 17:25     ` Ashish Agarwal
@ 2015-10-17 19:42     ` ygrek
  2015-10-19  8:50       ` Kenneth Adam Miller
  1 sibling, 1 reply; 6+ messages in thread
From: ygrek @ 2015-10-17 19:42 UTC (permalink / raw)
  To: caml-list

Hello,

 this seems to be a common theme this days, so I am using an ocamlbuild plugin
 to handle git version extraction - https://github.com/ygrek/mybuild

-- 
  

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

* Re: [Caml-list] releasing and publishing an OCaml program
  2015-10-17 19:42     ` ygrek
@ 2015-10-19  8:50       ` Kenneth Adam Miller
  0 siblings, 0 replies; 6+ messages in thread
From: Kenneth Adam Miller @ 2015-10-19  8:50 UTC (permalink / raw)
  To: caml users

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

Me personally, I think that the opam and oasis combination make a great
build and development ecosystem. If you want to deploy something after
you're happy having pinned and tested it enough, just make a merge request
to the github opam-repository; whatever works with pinning should work on
the repo, just make sure and write your installation script so that it
pulls from your github repo.

On Sat, Oct 17, 2015 at 3:42 PM, ygrek <ygrek@autistici.org> wrote:

> Hello,
>
>  this seems to be a common theme this days, so I am using an ocamlbuild
> plugin
>  to handle git version extraction - https://github.com/ygrek/mybuild
>
> --
>
>
> --
> 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
>

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

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

end of thread, other threads:[~2015-10-19  8:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-16 18:24 [Caml-list] releasing and publishing an OCaml program David CHEMOUIL
2015-10-16 19:29 ` Basile Starynkevitch
2015-10-17  7:22   ` Gabriel Scherer
2015-10-17 17:25     ` Ashish Agarwal
2015-10-17 19:42     ` ygrek
2015-10-19  8:50       ` Kenneth Adam Miller

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