Skip to content

Commit dd1f65c

Browse files
Merge branch 'main' into patch-1
2 parents cef64e9 + 3034248 commit dd1f65c

File tree

6 files changed

+110
-47
lines changed

6 files changed

+110
-47
lines changed

doc/faq.rst

+19-19
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ FAQ
88
99
Some of these are mini how-to guides, or sections of existing guides.
1010
11-
Why Do Many Dune Projects Contain a ``Makefile``?
11+
Why do many Dune projects contain a ``Makefile``?
1212
=================================================
1313

1414
Many Dune projects contain a root ``Makefile``. It's often only there for
@@ -23,31 +23,31 @@ convenience for the following reasons:
2323

2424
3. ``make`` is shorter to type than ``dune build @install``
2525

26-
How to Add a Configure Step to a Dune Project
27-
=============================================
26+
How to add a configure step to a Dune project?
27+
==============================================
2828

2929
The with-configure-step_ example shows one way to add a configure step that
3030
preserves composability; i.e., it doesn't require manually running the
3131
``./configure`` script when working on multiple projects simultaneously.
3232

3333
.. _with-configure-step: https://github.com/ocaml/dune/tree/master/example/with-configure-step.t
3434

35-
Can I Use ``topkg`` with Dune?
35+
Can I use ``topkg`` with Dune?
3636
==============================
3737

3838
While it's possible to use the topkg-jbuilder_, it's not recommended.
3939
dune-release_ subsumes ``topkg-jbuilder`` and is specifically tailored to Dune
4040
projects.
4141

4242

43-
How Do I Publish My Packages with Dune?
43+
How do I publish my packages with Dune?
4444
=======================================
4545

4646
Dune is just a build system and considers publishing outside of its scope.
4747
However, the dune-release_ project is specifically designed for releasing Dune
4848
projects to opam. We recommend using this tool for publishing Dune packages.
4949

50-
Where Can I Find Some Examples of Projects Using Dune?
50+
Where can I find some examples of projects using Dune?
5151
======================================================
5252

5353
The dune-universe_ repository contains a snapshot of the latest versions of all
@@ -68,8 +68,8 @@ Jane Street as well.
6868
.. _dune-release: https://github.com/samoht/dune-release
6969
.. _jenga: https://github.com/janestreet/jenga
7070

71-
How to Make Warnings Non-Fatal
72-
==============================
71+
How to make warnings non-fatal?
72+
===============================
7373

7474
`jbuilder` formerly displayed warnings, but most of them wouldn't stop the
7575
build. However, Dune makes all warnings fatal by default. This can be a
@@ -92,8 +92,8 @@ non-fatal:
9292
(dev
9393
(flags (:standard -warn-error -A))))
9494
95-
How to Turn Specific Errors into Warnings
96-
=========================================
95+
How to turn specific errors into warnings?
96+
==========================================
9797

9898
Dune is strict about warnings by default in that all warnings are treated as
9999
fatal errors. To change certain errors into warnings for a project, you can add
@@ -106,8 +106,8 @@ the following to ``dune-workspace``:
106106
In this example, the warnings 27 (unused-var-strict) and 32
107107
(unused-value-declaration) are treated as warnings rather than errors.
108108

109-
How to Display the Output of Commands as They Run
110-
=================================================
109+
How to display the output of commands as they run?
110+
==================================================
111111

112112
When Dune runs external commands, it redirects and saves their output, then
113113
displays it when complete. This ensures that there's no interleaving when
@@ -120,8 +120,8 @@ In that case, one can pass ``-j1 --no-buffer`` so the commands are directly
120120
printed on the console (and the parallelism is disabled so the output stays
121121
readable).
122122

123-
How Can I Generate an ``mli`` File From an ``ml`` File
124-
======================================================
123+
How can I generate an ``mli`` file from an ``ml`` file?
124+
=======================================================
125125

126126
When a module starts as just an implementation (``.ml`` file), it can be
127127
tedious to define the corresponding interface (``.mli`` file).
@@ -143,7 +143,7 @@ file:
143143
The ``ocaml-print-intf`` program has special support for Dune, so it will
144144
automatically understand external dependencies.
145145

146-
How Can I Build a Single Library?
146+
How can I build a single library?
147147
=================================
148148

