Skip to content
This repository has been archived by the owner on Aug 25, 2022. It is now read-only.

Update names #174

Merged
merged 2 commits into from
Jul 30, 2019
Merged
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
35 changes: 20 additions & 15 deletions app/functoria_app.ml
Original file line number Diff line number Diff line change
Expand Up @@ -537,13 +537,13 @@ module Make (P: S) = struct
>>| fun () -> true)
| false -> Ok false

(* Generate a dune file in the build-config directory.
(* Generate a dune file in the config directory.
If a `dune.config` file exists, it's included in the generated dune file
and a `config_custom` dummy dependency is created to allow external
and a `mirage_config` dummy dependency is created to allow external
dependencies through transitive closure.
An example dune.config file:
(library
(name config_custom)
(name mirage_config)
(libraries foo bar dep)
(modules)
)
Expand All @@ -561,18 +561,23 @@ module Make (P: S) = struct
) String.Set.empty pkgs
|> String.Set.elements
in
let pkgs = if has_dune_config then "config_custom"::pkgs else pkgs
let pkgs = if has_dune_config then "mirage_config"::pkgs else pkgs
in
String.concat ~sep:" " pkgs
in
let dune_content_default =
Format.sprintf
{|(executable (name config) (modules config) (libraries %s))
(alias
(name config)
(enabled_if (= %%{context_name} default))
(deps config.exe))
|} pkgs
{|;; DO NOT EDIT: auto-generated by 'mirage configure'
(executable
(name config)
(modules config)
(libraries %s))

(alias
(name config)
(enabled_if (= %%{context_name} default))
(deps config.exe))
|} pkgs
in
let dune_content =
if has_dune_config
Expand All @@ -583,13 +588,13 @@ module Make (P: S) = struct
>>= fun () -> Bos.OS.File.write dune_file dune_content

(* Set up everything needed to build the configuration file inside a
separate build-config directory. *)
separate config/ directory. *)
let configure_build_config_directory ~config_dir ~build_config_dir () =
let config_file_name = Fpath.basename (!config_file) in
let dune_project_file = Fpath.(build_config_dir / "dune-project")
in
Bos.OS.Dir.create build_config_dir >>= fun _ ->
(* Symlink config.ml inside the build-config directory *)
(* Symlink config.ml inside the config/ directory *)
Bos.OS.Path.symlink
~force:true
~target:(Fpath.(config_dir / config_file_name))
Expand Down Expand Up @@ -618,7 +623,7 @@ module Make (P: S) = struct

(* Compile the configuration file. *)
let compile () =
let build_config_name = "build-config" in
let build_config_name = "config" in
let build_dir = get_build_dir () in
let build_config_dir = Fpath.(build_dir / build_config_name) in
let config_dir = get_config_dir ()
Expand Down Expand Up @@ -813,7 +818,7 @@ module Make (P: S) = struct
acc >>= fun () ->
match Fpath.basename target with
| "_build" -> Ok ()
| "build-config" -> Ok ()
| "config" -> Ok ()
| b ->
if Fpath.basename !config_file = b then Ok ()
else (
Expand All @@ -837,7 +842,7 @@ module Make (P: S) = struct
(fun () ->
clean_main i job >>= fun () ->
Bos.OS.Dir.delete ~recurse:true (Fpath.v "_build") >>= fun () ->
Bos.OS.Dir.delete ~recurse:true (Fpath.v "build-config") >>= fun () ->
Bos.OS.Dir.delete ~recurse:true (Fpath.v "config") >>= fun () ->
Cache.clean (Info.build_dir i) >>= fun () ->
Bos.OS.File.delete (Fpath.v "log"))
"clean"
Expand Down
7 changes: 3 additions & 4 deletions tests/app/dune.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(library
(name config_custom)
(libraries functoria.test)
(modules)
)
(name mirage_config)
(libraries functoria.test)
(modules))
6 changes: 3 additions & 3 deletions tests/test_full.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let read_file file = get_ok @@ Bos.OS.File.read Fpath.(v file)

let clean_app () =
get_ok @@ Bos.OS.Dir.delete ~recurse:true Fpath.(v "app/_build");
get_ok @@ Bos.OS.Dir.delete ~recurse:true Fpath.(v "app/build-config");
get_ok @@ Bos.OS.Dir.delete ~recurse:true Fpath.(v "app/config");
let files = list_files "app" in
List.iter (fun f ->
match Filename.basename f with
Expand Down Expand Up @@ -87,7 +87,7 @@ let test_configure () =
test "configure -vv --file app/config.ml";
Alcotest.(check files) "new files should be created in the source dir"
["app.ml"; "config.ml"; "dune.config"; "key_gen.ml";
"main.ml"; ".mirage.config"; "dune"; "build-config"; "_build"] (list_files "app");
"main.ml"; ".mirage.config"; "dune"; "config"; "_build"] (list_files "app");
clean_app ();

(* check that configure generates the file in the right dir when
Expand All @@ -101,7 +101,7 @@ let test_configure () =
(list_files "app");
Alcotest.(check files) "other files should be created in custom_build_"
["main.ml"; "app.ml"; "dune.config"; ".mirage.config"; "dune"; "key_gen.ml";
"build-config"; "_build"
"config"; "_build"
(* FIXME: add a .mirage-ignore file to avoid this *) ]
(list_files "custom_build_");
clean_build ();
Expand Down