xmake.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package("v8")
  2. set_homepage("https://chromium.googlesource.com/v8/v8.git")
  3. set_description("V8 JavaScript Engine")
  4. add_urls("https://github.com/v8/v8.git")
  5. add_versions("10.0.58", "d75903764c8547b6fc35c7a3fe4991320be03135")
  6. add_deps("depot_tools")
  7. if is_plat("linux", "bsd") then
  8. add_syslinks("pthread", "dl")
  9. elseif is_plat("windows") then
  10. add_syslinks("user32", "winmm", "advapi32", "dbghelp", "shlwapi")
  11. add_configs("vs_runtime", {description = "Set vs runtime.", default = "MT", readonly = true})
  12. end
  13. add_links("v8_monolith",
  14. "v8_initializers",
  15. "v8_init",
  16. "v8_compiler",
  17. "v8_compiler_opt",
  18. "v8_cppgc_shared",
  19. "v8_bigint",
  20. "v8_snapshot",
  21. "v8_base_without_compiler",
  22. "v8_libplatform",
  23. "v8_libbase",
  24. "torque_base",
  25. "torque_generated_definitions",
  26. "cppgc_base",
  27. "torque_ls_base")
  28. on_install("linux", "macosx", "windows", function (package)
  29. import("core.base.global")
  30. -- maybe we need set proxy, e.g. `xmake g --proxy=http://127.0.0.1:xxxx`
  31. local envs = {}
  32. local proxy = global.get("proxy")
  33. if proxy then
  34. envs.HTTP_PROXY = proxy
  35. envs.HTTPS_PROXY = proxy
  36. envs.ALL_PROXY = proxy
  37. end
  38. io.writefile(".gclient", [=[solutions = [
  39. {
  40. "name": ".",
  41. "url": "https://github.com/v8/v8.git",
  42. "deps_file": "DEPS",
  43. "managed": False,
  44. "custom_deps": {},
  45. }]]=])
  46. if package:is_plat("windows") then
  47. envs.DEPOT_TOOLS_WIN_TOOLCAHIN = "0"
  48. end
  49. local gclient = is_host("windows") and "gclient.bat" or "gclient"
  50. os.vrunv(gclient, {"sync", "-v"}, {envs = envs})
  51. local configs = {
  52. is_official_build = false,
  53. is_component_build = false,
  54. is_debug = package:debug(),
  55. is_shared_library = package:config("shared"),
  56. symbol_level = 0,
  57. treat_warnings_as_errors = false,
  58. use_custom_libcxx = false,
  59. v8_static_library = not package:config("shared"),
  60. v8_monolithic = true,
  61. v8_use_external_startup_data = false,
  62. v8_enable_test_features = false,
  63. v8_enable_i18n_support = false}
  64. if package:is_plat("windows") then
  65. configs.extra_cflags = {(package:config("vs_runtime"):startswith("MT") and "/MT" or "/MD")}
  66. configs.is_clang = false
  67. end
  68. import("package.tools.gn").build(package, configs, {buildir = "out.gn"})
  69. os.cp("include", package:installdir())
  70. os.trycp("out.gn/obj/*.a", package:installdir("lib"))
  71. os.trycp("out.gn/obj/*.lib", package:installdir("lib"))
  72. os.trycp("out.gn/obj/*.dll", package:installdir("bin"))
  73. end)
  74. on_test(function (package)
  75. assert(package:has_cxxfuncs("v8::V8::InitializePlatform(0)", {configs = {languages = "c++17"}, includes = "v8.h"}))
  76. end)