|
1 | 1 | open Import
|
| 2 | +open Memo.O |
2 | 3 |
|
3 | 4 | type t =
|
4 | 5 | { libraries : Foreign.Sources.t Lib_name.Map.t
|
@@ -215,24 +216,23 @@ let make stanzas ~(sources : Unresolved.t) ~dune_version =
|
215 | 216 | List.fold_left
|
216 | 217 | stanzas
|
217 | 218 | ~init:([], [], [])
|
218 |
| - ~f:(fun ((libs, foreign_libs, exes) as acc) stanza -> |
219 |
| - match Stanza.repr stanza with |
220 |
| - | Library.T lib -> |
| 219 | + ~f:(fun (libs, foreign_libs, exes) stanza -> |
| 220 | + match stanza with |
| 221 | + | `Library (lib : Library.t) -> |
221 | 222 | let all =
|
222 | 223 | eval_foreign_stubs lib.buildable.foreign_stubs lib.buildable.ctypes
|
223 | 224 | in
|
224 | 225 | (lib, all) :: libs, foreign_libs, exes
|
225 |
| - | Foreign_library.T library -> |
| 226 | + | `Foreign_library (library : Foreign_library.t) -> |
226 | 227 | let all = eval_foreign_stubs [ library.stubs ] None in
|
227 | 228 | ( libs
|
228 | 229 | , (library.archive_name, (library.archive_name_loc, all)) :: foreign_libs
|
229 | 230 | , exes )
|
230 |
| - | Executables.T exe | Tests.T { exes = exe; _ } -> |
| 231 | + | `Executables exe | `Tests { Tests.exes = exe; _ } -> |
231 | 232 | let all =
|
232 | 233 | eval_foreign_stubs exe.buildable.foreign_stubs exe.buildable.ctypes
|
233 | 234 | in
|
234 |
| - libs, foreign_libs, (exe, all) :: exes |
235 |
| - | _ -> acc) |
| 235 | + libs, foreign_libs, (exe, all) :: exes) |
236 | 236 | in
|
237 | 237 | List.(rev libs, rev foreign_libs, rev exes)
|
238 | 238 | in
|
@@ -337,3 +337,23 @@ let make stanzas ~dune_version ~dirs =
|
337 | 337 | let sources = Unresolved.load_dirs ~dune_version dirs in
|
338 | 338 | make stanzas ~dune_version ~sources
|
339 | 339 | ;;
|
| 340 | + |
| 341 | +let make stanzas ~dir ~dune_version ~dirs = |
| 342 | + let+ stanzas = |
| 343 | + List.filter_map stanzas ~f:(fun stanza -> |
| 344 | + match Stanza.repr stanza with |
| 345 | + | Library.T lib -> Some (`Library lib, lib.enabled_if) |
| 346 | + | Foreign_library.T lib -> Some (`Foreign_library lib, lib.enabled_if) |
| 347 | + | Executables.T exe -> Some (`Executables exe, exe.enabled_if) |
| 348 | + | Tests.T ({ exes = exe; _ } as tests) -> Some (`Tests tests, exe.enabled_if) |
| 349 | + | _ -> None) |
| 350 | + |> Memo.parallel_map ~f:(fun (stanza, enabled_if) -> |
| 351 | + let* expander = Expander0.get ~dir in |
| 352 | + Expander0.eval_blang expander enabled_if |
| 353 | + >>| function |
| 354 | + | false -> None |
| 355 | + | true -> Some stanza) |
| 356 | + >>| List.filter_opt |
| 357 | + in |
| 358 | + make stanzas ~dune_version ~dirs |
| 359 | +;; |
0 commit comments