Skip to content

Commit

Permalink
Add support for setting build command when not set
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
  • Loading branch information
rgrinberg committed May 2, 2019
1 parent 65a6e4f commit d4bf448
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/opam_create.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
open Stdune

let default_build_command = lazy (
let path = Path.of_string "<internal>" in
let dummy_opam =
Opam_file.of_string ~path {|
build:
[ "dune" "subst" ] {pinned}
[ "dune" "build" "-p" name "-j" jobs]
|}
in
Opam_file.get_field dummy_opam "build"
|> Option.value_exn)

let correct_specific
{ Package.synopsis
; description
Expand Down Expand Up @@ -27,6 +39,7 @@ let correct project (package : Package.t) =
let open Opam_file.Mutator in
let open Opam_file.Mutator.No_overwrite in
correct_specific package >>>
set_var "build" (Lazy.force default_build_command) >>>
opt (Dune_project.maintainer project) (set_string "maintainer") >>>
opt (Dune_project.bug_reports project) (set_string "bug-reports") >>>
opt (Dune_project.homepage project) (set_string "homepage") >>>
Expand Down
2 changes: 1 addition & 1 deletion src/opam_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ module Mutator = struct
module Make_set(Set_var : sig
val set_var : string -> value -> t
end) = struct
open Set_var
include Set_var
let set_string x y = set_var x (mkstring y)
let set_list x conv l = set_var x (mklist conv l)
end
Expand Down

0 comments on commit d4bf448

Please sign in to comment.