149149
You might want to do this when you don't have all the dependencies installed to
@@ -171,8 +171,8 @@ directory - not the project root. If the library defines a ``name`` distinct fro
171171
its ``public_name`` then that can be used interchangeably with the ``public_name``
172172
in this command.
173173

174-
Files and Directories Whose Names Begin with "." (Period) are Ignored by ``source_tree``
175-
========================================================================================
174+
Why does ``source_tree`` ignore files and directories when they begin with a "." (period)?
175+
==========================================================================================
176176

177177
Dune's default behaviour is to ignore files and directories starting with "."
178178
when copying directories with ``source_tree``. This is to avoid accidentally
@@ -224,8 +224,8 @@ In this case you can update it to look like this:
224224
(dirs :standard .cargo \ target)
225225
(data_only_dirs vendor)
226226
227-
How Can I Write Inline Tests in a Package Without my Users Needing to Install ``ppx_inline_test``?
228-
==================================================================================================
227+
Why can't I write inline tests in a package without users needing to install ``ppx_inline_test``?
228+
=================================================================================================
229229

230230
If you came to OCaml from Rust and noticed that Dune has a feature for running
231231
inline tests you might be wondering how to do the OCaml equivalent of:

src/dune_lang/action.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ end
7070

7171
module Env_update = struct
7272
module Op = struct
73-
type t =
73+
type t = OpamParserTypes.env_update_op =
7474
| Eq
7575
| PlusEq
7676
| EqPlus

src/dune_lang/action.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ end
6666

6767
module Env_update : sig
6868
module Op : sig
69-
type t =
69+
type t = OpamParserTypes.env_update_op =
7070
| Eq
7171
| PlusEq
7272
| EqPlus

src/dune_pkg/opam_solver.ml

+14-22
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ module Solver = struct
360360
and real_impl =
361361
{ pkg : OpamPackage.t
362362
; conflict_class : OpamPackage.Name.t list
363-
; requires : dependency list
363+
; requires : dependency list Lazy.t
364364
}
365365

366366
and dependency =
@@ -454,7 +454,7 @@ module Solver = struct
454454
let requires _ = function
455455
| Dummy | Reject _ -> []
456456
| VirtualImpl (_, deps) -> deps
457-
| RealImpl impl -> impl.requires
457+
| RealImpl impl -> Lazy.force impl.requires
458458
;;
459459

460460
let conflict_class = function
@@ -565,15 +565,16 @@ module Solver = struct
565565
let pkg = OpamPackage.create role version in
566566
(* Note: we ignore depopts here: see opam/doc/design/depopts-and-features *)
567567
let requires =
568-
let rank = Rank.assign () in
569-
let make_deps importance xform get =
570-
get opam
571-
|> Context.filter_deps context pkg
572-
|> xform
573-
|> list_deps ~importance ~rank
574-
in
575-
make_deps Ensure ensure OpamFile.OPAM.depends
576-
@ make_deps Prevent prevent OpamFile.OPAM.conflicts
568+
lazy
569+
(let rank = Rank.assign () in
570+
let make_deps importance xform get =
571+
get opam
572+
|> Context.filter_deps context pkg
573+
|> xform
574+
|> list_deps ~importance ~rank
575+
in
576+
make_deps Ensure ensure OpamFile.OPAM.depends
577+
@ make_deps Prevent prevent OpamFile.OPAM.conflicts)
577578
in
578579
let conflict_class = OpamFile.OPAM.conflict_class opam in
579580
Some (RealImpl { pkg; requires; conflict_class }))
@@ -1536,17 +1537,8 @@ let opam_commands_to_actions
15361537
Some action))
15371538
;;
15381539

1539-
let opam_env_update_to_env_update ((var, env_op, value_string, _) : OpamTypes.env_update)
1540-
: String_with_vars.t Action.Env_update.t
1541-
=
1542-
{ Action.Env_update.op =
1543-
(match (env_op : OpamParserTypes.env_update_op) with
1544-
| Eq -> Eq
1545-
| PlusEq -> PlusEq
1546-
| EqPlus -> EqPlus
1547-
| ColonEq -> ColonEq
1548-
| EqColon -> EqColon
1549-
| EqPlusEq -> EqPlusEq)
1540+
let opam_env_update_to_env_update (var, env_op, value_string, _) : _ Action.Env_update.t =
1541+
{ Action.Env_update.op = env_op
15501542
; var
15511543
; value = String_with_vars.make_text Loc.none value_string
15521544
}

src/sat/sat.ml

+15-4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module VarID : sig
4242
val create : unit -> t
4343
val mem : t -> id -> bool
4444
val add : t -> id -> unit
45+
val clear : t -> unit
4546
end
4647
end = struct
4748
type t = int
@@ -153,6 +154,12 @@ module Make (User : USER) = struct
153154
}
154155

