diff --git a/examples/binary/.ocamlformat b/examples/binary/.ocamlformat index 0eac260..bc9c6ce 100644 --- a/examples/binary/.ocamlformat +++ b/examples/binary/.ocamlformat @@ -1 +1 @@ -version = 0.12 +version = 0.19.0 diff --git a/examples/binary/CONTRIBUTING.md b/examples/binary/CONTRIBUTING.md index 0ee9ff6..ef9f5e8 100644 --- a/examples/binary/CONTRIBUTING.md +++ b/examples/binary/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Setting up your working environment -binary requires OCaml 4.09.0 or higher so you will need a corresponding opam +binary requires OCaml 4.14.0 or higher so you will need a corresponding opam switch. You can install a switch with the latest OCaml version by running: ``` diff --git a/examples/binary/dune-project b/examples/binary/dune-project index 09129c7..7cfa173 100644 --- a/examples/binary/dune-project +++ b/examples/binary/dune-project @@ -1,4 +1,4 @@ -(lang dune 2.0) +(lang dune 2.9.1) (name binary) (implicit_transitive_deps false) @@ -14,4 +14,4 @@ Binary that depends on a tested library ") (documentation https://JoeBloggs.github.io/binary/) - (depends alcotest fmt logs)) + (depends (alcotest :with-test) fmt logs)) diff --git a/examples/binary/lib/dune b/examples/binary/lib/dune index 24976ea..b542398 100644 --- a/examples/binary/lib/dune +++ b/examples/binary/lib/dune @@ -1,3 +1,4 @@ (library (name binary) + (public_name binary) (libraries logs)) diff --git a/examples/executable/dune-project b/examples/executable/dune-project index 929c696..3aad160 100644 --- a/examples/executable/dune-project +++ b/examples/executable/dune-project @@ -1 +1 @@ -(lang dune 2.0) +(lang dune 2.9.1) diff --git a/examples/library/.ocamlformat b/examples/library/.ocamlformat index 0eac260..bc9c6ce 100644 --- a/examples/library/.ocamlformat +++ b/examples/library/.ocamlformat @@ -1 +1 @@ -version = 0.12 +version = 0.19.0 diff --git a/examples/library/CONTRIBUTING.md b/examples/library/CONTRIBUTING.md index f5c8493..21ab694 100644 --- a/examples/library/CONTRIBUTING.md +++ b/examples/library/CONTRIBUTING.md @@ -1,6 +1,6 @@ ## Setting up your working environment -library requires OCaml 4.09.0 or higher so you will need a corresponding opam +library requires OCaml 4.14.0 or higher so you will need a corresponding opam switch. You can install a switch with the latest OCaml version by running: ``` diff --git a/examples/library/dune-project b/examples/library/dune-project index 8c32354..d019d73 100644 --- a/examples/library/dune-project +++ b/examples/library/dune-project @@ -1,4 +1,4 @@ -(lang dune 2.0) +(lang dune 2.9.1) (name library) (implicit_transitive_deps false) @@ -14,4 +14,4 @@ Single package in `src` ") (documentation https://JoeBloggs.github.io/library/) - (depends alcotest fmt logs)) + (depends (alcotest :with-test) fmt logs)) diff --git a/examples/library/src/dune b/examples/library/src/dune index 15c6ac2..02893e0 100644 --- a/examples/library/src/dune +++ b/examples/library/src/dune @@ -1,3 +1,4 @@ (library (name library) + (public_name library) (libraries logs)) diff --git a/lib/config.ml b/lib/config.ml index e704661..1f4d515 100644 --- a/lib/config.ml +++ b/lib/config.ml @@ -7,6 +7,11 @@ type versions = { ocamlformat : string; } +type dependency = { + dep_name : string; + dep_filter : string option; (** For example, ["with-test"]. *) +} + type t = { name : string; project_synopsis : string; @@ -15,7 +20,7 @@ type t = { github_organisation : string; initial_version : string; license : License.t; - dependencies : string list; + dependencies : dependency list; versions : versions; ocamlformat_options : (string * string) list; current_year : int; diff --git a/lib/contents.ml b/lib/contents.ml index d803162..85adb16 100644 --- a/lib/contents.ml +++ b/lib/contents.ml @@ -3,13 +3,18 @@ open Utils type file_printer = Config.t -> Format.formatter -> unit +let dep_alcotest = { dep_name = "alcotest"; dep_filter = Some "with-test" } + +let project_dependencies config = + config.dependencies |> List.append [ dep_alcotest ] |> List.sort_uniq compare + module Dune_project = struct + let pp_depend ppf dep = + match dep.dep_filter with + | None -> Fmt.string ppf dep.dep_name + | Some filter -> Fmt.pf ppf "(%s :%s)" dep.dep_name filter + let package c ppf = - let dependencies = - c.dependencies - |> List.append [ "alcotest" ] - |> List.sort_uniq String.compare - in Fmt.pf ppf {|(lang dune %s) (name %s) (implicit_transitive_deps false) @@ -35,8 +40,8 @@ module Dune_project = struct (documentation https://%s.github.io/%s/) (depends %a))|} c.name c.project_synopsis c.project_synopsis c.github_organisation c.name - Fmt.(list ~sep:(const string " ") string) - dependencies + Fmt.(list ~sep:(const string " ") pp_depend) + (project_dependencies c) let minimal config ppf = Fmt.pf ppf "(lang dune %s)" config.versions.dune end @@ -198,6 +203,9 @@ let opam config ppf = Fmt.pf ppf "git+https://github.com/%s/%s.git" config.github_organisation config.name in + let pp_depend ppf dep = + Fmt.pf ppf "%S%a" dep.dep_name Fmt.(option (fmt " {%s}")) dep.dep_filter + in Fmt.pf ppf {|opam-version: "%s" maintainer: "%s" @@ -216,14 +224,14 @@ build: [ depends: [ "ocaml" {>= "%s"} "dune" {build & >= "%s"} - "fmt" - "logs" - "alcotest" {with-test} + @[%a@] ] synopsis: "%s"|} config.versions.opam config.maintainer_fullname config.maintainer_fullname Config.pp_license config.license pp_homepage config pp_bugreports config pp_devrepo config config.versions.ocaml config.versions.dune + Fmt.(list ~sep:cut pp_depend) + (project_dependencies config) config.project_synopsis let test_main_ml config ppf = diff --git a/lib/layouts.ml b/lib/layouts.ml index 3a66692..0e5359c 100644 --- a/lib/layouts.ml +++ b/lib/layouts.ml @@ -152,7 +152,7 @@ let binary = { layout = binary; post_init = [] } let executable (config : Config.t) = let name = config.name in let toplevel_file = Utils.Utils_naming.file_of_project name in - let libraries = config.dependencies in + let libraries = List.map (fun d -> d.Config.dep_name) config.dependencies in let open Contents in Folder ( config.name, diff --git a/lib/oskel.ml b/lib/oskel.ml index f86ca00..913157d 100644 --- a/lib/oskel.ml +++ b/lib/oskel.ml @@ -180,6 +180,11 @@ let run ~project_kind ?name ?project_synopsis ~maintainer_fullname if !progress_bar_active then Printf.printf "\r\n%!"; return ()) and+ c = config >* progress in + let dependencies = + List.map + (fun dep_name -> { Config.dep_name; dep_filter = None }) + dependencies + in let versions = versions |> function