xmake.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package("ifort")
  2. set_kind("toolchain")
  3. set_homepage("https://www.intel.com/content/www/us/en/developer/tools/oneapi/fortran-compiler.html")
  4. set_description("The Fortran Compiler provided by Intel®")
  5. if is_host("linux") then
  6. add_urls("https://registrationcenter-download.intel.com/akdlm/irc_nas/18210/l_fortran-compiler_p_$(version).sh", {version = function(version)
  7. return version:gsub("%+", ".")
  8. end})
  9. add_versions("2021.4.0+3224", "7fef4c98a86db04061634a462e8e4743d9a073f805c191db2a83ee161cea5313")
  10. elseif is_host("windows") then
  11. add_urls("https://registrationcenter-download.intel.com/akdlm/irc_nas/18215/w_fortran-compiler_p_$(version).exe", {version = function(version)
  12. return version:gsub("%+", ".")
  13. end})
  14. add_versions("2021.4.0+3208", "942e2f466ec70198a6137a60e3a96880a09cddce3a4a89c449dce20cad5d7a5a")
  15. elseif is_host("macosx") then
  16. add_urls("https://registrationcenter-download.intel.com/akdlm/irc_nas/18341/m_HPCKit_p_$(version)_offline.dmg", {version = function(version)
  17. return version:gsub("%+", ".")
  18. end})
  19. add_versions("2022.1.0+86", "c215cc7be7530fe0a60f4bda43923226d41f88a296134852252076a740a205c0")
  20. end
  21. on_fetch("@linux", function(package, opt)
  22. if opt.system then
  23. local ifortenv = import("detect.sdks.find_ifortenv")()
  24. if ifortenv then
  25. package:addenv("PATH", ifortenv.bindir)
  26. package:addenv("LD_LIBRARY_PATH", ifortenv.libdir)
  27. return true
  28. end
  29. end
  30. end)
  31. on_install("@linux", function(package)
  32. local arch = package:is_arch("x86_64") and "intel64" or "ia32"
  33. local plat = package:plat()
  34. local version = package:version():shortstr()
  35. local installdir = package:installdir()
  36. local homedir = path.absolute("home")
  37. if package:is_plat("windows") then
  38. -- windows is starting 'bootstrapper.exe' in another process
  39. -- and therefore xmake thinks it is done, so currently we need
  40. -- to disable it
  41. -- We could wait until the 'bootstrapper.exe' is done and then continue, maybe.
  42. os.execv(package:originfile(), {"-a", "-s", "--eula", "accept", "-p=NEED_VS2017_INTEGRATION=0", "--install-dir", installdir}, {envs = {HOME = homedir}})
  43. elseif package:is_plat("macosx") then
  44. -- this will cause the user permissions of the installation directory to
  45. -- be modified to root, so we can only temporarily disable the installation
  46. -- under macosx.
  47. plat = "macos"
  48. local mountdir
  49. local result = os.iorunv("hdiutil", {"attach", package:originfile()})
  50. if result then
  51. for _, line in ipairs(result:split("\n", {plain = true})) do
  52. local pos = line:find("/Volumes", 1, true)
  53. if pos then
  54. mountdir = line:sub(pos):trim()
  55. break
  56. end
  57. end
  58. end
  59. assert(mountdir and os.isdir(mountdir), "cannot mount %s", package:originfile())
  60. os.cp(path.join(mountdir, "bootstrapper.app"), "bootstrapper.app")
  61. os.execv("hdiutil", {"detach", mountdir})
  62. os.execv("sh", {"bootstrapper.app/Contents/MacOS/install.sh",
  63. "-s", "--eula", "accept", "--install-dir", installdir}, {envs = {HOME = homedir}})
  64. package:addenv("DYLD_LIBRARY_PATH", path.join(installdir, "compiler", version, plat, "compiler/lib", arch))
  65. else
  66. os.execv("sh", {package:originfile(), "-a", "-s", "--eula", "accept", "--install-dir", installdir}, {envs = {HOME = homedir}})
  67. package:addenv("LD_LIBRARY_PATH", path.join(installdir, "compiler", version, plat, "compiler/lib", arch))
  68. end
  69. package:addenv("PATH", path.join(installdir, "compiler", version, plat, "bin", arch))
  70. end)
  71. on_test(function (package)
  72. os.runv("ifort --version")
  73. end)