Small optimizations
This commit is contained in:
@@ -1,35 +1,35 @@
|
||||
package commands;
|
||||
|
||||
class Compiler {
|
||||
public static function test(args:Array<String>) {
|
||||
__build(args, ["test", getBuildTarget(), "-D", "TEST_BUILD"]);
|
||||
}
|
||||
public static function build(args:Array<String>) {
|
||||
__build(args, ["build", getBuildTarget(), "-D", "TEST_BUILD"]);
|
||||
}
|
||||
public static function release(args:Array<String>) {
|
||||
__build(args, ["build", getBuildTarget()]);
|
||||
}
|
||||
public static function testRelease(args:Array<String>) {
|
||||
__build(args, ["test", getBuildTarget()]);
|
||||
}
|
||||
public static function test(args:Array<String>) {
|
||||
__build(args, ["test", getBuildTarget(), "-D", "TEST_BUILD"]);
|
||||
}
|
||||
public static function build(args:Array<String>) {
|
||||
__build(args, ["build", getBuildTarget(), "-D", "TEST_BUILD"]);
|
||||
}
|
||||
public static function release(args:Array<String>) {
|
||||
__build(args, ["build", getBuildTarget()]);
|
||||
}
|
||||
public static function testRelease(args:Array<String>) {
|
||||
__build(args, ["test", getBuildTarget()]);
|
||||
}
|
||||
|
||||
private static function __build(args:Array<String>, arg:Array<String>) {
|
||||
for(a in args)
|
||||
arg.push(a);
|
||||
Sys.command("lime", arg);
|
||||
}
|
||||
private static function __build(args:Array<String>, arg:Array<String>) {
|
||||
for(a in args)
|
||||
arg.push(a);
|
||||
Sys.command("lime", arg);
|
||||
}
|
||||
|
||||
private static function getBuildTarget() {
|
||||
return switch(Sys.systemName()) {
|
||||
case "Windows":
|
||||
"windows";
|
||||
case "Mac":
|
||||
"macos";
|
||||
case "Linux":
|
||||
"linux";
|
||||
case def:
|
||||
def.toLowerCase();
|
||||
}
|
||||
}
|
||||
private static function getBuildTarget() {
|
||||
return switch(Sys.systemName()) {
|
||||
case "Windows":
|
||||
"windows";
|
||||
case "Mac":
|
||||
"macos";
|
||||
case "Linux":
|
||||
"linux";
|
||||
case def:
|
||||
def.toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,15 +7,15 @@ import sys.io.Process;
|
||||
import sys.FileSystem;
|
||||
|
||||
class Update {
|
||||
public static function main(args:Array<String>) {
|
||||
public static function main(args:Array<String>) {
|
||||
prettyPrint("Preparing installation...");
|
||||
|
||||
// to prevent messing with currently installed libs
|
||||
if (!FileSystem.exists('.haxelib'))
|
||||
FileSystem.createDirectory('.haxelib');
|
||||
|
||||
var libs:Array<Library> = [];
|
||||
var libsXML:Access = new Access(Xml.parse(File.getContent('./libs.xml')).firstElement());
|
||||
if (!FileSystem.exists('.haxelib'))
|
||||
FileSystem.createDirectory('.haxelib');
|
||||
|
||||
var libs:Array<Library> = [];
|
||||
var libsXML:Access = new Access(Xml.parse(File.getContent('./libs.xml')).firstElement());
|
||||
|
||||
for (libNode in libsXML.elements) {
|
||||
var lib:Library = {
|
||||
@@ -33,23 +33,23 @@ class Update {
|
||||
libs.push(lib);
|
||||
}
|
||||
|
||||
for(lib in libs) {
|
||||
// install libs
|
||||
var globalism = lib.global == "true" ? "--global" : "";
|
||||
switch(lib.type) {
|
||||
case "lib":
|
||||
prettyPrint((lib.global == "true" ? "Globally installing" : "Locally installing") + ' "${lib.name}"...');
|
||||
Sys.command('haxelib $globalism install ${lib.name} ${lib.version != null ? " " + lib.version : " "}');
|
||||
case "git":
|
||||
prettyPrint((lib.global == "true" ? "Globally installing" : "Locally installing") + ' "${lib.name}" from git url "${lib.url}"');
|
||||
if (lib.ref != null)
|
||||
Sys.command('haxelib $globalism git ${lib.name} ${lib.url} ${lib.ref}');
|
||||
else
|
||||
Sys.command('haxelib $globalism git ${lib.name} ${lib.url}');
|
||||
default:
|
||||
prettyPrint('Cannot resolve library of type "${lib.type}"');
|
||||
}
|
||||
}
|
||||
for(lib in libs) {
|
||||
// install libs
|
||||
var globalism = lib.global == "true" ? "--global" : "";
|
||||
switch(lib.type) {
|
||||
case "lib":
|
||||
prettyPrint((lib.global == "true" ? "Globally installing" : "Locally installing") + ' "${lib.name}"...');
|
||||
Sys.command('haxelib $globalism install ${lib.name} ${lib.version != null ? " " + lib.version : " "}');
|
||||
case "git":
|
||||
prettyPrint((lib.global == "true" ? "Globally installing" : "Locally installing") + ' "${lib.name}" from git url "${lib.url}"');
|
||||
if (lib.ref != null)
|
||||
Sys.command('haxelib $globalism git ${lib.name} ${lib.url} ${lib.ref}');
|
||||
else
|
||||
Sys.command('haxelib $globalism git ${lib.name} ${lib.url}');
|
||||
default:
|
||||
prettyPrint('Cannot resolve library of type "${lib.type}"');
|
||||
}
|
||||
}
|
||||
|
||||
var proc = new Process('haxe --version');
|
||||
proc.exitCode(true);
|
||||
@@ -76,24 +76,24 @@ class Update {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function prettyPrint(text:String) {
|
||||
var header = "══════";
|
||||
for(i in 0...(text.length-(text.lastIndexOf("\n")+1)))
|
||||
header += "═";
|
||||
Sys.println("");
|
||||
Sys.println('╔$header╗');
|
||||
Sys.println('║ $text ║');
|
||||
Sys.println('╚$header╝');
|
||||
}
|
||||
public static function prettyPrint(text:String) {
|
||||
var header = "══════";
|
||||
for(i in 0...(text.length-(text.lastIndexOf("\n")+1)))
|
||||
header += "═";
|
||||
Sys.println("");
|
||||
Sys.println('╔$header╗');
|
||||
Sys.println('║ $text ║');
|
||||
Sys.println('╚$header╝');
|
||||
}
|
||||
}
|
||||
|
||||
typedef Library = {
|
||||
var name:String;
|
||||
var type:String;
|
||||
var ?global:String;
|
||||
var ?version:String;
|
||||
var ?ref:String;
|
||||
var ?url:String;
|
||||
var name:String;
|
||||
var type:String;
|
||||
var ?global:String;
|
||||
var ?version:String;
|
||||
var ?ref:String;
|
||||
var ?url:String;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user