Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

voodoo-prep: optimize the loop iterating over packages #121

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions src/voodoo-prep/prep.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ let process_package : Fpath.t -> Package.t -> Fpath.t list -> unit =
Util.write_file Fpath.(dest // set_ext "ocamlobjinfo" fpath) lines)
actions.objinfo

let write_opam_file package =
match Opam.opam_file package with
| Some lines ->
let dest = Package.prep_path package in
Util.write_file Fpath.(dest / "opam") lines
| None -> ()

let run (universes : (string * string) list) =
let get_universe =
match universes with
Expand All @@ -85,25 +92,12 @@ let run (universes : (string * string) list) =
with _ -> None)
in

let packages =
Opam.all_opam_packages ()
|> List.fold_left
(fun acc pkg ->
match get_universe pkg with Some pkg -> pkg :: acc | None -> acc)
[]
in
let root = Opam.prefix () |> Fpath.v in
let pkg_contents =
List.map (fun package -> (package, Opam.pkg_contents package)) packages
in
List.iter
(fun (package, files) -> process_package root package files)
pkg_contents;
List.iter
(fun package ->
match Opam.opam_file package with
| Some lines ->
let dest = Package.prep_path package in
Util.write_file Fpath.(dest / "opam") lines
| None -> ())
packages
Opam.all_opam_packages ()
|> List.iter (fun pkg ->
match get_universe pkg with
| Some package ->
let files = Opam.pkg_contents package in
process_package root package files;
write_opam_file package
| None -> ())
Loading