@next2d/builder 0.1.5 → 0.1.6
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 +11 -0
- package/dist/index.js +247 -3
- package/package.json +10 -8
- package/templates/xbox/CMakeLists.txt +121 -0
- package/templates/xbox/MicrosoftGame.config +36 -0
- package/templates/xbox/README.md +319 -0
- package/templates/xbox/cmake/FetchDawn.cmake +42 -0
- package/templates/xbox/cmake/FindV8.cmake +62 -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 +284 -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.bin +0 -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,17 @@ 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 --v8-root C:\path\to\v8
|
|
52
|
+
```
|
|
42
53
|
|
|
43
54
|
### Scheduled introduction
|
|
44
55
|
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
import pc from "picocolors";
|
|
4
4
|
import fs from "fs";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
5
7
|
import cp from "child_process";
|
|
6
8
|
import { loadConfigFromFile } from "vite";
|
|
7
9
|
import { api } from "@electron-forge/core";
|
|
@@ -19,6 +21,7 @@ let hasHelp = false;
|
|
|
19
21
|
let preview = false;
|
|
20
22
|
let open = false;
|
|
21
23
|
let build = false;
|
|
24
|
+
let v8Root = "";
|
|
22
25
|
for (let idx = 0; idx < process.argv.length; ++idx) {
|
|
23
26
|
switch (process.argv[idx]) {
|
|
24
27
|
case "--preview":
|
|
@@ -40,6 +43,10 @@ for (let idx = 0; idx < process.argv.length; ++idx) {
|
|
|
40
43
|
case "--env":
|
|
41
44
|
environment = process.argv[++idx];
|
|
42
45
|
break;
|
|
46
|
+
case "--v8-root":
|
|
47
|
+
// Xbox ビルドで使う prebuilt V8 monolith のパス (環境変数 V8_ROOT より優先)
|
|
48
|
+
v8Root = process.argv[++idx] || "";
|
|
49
|
+
break;
|
|
43
50
|
default:
|
|
44
51
|
break;
|
|
45
52
|
}
|
|
@@ -60,7 +67,7 @@ if (!platform || !environment) {
|
|
|
60
67
|
*/
|
|
61
68
|
const echoHelp = () => {
|
|
62
69
|
console.log();
|
|
63
|
-
console.log(pc.green("`--platform` can be specified for macOS, Windows, iOS, Android, and Web"));
|
|
70
|
+
console.log(pc.green("`--platform` can be specified for macOS, Windows, iOS, Android, Xbox, and Web"));
|
|
64
71
|
console.log(pc.green("It is not case sensitive."));
|
|
65
72
|
console.log();
|
|
66
73
|
console.log("For build example:");
|
|
@@ -69,6 +76,9 @@ const echoHelp = () => {
|
|
|
69
76
|
console.log("For preview example:");
|
|
70
77
|
console.log("npx @next2d/builder --preview --platform web --env prd");
|
|
71
78
|
console.log();
|
|
79
|
+
console.log("For Xbox build example (prebuilt V8 monolith path):");
|
|
80
|
+
console.log("npx @next2d/builder --platform xbox --env prd --v8-root C:\\path\\to\\v8");
|
|
81
|
+
console.log();
|
|
72
82
|
process.exit(1);
|
|
73
83
|
};
|
|
74
84
|
if (hasHelp) {
|
|
@@ -86,6 +96,7 @@ switch (platform) {
|
|
|
86
96
|
case "steam:linux":
|
|
87
97
|
case "ios":
|
|
88
98
|
case "android":
|
|
99
|
+
case "xbox":
|
|
89
100
|
case "web":
|
|
90
101
|
break;
|
|
91
102
|
default:
|
|
@@ -434,6 +445,239 @@ const buildNative = async () => {
|
|
|
434
445
|
], { "stdio": "inherit" });
|
|
435
446
|
});
|
|
436
447
|
};
|
|
448
|
+
/**
|
|
449
|
+
* @type {string}
|
|
450
|
+
* @constant
|
|
451
|
+
*/
|
|
452
|
+
const XBOX_DIR_NAME = "xbox";
|
|
453
|
+
/**
|
|
454
|
+
* @description builder パッケージに同梱したテンプレートの絶対パスを取得
|
|
455
|
+
* Get the absolute path of a template shipped with the builder package
|
|
456
|
+
*
|
|
457
|
+
* @param {string} name
|
|
458
|
+
* @return {string}
|
|
459
|
+
* @method
|
|
460
|
+
* @public
|
|
461
|
+
*/
|
|
462
|
+
const getTemplateDir = (name) => {
|
|
463
|
+
// dist/index.js から見た templates/ (パッケージルート直下)
|
|
464
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url));
|
|
465
|
+
return path.resolve(currentDir, "..", "templates", name);
|
|
466
|
+
};
|
|
467
|
+
/**
|
|
468
|
+
* @type {string}
|
|
469
|
+
* @constant
|
|
470
|
+
*/
|
|
471
|
+
const XBOX_CONFIG_NAME = "MicrosoftGame.config";
|
|
472
|
+
/**
|
|
473
|
+
* @description ゲーム側の `xbox/` へスキャフォールドしないテンプレート内ファイル。
|
|
474
|
+
* - MicrosoftGame.config : ゲーム固有設定 (injectGameConfig が注入)
|
|
475
|
+
* - tests / .v8_headers : builder リポジトリ側の開発用テスト・キャッシュ
|
|
476
|
+
* - build 系 : テンプレート内でビルドした場合の生成物
|
|
477
|
+
* Template entries excluded from the per-game `xbox/` scaffold.
|
|
478
|
+
*
|
|
479
|
+
* @type {Set<string>}
|
|
480
|
+
* @constant
|
|
481
|
+
*/
|
|
482
|
+
const XBOX_SCAFFOLD_EXCLUDES = new Set([
|
|
483
|
+
XBOX_CONFIG_NAME,
|
|
484
|
+
"tests",
|
|
485
|
+
".v8_headers",
|
|
486
|
+
"build",
|
|
487
|
+
"out",
|
|
488
|
+
"_deps",
|
|
489
|
+
"CMakeCache.txt",
|
|
490
|
+
"CMakeFiles"
|
|
491
|
+
]);
|
|
492
|
+
/**
|
|
493
|
+
* @description XboxホストのC++/CMake一式をbuilder同梱テンプレートから毎回更新する。
|
|
494
|
+
* ホストは「エンジン相当」でユーザーは編集しない前提のため、常に最新へ上書きする。
|
|
495
|
+
* ただし各ゲーム固有の `MicrosoftGame.config` は対象外(injectGameConfigが扱う)。
|
|
496
|
+
* Refresh the Xbox host (C++/CMake) from the builder's bundled template on every build.
|
|
497
|
+
* The host is engine-like and not user-edited, so it is always overwritten,
|
|
498
|
+
* excluding the per-game `MicrosoftGame.config` (handled by injectGameConfig).
|
|
499
|
+
*
|
|
500
|
+
* @return {Promise}
|
|
501
|
+
* @method
|
|
502
|
+
* @public
|
|
503
|
+
*/
|
|
504
|
+
const refreshXboxHost = () => {
|
|
505
|
+
return new Promise((resolve, reject) => {
|
|
506
|
+
const projectDir = `${process.cwd()}/${XBOX_DIR_NAME}`;
|
|
507
|
+
const templateDir = getTemplateDir("xbox");
|
|
508
|
+
if (!fs.existsSync(templateDir)) {
|
|
509
|
+
return reject(`Xbox template not found: ${templateDir}`);
|
|
510
|
+
}
|
|
511
|
+
try {
|
|
512
|
+
fs.cpSync(templateDir, projectDir, {
|
|
513
|
+
"recursive": true,
|
|
514
|
+
// ゲーム固有設定と builder 側の開発用ファイルはスキャフォールドしない
|
|
515
|
+
"filter": (src) => !XBOX_SCAFFOLD_EXCLUDES.has(path.basename(src))
|
|
516
|
+
});
|
|
517
|
+
console.log(pc.green(`Successfully refreshed \`${XBOX_DIR_NAME}\` host.`));
|
|
518
|
+
resolve();
|
|
519
|
+
}
|
|
520
|
+
catch (error) {
|
|
521
|
+
reject(`Failed to refresh ${XBOX_DIR_NAME} host. ${error}`);
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
};
|
|
525
|
+
/**
|
|
526
|
+
* @description ゲームルートの `MicrosoftGame.config` をXboxホストへ注入する。
|
|
527
|
+
* capacitor.config.json と同様、各ゲーム固有の設定(TitleId/StoreId/名称/ロゴ)は
|
|
528
|
+
* プロジェクトルートで管理し、それをホストのビルド対象へ配置する。
|
|
529
|
+
* 未配置ならbuilder同梱の既定をフォールバックとして使い、作成を促す。
|
|
530
|
+
* Inject the game-root `MicrosoftGame.config` into the Xbox host.
|
|
531
|
+
*
|
|
532
|
+
* @return {Promise}
|
|
533
|
+
* @method
|
|
534
|
+
* @public
|
|
535
|
+
*/
|
|
536
|
+
const injectGameConfig = () => {
|
|
537
|
+
return new Promise((resolve, reject) => {
|
|
538
|
+
const rootConfig = `${process.cwd()}/${XBOX_CONFIG_NAME}`;
|
|
539
|
+
const hostConfig = `${process.cwd()}/${XBOX_DIR_NAME}/${XBOX_CONFIG_NAME}`;
|
|
540
|
+
try {
|
|
541
|
+
if (fs.existsSync(rootConfig)) {
|
|
542
|
+
fs.cpSync(rootConfig, hostConfig);
|
|
543
|
+
console.log(pc.green(`Applied project \`${XBOX_CONFIG_NAME}\`.`));
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
// フォールバック: builder同梱の既定を配置し、ルートへの作成を促す
|
|
547
|
+
fs.cpSync(`${getTemplateDir("xbox")}/${XBOX_CONFIG_NAME}`, hostConfig);
|
|
548
|
+
console.log(pc.yellow(`\`${XBOX_CONFIG_NAME}\` not found at project root. Using the default template.`));
|
|
549
|
+
console.log(pc.yellow(`Create \`${XBOX_CONFIG_NAME}\` at your project root (like capacitor.config.json) to set TitleId/StoreId/logos.`));
|
|
550
|
+
}
|
|
551
|
+
resolve();
|
|
552
|
+
}
|
|
553
|
+
catch (error) {
|
|
554
|
+
reject(`Failed to apply ${XBOX_CONFIG_NAME}. ${error}`);
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
};
|
|
558
|
+
/**
|
|
559
|
+
* @description ビルド済みWeb資材(JS/HTML/アセット)をXboxホストのassetsへ配置
|
|
560
|
+
* Deploy built web resources (JS/HTML/assets) into the Xbox host assets
|
|
561
|
+
*
|
|
562
|
+
* @return {Promise}
|
|
563
|
+
* @method
|
|
564
|
+
* @public
|
|
565
|
+
*/
|
|
566
|
+
const copyXboxResources = () => {
|
|
567
|
+
return new Promise((resolve, reject) => {
|
|
568
|
+
const assetsDir = `${process.cwd()}/${XBOX_DIR_NAME}/assets/app`;
|
|
569
|
+
try {
|
|
570
|
+
// reset
|
|
571
|
+
fs.rmSync(assetsDir, { "recursive": true, "force": true });
|
|
572
|
+
fs.mkdirSync(assetsDir, { "recursive": true });
|
|
573
|
+
// copy built web resources (JS/HTML/assets)
|
|
574
|
+
fs.cpSync(`${$buildDir}/`, assetsDir, { "recursive": true });
|
|
575
|
+
console.log(pc.green("Successfully copy built resources to Xbox host."));
|
|
576
|
+
resolve();
|
|
577
|
+
}
|
|
578
|
+
catch (error) {
|
|
579
|
+
reject(`Failed to copy built resources to Xbox host. ${error}`);
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
};
|
|
583
|
+
/**
|
|
584
|
+
* @description Xbox(GDKネイティブ)用アプリの書き出し関数。
|
|
585
|
+
* V8にNext2DのJSを載せ、Dawn(WebGPU/D3D12)で描画するC++ホストをビルドする。
|
|
586
|
+
* Export function for Xbox (GDK native) apps.
|
|
587
|
+
* Builds a C++ host that runs Next2D's JS on V8 and renders via Dawn (WebGPU/D3D12).
|
|
588
|
+
*
|
|
589
|
+
* @return {Promise}
|
|
590
|
+
* @method
|
|
591
|
+
* @public
|
|
592
|
+
*/
|
|
593
|
+
const buildXbox = async () => {
|
|
594
|
+
// C++/CMake ホストを最新へ更新 (ゲーム固有設定は除外)
|
|
595
|
+
await refreshXboxHost();
|
|
596
|
+
// ゲームルートの MicrosoftGame.config を注入
|
|
597
|
+
await injectGameConfig();
|
|
598
|
+
// ビルド済みWeb資材を配置
|
|
599
|
+
await copyXboxResources();
|
|
600
|
+
/**
|
|
601
|
+
* GDK ビルドは Windows + Visual Studio + Microsoft GDK が必須。
|
|
602
|
+
* それ以外の環境ではスキャフォールドと資材配置のみを行い、手順を案内する。
|
|
603
|
+
* The GDK build requires Windows + Visual Studio + Microsoft GDK.
|
|
604
|
+
* On other platforms we only scaffold and copy assets, then guide the next steps.
|
|
605
|
+
*/
|
|
606
|
+
if (process.platform !== "win32") {
|
|
607
|
+
console.log();
|
|
608
|
+
console.log(pc.yellow("Xbox host project has been generated and assets were copied."));
|
|
609
|
+
console.log(pc.yellow("The GDK build must run on Windows with Visual Studio and the Microsoft GDK installed."));
|
|
610
|
+
console.log(pc.yellow(`See ${XBOX_DIR_NAME}/README.md for the build steps.`));
|
|
611
|
+
console.log();
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* @type {string}
|
|
616
|
+
* GDK の対象コンソール世代。既定は Xbox Series X|S (Scarlett)。
|
|
617
|
+
* 必要に応じて `Gaming.Xbox.XboxOne.x64` / `Gaming.Desktop.x64` を選択。
|
|
618
|
+
*/
|
|
619
|
+
const gdkArch = process.env.NEXT2D_XBOX_ARCH || "Gaming.Xbox.Scarlett.x64";
|
|
620
|
+
const cmakeBuildDir = `${process.cwd()}/${$outDir}/${platformDir}/build`;
|
|
621
|
+
/**
|
|
622
|
+
* prebuilt V8 monolith のパス。優先順: `--v8-root` 引数 > 環境変数 V8_ROOT。
|
|
623
|
+
* どちらも無い場合は CMake (FindV8.cmake) が明確なエラーで停止するため、
|
|
624
|
+
* ここでは事前に分かりやすく案内だけする。
|
|
625
|
+
*/
|
|
626
|
+
const resolvedV8Root = v8Root
|
|
627
|
+
? path.resolve(process.cwd(), v8Root)
|
|
628
|
+
: process.env.V8_ROOT || "";
|
|
629
|
+
if (!resolvedV8Root) {
|
|
630
|
+
console.log(pc.red("V8 path is not specified."));
|
|
631
|
+
console.log(pc.red("Pass `--v8-root <path>` (or set the V8_ROOT environment variable):"));
|
|
632
|
+
console.log(pc.red(" npx @next2d/builder --platform xbox --env prd --v8-root C:\\path\\to\\v8"));
|
|
633
|
+
console.log(pc.red(`The path must contain \`include/v8.h\` and \`lib/v8_monolith.lib\`. See ${XBOX_DIR_NAME}/README.md.`));
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
if (!fs.existsSync(`${resolvedV8Root}/include/v8.h`)) {
|
|
637
|
+
console.log(pc.red(`\`include/v8.h\` not found under: ${resolvedV8Root}`));
|
|
638
|
+
console.log(pc.red(`Check the \`--v8-root\` path. See ${XBOX_DIR_NAME}/README.md for how to prepare the prebuilt V8.`));
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
const configure = () => {
|
|
642
|
+
return new Promise((resolve, reject) => {
|
|
643
|
+
const stream = cp.spawn("cmake", [
|
|
644
|
+
"-S", `${process.cwd()}/${XBOX_DIR_NAME}`,
|
|
645
|
+
"-B", cmakeBuildDir,
|
|
646
|
+
"-G", "Visual Studio 17 2022",
|
|
647
|
+
"-A", gdkArch,
|
|
648
|
+
"-D", `V8_ROOT=${resolvedV8Root}`
|
|
649
|
+
], { "stdio": "inherit" });
|
|
650
|
+
stream.on("close", (code) => {
|
|
651
|
+
if (code !== 0) {
|
|
652
|
+
return reject("Failed to configure the Xbox (CMake/GDK) project.");
|
|
653
|
+
}
|
|
654
|
+
resolve();
|
|
655
|
+
});
|
|
656
|
+
});
|
|
657
|
+
};
|
|
658
|
+
await configure();
|
|
659
|
+
if (open || preview) {
|
|
660
|
+
// Visual Studio ソリューションを開く (実機/エミュレータでの実行はVS側で行う)
|
|
661
|
+
cp.spawn("cmake", [
|
|
662
|
+
"--open", cmakeBuildDir
|
|
663
|
+
], { "stdio": "inherit" });
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
// フルビルド (Release パッケージまで)
|
|
667
|
+
const stream = cp.spawn("cmake", [
|
|
668
|
+
"--build", cmakeBuildDir,
|
|
669
|
+
"--config", "Release"
|
|
670
|
+
], { "stdio": "inherit" });
|
|
671
|
+
stream.on("close", (code) => {
|
|
672
|
+
if (code !== 0) {
|
|
673
|
+
console.log(pc.red("Export of the Xbox (GDK) package failed."));
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
console.log();
|
|
677
|
+
console.log(pc.green(`Finished building the Xbox (GDK) package for ${gdkArch}.`));
|
|
678
|
+
console.log();
|
|
679
|
+
});
|
|
680
|
+
};
|
|
437
681
|
/**
|
|
438
682
|
* @description ビルドの実行関数
|
|
439
683
|
* Build Execution Functions
|
|
@@ -468,8 +712,8 @@ const multiBuild = async () => {
|
|
|
468
712
|
break;
|
|
469
713
|
}
|
|
470
714
|
break;
|
|
471
|
-
case "
|
|
472
|
-
await
|
|
715
|
+
case "xbox":
|
|
716
|
+
await buildXbox();
|
|
473
717
|
break;
|
|
474
718
|
case "web":
|
|
475
719
|
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.6",
|
|
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,121 @@
|
|
|
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
|
+
target_compile_definitions(Next2DXboxHost PRIVATE
|
|
97
|
+
V8_COMPRESS_POINTERS
|
|
98
|
+
V8_ENABLE_SANDBOX
|
|
99
|
+
NOMINMAX
|
|
100
|
+
WIN32_LEAN_AND_MEAN
|
|
101
|
+
UNICODE
|
|
102
|
+
_UNICODE
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# -----------------------------------------------------------------------------
|
|
106
|
+
# ランタイム資材のステージング
|
|
107
|
+
# builder が assets/app に JS/HTML/アセットを配置する。
|
|
108
|
+
# js/bootstrap.js はブラウザ相当グローバルを整える起動スクリプト。
|
|
109
|
+
# -----------------------------------------------------------------------------
|
|
110
|
+
add_custom_command(TARGET Next2DXboxHost POST_BUILD
|
|
111
|
+
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
112
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/assets"
|
|
113
|
+
"$<TARGET_FILE_DIR:Next2DXboxHost>/assets"
|
|
114
|
+
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
|
115
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/js"
|
|
116
|
+
"$<TARGET_FILE_DIR:Next2DXboxHost>/js"
|
|
117
|
+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
118
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/MicrosoftGame.config"
|
|
119
|
+
"$<TARGET_FILE_DIR:Next2DXboxHost>/MicrosoftGame.config"
|
|
120
|
+
COMMENT "Staging Next2D assets, bootstrap JS and MicrosoftGame.config"
|
|
121
|
+
)
|
|
@@ -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>
|