From: Julien Signoles <julien.signoles@gmail.com>
To: "Étienne André" <Etienne.Andre@univ-paris13.fr>
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Build number and date in OCaml?
Date: Wed, 10 Apr 2013 10:49:23 +0200 [thread overview]
Message-ID: <CAPczgCCt_Tki79V5p1T0Z0cWXnfmFBZ5gTtghk-dH93X4iF++w@mail.gmail.com> (raw)
In-Reply-To: <CAB+Vvvgfrez6qedMwyj4_2fjPy+x_DyGzSOBXKQ4paLNEtk3mg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1180 bytes --]
Hello,
2013/4/9 Étienne André <Etienne.Andre@univ-paris13.fr>
> I've been using OCaml for a couple of years, but without using any
> advanced feature; so my question may be a little naive.
> Is there any way to insert easily the current date and time of compiling,
> as well as, e.g., an incremental build number in an OCaml program?
So that it is printed at runtime, e.g., in the program header.
>
This kind of information is part of your build process and are not directly
accessible in OCaml. If you want to access it in your OCaml program, you
have to pass them from the build environment to the program environment. As
Jeremie Dimino said, the usual way is to general a small OCaml file at
build time and to link it to your program.
For instance, if you use 'make', you could have the following lines in your
Makefile:
VERSION=...
config.ml: Makefile
echo "let version = \"$(VERSION)\"" > $@
echo "let compilation_date = \"`date`\" >> $@
CMO_FILES = config.cmo ... (* other cmo files)
Of course, it is better to add the corresponding config.mli by hand:
config.mli:
val version: string
val date: string
Hope this helps,
Julien
[-- Attachment #2: Type: text/html, Size: 1876 bytes --]
next prev parent reply other threads:[~2013-04-10 8:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-09 11:38 Étienne André
2013-04-09 12:18 ` Jeremie Dimino
2013-04-10 8:49 ` Julien Signoles [this message]
2013-04-10 9:08 ` David Allsopp
2013-04-11 13:00 ` Alain Frisch
2013-04-12 14:38 ` Daniel Weil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPczgCCt_Tki79V5p1T0Z0cWXnfmFBZ5gTtghk-dH93X4iF++w@mail.gmail.com \
--to=julien.signoles@gmail.com \
--cc=Etienne.Andre@univ-paris13.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox