瀏覽代碼

v8: fix and update to 13.5.212.10 (#6863)

* v8: fix and update package for V8 library

- support latest stable version 13.5.212.10
- tested on Windows only
- fix syntax to configure "runtimes"
- only build static monolith flavor
- patch to fix build configuration of a third party
- erase previous version 10.0.58

* v8: improve code style, remove obsolete command

- don't need to reset core.longpaths option after running "gclient"
- use better API functions to get data from "package"
- fix code style

* v8: fix compilation for Linux

Untested for macOS, it might be enough.

* Update xmake.lua

* Update xmake.lua

* v8: fix compilation for CI

- configure a dummy Git account, required to use 'gclient'
- remove patch, build issue seems to have been fixed by Google.

* v8: remove support for macOS

Not tested locally and last CI workflow didn't work.

* v8: add checks for C++20 and MSVC/VS 2022 on Windows

* v8: scope cxxflags to Windows only when testing

* v8: only configured for static + release usage

* ci: try to free disk space in Ubuntu runner

Attempt to free disk space to provide enough storage to build V8 library.

* v8: use package's api to run environment checks

* v8: only configured for MT usage

Ignore MD compilation; it would need tests to actually make V8 compliant with MD, if possible.

* v8: should fix CI for Archlinux and Fedora

Should fix errors of compilation due to missing headers.

* v8: only check MT on Windows

* v8: fix imports and checks

* v8: remove redundant runtimes check

* Revert "v8: should fix CI for Archlinux and Fedora"

This reverts commit 60e921aba0d9b65f41364ec47aa8e5263e513bd4.

* v8: prevent builds on Archlinux / Fedora / Win11 arm64 / Linux arm64

* v8: prevent builds on Archlinux / Fedora / Win11 arm64 / Linux arm64

---------

Co-authored-by: ruki <[email protected]>
Louis Poirier 3 月之前
父節點
當前提交
23717061be
共有 2 個文件被更改,包括 106 次插入34 次删除
  1. 12 0
      .github/workflows/ubuntu.yml
  2. 94 34
      packages/v/v8/xmake.lua

+ 12 - 0
.github/workflows/ubuntu.yml

@@ -19,6 +19,18 @@ jobs:
         group: ${{ github.ref }}-${{ github.base_ref }}-${{ github.head_ref }}-Linux-${{ matrix.kind }}-${{ matrix.mode }}
         cancel-in-progress: true
     steps:
+      - name: Free Disk Space
+        uses: jlumbroso/[email protected]
+        with:
+          tool-cache: false
+
+          android: true
+          dotnet: true
+          haskell: true
+          large-packages: true
+          docker-images: true
+          swap-storage: true
+
       - uses: actions/checkout@v1
       - uses: xmake-io/github-action-setup-xmake@v1
         with:

+ 94 - 34
packages/v/v8/xmake.lua

@@ -1,9 +1,9 @@
 package("v8")
-    set_homepage("https://chromium.googlesource.com/v8/v8.git")
+    set_homepage("https://v8.dev")
     set_description("V8 JavaScript Engine")
 
     add_urls("https://github.com/v8/v8.git")
-    add_versions("10.0.58", "d75903764c8547b6fc35c7a3fe4991320be03135")
+    add_versions("13.5.212.10", "e2591684c45463aa1e46ebefc3fd35deee63f37c")
 
     add_deps("depot_tools")
 
@@ -11,26 +11,57 @@ package("v8")
         add_syslinks("pthread", "dl")
     elseif is_plat("windows") then
         add_syslinks("user32", "winmm", "advapi32", "dbghelp", "shlwapi")
-        add_configs("vs_runtime", {description = "Set vs runtime.", default = "MT", readonly = true})
+        add_configs("runtimes", {description = "Set runtime.", default = "MT", readonly = true})
     end
 
-    add_links("v8_monolith",
-              "v8_initializers",
-              "v8_init",
-              "v8_compiler",
-              "v8_compiler_opt",
-              "v8_cppgc_shared",
-              "v8_bigint",
-              "v8_snapshot",
-              "v8_base_without_compiler",
-              "v8_libplatform",
-              "v8_libbase",
-              "torque_base",
-              "torque_generated_definitions",
-              "cppgc_base",
-              "torque_ls_base")
-
-    on_install("linux", "macosx", "windows", function (package)
+    add_includedirs("include")
+    add_links("v8_monolith")
+
+    on_check(function (package)
+        local is_release = not package:is_debug()
+        local is_static = not package:config("shared")
+        local is_arm64 = package:is_arch("arm64")
+
+        -- Require C++20
+        assert(package:check_cxxsnippets({test = [[
+             #include <cstddef>
+             #include <iterator>
+             struct SimpleInputIterator {
+                 using difference_type = std::ptrdiff_t;
+                 using value_type = int;
+                 int operator*() const;
+                 SimpleInputIterator& operator++();
+                 void operator++(int) { ++*this; }
+             };
+             static_assert(std::input_iterator<SimpleInputIterator>);
+         ]]}, {configs = {languages = "c++20"}}), "package(v8): require at least C++20.")
+
+        -- Only configured and tested for:
+        assert(is_release and is_static, "package(v8): only configured for static + release usage.")
+
+        if package:is_plat("windows") then
+            -- Require MSVC / Visual Studio 2022
+            local msvc = package:toolchain("msvc")
+            if msvc then
+                local vs = msvc:config("vs")
+                local year = tonumber(vs)
+                assert(year >= 2022, "package(v8): require at least Visual Studio 2022.")
+            else
+                assert(false, "package(v8): only configured for MSVC on Windows.")
+            end
+
+            local is_win11 = winos.version():ge("10.0.22000+194")
+            assert(not (is_win11 and is_arm64), "package(v8): Windows 11 arm64 is not supported.")
+        elseif package:is_plat("linux") then
+            local distrib = linuxos.name()
+
+            assert(distrib ~= "archlinux", "package(v8): Archlinux is not supported.")
+            assert(distrib ~= "fedora", "package(v8): Fedora is not supported.")
+            assert(not is_arm64, "package(v8): Linux arm64 is not supported.")
+        end
+    end)
+
+    on_install("linux", "windows", function (package)
         import("core.base.global")
 
         -- maybe we need set proxy, e.g. `xmake g --proxy=http://127.0.0.1:xxxx`
@@ -49,30 +80,51 @@ package("v8")
     "managed": False,
     "custom_deps": {},
   }]]=])
