@@ -520,7 +520,8 @@ let () =
520
520
Path.Build.Set. iter fns ~f: (fun p -> Path. unlink_no_err (Path. build p)))
521
521
522
522
let compute_target_digests targets =
523
- Option.List. traverse (Path.Build.Set. to_list targets) ~f: (fun target ->
523
+ Option.List. traverse (Targets. to_list_map targets ~file: Fun. id)
524
+ ~f: (fun target ->
524
525
Cached_digest. build_file target
525
526
|> Cached_digest.Digest_result. to_option
526
527
|> Option. map ~f: (fun digest -> (target, digest)))
@@ -535,15 +536,15 @@ let compute_target_digests_or_raise_error exec_params ~loc targets =
535
536
(* FIXME: searching the dune version for each single target seems way
536
537
suboptimal. This information could probably be stored in rules
537
538
directly. *)
538
- if Path.Build.Set . is_empty targets then
539
+ if Targets . is_empty targets then
539
540
false
540
541
else
541
542
Execution_parameters. should_remove_write_permissions_on_generated_files
542
543
exec_params
543
544
in
544
545
let good, missing, errors =
545
- Path.Build.Set . fold targets ~init: ([] , [] , [] )
546
- ~f : (fun target (good , missing , errors ) ->
546
+ Targets . fold targets ~init: ([] , [] , [] )
547
+ ~file : (fun target (good , missing , errors ) ->
547
548
let expected_syscall_path = Path. to_string (Path. build target) in
548
549
match Cached_digest. refresh ~remove_write_permissions target with
549
550
| Ok digest -> ((target, digest) :: good, missing, errors)
@@ -773,13 +774,13 @@ end = struct
773
774
we try to sandbox this. *)
774
775
~sandbox: Sandbox_config. no_sandboxing ~context: None
775
776
~info: (Source_file_copy path)
776
- ~targets: (Path.Build.Set. singleton ctx_path)
777
+ ~targets: (Targets.File. create ctx_path)
777
778
build)
778
779
779
780
let compile_rules ~dir ~source_dirs rules =
780
781
List. concat_map rules ~f: (fun rule ->
781
782
assert (Path.Build. ( = ) dir rule.Rule. dir);
782
- Path.Build.Set. to_list_map rule.targets ~f : (fun target ->
783
+ Targets. to_list_map rule.targets ~file : (fun target ->
783
784
if String.Set. mem source_dirs (Path.Build. basename target) then
784
785
report_rule_src_dir_conflict dir target rule
785
786
else
@@ -851,8 +852,9 @@ end = struct
851
852
(* All targets are in [dir] and we know it correspond to a directory
852
853
of a build context since there are source files to copy, so this
853
854
call can't fail. *)
854
- Path.Build.Set. to_list rule.targets
855
- |> Path.Source.Set. of_list_map ~f: Path.Build. drop_build_context_exn
855
+ Targets. to_list_map rule.targets
856
+ ~file: Path.Build. drop_build_context_exn
857
+ |> Path.Source.Set. of_list
856
858
in
857
859
if Path.Source.Set. is_subset source_files_for_targets ~of_: to_copy
858
860
then
@@ -1020,10 +1022,10 @@ end = struct
1020
1022
match mode with
1021
1023
| Promote { only = None ; _ }
1022
1024
| Ignore_source_files ->
1023
- Path.Build.Set. union targets acc_ignored
1025
+ Path.Build.Set. union ( Targets. files targets) acc_ignored
1024
1026
| Promote { only = Some pred ; _ } ->
1025
1027
let to_ignore =
1026
- Path.Build.Set. filter targets ~f: (fun target ->
1028
+ Path.Build.Set. filter ( Targets. files targets) ~f: (fun target ->
1027
1029
Predicate_lang.Glob. exec pred
1028
1030
(Path. reach (Path. build target) ~from: (Path. build dir))
1029
1031
~standard: Predicate_lang. any)
@@ -1361,7 +1363,7 @@ end = struct
1361
1363
let trace =
1362
1364
( rule_digest_version (* Update when changing the rule digest scheme. *)
1363
1365
, Dep.Facts. digest deps ~sandbox_mode ~env
1364
- , Path.Build.Set. to_list_map rule.targets ~f : Path.Build. to_string
1366
+ , Targets. to_list_map rule.targets ~file : Path.Build. to_string
1365
1367
, Option. map rule.context ~f: (fun c -> Context_name. to_string c.name)
1366
1368
, Action. for_shell action
1367
1369
, can_go_in_shared_cache
@@ -1430,7 +1432,8 @@ end = struct
1430
1432
let { Action.Full. action; env; locks; can_go_in_shared_cache = _ } =
1431
1433
action
1432
1434
in
1433
- pending_targets := Path.Build.Set. union targets ! pending_targets;
1435
+ let file_targets = Targets. files targets in
1436
+ pending_targets := Path.Build.Set. union file_targets ! pending_targets;
1434
1437
let chdirs = Action. chdirs action in
1435
1438
let sandbox =
1436
1439
Option. map sandbox_mode ~f: (fun mode ->
@@ -1473,7 +1476,7 @@ end = struct
1473
1476
in
1474
1477
Option. iter sandbox ~f: Sandbox. destroy;
1475
1478
(* All went well, these targets are no longer pending *)
1476
- pending_targets := Path.Build.Set. diff ! pending_targets targets ;
1479
+ pending_targets := Path.Build.Set. diff ! pending_targets file_targets ;
1477
1480
exec_result
1478
1481
1479
1482
let try_to_store_to_shared_cache ~mode ~rule_digest ~action ~targets =
@@ -1494,7 +1497,7 @@ end = struct
1494
1497
Cached_digest. set target digest)
1495
1498
in
1496
1499
match
1497
- Path.Build.Set. to_list_map targets ~f : Dune_cache.Local.Target. create
1500
+ Targets. to_list_map targets ~file : Dune_cache.Local.Target. create
1498
1501
|> Option.List. all
1499
1502
with
1500
1503
| None -> Fiber. return None
@@ -1590,7 +1593,7 @@ end = struct
1590
1593
rule
1591
1594
in
1592
1595
start_rule t rule;
1593
- let head_target = Path.Build.Set. choose_exn targets in
1596
+ let head_target = Targets. head_exn targets in
1594
1597
let * execution_parameters =
1595
1598
match Dpath.Target_dir. of_target dir with
1596
1599
| Regular (With_context (_, dir))
@@ -1745,7 +1748,7 @@ end = struct
1745
1748
~cache_debug_flags: t.cache_debug_flags ~head_target miss_reason;
1746
1749
(* Step I. Remove stale targets both from the digest table and from
1747
1750
the build directory. *)
1748
- Path.Build.Set. iter targets ~f : (fun target ->
1751
+ Targets. iter targets ~file : (fun target ->
1749
1752
Cached_digest. remove target;
1750
1753
Path.Build. unlink_no_err target);
1751
1754
(* Step II. Try to restore artifacts from the shared cache if the
@@ -1855,20 +1858,22 @@ end = struct
1855
1858
| Promote { lifetime; into; only } , (Some Automatically | None ) ->
1856
1859
Fiber. parallel_iter_set
1857
1860
(module Path.Build. Set )
1858
- targets
1859
- ~f: (fun path ->
1861
+ ( Targets. files targets)
1862
+ ~f: (fun target ->
1860
1863
let consider_for_promotion =
1861
1864
match only with
1862
1865
| None -> true
1863
1866
| Some pred ->
1864
1867
Predicate_lang.Glob. exec pred
1865
- (Path. reach (Path. build path ) ~from: (Path. build dir))
1868
+ (Path. reach (Path. build target ) ~from: (Path. build dir))
1866
1869
~standard: Predicate_lang. any
1867
1870
in
1868
1871
match consider_for_promotion with
1869
1872
| false -> Fiber. return ()
1870
1873
| true ->
1871
- let in_source_tree = Path.Build. drop_build_context_exn path in
1874
+ let in_source_tree =
1875
+ Path.Build. drop_build_context_exn target
1876
+ in
1872
1877
let in_source_tree =
1873
1878
match into with
1874
1879
| None -> in_source_tree
@@ -1910,7 +1915,7 @@ end = struct
1910
1915
| None -> false
1911
1916
| Some in_source_tree_digest -> (
1912
1917
match
1913
- Cached_digest. build_file path
1918
+ Cached_digest. build_file target
1914
1919
|> Cached_digest.Digest_result. to_option
1915
1920
with
1916
1921
| None ->
@@ -1935,7 +1940,7 @@ end = struct
1935
1940
explicitly set the user writable bit. *)
1936
1941
let chmod n = n lor 0o200 in
1937
1942
Path. unlink_no_err (Path. source dst);
1938
- t.promote_source ~src: path ~dst ~chmod context
1943
+ t.promote_source ~src: target ~dst ~chmod context
1939
1944
))
1940
1945
in
1941
1946
t.rule_done < - t.rule_done + 1 ;
@@ -2005,7 +2010,7 @@ end = struct
2005
2010
(match loc with
2006
2011
| Some loc -> From_dune_file loc
2007
2012
| None -> Internal )
2008
- ~targets: (Path.Build.Set. singleton target)
2013
+ ~targets: (Targets.File. create target)
2009
2014
(Action_builder. of_thunk
2010
2015
{ f =
2011
2016
(fun mode ->
0 commit comments