Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using NiceIO.Sysroot;
  6. using UnityEditor.Il2Cpp;
  7. namespace UnityEditor.Il2Cpp
  8. {
  9. /// <summary>
  10. /// Toolchain for building Linux x86_64 target on Windows x86_64 host
  11. /// </summary>
  12. public class ToolchainWindowsX86_64LinuxX86_64: SysrootLinuxX86_64
  13. {
  14. private string _packageName => "com.unity.toolchain.win-x86_64-linux-x86_64";
  15. /// <summary>
  16. /// Name of package
  17. /// </summary>
  18. public override string Name => _packageName;
  19. /// <summary>
  20. /// Name of host platform
  21. /// </summary>
  22. public override string HostPlatform => "windows";
  23. /// <summary>
  24. /// Name of host architecture
  25. /// </summary>
  26. public override string HostArch => "x86_64";
  27. /// <summary>
  28. /// Name of target platform
  29. /// </summary>
  30. public override string TargetPlatform => "linux";
  31. /// <summary>
  32. /// Name of target architecture
  33. /// </summary>
  34. public override string TargetArch => "x86_64";
  35. private string _payloadVersion => "llvm-9.0.1-1";
  36. private string _payloadDir;
  37. private string _target = "x86_64-glibc2.17-linux-gnu";
  38. private string _linkerFile => "bin/ld.lld";
  39. private NPath _toolchainPath = null;
  40. public ToolchainWindowsX86_64LinuxX86_64()
  41. {
  42. _payloadDir = $"windows-x86_64-linux-x86_64/{_payloadVersion}";
  43. RegisterPayload(_packageName, _payloadDir);
  44. _toolchainPath = PayloadInstallDirectory(_payloadDir);
  45. }
  46. /// <summary>
  47. /// Initialize toolchain
  48. /// </summary>
  49. public override bool Initialize()
  50. {
  51. UpdatePath();
  52. return base.Initialize();
  53. }
  54. private void UpdatePath()
  55. {
  56. string binPath = _toolchainPath.Combine("bin").ToString(SlashMode.Native);
  57. string paths = Environment.GetEnvironmentVariable("PATH");
  58. foreach (var path in paths.Split(';'))
  59. {
  60. if (path == binPath)
  61. return;
  62. }
  63. Environment.SetEnvironmentVariable("PATH", $"{paths};{binPath}");
  64. }
  65. /// <summary>
  66. /// Supplies arguments to il2cpp.exe
  67. /// </summary>
  68. /// <returns>Next argument to il2cpp.exe</returns>
  69. public override IEnumerable<string> GetIl2CppArguments()
  70. {
  71. var linkerpath = _toolchainPath.Combine(_linkerFile);
  72. yield return $"--sysroot-path={SysrootInstallDirectory()}";
  73. yield return $"--compiler-flags=\"-target {_target}\"";
  74. yield return $"--tool-chain-path={_toolchainPath.InQuotes(SlashMode.Forward)}";
  75. yield return $"--linker-flags=\"-fuse-ld=\"{linkerpath.InQuotes(SlashMode.Forward)}\" -target {_target} -static-libstdc++\"";
  76. }
  77. #if !IL2CPP_LEGACY_API_PRESENT
  78. public override string GetSysrootPath()
  79. {
  80. return SysrootInstallDirectory().Trim('"');
  81. }
  82. public override string GetToolchainPath()
  83. {
  84. return _toolchainPath.ToString();
  85. }
  86. public override string GetIl2CppCompilerFlags()
  87. {
  88. return $"-target {_target}";
  89. }
  90. public override string GetIl2CppLinkerFlags()
  91. {
  92. var linkerpath = _toolchainPath.Combine(_linkerFile);
  93. return $"-fuse-ld={linkerpath.InQuotes(SlashMode.Forward)} -target {_target} -static-libstdc++";
  94. }
  95. #endif
  96. }
  97. }