Skip to content

Commit 4110548

Browse files
Move to hidden directory inside _build
This avoids the case of the name being picked up as build context Signed-off-by: Marek Kubica <[email protected]>
1 parent ec2b509 commit 4110548

27 files changed

+51
-48
lines changed

src/dune_pkg/lock_dir.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1783,7 +1783,7 @@ let loc_in_source_tree loc =
17831783
|> Loc.map_pos ~f:(fun ({ pos_fname; _ } as pos) ->
17841784
(* we're excluding the hidden dev-tools.locks folders in the build folder
17851785
from rewriting *)
1786-
match String.starts_with ~prefix:"_build/dev-tools.locks/" pos_fname with
1786+
match String.starts_with ~prefix:"_build/.dev-tools.locks/" pos_fname with
17871787
| true -> pos
17881788
| false ->
17891789
let path = Path.of_string pos_fname in

src/dune_rules/lock_dir.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ let dev_tool_to_path_segment dev_tool =
149149

150150
let dev_tool_source_lock_dir dev_tool =
151151
let dev_tools_path =
152-
Path.Source.L.relative Path.Source.root [ "_build"; "dev-tools.locks" ]
152+
Path.Source.L.relative Path.Source.root [ "_build"; ".dev-tools.locks" ]
153153
in
154154
let dev_tool_segment = dev_tool_to_path_segment dev_tool in
155155
Path.Source.append_local dev_tools_path dev_tool_segment

src/dune_rules/pkg_rules.ml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,10 +1494,10 @@ end = struct
14941494
in
14951495
resolve db dep_loc dep_pkg_digest package_universe)
14961496
and+ files_dir =
1497-
let* lock_dir =
1497+
let+ lock_dir =
14981498
Package_universe.lock_dir_path package_universe >>| Option.value_exn
14991499
in
1500-
let+ files_dir =
1500+
let files_dir =
15011501
let module Pkg = Dune_pkg.Lock_dir.Pkg in
15021502
(* TODO(steve): simplify this once portable lockdirs become the
15031503
default. This logic currently handles both the cases where
@@ -1509,17 +1509,15 @@ end = struct
15091509
let path_with_version =
15101510
Pkg.source_files_dir info.name (Some info.version) ~lock_dir
15111511
in
1512-
let* path_with_version_exists =
1513-
Fs_memo.dir_exists (Path.Outside_build_dir.In_source_dir path_with_version)
1512+
let path_with_version_exists =
1513+
Path.Untracked.exists (Path.source path_with_version)
15141514
in
15151515
match path_with_version_exists with
1516-
| true ->
1517-
Memo.return @@ Some (Pkg.files_dir info.name (Some info.version) ~lock_dir)
1516+
| true -> Some (Pkg.files_dir info.name (Some info.version) ~lock_dir)
15181517
| false ->
15191518
let path_without_version = Pkg.source_files_dir info.name None ~lock_dir in
1520-
let+ path_without_version_exists =
1521-
Fs_memo.dir_exists
1522-
(Path.Outside_build_dir.In_source_dir path_without_version)
1519+
let path_without_version_exists =
1520+
Path.Untracked.exists (Path.source path_without_version)
15231521
in
15241522
(match path_without_version_exists with
15251523
| true -> Some (Pkg.files_dir info.name None ~lock_dir)
@@ -1533,18 +1531,23 @@ end = struct
15331531
"Package files directory is external source directory, this is unsupported"
15341532
[ "dir", Path.External.to_dyn e ]
15351533
| In_source_tree s ->
1534+
(* TODO this probably never happens now *)
15361535
(match Path.Source.explode s with
1537-
| [ "_build"; "dev-tools.locks"; dev_tool; files_dir ] ->
1536+
| [ "_build"; ".dev-tools.locks"; dev_tool; files_dir ] ->
15381537
Path.Build.L.relative
15391538
Private_context.t.build_dir
15401539
[ "default"; ".dev-tool-locks"; dev_tool; files_dir ]
15411540
| otherwise ->
15421541
Code_error.raise
15431542
"Unexpected files_dir path"
15441543
[ "components", (Dyn.list Dyn.string) otherwise ])
1545-
| In_build_dir b ->
1546-
(* it's already a build path, no need to do anything *)
1547-
b)
1544+
| In_build_dir b -> (
1545+
match Path.Build.explode b with
1546+
| [".dev-tools.locks"; dev_tool; files_dir] ->
1547+
Path.Build.L.relative
1548+
Private_context.t.build_dir
1549+
[ "default"; ".dev-tool-locks"; dev_tool; files_dir ]
1550+
| _otherwise -> b))
15481551
in
15491552
let id = Pkg.Id.gen () in
15501553
let write_paths =

test/blackbox-tests/test-cases/pkg/ocamlformat/gh10991.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Initial file:
1919
let () = print_endline "Hello, world"
2020

2121
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune fmt
22-
Solution for _build/dev-tools.locks/ocamlformat:
22+
Solution for _build/.dev-tools.locks/ocamlformat:
2323
- ocamlformat.0.0.1
2424
File "foo.ml", line 1, characters 0-0:
2525
Error: Files _build/default/foo.ml and _build/default/.formatted/foo.ml

test/blackbox-tests/test-cases/pkg/ocamlformat/gh11037.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ attempt to build the package "foo".
4040
$ cat foo.ml
4141
let () = print_endline "Hello, world"
4242
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune fmt
43-
Solution for _build/dev-tools.locks/ocamlformat:
43+
Solution for _build/.dev-tools.locks/ocamlformat:
4444
- ocamlformat.0.0.1
4545
File "foo.ml", line 1, characters 0-0:
4646
Error: Files _build/default/foo.ml and _build/default/.formatted/foo.ml

test/blackbox-tests/test-cases/pkg/ocamlformat/helpers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
. ../helpers.sh
22

3-
dev_tool_lock_dir="_build/dev-tools.locks/ocamlformat"
3+
dev_tool_lock_dir="_build/.dev-tools.locks/ocamlformat"
44

55
make_fake_ocamlformat() {
66
version=$1

test/blackbox-tests/test-cases/pkg/ocamlformat/ocamlformat-avoid-conflict-with-project.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Add a fake executable in the PATH
2929

3030
Build the OCamlFormat binary dev-tool
3131
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune fmt --preview
32-
Solution for _build/dev-tools.locks/ocamlformat:
32+
Solution for _build/.dev-tools.locks/ocamlformat:
3333
- ocamlformat.0.26.2
3434
File "dune", line 1, characters 0-0:
3535
Error: Files _build/default/dune and _build/default/.formatted/dune differ.

test/blackbox-tests/test-cases/pkg/ocamlformat/ocamlformat-avoid-taking-from-project-deps.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Format using the dev-tools feature, it does not invoke the OCamlFormat binary fr
4545
the project dependencies (0.26.2) but instead builds and runs the OCamlFormat binary as a
4646
dev-tool (0.26.3).
4747
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune fmt
48-
Solution for _build/dev-tools.locks/ocamlformat:
48+
Solution for _build/.dev-tools.locks/ocamlformat:
4949
- ocamlformat.0.26.3
5050
File "foo.ml", line 1, characters 0-0:
5151
Error: Files _build/default/foo.ml and _build/default/.formatted/foo.ml

test/blackbox-tests/test-cases/pkg/ocamlformat/ocamlformat-dev-tool-deps-conflict-project-deps.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ It shows that the project uses printer.2.0
9494
Format foo.ml, "dune fmt" uses printer.1.0 instead. There is no conflict with different
9595
versions of the same dependency.
9696
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune fmt --preview
97-
Solution for _build/dev-tools.locks/ocamlformat:
97+
Solution for _build/.dev-tools.locks/ocamlformat:
9898
- ocamlformat.0.26.2
9999
- printer.1.0
100100
File "foo.ml", line 1, characters 0-0:

test/blackbox-tests/test-cases/pkg/ocamlformat/ocamlformat-dev-tool-fails-to-build.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Make dune-project that uses the mocked dev-tool opam-reposiotry.
1313

1414
It fails during the build because of missing OCamlFormat module.
1515
$ DUNE_CONFIG__LOCK_DEV_TOOL=enabled dune fmt
16-
Solution for _build/dev-tools.locks/ocamlformat:
16+
Solution for _build/.dev-tools.locks/ocamlformat:
1717
- ocamlformat.0.26.4
18-
File "_build/dev-tools.locks/ocamlformat/ocamlformat.pkg", line 4, characters 6-10:
18+
File "_build/.dev-tools.locks/ocamlformat/ocamlformat.pkg", line 4, characters 6-10:
1919
4 | (run dune build -p %{pkg-self:name} @install))
2020
^^^^
2121
Error: Logs for package ocamlformat

0 commit comments

Comments
 (0)