Skip to content

Commit 7f88d92

Browse files
authored
Merge pull request #3884 from BuckleScript/snapshot_for_4.06
Snapshot compiler upgrade not using temporary file
2 parents 1ab2a74 + 4d5008b commit 7f88d92

File tree

7 files changed

+67
-2
lines changed

7 files changed

+67
-2
lines changed

lib/4.06.1/bsdep.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,9 @@ val copy_file_chunk: in_channel -> out_channel -> int -> unit
770770
val string_of_file: in_channel -> string
771771
(* [string_of_file ic] reads the contents of file [ic] and copies
772772
them to a string. It stops when encountering EOF on [ic]. *)
773+
774+
val output_to_bin_file_directly: string -> (string -> out_channel -> 'a) -> 'a
775+
773776
val output_to_file_via_temporary:
774777
?mode:open_flag list -> string -> (string -> out_channel -> 'a) -> 'a
775778
(* Produce output in temporary file, then rename it
@@ -1269,6 +1272,12 @@ let string_of_file ic =
12691272
(Buffer.add_subbytes b buff 0 n; copy())
12701273
in copy()
12711274

1275+
let output_to_bin_file_directly filename fn =
1276+
let oc = Pervasives.open_out_bin filename in
1277+
match fn filename oc with
1278+
| v -> close_out oc ; v
1279+
| exception e -> close_out oc ; raise e
1280+
12721281
let output_to_file_via_temporary ?(mode = [Open_text]) filename fn =
12731282
let (temp_filename, oc) =
12741283
Filename.open_temp_file

lib/4.06.1/bspp.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,9 @@ val copy_file_chunk: in_channel -> out_channel -> int -> unit
707707
val string_of_file: in_channel -> string
708708
(* [string_of_file ic] reads the contents of file [ic] and copies
709709
them to a string. It stops when encountering EOF on [ic]. *)
710+
711+
val output_to_bin_file_directly: string -> (string -> out_channel -> 'a) -> 'a
712+
710713
val output_to_file_via_temporary:
711714
?mode:open_flag list -> string -> (string -> out_channel -> 'a) -> 'a
712715
(* Produce output in temporary file, then rename it
@@ -1206,6 +1209,12 @@ let string_of_file ic =
12061209
(Buffer.add_subbytes b buff 0 n; copy())
12071210
in copy()
12081211

1212+
let output_to_bin_file_directly filename fn =
1213+
let oc = Pervasives.open_out_bin filename in
1214+
match fn filename oc with
1215+
| v -> close_out oc ; v
1216+
| exception e -> close_out oc ; raise e
1217+
12091218
let output_to_file_via_temporary ?(mode = [Open_text]) filename fn =
12101219
let (temp_filename, oc) =
12111220
Filename.open_temp_file

lib/4.06.1/bsppx.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,9 @@ val copy_file_chunk: in_channel -> out_channel -> int -> unit
707707
val string_of_file: in_channel -> string
708708
(* [string_of_file ic] reads the contents of file [ic] and copies
709709
them to a string. It stops when encountering EOF on [ic]. *)
710+
711+
val output_to_bin_file_directly: string -> (string -> out_channel -> 'a) -> 'a
712+
710713
val output_to_file_via_temporary:
711714
?mode:open_flag list -> string -> (string -> out_channel -> 'a) -> 'a
712715
(* Produce output in temporary file, then rename it
@@ -1206,6 +1209,12 @@ let string_of_file ic =
12061209
(Buffer.add_subbytes b buff 0 n; copy())
12071210
in copy()
12081211

1212+
let output_to_bin_file_directly filename fn =
1213+
let oc = Pervasives.open_out_bin filename in
1214+
match fn filename oc with
1215+
| v -> close_out oc ; v
1216+
| exception e -> close_out oc ; raise e
1217+
12091218
let output_to_file_via_temporary ?(mode = [Open_text]) filename fn =
12101219
let (temp_filename, oc) =
12111220
Filename.open_temp_file

lib/4.06.1/unstable/bspack.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,9 @@ val copy_file_chunk: in_channel -> out_channel -> int -> unit
707707
val string_of_file: in_channel -> string
708708
(* [string_of_file ic] reads the contents of file [ic] and copies
709709
them to a string. It stops when encountering EOF on [ic]. *)
710+
711+
val output_to_bin_file_directly: string -> (string -> out_channel -> 'a) -> 'a
712+
710713
val output_to_file_via_temporary:
711714
?mode:open_flag list -> string -> (string -> out_channel -> 'a) -> 'a
712715
(* Produce output in temporary file, then rename it
@@ -1206,6 +1209,12 @@ let string_of_file ic =
12061209
(Buffer.add_subbytes b buff 0 n; copy())
12071210
in copy()
12081211

1212+
let output_to_bin_file_directly filename fn =
1213+
let oc = Pervasives.open_out_bin filename in
1214+
match fn filename oc with
1215+
| v -> close_out oc ; v
1216+
| exception e -> close_out oc ; raise e
1217+
12091218
let output_to_file_via_temporary ?(mode = [Open_text]) filename fn =
12101219
let (temp_filename, oc) =
12111220
Filename.open_temp_file

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,9 @@ val copy_file_chunk: in_channel -> out_channel -> int -> unit
707707
val string_of_file: in_channel -> string
708708
(* [string_of_file ic] reads the contents of file [ic] and copies
709709
them to a string. It stops when encountering EOF on [ic]. *)
710+
711+
val output_to_bin_file_directly: string -> (string -> out_channel -> 'a) -> 'a
712+
710713
val output_to_file_via_temporary:
711714
?mode:open_flag list -> string -> (string -> out_channel -> 'a) -> 'a
712715
(* Produce output in temporary file, then rename it
@@ -1206,6 +1209,12 @@ let string_of_file ic =
12061209
(Buffer.add_subbytes b buff 0 n; copy())
12071210
in copy()
12081211

1212+
let output_to_bin_file_directly filename fn =
1213+
let oc = Pervasives.open_out_bin filename in
1214+
match fn filename oc with
1215+
| v -> close_out oc ; v
1216+
| exception e -> close_out oc ; raise e
1217+
12091218
let output_to_file_via_temporary ?(mode = [Open_text]) filename fn =
12101219
let (temp_filename, oc) =
12111220
Filename.open_temp_file
@@ -57055,8 +57064,9 @@ let record_value_dependency vd1 vd2 =
5705557064

5705657065
let save_cmt filename modname binary_annots sourcefile initial_env cmi =
5705757066
if !Clflags.binary_annotations && not !Clflags.print_types then begin
57067+
(if !Clflags.bs_only then Misc.output_to_bin_file_directly else
5705857068
Misc.output_to_file_via_temporary
57059-
~mode:[Open_binary] filename
57069+
~mode:[Open_binary] ) filename
5706057070
(fun temp_file_name oc ->
5706157071
let this_crc =
5706257072
match cmi with

lib/4.06.1/unstable/native_ppx.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,9 @@ val copy_file_chunk: in_channel -> out_channel -> int -> unit
707707
val string_of_file: in_channel -> string
708708
(* [string_of_file ic] reads the contents of file [ic] and copies
709709
them to a string. It stops when encountering EOF on [ic]. *)
710+
711+
val output_to_bin_file_directly: string -> (string -> out_channel -> 'a) -> 'a
712+
710713
val output_to_file_via_temporary:
711714
?mode:open_flag list -> string -> (string -> out_channel -> 'a) -> 'a
712715
(* Produce output in temporary file, then rename it
@@ -1206,6 +1209,12 @@ let string_of_file ic =
12061209
(Buffer.add_subbytes b buff 0 n; copy())
12071210
in copy()
12081211

1212+
let output_to_bin_file_directly filename fn =
1213+
let oc = Pervasives.open_out_bin filename in
1214+
match fn filename oc with
1215+
| v -> close_out oc ; v
1216+
| exception e -> close_out oc ; raise e
1217+
12091218
let output_to_file_via_temporary ?(mode = [Open_text]) filename fn =
12101219
let (temp_filename, oc) =
12111220
Filename.open_temp_file

lib/4.06.1/whole_compiler.ml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,9 @@ val copy_file_chunk: in_channel -> out_channel -> int -> unit
707707
val string_of_file: in_channel -> string
708708
(* [string_of_file ic] reads the contents of file [ic] and copies
709709
them to a string. It stops when encountering EOF on [ic]. *)
710+
711+
val output_to_bin_file_directly: string -> (string -> out_channel -> 'a) -> 'a
712+
710713
val output_to_file_via_temporary:
711714
?mode:open_flag list -> string -> (string -> out_channel -> 'a) -> 'a
712715
(* Produce output in temporary file, then rename it
@@ -1206,6 +1209,12 @@ let string_of_file ic =
12061209
(Buffer.add_subbytes b buff 0 n; copy())
12071210
in copy()
12081211

1212+
let output_to_bin_file_directly filename fn =
1213+
let oc = Pervasives.open_out_bin filename in
1214+
match fn filename oc with
1215+
| v -> close_out oc ; v
1216+
| exception e -> close_out oc ; raise e
1217+
12091218
let output_to_file_via_temporary ?(mode = [Open_text]) filename fn =
12101219
let (temp_filename, oc) =
12111220
Filename.open_temp_file
@@ -45313,8 +45322,9 @@ let record_value_dependency vd1 vd2 =
4531345322

4531445323
let save_cmt filename modname binary_annots sourcefile initial_env cmi =
4531545324
if !Clflags.binary_annotations && not !Clflags.print_types then begin
45325+
(if !Clflags.bs_only then Misc.output_to_bin_file_directly else
4531645326
Misc.output_to_file_via_temporary
45317-
~mode:[Open_binary] filename
45327+
~mode:[Open_binary] ) filename
4531845328
(fun temp_file_name oc ->
4531945329
let this_crc =
4532045330
match cmi with

0 commit comments

Comments
 (0)