  $ export BUILD_PATH_PREFIX_MAP=\
  > "OPAM_PREFIX=$(ocamlc -where):$BUILD_PATH_PREFIX_MAP"

If Merlin field is absent, default context is chosen

  $ cat >dune-workspace <<EOF
  > (lang dune 2.9)
  > (context (default))
  > (context
  >  (default
  >   (name cross)))
  > EOF

  $ dune build

  $ [ ! -d _build/cross/.merlin-conf ] && echo "No config in cross"
  No config in cross

  $ ls -a _build/default/.merlin-conf
  .
  ..
  lib-foo

  $ dune ocaml merlin dump-config --format=json "$PWD" | jq -r '
  >   include "dune";
  >   merlinEntry("Foo")
  >   | merlinJsonEntryWithConfigNames(["STDLIB", "UNIT_NAME"])'
  Foo: _build/default/foo
  ["STDLIB","OPAM_PREFIX"]
  ["UNIT_NAME","foo"]
  Foo: _build/default/foo.ml
  ["STDLIB","OPAM_PREFIX"]
  ["UNIT_NAME","foo"]

If Merlin field is present, this context is chosen

  $ cat >dune-workspace <<EOF
  > (lang dune 2.8)
  > (context (default))
  > (context
  >  (default
  >   (name cross)
  >   (merlin)))
  > EOF

  $ dune build

  $ ls -a _build/cross/.merlin-conf
  .
  ..
  lib-foo

  $ [ ! -d _build/default/.merlin-conf ] && echo "No config in default"
  No config in default

  $ dune ocaml merlin dump-config --format=json "$PWD" | jq -r '
  >   include "dune";
  >   merlinEntry("Foo")
  >   | merlinJsonEntryWithConfigNames(["STDLIB", "UNIT_NAME"])'
  Foo: _build/cross/foo
  ["STDLIB","OPAM_PREFIX"]
  ["UNIT_NAME","foo"]
  Foo: _build/cross/foo.ml
  ["STDLIB","OPAM_PREFIX"]
  ["UNIT_NAME","foo"]

If `generate_merlin_rules` field is present, rules are generated even if merlin
is disabled in that context

  $ cat >dune-workspace <<EOF
  > (lang dune 3.16)
  > (context (default))
  > (context
  >  (default
  >   (name cross)
  >   (generate_merlin_rules)))
  > EOF

  $ dune build

  $ ls -a _build/cross/.merlin-conf
  .
  ..
  lib-foo

  $ ls -a _build/default/.merlin-conf
  .
  ..
  lib-foo

  $ dune ocaml merlin dump-config --format=json "$PWD" | jq -r '
  >   include "dune";
  >   merlinEntry("Foo")
  >   | merlinJsonEntryWithConfigNames(["STDLIB", "UNIT_NAME"])'
  Foo: _build/default/foo
  ["STDLIB","OPAM_PREFIX"]
  ["UNIT_NAME","foo"]
  Foo: _build/default/foo.ml
  ["STDLIB","OPAM_PREFIX"]
  ["UNIT_NAME","foo"]
