Lua.hx 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package runci.targets;
  2. import sys.FileSystem;
  3. import runci.System.*;
  4. import runci.Config.*;
  5. import haxe.io.*;
  6. using StringTools;
  7. class Lua {
  8. static var miscLuaDir(get,never):String;
  9. static inline function get_miscLuaDir() return miscDir + 'lua/';
  10. static public function getLuaDependencies(){
  11. switch (systemName){
  12. case "Linux":
  13. Linux.requireAptPackages(["libpcre3-dev", "libssl-dev", "libreadline-dev"]);
  14. runCommand("pip", ["install", "--user", "hererocks"]);
  15. var pyUserBase = commandResult("python", ["-m", "site", "--user-base"]).stdout.trim();
  16. addToPATH(Path.join([pyUserBase, "bin"]));
  17. case "Mac": {
  18. if (commandSucceed("python3", ["-V"]))
  19. infoMsg('python3 has already been installed.');
  20. else
  21. runCommand("brew", ["install", "python3"], true);
  22. runCommand("brew", ["install", "pcre"], false, true);
  23. runCommand("pip3", ["install", "hererocks"]);
  24. }
  25. }
  26. }
  27. static function installLib(lib : String, version : String, ?server :String){
  28. if (!commandSucceed("luarocks", ["show", lib, version])) {
  29. var args = ["install", lib, version];
  30. if (server != null){
  31. var server_arg = '--server=$server';
  32. args.push(server_arg);
  33. }
  34. runCommand("luarocks", args);
  35. } else {
  36. infoMsg('Lua dependency $lib is already installed at version $version');
  37. }
  38. }
  39. static public function run(args:Array<String>) {
  40. getLuaDependencies();
  41. for (lv in ["-l5.1", "-l5.2", "-l5.3", "-j2.0", "-j2.1" ]){
  42. var envpath = Sys.getEnv("HOME") + '/lua_env$lv';
  43. addToPATH(envpath + '/bin');
  44. if (systemName == "Mac" && lv.startsWith("-j")) continue;
  45. Sys.println('--------------------');
  46. Sys.println('Lua Version: $lv');
  47. runCommand("hererocks", [envpath, lv, "-rlatest", "-i"]);
  48. trace('path: ' + Sys.getEnv("PATH"));
  49. runCommand("lua",["-v"]);
  50. runCommand("luarocks", ["config", "--lua-incdir"]);
  51. runCommand("luarocks", ["config", "--lua-libdir"]);
  52. runCommand("luarocks", ["config", "--lua-ver"]);
  53. runCommand("luarocks", ["config", "--system-config"]);
  54. runCommand("luarocks", ["config", "--rock-trees"]);
  55. // Note: don't use a user config
  56. // runCommand("luarocks", ["config", "--user-config"], false, true);
  57. installLib("haxe-deps", "0.0.1-6");
  58. changeDirectory(unitDir);
  59. runCommand("haxe", ["compile-lua.hxml"].concat(args));
  60. runCommand("lua", ["bin/unit.lua"]);
  61. changeDirectory(sysDir);
  62. runCommand("haxe", ["compile-lua.hxml"].concat(args));
  63. runSysTest("lua", ["bin/lua/sys.lua"]);
  64. changeDirectory(miscDir + "luaDeadCode/stringReflection");
  65. runCommand("haxe", ["compile.hxml"]);
  66. changeDirectory(miscLuaDir);
  67. runCommand("haxe", ["run.hxml"]);
  68. }
  69. }
  70. }