From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 9D2367EE7C for ; Tue, 12 Apr 2016 17:33:54 +0200 (CEST) IronPort-PHdr: 9a23:7Is7PR1BoGl+6E+ZsmDT+DRfVm0co7zxezQtwd8ZsekWLPad9pjvdHbS+e9qxAeQG96Lu7QZ0qGG6ujJYi8p39WoiDg6aptCVhsI2409vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kO74TNaIBjjLw09fr2zQd6CyZnunLDrs7ToICx2xxOFKYtoKxu3qQiD/uI3uqBFbpgL9x3Sv3FTcP5Xz247bXianhL7+9vitMU7q3cYk7sb+sVBSaT3ebgjBfwdVWx+cjMD39DwrRTIUSeI43IdVC1WzksJUED560TTRZfwqSuyn+V0wjaTOYWiRL89Qyur6/46F0LAhyIONjp/+2bS3J9elqVe9T2orQZ+zoqcW4qVOeBzZOuJctoQX2tMWoBKXCxMGI6mR4QKBusFe+1fqt+u9BM1sRKiCFz0V6vUwThSiyqzgPQ3 Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=gabriel.scherer@gmail.com; spf=Pass smtp.mailfrom=gabriel.scherer@gmail.com; spf=None smtp.helo=postmaster@mail-ig0-f170.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.213.170; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.213.170 as permitted sender) identity=mailfrom; client-ip=209.85.213.170; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@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-ig0-f170.google.com) identity=helo; client-ip=209.85.213.170; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-ig0-f170.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BmAADDFA1Xi6rVVdFehAp9BqoFkFsBDYF0IYVsAoEsBzgUAQEBAQEBAQERAQEBCAsLCR8xgi2CFAEBAQMBEhEEGQEbEgsBAwELBgULDQICCR0CAiEBAREBBQEKEgYTEhCHcAEDCggOoV+BMT4xizaBaoJXh2gKGScDClGEPAEBAQEBAQEBAgEBAQEBAQETAQUKBW2FJYRLgkGBfIMCglYFhjEMkRoxgVSEI4YhgXWCNYxbh0uGHxEegQ4eAQGCOR6BbiAwigUBAQE X-IPAS-Result: A0BmAADDFA1Xi6rVVdFehAp9BqoFkFsBDYF0IYVsAoEsBzgUAQEBAQEBAQERAQEBCAsLCR8xgi2CFAEBAQMBEhEEGQEbEgsBAwELBgULDQICCR0CAiEBAREBBQEKEgYTEhCHcAEDCggOoV+BMT4xizaBaoJXh2gKGScDClGEPAEBAQEBAQEBAgEBAQEBAQETAQUKBW2FJYRLgkGBfIMCglYFhjEMkRoxgVSEI4YhgXWCNYxbh0uGHxEegQ4eAQGCOR6BbiAwigUBAQE X-IronPort-AV: E=Sophos;i="5.24,474,1454972400"; d="scan'208";a="173934746" Received: from mail-ig0-f170.google.com ([209.85.213.170]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 12 Apr 2016 17:33:53 +0200 Received: by mail-ig0-f170.google.com with SMTP id kb1so110693738igb.0 for ; Tue, 12 Apr 2016 08:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=tLSZlNWFvsfoWeBvEKU/T+C4f9On0+qCWT6JaqZTWVc=; b=MZ6KuCZhdAn/ie1gK2urAil1aAR35QE1Nm/qq55y/3KWRWFEWthFhaBJyEHuVmj/a6 EFUqEXtNQ6WHrCtDAC2a6KEMHMWVkc84nNfjtbdHMo0+HjCTj8G26eH2kSBFSRBXvo2o 5ZS4MqF42fdYVxJkqjRWOYI0f3vUnsgf5lqcOZr9lG+1Mp/Fejft1UZdUV4jNoyrTbKg Kl8Yoy3hY02NOntIMJJRWLai6Tlb41uwqI8pUNC4Q9T2BdeST+mWgu7sJHVoU6Vt8WI4 Of2iMKjn5hXepyRxj0Y82GfxnzXLRSdZr2/ZtWiPBJpAa42LAMl2ThuStzfDyGTsn2E9 AbDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=tLSZlNWFvsfoWeBvEKU/T+C4f9On0+qCWT6JaqZTWVc=; b=XL5xOok6TMQZLJSa9svuipddM/GK3OsCucHddTpAZDvQsVQi01ncVIc6iMM+cvPHXo o5cIobSV6nSvUqtlvUBuZGmDLn8p7xzI3kJBis7ZnYsHDGKUgIHkxZAWg6sCxxh4B4tx YaoM8CZzK+7ohm9y0dcVhKGb26mC6dRKpxhm9jr8W2zC5HQ8hB8jCHlR7O2TmDeS5tng IhfySasRUvxulRHsOx4UAv3Nn1pB84QZ5HVrelUD89yZ1DCdZRVtex71DI7INYMKs9gq oPxmZhvNqHPii8tL/MH9sU9GGu2L5GUPCi5w0Q3I0rXWbpSmOafZCiAJ5m2TqAwhZqW6 P0kA== X-Gm-Message-State: AD7BkJK1R2f4IB8RTuud7WscLFGQ+WBq+RFVApM4OLFe3PyGVk8LQEO6KQiJZieu2QOTWM4+AJdYzOywYPgtKg== X-Received: by 10.50.23.80 with SMTP id k16mr26383407igf.94.1460475231806; Tue, 12 Apr 2016 08:33:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.17.4 with HTTP; Tue, 12 Apr 2016 08:33:12 -0700 (PDT) In-Reply-To: References: <570CE35A.4090709@tu-berlin.de> <570CF14F.3080801@tu-berlin.de> From: Gabriel Scherer Date: Tue, 12 Apr 2016 11:33:12 -0400 Message-ID: To: Ashish Agarwal Cc: =?UTF-8?Q?Christoph_H=C3=B6ger?= , caml users Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] glob-ing dependencies for a custom ocamlbuild rule For the record, below is the code of a small plugin that will list files in %.modlib/*.mo in the source dir, import them all in the build directory, and also build a %.modlib.list file (in the build directory) containing the list of imported files. open Ocamlbuild_plugin let modlibc_command env build =3D let dir =3D env "%.modlib" in let dir_in_source =3D Pathname.concat Pathname.pwd dir in let files =3D (* filenames found in %.modlib/*.mo *) Pathname.readdir dir_in_source |> Array.to_list |> List.filter (fun path -> Pathname.check_extension path "mo") in let () =3D (* "build" all these files; imports them in the build directory *) List.map (fun file -> [Pathname.concat dir file]) files |> build |> List.iter Outcome.ignore_good in (* then populate %.modlib.list with the list of files we found *) Echo (List.map (fun s -> s ^ "\n") files, env "%.modlib.list") let _ =3D dispatch begin function | After_rules -> rule "modelica listing: %.modlib/ =3D> %.modlib.list" ~prods:["%.modlib.list"] ~doc:"list the files of a Modelica library" modlibc_command; | _ -> () end On Tue, Apr 12, 2016 at 9:15 AM, Ashish Agarwal wro= te: > On Tue, Apr 12, 2016 at 8:59 AM, Christoph H=C3=B6ger > wrote: > >> _all_ source files in > > > I think that is Gabriel's point. The definition of _all_ depends on when = you > think this pattern will be evaluated. > > >> It would be a major PITA to add all these files manually... > > > Not really. The nice thing about ocamlbuild is that you can write arbitra= ry > OCaml code, so just compute deps by traversing the directory yourself. > > > > >> Am 12.04.2016 um 14:48 schrieb Gabriel Scherer: >> > Ocamlbuild distinguishes "static dependencies", which are expressed in >> > the ~deps argument of the rule declaration, and "dynamic dependencies" >> > which are files required by the rule command. >> > >> > The notion of pattern accepted for static dependencies is indeed >> > rather rigid (less expressive than the patterns used in the _tags >> > file), and what you have in mind does not work. The supported patterns >> > are deterministic: given one file, there is a unique way a pattern can >> > match, and a pattern is instantiated into a single file by any >> > substitution environment. There is a good reason for that: it is not >> > clear what the semantics of your proposal would be. Indeed, ocamlbuild >> > tries to recursively build all static dependencies before deciding to >> > apply a rule, but what does it mean to build all **/*.mo? Listing the >> > one that exist in the source directory is easy, but how would you >> > guess which one to try to build recursively using other rules? >> > >> > Notions such as "all files matching P in this directory" are not >> > stable to the replacement of a source file by an intermediate target: >> > for example if tomorrow you decide that one of the .mo file will be >> > itself pre-processed from a .mo.pp file, it won't be seen by a >> > existing-file globbing technique anymore. You have a lot of >> > flexibility in the behaviors you implement in the build command, so >> > you can easily do the matching there and "build" those files, but it >> > will result in a relatively fragile rule; this is you decision to >> > make, and not in the path of least resistance. >> > >> > >> > On Tue, Apr 12, 2016 at 8:00 AM, Christoph H=C3=B6ger >> > wrote: >> >> Dear all, >> >> >> >> I want to write a custom ocamlbuild rule that basically combines all >> >> source files from a given (sub-)directory and thus depends on these >> >> files. >> >> >> >> However, the following does not work: >> >> >> >> rule "normalize (preprocess) a Modelica library" >> >> ~prods:["%.modlib.impl"; "%.modlib.sign"] >> >> ~deps:["%.modlib/**/*.mo"; "%.modlib.depends"] >> >> ~doc:"Preprocesses a Modelica library" >> >> modlibc_command >> >> >> >> It seems that the rule does not expand the pattern in the dependency. >> >> Is >> >> there a way to achieve something similar? It would be a major PITA to >> >> add all these files manually... >> >> >> >> regards, >> >> >> >> Christoph >> >> -- >> >> Christoph H=C3=B6ger >> >> >> >> Technische Universit=C3=A4t Berlin >> >> Fakult=C3=A4t IV - Elektrotechnik und Informatik >> >> =C3=9Cbersetzerbau und Programmiersprachen >> >> >> >> Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin >> >> >> >> Tel.: +49 (30) 314-24890 >> >> E-Mail: christoph.hoeger@tu-berlin.de >> >> >> >> -- >> >> 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 >> > >> >> >> -- >> Christoph H=C3=B6ger >> >> Technische Universit=C3=A4t Berlin >> Fakult=C3=A4t IV - Elektrotechnik und Informatik >> =C3=9Cbersetzerbau und Programmiersprachen >> >> Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin >> >> Tel.: +49 (30) 314-24890 >> E-Mail: christoph.hoeger@tu-berlin.de >> >> -- >> 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 > >