xmake.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package("emscripten")
  2. set_kind("toolchain")
  3. set_homepage("https://emscripten.org/")
  4. set_description("Emscripten: An LLVM-to-WebAssembly Compiler.")
  5. set_license("MIT")
  6. set_urls("https://github.com/emscripten-core/emsdk.git")
  7. add_versions("4.0.12", "f39e849effe1bd679aa9ef3cd1798d327c9619db")
  8. add_versions("3.1.55", "7815dcaa5c97ee387e925137a42dd4219e7cec82")
  9. add_versions("3.1.42", "c2260b4f28f53b411032de0955a6fe6b6bcf3edd")
  10. add_versions("3.1.25", "92d9023adc4dbc66424df9483cee302c68817d3c")
  11. add_versions("3.1.14", "517e02fac88b48c74da14b1cf7c6d51e489a5793")
  12. add_versions("1.39.8", "1458145cf4f3db0fb548343e6acab267eef8e4ef")
  13. add_deps("python")
  14. on_load(function (package)
  15. package:addenv("PATH", "upstream/emscripten")
  16. package:addenv("PATH", ".")
  17. package:addenv("EMSDK", ".")
  18. package:mark_as_pathenv("EMSDK")
  19. package:mark_as_pathenv("EMSDK_NODE")
  20. if package:is_plat("windows") then
  21. package:mark_as_pathenv("EMSDK_PYTHON")
  22. package:mark_as_pathenv("JAVA_HOME")
  23. end
  24. end)
  25. on_install("windows|!arm*", "macosx", "linux", function (package)
  26. import("lib.detect.find_directory")
  27. -- installation
  28. os.cp("*", package:installdir())
  29. local version = package:version():rawstr()
  30. local installdir = package:installdir()
  31. local py = package:is_plat("windows") and "python" or "python3"
  32. os.vrunv(py, {path.join(installdir, "emsdk.py"), "install", version})
  33. -- activation
  34. os.vrunv(py, {path.join(installdir, "emsdk.py"), "activate", version})
  35. -- setup env
  36. local exe = package:is_plat("windows") and ".exe" or ""
  37. local node_bindir = find_directory("bin", {path.join(installdir, "node", "**")})
  38. if node_bindir then
  39. node_bindir = path.relative(node_bindir, installdir)
  40. package:addenv("PATH", node_bindir)
  41. package:addenv("EMSDK_NODE", path.join(node_bindir, "node" .. exe))
  42. end
  43. if package:is_plat("windows") then
  44. local python = find_directory("*", path.join(installdir, "python"))
  45. if python then
  46. python = path.relative(python, installdir)
  47. package:addenv("EMSDK_PYTHON", path.join(python, "python" .. exe))
  48. end
  49. local java = find_directory("*", path.join(installdir, "java"))
  50. if java then
  51. java = path.relative(java, installdir)
  52. package:addenv("JAVA_HOME", java)
  53. end
  54. end
  55. end)
  56. on_test(function (package)
  57. local emcc = is_host("windows") and "emcc.bat" or "emcc"
  58. os.vrunv(emcc, {"--version"})
  59. end)