xmake.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package("depot_tools")
  2. set_kind("binary")
  3. set_homepage("https://chromium.googlesource.com/chromium/tools/depot_tools")
  4. set_description("Tools for working with Chromium development")
  5. add_urls("https://github.com/xmake-mirror/depot_tools.git",
  6. "https://chromium.googlesource.com/chromium/tools/depot_tools.git")
  7. add_versions("2022.2.1", "8a6d00f116d6de9d5c4e92acb519fd0859c6449a")
  8. add_versions("2024.2.29", "50de666ba40a4808daf9791fece3d8a43228a1de")
  9. -- we use external ninja instead of depot_tools/ninja which eating ram until VM exhaustion (16GB)
  10. add_deps("ninja", {private = true, system = false})
  11. on_load(function (package)
  12. package:addenv("PATH", ".")
  13. package:addenv("PATH", "python-bin")
  14. package:addenv("DEPOT_TOOLS_UPDATE", "0")
  15. package:addenv("DEPOT_TOOLS_METRICS", "0")
  16. package:addenv("DEPOT_TOOLS_WIN_TOOLCHAIN", "0")
  17. end)
  18. on_install("linux", "macosx", "windows", function (package)
  19. import("core.base.global")
  20. local ninja = path.join(package:dep("ninja"):installdir("bin"), "ninja" .. (is_host("windows") and ".exe" or ""))
  21. if ninja and os.isfile(ninja) then
  22. os.trycp(ninja, os.curdir())
  23. end
  24. os.cp("*", package:installdir())
  25. os.cd(package:installdir())
  26. -- maybe we need set proxy, e.g. `xmake g --proxy=http://127.0.0.1:xxxx`
  27. -- @note we must use http proxy instead of socks5 proxy
  28. local envs = {}
  29. local proxy = global.get("proxy")
  30. if proxy then
  31. envs.HTTP_PROXY = proxy
  32. envs.HTTPS_PROXY = proxy
  33. envs.ALL_PROXY = proxy
  34. end
  35. envs.PATH = table.join(os.curdir(), path.splitenv(os.getenv("PATH")))
  36. -- skip to check and update obsolete URL
  37. io.replace("./update_depot_tools",
  38. 'CANONICAL_GIT_URL="https://chromium.googlesource.com/chromium/tools/depot_tools.git"',
  39. 'CANONICAL_GIT_URL="https://github.com/xmake-mirror/depot_tools.git"', {plain = true})
  40. -- we need fetch some files when running gclient for the first time
  41. if is_host("windows") then
  42. os.vrunv("gclient.bat", {"--verbose"}, {envs = envs})
  43. else
  44. os.vrunv("./gclient", {"--verbose"}, {shell = true, envs = envs})
  45. end
  46. end)
  47. on_test(function (package)
  48. import("core.base.global")
  49. os.vrun("python3 --version")
  50. os.vrun("ninja --version")
  51. local envs = {}
  52. local proxy = global.get("proxy")
  53. if proxy then
  54. envs.HTTP_PROXY = proxy
  55. envs.HTTPS_PROXY = proxy
  56. envs.ALL_PROXY = proxy
  57. end
  58. os.vrunv(is_host("windows") and "gclient.bat" or "gclient", {"--version"}, {envs = envs})
  59. end)