From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 09AE3BBAF for ; Tue, 23 Mar 2010 02:56:58 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkUDAMu8p0tQDPIufGdsb2JhbACbKhUBAQsJCgcTBR+9SoR9BIMe X-IronPort-AV: E=Sophos;i="4.51,291,1267398000"; d="scan'208";a="47312161" Received: from smtp21.orange.fr ([80.12.242.46]) by mail3-smtp-sop.national.inria.fr with ESMTP; 23 Mar 2010 02:56:57 +0100 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2106.orange.fr (SMTP Server) with ESMTP id 20B111C013AE; Tue, 23 Mar 2010 02:56:57 +0100 (CET) Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2106.orange.fr (SMTP Server) with ESMTP id 11ADE1C013CF; Tue, 23 Mar 2010 02:56:57 +0100 (CET) Received: from [192.168.1.102] (c-67-188-233-64.hsd1.ca.comcast.net [67.188.233.64]) by mwinf2106.orange.fr (SMTP Server) with ESMTP id 21C0F1C013AE; Tue, 23 Mar 2010 02:56:55 +0100 (CET) X-ME-UUID: 20100323015656138.21C0F1C013AE@mwinf2106.orange.fr X-ME-User-Auth: padator@wanadoo.fr Subject: Re: [Caml-list] Building multiple configurations? Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=us-ascii From: Yoann Padioleau In-Reply-To: <4BA81A46.1030004@grant-olson.net> Date: Mon, 22 Mar 2010 18:56:54 -0700 Cc: caml-list@inria.fr Content-Transfer-Encoding: quoted-printable Message-Id: <6A0948D6-EBA8-4EAD-9684-DD8CDEFE0A1C@wanadoo.fr> References: <4BA80CB5.4080402@grant-olson.net> <4BA81A46.1030004@grant-olson.net> To: kgo@grant-olson.net X-Mailer: Apple Mail (2.1077) X-Spam: no; 0.00; runtime:01 flags:01 blablabla:01 parser:01 ocaml:01 compile-time:01 runtime:01 syntax:01 ifdef:01 ifdef:01 dependencies:01 dependencies:01 config:01 config:01 wrote:01 On Mar 22, 2010, at 6:32 PM, Grant Olson wrote: >=20 > On 3/22/2010 9:13 PM, Yoann Padioleau wrote: >>>=20 >>> I've got a configuration file that's a .ml file. And I do want it = to be >>> an .ml file that gets included at compile time, not some .txt config >>> file that gets read in at runtime. I'm building two different = versions >>> of my app, with two different configurations. >>=20 >> Why ? Why ? Why not having your app configurable with a txt file >> or some command line flags like every other programs ? >>=20 >=20 > Because it's an elaborate configuration. =20 Apparently it's a boolean since you support only 2 different configs ... let config1 =3D { field1 =3D 1; field2 =3D true; } let config2 =3D { field1 =3D 2; field2 =3D true; } (* settable via command line or config file *) let config =3D ref true=20 let current_config () =3D=20 if !config then config1 else config2 ... let main =3D=20 let args =3D [ "-config1", Arg.Set config, ""; "-config2", Arg.Clear config ""; ] in Arg.parse ... blablabla > I don't want to write an > equally elaborate parser when I've already got ocaml to do that for = me. > I'd rather get a compile-time error than a runtime error if the syntax > is bad. And the app isn't designed to be user-configured. >=20 >>>=20 >>> Basically, I want to do the same thing as a C #ifdef: >>>=20 >>> #ifdef VERSION2 >>> ... include version one >>> #else >>> ... include version two >>> #endif >>=20 >> People use that because they want to do different things depending on = the architecture, or >> if some dependencies are present or not. Do you have the same = requirement here ? >>=20 >=20 > They also use it for things like debug/release build. But I suppose = you > could say that the two configurations have totally different > dependencies for these purposes. >=20 > I know what I'm doing is a little weird. But I have my reasons for > wanting to do it this way. >=20