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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 58B5D7ED7A for ; Wed, 12 Sep 2012 01:14:00 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=pra; client-ip=212.227.126.187; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of info@gerd-stolpmann.de) identity=mailfrom; client-ip=212.227.126.187; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="info@gerd-stolpmann.de"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of postmaster@moutng.kundenserver.de designates 212.227.126.187 as permitted sender) identity=helo; client-ip=212.227.126.187; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="info@gerd-stolpmann.de"; x-sender="postmaster@moutng.kundenserver.de"; x-conformance=sidf_compatible; x-record-type="v=spf1" X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: An0BAPDET1DU4367k2dsb2JhbABFqXiRYCIBAQEBCQkLCRQDJIIgAQEEATo0BgUFFg4KDUIbCRIGEwkJh2wDCQoHsksDColTFIoZY4YmA41Mhj6CaYoBh3A X-IronPort-AV: E=Sophos;i="4.80,407,1344204000"; d="scan'208";a="155404490" Received: from moutng.kundenserver.de ([212.227.126.187]) by mail4-smtp-sop.national.inria.fr with ESMTP; 12 Sep 2012 01:13:59 +0200 Received: from office1.lan.sumadev.de (dslb-094-219-216-191.pools.arcor-ip.net [94.219.216.191]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0Lr20J-1ToE7S2Psh-00eZFb; Wed, 12 Sep 2012 01:13:57 +0200 Received: from samsung (ip-176-199-33-11.unitymediagroup.de [176.199.33.11]) by office1.lan.sumadev.de (Postfix) with ESMTPSA id 33D8EC00D1; Wed, 12 Sep 2012 01:13:57 +0200 (CEST) Date: Wed, 12 Sep 2012 01:13:59 +0200 From: Gerd Stolpmann To: Hongbo Zhang Cc: caml users In-Reply-To: <504F9DFD.1010204@gmail.com> (from bobzhang1988@gmail.com on Tue Sep 11 22:24:29 2012) X-Mailer: Balsa 2.4.11 Message-Id: <1347405239.3496.12@samsung> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; DelSp=Yes; Format=Flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-Provags-ID: V02:K0:E6vTaIkKxTVvG2Cit79jdTekmaBWg29TNtWDxT7cpO8 +dxbCX7V9dxZFAXkxmIay1iGnjstflK2pTp2KeJp9ZnRKegVsS qRQ/NLD9PDS2N63TGT+dfTO2uCPQJ348N+nlRzbZCQbkWpYYzp b4lZB89dSZerI154SK8HZ5KGGAjQf26gynGsWY5SINwCE9toW3 +8qGM7e5ggGze5W+Cf7CAXoNpv0HdoZKqtwlAYoq51mxRbBucB RV4vDYnXncynrcAYG09En1qz9QB/mLnu/ZbKrFUuxylobBeFSF 0cXT6kFEWZdyRZrFg/+8whKNmlmGv/l0zM8jKw7qBmE0Msr88R qCOh6k6XtlqCkyMZJ5JlVKFFh8g+6z2rvX+EfxMyy Subject: [Caml-list] Re: working %.pp.ml target with ocamfind/ocamlbuild Am 11.09.2012 22:24:29 schrieb(en) Hongbo Zhang: > On 9/11/12 2:27 PM, Gerd Stolpmann wrote: >> Am 10.09.2012 14:18:42 schrieb(en) bob zhang: >>> Btw, there's something wrong with the rule "%.pp.ml", I don't=20=20 >>> remember >>> exactly where it's, for your interest, you can have a look at >>>=20 >>> https://bitbucket.org/HongboZhang/camlp4/src/e88f431db722/myocamlbuild.= ml >>>=20 >>> ocaml has a really really *high quality* compiler, but all the tools >>> around >>> it is not that satisfied, contribution is much harder than bug=20=20 >>> fixes :-( >>>=20 >>> If you take a look at ICFP 12's paper about Shake, the idea is >>> essentially >>> the same as 'ocamlbuild', and the idea is cool, but the=20=20 >>> implementation of >>> ocamlbuild is fragile and buggy. >>=20 >> And I wonder why ocamlbuild is actually used. There is a *high=20=20 >> quality* >> build tool for ocaml: omake > Well, IMHO, using a general purpose programming language with some=20=20 > combinators is *way more better* than a DSL, I used ocamlbuild to=20=20 > build a quite complex project: which includes bootstrapping,=20=20 > different preprocessing flags, nested directories, packing=20=20 > modules(byte code, native coce), (I even dynamically caculated the=20=20 > preprocess flags). Fully agreed - just FYI, your statement is also completely true for the=20= =20 omake DSL. As said, it is a functional language adapted to the special=20= =20 needs of build processes. The effects you mention are surprisingly=20=20 simple to get from omake. Just a few examples: - nested directories: A build project is always a tree. You add a subdirectory by listing it in .SUBDIRS. You can refer to files in other directories with relative path, or by $(rootname path), which turns it into a path relative to the project root. omake understands when different paths mean the same file. Dependencies work cross-directory, of course. - preprocessing flags: Here is a function that adds some flags for a certain top-level module: Camlp4o(module) =3D section OCAMLPACKS +=3D camlp4 OCAMLFINDFLAGS +=3D -syntax camlp4o $(module).cmi: $(module).cmo: $(module).o $(module).cmx: You call it as Camlp4o(my_module), and the effect is that the flags are added to the default ones. Easy, isn't it? (Unfortunately, this example is missing in the manual.) This is possible because omake has scoped dependencies. This is ultra-cool, and I haven't this seen anywhere else in a build tool yet. - Dynamically calculated flags: Well, variables can be lazily evaluated, so you can include function calls, e.g. OCAMLFLAGS =3D -pp -Dbuild_time=3D$`(gettimeofday) gettimeofday is here first called just before the compiler is invoked (because of the backtick, which makes it lazily called). Depending on when you want to calculate the flags, there are lots of=20=20 alternatives. An example: OCAMLFLAGS +=3D $(if $(multithreaded),-thread,) (when "multithreaded" is a boolean variable). - You can vmount directories over each other. This is very useful for bootstrapping somthing, e.g. if $(eq $(stage),1) vmount(-l,src,stage_1) if $(eq $(stage),2) vmount(-l,src,stage_2) The binary output of stage 1 is written to directory stage_1, and the output of stage 2 to stage_2. Both directories can have different build rules, so you can declare to build stage_2 with the tools from stage_1. The omake DSL is different from ocaml in the following points (apart=20=20 from supporting special syntax for describing dependencies, and a nice=20= =20 standard library): - It has dynamically scoped variables by default (i.e. closures take the bindings from where the function is called, not defined). This makes variables work more like normal arguments, and this is very useful here - build actions can be modified by the user in a context-dependent way. - It is dynamically typed (but supports strings, lists/arrays, maps,=20=20 objects, functions, and a number of other types). The dynamic typing is not=20=20 crucial here, though - it is more a matter of a simple implementation. - You can mix eager and lazy evaluation arbitrarily - The expression syntax can be directly embedded in shell commands Summarized, you can instruct omake with a few definitions to support=20=20 even complex builds. It's just a time saver. Gerd > The problem with ocamlbuild is its implementation, not the idea, the=20= =20 > idea is pretty good. >>=20 >>>=20 >>> On Mon, Sep 10, 2012 at 2:08 PM, Hongbo Zhang >>> wrote: >>>=20 >>> > Greetings, >>> > On 9/9/12 6:29 PM, Wojciech Meyer wrote: >>> > >>> >> Gabriel Scherer writes: >>> >> >>> >> This is useful for debugging purposes, and for some (minor)=20=20 >>> modes of >>> >>> use of Camlp4. However, for most Camlp4 development, this has=20=20 >>> the >>> >>> severe downside of losing the location information of the=20=20 >>> original >>> >>> file, if I understand correctly. This means that you don't want=20= =20 >>> to >>> use >>> >>> it as a transparent step towards compilation, but only in=20=20 >>> exceptional >>> >>> situations where the developers will re-edit the output code. >>> >>> >>> >> >>> >> I think I've to say I disagree it's not useful, when I'm=20=20 >>> developing a >>> >> syntax extension on top of Camlp4 I really want to see the=20=20 >>> generated >>> >> code. Moreover to understand some of the more complicated syntax >>> >> extensions like type_conv, deriving, FoldGenerator I need to look >>> at the >>> >> expanded code to understand how to use it - last time I hit the=20= =20 >>> same >>> >> >>> > Yes, it's damn useful not only for bootstrapping, but also for >>> developing >>> > to locate type errors. But there's something wrong with Camlp4's >>> printer, >>> > it has *4* printers in total, writing a printer for an Ast which=20= =20 >>> has no >>> > backend is totally useless. In my branch of camlp4, *I removed all >>> those 4 >>> > printers and using tools/pprintast.ml* in ocaml's compiler source >>> > tree(with some my own bug fixes), and it works very well. >>> > Btw, are you in ICFP? we could have a talk about Camlp4 :-) >>> > >>> >> problem it was actually 'deriving-ocsigen' when I needed to >>> implement my >>> >> own Show module - it's just much faster to see what's being=20=20 >>> generated >>> >> for the usual case, then trying to figure out from the recipe in=20= =20 >>> the >>> >> documentation. Otherwise for bootstrapping purposes, you might >>> want to >>> >> pre-generate some code too and put into the repository. >>> >> >>> >> -- >>> >> Wojciech Meyer >>> >> http://danmey.org >>> >> >>> >> >>> > >>>=20 >>>=20 >>> -- >>> Regards >>> -- Bob >>>=20 >>> -- >>> Caml-list mailing list. Subscription management and archives: >>> https://sympa-roc.inria.fr/wws/info/caml-list >>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners >>> Bug reports: http://caml.inria.fr/bin/caml-bugs >>>=20 >>>=20 >>=20 >=20 >=20 --=20 ------------------------------------------------------------ Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de Creator of GODI and camlcity.org. Contact details: http://www.camlcity.org/contact.html Company homepage: http://www.gerd-stolpmann.de ------------------------------------------------------------=