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

Rename sources into pins #11186

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion bin/lock_dev_tool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ let solve ~dev_tool ~local_packages =
@@ Lock.solve
(Workspace.add_repo workspace Dune_pkg.Pkg_workspace.Repository.binary_packages)
~local_packages
~project_sources:Dune_pkg.Pin_stanza.DB.empty
~project_pins:Dune_pkg.Pin_stanza.DB.empty
~solver_env_from_current_system
~version_preference:None
~lock_dirs:[ lock_dir ]
Expand Down
36 changes: 18 additions & 18 deletions bin/pkg/lock.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,39 +52,39 @@ module Progress_indicator = struct
let add_overlay (t : t) = Console.Status_line.add_overlay (Live (fun () -> pp t))
end

let resolve_project_sources sources =
let resolve_project_pins project_pins =
let scan_project ~read ~files =
let read file = Memo.of_reproducible_fiber (read file) in
let open Memo.O in
Dune_project.gen_load ~read ~files ~dir:Path.Source.root ~infer_from_opam_files:false
>>| Option.map ~f:(fun project ->
let sources = Dune_project.sources project in
let pins = Dune_project.pins project in
let packages = Dune_project.packages project in
sources, packages)
pins, packages)
|> Memo.run
in
Pin_stanza.resolve sources ~scan_project
Pin_stanza.resolve project_pins ~scan_project
;;

let solve_lock_dir
workspace
~local_packages
~project_sources
~project_pins
version_preference
solver_env_from_current_system
lock_dir_path
progress_state
=
let open Fiber.O in
let lock_dir = Workspace.find_lock_dir workspace lock_dir_path in
let project_sources =
let project_pins =
match lock_dir with
| None -> project_sources
| None -> project_pins
| Some lock_dir ->
let workspace =
Pin_stanza.DB.Workspace.extract workspace.sources ~names:lock_dir.pins
Pin_stanza.DB.Workspace.extract workspace.pins ~names:lock_dir.pins
in
Pin_stanza.DB.combine_exn workspace project_sources
Pin_stanza.DB.combine_exn workspace project_pins
in
let solver_env =
solver_env
Expand All @@ -104,7 +104,7 @@ let solve_lock_dir
:= Some (Progress_indicator.Per_lockdir.State.Updating_repos repo_names);
get_repos repo_map ~repositories:(repositories_of_lock_dir workspace ~lock_dir_path)
in
let* pins = resolve_project_sources project_sources in
let* pins = resolve_project_pins project_pins in
progress_state := Some Progress_indicator.Per_lockdir.State.Solving;
Dune_pkg.Opam_solver.solve_lock_dir
solver_env
Expand Down Expand Up @@ -141,7 +141,7 @@ let solve_lock_dir
let solve
workspace
~local_packages
~project_sources
~project_pins
~solver_env_from_current_system
~version_preference
~lock_dirs
Expand All @@ -165,7 +165,7 @@ let solve
solve_lock_dir
workspace
~local_packages
~project_sources
~project_pins
version_preference
solver_env_from_current_system
lockdir_path
Expand All @@ -191,11 +191,11 @@ let solve
List.iter write_disk_list ~f:Lock_dir.Write_disk.commit
;;

let project_sources =
let project_pins =
let open Memo.O in
Dune_rules.Dune_load.projects ()
>>| List.fold_left ~init:Pin_stanza.DB.empty ~f:(fun acc project ->
Pin_stanza.DB.combine_exn acc (Dune_project.sources project))
Pin_stanza.DB.combine_exn acc (Dune_project.pins project))
;;

