Browse Source

haxelib integration.

Nicolas Cannasse 19 years ago
parent
commit
e981ab566a
1 changed files with 16 additions and 0 deletions
  1. 16 0
      main.ml

+ 16 - 0
main.ml

@@ -131,6 +131,7 @@ try
 	let hres = Hashtbl.create 0 in
 	let hres = Hashtbl.create 0 in
 	let cmds = ref [] in
 	let cmds = ref [] in
 	let excludes = ref [] in
 	let excludes = ref [] in
+	let libs = ref [] in
 	let gen_hx = ref false in
 	let gen_hx = ref false in
 	Plugin.defines := base_defines;
 	Plugin.defines := base_defines;
 	Typer.check_override := false;
 	Typer.check_override := false;
@@ -200,6 +201,7 @@ try
 			main_class := Some cpath;
 			main_class := Some cpath;
 			classes := cpath :: !classes
 			classes := cpath :: !classes
 		),"<class> : select startup class");
 		),"<class> : select startup class");
+		("-lib",Arg.String (fun l -> libs := l :: !libs),"<library[:version]> : use an haxelib library");
 		("-D",Arg.String (fun def ->
 		("-D",Arg.String (fun def ->
 			Plugin.define def;
 			Plugin.define def;
 		),"<var> : define a conditional compilation flag");
 		),"<var> : define a conditional compilation flag");
@@ -274,6 +276,20 @@ try
 			classes := make_path cl :: !classes
 			classes := make_path cl :: !classes
 	in
 	in
 	Arg.parse_argv ~current args args_spec args_callback usage;
 	Arg.parse_argv ~current args args_spec args_callback usage;
+	(match !libs with
+	| [] -> ()
+	| l -> 
+		let cmd = "haxelib path " ^ String.concat " " l in
+		let p = Unix.open_process_in cmd in
+		let lines = Std.input_list p in
+		let ret = Unix.close_process_in p in
+		let lines = List.map (fun l ->
+			let p = String.length l - 1 in
+			if l.[p] = '\r' then String.sub l 0 p else l
+		) lines in
+		if ret <> Unix.WEXITED 0 then failwith (String.concat "\n" lines);
+		Plugin.class_path := lines @ !Plugin.class_path;
+	);
 	(match !target with
 	(match !target with
 	| No ->
 	| No ->
 		()
 		()