Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds haxelib libpath #410

Merged
merged 3 commits into from
Mar 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion haxelib.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haxelib",
"url" : "http://haxe.org/haxelib",
"url" : "https://lib.haxe.org/documentation/",
"license": "GPL",
"tags": ["haxelib", "core"],
"description": "The haxelib client",
Expand Down
27 changes: 20 additions & 7 deletions src/haxelib/client/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ class Main {
addCommand("info", info, "list information on a given library", Information);
addCommand("user", user, "list information on a given user", Information);
addCommand("config", config, "print the repository path", Information, false);
addCommand("path", path, "give paths to libraries", Information, false);
addCommand("path", path, "give paths to libraries' sources and necessary build definitions", Information, false);
addCommand("libpath", libpath, "returns the root path of a library", Information, false);
addCommand("version", version, "print the currently used haxelib version", Information, false);
addCommand("help", usage, "display this list of options", Information, false);

Expand Down Expand Up @@ -1290,7 +1291,7 @@ class Main {
print("Library "+prj+" current version is now "+version);
}

function checkRec( rep : String, prj : String, version : String, l : List<{ project : String, version : String, dir : String, info : Infos }> ) {
function checkRec( rep : String, prj : String, version : String, l : List<{ project : String, version : String, dir : String, info : Infos }>, ?returnDependencies : Bool = true ) {
var pdir = rep + Data.safe(prj);
if( !FileSystem.exists(pdir) )
throw "Library "+prj+" is not installed : run 'haxelib install "+prj+"'";
Expand All @@ -1306,22 +1307,24 @@ class Main {
if( p.project == prj ) {
if( p.version == version )
return;
throw "Library "+prj+" has two version included "+version+" and "+p.version;
throw "Library "+prj+" has two versions included : "+version+" and "+p.version;
}
var json = try File.getContent(vdir+"/"+Data.JSON) catch( e : Dynamic ) null;
var inf = Data.readData(json,false);
l.add({ project : prj, version : version, dir : Path.addTrailingSlash(vdir), info: inf });
for( d in inf.dependencies )
if( !Lambda.exists(l, function(e) return e.project == d.name) )
checkRec(rep,d.name,if( d.version == "" ) null else d.version,l);
if( returnDependencies ) {
for( d in inf.dependencies )
if( !Lambda.exists(l, function(e) return e.project == d.name) )
checkRec(rep,d.name,if( d.version == "" ) null else d.version,l);
}
}

function path() {
var rep = getRepository();
var list = new List();
while( argcur < args.length ) {
var a = args[argcur++].split(":");
checkRec(rep, a[0],a[1],list);
checkRec(rep, a[0], a[1], list);
}
for( d in list ) {
var ndir = d.dir + "ndll";
Expand All @@ -1344,6 +1347,16 @@ class Main {
}
}

function libpath( ) {
var rep = getRepository();
while( argcur < args.length ) {
var a = args[argcur++].split(":");
var results = new List();
checkRec(rep, a[0], a[1], results, false);
if( !results.isEmpty() ) Sys.println(results.first().dir);
}
}

function dev() {
var rep = getRepository();
var project = param("Library");
Expand Down
41 changes: 40 additions & 1 deletion www/documentation-files/using-haxelib.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The following commands are available:
<li><a href="#user">user</a></li>
<li><a href="#config">config</a></li>
<li><a href="#path">path</a></li>
<li><a href="#libpath">libpath</a></li>
<li><a href="#version">version</a></li>
<li><a href="#help">help</a></li>
</ul>
Expand Down Expand Up @@ -249,8 +250,19 @@ haxelib path hscript:2.0.0
haxelib path hscript erazor buddy
haxelib path hscript erazor buddy:1.0.0
```
Example output :
```
haxelib path openfl hxcpp format
--macro openfl._internal.utils.ExtraParams.include()
/usr/local/lib/haxe/lib/openfl/6.5.3/
-D openfl=6.5.3
/usr/local/lib/haxe/lib/hxcpp/git/
-D hxcpp=3.4.0
/usr/local/lib/haxe/lib/format/3,3,0/
-D format=3.3.0
```

> Prints the path to one or more libraries, as well as any dependencies and compiler definitions required by those libraries.
> Prints the source paths to one or more libraries, as well as any dependencies and compiler definitions required by those libraries.
>
> You can specify a version by appending `:version` to the library name. If no version is specified the set version is used.
>
Expand All @@ -260,6 +272,33 @@ haxelib path hscript erazor buddy:1.0.0



<a name="libpath" class="anch"></a>

#### `haxelib libpath`

```
haxelib libpath [project-name[:version]...]
haxelib libpath hscript
haxelib libpath hscript:2.0.0
haxelib libpath hscript erazor buddy
haxelib libpath hscript erazor buddy:1.0.0
```
Example output :
```
haxelib libpath hxcpp format hscript
/usr/local/lib/haxe/lib/hxcpp/git/
/usr/local/lib/haxe/lib/format/3,3,0/
/usr/local/lib/haxe/lib/hxcpp/2,1,1/
```

> Prints the root path of one or more libraries. Will output 1 path per line.
>
> You can specify a version by appending `:version` to the library name. If no version is specified the set version is used.
>
> If a [development](#dev) version is set it'll be used even if a version is specified.



<a name="version" class="anch"></a>

#### `haxelib version`
Expand Down