Allow fallback to alternate tools if setting HAXELIB_PATH in project

This commit is contained in:
Joshua Granick
2017-08-16 10:57:01 -07:00
parent f83c7e53bc
commit 041db4d98e
4 changed files with 53 additions and 5 deletions

View File

@@ -70,6 +70,7 @@ class HXProject {
private var defaultApp:ApplicationData;
private var defaultMeta:MetaData;
private var defaultWindow:WindowData;
private var needRerun:Bool;
public static var _command:String;
public static var _debug:Bool;

View File

@@ -1163,9 +1163,30 @@ class ProjectXMLParser extends HXProject {
var name = substitute (element.att.name);
defines.set (name, value);
environment.set (name, value);
setenv (name, value);
if (name == "HAXELIB_PATH") {
var currentPath = HaxelibHelper.getRepositoryPath ();
defines.set (name, value);
environment.set (name, value);
setenv (name, value);
var newPath = HaxelibHelper.getRepositoryPath (true);
if (currentPath != newPath) {
needRerun = true;
return;
}
} else {
defines.set (name, value);
environment.set (name, value);
setenv (name, value);
}
case "error":

View File

@@ -81,9 +81,9 @@ class HaxelibHelper {
}
public static function getRepositoryPath ():String {
public static function getRepositoryPath (clearCache:Bool = false):String {
if (repositoryPath == null) {
if (repositoryPath == null || clearCache) {
var cache = LogHelper.verbose;
LogHelper.verbose = debug;

View File

@@ -20,6 +20,8 @@ import utils.CreateTemplate;
import utils.JavaExternGenerator;
import utils.PlatformSetup;
@:access(lime.project.HXProject)
class CommandLineTools {
@@ -1695,6 +1697,30 @@ class CommandLineTools {
}
if (project != null && project.needRerun && !project.targetFlags.exists ("norerun")) {
HaxelibHelper.pathOverrides.remove ("lime");
var workingDirectory = Sys.getCwd ();
var limePath = HaxelibHelper.getPath (new Haxelib ("lime"), true, true);
Sys.setCwd (workingDirectory);
LogHelper.info ("", LogHelper.accentColor + "Requesting alternate tools from custom haxelib path...\x1b[0m\n\n");
var args = Sys.args ();
args.pop ();
Sys.setCwd (limePath);
args = [ PathHelper.combine (limePath, "run.n") ].concat (args);
args.push ("--haxelib-lime=" + limePath);
args.push ("-norerun");
args.push (workingDirectory);
Sys.exit (Sys.command ("neko", args));
return null;
}
if (project == null || (command != "rebuild" && project.sources.length == 0 && !FileSystem.exists (project.app.main + ".hx"))) {
LogHelper.error ("You must have a \"project.xml\" file or specify another valid project file when using the '" + command + "' command");