nixpkgs/pkgs/development/compilers/haxe/haxelib-nix.patch

127 lines
4.4 KiB
Diff
Raw Normal View History

diff --git a/extra/haxelib_src/src/tools/haxelib/Main.hx b/extra/haxelib_src/src/tools/haxelib/Main.hx
index a44a785..0eb811a 100644
--- a/extra/haxelib_src/src/tools/haxelib/Main.hx
+++ b/extra/haxelib_src/src/tools/haxelib/Main.hx
@@ -996,21 +996,26 @@ class Main {
}
function checkRec( prj : String, version : String, l : List<{ project : String, version : String, info : Infos }> ) {
- var pdir = getRepository() + Data.safe(prj);
- if( !FileSystem.exists(pdir) )
- throw "Library "+prj+" is not installed : run 'haxelib install "+prj+"'";
- var version = if( version != null ) version else getCurrent(pdir);
- var vdir = pdir + "/" + Data.safe(version);
- if( vdir.endsWith("dev") )
- vdir = getDev(pdir);
- if( !FileSystem.exists(vdir) )
- throw "Library "+prj+" version "+version+" is not installed";
- for( p in l )
- if( p.project == prj ) {
- if( p.version == version )
- return;
- throw "Library "+prj+" has two version included "+version+" and "+p.version;
- }
+ var vdir = this.getNixLib(prj);
+ if (vdir == null) {
+ var pdir = getRepository() + Data.safe(prj);
+ if( !FileSystem.exists(pdir) )
+ throw "Library "+prj+" is not installed : run 'haxelib install "+prj+"'";
+ var version = if( version != null ) version else getCurrent(pdir);
+ var vdir = pdir + "/" + Data.safe(version);
+ if( vdir.endsWith("dev") )
+ vdir = getDev(pdir);
+ if( !FileSystem.exists(vdir) )
+ throw "Library "+prj+" version "+version+" is not installed";
+ for( p in l )
+ if( p.project == prj ) {
+ if( p.version == version )
+ return;
+ throw "Library "+prj+" has two version included "+version+" and "+p.version;
+ }
+ } else {
+ version = null;
+ }
var json = try File.getContent(vdir+"/"+Data.JSON) catch( e : Dynamic ) null;
var inf = Data.readData(json,false);
l.add({ project : prj, version : version, info: inf });
@@ -1025,15 +1030,21 @@ class Main {
var a = args[argcur++].split(":");
checkRec(a[0],a[1],list);
}
- var rep = getRepository();
for( d in list ) {
- var pdir = Data.safe(d.project)+"/"+Data.safe(d.version)+"/";
- var dir = rep + pdir;
- try {
- dir = getDev(rep+Data.safe(d.project));
+ var dir = this.getNixLib(d.project);
+ var pdir = Data.safe(d.project)+"/";
+ if (dir == null) {
+ var rep = getRepository();
+ pdir += Data.safe(d.version)+"/";
+ dir = rep + pdir;
+ try {
+ dir = getDev(rep+Data.safe(d.project));
+ dir = Path.addTrailingSlash(dir);
+ pdir = dir;
+ } catch( e : Dynamic ) {}
+ } else {
dir = Path.addTrailingSlash(dir);
- pdir = dir;
- } catch( e : Dynamic ) {}
+ }
var ndir = dir + "ndll";
if( FileSystem.exists(ndir) ) {
var sysdir = ndir+"/"+Sys.systemName();
@@ -1153,21 +1164,39 @@ class Main {
print(' Path: $devPath');
}
+ function getNixLib(project:String):Null<String>
+ {
+ var hlibPath = Sys.getEnv("HAXELIB_PATH");
+ if (hlibPath != null) {
+ for (libDir in hlibPath.split(":")) {
+ var fullpath = libDir;
+ fullpath += libDir.substr(-1, 1) == "/" ? "" : "/";
+ fullpath += Data.safe(project);
+ if (FileSystem.exists(fullpath))
+ return fullpath;
+ }
+ }
+ return null;
+ }
+
function run() {
- var rep = getRepository();
var project = param("Library");
var temp = project.split(":");
project = temp[0];
- var pdir = rep + Data.safe(project);
- if( !FileSystem.exists(pdir) )
- throw "Library "+project+" is not installed";
- pdir += "/";
- var version = temp[1] != null ? temp[1] : getCurrent(pdir);
- var dev = try getDev(pdir) catch ( e : Dynamic ) null;
- var vdir = dev!=null ? dev : pdir + Data.safe(version);
- var rdir = vdir + "/run.n";
- if( !FileSystem.exists(rdir) )
- throw "Library "+project+" version "+version+" does not have a run script";
+ var vdir = this.getNixLib(project);
+ if (vdir == null) {
+ var rep = getRepository();
+ var pdir = rep + Data.safe(project);
+ if( !FileSystem.exists(pdir) )
+ throw "Library "+project+" is not installed";
+ pdir += "/";
+ var version = temp[1] != null ? temp[1] : getCurrent(pdir);
+ var dev = try getDev(pdir) catch ( e : Dynamic ) null;
+ vdir = dev!=null ? dev : pdir + Data.safe(version);
+ var rdir = vdir + "/run.n";
+ if( !FileSystem.exists(rdir) )
+ throw "Library "+project+" version "+version+" does not have a run script";
+ }
args.push(Sys.getCwd());
Sys.setCwd(vdir);
var cmd = "neko run.n";