Skip to content

Commit 3dc06bb

Browse files
committed
use st_atime to work around npm issues, always record rescript.exe timestamp
1 parent b34adad commit 3dc06bb

File tree

4 files changed

+51
-57
lines changed

4 files changed

+51
-57
lines changed

jscomp/bsb/bsb_ninja_check.ml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ let rec check_aux cwd (xs : string list) =
6666
match xs with
6767
| [] -> Good
6868
| "===" :: rest ->
69-
check_global rest
69+
check_global_atime rest
7070
| item :: rest
7171
->
7272
match Ext_string.split item '\t' with
@@ -78,7 +78,7 @@ let rec check_aux cwd (xs : string list) =
7878
check_aux cwd rest
7979
else Other cur_file
8080
| _ -> Bsb_file_corrupted
81-
and check_global rest =
81+
and check_global_atime rest =
8282
match rest with
8383
| [] -> Good
8484
| item :: rest ->
@@ -87,20 +87,22 @@ and check_global rest =
8787
let stamp = float_of_string stamp in
8888
let cur_file = file in
8989
let stat = Unix.stat cur_file in
90-
if stat.st_mtime <> stamp then
91-
check_global rest
90+
if stat.st_atime <= stamp then
91+
check_global_atime rest
9292
else Other cur_file
9393
| _ -> Bsb_file_corrupted
9494

9595

9696
(* TODO: for such small data structure, maybe text format is better *)
9797

98-
98+
let record_global_atime buf name =
99+
let stamp = (Unix.stat name).st_atime in
100+
Ext_buffer.add_string_char buf name '\t';
101+
Ext_buffer.add_string_char buf (hex_of_float stamp) '\n'
99102
let record
100103
~(package_kind : Bsb_package_kind.t)
101104
~per_proj_dir ~file
102105
~(config:Bsb_config_types.t) (file_or_dirs : string list) : unit =
103-
let _ = config in
104106
let buf = Ext_buffer.create 1_000 in
105107
Ext_buffer.add_string_char buf Bs_version.version '\n';
106108
Ext_buffer.add_string_char buf per_proj_dir '\n';
@@ -114,17 +116,13 @@ let record
114116
Ext_buffer.add_string_char buf
115117
(hex_of_float (Unix.stat (Filename.concat per_proj_dir f)).st_mtime) '\n';
116118
);
117-
begin match config.ppx_files with
118-
| [] -> ()
119-
| files ->
120-
Ext_buffer.add_string buf "===\n";
121-
Ext_list.iter files (fun {name ; args = _} ->
122-
try
123-
let stamp = (Unix.stat name).st_mtime in
124-
Ext_buffer.add_string_char buf name '\t';
125-
Ext_buffer.add_string_char buf (hex_of_float stamp) '\n'
126-
with _ -> ())
127-
end;
119+
Ext_buffer.add_string buf "===\n";
120+
record_global_atime buf Sys.executable_name;
121+
Ext_list.iter config.ppx_files (fun {name ; args = _} ->
122+
try
123+
record_global_atime buf name
124+
with _ -> (* record the ppx files as a best effort *)
125+
());
128126
let oc = open_out_bin file in
129127
Ext_buffer.output_buffer oc buf ;
130128
close_out oc

jscomp/bsb/bsb_ninja_regen.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ let regenerate_ninja
4242
~package_kind
4343
~per_proj_dir
4444
~forced ~file:output_deps in
45-
Bsb_log.info
46-
"@{<info>BSB check@} build spec : %a @." Bsb_ninja_check.pp_check_result check_result ;
4745
match check_result with
4846
| Good ->
4947
None (* Fast path, no need regenerate ninja *)
@@ -54,6 +52,8 @@ let regenerate_ninja
5452
| Bsb_file_not_exist
5553
| Bsb_source_directory_changed
5654
| Other _ ->
55+
Bsb_log.info
56+
"@{<info>BSB check@} build spec : %a @." Bsb_ninja_check.pp_check_result check_result;
5757
if check_result = Bsb_bsc_version_mismatch then begin
5858
Bsb_log.warn "@{<info>Different compiler version@}: clean current repo@.";
5959
Bsb_clean.clean_self per_proj_dir;

