My aggregated monorepo of OCaml code, automaintained
0
fork

Configure Feed

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

day10: write per-package findlib_index.json at p/<pkg>/<ver>/

Adds a stable, human-readable entry point for each target package.
The per-package findlib_index contains the same compiler info and
META paths as the universe-level index, but with paths rebased
relative to p/<pkg>/<ver>/. The target package's own META uses a
short content-hashed path; all other paths include full content
hashes for immutability.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+30 -2
+30 -2
day10/bin/jtw_gen.ml
··· 257 257 ) solutions; 258 258 259 259 (* Step 2: For each solution, assemble universe directories *) 260 - List.iter (fun (_target_pkg, solution, _ocaml_version, worker_output_dir) -> 260 + List.iter (fun (target_pkg, solution, _ocaml_version, worker_output_dir) -> 261 261 let ocaml_ver, compiler_hash = 262 262 Hashtbl.find compiler_info worker_output_dir 263 263 in ··· 369 369 ] in 370 370 let findlib_index = generate_findlib_index ~compiler:compiler_json sorted_metas in 371 371 Os.write_to_file Path.(u_dir / "findlib_index.json") findlib_index 372 - end 372 + end; 373 + 374 + (* Write per-package findlib_index for the target package. 375 + This provides a stable, human-readable entry point at 376 + p/<pkg>/<ver>/findlib_index.json. All paths are rebased from 377 + u/<hash>/ (2 levels deep) to p/<pkg>/<ver>/ (3 levels deep). *) 378 + let target_name = OpamPackage.name_to_string target_pkg in 379 + let target_version = OpamPackage.version_to_string target_pkg in 380 + let target_prefix = "../../p/" ^ target_name ^ "/" ^ target_version ^ "/" in 381 + let pkg_metas = List.map (fun meta_path -> 382 + if String.length meta_path > String.length target_prefix 383 + && String.sub meta_path 0 (String.length target_prefix) = target_prefix then 384 + (* Target package's own META — strip the ../../p/<pkg>/<ver>/ prefix, 385 + leaving just <content-hash>/lib/<name>/META *) 386 + String.sub meta_path (String.length target_prefix) 387 + (String.length meta_path - String.length target_prefix) 388 + else 389 + (* Other paths (deps at ../../p/... or stdlib at ../../compiler/...) — 390 + add one ../ since p/<pkg>/<ver>/ is one level deeper than u/<hash>/ *) 391 + "../" ^ meta_path 392 + ) sorted_metas in 393 + let compiler_json = `Assoc [ 394 + ("version", `String ocaml_ver); 395 + ("content_hash", `String compiler_hash); 396 + ] in 397 + let pkg_findlib = generate_findlib_index ~compiler:compiler_json pkg_metas in 398 + let pkg_index_dir = Path.(jtw_output / "p" / target_name / target_version) in 399 + Os.mkdir ~parents:true pkg_index_dir; 400 + Os.write_to_file Path.(pkg_index_dir / "findlib_index.json") pkg_findlib 373 401 ) solutions 374 402 375 403 (** Save jtw layer info to layer.json *)