Jelajahi Sumber

only load a native lib once we actually need it

Simon Krajewski 1 tahun lalu
induk
melakukan
ba140a7bc7
1 mengubah file dengan 10 tambahan dan 2 penghapusan
  1. 10 2
      src/context/commonCache.ml

+ 10 - 2
src/context/commonCache.ml

@@ -26,7 +26,15 @@ end
 
 let handle_native_lib com lib =
 	com.native_libs.all_libs <- lib#get_file_path :: com.native_libs.all_libs;
-	com.load_extern_type <- com.load_extern_type @ [lib#get_file_path,lib#build];
+	let build path =
+		(* The first build has to load, afterwards we install a direct lib#build call. *)
+		lib#load;
+		com.load_extern_type <- List.map (fun (name,f) ->
+			name,if name = lib#get_file_path then lib#build else f
+		) com.load_extern_type;
+		lib#build path;
+	in
+	com.load_extern_type <- com.load_extern_type @ [lib#get_file_path,build];
 	if not (Define.raw_defined com.defines "haxe.noNativeLibsCache") then begin
 		let cs = com.cs in
 		let init () =
@@ -54,7 +62,7 @@ let handle_native_lib com lib =
 					name,if name = lib#get_file_path then build else f
 				) com.load_extern_type
 			| None ->
-				lib#load
+				()
 		)
 	end else
 		(* Offline mode, just read library as usual. *)