瀏覽代碼

[java/cs] Initial implementation of javac-opt / cs-opt. Closes #3768

Cauê Waneck 10 年之前
父節點
當前提交
d7c43638bd
共有 3 個文件被更改,包括 26 次插入0 次删除
  1. 4 0
      common.ml
  2. 16 0
      gencommon.ml
  3. 6 0
      main.ml

+ 4 - 0
common.ml

@@ -150,6 +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 js_gen : (unit -> unit) option;
 	(* typing *)
 	mutable basic : basic_types;
@@ -708,6 +710,8 @@ let create v args =
 		net_libs = [];
 		net_std = [];
 		net_path_map = Hashtbl.create 0;
+		javac_opts = [];
+		cs_opts = [];
 		neko_libs = [];
 		php_prefix = None;
 		js_gen = None;

+ 16 - 0
gencommon.ml

@@ -1081,6 +1081,22 @@ let dump_descriptor gen name path_s module_s =
 			end
 		) gen.gcon.net_libs;
 	SourceWriter.write w "end libs";
+	SourceWriter.newline w;
+	let opts = match gen.gcon.platform with
+		| Java ->
+			gen.gcon.javac_opts
+		| Cs ->
+			gen.gcon.cs_opts
+		| _ ->
+			[]
+	in
+	if opts <> [] then begin
+		SourceWriter.write w "begin opts";
+		SourceWriter.newline w;
+		List.iter (fun opt -> SourceWriter.write w opt; SourceWriter.newline w) opts;
+		SourceWriter.write w "end opts";
+		SourceWriter.newline w;
+	end;
 
 	let contents = SourceWriter.contents w in
 	let f = open_out (gen.gcon.file ^ "/" ^ name) in

+ 6 - 0
main.ml

@@ -1139,6 +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");
+		("-cs-opt",Arg.String (fun arg ->
+			com.cs_opts <- arg :: com.cs_opts
+		),"<opt> : pass option <opt> to the C# compiler");
 		("-x", Arg.String (fun file ->
 			let neko_file = file ^ ".n" in
 			set_platform Neko neko_file;