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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 9039E7EE51 for ; Fri, 12 Apr 2013 16:39:07 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of danweil68@gmail.com) identity=pra; client-ip=74.125.82.182; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="danweil68@gmail.com"; x-sender="danweil68@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of danweil68@gmail.com designates 74.125.82.182 as permitted sender) identity=mailfrom; client-ip=74.125.82.182; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="danweil68@gmail.com"; x-sender="danweil68@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-we0-f182.google.com) identity=helo; client-ip=74.125.82.182; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="danweil68@gmail.com"; x-sender="postmaster@mail-we0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Am8KAP8baFFKfVK2k2dsb2JhbAA2GoM8iUOmBYNRhhIBiDUZaggWDgEBAQEHCwsJFAQkgh8BAQQBQAEbEgsBAwELBgULDQ0hIgERAQUBChIZCAqHbwEDCQYML55RjC+Ce4RUChknAwpZiH4BBQyPBwQHg0EDlwKBIYpWgzgWKYJUgVw6 X-IPAS-Result: Am8KAP8baFFKfVK2k2dsb2JhbAA2GoM8iUOmBYNRhhIBiDUZaggWDgEBAQEHCwsJFAQkgh8BAQQBQAEbEgsBAwELBgULDQ0hIgERAQUBChIZCAqHbwEDCQYML55RjC+Ce4RUChknAwpZiH4BBQyPBwQHg0EDlwKBIYpWgzgWKYJUgVw6 X-IronPort-AV: E=Sophos;i="4.87,462,1363129200"; d="scan'208";a="10763387" Received: from mail-we0-f182.google.com ([74.125.82.182]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 12 Apr 2013 16:39:06 +0200 Received: by mail-we0-f182.google.com with SMTP id k14so2111365wer.41 for ; Fri, 12 Apr 2013 07:39:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:cc:content-type; bh=hjzqTwmYZUm7t8IoHCmoI1bP1aOpE3PuqKQ+cXuVR9Y=; b=1Aj7k4R1aKJvDWy5RozNmxZLPSf2fBYKmVLV1NwRZjFddAPDK5CAgDvEO8GN5bezGU LBJqZo7XgL1ziw32HXsN31Z7K1z21iLejNxb0Ht5cyvHNkPxSmASTVcry/rpy6v70zGO cB0iaXtxRL0mK+9FTuyv9uCf0DWw0Mhdy7pwrhgQkvsV5CXFraJlOCQBXSX1NOu/av10 7XmXgBpY2Lz31473hoGg42FVBVtovBNwRDKqkuSa9LpHTLe5ailPNNXd+EmLKm0hqtpI oyVva3RtroUvKVxAP9kF4P/hNsp5tu+/I059gtwu+O0px8uxl2IeG2i5gztoSnBWsndW XdSw== X-Received: by 10.194.104.137 with SMTP id ge9mr12326564wjb.52.1365777546454; Fri, 12 Apr 2013 07:39:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.217.106.129 with HTTP; Fri, 12 Apr 2013 07:38:45 -0700 (PDT) In-Reply-To: <5166B3F9.9040105@lexifi.com> References: <5166B3F9.9040105@lexifi.com> From: Daniel Weil Date: Fri, 12 Apr 2013 16:38:45 +0200 Message-ID: Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=089e010d83887fb1b804da2add68 Subject: Re: [Caml-list] Build number and date in OCaml? --089e010d83887fb1b804da2add68 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable If you like ocambuild, an alternative is to add a small rule in your ocamlbuild plugin. The ocamlbuild wiki gives an example of ocamlbuild plugin that create a " version.ml" file in the _build directory at each build. You can then link your code with this version.ml file. http://brion.inria.fr/gallium/index.php/Automatic_Version_Generation Daniel 2013/4/11 Alain Frisch > On 04/09/2013 01:38 PM, =C9tienne Andr=E9 wrote: > >> I quite stupidly used the Unix.gettimeofday() function before realizing >> that it is of course executed at runtime. >> > > As others suggested, you can tell your build system to generate an ad hoc > file containing the compile-time information. Another approach is to use= a > preprocessor to inject such compile-time information into the source code > "on the fly" during its compilation. This can be done with a dedicated > Camlp4 syntax extension or a -ppx preprocessor (available in trunk only, > with syntactic extension points being designed in the extension_points > branch of the OCaml SVN). > > As an illustration of the -ppx approach, I've created a tiny preprocessor > which uses the OCaml toplevel to evaluate expressions and inserts the > result as constants in the compiled code. > > The source code for this -ppx preprocessor can be found here: > > http://caml.inria.fr/cgi-bin/**viewvc.cgi/ocaml/branches/** > extension_points/experimental/**frisch/eval.ml?&view=3Dmarkup > > and here is an example of what you can write with it: > > http://caml.inria.fr/cgi-bin/**viewvc.cgi/ocaml/branches/** > extension_points/experimental/**frisch/test_eval.ml?&view=3D**markup > > (To play with it, you need to checkout the extension_points branch and > after compiling it: cd experimental/frisch && make eval) > > -- Alain > > > -- > 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 > --089e010d83887fb1b804da2add68 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
If you like ocambuild, an alternative is to add= a small rule in your ocamlbuild plugin.=A0
The ocamlbuild = wiki gives an example of ocamlbuild plugin that create a "version.ml" file in the _build directory at each= build. You can then link your code with this version.ml file.=A0

http://brion.inria.fr/gallium/index.php/Automatic_Vers= ion_Generation

Daniel




2= 013/4/11 Alain Frisch <alain.frisch@lexifi.com>
On 04/09/2013 01:38 PM, =C9tienne Andr=E9 wrote:
I quite stupidly used the Unix.gettimeofday() function before realizing
that it is of course executed at runtime.

As others suggested, you can tell your build system to generate an ad hoc f= ile containing the compile-time information. =A0Another approach is to use = a preprocessor to inject such compile-time information into the source code= "on the fly" during its compilation. =A0This can be done with a = dedicated Camlp4 syntax extension or a -ppx preprocessor (available in trun= k only, with syntactic extension points being designed in the extension_poi= nts branch of the OCaml SVN).

As an illustration of the -ppx approach, I've created a tiny preprocess= or which uses the OCaml toplevel to evaluate expressions and inserts the re= sult as constants in the compiled code.

The source code for this -ppx preprocessor can be found here:

h= ttp://caml.inria.fr/cgi-bin/viewvc.cgi/ocaml/branches/extensi= on_points/experimental/frisch/eval.ml?&view=3Dmarkup

and here is an example of what you can write with it:

http://caml.inria.fr/cgi-bin/viewvc.cgi/ocaml/branches/ex= tension_points/experimental/frisch/test_eval.ml?&view=3Dm= arkup

(To play with it, you need to checkout the extension_points branch and afte= r compiling it: cd experimental/frisch && make eval)

-- Alain

--089e010d83887fb1b804da2add68--