@next2d/builder 0.1.5 → 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 +15 -0
- package/dist/index.js +315 -3
- package/package.json +10 -8
- package/templates/xbox/CMakeLists.txt +124 -0
- package/templates/xbox/MicrosoftGame.config +36 -0
- package/templates/xbox/README.md +372 -0
- package/templates/xbox/cmake/FetchDawn.cmake +42 -0
- package/templates/xbox/cmake/FindV8.cmake +68 -0
- package/templates/xbox/js/bootstrap.js +143 -0
- package/templates/xbox/js/selftest.js +515 -0
- package/templates/xbox/src/AssetLoader.cpp +106 -0
- package/templates/xbox/src/AssetLoader.h +35 -0
- package/templates/xbox/src/EventLoop.cpp +162 -0
- package/templates/xbox/src/EventLoop.h +73 -0
- package/templates/xbox/src/HostContext.h +58 -0
- package/templates/xbox/src/bindings/Audio.cpp +320 -0
- package/templates/xbox/src/bindings/Bindings.h +75 -0
- package/templates/xbox/src/bindings/Canvas.cpp +171 -0
- package/templates/xbox/src/bindings/Canvas2D.cpp +462 -0
- package/templates/xbox/src/bindings/Console.cpp +52 -0
- package/templates/xbox/src/bindings/DomShims.cpp +221 -0
- package/templates/xbox/src/bindings/EventTarget.cpp +127 -0
- package/templates/xbox/src/bindings/EventTarget.h +17 -0
- package/templates/xbox/src/bindings/Fetch.cpp +149 -0
- package/templates/xbox/src/bindings/Gamepad.cpp +79 -0
- package/templates/xbox/src/bindings/Image.cpp +160 -0
- package/templates/xbox/src/bindings/ImageSource.h +26 -0
- package/templates/xbox/src/bindings/Network.cpp +303 -0
- package/templates/xbox/src/bindings/RasterCore.h +265 -0
- package/templates/xbox/src/bindings/Timers.cpp +87 -0
- package/templates/xbox/src/bindings/Video.cpp +235 -0
- package/templates/xbox/src/bindings/webgpu/WebGPU.cpp +1318 -0
- package/templates/xbox/src/bindings/webgpu/WebGPUCommon.h +119 -0
- package/templates/xbox/src/bindings/webgpu/WebGPUEnums.h +245 -0
- package/templates/xbox/src/gpu/DawnContext.cpp +170 -0
- package/templates/xbox/src/gpu/DawnContext.h +64 -0
- package/templates/xbox/src/main.cpp +368 -0
- package/templates/xbox/src/platform/AudioEngine.cpp +184 -0
- package/templates/xbox/src/platform/AudioEngine.h +65 -0
- package/templates/xbox/src/platform/GamepadManager.cpp +83 -0
- package/templates/xbox/src/platform/GamepadManager.h +40 -0
- package/templates/xbox/src/platform/ImageTypes.h +17 -0
- package/templates/xbox/src/platform/TextRasterizer.cpp +183 -0
- package/templates/xbox/src/platform/TextRasterizer.h +35 -0
- package/templates/xbox/src/platform/WicDecoder.cpp +63 -0
- package/templates/xbox/src/platform/WicDecoder.h +16 -0
- package/templates/xbox/src/v8/V8Runtime.cpp +285 -0
- package/templates/xbox/src/v8/V8Runtime.h +68 -0
- package/templates/xbox/src/v8/V8Util.h +56 -0
- package/templates/xbox/src/worker/WorkerRuntime.cpp +453 -0
- package/templates/xbox/src/worker/WorkerRuntime.h +108 -0
- package/templates/xbox/tests/check_local.sh +56 -0
- package/templates/xbox/tests/raster_test.cpp +279 -0
- package/templates/xbox/tests/windows_platform_test.cpp +187 -0
package/README.md
CHANGED
|
@@ -39,6 +39,21 @@ With Next2D Framework, you can efficiently develop and deploy applications optim
|
|
|
39
39
|
| web | Export minfy'd JS files |
|
|
40
40
|
| iOS | open Xcode, and Export ipa |
|
|
41
41
|
| iOS | open Android Studio, and Export apk |
|
|
42
|
+
| Xbox | GDK native title (V8 + Dawn/WebGPU) |
|
|
43
|
+
|
|
44
|
+
Xbox exports a GDK native title that runs the Next2D JavaScript on the V8 engine and
|
|
45
|
+
renders with Dawn (WebGPU → D3D12), packaged as a C++ executable (no Electron/WebView).
|
|
46
|
+
Building the GDK package requires Windows + Visual Studio 2022 + Microsoft GDK + a devkit.
|
|
47
|
+
On other platforms the builder scaffolds the host project and stages assets only.
|
|
48
|
+
See the generated `xbox/README.md` for full build steps.
|
|
49
|
+
|
|
50
|
+
```bat
|
|
51
|
+
npx @next2d/builder --platform xbox --env prd
|
|
52
|
+
```
|
|
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`.
|
|
42
57
|
|
|
43
58
|
### Scheduled introduction
|
|
44
59
|
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
import pc from "picocolors";
|
|
4
4
|
import fs from "fs";
|
|
5
|
+
import os from "os";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
5
8
|
import cp from "child_process";
|
|
6
9
|
import { loadConfigFromFile } from "vite";
|
|
7
10
|
import { api } from "@electron-forge/core";
|
|
@@ -19,6 +22,7 @@ let hasHelp = false;
|
|
|
19
22
|
let preview = false;
|
|
20
23
|
let open = false;
|
|
21
24
|
let build = false;
|
|
25
|
+
let v8Root = "";
|
|
22
26
|
for (let idx = 0; idx < process.argv.length; ++idx) {
|
|
23
27
|
switch (process.argv[idx]) {
|
|
24
28
|
case "--preview":
|
|
@@ -40,6 +44,10 @@ for (let idx = 0; idx < process.argv.length; ++idx) {
|
|
|
40
44
|
case "--env":
|
|
41
45
|
environment = process.argv[++idx];
|
|
42
46
|
break;
|
|
47
|
+
case "--v8-root":
|
|
48
|
+
// Xbox ビルドで使う prebuilt V8 monolith のパス (環境変数 V8_ROOT より優先)
|
|
49
|
+
v8Root = process.argv[++idx] || "";
|
|
50
|
+
break;
|
|
43
51
|
default:
|
|
44
52
|
break;
|
|
45
53
|
}
|
|
@@ -60,7 +68,7 @@ if (!platform || !environment) {
|
|
|
60
68
|
*/
|
|
61
69
|
const echoHelp = () => {
|
|
62
70
|
console.log();
|
|
63
|
-
console.log(pc.green("`--platform` can be specified for macOS, Windows, iOS, Android, and Web"));
|
|
71
|
+
console.log(pc.green("`--platform` can be specified for macOS, Windows, iOS, Android, Xbox, and Web"));
|
|
64
72
|
console.log(pc.green("It is not case sensitive."));
|
|
65
73
|
console.log();
|
|
66
74
|
console.log("For build example:");
|
|
@@ -69,6 +77,10 @@ const echoHelp = () => {
|
|
|
69
77
|
console.log("For preview example:");
|
|
70
78
|
console.log("npx @next2d/builder --preview --platform web --env prd");
|
|
71
79
|
console.log();
|
|
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");
|
|
83
|
+
console.log();
|
|
72
84
|
process.exit(1);
|
|
73
85
|
};
|
|
74
86
|
if (hasHelp) {
|
|
@@ -86,6 +98,7 @@ switch (platform) {
|
|
|
86
98
|
case "steam:linux":
|
|
87
99
|
case "ios":
|
|
88
100
|
case "android":
|
|
101
|
+
case "xbox":
|
|
89
102
|
case "web":
|
|
90
103
|
break;
|
|
91
104
|
default:
|
|
@@ -434,6 +447,305 @@ const buildNative = async () => {
|
|
|
434
447
|
], { "stdio": "inherit" });
|
|
435
448
|
});
|
|
436
449
|
};
|
|
450
|
+
/**
|
|
451
|
+
* @type {string}
|
|
452
|
+
* @constant
|
|
453
|
+
*/
|
|
454
|
+
const XBOX_DIR_NAME = "xbox";
|
|
455
|
+
/**
|
|
456
|
+
* @description builder パッケージに同梱したテンプレートの絶対パスを取得
|
|
457
|
+
* Get the absolute path of a template shipped with the builder package
|
|
458
|
+
*
|
|
459
|
+
* @param {string} name
|
|
460
|
+
* @return {string}
|
|
461
|
+
* @method
|
|
462
|
+
* @public
|
|
463
|
+
*/
|
|
464
|
+
const getTemplateDir = (name) => {
|
|
465
|
+
// dist/index.js から見た templates/ (パッケージルート直下)
|
|
466
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
467
|
+
return path.resolve(currentDir, "..", "templates", name);
|
|
468
|
+
};
|
|
469
|
+
/**
|
|
470
|
+
* @type {string}
|
|
471
|
+
* @constant
|
|
472
|
+
*/
|
|
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";
|
|
485
|
+
/**
|
|
486
|
+
* @description ゲーム側の `xbox/` へスキャフォールドしないテンプレート内ファイル。
|
|
487
|
+
* - MicrosoftGame.config : ゲーム固有設定 (injectGameConfig が注入)
|
|
488
|
+
* - tests / .v8_headers : builder リポジトリ側の開発用テスト・キャッシュ
|
|
489
|
+
* - build 系 : テンプレート内でビルドした場合の生成物
|
|
490
|
+
* Template entries excluded from the per-game `xbox/` scaffold.
|
|
491
|
+
*
|
|
492
|
+
* @type {Set<string>}
|
|
493
|
+
* @constant
|
|
494
|
+
*/
|
|
495
|
+
const XBOX_SCAFFOLD_EXCLUDES = new Set([
|
|
496
|
+
XBOX_CONFIG_NAME,
|
|
497
|
+
"tests",
|
|
498
|
+
".v8_headers",
|
|
499
|
+
"build",
|
|
500
|
+
"out",
|
|
501
|
+
"_deps",
|
|
502
|
+
"CMakeCache.txt",
|
|
503
|
+
"CMakeFiles"
|
|
504
|
+
]);
|
|
505
|
+
/**
|
|
506
|
+
* @description XboxホストのC++/CMake一式をbuilder同梱テンプレートから毎回更新する。
|
|
507
|
+
* ホストは「エンジン相当」でユーザーは編集しない前提のため、常に最新へ上書きする。
|
|
508
|
+
* ただし各ゲーム固有の `MicrosoftGame.config` は対象外(injectGameConfigが扱う)。
|
|
509
|
+
* Refresh the Xbox host (C++/CMake) from the builder's bundled template on every build.
|
|
510
|
+
* The host is engine-like and not user-edited, so it is always overwritten,
|
|
511
|
+
* excluding the per-game `MicrosoftGame.config` (handled by injectGameConfig).
|
|
512
|
+
*
|
|
513
|
+
* @return {Promise}
|
|
514
|
+
* @method
|
|
515
|
+
* @public
|
|
516
|
+
*/
|
|
517
|
+
const refreshXboxHost = () => {
|
|
518
|
+
return new Promise((resolve, reject) => {
|
|
519
|
+
const projectDir = `${process.cwd()}/${XBOX_DIR_NAME}`;
|
|
520
|
+
const templateDir = getTemplateDir("xbox");
|
|
521
|
+
if (!fs.existsSync(templateDir)) {
|
|
522
|
+
return reject(`Xbox template not found: ${templateDir}`);
|
|
523
|
+
}
|
|
524
|
+
try {
|
|
525
|
+
fs.cpSync(templateDir, projectDir, {
|
|
526
|
+
"recursive": true,
|
|
527
|
+
// ゲーム固有設定と builder 側の開発用ファイルはスキャフォールドしない
|
|
528
|
+
"filter": (src) => !XBOX_SCAFFOLD_EXCLUDES.has(path.basename(src))
|
|
529
|
+
});
|
|
530
|
+
console.log(pc.green(`Successfully refreshed \`${XBOX_DIR_NAME}\` host.`));
|
|
531
|
+
resolve();
|
|
532
|
+
}
|
|
533
|
+
catch (error) {
|
|
534
|
+
reject(`Failed to refresh ${XBOX_DIR_NAME} host. ${error}`);
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
};
|
|
538
|
+
/**
|
|
539
|
+
* @description ゲームルートの `MicrosoftGame.config` をXboxホストへ注入する。
|
|
540
|
+
* capacitor.config.json と同様、各ゲーム固有の設定(TitleId/StoreId/名称/ロゴ)は
|
|
541
|
+
* プロジェクトルートで管理し、それをホストのビルド対象へ配置する。
|
|
542
|
+
* 未配置ならbuilder同梱の既定をフォールバックとして使い、作成を促す。
|
|
543
|
+
* Inject the game-root `MicrosoftGame.config` into the Xbox host.
|
|
544
|
+
*
|
|
545
|
+
* @return {Promise}
|
|
546
|
+
* @method
|
|
547
|
+
* @public
|
|
548
|
+
*/
|
|
549
|
+
const injectGameConfig = () => {
|
|
550
|
+
return new Promise((resolve, reject) => {
|
|
551
|
+
const rootConfig = `${process.cwd()}/${XBOX_CONFIG_NAME}`;
|
|
552
|
+
const hostConfig = `${process.cwd()}/${XBOX_DIR_NAME}/${XBOX_CONFIG_NAME}`;
|
|
553
|
+
try {
|
|
554
|
+
if (fs.existsSync(rootConfig)) {
|
|
555
|
+
fs.cpSync(rootConfig, hostConfig);
|
|
556
|
+
console.log(pc.green(`Applied project \`${XBOX_CONFIG_NAME}\`.`));
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
559
|
+
// フォールバック: builder同梱の既定を配置し、ルートへの作成を促す
|
|
560
|
+
fs.cpSync(`${getTemplateDir("xbox")}/${XBOX_CONFIG_NAME}`, hostConfig);
|
|
561
|
+
console.log(pc.yellow(`\`${XBOX_CONFIG_NAME}\` not found at project root. Using the default template.`));
|
|
562
|
+
console.log(pc.yellow(`Create \`${XBOX_CONFIG_NAME}\` at your project root (like capacitor.config.json) to set TitleId/StoreId/logos.`));
|
|
563
|
+
}
|
|
564
|
+
resolve();
|
|
565
|
+
}
|
|
566
|
+
catch (error) {
|
|
567
|
+
reject(`Failed to apply ${XBOX_CONFIG_NAME}. ${error}`);
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
};
|
|
571
|
+
/**
|
|
572
|
+
* @description ビルド済みWeb資材(JS/HTML/アセット)をXboxホストのassetsへ配置
|
|
573
|
+
* Deploy built web resources (JS/HTML/assets) into the Xbox host assets
|
|
574
|
+
*
|
|
575
|
+
* @return {Promise}
|
|
576
|
+
* @method
|
|
577
|
+
* @public
|
|
578
|
+
*/
|
|
579
|
+
const copyXboxResources = () => {
|
|
580
|
+
return new Promise((resolve, reject) => {
|
|
581
|
+
const assetsDir = `${process.cwd()}/${XBOX_DIR_NAME}/assets/app`;
|
|
582
|
+
try {
|
|
583
|
+
// reset
|
|
584
|
+
fs.rmSync(assetsDir, { "recursive": true, "force": true });
|
|
585
|
+
fs.mkdirSync(assetsDir, { "recursive": true });
|
|
586
|
+
// copy built web resources (JS/HTML/assets)
|
|
587
|
+
fs.cpSync(`${$buildDir}/`, assetsDir, { "recursive": true });
|
|
588
|
+
console.log(pc.green("Successfully copy built resources to Xbox host."));
|
|
589
|
+
resolve();
|
|
590
|
+
}
|
|
591
|
+
catch (error) {
|
|
592
|
+
reject(`Failed to copy built resources to Xbox host. ${error}`);
|
|
593
|
+
}
|
|
594
|
+
});
|
|
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
|
+
};
|
|
649
|
+
/**
|
|
650
|
+
* @description Xbox(GDKネイティブ)用アプリの書き出し関数。
|
|
651
|
+
* V8にNext2DのJSを載せ、Dawn(WebGPU/D3D12)で描画するC++ホストをビルドする。
|
|
652
|
+
* Export function for Xbox (GDK native) apps.
|
|
653
|
+
* Builds a C++ host that runs Next2D's JS on V8 and renders via Dawn (WebGPU/D3D12).
|
|
654
|
+
*
|
|
655
|
+
* @return {Promise}
|
|
656
|
+
* @method
|
|
657
|
+
* @public
|
|
658
|
+
*/
|
|
659
|
+
const buildXbox = async () => {
|
|
660
|
+
// C++/CMake ホストを最新へ更新 (ゲーム固有設定は除外)
|
|
661
|
+
await refreshXboxHost();
|
|
662
|
+
// ゲームルートの MicrosoftGame.config を注入
|
|
663
|
+
await injectGameConfig();
|
|
664
|
+
// ビルド済みWeb資材を配置
|
|
665
|
+
await copyXboxResources();
|
|
666
|
+
/**
|
|
667
|
+
* GDK ビルドは Windows + Visual Studio + Microsoft GDK が必須。
|
|
668
|
+
* それ以外の環境ではスキャフォールドと資材配置のみを行い、手順を案内する。
|
|
669
|
+
* The GDK build requires Windows + Visual Studio + Microsoft GDK.
|
|
670
|
+
* On other platforms we only scaffold and copy assets, then guide the next steps.
|
|
671
|
+
*/
|
|
672
|
+
if (process.platform !== "win32") {
|
|
673
|
+
console.log();
|
|
674
|
+
console.log(pc.yellow("Xbox host project has been generated and assets were copied."));
|
|
675
|
+
console.log(pc.yellow("The GDK build must run on Windows with Visual Studio and the Microsoft GDK installed."));
|
|
676
|
+
console.log(pc.yellow(`See ${XBOX_DIR_NAME}/README.md for the build steps.`));
|
|
677
|
+
console.log();
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* @type {string}
|
|
682
|
+
* GDK の対象コンソール世代。既定は Xbox Series X|S (Scarlett)。
|
|
683
|
+
* 必要に応じて `Gaming.Xbox.XboxOne.x64` / `Gaming.Desktop.x64` を選択。
|
|
684
|
+
*/
|
|
685
|
+
const gdkArch = process.env.NEXT2D_XBOX_ARCH || "Gaming.Xbox.Scarlett.x64";
|
|
686
|
+
const cmakeBuildDir = `${process.cwd()}/${$outDir}/${platformDir}/build`;
|
|
687
|
+
/**
|
|
688
|
+
* prebuilt V8 のパスを解決する (--v8-root > V8_ROOT > キャッシュ > 自動ダウンロード)。
|
|
689
|
+
* 通常は何も指定せずにビルドできる。
|
|
690
|
+
*/
|
|
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.`));
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
if (!fs.existsSync(`${resolvedV8Root}/include/v8.h`)) {
|
|
705
|
+
console.log(pc.red(`\`include/v8.h\` not found under: ${resolvedV8Root}`));
|
|
706
|
+
console.log(pc.red(`Check the \`--v8-root\` path. See ${XBOX_DIR_NAME}/README.md for how to prepare the prebuilt V8.`));
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
const configure = () => {
|
|
710
|
+
return new Promise((resolve, reject) => {
|
|
711
|
+
const stream = cp.spawn("cmake", [
|
|
712
|
+
"-S", `${process.cwd()}/${XBOX_DIR_NAME}`,
|
|
713
|
+
"-B", cmakeBuildDir,
|
|
714
|
+
"-G", "Visual Studio 17 2022",
|
|
715
|
+
"-A", gdkArch,
|
|
716
|
+
"-D", `V8_ROOT=${resolvedV8Root}`
|
|
717
|
+
], { "stdio": "inherit" });
|
|
718
|
+
stream.on("close", (code) => {
|
|
719
|
+
if (code !== 0) {
|
|
720
|
+
return reject("Failed to configure the Xbox (CMake/GDK) project.");
|
|
721
|
+
}
|
|
722
|
+
resolve();
|
|
723
|
+
});
|
|
724
|
+
});
|
|
725
|
+
};
|
|
726
|
+
await configure();
|
|
727
|
+
if (open || preview) {
|
|
728
|
+
// Visual Studio ソリューションを開く (実機/エミュレータでの実行はVS側で行う)
|
|
729
|
+
cp.spawn("cmake", [
|
|
730
|
+
"--open", cmakeBuildDir
|
|
731
|
+
], { "stdio": "inherit" });
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
// フルビルド (Release パッケージまで)
|
|
735
|
+
const stream = cp.spawn("cmake", [
|
|
736
|
+
"--build", cmakeBuildDir,
|
|
737
|
+
"--config", "Release"
|
|
738
|
+
], { "stdio": "inherit" });
|
|
739
|
+
stream.on("close", (code) => {
|
|
740
|
+
if (code !== 0) {
|
|
741
|
+
console.log(pc.red("Export of the Xbox (GDK) package failed."));
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
console.log();
|
|
745
|
+
console.log(pc.green(`Finished building the Xbox (GDK) package for ${gdkArch}.`));
|
|
746
|
+
console.log();
|
|
747
|
+
});
|
|
748
|
+
};
|
|
437
749
|
/**
|
|
438
750
|
* @description ビルドの実行関数
|
|
439
751
|
* Build Execution Functions
|
|
@@ -468,8 +780,8 @@ const multiBuild = async () => {
|
|
|
468
780
|
break;
|
|
469
781
|
}
|
|
470
782
|
break;
|
|
471
|
-
case "
|
|
472
|
-
await
|
|
783
|
+
case "xbox":
|
|
784
|
+
await buildXbox();
|
|
473
785
|
break;
|
|
474
786
|
case "web":
|
|
475
787
|
console.log();
|
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",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"JavaScript for iOS",
|
|
18
18
|
"JavaScript for Android",
|
|
19
19
|
"JavaScript for Steam",
|
|
20
|
+
"JavaScript for Xbox",
|
|
20
21
|
"Multi-platform builder"
|
|
21
22
|
],
|
|
22
23
|
"scripts": {
|
|
@@ -24,7 +25,8 @@
|
|
|
24
25
|
"release": "tsc"
|
|
25
26
|
},
|
|
26
27
|
"files": [
|
|
27
|
-
"dist"
|
|
28
|
+
"dist",
|
|
29
|
+
"templates"
|
|
28
30
|
],
|
|
29
31
|
"repository": {
|
|
30
32
|
"type": "git",
|
|
@@ -35,18 +37,18 @@
|
|
|
35
37
|
},
|
|
36
38
|
"dependencies": {
|
|
37
39
|
"@electron-forge/core": "^7.11.2",
|
|
38
|
-
"@types/node": "^
|
|
40
|
+
"@types/node": "^26.1.0",
|
|
39
41
|
"picocolors": "^1.1.1",
|
|
40
|
-
"vite": "^8.
|
|
42
|
+
"vite": "^8.1.2"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
45
|
"@eslint/eslintrc": "^3.3.5",
|
|
44
46
|
"@eslint/js": "^10.0.1",
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
46
|
-
"@typescript-eslint/parser": "^8.
|
|
47
|
-
"eslint": "^10.
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^8.62.1",
|
|
48
|
+
"@typescript-eslint/parser": "^8.62.1",
|
|
49
|
+
"eslint": "^10.6.0",
|
|
48
50
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
49
|
-
"globals": "^17.
|
|
51
|
+
"globals": "^17.7.0",
|
|
50
52
|
"typescript": "^6.0.3"
|
|
51
53
|
}
|
|
52
54
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# Next2D Xbox (GDK native) host
|
|
3
|
+
#
|
|
4
|
+
# V8 に Next2D の JavaScript を載せ、Dawn(WebGPU/D3D12) で描画する
|
|
5
|
+
# ネイティブタイトルをビルドする CMake プロジェクト。
|
|
6
|
+
#
|
|
7
|
+
# 対象トリプレット (builder が -A に渡す):
|
|
8
|
+
# - Gaming.Xbox.Scarlett.x64 : Xbox Series X|S
|
|
9
|
+
# - Gaming.Xbox.XboxOne.x64 : Xbox One
|
|
10
|
+
# - Gaming.Desktop.x64 : PC(GDK) / ローカル検証
|
|
11
|
+
#
|
|
12
|
+
# 必須:
|
|
13
|
+
# - Windows + Visual Studio 2022 (v143)
|
|
14
|
+
# - Microsoft GDK (June 2024 以降)
|
|
15
|
+
# - V8 の prebuilt ライブラリ (V8_ROOT で指定)
|
|
16
|
+
# - Dawn (FetchContent で取得・ビルド)
|
|
17
|
+
# =============================================================================
|
|
18
|
+
cmake_minimum_required(VERSION 3.26)
|
|
19
|
+
|
|
20
|
+
project(Next2DXboxHost LANGUAGES CXX)
|
|
21
|
+
|
|
22
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
23
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
24
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
25
|
+
|
|
26
|
+
# GDK target platform (Gaming.Xbox.* / Gaming.Desktop.*) の判定
|
|
27
|
+
if(NOT DEFINED CMAKE_GENERATOR_PLATFORM)
|
|
28
|
+
message(WARNING "CMAKE_GENERATOR_PLATFORM が未設定です。builder は -A Gaming.Xbox.Scarlett.x64 等を渡します。")
|
|
29
|
+
endif()
|
|
30
|
+
|
|
31
|
+
string(FIND "${CMAKE_GENERATOR_PLATFORM}" "Gaming.Xbox" _is_console)
|
|
32
|
+
if(_is_console GREATER_EQUAL 0)
|
|
33
|
+
set(NEXT2D_IS_CONSOLE ON)
|
|
34
|
+
else()
|
|
35
|
+
set(NEXT2D_IS_CONSOLE OFF)
|
|
36
|
+
endif()
|
|
37
|
+
|
|
38
|
+
# -----------------------------------------------------------------------------
|
|
39
|
+
# 依存: Dawn (WebGPU 実装 / D3D12 バックエンド)
|
|
40
|
+
# -----------------------------------------------------------------------------
|
|
41
|
+
include(cmake/FetchDawn.cmake)
|
|
42
|
+
|
|
43
|
+
# -----------------------------------------------------------------------------
|
|
44
|
+
# 依存: V8 (prebuilt)
|
|
45
|
+
# V8 はソースからのビルドが重いため prebuilt を前提とする。
|
|
46
|
+
# cmake -D V8_ROOT=<path> で monolith ビルド (v8_monolith.lib) を指す。
|
|
47
|
+
# -----------------------------------------------------------------------------
|
|
48
|
+
include(cmake/FindV8.cmake)
|
|
49
|
+
|
|
50
|
+
# -----------------------------------------------------------------------------
|
|
51
|
+
# ソース
|
|
52
|
+
# -----------------------------------------------------------------------------
|
|
53
|
+
file(GLOB_RECURSE NEXT2D_HOST_SOURCES
|
|
54
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp"
|
|
55
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.h"
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
add_executable(Next2DXboxHost WIN32 ${NEXT2D_HOST_SOURCES})
|
|
59
|
+
|
|
60
|
+
target_include_directories(Next2DXboxHost PRIVATE
|
|
61
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/src"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
target_link_libraries(Next2DXboxHost PRIVATE
|
|
65
|
+
v8::v8
|
|
66
|
+
dawn::webgpu_dawn
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
# WebGPU / D3D12 / GameInput / WIC / XAudio2 / GDK
|
|
70
|
+
target_link_libraries(Next2DXboxHost PRIVATE
|
|
71
|
+
d3d12
|
|
72
|
+
dxgi
|
|
73
|
+
dxguid
|
|
74
|
+
windowscodecs # WIC: 画像デコード
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
if(NEXT2D_IS_CONSOLE)
|
|
78
|
+
# コンソール用ライブラリ (GDK が提供)
|
|
79
|
+
target_link_libraries(Next2DXboxHost PRIVATE
|
|
80
|
+
xgameruntime
|
|
81
|
+
gameinput
|
|
82
|
+
xaudio2_9 # コンソールは XAudio2.9
|
|
83
|
+
)
|
|
84
|
+
target_compile_definitions(Next2DXboxHost PRIVATE NEXT2D_XBOX_CONSOLE=1)
|
|
85
|
+
else()
|
|
86
|
+
# PC(GDK) / ローカル検証
|
|
87
|
+
target_link_libraries(Next2DXboxHost PRIVATE
|
|
88
|
+
xgameruntime
|
|
89
|
+
gameinput
|
|
90
|
+
xaudio2
|
|
91
|
+
)
|
|
92
|
+
target_compile_definitions(Next2DXboxHost PRIVATE NEXT2D_XBOX_CONSOLE=0)
|
|
93
|
+
endif()
|
|
94
|
+
|
|
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 は定義しない
|
|
100
|
+
target_compile_definitions(Next2DXboxHost PRIVATE
|
|
101
|
+
V8_COMPRESS_POINTERS
|
|
102
|
+
NOMINMAX
|
|
103
|
+
WIN32_LEAN_AND_MEAN
|
|
104
|
+
UNICODE
|
|
105
|
+
_UNICODE
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# -----------------------------------------------------------------------------
|
|
109
|
+
# ランタイム資材のステージング
|
|
110
|
+
# builder が assets/app に JS/HTML/アセットを配置する。
|
|
111
|
+
# js/bootstrap.js はブラウザ相当グローバルを整える起動スクリプト。
|
|
112
|
+
# -----------------------------------------------------------------------------
|
|
113
|
+
add_custom_command(TARGET Next2DXboxHost POST_BUILD
|
|
114
|
+
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
115
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/assets"
|
|
116
|
+
"$<TARGET_FILE_DIR:Next2DXboxHost>/assets"
|
|
117
|
+
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
118
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/js"
|
|
119
|
+
"$<TARGET_FILE_DIR:Next2DXboxHost>/js"
|
|
120
|
+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
121
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/MicrosoftGame.config"
|
|
122
|
+
"$<TARGET_FILE_DIR:Next2DXboxHost>/MicrosoftGame.config"
|
|
123
|
+
COMMENT "Staging Next2D assets, bootstrap JS and MicrosoftGame.config"
|
|
124
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
Microsoft GDK ゲーム構成ファイル。
|
|
4
|
+
ID@Xbox で発行される TitleId / StoreId / MSAAppId 等を Partner Center の値に置き換えること。
|
|
5
|
+
詳細: https://learn.microsoft.com/gaming/gdk/_content/gc/system/overviews/microsoft-game-config
|
|
6
|
+
-->
|
|
7
|
+
<Game configVersion="1">
|
|
8
|
+
|
|
9
|
+
<Identity Name="Next2DGame"
|
|
10
|
+
Publisher="CN=Next2D"
|
|
11
|
+
Version="1.0.0.0" />
|
|
12
|
+
|
|
13
|
+
<ExecutableList>
|
|
14
|
+
<Executable Name="Next2DXboxHost.exe"
|
|
15
|
+
Id="Game"
|
|
16
|
+
TargetDeviceFamily="XboxOne;Scarlett" />
|
|
17
|
+
</ExecutableList>
|
|
18
|
+
|
|
19
|
+
<ShellVisuals DefaultDisplayName="Next2D Game"
|
|
20
|
+
PublisherDisplayName="Next2D"
|
|
21
|
+
StoreLogo="assets\StoreLogo.png"
|
|
22
|
+
Square150x150Logo="assets\Square150x150Logo.png"
|
|
23
|
+
Square44x44Logo="assets\Square44x44Logo.png"
|
|
24
|
+
SplashScreenImage="assets\SplashScreen.png"
|
|
25
|
+
Description="A game built with Next2D." />
|
|
26
|
+
|
|
27
|
+
<!-- ID@Xbox 発行値に置き換える -->
|
|
28
|
+
<MSAAppId>00000000000000000000000000000000</MSAAppId>
|
|
29
|
+
<TitleId>00000000</TitleId>
|
|
30
|
+
<StoreId>0000000000000000</StoreId>
|
|
31
|
+
|
|
32
|
+
<VirtualMachineList>
|
|
33
|
+
<VirtualMachine SandboxId="XDKS.1" TitleId="00000000" />
|
|
34
|
+
</VirtualMachineList>
|
|
35
|
+
|
|
36
|
+
</Game>
|