<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>A short answer: Look how cabal-docspec is implemented. It does do
what you want (i.e. finds all source files) to do its job too.<br>
<br>
A slightly longer version:<br>
- cabal-plan library parses plan.json, its types tell you what is
there [1]<br>
- plan doesn't include location of .cabal files directly, but it
has PkgLoc. From there you can find .cabal files<br>
- in cabal-docspec (and cabal-hie) for that matter, I simplify GPD
parts using flags information in plan.json to figure out exactly
which modules are in play<br>
- this part is too complicated, can probably be done simpler
with finalizePD [2]<br>
- cabal-docspec uses utilities in cabal-extras repository to
figure out GHC information for the previous step.<br>
<br>
It's not simple, you need to combine parts, but all pieces are
there.</p>
<p>- Oleg<br>
</p>
<p><br>
[1]:
<a class="moz-txt-link-freetext" href="https://hackage.haskell.org/package/cabal-plan-0.7.2.0/docs/Cabal-Plan.html">https://hackage.haskell.org/package/cabal-plan-0.7.2.0/docs/Cabal-Plan.html</a><br>
[2]:
<a class="moz-txt-link-freetext" href="https://hackage.haskell.org/package/Cabal-3.4.0.0/docs/Distribution-PackageDescription-Configuration.html#v:finalizePD">https://hackage.haskell.org/package/Cabal-3.4.0.0/docs/Distribution-PackageDescription-Configuration.html#v:finalizePD</a><br>
</p>
<div class="moz-cite-prefix">On 19.3.2021 22.20, Nicolas Frisby
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CADfHYo41nLaWfg65mpvRWnARZjvkH+5DSW9jk-9oYJqPuvdezw@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="auto">Hi all. Without show-build-info yet and without a
cabal-install library, a hobby project relies on parsing
plan.json to access eg the list of .cabal files and their flags
as configured during the most recent cabal-install invocation.
<div dir="auto"><br>
</div>
<div dir="auto">I haven't found much documentation about
plan.json. I'm particularly curious what are its current
semantics and intended use, and if these are intended to
remain stable going forward.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Some example specific questions:</div>
<div dir="auto"><br>
</div>
<div dir="auto"> * Would show-build-info supplant plan.json? If
so, would there be a deprecation delay?</div>
<div dir="auto"><br>
</div>
<div dir="auto"> * The docs say "A JSON serialization of the
computed install plan intended for integrating cabal with
external tooling." It seems likely that answering my questions
will involve explaining what an "install plan" is. (I'm
unfortunately unfamiliar with Cabal internals, and ReadTheDocs
search doesn't seem to support phrases as queries.)</div>
<div dir="auto"><br>
</div>
<div dir="auto"> * What determines which packages have entries
in the plan.json file after a particular cabal-install
invocation? Will it always include all local .cabal files?
(🤞)</div>
<div dir="auto"><br>
</div>
<div dir="auto"> * Is there enough information in the plan.json
file in order to map an entry there for source repository
package to the corresponding path under the builddir's `src`
directory? There seems to be some sort of hash involved in
that path and I haven't figured what its inputs are and
whether the plan.json file includes them all.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Thank you for your time. -Nick</div>
<div dir="auto"><br>
</div>
<div dir="auto">PS - My hobby project driving this question is
based on wanting to parse all local source files without
having to typecheck/build any of them (ideally nor their
non-local dependencies). I need each source file path and
corresponding language extensions etc in order to invoke the
parser. (hie-bios doesn't suffice because its solution to this
problem involves building dependencies, possibly including
local packages.)</div>
<div dir="auto"><br>
</div>
<div dir="auto">If you see a more direct path that doesn't
involve plan.json, please say so. Thanks again!</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
cabal-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cabal-devel@haskell.org">cabal-devel@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/cabal-devel">http://mail.haskell.org/cgi-bin/mailman/listinfo/cabal-devel</a>
</pre>
</blockquote>
</body>
</html>