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 5CBEC7EE51 for ; Thu, 11 Apr 2013 15:00:39 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain.frisch@lexifi.com) identity=pra; client-ip=193.252.23.214; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="alain.frisch@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of alain.frisch@lexifi.com) identity=mailfrom; client-ip=193.252.23.214; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="alain.frisch@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@msa.smtpout.orange.fr) identity=helo; client-ip=193.252.23.214; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="postmaster@msa.smtpout.orange.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArcCAKGyZlHB/BfWlGdsb2JhbABQgzzBRwMBgRoOAQEBAQkLCQkUAyWCHwEBBTIBBUARCxgJFg8JAwIBAgFFBgEMCAEBiBQIvXWOI3qDQQOXAIEhhGKOGA X-IPAS-Result: ArcCAKGyZlHB/BfWlGdsb2JhbABQgzzBRwMBgRoOAQEBAQkLCQkUAyWCHwEBBTIBBUARCxgJFg8JAwIBAgFFBgEMCAEBiBQIvXWOI3qDQQOXAIEhhGKOGA X-IronPort-AV: E=Sophos;i="4.87,455,1363129200"; d="scan'208";a="12828406" Received: from msa05.smtpout.orange.fr (HELO msa.smtpout.orange.fr) ([193.252.23.214]) by mail2-smtp-roc.national.inria.fr with ESMTP; 11 Apr 2013 15:00:39 +0200 Received: from [192.168.1.109] ([86.195.22.55]) by mwinf5d45 with ME id Nd0e1l00A1BJsxy03d0evd; Thu, 11 Apr 2013 15:00:38 +0200 Message-ID: <5166B3F9.9040105@lexifi.com> Date: Thu, 11 Apr 2013 15:00:41 +0200 From: Alain Frisch Organization: LexiFi User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:20.0) Gecko/20100101 Thunderbird/20.0 MIME-Version: 1.0 To: =?ISO-8859-1?Q?=C9tienne_Andr=E9?= , caml-list@inria.fr References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Validation-by: alain.frisch@lexifi.com Subject: Re: [Caml-list] Build number and date in OCaml? On 04/09/2013 01:38 PM, Étienne André 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=markup 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=markup (To play with it, you need to checkout the extension_points branch and after compiling it: cd experimental/frisch && make eval) -- Alain