xmake.lua 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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("3.1.55", "7815dcaa5c97ee387e925137a42dd4219e7cec82")
  8. add_versions("3.1.42", "c2260b4f28f53b411032de0955a6fe6b6bcf3edd")
  9. add_versions("3.1.25", "92d9023adc4dbc66424df9483cee302c68817d3c")
  10. add_versions("3.1.14", "517e02fac88b48c74da14b1cf7c6d51e489a5793")
  11. add_versions("1.39.8", "1458145cf4f3db0fb548343e6acab267eef8e4ef")
  12. add_deps("python")
  13. on_load(function (package)
  14. package:addenv("PATH", "upstream/emscripten")
  15. package:addenv("PATH", ".")
  16. package:addenv("EMSDK", ".")
  17. package:mark_as_pathenv("EMSDK")
  18. package:mark_as_pathenv("EMSDK_NODE")
  19. if package:is_plat("windows") then
  20. package:mark_as_pathenv("EMSDK_PYTHON")
  21. package:mark_as_pathenv("JAVA_HOME")
  22. end
  23. end)
  24. on_install("windows", "macosx", "linux", function (package)
  25. import("lib.detect.find_directory")
  26. -- installation
  27. os.cp("*", package:installdir())
  28. local version = package:version():rawstr()
  29. local installdir = package:installdir()
  30. local py = package:is_plat("windows") and "python" or "python3"
  31. os.vrunv(py, {path.join(installdir, "emsdk.py"), "install", version})
  32. -- activation
  33. os.vrunv(py, {path.join(installdir, "emsdk.py"), "activate", version})
  34. -- setup env
  35. local exe = package:is_plat("windows") and ".exe" or ""
  36. local node_bindir = find_directory("bin", {path.join(installdir, "node", "**")})
  37. if node_bindir then
  38. node_bindir = path.relative(node_bindir, installdir)
  39. package:addenv("PATH", node_bindir)
  40. package:addenv("EMSDK_NODE", path.join(node_bindir, "node" .. exe))
  41. end
  42. if package:is_plat("windows") then
  43. local python = find_directory("*", path.join(installdir, "python"))
  44. if python then
  45. python = path.relative(python, installdir)
  46. package:addenv("EMSDK_PYTHON", path.join(python, "python" .. exe))
  47. end
  48. local java = find_directory("*", path.join(installdir, "java"))
  49. if java then
  50. java = path.relative(java, installdir)
  51. package:addenv("JAVA_HOME", java)
  52. end
  53. end
  54. end)
  55. on_test(function (package)
  56. local emcc = is_host("windows") and "emcc.bat" or "emcc"
  57. os.vrunv(emcc, {"--version"})
  58. end)