Browse Source

[flash] fix lib path resolution being in the wrong place

Simon Krajewski 6 years ago
parent
commit
691301e962
5 changed files with 18 additions and 10 deletions
  1. 1 0
      src/codegen/dotnet.ml
  2. 1 0
      src/codegen/java.ml
  3. 4 3
      src/codegen/swfLoader.ml
  4. 4 7
      src/context/common.ml
  5. 8 0
      src/context/nativeLibraries.ml

+ 1 - 0
src/codegen/dotnet.ml

@@ -1222,6 +1222,7 @@ let add_net_lib com file std =
 	let net_lib = new net_library com file real_file std in
 	com.load_extern_type <- com.load_extern_type @ [net_lib#build];
 	com.native_libs.net_libs <- (net_lib :> (net_lib_type,unit) native_library) :: com.native_libs.net_libs
+	com.native_libs.all_libs <- net_lib#get_file_path :: com.native_libs.all_libs
 
 let before_generate com =
 	(* netcore version *)

+ 1 - 0
src/codegen/java.ml

@@ -1208,6 +1208,7 @@ let add_java_lib com name std =
 	(* TODO: add_dependency m mdep *)
 	com.load_extern_type <- com.load_extern_type @ [build];
 	com.native_libs.java_libs <- (java_lib :> (java_lib_type,unit) native_library) :: com.native_libs.java_libs
+	com.native_libs.all_libs <- java_lib#get_file_path :: com.native_libs.all_libs
 
 let before_generate con =
 	let java_ver = try

+ 4 - 3
src/codegen/swfLoader.ml

@@ -542,7 +542,6 @@ let remove_debug_infos as3 =
 let parse_swf com file =
 	let t = Timer.timer ["read";"swf"] in
 	let is_swc = file_extension file = "swc" || file_extension file = "ane" in
-	let file = (try Common.find_file com file with Not_found -> failwith ((if is_swc then "SWC" else "SWF") ^ " Library not found : " ^ file)) in
 	let ch = if is_swc then begin
 		let zip = Zip.open_in file in
 		try
@@ -624,9 +623,11 @@ class swf_library com name file_path = object(self)
 end
 
 let add_swf_lib com file extern =
-	let swf_lib = new swf_library com file file in
+	let real_file = (try Common.find_file com file with Not_found -> failwith (" Library not found : " ^ file)) in
+	let swf_lib = new swf_library com file real_file in
 	com.load_extern_type <- com.load_extern_type @ [swf_lib#build];
-	if not extern then com.native_libs.swf_libs <- (swf_lib :> (swf_lib_type,Swf.swf) native_library) :: com.native_libs.swf_libs
+	if not extern then com.native_libs.swf_libs <- (swf_lib :> (swf_lib_type,Swf.swf) native_library) :: com.native_libs.swf_libs;
+	com.native_libs.all_libs <- swf_lib#get_file_path :: com.native_libs.all_libs
 
 let remove_classes toremove lib l =
 	match !toremove with

+ 4 - 7
src/context/common.ml

@@ -442,11 +442,7 @@ let create version s_version args =
 		flash_version = 10.;
 		resources = Hashtbl.create 0;
 		net_std = [];
-		native_libs = {
-			java_libs = [];
-			net_libs = [];
-			swf_libs = [];
-		};
+		native_libs = create_native_libs();
 		net_path_map = Hashtbl.create 0;
 		c_args = [];
 		neko_libs = [];
@@ -504,7 +500,8 @@ let clone com =
 		defines = {
 			values = com.defines.values;
 			defines_signature = com.defines.defines_signature;
-		}
+		};
+		native_libs = create_native_libs();
 	}
 
 let file_time file = Extc.filetime file
@@ -815,4 +812,4 @@ let dump_context com = s_record_fields "" [
 	"class_path",s_list ", " (fun s -> s) com.class_path;
 	"defines",s_pmap (fun s -> s) (fun s -> s) com.defines.values;
 	"defines_signature",s_opt (fun s -> Digest.to_hex s) com.defines.defines_signature;
-]
+]

+ 8 - 0
src/context/nativeLibraries.ml

@@ -48,4 +48,12 @@ type native_libraries = {
 	mutable java_libs : (java_lib_type,unit) native_library list;
 	mutable net_libs : (net_lib_type,unit) native_library list;
 	mutable swf_libs : (swf_lib_type,Swf.swf) native_library list;
+	mutable all_libs : string list;
+}
+
+let create_native_libs () = {
+	java_libs = [];
+	net_libs = [];
+	swf_libs = [];
+	all_libs = [];
 }