@@ -32,50 +32,6 @@ include Common.Let_syntax
3232
3333let in_group (t , info ) = (Term.Group. Term t, info)
3434
35- let make_cache (config : Dune_config.t ) =
36- let make_cache () =
37- let command_handler (Cache. Dedup file ) =
38- match Build_system. get_cache () with
39- | None -> Code_error. raise " deduplication message and no caching" []
40- | Some caching ->
41- Scheduler. send_sync_task (fun () ->
42- let (module Caching : Cache.Caching ) = caching.cache in
43- match Cached_digest. peek_file (Path. build file.path) with
44- | None -> ()
45- | Some d when not (Digest. equal d file.digest) -> ()
46- | _ -> Caching.Cache. deduplicate Caching. cache file)
47- in
48- match config.cache_transport with
49- | Dune_config.Caching.Transport. Direct ->
50- Log. info [ Pp. text " enable binary cache in direct access mode" ];
51- let cache =
52- Result. ok_exn
53- (Result. map_error
54- ~f: (fun s -> User_error. E (User_error. make [ Pp. text s ]))
55- (Cache.Local. make ?duplication_mode:config.cache_duplication
56- ~command_handler () ))
57- in
58- Cache. make_caching (module Cache. Local ) cache
59- | Daemon ->
60- Log. info [ Pp. text " enable binary cache in daemon mode" ];
61- let cache =
62- Result. ok_exn
63- (Cache.Client. make ?duplication_mode:config.cache_duplication
64- ~command_handler () )
65- in
66- Cache. make_caching (module Cache. Client ) cache
67- in
68- Fiber. return
69- (match config.cache_mode with
70- | Dune_config.Caching.Mode. Enabled ->
71- Some
72- { Build_system. cache = make_cache ()
73- ; check_probability = config.cache_check_probability
74- }
75- | Dune_config.Caching.Mode. Disabled ->
76- Log. info [ Pp. text " disable binary cache" ];
77- None )
78-
7935module Main = struct
8036 include Dune_rules. Main
8137
@@ -93,7 +49,6 @@ module Main = struct
9349
9450 let setup ?build_mutex common =
9551 let open Fiber.O in
96- let * caching = make_cache (Common. config common) in
9752 let * workspace = scan_workspace common in
9853 let * only_packages =
9954 match Common. only_packages common with
@@ -132,9 +87,22 @@ module Main = struct
13287 >> | Option. some
13388 in
13489 let stats = Common. stats common in
90+ let cache_config =
91+ match (Common. config common).cache_mode with
92+ | Disabled -> Dune_cache.Config. Disabled
93+ | Enabled ->
94+ Enabled
95+ { storage_mode =
96+ (match (Common. config common).cache_duplication with
97+ | None
98+ | Some Hardlink ->
99+ Dune_cache_storage.Mode. Hardlink
100+ | Some Copy -> Copy )
101+ }
102+ in
135103 init_build_system workspace ?stats
136104 ~sandboxing_preference: (Common. config common).sandboxing_preference
137- ?caching ? build_mutex ?only_packages
105+ ?build_mutex ?only_packages ~cache_config
138106end
139107
140108module Scheduler = struct
0 commit comments