Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
back2dos committed Mar 16, 2015
2 parents c09ec62 + 9ea04a0 commit dfbb220
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 6 deletions.
49 changes: 46 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,50 @@
Haxelib
=======
# Haxelib

For documentation, please refer to [haxe.org](http://haxe.org/haxelib)
For more documentation, please refer to [haxe.org](http://haxe.org/haxelib)

[![TravisCI Build Status](https://travis-ci.org/HaxeFoundation/haxelib.svg?branch=master)](https://travis-ci.org/HaxeFoundation/haxelib)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/HaxeFoundation/haxelib?branch=master&svg=true)](https://ci.appveyor.com/project/andyli/haxelib)

## Per-project setup

Currently haxelib has two ways to have project local setups.

1. Using `haxelib newrepo`
2. Using `haxelib install all`

### Using haxelib newrepo

When using `haxelib newrepo` you can have a project-local haxelib repository. This feature is quite new and a little rough around the edges.

Caveats:

- if you mistakenly run a haxelib command in a subdirectory of your project, it will be executed on the global repo (to be fixed)
- there may be some issues with `haxelib run` and `haxelib selfupdate` (to be fixed)
- libraries get downloaded for each project
- it requires a recent Haxe version (after 3.1.3) to work properly with ndlls.

### Using haxelib install all

Haxe allows you to define specific versions of the libraries you want to use with `-lib <libname>:<version>`. If you make sure to use this in all your hxmls, then `haxelib install all --always` (the `--always` avoiding you being prompted for confirmation) will be able to ensure the libraries your project needs are available in the necessary versions. If in fact you run this in a checkout hook, your get to track your dependencies in your git repo (some other VCSs should allow for a similar setup), allowing you to have a well defined and replicable setup for any state (commit/branch/etc.).

Disadvantages:

- the approach requires you to define all dependencies with specific versions and then running `haxelib install all` to grab them
- with this approach, any other project that does not have specific versions defined may be affected, as under some circumstances `haxelib install all` may set the global "current" version of the libraries (to be fixed)

Advantages:

- as pointed out above, this approach allows defining a *versionable* and *replicable* state.
- you don't have to download libraries for each project, which does make a difference for heavy weights like openfl and hxcpp

#### Sidestepping haxelib git issues

Because you cannot specify git versions with `-lib` paremeters, we suggest using git submodules instead, as again they provide an adequate way of definining a *versionable* and *replicable* state.

### Combining both approaches

You can of course combine both approaches, giving you the isolation provided by the first one, and the replicability provided by the second one.

### Future solutions

A solution that combines the strengths of both approaches is in the making. Stay tuned.
4 changes: 3 additions & 1 deletion haxelib_script.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#!/bin/sh
exec haxe --run tools.haxelib.Main "$@"
OLDCWD=`pwd`
cd src
exec haxe --run tools.haxelib.Main -cwd $OLDCWD $@
8 changes: 6 additions & 2 deletions src/tools/haxelib/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1045,18 +1045,22 @@ class Main {
var p = new Process('haxelib', ['path', 'haxelib_client']);
if (p.exitCode() == 0) {
var args = [];
var classPath = "";
for (arg in p.stdout.readAll().toString().split('\n')) {
arg = arg.trim();
if (arg.charAt(0) == '-')
args.push(arg);
else if (arg.length > 0)
args.push('-cp "$arg"');
classPath = arg;
};

var file = haxepath+'haxelib';
try File.saveContent(
file,
'#!/bin/sh\nexec haxe '+args.join(' ')+' --run tools.haxelib.Main "$@"'
'#!/bin/sh'
+'\n'+'OLDCWD=`pwd`'
+'\n'+'cd $classPath'
+'\n'+'exec haxe '+args.join(' ')+" --run tools.haxelib.Main -cwd $OLDCWD $@"
)
catch (e:Dynamic)
throw 'Error writing file $file. Please ensure you have write permissions. \n ' + Std.string(e);
Expand Down

0 comments on commit dfbb220

Please sign in to comment.