@@ -7803,10 +7803,9 @@ type dep_info = {
78037803
78047804type check_result =
78057805 | Good
7806- | Bsb_file_not_exist (* * We assume that it is a clean repo *)
7807- | Bsb_version_mismatch
7806+ | Bsb_file_not_exist (* * We assume that it is a clean repo *)
78087807 | Bsb_source_directory_changed
7809- | Bsc_version_mismatch
7808+ | Bsb_bsc_version_mismatch
78107809 | Bsb_forced
78117810 | Other of string
78127811
@@ -7856,45 +7855,36 @@ type t =
78567855 }
78577856
78587857
7859- let magic_number = " BS_DEP_INFOS_20161116"
7860- let bsb_version = " 20160121+dev"
7858+ let magic_number = " BS_DEP_INFOS_20170209"
7859+ let bsb_version = " 20170209+dev"
7860+ (* TODO: for such small data structure, maybe text format is better *)
78617861
78627862let write (fname : string ) (x : t ) =
78637863 let oc = open_out_bin fname in
78647864 output_string oc magic_number ;
78657865 output_value oc x ;
78667866 close_out oc
78677867
7868- let read (fname : string ) : t =
7869- let ic = open_in_bin fname in (* Windows binary mode*)
7870- let buffer = really_input_string ic (String. length magic_number) in
7871- assert (buffer = magic_number);
7872- let res : t = input_value ic in
7873- close_in ic ;
7874- res
7875-
78767868
78777869
78787870
78797871
78807872type check_result =
78817873 | Good
78827874 | Bsb_file_not_exist (* * We assume that it is a clean repo *)
7883- | Bsb_version_mismatch
78847875 | Bsb_source_directory_changed
7885- | Bsc_version_mismatch
7876+ | Bsb_bsc_version_mismatch
78867877 | Bsb_forced
78877878 | Other of string
78887879
78897880let to_str (check_resoult : check_result ) =
78907881 match check_resoult with
78917882 | Good -> Ext_string. empty
78927883 | Bsb_file_not_exist -> " File not found"
7893- | Bsb_version_mismatch -> " Bsb version mismatch"
78947884 | Bsb_source_directory_changed ->
78957885 " Bsb source directory changed"
7896- | Bsc_version_mismatch ->
7897- " Bsc version mismatch"
7886+ | Bsb_bsc_version_mismatch ->
7887+ " bsc or bsb version mismatch"
78987888 | Bsb_forced ->
78997889 " Bsb forced rebuild "
79007890 | Other s ->
@@ -7910,33 +7900,46 @@ let rec check_aux xs i finish =
79107900 check_aux xs (i + 1 ) finish
79117901 else Other current_file
79127902
7913-
7903+
7904+ let read (fname : string ) cont =
7905+ match open_in_bin fname with (* Windows binary mode*)
7906+ | ic ->
7907+ let buffer = really_input_string ic (String. length magic_number) in
7908+ if (buffer <> magic_number) then Bsb_bsc_version_mismatch
7909+ else
7910+ let res : t = input_value ic in
7911+ close_in ic ;
7912+ cont res
7913+ | exception _ -> Bsb_file_not_exist
7914+
7915+
79147916(* * check time stamp for all files
79157917 TODO: those checks system call can be saved later
79167918 Return a reason
79177919 Even forced, we still need walk through a little
79187920 bit in case we found a different version of compiler
79197921*)
79207922let check ~cwd forced file =
7921- try
7922- let {
7923- file_stamps = xs; source_directory; bsb_version = old_version;
7924- bsc_version
7925- } = read file in
7926- if old_version <> bsb_version then Bsb_version_mismatch else
7923+ read file begin function {
7924+ file_stamps = xs; source_directory; bsb_version = old_version;
7925+ bsc_version
7926+ } ->
7927+ if old_version <> bsb_version then Bsb_bsc_version_mismatch else
79277928 if cwd <> source_directory then Bsb_source_directory_changed else
7928- if bsc_version <> Bs_version. version then Bsc_version_mismatch else
7929+ if bsc_version <> Bs_version. version then Bsb_bsc_version_mismatch else
79297930 if forced then Bsb_forced (* No need walk through *)
79307931 else
7931- check_aux xs 0 (Array. length xs)
7932- with _ -> Bsb_file_not_exist
7932+ try
7933+ check_aux xs 0 (Array. length xs)
7934+ with _ -> Bsb_file_not_exist
7935+ end
79337936
79347937let store ~cwd name file_stamps =
79357938 write name
7936- { file_stamps ;
7937- source_directory = cwd ;
7938- bsb_version ;
7939- bsc_version = Bs_version. version }
7939+ { file_stamps ;
7940+ source_directory = cwd ;
7941+ bsb_version ;
7942+ bsc_version = Bs_version. version }
79407943
79417944end
79427945module Bsb_file : sig
@@ -9048,14 +9051,13 @@ let regenerate_ninja cwd bsc_dir forced =
90489051 begin match reason with
90499052 | Good -> None (* Fast path *)
90509053 | Bsb_forced
9051- | Bsc_version_mismatch
9054+ | Bsb_bsc_version_mismatch
90529055 | Bsb_file_not_exist
9053- | Bsb_version_mismatch
90549056 | Bsb_source_directory_changed
90559057 | Other _ ->
90569058 print_string " Regenerating build spec : " ;
90579059 print_endline (Bsb_dep_infos. to_str reason) ;
9058- if reason = Bsc_version_mismatch then begin
9060+ if reason = Bsb_bsc_version_mismatch then begin
90599061 print_endline " Also clean current repo due to we have detected a different compiler" ;
90609062 clean_self () ;
90619063 end ;
0 commit comments