Cpp.hx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package runci.targets;
  2. import sys.FileSystem;
  3. import runci.System.*;
  4. import runci.Config.*;
  5. class Cpp {
  6. static public var gotCppDependencies = false;
  7. static final miscCppDir = getMiscSubDir('cpp');
  8. static public function getCppDependencies() {
  9. if (gotCppDependencies) return;
  10. //hxcpp dependencies
  11. switch (systemName) {
  12. case "Linux":
  13. if (Linux.arch == Amd64) {
  14. Linux.requireAptPackages(["gcc-multilib", "g++-multilib"]);
  15. }
  16. case "Mac":
  17. //pass
  18. }
  19. //install and build hxcpp
  20. try {
  21. final path = getHaxelibPath("hxcpp");
  22. infoMsg('hxcpp has already been installed in $path.');
  23. } catch(e:Dynamic) {
  24. haxelibInstallGit("HaxeFoundation", "hxcpp", true);
  25. final oldDir = Sys.getCwd();
  26. changeDirectory(getHaxelibPath("hxcpp") + "tools/hxcpp/");
  27. runCommand("haxe", ["-D", "source-header=''", "compile.hxml"]);
  28. changeDirectory(oldDir);
  29. }
  30. gotCppDependencies = true;
  31. }
  32. static public function runCpp(bin:String, ?args:Array<String>):Void {
  33. if (args == null) args = [];
  34. bin = FileSystem.fullPath(bin);
  35. runCommand(bin, args);
  36. }
  37. static public function run(args:Array<String>, testCompiled:Bool, testCppia:Bool) {
  38. getCppDependencies();
  39. final isLinuxArm64 = systemName == 'Linux' && Linux.arch == Arm64;
  40. final archFlag = switch systemName {
  41. case 'Windows':
  42. 'HXCPP_M32';
  43. case 'Linux' if(Linux.arch == Arm64):
  44. 'HXCPP_LINUX_ARM64';
  45. case 'Mac' if(commandResult('arch', []).stdout == "arm64"):
  46. 'HXCPP_ARM64';
  47. case _:
  48. 'HXCPP_M64';
  49. }
  50. if (testCompiled) {
  51. runCommand("rm", ["-rf", "cpp"]);
  52. runCommand("haxe", ["compile-cpp.hxml", "-D", archFlag].concat(args));
  53. runCpp("bin/cpp/TestMain-debug", []);
  54. }
  55. if (testCppia) {
  56. runCommand("haxe", ["compile-cppia-host.hxml", "-D", archFlag].concat(args));
  57. runCommand("haxe", ["compile-cppia.hxml"].concat(args));
  58. runCpp("bin/cppia/Host-debug", ["bin/unit.cppia"]);
  59. if (!isLinuxArm64) // FIXME
  60. runCpp("bin/cppia/Host-debug", ["bin/unit.cppia", "-jit"]);
  61. }
  62. Display.maybeRunDisplayTests(Cpp);
  63. changeDirectory(sysDir);
  64. runCommand("haxe", ["-D", archFlag, "--each", "compile-cpp.hxml"].concat(args));
  65. runSysTest(FileSystem.fullPath("bin/cpp/Main-debug"));
  66. if (!isLinuxArm64) { // FIXME
  67. changeDirectory(threadsDir);
  68. runCommand("haxe", ["-D", archFlag, "build.hxml", "-cpp", "export/cpp"]);
  69. runCpp("export/cpp/Main");
  70. }
  71. changeDirectory(getMiscSubDir("eventLoop"));
  72. runCommand("haxe", ["build-cpp.hxml"]);
  73. // TODO: check output like misc tests do
  74. runCpp("cpp/Main");
  75. if (Sys.systemName() == "Mac") {
  76. changeDirectory(getMiscSubDir("cppObjc"));
  77. runCommand("haxe", ["-D", archFlag, "build.hxml"]);
  78. runCpp("bin/TestObjc-debug");
  79. }
  80. changeDirectory(miscCppDir);
  81. runCommand("haxe", ["run.hxml"]);
  82. }
  83. }