Skip to content

Commit

Permalink
dune build @fmt --auto
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesm committed Jun 20, 2022
1 parent afffaa6 commit 4b2a168
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
36 changes: 29 additions & 7 deletions lib/functoria/lib.ml
Expand Up @@ -62,10 +62,32 @@ module Config = struct
let packages = Key.pure @@ packages in
let jobs = Impl.abstract jobs in
let keys = Key.Set.(union (of_list keys) (get_if_context jobs)) in
{ config_file; packages; keys; name; init; configure_cmd; depend_cmd; build_cmd; jobs; src }
{
config_file;
packages;
keys;
name;
init;
configure_cmd;
depend_cmd;
build_cmd;
jobs;
src;
}

let eval ~full context
{ config_file; name = n; configure_cmd; depend_cmd; build_cmd; packages; keys; jobs; init; src } =
{
config_file;
name = n;
configure_cmd;
depend_cmd;
build_cmd;
packages;
keys;
jobs;
init;
src;
} =
let jobs = Impl.simplify ~full ~context jobs in
let device_graph = Impl.eval ~context jobs in
let packages = Key.(pure List.append $ packages $ Engine.packages jobs) in
Expand Down Expand Up @@ -121,9 +143,9 @@ module Make (P : S) = struct
|> List.map (fun x -> "\"" ^ x ^ "\"")
|> String.concat ~sep:" "
in
Fmt.str {|"%s" "configure" %s|} P.name command_line_arguments,
Fmt.str {|make "depend"|},
Fmt.str {|"%s" "build"|} P.name
( Fmt.str {|"%s" "configure" %s|} P.name command_line_arguments,
Fmt.str {|make "depend"|},
Fmt.str {|"%s" "build"|} P.name )

(* STAGE 2 *)

Expand Down Expand Up @@ -473,8 +495,8 @@ module Make (P : S) = struct
let configure_cmd, depend_cmd, build_cmd = get_build_cmd args in
let main_dev = P.create (init @ jobs) in
let c =
Config.v ~config_file ?keys ?packages ~init ~configure_cmd
~depend_cmd ~build_cmd ~src name main_dev
Config.v ~config_file ?keys ?packages ~init ~configure_cmd ~depend_cmd
~build_cmd ~src name main_dev
in
run_configure_with_argv argv args c
in
Expand Down
15 changes: 7 additions & 8 deletions lib/functoria/opam.ml
Expand Up @@ -142,8 +142,8 @@ type t = {
src : string option;
}

let v ?configure ?depend ?build ?(install = Install.empty)
?(extra_repo = []) ?(depends = []) ?(pins = []) ~src name =
let v ?configure ?depend ?build ?(install = Install.empty) ?(extra_repo = [])
?(depends = []) ?(pins = []) ~src name =
let src =
match src with `Auto -> guess_src () | `None -> None | `Some d -> Some d
in
Expand Down Expand Up @@ -174,8 +174,9 @@ let pp ppf t =
Fmt.pf ppf "\n%a\n" (Fmt.list ~sep:(Fmt.any "\n") (Fmt.fmt " [ %s ]")) vals
in
let pp_repo =
Fmt.(list ~sep:(any "\n")
(brackets (pair ~sep:(any " ") (quote string) (quote string))))
Fmt.(
list ~sep:(any "\n")
(brackets (pair ~sep:(any " ") (quote string) (quote string))))
in
let switch_packages =
List.filter_map
Expand Down Expand Up @@ -210,9 +211,7 @@ x-mirage-extra-repo: [%a]

x-opam-monorepo-opam-provided: [%a]
%a%a|}
t.name pp_build (t.configure, t.build) Install.pp_opam t.install
pp_packages t.depends
pp_build (t.configure, t.depend)
pp_repo t.extra_repo
t.name pp_build (t.configure, t.build) Install.pp_opam t.install pp_packages
t.depends pp_build (t.configure, t.depend) pp_repo t.extra_repo
(Fmt.list pp_switch_package)
switch_packages pp_src t.src pp_pins t.pins
4 changes: 2 additions & 2 deletions test/functoria-test/functoria_test.ml
Expand Up @@ -17,8 +17,8 @@ let run ?(keys = []) ?init context device =
let keys = keys @ Key.Set.elements (Engine.all_keys t) in
let packages = Key.eval context (Engine.packages t) in
let info =
Functoria.Info.v ~packages ~context ~keys ~build_cmd:"build me"
~src:`None "foo"
Functoria.Info.v ~packages ~context ~keys ~build_cmd:"build me" ~src:`None
"foo"
in
let t = Impl.eval ~context t in
let* () = prelude info in
Expand Down

0 comments on commit 4b2a168

Please sign in to comment.