Browse Source

allow loading of .[platform].hx when .hx exists

Nicolas Cannasse 9 năm trước cách đây
mục cha
commit
83a271ceaf
1 tập tin đã thay đổi với 8 bổ sung3 xóa
  1. 8 3
      src/typing/common.ml

+ 8 - 3
src/typing/common.ml

@@ -1006,9 +1006,14 @@ let find_file ctx f =
 			| [] -> loop true [""]
 			| p :: l ->
 				let file = p ^ f in
-				if Sys.file_exists file then
-					file
-				else
+				if Sys.file_exists file then begin
+					(try
+						let ext = String.rindex file '.' in
+						let file_pf = String.sub file 0 (ext + 1) ^ platform_name ctx.platform ^ String.sub file ext (String.length file - ext) in
+						if not (defined ctx Define.CoreApi) && Sys.file_exists file_pf then file_pf else file
+					with Not_found ->
+						file)
+				end else
 					loop (had_empty || p = "") l
 		in
 		let r = (try Some (loop false ctx.class_path) with Not_found -> None) in