@next2d/builder 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/index.js +81 -13
- package/package.json +1 -1
- package/templates/xbox/CMakeLists.txt +5 -2
- package/templates/xbox/README.md +62 -9
- package/templates/xbox/cmake/FindV8.cmake +7 -1
- package/templates/xbox/src/v8/V8Runtime.cpp +3 -2
- package/templates/xbox/tests/check_local.sh +1 -1
- package/templates/xbox/tests/raster_test.bin +0 -0
package/README.md
CHANGED
|
@@ -48,9 +48,13 @@ On other platforms the builder scaffolds the host project and stages assets only
|
|
|
48
48
|
See the generated `xbox/README.md` for full build steps.
|
|
49
49
|
|
|
50
50
|
```bat
|
|
51
|
-
npx @next2d/builder --platform xbox --env prd
|
|
51
|
+
npx @next2d/builder --platform xbox --env prd
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
The prebuilt V8 engine is downloaded automatically on the first Xbox build
|
|
55
|
+
(published from the `build-v8` workflow). To use your own build, pass
|
|
56
|
+
`--v8-root C:\path\to\v8`.
|
|
57
|
+
|
|
54
58
|
### Scheduled introduction
|
|
55
59
|
|
|
56
60
|
| platform |
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
import pc from "picocolors";
|
|
4
4
|
import fs from "fs";
|
|
5
|
+
import os from "os";
|
|
5
6
|
import path from "path";
|
|
6
7
|
import { fileURLToPath } from "url";
|
|
7
8
|
import cp from "child_process";
|
|
@@ -76,8 +77,9 @@ const echoHelp = () => {
|
|
|
76
77
|
console.log("For preview example:");
|
|
77
78
|
console.log("npx @next2d/builder --preview --platform web --env prd");
|
|
78
79
|
console.log();
|
|
79
|
-
console.log("For Xbox build example (prebuilt V8
|
|
80
|
-
console.log("npx @next2d/builder --platform xbox --env prd
|
|
80
|
+
console.log("For Xbox build example (prebuilt V8 is downloaded automatically):");
|
|
81
|
+
console.log("npx @next2d/builder --platform xbox --env prd");
|
|
82
|
+
console.log("To use your own V8 build: --v8-root C:\\path\\to\\v8");
|
|
81
83
|
console.log();
|
|
82
84
|
process.exit(1);
|
|
83
85
|
};
|
|
@@ -469,6 +471,17 @@ const getTemplateDir = (name) => {
|
|
|
469
471
|
* @constant
|
|
470
472
|
*/
|
|
471
473
|
const XBOX_CONFIG_NAME = "MicrosoftGame.config";
|
|
474
|
+
/**
|
|
475
|
+
* @description 自動ダウンロードする prebuilt V8 のバージョン。
|
|
476
|
+
* `.github/workflows/build-v8.yml` で発行した Releases のタグと、
|
|
477
|
+
* `xbox-host-ci.yml` の V8_TAG に一致させること。
|
|
478
|
+
* The prebuilt V8 version to auto-download. Must match the release tag
|
|
479
|
+
* published by `build-v8.yml` and V8_TAG in `xbox-host-ci.yml`.
|
|
480
|
+
*
|
|
481
|
+
* @type {string}
|
|
482
|
+
* @constant
|
|
483
|
+
*/
|
|
484
|
+
const XBOX_V8_VERSION = "13.6.233.17";
|
|
472
485
|
/**
|
|
473
486
|
* @description ゲーム側の `xbox/` へスキャフォールドしないテンプレート内ファイル。
|
|
474
487
|
* - MicrosoftGame.config : ゲーム固有設定 (injectGameConfig が注入)
|
|
@@ -580,6 +593,59 @@ const copyXboxResources = () => {
|
|
|
580
593
|
}
|
|
581
594
|
});
|
|
582
595
|
};
|
|
596
|
+
/**
|
|
597
|
+
* @description Xbox ビルドに使う V8 のパスを解決する。優先順:
|
|
598
|
+
* 1. `--v8-root` 引数
|
|
599
|
+
* 2. 環境変数 `V8_ROOT`
|
|
600
|
+
* 3. キャッシュ済みの prebuilt (%LOCALAPPDATA%/next2d/v8/<version>)
|
|
601
|
+
* 4. GitHub Releases (build-v8.yml が発行) から自動ダウンロード
|
|
602
|
+
* 3・4 により、通常は何も指定せずに `--platform xbox` だけでビルドできる。
|
|
603
|
+
* Resolve the V8 path for the Xbox build. With the cached/auto-downloaded
|
|
604
|
+
* prebuilt, no flag or env var is required in the common case.
|
|
605
|
+
*
|
|
606
|
+
* @return {Promise<string>}
|
|
607
|
+
* @method
|
|
608
|
+
* @public
|
|
609
|
+
*/
|
|
610
|
+
const resolveXboxV8Root = async () => {
|
|
611
|
+
// 1. --v8-root 引数
|
|
612
|
+
if (v8Root) {
|
|
613
|
+
return path.resolve(process.cwd(), v8Root);
|
|
614
|
+
}
|
|
615
|
+
// 2. 環境変数 V8_ROOT
|
|
616
|
+
if (process.env.V8_ROOT) {
|
|
617
|
+
return process.env.V8_ROOT;
|
|
618
|
+
}
|
|
619
|
+
// 3. キャッシュ済み prebuilt
|
|
620
|
+
const cacheBase = process.env.LOCALAPPDATA
|
|
621
|
+
? `${process.env.LOCALAPPDATA}/next2d`
|
|
622
|
+
: `${os.homedir()}/.cache/next2d`;
|
|
623
|
+
const cacheDir = `${cacheBase}/v8/${XBOX_V8_VERSION}`;
|
|
624
|
+
if (fs.existsSync(`${cacheDir}/include/v8.h`)) {
|
|
625
|
+
return cacheDir;
|
|
626
|
+
}
|
|
627
|
+
// 4. GitHub Releases から自動ダウンロード (マシンごとに初回のみ)
|
|
628
|
+
const assetName = `v8-monolith-${XBOX_V8_VERSION}-windows-x64.zip`;
|
|
629
|
+
const url = `https://github.com/Next2D/builder/releases/download/v8-${XBOX_V8_VERSION}-windows-x64/${assetName}`;
|
|
630
|
+
console.log(pc.green(`Downloading prebuilt V8 ${XBOX_V8_VERSION} (first time only) ...`));
|
|
631
|
+
console.log(url);
|
|
632
|
+
const response = await fetch(url);
|
|
633
|
+
if (!response.ok) {
|
|
634
|
+
throw new Error(`download failed: HTTP ${response.status}`);
|
|
635
|
+
}
|
|
636
|
+
fs.mkdirSync(cacheDir, { "recursive": true });
|
|
637
|
+
const zipPath = `${cacheDir}/${assetName}.tmp`;
|
|
638
|
+
fs.writeFileSync(zipPath, Buffer.from(await response.arrayBuffer()));
|
|
639
|
+
// Windows 10+ 標準の tar (bsdtar) は zip も展開できる
|
|
640
|
+
const extract = cp.spawnSync("tar", ["-xf", zipPath, "-C", cacheDir], { "stdio": "inherit" });
|
|
641
|
+
fs.rmSync(zipPath, { "force": true });
|
|
642
|
+
if (extract.status !== 0 || !fs.existsSync(`${cacheDir}/include/v8.h`)) {
|
|
643
|
+
fs.rmSync(cacheDir, { "recursive": true, "force": true });
|
|
644
|
+
throw new Error("failed to extract the prebuilt V8 archive");
|
|
645
|
+
}
|
|
646
|
+
console.log(pc.green(`Prebuilt V8 cached at: ${cacheDir}`));
|
|
647
|
+
return cacheDir;
|
|
648
|
+
};
|
|
583
649
|
/**
|
|
584
650
|
* @description Xbox(GDKネイティブ)用アプリの書き出し関数。
|
|
585
651
|
* V8にNext2DのJSを載せ、Dawn(WebGPU/D3D12)で描画するC++ホストをビルドする。
|
|
@@ -619,18 +685,20 @@ const buildXbox = async () => {
|
|
|
619
685
|
const gdkArch = process.env.NEXT2D_XBOX_ARCH || "Gaming.Xbox.Scarlett.x64";
|
|
620
686
|
const cmakeBuildDir = `${process.cwd()}/${$outDir}/${platformDir}/build`;
|
|
621
687
|
/**
|
|
622
|
-
* prebuilt V8
|
|
623
|
-
*
|
|
624
|
-
* ここでは事前に分かりやすく案内だけする。
|
|
688
|
+
* prebuilt V8 のパスを解決する (--v8-root > V8_ROOT > キャッシュ > 自動ダウンロード)。
|
|
689
|
+
* 通常は何も指定せずにビルドできる。
|
|
625
690
|
*/
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
console.log(pc.red(
|
|
632
|
-
console.log(pc.red("
|
|
633
|
-
console.log(pc.red(
|
|
691
|
+
let resolvedV8Root = "";
|
|
692
|
+
try {
|
|
693
|
+
resolvedV8Root = await resolveXboxV8Root();
|
|
694
|
+
}
|
|
695
|
+
catch (error) {
|
|
696
|
+
console.log(pc.red(`Failed to prepare the prebuilt V8: ${error}`));
|
|
697
|
+
console.log(pc.red("Fallbacks:"));
|
|
698
|
+
console.log(pc.red(" 1) Retry later (the download may have failed temporarily)."));
|
|
699
|
+
console.log(pc.red(" 2) Build V8 yourself and pass `--v8-root <path>`:"));
|
|
700
|
+
console.log(pc.red(" npx @next2d/builder --platform xbox --env prd --v8-root C:\\path\\to\\v8"));
|
|
701
|
+
console.log(pc.red(` See ${XBOX_DIR_NAME}/README.md ("V8 の用意") for the build steps.`));
|
|
634
702
|
return;
|
|
635
703
|
}
|
|
636
704
|
if (!fs.existsSync(`${resolvedV8Root}/include/v8.h`)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/builder",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Multi-platform builder for Next2d Framework, supporting export to various platforms such as macOS, Windows, iOS, Android and Web(HTML)",
|
|
5
5
|
"author": "Toshiyuki Ienaga <ienaga@next2d.app>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -92,10 +92,13 @@ else()
|
|
|
92
92
|
target_compile_definitions(Next2DXboxHost PRIVATE NEXT2D_XBOX_CONSOLE=0)
|
|
93
93
|
endif()
|
|
94
94
|
|
|
95
|
-
# V8
|
|
95
|
+
# V8 のプラットフォーム要件。
|
|
96
|
+
# prebuilt V8 (build-v8.yml) のビルドフラグと一致させること:
|
|
97
|
+
# V8_COMPRESS_POINTERS <-> v8_enable_pointer_compression=true
|
|
98
|
+
# sandbox は無効 (libc++ ハードニング必須のため use_custom_libcxx=false と両立しない)
|
|
99
|
+
# → V8_ENABLE_SANDBOX は定義しない
|
|
96
100
|
target_compile_definitions(Next2DXboxHost PRIVATE
|
|
97
101
|
V8_COMPRESS_POINTERS
|
|
98
|
-
V8_ENABLE_SANDBOX
|
|
99
102
|
NOMINMAX
|
|
100
103
|
WIN32_LEAN_AND_MEAN
|
|
101
104
|
UNICODE
|
package/templates/xbox/README.md
CHANGED
|
@@ -75,7 +75,7 @@ C++ 実行ファイルをビルドします。Electron や WebView は使用し
|
|
|
75
75
|
| IDE | Visual Studio 2022 (v143, C++ Game development workload) |
|
|
76
76
|
| GDK | Microsoft GDK (June 2024 以降) — ID@Xbox 登録が必要 |
|
|
77
77
|
| CMake | 3.26 以降 |
|
|
78
|
-
| V8 | prebuilt
|
|
78
|
+
| V8 | 不要 (builder が prebuilt を自動ダウンロード)。自前ビルドは `--v8-root` で指定可 |
|
|
79
79
|
| Dawn | CMake の FetchContent で自動取得(ネットワーク必須) |
|
|
80
80
|
| devkit | Xbox 開発機(実機検証用) |
|
|
81
81
|
|
|
@@ -83,25 +83,72 @@ C++ 実行ファイルをビルドします。Electron や WebView は使用し
|
|
|
83
83
|
|
|
84
84
|
## V8 の用意
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
**通常は何も必要ありません。** builder が Next2D の GitHub Releases から
|
|
87
|
+
prebuilt V8 monolith を自動ダウンロードし、`%LOCALAPPDATA%\next2d\v8\<version>` に
|
|
88
|
+
キャッシュします (マシンごとに初回のみ、以後は再利用)。
|
|
89
|
+
|
|
90
|
+
自動ダウンロードを使わない場合の優先順:
|
|
91
|
+
|
|
92
|
+
1. `--v8-root <path>` 引数
|
|
93
|
+
2. 環境変数 `V8_ROOT`
|
|
94
|
+
3. キャッシュ済み prebuilt
|
|
95
|
+
4. GitHub Releases から自動ダウンロード
|
|
96
|
+
|
|
97
|
+
> prebuilt は builder リポジトリの `build-v8.yml` ワークフロー (windows-latest) で
|
|
98
|
+
> ビルドして Releases に発行しています。バージョンは builder の `XBOX_V8_VERSION` に固定。
|
|
99
|
+
|
|
100
|
+
### 自前ビルドする場合 (任意)
|
|
101
|
+
|
|
102
|
+
コンソール実機向け (GDK ツールチェーン) や V8 バージョンを変えたい場合のみ。
|
|
103
|
+
**マシンごとに 1 回だけ**の作業で、以後は `--v8-root` で使い回せます。
|
|
104
|
+
|
|
105
|
+
事前準備 (V8 ビルド用):
|
|
106
|
+
|
|
107
|
+
| 項目 | 内容 |
|
|
108
|
+
|------|------|
|
|
109
|
+
| ディスク | 約 40GB (ソース + ビルド生成物) |
|
|
110
|
+
| 時間 | 初回 fetch 30〜60 分 + ビルド 1〜3 時間 |
|
|
111
|
+
| Git | インストール済みであること |
|
|
112
|
+
| depot_tools | [取得手順](https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up)に従い展開し、**PATH の先頭**に追加 |
|
|
113
|
+
| 環境変数 | `DEPOT_TOOLS_WIN_TOOLCHAIN=0` (Google 社内ツールチェーンを使わない指定。未設定だと fetch が失敗する) |
|
|
114
|
+
| Windows SDK | Visual Studio Installer で「Windows 11 SDK」と「Windows 用デバッグツール」を含めること (GN が要求する) |
|
|
115
|
+
|
|
116
|
+
ビルド手順:
|
|
87
117
|
|
|
88
118
|
```bat
|
|
89
|
-
|
|
119
|
+
set DEPOT_TOOLS_WIN_TOOLCHAIN=0
|
|
90
120
|
fetch v8
|
|
91
121
|
cd v8
|
|
92
|
-
|
|
122
|
+
:: CI のコンパイル検証と同じバージョンに固定 (xbox-host-ci.yml の V8_TAG)
|
|
123
|
+
git checkout 13.6.233.17
|
|
124
|
+
gclient sync
|
|
125
|
+
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"
|
|
93
126
|
ninja -C out\x64.release v8_monolith
|
|
94
127
|
```
|
|
95
128
|
|
|
96
129
|
生成物を次の構成で配置し、builder の `--v8-root` 引数 (または環境変数 `V8_ROOT`) で指すこと:
|
|
97
130
|
|
|
98
131
|
```
|
|
99
|
-
<V8_ROOT>/include/v8.h ...
|
|
100
|
-
<V8_ROOT>/lib/v8_monolith.lib
|
|
132
|
+
<V8_ROOT>/include/v8.h ... (v8/include を丸ごとコピー)
|
|
133
|
+
<V8_ROOT>/lib/v8_monolith.lib (v8/out/x64.release/obj/v8_monolith.lib)
|
|
101
134
|
```
|
|
102
135
|
|
|
103
|
-
>
|
|
104
|
-
>
|
|
136
|
+
> - `use_custom_libcxx=false` は必須。V8 は clang でビルドされるため、これを外すと
|
|
137
|
+
> V8 同梱の libc++ が使われ、MSVC (MS STL) でビルドする本ホストとリンクできません。
|
|
138
|
+
> - `v8_enable_sandbox=false` は必須。sandbox は libc++ ハードニング(=V8 同梱 libc++)を
|
|
139
|
+
> 要求するため `use_custom_libcxx=false` と両立しません (BUILD.gn の assert で停止)。
|
|
140
|
+
> 本ホストは自明に信頼済みのゲーム JS のみ実行するため無効で問題ありません。
|
|
141
|
+
> - `icu_use_data_file=false` を推奨。外すと実行時に `icudtl.dat` の同梱が必要になります。
|
|
142
|
+
> - `treat_warnings_as_errors=false` を推奨。`use_custom_libcxx=false` では MSVC STL の
|
|
143
|
+
> ヘッダ警告が -Werror で停止することがあります。**VS のバージョンは VS2022 (v143) を推奨**
|
|
144
|
+
> (新しすぎる STL は V8 の clang が警告/エラーを出しやすい)。
|
|
145
|
+
> - `v8_jitless=true` + `v8_enable_turbofan=false` + `v8_enable_webassembly=false` を推奨。
|
|
146
|
+
> ホストは実行時 `--jitless` で動かすため (Xbox は JIT 禁止)、JIT/wasm をビルドから
|
|
147
|
+
> 外すのが正しい構成です (BUILD.gn の assert もこの組み合わせを要求)。ビルドも大幅に速くなります。
|
|
148
|
+
> - pointer compression は `CMakeLists.txt` の `V8_COMPRESS_POINTERS` と一致させてください
|
|
149
|
+
> (sandbox 無効に合わせ `V8_ENABLE_SANDBOX` は定義しません)。不一致は ABI 崩れの原因になります。
|
|
150
|
+
> - 上記は PC (`Gaming.Desktop.x64`) 用。コンソール実機 (`Gaming.Xbox.*`) 向けは
|
|
151
|
+
> GDK ツールチェーンでの再ビルドが必要です (devkit 入手後の作業)。
|
|
105
152
|
|
|
106
153
|
---
|
|
107
154
|
|
|
@@ -110,7 +157,13 @@ ninja -C out\x64.release v8_monolith
|
|
|
110
157
|
builder 経由(推奨):
|
|
111
158
|
|
|
112
159
|
```bat
|
|
113
|
-
:: プロジェクトルートで。V8
|
|
160
|
+
:: プロジェクトルートで。V8 は初回に自動ダウンロードされる (指定不要)
|
|
161
|
+
npx @next2d/builder --platform xbox --env prd
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
自前の V8 を使う場合のみ `--v8-root` を指定:
|
|
165
|
+
|
|
166
|
+
```bat
|
|
114
167
|
npx @next2d/builder --platform xbox --env prd --v8-root C:\path\to\v8
|
|
115
168
|
```
|
|
116
169
|
|
|
@@ -10,10 +10,16 @@
|
|
|
10
10
|
# v8_monolithic=true
|
|
11
11
|
# v8_use_external_startup_data=false
|
|
12
12
|
# is_component_build=false
|
|
13
|
+
# use_custom_libcxx=false
|
|
14
|
+
# icu_use_data_file=false
|
|
15
|
+
# treat_warnings_as_errors=false
|
|
16
|
+
# v8_jitless=true
|
|
17
|
+
# v8_enable_turbofan=false
|
|
18
|
+
# v8_enable_webassembly=false
|
|
13
19
|
# target_cpu="x64"
|
|
14
20
|
# is_debug=false
|
|
15
21
|
# v8_enable_pointer_compression=true
|
|
16
|
-
# v8_enable_sandbox=
|
|
22
|
+
# v8_enable_sandbox=false'
|
|
17
23
|
# ninja -C out/x64.release v8_monolith
|
|
18
24
|
#
|
|
19
25
|
# 2. 配布物 (v8_monolith.lib + include/) を取得
|
|
@@ -44,8 +44,9 @@ void V8Runtime::InitializeProcess(const char* exec_path)
|
|
|
44
44
|
{
|
|
45
45
|
// Xbox(GDK) / Nintendo Switch のリテール環境は動的コード生成(JIT)を禁止する。
|
|
46
46
|
// V8 を jitless (Ignition インタプリタのみ・TurboFan/Sparkplug/RWXページ無し) で動かす。
|
|
47
|
-
//
|
|
48
|
-
|
|
47
|
+
// prebuilt V8 (build-v8.yml) は v8_jitless=true + turbofan/wasm 無効でビルドされる。
|
|
48
|
+
// wasm/opt 系フラグはそのビルドに存在しないため渡さない (未知フラグ警告を避ける)。
|
|
49
|
+
v8::V8::SetFlagsFromString("--jitless");
|
|
49
50
|
|
|
50
51
|
v8::V8::InitializeICUDefaultLocation(exec_path);
|
|
51
52
|
v8::V8::InitializeExternalStartupData(exec_path);
|
|
Binary file
|