let lock ~version_preference ~lock_dirs_arg =
Expand All @@ -204,22 +204,22 @@ let lock ~version_preference ~lock_dirs_arg =
Dune_pkg.Sys_poll.make ~path:(Env_path.path Stdune.Env.initial)
|> Dune_pkg.Sys_poll.solver_env_from_current_system
>>| Option.some
and* workspace, local_packages, project_sources =
and* workspace, local_packages, project_pins =
Memo.run
@@
let open Memo.O in
let+ workspace = Workspace.workspace ()
and+ local_packages = find_local_packages
and+ project_sources = project_sources in
workspace, local_packages, project_sources
and+ project_pins = project_pins in
workspace, local_packages, project_pins
in
let lock_dirs =
Pkg_common.Lock_dirs_arg.lock_dirs_of_workspace lock_dirs_arg workspace
in
solve
workspace
~local_packages
~project_sources
~project_pins
~solver_env_from_current_system
~version_preference
~lock_dirs
Expand Down
2 changes: 1 addition & 1 deletion bin/pkg/lock.mli
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ open Import
val solve
: Workspace.t
-> local_packages:Dune_pkg.Local_package.t Package_name.Map.t
-> project_sources:Dune_pkg.Pin_stanza.DB.t
-> project_pins:Dune_pkg.Pin_stanza.DB.t
-> solver_env_from_current_system:Dune_pkg.Solver_env.t option
-> version_preference:Dune_pkg.Version_preference.t option
-> lock_dirs:Path.Source.t list
Expand Down
18 changes: 9 additions & 9 deletions src/dune_rules/dune_project.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type t =
; subst_config : (Loc.t * Subst_config.t) option
; strict_package_deps : bool
; allow_approximate_merlin : Loc.t option
; sources : Dune_pkg.Pin_stanza.DB.t
; pins : Dune_pkg.Pin_stanza.DB.t
; cram : bool
; expand_aliases_in_sandbox : bool
; opam_file_location : [ `Relative_to_project | `Inside_opam_directory ]
Expand Down Expand Up @@ -70,7 +70,7 @@ let file_key t = t.file_key
let implicit_transitive_deps t = t.implicit_transitive_deps
let generate_opam_files t = t.generate_opam_files
let warnings t = t.warnings
let sources t = Dune_pkg.Pin_stanza.DB.add_opam_pins t.sources t.packages
let pins t = Dune_pkg.Pin_stanza.DB.add_opam_pins t.pins t.packages
let set_generate_opam_files generate_opam_files t = { t with generate_opam_files }
let use_standard_c_and_cxx_flags t = t.use_standard_c_and_cxx_flags
let dialects t = t.dialects
Expand Down Expand Up @@ -103,7 +103,7 @@ let to_dyn
; subst_config
; strict_package_deps
; allow_approximate_merlin
; sources = _
; pins = _
; cram
; expand_aliases_in_sandbox
; opam_file_location
Expand Down Expand Up @@ -427,7 +427,7 @@ let infer ~dir info packages =
let opam_file_location = opam_file_location_default ~lang in
{ name
; allow_approximate_merlin = None
; sources = Dune_pkg.Pin_stanza.DB.empty
; pins = Dune_pkg.Pin_stanza.DB.empty
; packages
; root
; info
Expand Down Expand Up @@ -463,7 +463,7 @@ let anonymous ~dir info packages = infer ~dir info packages
let encode : t -> Dune_lang.t list =
fun { name
; allow_approximate_merlin = _
; sources
; pins
; version
; dune_version
; info
Expand Down Expand Up @@ -575,7 +575,7 @@ let encode : t -> Dune_lang.t list =
let version =
Option.map ~f:(constr "version" Package_version.encode) version |> Option.to_list
in
let sources = Dune_pkg.Pin_stanza.DB.encode sources in
let pins = Dune_pkg.Pin_stanza.DB.encode pins in
List.concat
[ [ lang_stanza; name ]
; flags
Expand All @@ -585,7 +585,7 @@ let encode : t -> Dune_lang.t list =
; dialects
; packages
; subst_config
; sources
; pins
]
;;

Expand Down Expand Up @@ -771,7 +771,7 @@ let parse ~dir ~(lang : Lang.Instance.t) ~file =
and+ version = field_o "version" Package_version.decode
and+ info = Package_info.decode ()
and+ packages = multi_field "package" (Package.decode ~dir)
and+ sources = Dune_pkg.Pin_stanza.DB.decode ~dir
and+ pins = Dune_pkg.Pin_stanza.DB.decode ~dir
and+ explicit_extensions =
multi_field
"using"
Expand Down Expand Up @@ -951,7 +951,7 @@ let parse ~dir ~(lang : Lang.Instance.t) ~file =
; subst_config
; strict_package_deps
; allow_approximate_merlin
; sources
; pins
; cram
; expand_aliases_in_sandbox
; opam_file_location
Expand Down
2 changes: 1 addition & 1 deletion src/dune_rules/dune_project.mli
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ val strict_package_deps : t -> bool
val cram : t -> bool
val info : t -> Package_info.t
val warnings : t -> Warning.Settings.t
val sources : t -> Dune_pkg.Pin_stanza.DB.t
val pins : t -> Dune_pkg.Pin_stanza.DB.t

(** Update the execution parameters according to what is written in the
[dune-project] file. *)
Expand Down
20 changes: 10 additions & 10 deletions src/dune_rules/workspace.ml
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,10 @@ type t =
; repos : Dune_pkg.Pkg_workspace.Repository.t list
; lock_dirs : Lock_dir.t list
; dir : Path.Source.t
; sources : Dune_pkg.Pin_stanza.DB.Workspace.t
; pins : Dune_pkg.Pin_stanza.DB.Workspace.t
}

let to_dyn { merlin_context; contexts; env; config; repos; lock_dirs; sources; dir } =
let to_dyn { merlin_context; contexts; env; config; repos; lock_dirs; pins; dir } =
let open Dyn in
record
[ "merlin_context", option Context_name.to_dyn merlin_context
Expand All @@ -651,22 +651,22 @@ let to_dyn { merlin_context; contexts; env; config; repos; lock_dirs; sources; d
; "repos", list Repository.to_dyn repos
; "solver", (list Lock_dir.to_dyn) lock_dirs
; "dir", Path.Source.to_dyn dir
; "sources", Dune_pkg.Pin_stanza.DB.Workspace.to_dyn sources
; "pins", Dune_pkg.Pin_stanza.DB.Workspace.to_dyn pins
]
;;

let equal { merlin_context; contexts; env; config; repos; lock_dirs; dir; sources } w =
let equal { merlin_context; contexts; env; config; repos; lock_dirs; dir; pins } w =
Option.equal Context_name.equal merlin_context w.merlin_context
&& List.equal Context.equal contexts w.contexts
&& Option.equal Dune_env.equal env w.env
&& Dune_config.equal config w.config
&& List.equal Repository.equal repos w.repos
&& List.equal Lock_dir.equal lock_dirs w.lock_dirs
&& Path.Source.equal dir w.dir
&& Dune_pkg.Pin_stanza.DB.Workspace.equal sources w.sources
&& Dune_pkg.Pin_stanza.DB.Workspace.equal pins w.pins
;;

let hash { merlin_context; contexts; env; config; repos; lock_dirs; dir; sources } =
let hash { merlin_context; contexts; env; config; repos; lock_dirs; dir; pins } =
Poly.hash
( Option.hash Context_name.hash merlin_context
, List.hash Context.hash contexts
Expand All @@ -675,7 +675,7 @@ let hash { merlin_context; contexts; env; config; repos; lock_dirs; dir; sources
, List.hash Repository.hash repos
, List.hash Lock_dir.hash lock_dirs
, Path.Source.hash dir
, Dune_pkg.Pin_stanza.DB.Workspace.hash sources )
, Dune_pkg.Pin_stanza.DB.Workspace.hash pins )
;;

let find_lock_dir t path =
Expand Down Expand Up @@ -845,7 +845,7 @@ let step1 clflags =
~default:(lazy []))
and+ config_from_workspace_file = Dune_config.decode_fields_of_workspace_file
and+ lock_dirs = multi_field "lock_dir" (Lock_dir.decode ~dir)
and+ sources = Dune_pkg.Pin_stanza.DB.Workspace.decode in
and+ pins = Dune_pkg.Pin_stanza.DB.Workspace.decode in
let+ contexts = multi_field "context" (lazy_ Context.decode) in
let config =
create_final_config
Expand Down Expand Up @@ -918,7 +918,7 @@ let step1 clflags =
; repos
; lock_dirs
; dir
; sources
; pins
})
in
{ Step1.t; config }
Expand Down Expand Up @@ -951,7 +951,7 @@ let default clflags =
; repos = default_repositories
; lock_dirs = []
; dir = Path.Source.root
; sources = Dune_pkg.Pin_stanza.DB.Workspace.empty
; pins = Dune_pkg.Pin_stanza.DB.Workspace.empty
}
;;

Expand Down
2 changes: 1 addition & 1 deletion src/dune_rules/workspace.mli
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type t = private
; repos : Dune_pkg.Pkg_workspace.Repository.t list
; lock_dirs : Lock_dir.t list
; dir : Path.Source.t
; sources : Dune_pkg.Pin_stanza.DB.Workspace.t
; pins : Dune_pkg.Pin_stanza.DB.Workspace.t
}

val equal : t -> t -> bool
Expand Down
Loading