+
         if package:is_plat("windows") then
-            envs.DEPOT_TOOLS_WIN_TOOLCAHIN = "0"
+            envs.DEPOT_TOOLS_WIN_TOOLCHAIN = "0"
+            envs.GYP_MSVS_VERSION = "2022"
         end
-        local gclient = is_host("windows") and "gclient.bat" or "gclient"
+
+        local gclient = package:is_plat("windows") and "gclient.bat" or "gclient"
+
+        -- A Git account needs to be configured
+        os.vrunv("git", {"config", "user.email", "[email protected]"})
+        os.vrunv("git", {"config", "user.name", "Dummy Dummy"})
+
+        -- Prevent long path issue on Windows
+        os.vrunv("git", {"config", "--local", "core.longpaths", "true"})
+
+        -- Update repository and dependencies
+        -- Clean any local changes to apply patches
         os.vrunv(gclient, {"sync", "-v"}, {envs = envs})
+
+        -- Setup args.gn
         local configs = {
             is_official_build = false,
             is_component_build = false,
-            is_debug = package:debug(),
-            is_shared_library = package:config("shared"),
-            symbol_level = 0,
+            is_debug = package:is_debug(),
+            symbol_level = package:is_debug() and 2 or 0,
+            strip_debug_info = not package:is_debug(),
             treat_warnings_as_errors = false,
             use_custom_libcxx = false,
-            v8_static_library = not package:config("shared"),
             v8_monolithic = true,
-            v8_use_external_startup_data = false,
+            v8_enable_sandbox = false,
+            v8_enable_pointer_compression = false,
+            v8_enable_webassembly = false,
+            v8_enable_gdbjit = package:is_debug(),
+            v8_enable_i18n_support = false,
             v8_enable_test_features = false,
-            v8_enable_i18n_support = false}
-
-        if package:is_plat("windows") then
-            configs.extra_cflags = {(package:config("vs_runtime"):startswith("MT") and "/MT" or "/MD")}
-            configs.is_clang = false 
+            v8_use_external_startup_data = false
+        }
+        if not package:is_plat("windows") then
+            configs.is_clang = false
         end
-        import("package.tools.gn").build(package, configs, {buildir = "out.gn"})
+
+        -- Build V8 library
+        import("package.tools.gn").build(package, configs, {buildir = "out.gn", target = {"v8_monolith"}})
+
+        -- Install headers and library files
         os.cp("include", package:installdir())
         os.trycp("out.gn/obj/*.a", package:installdir("lib"))
         os.trycp("out.gn/obj/*.lib", package:installdir("lib"))
@@ -80,5 +132,13 @@ package("v8")
     end)
 
     on_test(function (package)
-        assert(package:has_cxxfuncs("v8::V8::InitializePlatform(0)", {configs = {languages = "c++17"}, includes = "v8.h"}))
+        local cxxflags = package:is_plat("windows") and "/Zc:__cplusplus" or ""
+
+        assert(package:has_cxxfuncs("v8::V8::InitializePlatform(0)", {
+            configs = {
+                languages = "c++20",
+                cxxflags = cxxflags
+            },
+            includes = "v8.h"
+        }))
     end)