summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSon Ho2023-11-27 14:15:01 +0100
committerSon Ho2023-11-27 14:15:01 +0100
commita17eef1053909117d75c9ea8eeaad786626cc05d (patch)
tree4de215bcf14c54eb653095c7ac398b0be10f87de
parentfdb8555cf6bc21ea230141373920196b078bdd28 (diff)
Update the way the Primitives file is copied
Diffstat (limited to '')
-rw-r--r--compiler/Translate.ml33
1 files changed, 20 insertions, 13 deletions
diff --git a/compiler/Translate.ml b/compiler/Translate.ml
index cc84b9fb..37f58140 100644
--- a/compiler/Translate.ml
+++ b/compiler/Translate.ml
@@ -1206,20 +1206,27 @@ let translate_crate (filename : string) (dest_dir : string) (crate : crate) :
match primitives_src_dest with
| None -> ()
| Some (primitives_src, primitives_destname) -> (
- let src = open_in (exe_dir ^ primitives_src) in
- let tgt_filename = Filename.concat dest_dir primitives_destname in
- let tgt = open_out tgt_filename in
- (* Very annoying: I couldn't find a "cp" function in the OCaml libraries... *)
try
- while true do
- (* We copy line by line *)
- let line = input_line src in
- Printf.fprintf tgt "%s\n" line
- done
- with End_of_file ->
- close_in src;
- close_out tgt;
- log#linfo (lazy ("Copied: " ^ tgt_filename)))
+ (* TODO: stop copying the primitives file *)
+ let src = open_in (exe_dir ^ primitives_src) in
+ let tgt_filename = Filename.concat dest_dir primitives_destname in
+ let tgt = open_out tgt_filename in
+ (* Very annoying: I couldn't find a "cp" function in the OCaml libraries... *)
+ try
+ while true do
+ (* We copy line by line *)
+ let line = input_line src in
+ Printf.fprintf tgt "%s\n" line
+ done
+ with End_of_file ->
+ close_in src;
+ close_out tgt;
+ log#linfo (lazy ("Copied: " ^ tgt_filename))
+ with Sys_error _ ->
+ log#error
+ "Could not copy the primitives file: %s.\n\
+ You will have to copy it/set up the project by hand."
+ primitives_src)
in
(* Extract the file(s) *)