From 47d06f9131bc03213b3afc09d09023b4d656d48e Mon Sep 17 00:00:00 2001 From: ienaga Date: Thu, 2 Jul 2026 18:13:27 +0900 Subject: [PATCH 1/6] =?UTF-8?q?wip:=20v8=E3=83=93=E3=83=AB=E3=83=89?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-v8.yml | 105 +++++++++++++++++++++++++++++++++ README.md | 6 +- src/index.ts | 105 ++++++++++++++++++++++++++++----- templates/xbox/README.md | 62 ++++++++++++++++--- 4 files changed, 254 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/build-v8.yml diff --git a/.github/workflows/build-v8.yml b/.github/workflows/build-v8.yml new file mode 100644 index 0000000..8779852 --- /dev/null +++ b/.github/workflows/build-v8.yml @@ -0,0 +1,105 @@ +# V8 monolith (Windows x64) を GitHub Actions 上でビルドし、Releases へ発行する。 +# +# 目的: ゲーム開発者が `npx @next2d/builder --platform xbox` を実行したとき、 +# builder がここで発行した prebuilt を自動ダウンロードできるようにする +# (`--v8-root` / V8_ROOT の指定を不要にする)。 +# +# 運用: 手動トリガー (Actions タブ → build-v8 → Run workflow)。 +# バージョンを上げるときは v8_version を変えて実行し、src/index.ts の +# XBOX_V8_VERSION と xbox-host-ci.yml の V8_TAG を同じ値に更新する。 +# +# 所要: 約 2〜4 時間 (V8 のフルビルド)。job 上限 6 時間以内。 +name: build-v8 + +on: + workflow_dispatch: + inputs: + v8_version: + description: "V8 version tag (https://github.com/v8/v8/tags)" + required: true + default: "13.6.233.17" + +permissions: + contents: write # Releases への発行に必要 + +jobs: + build-v8-windows-x64: + runs-on: windows-latest + timeout-minutes: 360 + steps: + - name: Setup depot_tools + shell: pwsh + working-directory: ${{ runner.temp }} + run: | + git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + Add-Content $env:GITHUB_PATH "$env:RUNNER_TEMP\depot_tools" + Add-Content $env:GITHUB_ENV "DEPOT_TOOLS_WIN_TOOLCHAIN=0" + + - name: Fetch V8 ${{ inputs.v8_version }} (no history) + shell: cmd + working-directory: ${{ runner.temp }} + env: + V8_VERSION: ${{ inputs.v8_version }} + run: | + call fetch --no-history v8 + if errorlevel 1 exit /b 1 + cd v8 + git fetch --depth 1 origin refs/tags/%V8_VERSION% + if errorlevel 1 exit /b 1 + git checkout FETCH_HEAD + if errorlevel 1 exit /b 1 + call gclient sync -D + if errorlevel 1 exit /b 1 + + - name: Build v8_monolith + shell: cmd + working-directory: ${{ runner.temp }}/v8 + run: | + rem フラグはホスト側 (templates/xbox/CMakeLists.txt) の defines と一致させること: + rem v8_enable_pointer_compression <-> V8_COMPRESS_POINTERS + rem v8_enable_sandbox <-> V8_ENABLE_SANDBOX + rem use_custom_libcxx=false : MSVC (MS STL) とのリンクに必須 + rem icu_use_data_file=false : icudtl.dat の同梱を不要にする + call gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false use_custom_libcxx=false icu_use_data_file=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=true" + if errorlevel 1 exit /b 1 + call ninja -C out\x64.release v8_monolith + if errorlevel 1 exit /b 1 + + - name: Package (include/ + lib/v8_monolith.lib) + shell: pwsh + working-directory: ${{ runner.temp }}/v8 + run: | + New-Item -ItemType Directory -Force package/lib | Out-Null + Copy-Item include package/include -Recurse + Copy-Item out/x64.release/obj/v8_monolith.lib package/lib/ + Copy-Item out/x64.release/args.gn package/ + "${{ inputs.v8_version }}" | Set-Content package/VERSION.txt + $zip = "$env:GITHUB_WORKSPACE/v8-monolith-${{ inputs.v8_version }}-windows-x64.zip" + Compress-Archive -Path package/* -DestinationPath $zip + Get-Item $zip | Select-Object Name, Length + + - name: Publish to GitHub Releases + shell: pwsh + env: + GH_TOKEN: ${{ github.token }} + run: | + $tag = "v8-${{ inputs.v8_version }}-windows-x64" + $zip = "v8-monolith-${{ inputs.v8_version }}-windows-x64.zip" + $notes = @" + Prebuilt V8 monolith for the Next2D Xbox host (windows-x64). + + - V8 ``${{ inputs.v8_version }}`` / VS2022 (windows-latest runner) + - gn args: monolithic, no external startup data, use_custom_libcxx=false, + icu_use_data_file=false, pointer compression + sandbox enabled + - Layout: ``include/`` + ``lib/v8_monolith.lib`` (pass the extracted dir to ``--v8-root``) + + ``npx @next2d/builder --platform xbox`` downloads this automatically when + ``--v8-root`` / ``V8_ROOT`` is not specified. + "@ + # 既存タグなら差し替え、無ければ新規作成 + gh release view $tag --repo ${{ github.repository }} 2>$null + if ($LASTEXITCODE -eq 0) { + gh release upload $tag $zip --clobber --repo ${{ github.repository }} + } else { + gh release create $tag $zip --title $tag --notes $notes --repo ${{ github.repository }} + } diff --git a/README.md b/README.md index 0056023..3186dd8 100644 --- a/README.md +++ b/README.md @@ -48,9 +48,13 @@ On other platforms the builder scaffolds the host project and stages assets only See the generated `xbox/README.md` for full build steps. ```bat -npx @next2d/builder --platform xbox --env prd --v8-root C:\path\to\v8 +npx @next2d/builder --platform xbox --env prd ``` +The prebuilt V8 engine is downloaded automatically on the first Xbox build +(published from the `build-v8` workflow). To use your own build, pass +`--v8-root C:\path\to\v8`. + ### Scheduled introduction | platform | diff --git a/src/index.ts b/src/index.ts index 1c2d0b5..f33a87b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ import pc from "picocolors"; import fs from "fs"; +import os from "os"; import path from "path"; import { fileURLToPath } from "url"; import cp from "child_process"; @@ -95,8 +96,9 @@ const echoHelp = (): void => console.log("For preview example:"); console.log("npx @next2d/builder --preview --platform web --env prd"); console.log(); - console.log("For Xbox build example (prebuilt V8 monolith path):"); - console.log("npx @next2d/builder --platform xbox --env prd --v8-root C:\\path\\to\\v8"); + console.log("For Xbox build example (prebuilt V8 is downloaded automatically):"); + console.log("npx @next2d/builder --platform xbox --env prd"); + console.log("To use your own V8 build: --v8-root C:\\path\\to\\v8"); console.log(); process.exit(1); }; @@ -613,6 +615,18 @@ const getTemplateDir = (name: string): string => */ const XBOX_CONFIG_NAME: string = "MicrosoftGame.config"; +/** + * @description 自動ダウンロードする prebuilt V8 のバージョン。 + * `.github/workflows/build-v8.yml` で発行した Releases のタグと、 + * `xbox-host-ci.yml` の V8_TAG に一致させること。 + * The prebuilt V8 version to auto-download. Must match the release tag + * published by `build-v8.yml` and V8_TAG in `xbox-host-ci.yml`. + * + * @type {string} + * @constant + */ +const XBOX_V8_VERSION: string = "13.6.233.17"; + /** * @description ゲーム側の `xbox/` へスキャフォールドしないテンプレート内ファイル。 * - MicrosoftGame.config : ゲーム固有設定 (injectGameConfig が注入) @@ -735,6 +749,69 @@ const copyXboxResources = (): Promise => }); }; +/** + * @description Xbox ビルドに使う V8 のパスを解決する。優先順: + * 1. `--v8-root` 引数 + * 2. 環境変数 `V8_ROOT` + * 3. キャッシュ済みの prebuilt (%LOCALAPPDATA%/next2d/v8/) + * 4. GitHub Releases (build-v8.yml が発行) から自動ダウンロード + * 3・4 により、通常は何も指定せずに `--platform xbox` だけでビルドできる。 + * Resolve the V8 path for the Xbox build. With the cached/auto-downloaded + * prebuilt, no flag or env var is required in the common case. + * + * @return {Promise} + * @method + * @public + */ +const resolveXboxV8Root = async (): Promise => +{ + // 1. --v8-root 引数 + if (v8Root) { + return path.resolve(process.cwd(), v8Root); + } + + // 2. 環境変数 V8_ROOT + if (process.env.V8_ROOT) { + return process.env.V8_ROOT; + } + + // 3. キャッシュ済み prebuilt + const cacheBase: string = process.env.LOCALAPPDATA + ? `${process.env.LOCALAPPDATA}/next2d` + : `${os.homedir()}/.cache/next2d`; + const cacheDir: string = `${cacheBase}/v8/${XBOX_V8_VERSION}`; + if (fs.existsSync(`${cacheDir}/include/v8.h`)) { + return cacheDir; + } + + // 4. GitHub Releases から自動ダウンロード (マシンごとに初回のみ) + const assetName: string = `v8-monolith-${XBOX_V8_VERSION}-windows-x64.zip`; + const url: string = `https://github.com/Next2D/builder/releases/download/v8-${XBOX_V8_VERSION}-windows-x64/${assetName}`; + + console.log(pc.green(`Downloading prebuilt V8 ${XBOX_V8_VERSION} (first time only) ...`)); + console.log(url); + + const response = await fetch(url); + if (!response.ok) { + throw new Error(`download failed: HTTP ${response.status}`); + } + + fs.mkdirSync(cacheDir, { "recursive": true }); + const zipPath: string = `${cacheDir}/${assetName}.tmp`; + fs.writeFileSync(zipPath, Buffer.from(await response.arrayBuffer())); + + // Windows 10+ 標準の tar (bsdtar) は zip も展開できる + const extract = cp.spawnSync("tar", ["-xf", zipPath, "-C", cacheDir], { "stdio": "inherit" }); + fs.rmSync(zipPath, { "force": true }); + if (extract.status !== 0 || !fs.existsSync(`${cacheDir}/include/v8.h`)) { + fs.rmSync(cacheDir, { "recursive": true, "force": true }); + throw new Error("failed to extract the prebuilt V8 archive"); + } + + console.log(pc.green(`Prebuilt V8 cached at: ${cacheDir}`)); + return cacheDir; +}; + /** * @description Xbox(GDKネイティブ)用アプリの書き出し関数。 * V8にNext2DのJSを載せ、Dawn(WebGPU/D3D12)で描画するC++ホストをビルドする。 @@ -778,19 +855,19 @@ const buildXbox = async (): Promise => const cmakeBuildDir: string = `${process.cwd()}/${$outDir}/${platformDir}/build`; /** - * prebuilt V8 monolith のパス。優先順: `--v8-root` 引数 > 環境変数 V8_ROOT。 - * どちらも無い場合は CMake (FindV8.cmake) が明確なエラーで停止するため、 - * ここでは事前に分かりやすく案内だけする。 + * prebuilt V8 のパスを解決する (--v8-root > V8_ROOT > キャッシュ > 自動ダウンロード)。 + * 通常は何も指定せずにビルドできる。 */ - const resolvedV8Root: string = v8Root - ? path.resolve(process.cwd(), v8Root) - : process.env.V8_ROOT || ""; - - if (!resolvedV8Root) { - console.log(pc.red("V8 path is not specified.")); - console.log(pc.red("Pass `--v8-root ` (or set the V8_ROOT environment variable):")); - console.log(pc.red(" npx @next2d/builder --platform xbox --env prd --v8-root C:\\path\\to\\v8")); - console.log(pc.red(`The path must contain \`include/v8.h\` and \`lib/v8_monolith.lib\`. See ${XBOX_DIR_NAME}/README.md.`)); + let resolvedV8Root: string = ""; + try { + resolvedV8Root = await resolveXboxV8Root(); + } catch (error) { + console.log(pc.red(`Failed to prepare the prebuilt V8: ${error}`)); + console.log(pc.red("Fallbacks:")); + console.log(pc.red(" 1) Retry later (the download may have failed temporarily).")); + console.log(pc.red(" 2) Build V8 yourself and pass `--v8-root `:")); + console.log(pc.red(" npx @next2d/builder --platform xbox --env prd --v8-root C:\\path\\to\\v8")); + console.log(pc.red(` See ${XBOX_DIR_NAME}/README.md ("V8 の用意") for the build steps.`)); return; } if (!fs.existsSync(`${resolvedV8Root}/include/v8.h`)) { diff --git a/templates/xbox/README.md b/templates/xbox/README.md index 211b7c2..0745910 100644 --- a/templates/xbox/README.md +++ b/templates/xbox/README.md @@ -75,7 +75,7 @@ C++ 実行ファイルをビルドします。Electron や WebView は使用し | IDE | Visual Studio 2022 (v143, C++ Game development workload) | | GDK | Microsoft GDK (June 2024 以降) — ID@Xbox 登録が必要 | | CMake | 3.26 以降 | -| V8 | prebuilt monolith (`v8_monolith.lib` + `include/`) | +| V8 | 不要 (builder が prebuilt を自動ダウンロード)。自前ビルドは `--v8-root` で指定可 | | Dawn | CMake の FetchContent で自動取得(ネットワーク必須) | | devkit | Xbox 開発機(実機検証用) | @@ -83,25 +83,63 @@ C++ 実行ファイルをビルドします。Electron や WebView は使用し ## V8 の用意 -V8 はソースビルドが非常に重いため prebuilt monolith を使います。自前ビルド例: +**通常は何も必要ありません。** builder が Next2D の GitHub Releases から +prebuilt V8 monolith を自動ダウンロードし、`%LOCALAPPDATA%\next2d\v8\` に +キャッシュします (マシンごとに初回のみ、以後は再利用)。 + +自動ダウンロードを使わない場合の優先順: + +1. `--v8-root ` 引数 +2. 環境変数 `V8_ROOT` +3. キャッシュ済み prebuilt +4. GitHub Releases から自動ダウンロード + +> prebuilt は builder リポジトリの `build-v8.yml` ワークフロー (windows-latest) で +> ビルドして Releases に発行しています。バージョンは builder の `XBOX_V8_VERSION` に固定。 + +### 自前ビルドする場合 (任意) + +コンソール実機向け (GDK ツールチェーン) や V8 バージョンを変えたい場合のみ。 +**マシンごとに 1 回だけ**の作業で、以後は `--v8-root` で使い回せます。 + +事前準備 (V8 ビルド用): + +| 項目 | 内容 | +|------|------| +| ディスク | 約 40GB (ソース + ビルド生成物) | +| 時間 | 初回 fetch 30〜60 分 + ビルド 1〜3 時間 | +| Git | インストール済みであること | +| depot_tools | [取得手順](https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up)に従い展開し、**PATH の先頭**に追加 | +| 環境変数 | `DEPOT_TOOLS_WIN_TOOLCHAIN=0` (Google 社内ツールチェーンを使わない指定。未設定だと fetch が失敗する) | +| Windows SDK | Visual Studio Installer で「Windows 11 SDK」と「Windows 用デバッグツール」を含めること (GN が要求する) | + +ビルド手順: ```bat -:: depot_tools 導入後 +set DEPOT_TOOLS_WIN_TOOLCHAIN=0 fetch v8 cd v8 -gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=true" +:: CI のコンパイル検証と同じバージョンに固定 (xbox-host-ci.yml の V8_TAG) +git checkout 13.6.233.17 +gclient sync +gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false use_custom_libcxx=false icu_use_data_file=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=true" ninja -C out\x64.release v8_monolith ``` 生成物を次の構成で配置し、builder の `--v8-root` 引数 (または環境変数 `V8_ROOT`) で指すこと: ``` -/include/v8.h ... -/lib/v8_monolith.lib +/include/v8.h ... (v8/include を丸ごとコピー) +/lib/v8_monolith.lib (v8/out/x64.release/obj/v8_monolith.lib) ``` -> V8 のビルドフラグ(pointer compression / sandbox)は `CMakeLists.txt` の -> `V8_COMPRESS_POINTERS` / `V8_ENABLE_SANDBOX` と一致させてください。不一致は ABI 崩れの原因になります。 +> - `use_custom_libcxx=false` は必須。V8 は clang でビルドされるため、これを外すと +> V8 同梱の libc++ が使われ、MSVC (MS STL) でビルドする本ホストとリンクできません。 +> - `icu_use_data_file=false` を推奨。外すと実行時に `icudtl.dat` の同梱が必要になります。 +> - pointer compression / sandbox は `CMakeLists.txt` の `V8_COMPRESS_POINTERS` / +> `V8_ENABLE_SANDBOX` と一致させてください。不一致は ABI 崩れの原因になります。 +> - 上記は PC (`Gaming.Desktop.x64`) 用。コンソール実機 (`Gaming.Xbox.*`) 向けは +> GDK ツールチェーンでの再ビルドが必要です (devkit 入手後の作業)。 --- @@ -110,7 +148,13 @@ ninja -C out\x64.release v8_monolith builder 経由(推奨): ```bat -:: プロジェクトルートで。V8 は --v8-root で指定する (環境変数 V8_ROOT でも可) +:: プロジェクトルートで。V8 は初回に自動ダウンロードされる (指定不要) +npx @next2d/builder --platform xbox --env prd +``` + +自前の V8 を使う場合のみ `--v8-root` を指定: + +```bat npx @next2d/builder --platform xbox --env prd --v8-root C:\path\to\v8 ``` From a6087d5894d25108705677c69635d385bb3418bb Mon Sep 17 00:00:00 2001 From: ienaga Date: Thu, 2 Jul 2026 18:32:29 +0900 Subject: [PATCH 2/6] =?UTF-8?q?wip:=20v8=E3=83=93=E3=83=AB=E3=83=89?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=20v2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-v8.yml | 9 ++++++--- .github/workflows/xbox-host-ci.yml | 2 +- templates/xbox/CMakeLists.txt | 7 +++++-- templates/xbox/README.md | 9 ++++++--- templates/xbox/cmake/FindV8.cmake | 4 +++- templates/xbox/tests/check_local.sh | 2 +- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-v8.yml b/.github/workflows/build-v8.yml index 8779852..a0837e2 100644 --- a/.github/workflows/build-v8.yml +++ b/.github/workflows/build-v8.yml @@ -57,10 +57,12 @@ jobs: run: | rem フラグはホスト側 (templates/xbox/CMakeLists.txt) の defines と一致させること: rem v8_enable_pointer_compression <-> V8_COMPRESS_POINTERS - rem v8_enable_sandbox <-> V8_ENABLE_SANDBOX rem use_custom_libcxx=false : MSVC (MS STL) とのリンクに必須 + rem v8_enable_sandbox=false : sandbox は libc++ ハードニング必須のため + rem use_custom_libcxx=false と両立しない (BUILD.gn の assert)。 + rem ホストは自明に信頼済みのゲームJSのみ実行するため無効で問題ない。 rem icu_use_data_file=false : icudtl.dat の同梱を不要にする - call gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false use_custom_libcxx=false icu_use_data_file=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=true" + call gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false use_custom_libcxx=false icu_use_data_file=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=false" if errorlevel 1 exit /b 1 call ninja -C out\x64.release v8_monolith if errorlevel 1 exit /b 1 @@ -90,7 +92,8 @@ jobs: - V8 ``${{ inputs.v8_version }}`` / VS2022 (windows-latest runner) - gn args: monolithic, no external startup data, use_custom_libcxx=false, - icu_use_data_file=false, pointer compression + sandbox enabled + icu_use_data_file=false, pointer compression enabled, sandbox disabled + (sandbox requires the bundled hardened libc++, which conflicts with MSVC linking) - Layout: ``include/`` + ``lib/v8_monolith.lib`` (pass the extracted dir to ``--v8-root``) ``npx @next2d/builder --platform xbox`` downloads this automatically when diff --git a/.github/workflows/xbox-host-ci.yml b/.github/workflows/xbox-host-ci.yml index 049bb3b..844257f 100644 --- a/.github/workflows/xbox-host-ci.yml +++ b/.github/workflows/xbox-host-ci.yml @@ -119,7 +119,7 @@ jobs: # CMakeLists.txt と同じ定義でコンパイルのみ実行 (/c)。 cl /c /nologo /std:c++20 /Zc:__cplusplus /EHsc /W3 ` /DNOMINMAX /DWIN32_LEAN_AND_MEAN /DUNICODE /D_UNICODE ` - /DV8_COMPRESS_POINTERS /DV8_ENABLE_SANDBOX ` + /DV8_COMPRESS_POINTERS ` /Isrc /I"$v8inc" ` @files if ($LASTEXITCODE -ne 0) { exit 1 } diff --git a/templates/xbox/CMakeLists.txt b/templates/xbox/CMakeLists.txt index 7dfb170..1785db2 100644 --- a/templates/xbox/CMakeLists.txt +++ b/templates/xbox/CMakeLists.txt @@ -92,10 +92,13 @@ else() target_compile_definitions(Next2DXboxHost PRIVATE NEXT2D_XBOX_CONSOLE=0) endif() -# V8 のプラットフォーム要件 +# V8 のプラットフォーム要件。 +# prebuilt V8 (build-v8.yml) のビルドフラグと一致させること: +# V8_COMPRESS_POINTERS <-> v8_enable_pointer_compression=true +# sandbox は無効 (libc++ ハードニング必須のため use_custom_libcxx=false と両立しない) +# → V8_ENABLE_SANDBOX は定義しない target_compile_definitions(Next2DXboxHost PRIVATE V8_COMPRESS_POINTERS - V8_ENABLE_SANDBOX NOMINMAX WIN32_LEAN_AND_MEAN UNICODE diff --git a/templates/xbox/README.md b/templates/xbox/README.md index 0745910..9ff196a 100644 --- a/templates/xbox/README.md +++ b/templates/xbox/README.md @@ -122,7 +122,7 @@ cd v8 :: CI のコンパイル検証と同じバージョンに固定 (xbox-host-ci.yml の V8_TAG) git checkout 13.6.233.17 gclient sync -gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false use_custom_libcxx=false icu_use_data_file=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=true" +gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false use_custom_libcxx=false icu_use_data_file=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=false" ninja -C out\x64.release v8_monolith ``` @@ -135,9 +135,12 @@ ninja -C out\x64.release v8_monolith > - `use_custom_libcxx=false` は必須。V8 は clang でビルドされるため、これを外すと > V8 同梱の libc++ が使われ、MSVC (MS STL) でビルドする本ホストとリンクできません。 +> - `v8_enable_sandbox=false` は必須。sandbox は libc++ ハードニング(=V8 同梱 libc++)を +> 要求するため `use_custom_libcxx=false` と両立しません (BUILD.gn の assert で停止)。 +> 本ホストは自明に信頼済みのゲーム JS のみ実行するため無効で問題ありません。 > - `icu_use_data_file=false` を推奨。外すと実行時に `icudtl.dat` の同梱が必要になります。 -> - pointer compression / sandbox は `CMakeLists.txt` の `V8_COMPRESS_POINTERS` / -> `V8_ENABLE_SANDBOX` と一致させてください。不一致は ABI 崩れの原因になります。 +> - pointer compression は `CMakeLists.txt` の `V8_COMPRESS_POINTERS` と一致させてください +> (sandbox 無効に合わせ `V8_ENABLE_SANDBOX` は定義しません)。不一致は ABI 崩れの原因になります。 > - 上記は PC (`Gaming.Desktop.x64`) 用。コンソール実機 (`Gaming.Xbox.*`) 向けは > GDK ツールチェーンでの再ビルドが必要です (devkit 入手後の作業)。 diff --git a/templates/xbox/cmake/FindV8.cmake b/templates/xbox/cmake/FindV8.cmake index d356144..6cfbd1e 100644 --- a/templates/xbox/cmake/FindV8.cmake +++ b/templates/xbox/cmake/FindV8.cmake @@ -10,10 +10,12 @@ # v8_monolithic=true # v8_use_external_startup_data=false # is_component_build=false +# use_custom_libcxx=false +# icu_use_data_file=false # target_cpu="x64" # is_debug=false # v8_enable_pointer_compression=true -# v8_enable_sandbox=true' +# v8_enable_sandbox=false' # ninja -C out/x64.release v8_monolith # # 2. 配布物 (v8_monolith.lib + include/) を取得 diff --git a/templates/xbox/tests/check_local.sh b/templates/xbox/tests/check_local.sh index 501aab5..86ddcb2 100755 --- a/templates/xbox/tests/check_local.sh +++ b/templates/xbox/tests/check_local.sh @@ -49,7 +49,7 @@ FILES=( ) for f in "${FILES[@]}"; do c++ -fsyntax-only -std=c++20 -Isrc -isystem "${V8INC}" \ - -DV8_COMPRESS_POINTERS -DV8_ENABLE_SANDBOX "$f" + -DV8_COMPRESS_POINTERS "$f" echo "OK $f" done From 9f10333c9ba411fb6a867e98084afc3b0768b675 Mon Sep 17 00:00:00 2001 From: ienaga Date: Thu, 2 Jul 2026 20:21:27 +0900 Subject: [PATCH 3/6] =?UTF-8?q?wip:=20v8=E3=83=93=E3=83=AB=E3=83=89?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=20v3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-v8.yml | 8 ++++++-- .github/workflows/xbox-host-ci.yml | 10 ++++++---- templates/xbox/README.md | 5 ++++- templates/xbox/cmake/FindV8.cmake | 1 + 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-v8.yml b/.github/workflows/build-v8.yml index a0837e2..518629b 100644 --- a/.github/workflows/build-v8.yml +++ b/.github/workflows/build-v8.yml @@ -24,7 +24,9 @@ permissions: jobs: build-v8-windows-x64: - runs-on: windows-latest + # windows-latest (VS2026/MSVC 14.5x) は STL が新しすぎて V8 の clang が + # -Werror で停止する。ホストの要件 (VS2022/v143, GDK) と同じ世代に固定する。 + runs-on: windows-2022 timeout-minutes: 360 steps: - name: Setup depot_tools @@ -62,7 +64,9 @@ jobs: rem use_custom_libcxx=false と両立しない (BUILD.gn の assert)。 rem ホストは自明に信頼済みのゲームJSのみ実行するため無効で問題ない。 rem icu_use_data_file=false : icudtl.dat の同梱を不要にする - call gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false use_custom_libcxx=false icu_use_data_file=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=false" + rem treat_warnings_as_errors=false : use_custom_libcxx=false では MSVC STL の + rem ヘッダ警告が -Werror で停止するため無効化 + call gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false use_custom_libcxx=false icu_use_data_file=false treat_warnings_as_errors=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=false" if errorlevel 1 exit /b 1 call ninja -C out\x64.release v8_monolith if errorlevel 1 exit /b 1 diff --git a/.github/workflows/xbox-host-ci.yml b/.github/workflows/xbox-host-ci.yml index 844257f..656629d 100644 --- a/.github/workflows/xbox-host-ci.yml +++ b/.github/workflows/xbox-host-ci.yml @@ -1,7 +1,7 @@ # Xbox ホスト (templates/xbox) の CI。 # -# ローカルに Windows PC / GDK が無くても、GitHub Actions の windows-latest 上で -# 以下を検証する: +# ローカルに Windows PC / GDK が無くても、GitHub Actions の Windows ランナー +# (windows-2022 = VS2022/v143, GDK ビルドと同じ toolset) 上で以下を検証する: # 1. raster-tests : Canvas2D ソフトラスタライザの単体テスト (Linux + Windows/MSVC) # 2. windows-platform : WIC / DirectWrite / Media Foundation / XAudio2 の # 実 API を Windows 上で実行する smoke テスト @@ -42,7 +42,8 @@ jobs: windows-tests: name: RasterCore + Windows platform tests (MSVC) - runs-on: windows-latest + # VS2022 (v143) 世代に固定 — GDK ビルドの実ターゲットと同じ toolset で検証する + runs-on: windows-2022 steps: - uses: actions/checkout@v4 - uses: ilammy/msvc-dev-cmd@v1 @@ -72,7 +73,8 @@ jobs: v8-syntax-check: name: V8-dependent sources compile check (MSVC) - runs-on: windows-latest + # VS2022 (v143) 世代に固定 — GDK ビルドの実ターゲットと同じ toolset で検証する + runs-on: windows-2022 steps: - uses: actions/checkout@v4 - uses: ilammy/msvc-dev-cmd@v1 diff --git a/templates/xbox/README.md b/templates/xbox/README.md index 9ff196a..1cccdfb 100644 --- a/templates/xbox/README.md +++ b/templates/xbox/README.md @@ -122,7 +122,7 @@ cd v8 :: CI のコンパイル検証と同じバージョンに固定 (xbox-host-ci.yml の V8_TAG) git checkout 13.6.233.17 gclient sync -gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false use_custom_libcxx=false icu_use_data_file=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=false" +gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false use_custom_libcxx=false icu_use_data_file=false treat_warnings_as_errors=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=false" ninja -C out\x64.release v8_monolith ``` @@ -139,6 +139,9 @@ ninja -C out\x64.release v8_monolith > 要求するため `use_custom_libcxx=false` と両立しません (BUILD.gn の assert で停止)。 > 本ホストは自明に信頼済みのゲーム JS のみ実行するため無効で問題ありません。 > - `icu_use_data_file=false` を推奨。外すと実行時に `icudtl.dat` の同梱が必要になります。 +> - `treat_warnings_as_errors=false` を推奨。`use_custom_libcxx=false` では MSVC STL の +> ヘッダ警告が -Werror で停止することがあります。**VS のバージョンは VS2022 (v143) を推奨** +> (新しすぎる STL は V8 の clang が警告/エラーを出しやすい)。 > - pointer compression は `CMakeLists.txt` の `V8_COMPRESS_POINTERS` と一致させてください > (sandbox 無効に合わせ `V8_ENABLE_SANDBOX` は定義しません)。不一致は ABI 崩れの原因になります。 > - 上記は PC (`Gaming.Desktop.x64`) 用。コンソール実機 (`Gaming.Xbox.*`) 向けは diff --git a/templates/xbox/cmake/FindV8.cmake b/templates/xbox/cmake/FindV8.cmake index 6cfbd1e..a5c6d63 100644 --- a/templates/xbox/cmake/FindV8.cmake +++ b/templates/xbox/cmake/FindV8.cmake @@ -12,6 +12,7 @@ # is_component_build=false # use_custom_libcxx=false # icu_use_data_file=false +# treat_warnings_as_errors=false # target_cpu="x64" # is_debug=false # v8_enable_pointer_compression=true From 42239e014670420b1dc26b1751c66d3b07b4ba5e Mon Sep 17 00:00:00 2001 From: ienaga Date: Thu, 2 Jul 2026 21:56:26 +0900 Subject: [PATCH 4/6] =?UTF-8?q?wip:=20v8=E3=83=93=E3=83=AB=E3=83=89?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=20v4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-v8.yml | 18 +++++++++++++++--- templates/xbox/README.md | 5 ++++- templates/xbox/cmake/FindV8.cmake | 3 +++ templates/xbox/src/v8/V8Runtime.cpp | 5 +++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-v8.yml b/.github/workflows/build-v8.yml index 518629b..2e36041 100644 --- a/.github/workflows/build-v8.yml +++ b/.github/workflows/build-v8.yml @@ -63,13 +63,23 @@ jobs: rem v8_enable_sandbox=false : sandbox は libc++ ハードニング必須のため rem use_custom_libcxx=false と両立しない (BUILD.gn の assert)。 rem ホストは自明に信頼済みのゲームJSのみ実行するため無効で問題ない。 + rem v8_jitless=true + turbofan/wasm 無効 : ホストは実行時 --jitless (Xbox は JIT 禁止)。 + rem BUILD.gn の assert により jitless では turbofan/sparkplug/maglev/wasm を + rem 無効にする必要がある (sparkplug/maglev は既定値が連動して自動で無効)。 + rem MSVC STL と相性の悪い wasm 系ソースもビルド対象から外れる。 rem icu_use_data_file=false : icudtl.dat の同梱を不要にする rem treat_warnings_as_errors=false : use_custom_libcxx=false では MSVC STL の rem ヘッダ警告が -Werror で停止するため無効化 - call gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false use_custom_libcxx=false icu_use_data_file=false treat_warnings_as_errors=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=false" + call gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false use_custom_libcxx=false icu_use_data_file=false treat_warnings_as_errors=false v8_jitless=true v8_enable_turbofan=false v8_enable_webassembly=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=false" if errorlevel 1 exit /b 1 call ninja -C out\x64.release v8_monolith - if errorlevel 1 exit /b 1 + if errorlevel 1 ( + echo. + echo ===== BUILD FAILED: retrying only the failed steps to surface the error ===== + echo ===== 下のログが実際のエラー内容 (失敗コマンドのみ再実行) ===== + call ninja -C out\x64.release v8_monolith + if errorlevel 1 exit /b 1 + ) - name: Package (include/ + lib/v8_monolith.lib) shell: pwsh @@ -97,7 +107,9 @@ jobs: - V8 ``${{ inputs.v8_version }}`` / VS2022 (windows-latest runner) - gn args: monolithic, no external startup data, use_custom_libcxx=false, icu_use_data_file=false, pointer compression enabled, sandbox disabled - (sandbox requires the bundled hardened libc++, which conflicts with MSVC linking) + (requires the bundled hardened libc++, conflicts with MSVC linking), + jitless (turbofan/sparkplug/maglev/wasm disabled — the host runs V8 with + --jitless because JIT is prohibited on Xbox) - Layout: ``include/`` + ``lib/v8_monolith.lib`` (pass the extracted dir to ``--v8-root``) ``npx @next2d/builder --platform xbox`` downloads this automatically when diff --git a/templates/xbox/README.md b/templates/xbox/README.md index 1cccdfb..aaf200d 100644 --- a/templates/xbox/README.md +++ b/templates/xbox/README.md @@ -122,7 +122,7 @@ cd v8 :: CI のコンパイル検証と同じバージョンに固定 (xbox-host-ci.yml の V8_TAG) git checkout 13.6.233.17 gclient sync -gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false use_custom_libcxx=false icu_use_data_file=false treat_warnings_as_errors=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=false" +gn gen out\x64.release --args="v8_monolithic=true v8_use_external_startup_data=false is_component_build=false use_custom_libcxx=false icu_use_data_file=false treat_warnings_as_errors=false v8_jitless=true v8_enable_turbofan=false v8_enable_webassembly=false target_cpu=\"x64\" is_debug=false v8_enable_pointer_compression=true v8_enable_sandbox=false" ninja -C out\x64.release v8_monolith ``` @@ -142,6 +142,9 @@ ninja -C out\x64.release v8_monolith > - `treat_warnings_as_errors=false` を推奨。`use_custom_libcxx=false` では MSVC STL の > ヘッダ警告が -Werror で停止することがあります。**VS のバージョンは VS2022 (v143) を推奨** > (新しすぎる STL は V8 の clang が警告/エラーを出しやすい)。 +> - `v8_jitless=true` + `v8_enable_turbofan=false` + `v8_enable_webassembly=false` を推奨。 +> ホストは実行時 `--jitless` で動かすため (Xbox は JIT 禁止)、JIT/wasm をビルドから +> 外すのが正しい構成です (BUILD.gn の assert もこの組み合わせを要求)。ビルドも大幅に速くなります。 > - pointer compression は `CMakeLists.txt` の `V8_COMPRESS_POINTERS` と一致させてください > (sandbox 無効に合わせ `V8_ENABLE_SANDBOX` は定義しません)。不一致は ABI 崩れの原因になります。 > - 上記は PC (`Gaming.Desktop.x64`) 用。コンソール実機 (`Gaming.Xbox.*`) 向けは diff --git a/templates/xbox/cmake/FindV8.cmake b/templates/xbox/cmake/FindV8.cmake index a5c6d63..bada275 100644 --- a/templates/xbox/cmake/FindV8.cmake +++ b/templates/xbox/cmake/FindV8.cmake @@ -13,6 +13,9 @@ # use_custom_libcxx=false # icu_use_data_file=false # treat_warnings_as_errors=false +# v8_jitless=true +# v8_enable_turbofan=false +# v8_enable_webassembly=false # target_cpu="x64" # is_debug=false # v8_enable_pointer_compression=true diff --git a/templates/xbox/src/v8/V8Runtime.cpp b/templates/xbox/src/v8/V8Runtime.cpp index 5965289..75bd998 100644 --- a/templates/xbox/src/v8/V8Runtime.cpp +++ b/templates/xbox/src/v8/V8Runtime.cpp @@ -44,8 +44,9 @@ void V8Runtime::InitializeProcess(const char* exec_path) { // Xbox(GDK) / Nintendo Switch のリテール環境は動的コード生成(JIT)を禁止する。 // V8 を jitless (Ignition インタプリタのみ・TurboFan/Sparkplug/RWXページ無し) で動かす。 - // WebAssembly も JIT を要するため無効化する。 - v8::V8::SetFlagsFromString("--jitless --no-expose-wasm --no-opt"); + // prebuilt V8 (build-v8.yml) は v8_jitless=true + turbofan/wasm 無効でビルドされる。 + // wasm/opt 系フラグはそのビルドに存在しないため渡さない (未知フラグ警告を避ける)。 + v8::V8::SetFlagsFromString("--jitless"); v8::V8::InitializeICUDefaultLocation(exec_path); v8::V8::InitializeExternalStartupData(exec_path); From 2f089c3ebc4ec8f4bb658194c7f011740e7715a1 Mon Sep 17 00:00:00 2001 From: ienaga Date: Thu, 2 Jul 2026 22:18:47 +0900 Subject: [PATCH 5/6] =?UTF-8?q?wip:=20v8=E3=83=93=E3=83=AB=E3=83=89?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=20v5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-v8.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-v8.yml b/.github/workflows/build-v8.yml index 2e36041..6987e4b 100644 --- a/.github/workflows/build-v8.yml +++ b/.github/workflows/build-v8.yml @@ -75,9 +75,9 @@ jobs: call ninja -C out\x64.release v8_monolith if errorlevel 1 ( echo. - echo ===== BUILD FAILED: retrying only the failed steps to surface the error ===== - echo ===== 下のログが実際のエラー内容 (失敗コマンドのみ再実行) ===== - call ninja -C out\x64.release v8_monolith + echo ===== BUILD FAILED: retrying serially to surface the exact error ===== + echo ===== -j 1 で再実行するため、このログの最後 = 失敗コマンドのエラー本体 ===== + call ninja -C out\x64.release -j 1 v8_monolith if errorlevel 1 exit /b 1 ) From c3ea8ef172e297d567b9516d152fbbaf03eeebf4 Mon Sep 17 00:00:00 2001 From: ienaga Date: Thu, 2 Jul 2026 22:40:50 +0900 Subject: [PATCH 6/6] =?UTF-8?q?wip:=20v8=E3=83=93=E3=83=AB=E3=83=89?= =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=20v6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-v8.yml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-v8.yml b/.github/workflows/build-v8.yml index 6987e4b..9dd093e 100644 --- a/.github/workflows/build-v8.yml +++ b/.github/workflows/build-v8.yml @@ -46,13 +46,30 @@ jobs: call fetch --no-history v8 if errorlevel 1 exit /b 1 cd v8 - git fetch --depth 1 origin refs/tags/%V8_VERSION% - if errorlevel 1 exit /b 1 - git checkout FETCH_HEAD - if errorlevel 1 exit /b 1 - call gclient sync -D + rem 重要: リビジョンは gclient に渡す。手動 git checkout だけだと + rem gclient sync が main へ戻してしまい、タグではなく main をビルドしてしまう。 + call gclient sync -D --revision refs/tags/%V8_VERSION% if errorlevel 1 exit /b 1 + - name: Verify checked-out V8 version (fail fast) + shell: pwsh + working-directory: ${{ runner.temp }}/v8 + run: | + # include/v8-version.h とタグの一致を検証する。 + # 不一致のまま 2 時間ビルドして main 由来のエラーに悩まされるのを防ぐ。 + $expected = "${{ inputs.v8_version }}" + $h = Get-Content include/v8-version.h -Raw + $maj = [regex]::Match($h, 'V8_MAJOR_VERSION (\d+)').Groups[1].Value + $min = [regex]::Match($h, 'V8_MINOR_VERSION (\d+)').Groups[1].Value + $bld = [regex]::Match($h, 'V8_BUILD_NUMBER (\d+)').Groups[1].Value + $pat = [regex]::Match($h, 'V8_PATCH_LEVEL (\d+)').Groups[1].Value + $actual = "$maj.$min.$bld.$pat" + if ($actual -ne $expected) { + Write-Error "V8 version mismatch: expected $expected but tree is $actual (gclient sync did not pin the tag)" + exit 1 + } + Write-Host "OK: building V8 $actual" + - name: Build v8_monolith shell: cmd working-directory: ${{ runner.temp }}/v8