2
0
Эх сурвалжийг харах

[java/cs] Add Compiler.addNativeArg and renamed from javac/csc-opt to -arg

Cauê Waneck 10 жил өмнө
parent
commit
184a376325
5 өөрчлөгдсөн 37 нэмэгдсэн , 15 устгасан
  1. 4 4
      common.ml
  2. 5 5
      gencommon.ml
  3. 14 0
      interp.ml
  4. 6 6
      main.ml
  5. 8 0
      std/haxe/macro/Compiler.hx

+ 4 - 4
common.ml

@@ -150,8 +150,8 @@ type context = {
 	mutable net_libs : (string * bool * (unit -> path list) * (path -> IlData.ilclass option)) list; (* (path,std,all_files,lookup) *)
 	mutable net_std : string list;
 	net_path_map : (path,string list * string list * string) Hashtbl.t;
-	mutable javac_opts : string list;
-	mutable cs_opts : string list;
+	mutable javac_args : string list;
+	mutable cs_args : string list;
 	mutable js_gen : (unit -> unit) option;
 	(* typing *)
 	mutable basic : basic_types;
@@ -710,8 +710,8 @@ let create v args =
 		net_libs = [];
 		net_std = [];
 		net_path_map = Hashtbl.create 0;
-		javac_opts = [];
-		cs_opts = [];
+		javac_args = [];
+		cs_args = [];
 		neko_libs = [];
 		php_prefix = None;
 		js_gen = None;

+ 5 - 5
gencommon.ml

@@ -1082,18 +1082,18 @@ let dump_descriptor gen name path_s module_s =
 		) gen.gcon.net_libs;
 	SourceWriter.write w "end libs";
 	SourceWriter.newline w;
-	let opts = match gen.gcon.platform with
+	let args = match gen.gcon.platform with
 		| Java ->
-			gen.gcon.javac_opts
+			gen.gcon.javac_args
 		| Cs ->
-			gen.gcon.cs_opts
+			gen.gcon.csc_arg
 		| _ ->
 			[]
 	in
-	if opts <> [] then begin
+	if args <> [] then begin
 		SourceWriter.write w "begin opts";
 		SourceWriter.newline w;
-		List.iter (fun opt -> SourceWriter.write w opt; SourceWriter.newline w) opts;
+		List.iter (fun opt -> SourceWriter.write w opt; SourceWriter.newline w) args;
 		SourceWriter.write w "end opts";
 		SourceWriter.newline w;
 	end;

+ 14 - 0
interp.ml

@@ -2547,6 +2547,20 @@ let macro_lib =
 			| _ ->
 				error()
 		);
+		"add_native_arg", Fun1 (fun v ->
+			match v with
+			| VString arg ->
+				let com = ccom() in
+				(match com.platform with
+				| Java ->
+					com.javac_args := arg :: com.javac_args
+				| Cs ->
+					com.csc_arg := arg :: com.csc_arg
+				| _ -> failwith "Unsupported platform");
+				VNull
+			| _ ->
+				error()
+		);
 		"module_dependency", Fun2 (fun m file ->
 			match m, file with
 			| VString m, VString file ->

+ 6 - 6
main.ml

@@ -1139,12 +1139,12 @@ try
 		("-net-std",Arg.String (fun file ->
 			Gencs.add_net_std com file
 		),"<file> : add a root std .NET DLL search path");
-		("-javac-opt",Arg.String (fun arg ->
-			com.javac_opts <- arg :: com.javac_opts
-		),"<opt> : pass option <opt> to the Java compiler");
-		("-csc-opt",Arg.String (fun arg ->
-			com.cs_opts <- arg :: com.cs_opts
-		),"<opt> : pass option <opt> to the C# compiler");
+		("-javac-arg",Arg.String (fun arg ->
+			com.javac_args <- arg :: com.javac_args
+		),"<arg> : pass argument <arg> to the Java compiler");
+		("-csc-arg",Arg.String (fun arg ->
+			com.csc_arg <- arg :: com.csc_arg
+		),"<arg> : pass option <arg> to the C# compiler");
 		("-x", Arg.String (fun file ->
 			let neko_file = file ^ ".n" in
 			set_platform Neko neko_file;

+ 8 - 0
std/haxe/macro/Compiler.hx

@@ -89,6 +89,14 @@ class Compiler {
 		untyped load("add_native_lib",1)(name.__s);
 	}
 
+	/**
+		Adds an argument to be passed to the native compiler (eg : -javac-arg for Java)
+	 **/
+	public static function addNativeArg( argument : String )
+	{
+		untyped load("add_native_arg",1)(argument.__s);
+	}
+
 	/**
 		Includes all modules in package `pack` in the compilation.