-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate common from package ml generator
- Loading branch information
1 parent
22b9c89
commit 582b935
Showing
3 changed files
with
82 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
open Dkml_install_runner.Error_handling.Monad_syntax | ||
module Arg = Cmdliner.Arg | ||
module Cmd = Cmdliner.Cmd | ||
module Term = Cmdliner.Term | ||
|
||
let copy_as_is file = | ||
let content = | ||
match Code.read file with | ||
| Some x -> x | ||
| None -> failwith (Fmt.str "No %s in crunched common_code.ml" file) | ||
in | ||
Dkml_install_runner.Error_handling.continue_or_exit | ||
@@ Dkml_install_runner.Error_handling.map_rresult_error_to_progress | ||
@@ Dkml_install_runner.Error_handling.continue_or_exit | ||
@@ Dkml_install_runner.Error_handling.map_rresult_error_to_progress | ||
@@ Bos.OS.File.with_oc (Fpath.v file) | ||
(fun oc () -> | ||
let fmt = Format.formatter_of_out_channel oc in | ||
Fmt.pf fmt "%s" content; | ||
Format.pp_print_flush fmt (); | ||
Ok ()) | ||
() | ||
|
||
let main () = | ||
let components = Common_installer_generator.ocamlfind () in | ||
|
||
let copy ~target_abi ~components filename = | ||
let content = Option.get (Code.read filename) in | ||
Dkml_install_runner.Error_handling.continue_or_exit | ||
@@ Dkml_install_runner.Error_handling.map_rresult_error_to_progress | ||
@@ Ml_of_installer_generator_lib.copy_with_templates ~target_abi ~components | ||
~output_file:(Fpath.v filename) content | ||
in | ||
|
||
Dkml_install_runner.Error_handling.continue_or_exit | ||
(let* target_abi, _fl = Dkml_install_runner.Ocaml_abi.create_v2 () in | ||
copy_as_is "discover.ml"; | ||
copy_as_is "entry-application.manifest"; | ||
copy ~target_abi ~components "entry_assembly_manifest.ml"; | ||
return ()) | ||
|
||
let main_t = Term.(const main $ const ()) | ||
|
||
let () = | ||
let doc = | ||
"Writes $(b,.ml) files that are used by dune-of-installer-generator.exe" | ||
in | ||
exit | ||
(Dkml_install_runner.Error_handling.catch_and_exit_on_error ~id:"878ee300" | ||
(fun () -> | ||
Cmd.( | ||
eval ~catch:false (v (info "common-ml-of-installer-generator" ~doc) main_t)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,37 @@ | ||
(rule | ||
(deps | ||
(glob_files code/*.ml) | ||
(glob_files code/*.manifest)) | ||
(target code.ml) | ||
(action | ||
(run ocaml-crunch -m plain -e ml -e manifest -o %{target} code/))) | ||
|
||
(library | ||
(name code) | ||
(modules code)) | ||
|
||
(executable | ||
(package dkml-install-installer) | ||
(name main) | ||
(public_name ml-of-installer-generator) | ||
(public_name common-ml-of-installer-generator) | ||
(name common_main) | ||
(modules common_main) | ||
(libraries | ||
bos | ||
cmdliner | ||
code | ||
common_installer_generator | ||
dkml-install-runner | ||
ml_of_installer_generator_lib)) | ||
|
||
(rule | ||
(deps | ||
(glob_files code/*.ml) | ||
(glob_files code/*.manifest)) | ||
(target code.ml) | ||
(action | ||
(run ocaml-crunch -m plain -e ml -e manifest -o %{target} code/))) | ||
(executable | ||
(package dkml-install-installer) | ||
(public_name package-ml-of-installer-generator) | ||
(name package_main) | ||
(modules package_main) | ||
(libraries | ||
bos | ||
cmdliner | ||
code | ||
common_installer_generator | ||
dkml-install-runner | ||
ml_of_installer_generator_lib)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters