Cpp.hx 2.7 KB

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