Browse Source

[cs] Add support for lib loading on no_root and erase_generics

Cauê Waneck 10 years ago
parent
commit
d10880bde9

+ 6 - 1
gencs.ml

@@ -3261,7 +3261,12 @@ let configure gen =
 					| _ :: _ when not erase_generics -> "_" ^ string_of_int (List.length c.cl_params)
 					| _ -> ""
 				in
-				let path = (fst c.cl_path, snd c.cl_path ^ extra) in
+				let pack = match c.cl_path with
+					| ([], _) when no_root && is_hxgen (TClassDecl c) ->
+						["haxe";"root"]
+					| (p,_) -> p
+				in
+				let path = (pack, snd c.cl_path ^ extra) in
 				ignore (List.find (function (_,_,_,lookup) ->
 					is_some (lookup path)) haxe_libs);
 				c.cl_extern <- true;

+ 5 - 2
tests/RunCi.hx

@@ -637,8 +637,11 @@ class RunCi {
 					runExe("bin/Main-Debug.exe", args);
 
 					changeDirectory(miscDir + "csTwoLibs");
-					runCommand("haxe", ["compile.hxml"]);
-					runExe("bin/main/bin/Main.exe");
+					for (i in 1...5)
+					{
+						runCommand("haxe", ['compile-$i.hxml']);
+						runExe("bin/main/bin/Main.exe");
+					}
 
 				case Flash9:
 					setupFlashPlayerDebugger();

+ 2 - 1
tests/misc/csTwoLibs/Main.hx

@@ -3,7 +3,8 @@ class Main
 	public static function main()
 	{
 		var asm = cs.system.reflection.Assembly.LoadFile(sys.FileSystem.fullPath("bin/lib1/bin/lib1.dll"));
-		var tp:Dynamic = asm.GetType("Lib1");
+		var name = #if no_root "haxe.root.Lib1" #else "Lib1" #end;
+		var tp:Dynamic = asm.GetType(name);
 		var obj = tp.test();
 		trace(obj);
 		for (field in Reflect.fields(obj))

+ 0 - 0
tests/misc/csTwoLibs/compile.hxml → tests/misc/csTwoLibs/compile-1.hxml


+ 18 - 0
tests/misc/csTwoLibs/compile-2.hxml

@@ -0,0 +1,18 @@
+cs.Boot
+-dce no
+-cs bin/haxeboot
+-D no_root
+--next
+-net-lib bin/haxeboot/bin/haxeboot.dll
+-dce no
+-D dll_import
+-D no_root
+Lib1
+-cs bin/lib1
+--next
+-net-lib bin/haxeboot/bin/haxeboot.dll
+-dce no
+-D dll_import
+-D no_root
+-main Main
+-cs bin/main

+ 18 - 0
tests/misc/csTwoLibs/compile-3.hxml

@@ -0,0 +1,18 @@
+cs.Boot
+-dce no
+-cs bin/haxeboot
+-D erase_generics
+--next
+-net-lib bin/haxeboot/bin/haxeboot.dll
+-dce no
+-D dll_import
+-D erase_generics
+Lib1
+-cs bin/lib1
+--next
+-net-lib bin/haxeboot/bin/haxeboot.dll
+-dce no
+-D dll_import
+-D erase_generics
+-main Main
+-cs bin/main

+ 21 - 0
tests/misc/csTwoLibs/compile-4.hxml

@@ -0,0 +1,21 @@
+cs.Boot
+-dce no
+-cs bin/haxeboot
+-D erase_generics
+-D no_root
+--next
+-net-lib bin/haxeboot/bin/haxeboot.dll
+-dce no
+-D dll_import
+-D erase_generics
+-D no_root
+Lib1
+-cs bin/lib1
+--next
+-net-lib bin/haxeboot/bin/haxeboot.dll
+-dce no
+-D dll_import
+-D erase_generics
+-D no_root
+-main Main
+-cs bin/main