From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 61EDC7FCD8 for ; Sat, 17 Oct 2015 19:26:17 +0200 (CEST) IronPort-PHdr: 9a23:HI3ENh1ih4nwkg41smDT+DRfVm0co7zxezQtwd8ZsekWLPad9pjvdHbS+e9qxAeQG96Lt7QV0KGG7OjJYi8p39WoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kO74TNaIBjjLw09fr2zQd6OyZXsnLDts7ToICx2xxOFKYtoKxu3qQiD/uI3uqBFbpgL9x3Sv3FTcP5Xz247bXianhL7+9vitMU7q3cYk7sb+sVBSaT3ebgjBfwdVWx+cjMD39DwrRTIUSeI43IdVC1WzksJUED560TVV53rsyb+/tF22CSAMNe+Gb89Uy6j4qMtUxTohT0KLRY29WjWjop7i6cN8zy7oBkq6pXUYZqVfNNxd7nCdNdSEWNOV9xOXigYU9zhR4QKBusFe+1fqt+u9BM1sRKiCFz0V6vUwThSiyqzgPQ3 Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=agarwal1975@gmail.com; spf=Pass smtp.mailfrom=agarwal1975@gmail.com; spf=None smtp.helo=postmaster@mail-wi0-f177.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of agarwal1975@gmail.com) identity=pra; client-ip=209.85.212.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="agarwal1975@gmail.com"; x-sender="agarwal1975@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of agarwal1975@gmail.com designates 209.85.212.177 as permitted sender) identity=mailfrom; client-ip=209.85.212.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="agarwal1975@gmail.com"; x-sender="agarwal1975@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wi0-f177.google.com) identity=helo; client-ip=209.85.212.177; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="agarwal1975@gmail.com"; x-sender="postmaster@mail-wi0-f177.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DXAAByhCJWlLHUVdFehApvBqw4K5EbgVohgkODOgKBHQc5EwEBAQEBAQEBEAEBAQEHCwsJHzCCJoIHAQEBAwESEQQZARsSCwEDAQsGAwILDQ0dAgIhAQERAQUBChIGExIQh3gBAwoIDZJGj06BMT4xi0mBbIJ5iE4KGScDClaELQEBAQEBAQEDAQEBAQEBAQEVAQUOi2eCUIFaEQFNBAeCaYFFBYYFDIcBiQoHhRmCcIMfgXWBWEiSLgUGg1CCIxIjgRcREgGCQw4VB4FxIjSEJ4FAAQEB X-IPAS-Result: A0DXAAByhCJWlLHUVdFehApvBqw4K5EbgVohgkODOgKBHQc5EwEBAQEBAQEBEAEBAQEHCwsJHzCCJoIHAQEBAwESEQQZARsSCwEDAQsGAwILDQ0dAgIhAQERAQUBChIGExIQh3gBAwoIDZJGj06BMT4xi0mBbIJ5iE4KGScDClaELQEBAQEBAQEDAQEBAQEBAQEVAQUOi2eCUIFaEQFNBAeCaYFFBYYFDIcBiQoHhRmCcIMfgXWBWEiSLgUGg1CCIxIjgRcREgGCQw4VB4FxIjSEJ4FAAQEB X-IronPort-AV: E=Sophos;i="5.17,693,1437429600"; d="scan'208";a="183255470" Received: from mail-wi0-f177.google.com ([209.85.212.177]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 17 Oct 2015 19:26:14 +0200 Received: by wicll6 with SMTP id ll6so46250253wic.0 for ; Sat, 17 Oct 2015 10:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=UOm2asf9PCEiHmbiiqtP54D15knPTcNQsnJaEAxdZjE=; b=GiDct54BrOu9bXg4mjz4NwM0nphLdZ3gLoMLhCre0f3/RYK1Er9bqg6FzIuMTuB9+3 OlFoXwogiQO4UFk7L6I3K7fpWoCjSg54POZuLpsJOJak2JFq4y3yiBIM+tx0BN8/wDX4 sHr3W2dOkbYJ7whQyx7vzGb5fmMDfMB2gDhIsCRRKBs7QhZFmV/ybZ03f911nSuQoKM2 CE3Y3qUFV+neDDeIJuCVcrvILNeLb+g/FHbESvOn1+ro3VCVHn6/Y70KH4SmhnEJdZoj q7vTUpXNQvXUpKB4PGMgZo2qYp5nc8EqGSiVMoqOBEPoeWBAkS9pHgfU2dL79f0hSFRT M9Bw== X-Received: by 10.194.23.2 with SMTP id i2mr24320288wjf.106.1445102774061; Sat, 17 Oct 2015 10:26:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.27.32.201 with HTTP; Sat, 17 Oct 2015 10:25:54 -0700 (PDT) In-Reply-To: References: <6f77545c62146e8d504a5117716d7d1f@sybille.onecert.fr> <5621502C.60607@starynkevitch.net> From: Ashish Agarwal Date: Sat, 17 Oct 2015 13:25:54 -0400 Message-ID: To: Gabriel Scherer Cc: Basile Starynkevitch , David CHEMOUIL , caml users Content-Type: multipart/alternative; boundary=047d7b45116883124f052250358a Subject: Re: [Caml-list] releasing and publishing an OCaml program --047d7b45116883124f052250358a Content-Type: text/plain; charset=UTF-8 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 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 > 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: basilestarynkevitchnet 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 > --047d7b45116883124f052250358a Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I have this in my OMake files:

