xmake.lua 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. add_versions("2024.7.4", "452fe3be37f78fbecefa1b4b0d359531bcd70d0d")
  10. -- we use external ninja instead of depot_tools/ninja which eating ram until VM exhaustion (16GB)
  11. add_deps("ninja", {private = true, system = false})
  12. on_load(function (package)
  13. package:addenv("PATH", ".")
  14. package:addenv("PATH", "python-bin")
  15. package:addenv("DEPOT_TOOLS_UPDATE", "0")
  16. package:addenv("DEPOT_TOOLS_METRICS", "0")
  17. package:addenv("DEPOT_TOOLS_WIN_TOOLCHAIN", "0")
  18. end)
  19. on_install("linux", "macosx", "windows", function (package)
  20. import("core.base.global")
  21. local sourcedir = os.curdir()
  22. os.cp("*", package:installdir())
  23. os.cd(package:installdir())
  24. -- maybe we need set proxy, e.g. `xmake g --proxy=http://127.0.0.1:xxxx`
  25. -- @note we must use http proxy instead of socks5 proxy
  26. local envs = {}
  27. local proxy = global.get("proxy")
  28. if proxy then
  29. envs.HTTP_PROXY = proxy
  30. envs.HTTPS_PROXY = proxy
  31. envs.ALL_PROXY = proxy
  32. end
  33. envs.PATH = table.join(sourcedir, path.splitenv(os.getenv("PATH")))
  34. -- skip to check and update obsolete URL
  35. io.replace("./update_depot_tools",
  36. 'CANONICAL_GIT_URL="https://chromium.googlesource.com/chromium/tools/depot_tools.git"',
  37. 'CANONICAL_GIT_URL="https://github.com/xmake-mirror/depot_tools.git"', {plain = true})
  38. io.replace("./update_depot_tools", 'remote_url=$(eval "$GIT" config --get remote.origin.url)',
  39. 'remote_url="https://github.com/xmake-mirror/depot_tools.git"', {plain = true})
  40. os.vrunv("git", {"config", "user.email", "[email protected]"})
  41. os.vrunv("git", {"config", "user.name", "me"})
  42. os.vrunv("git", {"commit", "-a", "-m", "..."})
  43. -- we need fetch some files when running gclient for the first time
  44. if is_host("windows") then
  45. os.vrunv("gclient.bat", {"--verbose"}, {envs = envs})
  46. else
  47. os.vrunv("./gclient", {"--verbose"}, {shell = true, envs = envs})
  48. end
  49. local ninja = path.join(package:dep("ninja"):installdir("bin"), "ninja" .. (is_host("windows") and ".exe" or ""))
  50. if ninja and os.isfile(ninja) then
  51. os.cp(ninja, package:installdir())
  52. end
  53. end)
  54. on_test(function (package)
  55. import("core.base.global")
  56. os.vrun("python3 --version")
  57. os.vrun("ninja --version")
  58. local envs = {}
  59. local proxy = global.get("proxy")
  60. if proxy then
  61. envs.HTTP_PROXY = proxy
  62. envs.HTTPS_PROXY = proxy
  63. envs.ALL_PROXY = proxy
  64. end
  65. os.vrunv(is_host("windows") and "gclient.bat" or "gclient", {"--version"}, {envs = envs})
  66. end)