Skip to content

Commit f3a1a84

Browse files
authored
Support opam new --with-vendored-deps configure option (#165)
1 parent 7a33ea8 commit f3a1a84

File tree

3 files changed

+32
-13
lines changed

3 files changed

+32
-13
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
unreleased
22
----------
33

4+
- Support opam new `--with-vendored-deps` configure option. (@MisterDA #165)
45
- Rework Windows images and update their dependencies:
56
+ Fix the origin of Install.cmd (avsm -> ocurrent);
67
+ Rename Windows.Cygwin.install_from_release to install_cygwin;

src-opam/opam.ml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,26 @@ let maybe_link_opam add_default_link prefix branch =
3333

3434
(* Build opam in a separate worktree from an already cloned opam *)
3535
let install_opam_from_source ?(add_default_link = true) ?(prefix = "/usr/local")
36-
?(enable_0install_solver = false) ~branch ~hash () =
36+
?(enable_0install_solver = false) ?(with_vendored_deps = false) ~branch
37+
~hash () =
3738
run
3839
"cd /tmp/opam-sources && cp -P -R -p . ../opam-build-%s && cd \
3940
../opam-build-%s && git checkout %s && ln -s ../opam/src_ext/archives \
4041
src_ext/archives && env PATH=\"/tmp/opam/bootstrap/ocaml/bin:$PATH\" \
41-
./configure --enable-cold-check%s && env \
42+
./configure --enable-cold-check%s%s && env \
4243
PATH=\"/tmp/opam/bootstrap/ocaml/bin:$PATH\" make lib-ext all && mkdir -p \
4344
%s/bin && cp /tmp/opam-build-%s/opam %s/bin/opam-%s && chmod a+x \
4445
%s/bin/opam-%s && rm -rf /tmp/opam-build-%s"
4546
branch branch hash
4647
(if enable_0install_solver then " --with-0install-solver" else "")
48+
(if with_vendored_deps then " --with-vendored-deps" else "")
4749
prefix branch prefix branch prefix branch branch
4850
@@ maybe_link_opam add_default_link prefix branch
4951

5052
(* Build opam in a separate worktree from an already cloned opam *)
5153
let install_opam_from_source_windows ?cyg ?prefix
52-
?(enable_0install_solver = false) ?(msvs = false) ~branch ~hash () =
54+
?(enable_0install_solver = false) ?(with_vendored_deps = false)
55+
?(msvs = false) ~branch ~hash () =
5356
(* Although opam's readme states it can autodetec the environment
5457
with MSVS, it doesn't always work. It's set explicitly here. *)
5558
let msvs_env =
@@ -65,11 +68,12 @@ let install_opam_from_source_windows ?cyg ?prefix
6568
(if msvs then msvs_env else "")
6669
(if msvs then ocaml_port else "")
6770
@@ Windows.Cygwin.run_sh ?cyg
68-
"cd /tmp/opam-build-%s && %s./configure --enable-cold-check %s%s%s && \
71+
"cd /tmp/opam-build-%s && %s./configure --enable-cold-check %s%s%s%s && \
6972
make && make install"
7073
branch
7174
(if msvs then msvs_env else "")
7275
(if msvs then "" else "--with-private-runtime")
76+
(if with_vendored_deps then "" else "--with-vendored_deps")
7377
(Option.fold prefix ~none:"" ~some:(fun prefix ->
7478
Printf.sprintf {| --prefix="%s"|} prefix))
7579
(if enable_0install_solver then " --with-0install-solver" else "")
@@ -203,6 +207,7 @@ type opam_branch = {
203207
branch : string;
204208
hash : string;
205209
enable_0install_solver : bool;
210+
with_vendored_deps : bool;
206211
public_name : string;
207212
aliases : string list;
208213
}
@@ -212,6 +217,7 @@ let opam_master_branch opam_master_hash =
212217
branch = "master";
213218
hash = opam_master_hash;
214219
enable_0install_solver = true;
220+
with_vendored_deps = true;
215221
public_name = "opam-dev";
216222
aliases = [ "opam-2.2" ];
217223
(* TODO: Remove/update when opam 2.2 is branched *)
@@ -225,6 +231,7 @@ let create_opam_branches opam_hashes =
225231
branch = "2.0";
226232
hash = opam_2_0_hash;
227233
enable_0install_solver = false;
234+
with_vendored_deps = false;
228235
public_name = "opam-2.0";
229236
aliases = [ "opam" ];
230237
(* Default *)
@@ -233,6 +240,7 @@ let create_opam_branches opam_hashes =
233240
branch = "2.1";
234241
hash = opam_2_1_hash;
235242
enable_0install_solver = true;
243+
with_vendored_deps = false;
236244
public_name = "opam-2.1";
237245
aliases = [];
238246
};
@@ -250,10 +258,10 @@ let install_opams ?prefix opam_master_hash opam_branches =
250258
shell/bootstrap-ocaml.sh && make -C src_ext cache-archives"
251259
opam_master_hash
252260
@@ List.fold_left
253-
(fun acc { branch; hash; enable_0install_solver; _ } ->
261+
(fun acc { branch; hash; enable_0install_solver; with_vendored_deps; _ } ->
254262
acc
255263
@@ install_opam_from_source ~add_default_link:false ?prefix
256-
~enable_0install_solver ~branch ~hash ())
264+
~enable_0install_solver ~with_vendored_deps ~branch ~hash ())
257265
empty opam_branches
258266

259267
let install_opams_windows ?cyg ?prefix ?msvs opam_master_hash opam_branches =
@@ -263,10 +271,10 @@ let install_opams_windows ?cyg ?prefix ?msvs opam_master_hash opam_branches =
263271
cp -P -R -p . ../opam-sources && git checkout %s"
264272
opam_master_hash
265273
@@ List.fold_left
266-
(fun acc { branch; hash; enable_0install_solver; _ } ->
274+
(fun acc { branch; hash; enable_0install_solver; with_vendored_deps; _ } ->
267275
acc
268276
@@ install_opam_from_source_windows ?cyg ?prefix ?msvs
269-
~enable_0install_solver ~branch ~hash ())
277+
~enable_0install_solver ~with_vendored_deps ~branch ~hash ())
270278
empty opam_branches
271279

272280
let copy_opams ~src ~dst opam_branches =
@@ -717,15 +725,23 @@ let multiarch_manifest ~target ~platforms =
717725

718726
(* Clone and build opam from source (legacy function) *)
719727
let install_opam_from_source ?(add_default_link = true) ?(prefix = "/usr/local")
720-
?(enable_0install_solver = false) ~branch ~hash () =
728+
?(enable_0install_solver = false) ?(with_vendored_deps = false) ~branch
729+
~hash () =
730+
let configure_args =
731+
let args =
732+
if enable_0install_solver then "--with-0install-solver" else ""
733+
in
734+
let args =
735+
args ^ if with_vendored_deps then "--with-vendored-deps" else ""
736+
in
737+
if args <> "" then " CONFIGURE_ARGS=" ^ args else ""
738+
in
721739
run
722740
"git clone https://github.com/ocaml/opam /tmp/opam && cd /tmp/opam && git \
723741
checkout %s"
724742
hash
725743
@@ Linux.run_sh
726744
"cd /tmp/opam && make%s cold && mkdir -p %s/bin && cp /tmp/opam/opam \
727745
%s/bin/opam-%s && chmod a+x %s/bin/opam-%s && rm -rf /tmp/opam"
728-
(if enable_0install_solver then " CONFIGURE_ARGS=--with-0install-solver"
729-
else "")
730-
prefix prefix branch prefix branch
746+
configure_args prefix prefix branch prefix branch
731747
@@ maybe_link_opam add_default_link prefix branch

src-opam/opam.mli

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ val install_opam_from_source :
2525
?add_default_link:bool ->
2626
?prefix:string ->
2727
?enable_0install_solver:bool ->
28+
?with_vendored_deps:bool ->
2829
branch:string ->
2930
hash:string ->
3031
unit ->
@@ -38,7 +39,8 @@ val install_opam_from_source :
3839
binary is hardlinked to [opam]. Set it to false if you want to install
3940
multiple opam binaries from different branches in the same container.
4041
If [enable_0install_solver] is true (false by default), then the [builtin-0install]
41-
solver should be accessible in the resulting opam binary. *)
42+
solver should be accessible in the resulting opam binary.
43+
Configure opam build [with_vendored_deps]. Required for opam 2.2. *)
4244

4345
type opam_hashes = {
4446
opam_2_0_hash : string;

0 commit comments

Comments
 (0)