Skip to content

Commit

Permalink
[java/cs] Add Compiler.addNativeArg and renamed from javac/csc-opt to…
Browse files Browse the repository at this point in the history
… -arg
  • Loading branch information
waneck committed Jan 19, 2015
1 parent 3b66474 commit 184a376
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 15 deletions.
8 changes: 4 additions & 4 deletions common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions gencommon.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions interp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
12 changes: 6 additions & 6 deletions main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions std/haxe/macro/Compiler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 184a376

Please sign in to comment.