155156
let create () = { pos = VarID.Hash_set.create (); neg = VarID.Hash_set.create () }
157+
let temp = create ()
158+
159+
let clear () =
160+
VarID.Hash_set.clear temp.pos;
161+
VarID.Hash_set.clear temp.neg
162+
;;
156163

157164
let mem { pos; neg } (sign, lit) =
158165
match sign with
@@ -194,7 +201,8 @@ module Make (User : USER) = struct
194201
;;
195202

196203
let remove_duplicates lits =
197-
let seen = LitSet.create () in
204+
LitSet.clear ();
205+
let seen = LitSet.temp in
198206
let rec find_unique = function
199207
| [] -> []
200208
| x :: xs when LitSet.mem seen x -> find_unique xs
@@ -454,13 +462,13 @@ module Make (User : USER) = struct
454462
enqueue problem lits.(0) (Clause t))
455463
else (
456464
match lit_value lits.(i) with
465+
| False -> find_not_false (i + 1)
457466
| Undecided | True ->
458467
(* If it's True then we've already done our job,
459468
so this means we don't get notified unless we backtrack, which is fine. *)
460469
Array.swap lits 1 i;
461470
watch_lit (neg lits.(1)) t;
462-
true
463-
| False -> find_not_false (i + 1))
471+
true)
464472
in
465473
find_not_false 2)
466474
| At_most_one (current, problem, lits) ->
@@ -595,7 +603,10 @@ module Make (User : USER) = struct
595603
then (* Trivially true already if any literal is True. *)
596604
()
597605
else (
598-
let seen = LitSet.create () in
606+
let seen =
607+
LitSet.clear ();
608+
LitSet.temp
609+
in
599610
let rec simplify unique = function
600611
| [] -> Some unique
601612
| x :: _ when LitSet.mem seen (neg x) -> None (* X or not(X) is always True *)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Tests for promoting directory targets
2+
-------------------------------------
3+
4+
$ cat > dune-project << EOF
5+
> (lang dune 3.0)
6+
> (using directory-targets 0.1)
7+
> EOF
8+
9+
$ cat > dune << EOF
10+
> (rule
11+
> (deps
12+
> (source_tree deep))
13+
> (targets
14+
> (dir deep_copied))
15+
> (mode promote)
16+
> (action
17+
> (run cp -r deep deep_copied)))
18+
> EOF
19+
20+
Let's create the directory structure we are going to promote (as a copy on
21+
another dir):
22+
23+
$ mkdir -p deep/a/
24+
$ touch deep/a/deep_file
25+
$ touch deep/base_file
26+
27+
Let's try this:
28+
29+
$ dune build deep_copied
30+
31+
This one works. Now, let's add a layer between base_file and deep_file:
32+
33+
$ rm -rf deep
34+
$ mkdir -p deep/a/b/
35+
$ touch deep/a/b/deep_file
36+
$ touch deep/base_file
37+
38+
$ dune build deep_copied
39+
File "dune", lines 1-8, characters 0-123:
40+
1 | (rule
41+
2 | (deps
42+
3 | (source_tree deep))
43+
4 | (targets
44+
5 | (dir deep_copied))
45+
6 | (mode promote)
46+
7 | (action
47+
8 | (run cp -r deep deep_copied)))
48+
Error: Cannot promote files to "deep_copied/a/b".
49+
Reason: opendir(deep_copied/a/b): No such file or directory
50+
-> required by _build/default/deep_copied
51+
[1]
52+
53+
It does not work! Note that the `base_file` is required. For instance, move it
54+
to `a/`, or remove it, and it works:
55+
56+
$ mv deep/base_file deep/a/
57+
$ dune build deep_copied
58+
59+
$ rm deep/a/base_file
60+
$ dune build deep_copied

0 commit comments

Comments
 (0)