Rebuild.hx 885 B

1234567891011121314151617181920212223242526272829303132333435
  1. package tools.haxelib;
  2. import sys.FileSystem;
  3. import sys.io.Process;
  4. class Rebuild {
  5. static function run(cmd:String, ?msg:String = '', ?args:Array<String>) {
  6. if (args == null) args = [];
  7. var p = new Process(cmd, args);
  8. if (p.exitCode() != 0)
  9. throw 'Error $msg:' + p.stderr.readAll().toString();
  10. }
  11. static function main() try {
  12. switch Sys.systemName() {
  13. case 'Windows':
  14. case os: throw 'Wrong OS. Expected Windows but detected $os';
  15. }
  16. var haxepath = Sys.getEnv("HAXEPATH");
  17. var file = '$haxepath/haxelib.n';
  18. run('haxe', 'rebuilding haxelib', [
  19. '-neko', file,
  20. '-lib', 'haxelib_client',
  21. '-main', 'tools.haxelib.Main',
  22. ]);
  23. run('nekotools', 'booting haxe', ['boot', file]);
  24. FileSystem.deleteFile(file);
  25. FileSystem.deleteFile('update.hxml');
  26. Sys.println('Update successful');
  27. }
  28. catch (e:Dynamic) {
  29. Sys.println(Std.string(e));
  30. }
  31. }