@@ -461,29 +461,40 @@ let get_installed_binaries stanzas ~(context : Context.t) =
461461 binaries_from_install files
462462 | Dune_file. Executables
463463 ({ install_conf = Some { section = Section Bin ; files; _ }; _ } as
464- exes) ->
465- let * compile_info =
466- let project = Scope. project d.scope in
467- let dune_version = Dune_project. dune_version project in
468- let + pps =
469- Resolve. read_memo_build
470- (Preprocess.Per_module. with_instrumentation
471- exes.buildable.preprocess
472- ~instrumentation_backend:
473- (Lib.DB. instrumentation_backend (Scope. libs d.scope)))
474- >> | Preprocess.Per_module. pps
475- in
476- Lib.DB. resolve_user_written_deps_for_exes (Scope. libs d.scope)
477- exes.names exes.buildable.libraries ~pps ~dune_version
478- ~allow_overlaps: exes.buildable.allow_overlapping_dependencies
464+ exes) -> (
465+ let * enabled_if =
466+ Expander.With_reduced_var_set. eval_blang ~context ~dir: d.ctx_dir
467+ exes.enabled_if
479468 in
480- let available =
481- Resolve. is_ok (Lib.Compile. direct_requires compile_info)
482- in
483- if available then
484- binaries_from_install files
485- else
486- Memo.Build. return Path.Build.Set. empty
469+ match enabled_if with
470+ | false -> Memo.Build. return Path.Build.Set. empty
471+ | true -> (
472+ match exes.optional with
473+ | false -> binaries_from_install files
474+ | true ->
475+ let * compile_info =
476+ let project = Scope. project d.scope in
477+ let dune_version = Dune_project. dune_version project in
478+ let + pps =
479+ Resolve. read_memo_build
480+ (Preprocess.Per_module. with_instrumentation
481+ exes.buildable.preprocess
482+ ~instrumentation_backend:
483+ (Lib.DB. instrumentation_backend (Scope. libs d.scope)))
484+ >> | Preprocess.Per_module. pps
485+ in
486+ Lib.DB. resolve_user_written_deps_for_exes (Scope. libs d.scope)
487+ exes.names exes.buildable.libraries ~pps ~dune_version
488+ ~allow_overlaps:
489+ exes.buildable.allow_overlapping_dependencies
490+ in
491+ let available =
492+ Resolve. is_ok (Lib.Compile. direct_requires compile_info)
493+ in
494+ if available then
495+ binaries_from_install files
496+ else
497+ Memo.Build. return Path.Build.Set. empty))
487498 | _ -> Memo.Build. return Path.Build.Set. empty)
488499 >> | Path.Build.Set. union_all)
489500 >> | Path.Build.Set. union_all
0 commit comments