enabled_if is now allowed on packages:

  $ testProject() {
  > cat > dune-project << EOF
  > (lang dune 3.22)
  > (using unreleased 0.1)
  > (generate_opam_files true)
  > (package
  >  (name foo)
  >  (dir foo)
  >  (enabled_if $1))
  > EOF
  > out=foo/out
  > dune build $out
  > }

  $ mkdir foo
  $ cat >foo/dune <<EOF
  > (rule (with-stdout-to out (echo foo)))
  > EOF

  $ testProject true
  $ testProject false
  Error: Don't know how to build foo/out
  [1]

Tests for generating opam files with the "enabled_if" field.

  $ cat > dune-project << EOF
  > (lang dune 3.22)
  > (using unreleased 0.1)
  > (generate_opam_files true)
  > (package
  >  (name foo)
  >  (enabled_if
  >   (and
  >    (<> %{os} linux)
  >    (or (= %{architecture} x86_64) (= %{architecture} arm64)))))
  > EOF

  $ dune build @opam

  $ cat foo.opam
  # This file is generated by dune, edit dune-project instead
  opam-version: "2.0"
  depends: [
    "dune" {>= "3.22"}
    "odoc" {with-doc}
  ]
  available: os != "linux" & (arch = "x86_64" | arch = "arm64")
  build: [
    ["dune" "subst"] {dev}
    [
      "dune"
      "build"
      "-p"
      name
      "-j"
      jobs
      "@install"
      "@runtest" {with-test}
      "@doc" {with-doc}
    ]
  ]
  x-maintenance-intent: ["(latest)"]

Demonstrate that we reject variables that we can't interpret:

  $ cat > dune-project << EOF
  > (lang dune 3.22)
  > (using unreleased 0.1)
  > (generate_opam_files true)
  > (package
  >  (name foo)
  >  (enabled_if (<> %{foo} bar)))
  > EOF

  $ dune build @opam
  File "dune-project", line 6, characters 17-23:
  6 |  (enabled_if (<> %{foo} bar)))
                       ^^^^^^
  Error: Unknown variable %{foo}
  [1]
