2
0

xmake.lua 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. end
  10. add_links("v8_monolith",
  11. "v8_initializers",
  12. "v8_init",
  13. "v8_compiler",
  14. "v8_compiler_opt",
  15. "v8_cppgc_shared",
  16. "v8_bigint",
  17. "v8_snapshot",
  18. "v8_base_without_compiler",
  19. "v8_libplatform",
  20. "v8_libbase",
  21. "torque_base",
  22. "torque_generated_definitions",
  23. "cppgc_base",
  24. "torque_ls_base")
  25. on_install("linux", "macosx", function (package)
  26. import("core.base.global")
  27. -- maybe we need set proxy, e.g. `xmake g --proxy=http://127.0.0.1:xxxx`
  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. io.writefile(".gclient", [=[solutions = [
  36. {
  37. "name": ".",
  38. "url": "https://github.com/v8/v8.git",
  39. "deps_file": "DEPS",
  40. "managed": False,
  41. "custom_deps": {},
  42. }]]=])
  43. local gclient = is_host("windows") and "gclient.bat" or "gclient"
  44. os.vrunv(gclient, {"sync", "-v"}, {envs = envs})
  45. local configs = {
  46. is_official_build = false,
  47. is_component_build = false,
  48. is_debug = package:debug(),
  49. is_shared_library = package:config("shared"),
  50. symbol_level = 0,
  51. treat_warnings_as_errors = false,
  52. use_custom_libcxx = false,
  53. v8_static_library = not package:config("shared"),
  54. v8_monolithic = true,
  55. v8_use_external_startup_data = false,
  56. v8_enable_test_features = false,
  57. v8_enable_i18n_support = false}
  58. if package:is_arch("x86", "i386") then
  59. configs.target_cpu = "x86"
  60. elseif package:is_arch("x64", "x86_64") then
  61. configs.target_cpu = "x64"
  62. elseif package:is_arch("arm64", "arm64-v8a") then
  63. configs.target_cpu = "arm64"
  64. end
  65. if not package:is_plat("windows") then
  66. configs.cc = package:build_getenv("cc")
  67. configs.cxx = package:build_getenv("cxx")
  68. else
  69. configs.extra_cflags = {(package:config("vs_runtime"):startswith("MT") and "/MT" or "/MD")}
  70. end
  71. if package:is_plat("macosx") then
  72. configs.extra_ldflags = {"-lstdc++"}
  73. local xcode = import("core.tool.toolchain").load("xcode", {plat = package:plat(), arch = package:arch()})
  74. configs.xcode_sysroot = xcode:config("xcode_sysroot")
  75. end
  76. import("package.tools.gn").build(package, configs, {buildir = "out"})
  77. os.cp("include", package:installdir())
  78. os.trycp("out/obj/*.a", package:installdir("lib"))
  79. os.trycp("out/obj/*.lib", package:installdir("lib"))
  80. os.trycp("out/obj/*.dll", package:installdir("bin"))
  81. end)
  82. on_test(function (package)
  83. assert(package:has_cxxfuncs("v8::V8::InitializePlatform(0)", {configs = {languages = "c++17"}, includes = "v8.h"}))
  84. end)