From 4bc629abbd408fd6aeb679f608e7d5ff6b916580 Mon Sep 17 00:00:00 2001 From: Kate Date: Thu, 23 Jul 2020 13:50:35 +0100 Subject: [PATCH] Opam file generation: Use {dev} instead of {pinned} when calling dune subst Signed-off-by: Kate --- src/dune/opam_create.ml | 24 ++++++++++++++--- .../test-cases/dune-project-meta/main/run.t | 27 +++++++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/dune/opam_create.ml b/src/dune/opam_create.ml index 6f3325b48222..976ddbad723e 100644 --- a/src/dune/opam_create.ml +++ b/src/dune/opam_create.ml @@ -13,7 +13,7 @@ let default_build_command = [ "dune" "build" "-p" name "@doc"] {with-doc} ] |})) - and from_1_11 = + and from_1_11_before_2_07 = lazy (Opam_file.parse_value (Lexbuf.from_string ~fname:"" @@ -26,14 +26,30 @@ let default_build_command = "@doc" {with-doc} ] ] +|})) + and from_2_07 = + lazy + (Opam_file.parse_value + (Lexbuf.from_string ~fname:"" + {| +[ + [ "dune" "subst" ] {dev} + [ "dune" "build" "-p" name "-j" jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] |})) in fun project -> Lazy.force ( if Dune_project.dune_version project < (1, 11) then - before_1_11 - else - from_1_11 ) + before_1_11 + else if Dune_project.dune_version project < (2, 7) then + from_1_11_before_2_07 + else + from_2_07 ) let package_fields { Package.synopsis diff --git a/test/blackbox-tests/test-cases/dune-project-meta/main/run.t b/test/blackbox-tests/test-cases/dune-project-meta/main/run.t index 3e046b55e57c..962a9d364017 100644 --- a/test/blackbox-tests/test-cases/dune-project-meta/main/run.t +++ b/test/blackbox-tests/test-cases/dune-project-meta/main/run.t @@ -397,3 +397,30 @@ Same with version of the language >= 2.6, we now add the constraint: depends: [ "dune" {>= "2.6"} ] + +When the version of the language >= 2.7 we use dev instead of pinned +when calling dune subst: + + $ cat > dune-project < (lang dune 2.7) + > (name foo) + > (generate_opam_files true) + > (package (name foo)) + > EOF + + $ dune build foo.opam + $ grep -A13 ^build: foo.opam + build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] + ]