lib/4.06.1/bsb.ml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12180,7 +12180,7 @@ let rec check_aux cwd (xs : string list) =
1218012180
match xs with
1218112181
| [] -> Good
1218212182
| "===" :: rest ->
12183-
check_global rest
12183+
check_global_atime rest
1218412184
| item :: rest
1218512185
->
1218612186
match Ext_string.split item '\t' with
@@ -12192,7 +12192,7 @@ let rec check_aux cwd (xs : string list) =
1219212192
check_aux cwd rest
1219312193
else Other cur_file
1219412194
| _ -> Bsb_file_corrupted
12195-
and check_global rest =
12195+
and check_global_atime rest =
1219612196
match rest with
1219712197
| [] -> Good
1219812198
| item :: rest ->
@@ -12201,20 +12201,22 @@ and check_global rest =
1220112201
let stamp = float_of_string stamp in
1220212202
let cur_file = file in
1220312203
let stat = Unix.stat cur_file in
12204-
if stat.st_mtime <> stamp then
12205-
check_global rest
12204+
if stat.st_atime <= stamp then
12205+
check_global_atime rest
1220612206
else Other cur_file
1220712207
| _ -> Bsb_file_corrupted
1220812208

1220912209

1221012210
(* TODO: for such small data structure, maybe text format is better *)
1221112211

12212-
12212+
let record_global_atime buf name =
12213+
let stamp = (Unix.stat name).st_atime in
12214+
Ext_buffer.add_string_char buf name '\t';
12215+
Ext_buffer.add_string_char buf (hex_of_float stamp) '\n'
1221312216
let record
1221412217
~(package_kind : Bsb_package_kind.t)
1221512218
~per_proj_dir ~file
1221612219
~(config:Bsb_config_types.t) (file_or_dirs : string list) : unit =
12217-
let _ = config in
1221812220
let buf = Ext_buffer.create 1_000 in
1221912221
Ext_buffer.add_string_char buf Bs_version.version '\n';
1222012222
Ext_buffer.add_string_char buf per_proj_dir '\n';
@@ -12228,17 +12230,13 @@ let record
1222812230
Ext_buffer.add_string_char buf
1222912231
(hex_of_float (Unix.stat (Filename.concat per_proj_dir f)).st_mtime) '\n';
1223012232
);
12231-
begin match config.ppx_files with
12232-
| [] -> ()
12233-
| files ->
12234-
Ext_buffer.add_string buf "===\n";
12235-
Ext_list.iter files (fun {name ; args = _} ->
12236-
try
12237-
let stamp = (Unix.stat name).st_mtime in
12238-
Ext_buffer.add_string_char buf name '\t';
12239-
Ext_buffer.add_string_char buf (hex_of_float stamp) '\n'
12240-
with _ -> ())
12241-
end;
12233+
Ext_buffer.add_string buf "===\n";
12234+
record_global_atime buf Sys.executable_name;
12235+
Ext_list.iter config.ppx_files (fun {name ; args = _} ->
12236+
try
12237+
record_global_atime buf name
12238+
with _ -> (* record the ppx files as a best effort *)
12239+
());
1224212240
let oc = open_out_bin file in
1224312241
Ext_buffer.output_buffer oc buf ;
1224412242
close_out oc
@@ -14163,8 +14161,6 @@ let regenerate_ninja
1416314161
~package_kind
1416414162
~per_proj_dir
1416514163
~forced ~file:output_deps in
14166-
Bsb_log.info
14167-
"@{<info>BSB check@} build spec : %a @." Bsb_ninja_check.pp_check_result check_result ;
1416814164
match check_result with
1416914165
| Good ->
1417014166
None (* Fast path, no need regenerate ninja *)
@@ -14175,6 +14171,8 @@ let regenerate_ninja
1417514171
| Bsb_file_not_exist
1417614172
| Bsb_source_directory_changed
1417714173
| Other _ ->
14174+
Bsb_log.info
14175+
"@{<info>BSB check@} build spec : %a @." Bsb_ninja_check.pp_check_result check_result;
1417814176
if check_result = Bsb_bsc_version_mismatch then begin
1417914177
Bsb_log.warn "@{<info>Different compiler version@}: clean current repo@.";
1418014178
Bsb_clean.clean_self per_proj_dir;