if = $(test -e .git)
=C2=A0 GIT_COMMIT =3D 'Some "$(shell git= rev-parse HEAD)"'
=C2=A0 export
else
=C2=A0 GIT_COMMIT =3D 'None'
=C2=A0 export
<= div>
I also define VERSION manually, but ideally I should ext= ract 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=3D$(VERSION) -D GIT_COMMIT=3D$(GIT_COMM= IT) about.ml.m4 > about.ml

$ cat about.ml.m4
(** General information about t= his project. *)

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

(**= Git commit if known: [GIT_COMMIT] *)
let git_commit =3D GIT_COMM= IT



On Sat, Oct 17, 2015 at 3:22 AM, Gabriel S= cherer <gabriel.scherer@gmail.com> wrote:
For reference, an ocamlbuild version would look lik= e this:

open Ocamlbuild_plugin

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

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 r= elease 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 dis= play 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 sim= ilar
> to the (untested) one below:
>
> ML_SOURCES=3D$(wildcard [a-z]*.ml)
> ML_INTERFACES=3D$(wildcard [a-z]*.mli)
> MD5SUM=3D md5sum
>
> _
= timestamp.ml:
>=C2=A0 =C2=A0 =C2=A0date +'let my_timestamp=3D"%c";;'= > _timestamp.tmp
>
>=C2=A0 =C2=A0 =C2=A0(echo -n 'let my_lastgitcommit =3D"' ;= \
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 git log --format=3Doneline --abbrev=3D12 --= abbrev-commit -q=C2=A0 \
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | head -1 | tr -d '\n\r\f\"= ' ; \
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 echo '";;') >> _timestam= p.tmp
>=C2=A0 =C2=A0 =C2=A0(echo -n 'let my_checksum =3D"'; cat $= (sort $(ML_SOURCES)) $(sort
> $(ML_INTERFACES))| $(MD5SUM) | cut -d' ' -f1 | tr -d '\n\r= \f\"\\' ; echo
> '";') >> _timestamp.tmp
>=C2=A0 =C2=A0 =C2=A0mv _timestamp.tmp _timestamp.ml
>
> Cheers
>
> --
> Basile STARYNKEVITCH=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0http://st= arynkevitch.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.=C2=A0 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.=C2=A0 Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocam= l_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--047d7b45116883124f052250358a--