Browse Source

allowed haxelib "dev" mode.

Nicolas Cannasse 18 years ago
parent
commit
281084f08d
2 changed files with 31 additions and 2 deletions
  1. 2 1
      genneko.ml
  2. 29 1
      std/tools/haxelib/Main.hx

+ 2 - 1
genneko.ml

@@ -712,7 +712,8 @@ let generate_libs_init = function
 			"@s = @s + \"/\";"
 			"@s = @s + \"/\";"
 		in
 		in
 		List.fold_left (fun acc l ->
 		List.fold_left (fun acc l ->
-			acc ^ "$loader.path = $array(@b + \"" ^ Nast.escape l ^ "\" + @s,$loader.path);"
+			let full_path = l.[0] = '/' || l.[1] = ':' in
+			acc ^ "$loader.path = $array(" ^ (if full_path then "" else "@b + ") ^ "\"" ^ Nast.escape l ^ "\" + @s,$loader.path);"
 		) boot libs
 		) boot libs
 
 
 let generate file types hres libs =
 let generate file types hres libs =

+ 29 - 1
std/tools/haxelib/Main.hx

@@ -123,6 +123,7 @@ class Main {
 		addCommand("path",path,"give paths to libraries");
 		addCommand("path",path,"give paths to libraries");
 		addCommand("run",run,"run the specified project with parameters");
 		addCommand("run",run,"run the specified project with parameters");
 		addCommand("test",test,"install the specified package localy");
 		addCommand("test",test,"install the specified package localy");
+		addCommand("dev",dev,"set the development directory for a given project");
 		siteUrl = "http://"+SERVER.host+":"+SERVER.port+"/"+SERVER.dir;
 		siteUrl = "http://"+SERVER.host+":"+SERVER.port+"/"+SERVER.dir;
 		site = new SiteProxy(haxe.remoting.Connection.urlConnect(siteUrl+SERVER.url).api);
 		site = new SiteProxy(haxe.remoting.Connection.urlConnect(siteUrl+SERVER.url).api);
 	}
 	}
@@ -515,14 +516,17 @@ class Main {
 				continue;
 				continue;
 			var versions = new Array();
 			var versions = new Array();
 			var current = neko.io.File.getContent(rep+p+"/.current");
 			var current = neko.io.File.getContent(rep+p+"/.current");
+			var dev = try neko.io.File.getContent(rep+p+"/.dev") catch( e : Dynamic ) null;
 			for( v in neko.FileSystem.readDirectory(rep+p) ) {
 			for( v in neko.FileSystem.readDirectory(rep+p) ) {
 				if( v.charAt(0) == "." )
 				if( v.charAt(0) == "." )
 					continue;
 					continue;
 				v = Datas.unsafe(v);
 				v = Datas.unsafe(v);
-				if( v == current )
+				if( dev == null && v == current )
 					v = "["+v+"]";
 					v = "["+v+"]";
 				versions.push(v);
 				versions.push(v);
 			}
 			}
+			if( dev != null )
+				versions.push("[dev:"+dev+"]");
 			print(Datas.unsafe(p) + ": "+versions.join(" "));
 			print(Datas.unsafe(p) + ": "+versions.join(" "));
 		}
 		}
 	}
 	}
@@ -644,6 +648,13 @@ class Main {
 		for( d in list ) {
 		for( d in list ) {
 			var pdir = Datas.safe(d.project)+"/"+Datas.safe(d.version)+"/";
 			var pdir = Datas.safe(d.project)+"/"+Datas.safe(d.version)+"/";
 			var dir = rep + pdir;
 			var dir = rep + pdir;
+			try {
+				dir = neko.io.File.getContent(rep+Datas.safe(d.project)+"/.dev");
+				if( dir.length == 0 || (dir.charAt(dir.length-1) != '/' && dir.charAt(dir.length-1) != '\\') )
+					dir += "/";
+				pdir = dir;
+			} catch( e : Dynamic ) {
+			}
 			var ndir = dir + "ndll";
 			var ndir = dir + "ndll";
 			if( neko.FileSystem.exists(ndir) ) {
 			if( neko.FileSystem.exists(ndir) ) {
 				var sysdir = ndir+"/"+neko.Sys.systemName();
 				var sysdir = ndir+"/"+neko.Sys.systemName();
@@ -655,6 +666,23 @@ class Main {
 		}
 		}
 	}
 	}
 
 
+	function dev() {
+		var rep = getRepository();
+		var project = param("Project");
+		var dir = paramOpt();
+		var devfile = rep + Datas.safe(project)+"/.dev";
+		if( dir == null ) {
+			if( neko.FileSystem.exists(devfile) )
+				neko.FileSystem.deleteFile(devfile);
+			print("Development directory disabled");
+		} else {
+			var f = neko.io.File.write(devfile,false);
+			f.write(dir);
+			f.close();
+			print("Development directory set to "+dir);
+		}
+	}
+
 	function run() {
 	function run() {
 		var rep = getRepository();
 		var rep = getRepository();
 		var project = param("Project");
 		var project = param("Project");