Browse Source

forgot file

Simon Krajewski 12 years ago
parent
commit
d7014f48f8
1 changed files with 35 additions and 0 deletions
  1. 35 0
      std/tools/haxelib/Rebuild.hx

+ 35 - 0
std/tools/haxelib/Rebuild.hx

@@ -0,0 +1,35 @@
+package tools.haxelib;
+
+import sys.FileSystem;
+import sys.io.Process;
+
+class Rebuild {
+	static function run(cmd:String, ?msg:String = '', ?args:Array<String>) {
+		if (args == null) args = [];
+		var p = new Process(cmd, args);
+		if (p.exitCode() != 0) 
+			throw 'Error $msg:' + p.stderr.readAll().toString();
+	}
+	static function main() try {
+		switch Sys.systemName() {
+			case 'Windows':
+			case os: throw 'Wrong OS. Expected Windows but detected $os';
+		}
+		var haxepath = Sys.getEnv("HAXEPATH");
+		var file = '$haxepath/haxelib.n';
+		
+		run('haxe', 'rebuilding haxelib', [
+			'-neko', file, 
+			'-lib', 'haxelib_client', 
+			'-main', 'tools.haxelib.Main', 
+		]);
+		
+		run('nekotools', 'booting haxe', ['boot', file]);
+		FileSystem.deleteFile(file);
+		FileSystem.deleteFile('update.hxml');
+		Sys.println('Update successful');
+	}
+	catch (e:Dynamic) {
+		Sys.println(Std.string(e));
+	}
+}