Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/binary/.ocamlformat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = 0.12
version = 0.19.0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a problem with the formatter. (this is from the first commit)

2 changes: 1 addition & 1 deletion examples/binary/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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:

```
Expand Down
4 changes: 2 additions & 2 deletions examples/binary/dune-project
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(lang dune 2.0)
(lang dune 2.9.1)
(name binary)
(implicit_transitive_deps false)

Expand All @@ -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))
1 change: 1 addition & 0 deletions examples/binary/lib/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
(library
(name binary)
(public_name binary)
(libraries logs))
2 changes: 1 addition & 1 deletion examples/executable/dune-project
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(lang dune 2.0)
(lang dune 2.9.1)
2 changes: 1 addition & 1 deletion examples/library/.ocamlformat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = 0.12
version = 0.19.0
2 changes: 1 addition & 1 deletion examples/library/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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:

```
Expand Down
4 changes: 2 additions & 2 deletions examples/library/dune-project
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(lang dune 2.0)
(lang dune 2.9.1)
(name library)
(implicit_transitive_deps false)

Expand All @@ -14,4 +14,4 @@
Single package in `src`
")
(documentation https://JoeBloggs.github.io/library/)
(depends alcotest fmt logs))
(depends (alcotest :with-test) fmt logs))
1 change: 1 addition & 0 deletions examples/library/src/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
(library
(name library)
(public_name library)
(libraries logs))
7 changes: 6 additions & 1 deletion lib/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
28 changes: 18 additions & 10 deletions lib/contents.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -216,14 +224,14 @@ build: [
depends: [
"ocaml" {>= "%s"}
"dune" {build & >= "%s"}
"fmt"
"logs"
"alcotest" {with-test}
@[<v 2>%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 =
Expand Down
2 changes: 1 addition & 1 deletion lib/layouts.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions lib/oskel.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down