lib/4.06.1/rescript.ml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12180,7 +12180,7 @@ let rec check_aux cwd (xs : string list) =
1218012180
match xs with
1218112181
| [] -> Good
1218212182
| "===" :: rest ->
12183-
check_global rest
12183+
check_global_atime rest
1218412184
| item :: rest
1218512185
->
1218612186
match Ext_string.split item '\t' with
@@ -12192,7 +12192,7 @@ let rec check_aux cwd (xs : string list) =
1219212192
check_aux cwd rest
1219312193
else Other cur_file
1219412194
| _ -> Bsb_file_corrupted
12195-
and check_global rest =
12195+
and check_global_atime rest =
1219612196
match rest with
1219712197
| [] -> Good
1219812198
| item :: rest ->
@@ -12201,20 +12201,22 @@ and check_global rest =
1220112201
let stamp = float_of_string stamp in
1220212202
let cur_file = file in
1220312203
let stat = Unix.stat cur_file in
12204-
if stat.st_mtime <> stamp then
12205-
check_global rest
12204+
if stat.st_atime <= stamp then
12205+
check_global_atime rest
1220612206
else Other cur_file
1220712207
| _ -> Bsb_file_corrupted
1220812208

1220912209

1221012210
(* TODO: for such small data structure, maybe text format is better *)
1221112211

12212-
12212+
let record_global_atime buf name =
12213+
let stamp = (Unix.stat name).st_atime in
12214+
Ext_buffer.add_string_char buf name '\t';
12215+
Ext_buffer.add_string_char buf (hex_of_float stamp) '\n'
1221312216
let record
1221412217
~(package_kind : Bsb_package_kind.t)
1221512218
~per_proj_dir ~file
1221612219
~(config:Bsb_config_types.t) (file_or_dirs : string list) : unit =
12217-
let _ = config in
1221812220
let buf = Ext_buffer.create 1_000 in
1221912221
Ext_buffer.add_string_char buf Bs_version.version '\n';
1222012222
Ext_buffer.add_string_char buf per_proj_dir '\n';
@@ -12228,17 +12230,13 @@ let record
1222812230
Ext_buffer.add_string_char buf
1222912231
(hex_of_float (Unix.stat (Filename.concat per_proj_dir f)).st_mtime) '\n';
1223012232
);
12231-
begin match config.ppx_files with
12232-
| [] -> ()
12233-
| files ->
12234-
Ext_buffer.add_string buf "===\n";
12235-
Ext_list.iter files (fun {name ; args = _} ->
12236-
try
12237-
let stamp = (Unix.stat name).st_mtime in
12238-
Ext_buffer.add_string_char buf name '\t';
12239-
Ext_buffer.add_string_char buf (hex_of_float stamp) '\n'
12240-
with _ -> ())
12241-
end;
12233+
Ext_buffer.add_string buf "===\n";
12234+
record_global_atime buf Sys.executable_name;
12235+
Ext_list.iter config.ppx_files (fun {name ; args = _} ->
12236+
try
12237+
record_global_atime buf name
12238+
with _ -> (* record the ppx files as a best effort *)
12239+
());
1224212240
let oc = open_out_bin file in
1224312241
Ext_buffer.output_buffer oc buf ;
1224412242
close_out oc
@@ -14163,8 +14161,6 @@ let regenerate_ninja
1416314161
~package_kind
1416414162
~per_proj_dir
1416514163
~forced ~file:output_deps in
14166-
Bsb_log.info
14167-
"@{<info>BSB check@} build spec : %a @." Bsb_ninja_check.pp_check_result check_result ;
1416814164
match check_result with
1416914165
| Good ->
1417014166
None (* Fast path, no need regenerate ninja *)
@@ -14175,6 +14171,8 @@ let regenerate_ninja
1417514171
| Bsb_file_not_exist
1417614172
| Bsb_source_directory_changed
1417714173
| Other _ ->
14174+
Bsb_log.info
14175+
"@{<info>BSB check@} build spec : %a @." Bsb_ninja_check.pp_check_result check_result;
1417814176
if check_result = Bsb_bsc_version_mismatch then begin
1417914177
Bsb_log.warn "@{<info>Different compiler version@}: clean current repo@.";
1418014178
Bsb_clean.clean_self per_proj_dir;

0 commit comments

Comments
 (0)