Skip to content

Commit dbd8448

Browse files
authored
pkg: add binary package repo (ocaml#11020)
Adds a repo of binary packages to dune so that dev tools can be quickly installed without the need to download and compile their entire dependency cone on supported platforms. Currently ocamlfind and ocamllsp are included in the repo. Signed-off-by: Stephen Sherratt <[email protected]>
1 parent bd29b15 commit dbd8448

File tree

8 files changed

+24
-2
lines changed

8 files changed

+24
-2
lines changed

bin/lock_dev_tool.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ let solve ~dev_tool ~local_packages =
7878
let lock_dir = Lock_dir.dev_tool_lock_dir_path dev_tool in
7979
Memo.of_reproducible_fiber
8080
@@ Lock.solve
81-
workspace
81+
(Workspace.add_repo workspace Dune_pkg.Pkg_workspace.Repository.binary_packages)
8282
~local_packages
8383
~project_sources:Dune_pkg.Pin_stanza.DB.empty
8484
~solver_env_from_current_system

bin/pkg/pkg_common.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ let repositories_of_lock_dir workspace ~lock_dir_path =
6262
match Workspace.find_lock_dir workspace lock_dir_path with
6363
| Some lock_dir -> lock_dir.repositories
6464
| None ->
65-
List.map Workspace.default_repositories ~f:(fun repo ->
65+
List.map workspace.repos ~f:(fun repo ->
6666
let name = Dune_pkg.Pkg_workspace.Repository.name repo in
6767
let loc = Loc.none in
6868
loc, name)

src/dune_pkg/opam_repo.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ type t =
4747
; serializable : Serializable.t option
4848
}
4949

50+
let to_dyn { source; loc; serializable } =
51+
Dyn.record
52+
[ "source", Source_backend.to_dyn source
53+
; "loc", Loc.to_dyn loc
54+
; "serializable", Dyn.option Serializable.to_dyn serializable
55+
]
56+
;;
57+
5058
let equal { source; serializable; loc } t =
5159
Source_backend.equal source t.source
5260
&& Option.equal Serializable.equal serializable t.serializable

src/dune_pkg/opam_repo.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module Serializable : sig
1111
val to_dyn : t -> Dyn.t
1212
end
1313

14+
val to_dyn : t -> Dyn.t
1415
val equal : t -> t -> bool
1516

1617
(** [of_opam_repo_dir_path opam_repo_dir] creates a repo represented by a local

src/dune_pkg/workspace.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ module Repository = struct
5252
}
5353
;;
5454

55+
let binary_packages =
56+
{ name = "binary-packages"
57+
; source =
58+
( Loc.none
59+
, OpamUrl.of_string "git+https://github.com/ocaml-dune/ocaml-binary-packages.git"
60+
)
61+
}
62+
;;
63+
5564
let decode =
5665
let open Decoder in
5766
fields

src/dune_pkg/workspace.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module Repository : sig
99
val equal : t -> t -> bool
1010
val upstream : t
1111
val overlay : t
12+
val binary_packages : t
1213
val decode : t Decoder.t
1314

1415
module Name : sig

src/dune_rules/workspace.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,8 @@ let find_lock_dir t path =
682682
List.find t.lock_dirs ~f:(fun lock_dir -> Path.Source.equal lock_dir.path path)
683683
;;
684684

685+
let add_repo t repo = { t with repos = repo :: t.repos }
686+
685687
include Dune_lang.Versioned_file.Make (struct
686688
type t = unit
687689
end)

src/dune_rules/workspace.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ val equal : t -> t -> bool
124124
val to_dyn : t -> Dyn.t
125125
val hash : t -> int
126126
val find_lock_dir : t -> Path.Source.t -> Lock_dir.t option
127+
val add_repo : t -> Dune_pkg.Pkg_workspace.Repository.t -> t
127128
val default_repositories : Dune_pkg.Pkg_workspace.Repository.t list
128129

129130
module Clflags : sig

0 commit comments

Comments
 (0)