Monorepo management for opam overlays
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

monopam: lint attributes private stanzas to single-package subtrees

stanza_owner returns None for stanzas that have no public_name and no
explicit (package ...) — typically build-time generators in a [gen/]
subdir. Before this commit, dune_packages_by_owner skipped those
stanzas outright, so their (libraries ...) entries never showed up in
any package's required set and the lint silently passed.

Fall back: when a subtree contains exactly one opam package, attribute
private stanzas' libs to that package. [dune build -p <only-pkg>
@install] is what actually compiles these stanzas at install time, so
their library closure really is part of the package's install-time
closure. Multi-package subtrees still skip private stanzas (no obvious
single owner to attribute to).

The failing test from the previous commit now passes.

+17 -7
+17 -7
lib/lint.ml
··· 392 392 let cur = try Hashtbl.find tbl owner with Not_found -> String_set.empty in 393 393 Hashtbl.replace tbl owner (String_set.add pkg cur) 394 394 in 395 + let single_owner = 396 + match String_set.elements own_set with [ only ] -> Some only | _ -> None 397 + in 398 + let attribute owner fields = 399 + List.iter 400 + (fun lib -> if not (is_builtin lib) then add owner (resolve lib)) 401 + (libs_of_fields fields) 402 + in 395 403 List.iter 396 404 (function 397 405 | Sexp.List (Sexp.Atom kind :: fields) 398 406 when List.mem kind [ "library"; "executable"; "executables" ] -> ( 399 407 match stanza_owner fields with 400 - | None -> () 401 - | Some owner -> 402 - let owner = resolve_owner owner in 403 - List.iter 404 - (fun lib -> 405 - if not (is_builtin lib) then add owner (resolve lib)) 406 - (libs_of_fields fields)) 408 + | Some owner -> attribute (resolve_owner owner) fields 409 + | None -> 410 + (* Private stanza (no public_name, no (package ...)). When the 411 + subtree has exactly one opam package, attribute its lib 412 + refs there: [dune build -p <only-pkg> @install] is what 413 + actually compiles these sibling generators or build-time 414 + helpers, so their libs really are part of [only-pkg]'s 415 + install-time closure. *) 416 + Option.iter (fun owner -> attribute owner fields) single_owner) 407 417 | _ -> ()) 408 418 stanzas; 409 419 fun pkg -> try Hashtbl.find tbl pkg with Not_found -> String_set.empty