Hl.hx 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package runci.targets;
  2. import haxe.io.Path;
  3. import sys.FileSystem;
  4. import runci.System.*;
  5. import runci.Config.*;
  6. class Hl {
  7. static var hlSrc = switch [ci, systemName] {
  8. case [AzurePipelines | GithubActions, "Windows"]: "C:\\hashlink";
  9. case _: Path.join([Sys.getEnv("HOME"), "hashlink"]);
  10. };
  11. static var hlBuild = switch [ci, systemName] {
  12. case [AzurePipelines | GithubActions, "Windows"]: "C:\\hashlink_build";
  13. case _: Path.join([Sys.getEnv("HOME"), "hashlink_build"]);
  14. };
  15. static var hlBinDir = switch [ci, systemName] {
  16. case [AzurePipelines | GithubActions, "Windows"]: "C:\\hashlink_build\\bin";
  17. case _: Path.join([Sys.getEnv("HOME"), "hashlink_build", "bin"]);
  18. };
  19. static var hlBinary = switch [ci, systemName] {
  20. case [AzurePipelines | GithubActions, "Windows"]: "C:\\hashlink_build\\bin\\hl.exe";
  21. case _: Path.join([Sys.getEnv("HOME"), "hashlink_build", "bin", "hl"]);
  22. };
  23. static public function getHlDependencies() {
  24. if (commandSucceed("hl", ["--version"])) {
  25. infoMsg('hl has already been installed.');
  26. return;
  27. }
  28. if (!FileSystem.exists(hlSrc)) {
  29. runCommand("git", ["clone", "https://github.com/HaxeFoundation/hashlink.git", hlSrc]);
  30. } else infoMsg("Reusing hashlink repository");
  31. switch (systemName) {
  32. case "Linux":
  33. Linux.requireAptPackages(["libpng-dev", "libjpeg-turbo8-dev", "libturbojpeg", "zlib1g-dev", "libvorbis-dev"]);
  34. case "Mac":
  35. runCommand("brew", ["update", '--preinstall'], true);
  36. runCommand("brew", ["bundle", '--file=${hlSrc}/Brewfile'], true);
  37. case "Windows":
  38. //pass
  39. }
  40. FileSystem.createDirectory(hlBuild);
  41. var generator = systemName == "Windows" ? [] : ["-GNinja"];
  42. runCommand("cmake", generator.concat([
  43. "-DBUILD_TESTING=OFF",
  44. "-DWITH_BULLET=OFF",
  45. "-DWITH_DIRECTX=OFF",
  46. "-DWITH_FMT=ON",
  47. "-DWITH_OPENAL=OFF",
  48. "-DWITH_SDL=OFF",
  49. "-DWITH_SQLITE=OFF",
  50. "-DWITH_SSL=OFF",
  51. "-DWITH_UI=OFF",
  52. "-DWITH_UV=OFF",
  53. "-DWITH_VIDEO=OFF",
  54. "-B" + hlBuild,
  55. "-H" + hlSrc
  56. ]));
  57. runCommand("cmake", [
  58. "--build", hlBuild
  59. ]);
  60. runCommand(hlBinary, ["--version"]);
  61. addToPATH(hlBinDir);
  62. }
  63. static public function run(args:Array<String>) {
  64. getHlDependencies();
  65. runCommand("haxe", ["compile-hl.hxml"].concat(args));
  66. runCommand(hlBinary, ["bin/unit.hl"]);
  67. // changeDirectory(threadsDir);
  68. // runCommand("haxe", ["build.hxml", "-hl", "export/threads.hl"]);
  69. // runCommand("hl", ["export/threads.hl"]);
  70. changeDirectory(sysDir);
  71. runCommand("haxe", ["compile-hl.hxml"].concat(args));
  72. runCommand(hlBinary, ["bin/hl/sys.hl"]);
  73. }
  74. }