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

129 lines
4.3 KiB
Diff
Raw Normal View History

2016-12-16 13:53:35 +00:00
diff --git a/src/tools/haxelib/Main.hx b/src/tools/haxelib/Main.hx
index dc18815..def5231 100644
--- a/extra/haxelib_src/src/tools/haxelib/Main.hx
+++ b/extra/haxelib_src/src/tools/haxelib/Main.hx
2016-12-16 13:53:35 +00:00
@@ -1301,21 +1301,26 @@ class Main {
}
2016-12-16 13:53:35 +00:00
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 });
2016-12-16 13:53:35 +00:00
@@ -1330,15 +1335,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();
2016-12-16 13:53:35 +00:00
@@ -1491,23 +1502,43 @@ class Main {
);
}
2016-12-16 13:53:35 +00:00
+ 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;
+ }
2016-12-16 13:53:35 +00:00
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;
2016-12-16 13:53:35 +00:00
- var vdir = dev != null ? dev : pdir + Data.safe(version);
args.push(cli.cwd);
+
+ 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";
+ }
2016-12-16 13:53:35 +00:00
cli.cwd = vdir;
-
var callArgs =
switch try [Data.readData(File.getContent(vdir + '/haxelib.json'), false), null] catch (e:Dynamic) [null, e] {
case [null, e]: