Skip to content

Commit

Permalink
Merge pull request mirage#1237 from TheLortex/move-dist-folder
Browse files Browse the repository at this point in the history
Move dist/ folder to where the config.ml resides
  • Loading branch information
samoht authored Oct 11, 2021
2 parents 006e714 + 8183eb1 commit c2590f5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 22 deletions.
14 changes: 5 additions & 9 deletions lib/functoria/install.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ let pp_opam ppf t =
(Fmt.list ~sep:(Fmt.any "\n") (fun ppf -> Fmt.pf ppf " [ %a ]" pp_etc))
t.etc

let promote_artifact ~build_dir ~context_name ~src ~dst =
let promote_artifact ~context_name ~src ~dst =
Dune.stanzaf
{|
(rule
Expand All @@ -68,18 +68,14 @@ let promote_artifact ~build_dir ~context_name ~src ~dst =
)
|}
Fpath.pp dst context_name Fpath.pp
Fpath.(build_dir // src)
Fpath.(v ".." // src)

let dune ~build_dir ~context_name t =
let dune ~context_name t =
let bin_rules =
List.map
(fun (src, dst) -> promote_artifact ~build_dir ~context_name ~src ~dst)
t.bin
List.map (fun (src, dst) -> promote_artifact ~context_name ~src ~dst) t.bin
in
let etc_rules =
List.map
(fun etc -> promote_artifact ~build_dir ~context_name ~src:etc ~dst:etc)
t.etc
List.map (fun etc -> promote_artifact ~context_name ~src:etc ~dst:etc) t.etc
in
Dune.v (bin_rules @ etc_rules)

Expand Down
6 changes: 3 additions & 3 deletions lib/functoria/install.mli
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ val pp : t Fmt.t
val pp_opam : t Fmt.t
(** Print the opam rules to install [t] *)

val dune : build_dir:Fpath.t -> context_name:string -> t -> Dune.t
(** [dune ~build_dir ~context_name ()] is the dune rules to promote installed
files back in the source tree. *)
val dune : context_name:string -> t -> Dune.t
(** [dune ~context_name ()] is the dune rules to promote installed files back in
the source tree. *)

val dump : t Fmt.t
(** Dump installation rules. *)
16 changes: 6 additions & 10 deletions lib/functoria/lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module Make (P : S) = struct

let mirage_dir args = Fpath.(build_dir args / P.name)

let artifacts_dir = Fpath.v "dist"
let artifacts_dir args = Fpath.(build_dir args / "dist")

let exit_err args = function
| Ok v -> v
Expand Down Expand Up @@ -250,9 +250,7 @@ module Make (P : S) = struct
| `Dune `Dist ->
let install = Key.eval (Info.context info) (Engine.install info jobs) in
Fmt.pr "%a\n%!" Dune.pp
(Install.dune
~build_dir:Fpath.(v ".." // build_dir)
~context_name:(P.context_name info) install)
(Install.dune ~context_name:(P.context_name info) install)

(* Configuration step. *)

Expand Down Expand Up @@ -310,15 +308,13 @@ module Make (P : S) = struct
Key.eval (Info.context info) (Engine.install info jobs)
in
Fmt.str "%a\n" Dune.pp
(Install.dune
~build_dir:Fpath.(v ".." // build_dir)
~context_name:(P.context_name info) install)
(Install.dune ~context_name:(P.context_name info) install)
in
Filegen.write file contents

let clean (args : _ Cli.clean_args) =
let* () = Action.rmdir (mirage_dir args) in
Action.rmdir artifacts_dir
Action.rmdir (artifacts_dir args)

let generate_makefile ~build_dir ~depext ~extra_repo name =
let file = Fpath.(v "Makefile") in
Expand Down Expand Up @@ -354,8 +350,8 @@ module Make (P : S) = struct
(* dune-project *)
let* () = generate_dune `Project args () in
(* Get install spec *)
let* _ = Action.mkdir artifacts_dir in
Action.with_dir artifacts_dir (generate_dune `Dist args)
let* _ = Action.mkdir (artifacts_dir args) in
Action.with_dir (artifacts_dir args) (generate_dune `Dist args)

let ok () = Action.ok ()

Expand Down
2 changes: 2 additions & 0 deletions test/functoria/e2e/build.t
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Build an application.
..
app.ml
config.ml
dist
dune
dune.build
dune.config
Expand Down Expand Up @@ -71,6 +72,7 @@ Test `--output`:
..
app.ml
config.ml
dist
dune
dune.build
dune.config
Expand Down
2 changes: 2 additions & 0 deletions test/functoria/e2e/clean.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Make sure that clean remove everything:
..
app.ml
config.ml
dist
dune
dune.build
dune.config
Expand Down Expand Up @@ -55,6 +56,7 @@ Check that clean works with `--output`:
..
app.ml
config.ml
dist
dune
dune.build
dune.config
Expand Down
1 change: 1 addition & 0 deletions test/functoria/e2e/configure.t
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ is passed:
..
app.ml
config.ml
dist
dune
dune.build
dune.config
Expand Down

0 comments on commit c2590f5

Please sign in to comment.