@skathi-native/cli 0.1.0-beta.2 → 0.1.0-beta.4
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/aot/host-globals.json +105 -0
- package/aot/native.ts +142 -0
- package/aot/pin.ts +67 -0
- package/aot/toolchain.lock.json +17 -0
- package/aot/transform.ts +69 -0
- package/check/codes.ts +19 -0
- package/check/command.ts +5 -3
- package/check/index.ts +44 -1
- package/cli/aot-build.ts +192 -0
- package/cli/build-app.ts +102 -31
- package/cli/config.ts +45 -102
- package/cli/create.ts +12 -54
- package/cli/dev.ts +109 -19
- package/cli/effects.ts +162 -0
- package/cli/elf.ts +3 -2
- package/cli/help.ts +56 -148
- package/cli/host-fetch.ts +116 -54
- package/cli/host.ts +59 -39
- package/cli/sk.ts +440 -246
- package/cli/skpk.ts +6 -0
- package/cli/stamp.ts +2 -2
- package/cli/term.ts +169 -38
- package/cli/workload-cache.ts +258 -0
- package/effects/compile.ts +952 -0
- package/effects/redslangc.json +23 -0
- package/effects/redslangc.ts +220 -0
- package/effects/sk.slang +558 -0
- package/package.json +6 -2
- package/templates/icon.png +0 -0
- package/templates/minimal/.vscode/settings.json +3 -0
- package/templates/minimal/src/App.vue +2 -2
- package/templates/showcase/.vscode/settings.json +3 -0
- package/templates/showcase/shaders/sheen.slang +23 -0
- package/templates/showcase/src/components/Titlebar.vue +7 -3
- package/templates/showcase/src/engine.ts +3 -26
- package/templates/showcase/src/pages/AudioPage.vue +6 -9
- package/templates/showcase/src/pages/FilesPage.vue +11 -15
- package/templates/showcase/src/pages/FormsPage.vue +2 -3
- package/templates/showcase/src/pages/GraphicsPage.vue +13 -15
- package/templates/showcase/src/pages/HomePage.vue +1 -2
- package/templates/showcase/src/pages/LocalePage.vue +2 -2
- package/templates/showcase/src/pages/MediaPage.vue +1 -1
- package/templates/showcase/src/pages/MotionPage.vue +1 -1
- package/templates/showcase/src/pages/NetworkPage.vue +6 -5
- package/templates/showcase/src/pages/PermissionsPage.vue +2 -2
- package/templates/showcase/src/pages/StoragePage.vue +23 -36
- package/templates/showcase/src/pages/StylesPage.vue +9 -1
- package/templates/showcase/src/pages/SystemPage.vue +3 -3
- package/templates/showcase/src/styles.css +2 -2
- package/templates/showcase/src/components/Missing.vue +0 -26
package/cli/aot-build.ts
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// `sk build --aot`: the app's production bundle compiled to a native image that travels in the
|
|
2
|
+
// payload beside app.prod.js (which stays: the host checks the image against it, and stacks name it).
|
|
3
|
+
//
|
|
4
|
+
// sk check (errors refuse the build) -> sk-aot matching the host (--aot-compiler, the checkout's
|
|
5
|
+
// build, or the release asset, cached) -> image + manifest
|
|
6
|
+
//
|
|
7
|
+
// The host checks the manifest against itself before it loads the image (crates/sk-app/src/native_aot.rs).
|
|
8
|
+
|
|
9
|
+
import { deflateRawSync } from "node:zlib";
|
|
10
|
+
import { existsSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { join, resolve } from "node:path";
|
|
12
|
+
import { AotError, compileNative, compilerInfo, compilerMismatch, nativeManifest, repoSkAot } from "../aot/native";
|
|
13
|
+
import type { CompilerInfo } from "../aot/pin";
|
|
14
|
+
import { TRANSFORM } from "../aot/transform";
|
|
15
|
+
import { exitCode, formatPretty, runCheck, type CheckReport } from "../check/index";
|
|
16
|
+
import { ConfigError } from "./config";
|
|
17
|
+
import { CLI_VERSION, HostError, REPO_ROOT, type HostAot, type ResolvedHost } from "./host";
|
|
18
|
+
import { cachedAotCompiler, fetchAotCompiler, type OnBytes } from "./host-fetch";
|
|
19
|
+
import type { Platform } from "./platform";
|
|
20
|
+
import { KIND, NAMES, type SkpkInput } from "./skpk";
|
|
21
|
+
import type { Progress } from "./term";
|
|
22
|
+
|
|
23
|
+
export const AOT_PLATFORM_ONLY = "AOT builds are Windows x64 only for now";
|
|
24
|
+
|
|
25
|
+
/** `--aot`, `--no-aot` and `--aot-compiler <exe>`; an unset `aot` leaves sk.config.json "aot" in charge. */
|
|
26
|
+
export function aotFlags(flags: Record<string, string | boolean>): {
|
|
27
|
+
aot: boolean | undefined;
|
|
28
|
+
aotCompiler: string | undefined;
|
|
29
|
+
} {
|
|
30
|
+
if (flags.aot === true && flags["no-aot"] === true) throw new ConfigError("--aot and --no-aot contradict each other");
|
|
31
|
+
const compiler = flags["aot-compiler"];
|
|
32
|
+
if (compiler !== undefined && (typeof compiler !== "string" || !compiler.trim()))
|
|
33
|
+
throw new ConfigError("--aot-compiler needs the path of sk-aot.exe");
|
|
34
|
+
return {
|
|
35
|
+
aot: flags["no-aot"] === true ? false : flags.aot === true ? true : undefined,
|
|
36
|
+
aotCompiler: typeof compiler === "string" ? resolve(compiler.trim()) : undefined,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Why this build cannot be AOT-compiled here, or null. */
|
|
41
|
+
export function aotPlatformProblem(
|
|
42
|
+
target: Platform,
|
|
43
|
+
here: { platform: string; arch: string } = { platform: process.platform, arch: process.arch },
|
|
44
|
+
): string | null {
|
|
45
|
+
if (target !== "windows")
|
|
46
|
+
return `${AOT_PLATFORM_ONLY}: build ${target} with --no-aot (or without "aot": true in sk.config.json)`;
|
|
47
|
+
if (here.platform !== "win32" || here.arch !== "x64")
|
|
48
|
+
return `${AOT_PLATFORM_ONLY}: the native compiler runs on Windows x64 and this is ${here.platform}-${here.arch}; build here with --no-aot`;
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The host's native AOT identity; an error when the host cannot load app images. */
|
|
53
|
+
export function hostAot(host: ResolvedHost): HostAot {
|
|
54
|
+
const aot = host.info.aot;
|
|
55
|
+
if (!host.info.features.includes("native-aot") || !aot) {
|
|
56
|
+
throw new HostError(
|
|
57
|
+
`${host.exe} cannot load native images (it was built without the native AOT loader) — ` +
|
|
58
|
+
`use a Skathi ${CLI_VERSION} release workload (sk workload install), or build one with the native-aot cargo feature`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
if (aot.transform !== TRANSFORM) {
|
|
62
|
+
throw new HostError(
|
|
63
|
+
`${host.exe} expects native images made with the ${aot.transform} transform and this sk makes ${TRANSFORM} — ` +
|
|
64
|
+
"use the sk that matches the workload",
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return aot;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface CompilerChoice {
|
|
71
|
+
path: string;
|
|
72
|
+
info: CompilerInfo;
|
|
73
|
+
source: "--aot-compiler" | "SK_AOT_COMPILER" | "repo" | "cache" | "release";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The sk-aot matching `aot`, first hit wins: --aot-compiler or SK_AOT_COMPILER (must match);
|
|
78
|
+
* the checkout's own build; the cache; a download from this version's release.
|
|
79
|
+
*/
|
|
80
|
+
export async function resolveAotCompiler(
|
|
81
|
+
aot: HostAot,
|
|
82
|
+
named: string | undefined,
|
|
83
|
+
log: (line: string) => void,
|
|
84
|
+
onBytes?: OnBytes,
|
|
85
|
+
): Promise<CompilerChoice> {
|
|
86
|
+
const explicit = named ?? process.env.SK_AOT_COMPILER;
|
|
87
|
+
if (explicit) {
|
|
88
|
+
const info = await compilerInfo(explicit);
|
|
89
|
+
const mismatch = compilerMismatch(info, aot);
|
|
90
|
+
if (mismatch) throw new AotError(`${explicit} compiles for another workload: ${mismatch}`);
|
|
91
|
+
return { path: explicit, info, source: named ? "--aot-compiler" : "SK_AOT_COMPILER" };
|
|
92
|
+
}
|
|
93
|
+
const tried: string[] = [];
|
|
94
|
+
const candidates: { path: string; source: "repo" | "cache" }[] = [];
|
|
95
|
+
if (REPO_ROOT) candidates.push({ path: repoSkAot(REPO_ROOT), source: "repo" });
|
|
96
|
+
candidates.push({ path: cachedAotCompiler(CLI_VERSION), source: "cache" });
|
|
97
|
+
for (const c of candidates) {
|
|
98
|
+
if (!existsSync(c.path)) continue;
|
|
99
|
+
const info = await compilerInfo(c.path);
|
|
100
|
+
const mismatch = compilerMismatch(info, aot);
|
|
101
|
+
if (!mismatch) return { ...c, info };
|
|
102
|
+
tried.push(`${c.path}: ${mismatch}`);
|
|
103
|
+
}
|
|
104
|
+
if (process.env.SK_HOST_OFFLINE === "1") {
|
|
105
|
+
throw new AotError(
|
|
106
|
+
`no sk-aot matches the workload${tried.length ? `:\n ${tried.join("\n ")}` : ""}\n` +
|
|
107
|
+
"SK_HOST_OFFLINE=1 forbids downloading it; pass --aot-compiler <sk-aot.exe>",
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
const fetched = await fetchAotCompiler({ log, onBytes });
|
|
111
|
+
const mismatch = compilerMismatch(fetched.info, aot);
|
|
112
|
+
if (mismatch) throw new AotError(`the Skathi ${CLI_VERSION} release's sk-aot: ${mismatch}`);
|
|
113
|
+
return { path: fetched.path, info: await compilerInfo(fetched.path), source: "release" };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** One line per diagnostic, for warnings that do not stop the build. */
|
|
117
|
+
export function checkLine(d: CheckReport["diagnostics"][number]): string {
|
|
118
|
+
return `${d.file}:${d.range.start.line + 1}:${d.range.start.character + 1} ${d.code} ${d.message}`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** `sk check` over the app: errors (and fatal findings) refuse the build with the report; warnings are printed. */
|
|
122
|
+
export async function aotCheck(
|
|
123
|
+
target: string,
|
|
124
|
+
configPath: string | undefined,
|
|
125
|
+
progress: Progress,
|
|
126
|
+
color: boolean,
|
|
127
|
+
): Promise<CheckReport> {
|
|
128
|
+
const report = await runCheck({ target, configPath, toolVersion: CLI_VERSION, progress });
|
|
129
|
+
const code = exitCode(report, false);
|
|
130
|
+
if (code !== 0) {
|
|
131
|
+
throw new ConfigError(
|
|
132
|
+
`sk check found what a native image cannot run, so the AOT build stops here:\n\n${formatPretty(report, { color })}\n\n` +
|
|
133
|
+
"Fix the errors (sk explain <CODE> says how), or build with --no-aot.",
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
for (const d of report.diagnostics) progress.warn(checkLine(d));
|
|
137
|
+
return report;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface NativeBuild {
|
|
141
|
+
inputs: SkpkInput[];
|
|
142
|
+
manifestPath: string;
|
|
143
|
+
imageBytes: number;
|
|
144
|
+
compressedBytes: number;
|
|
145
|
+
entry: number;
|
|
146
|
+
compiler: CompilerChoice;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** The two payload entries that make an app native, written also to `work` for inspection. */
|
|
150
|
+
export async function buildNative(options: {
|
|
151
|
+
source: Uint8Array;
|
|
152
|
+
aot: HostAot;
|
|
153
|
+
compilerPath: string | undefined;
|
|
154
|
+
work: string;
|
|
155
|
+
progress: Progress;
|
|
156
|
+
log: (line: string) => void;
|
|
157
|
+
}): Promise<NativeBuild> {
|
|
158
|
+
const { progress, log, aot, work } = options;
|
|
159
|
+
progress.step("AOT toolchain");
|
|
160
|
+
const compiler = await resolveAotCompiler(aot, options.compilerPath, log, (done, total) =>
|
|
161
|
+
progress.bytes(done, total),
|
|
162
|
+
);
|
|
163
|
+
progress.detail(`sk-aot (${compiler.source})`);
|
|
164
|
+
progress.step("native image");
|
|
165
|
+
const native = await compileNative({
|
|
166
|
+
compiler: compiler.path,
|
|
167
|
+
source: new TextDecoder().decode(options.source),
|
|
168
|
+
work,
|
|
169
|
+
});
|
|
170
|
+
const compressed = deflateRawSync(native.image, { level: 9 });
|
|
171
|
+
progress.detail(
|
|
172
|
+
`${(native.image.length / 2 ** 20).toFixed(1)} MiB, ${(compressed.length / 2 ** 20).toFixed(1)} MiB packed`,
|
|
173
|
+
);
|
|
174
|
+
const manifest = nativeManifest("application", compiler.info, native, {
|
|
175
|
+
image: NAMES.NATIVE_IMAGE,
|
|
176
|
+
preludeSha256: aot.preludeSha256,
|
|
177
|
+
});
|
|
178
|
+
const text = JSON.stringify(manifest, null, 2);
|
|
179
|
+
const manifestPath = join(work, "app.native.json");
|
|
180
|
+
writeFileSync(manifestPath, text);
|
|
181
|
+
return {
|
|
182
|
+
inputs: [
|
|
183
|
+
{ name: NAMES.NATIVE_MANIFEST, kind: KIND.NATIVE_MANIFEST, data: new TextEncoder().encode(text) },
|
|
184
|
+
{ name: NAMES.NATIVE_IMAGE, kind: KIND.NATIVE_IMAGE, data: new Uint8Array(compressed) },
|
|
185
|
+
],
|
|
186
|
+
manifestPath,
|
|
187
|
+
imageBytes: native.image.length,
|
|
188
|
+
compressedBytes: compressed.length,
|
|
189
|
+
entry: native.entry,
|
|
190
|
+
compiler,
|
|
191
|
+
};
|
|
192
|
+
}
|
package/cli/build-app.ts
CHANGED
|
@@ -8,21 +8,17 @@
|
|
|
8
8
|
// without a re-stamp. On macOS (or `--platform macos` with `--host <mac sk-app>`) the last step is
|
|
9
9
|
// macos-bundle.ts: the host is copied into `<exeName>.app`, the SKPK goes in Contents/Resources,
|
|
10
10
|
// and the bundle is signed (ad hoc unless an identity is given). On Linux the SKPK is appended to a
|
|
11
|
-
// copy of the host ELF (elf.ts). `PACKAGERS` holds the three.
|
|
11
|
+
// copy of the host ELF (elf.ts). `PACKAGERS` holds the three. With `--aot` (Windows x64), aot-build.ts adds
|
|
12
|
+
// the app's native image to the SKPK. The app's shaders/*.slang go in as `sk/effects/*` (effects.ts), every
|
|
13
|
+
// renderer's target whatever the OS.
|
|
12
14
|
|
|
13
15
|
import { createHash } from "node:crypto";
|
|
14
16
|
import { existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
15
17
|
import { join, relative, resolve, sep } from "node:path";
|
|
18
|
+
import { aotCheck, aotPlatformProblem, buildNative, hostAot, type NativeBuild } from "./aot-build";
|
|
16
19
|
import { collectAssets, type AssetFile } from "./assets";
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
partsLeftOut,
|
|
20
|
-
variantFor,
|
|
21
|
-
variantWarnings,
|
|
22
|
-
type AppConfig,
|
|
23
|
-
type PackConfig,
|
|
24
|
-
type Variant,
|
|
25
|
-
} from "./config";
|
|
20
|
+
import { ConfigError, loadAppConfig, parseVariant, type AppConfig, type PackConfig, type Variant } from "./config";
|
|
21
|
+
import { buildAppEffects, type BuiltEffects } from "./effects";
|
|
26
22
|
import { stampElf, type ElfStampResult } from "./elf";
|
|
27
23
|
import { CLI_VERSION, PKG_DIR, type ResolvedHost } from "./host";
|
|
28
24
|
import { resolveOrFetchHost } from "./host-fetch";
|
|
@@ -55,20 +51,28 @@ export interface BuildOptions {
|
|
|
55
51
|
configPath?: string | undefined;
|
|
56
52
|
out?: string | undefined;
|
|
57
53
|
host?: string | undefined;
|
|
58
|
-
/** The host variant; overrides
|
|
54
|
+
/** The host variant (standard or no-devtools); overrides the mode's. */
|
|
59
55
|
variant?: Variant | undefined;
|
|
60
56
|
console?: boolean;
|
|
61
57
|
payloadOnly?: boolean;
|
|
62
58
|
allowHostMismatch?: boolean;
|
|
63
59
|
defines?: string[] | undefined;
|
|
64
60
|
aotInputs?: boolean;
|
|
61
|
+
/** Compile the app to a native image (over sk.config.json "aot"). */
|
|
62
|
+
aot?: boolean | undefined;
|
|
63
|
+
/** The sk-aot to use instead of the checkout's or the release's. */
|
|
64
|
+
aotCompiler?: string | undefined;
|
|
65
|
+
/** The redslangc that compiles the app's effect shaders instead of the pinned release. */
|
|
66
|
+
shaderCompiler?: string | undefined;
|
|
67
|
+
/** Colors in a report that refuses the build. */
|
|
68
|
+
color?: boolean;
|
|
65
69
|
platform?: Platform | undefined;
|
|
66
70
|
/** macOS: a codesign identity (`-` = ad hoc), or false for none; over `macos.sign`. */
|
|
67
71
|
sign?: string | false | undefined;
|
|
68
72
|
/**
|
|
69
73
|
* `sk build` is "debug": devtools always in, the bundle not minified, <app>/dist/debug. `sk publish` is
|
|
70
|
-
* "release": sk.config.json
|
|
71
|
-
* the
|
|
74
|
+
* "release": no devtools unless sk.config.json has "publishDevtools": true; <app>/dist/release. Unset:
|
|
75
|
+
* the standard host into <app>/dist.
|
|
72
76
|
*/
|
|
73
77
|
mode?: "debug" | "release" | undefined;
|
|
74
78
|
/** Plain lines instead of the default progress on stderr. */
|
|
@@ -76,12 +80,9 @@ export interface BuildOptions {
|
|
|
76
80
|
progress?: Progress;
|
|
77
81
|
}
|
|
78
82
|
|
|
79
|
-
/** The variant a mode builds when
|
|
83
|
+
/** The variant a mode builds when `--variant` names none. */
|
|
80
84
|
export function modeVariant(config: AppConfig, mode: BuildOptions["mode"]): Variant {
|
|
81
|
-
|
|
82
|
-
if (mode === "debug") return variantFor(partsLeftOut(selected).filter((p) => p !== "devtools"));
|
|
83
|
-
if (mode === "release" && !config.windows.selected) return "no-devtools";
|
|
84
|
-
return selected;
|
|
85
|
+
return mode === "release" && !config.publishDevtools ? "no-devtools" : "standard";
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
interface BuilderAsset {
|
|
@@ -122,6 +123,16 @@ export interface BuildResult {
|
|
|
122
123
|
payloadBytes: number;
|
|
123
124
|
packs: { name: string; path: string; bytes: number; assets: number }[];
|
|
124
125
|
aotInputs: string | null;
|
|
126
|
+
/** The app's own --shading effects, compiled into the payload. */
|
|
127
|
+
effects: { names: string[]; dir: string; compiler: string } | null;
|
|
128
|
+
native: {
|
|
129
|
+
manifest: string;
|
|
130
|
+
imageBytes: number;
|
|
131
|
+
compressedBytes: number;
|
|
132
|
+
entry: number;
|
|
133
|
+
compiler: string;
|
|
134
|
+
ms: number;
|
|
135
|
+
} | null;
|
|
125
136
|
warnings: string[];
|
|
126
137
|
ms: { bundle: number; assets: number; stamp: number; total: number };
|
|
127
138
|
}
|
|
@@ -339,9 +350,12 @@ const PACKAGERS: Record<Platform, (input: PackageInput) => Packaged> = {
|
|
|
339
350
|
export async function buildApp(options: BuildOptions): Promise<BuildResult> {
|
|
340
351
|
const progress = options.progress ?? (options.log ? lineProgress(options.log, false) : progressFor(process.stderr));
|
|
341
352
|
try {
|
|
342
|
-
|
|
343
|
-
} finally {
|
|
353
|
+
const result = await build(options, progress);
|
|
344
354
|
if (!options.progress) progress.end();
|
|
355
|
+
return result;
|
|
356
|
+
} catch (e) {
|
|
357
|
+
progress.fail();
|
|
358
|
+
throw e;
|
|
345
359
|
}
|
|
346
360
|
}
|
|
347
361
|
|
|
@@ -354,31 +368,46 @@ async function build(options: BuildOptions, progress: Progress): Promise<BuildRe
|
|
|
354
368
|
const platform = options.platform ?? currentPlatform();
|
|
355
369
|
const config = loadAppConfig(options.target, { configPath: options.configPath, platform });
|
|
356
370
|
const warnings = [...config.warnings];
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
371
|
+
const variant: Variant =
|
|
372
|
+
options.variant === undefined ? modeVariant(config, options.mode) : parseVariant(options.variant, "--variant");
|
|
373
|
+
const aot = options.aot ?? config.aot;
|
|
374
|
+
if (aot) {
|
|
375
|
+
const problem = aotPlatformProblem(platform);
|
|
376
|
+
if (problem) throw new ConfigError(problem);
|
|
377
|
+
if (options.payloadOnly)
|
|
378
|
+
throw new ConfigError(
|
|
379
|
+
"--aot compiles against the workload it stamps, so it cannot be combined with --payload-only",
|
|
380
|
+
);
|
|
381
|
+
}
|
|
360
382
|
const outDir = resolve(options.out ?? join(config.appRoot, "dist", ...(options.mode ? [options.mode] : [])));
|
|
361
383
|
const work = join(outDir, ".sk");
|
|
362
384
|
mkdirSync(work, { recursive: true });
|
|
363
385
|
|
|
364
386
|
// The host first: a missing or mismatched host should fail before a bundle is spent on it.
|
|
365
|
-
if (!options.payloadOnly) progress.step("
|
|
387
|
+
if (!options.payloadOnly) progress.step("workload");
|
|
366
388
|
const host = options.payloadOnly
|
|
367
389
|
? null
|
|
368
390
|
: await resolveOrFetchHost({
|
|
369
391
|
host: options.host,
|
|
370
|
-
variant
|
|
392
|
+
variant,
|
|
371
393
|
allowMismatch: options.allowHostMismatch,
|
|
372
394
|
platform,
|
|
373
395
|
log,
|
|
396
|
+
onBytes: (done, total) => progress.bytes(done, total),
|
|
374
397
|
});
|
|
375
398
|
if (host) {
|
|
376
399
|
progress.detail(`${host.info.variant} · Skathi ${host.info.skathi} ${host.info.profile} · ${host.source}`);
|
|
377
400
|
if (host.unverified) warnings.push(host.unverified);
|
|
378
|
-
if (host.substitute) warnings.push(host.substitute);
|
|
379
401
|
}
|
|
380
|
-
|
|
381
|
-
|
|
402
|
+
const hostNative = aot && host ? hostAot(host) : null;
|
|
403
|
+
|
|
404
|
+
const effects: BuiltEffects | null = await buildAppEffects({
|
|
405
|
+
appRoot: config.appRoot,
|
|
406
|
+
out: join(work, "effects"),
|
|
407
|
+
compiler: options.shaderCompiler,
|
|
408
|
+
progress,
|
|
409
|
+
});
|
|
410
|
+
if (!effects) rmSync(join(work, "effects"), { recursive: true, force: true });
|
|
382
411
|
|
|
383
412
|
const jsOut = join(work, "app.prod.js");
|
|
384
413
|
const assetsJson = join(work, "assets.json");
|
|
@@ -417,6 +446,7 @@ async function build(options: BuildOptions, progress: Progress): Promise<BuildRe
|
|
|
417
446
|
const script = readFileSync(jsOut);
|
|
418
447
|
const windowJson = readFileSync(join(work, "window.json"));
|
|
419
448
|
const msBundle = performance.now() - tb;
|
|
449
|
+
if (aot) await aotCheck(options.target, options.configPath, progress, options.color ?? false);
|
|
420
450
|
|
|
421
451
|
progress.step("assets");
|
|
422
452
|
const ta = performance.now();
|
|
@@ -472,11 +502,27 @@ async function build(options: BuildOptions, progress: Progress): Promise<BuildRe
|
|
|
472
502
|
{ name: NAMES.WINDOW, kind: KIND.WINDOW, data: windowJson },
|
|
473
503
|
{ name: NAMES.SCRIPT, kind: KIND.SCRIPT, data: script },
|
|
474
504
|
...split.own.map((f) => ({ name: f.key, kind: KIND.ASSET, data: new Uint8Array(readFileSync(f.path)) })),
|
|
505
|
+
...(effects?.inputs ?? []),
|
|
475
506
|
];
|
|
476
507
|
const skpk = join(work, "app.skpk");
|
|
477
508
|
for (const p of packs) writeFileSync(join(work, p.file), p.blob);
|
|
478
509
|
progress.detail(`${collected.files.length} files · ${kib(collected.totalBytes)}`);
|
|
479
510
|
|
|
511
|
+
let native: NativeBuild | null = null;
|
|
512
|
+
const tn = performance.now();
|
|
513
|
+
if (hostNative) {
|
|
514
|
+
native = await buildNative({
|
|
515
|
+
source: script,
|
|
516
|
+
aot: hostNative,
|
|
517
|
+
compilerPath: options.aotCompiler,
|
|
518
|
+
work: join(work, "aot"),
|
|
519
|
+
progress,
|
|
520
|
+
log,
|
|
521
|
+
});
|
|
522
|
+
inputs.push(...native.inputs);
|
|
523
|
+
}
|
|
524
|
+
const msNative = performance.now() - tn;
|
|
525
|
+
|
|
480
526
|
let packaged: Packaged | null = null;
|
|
481
527
|
const ts = performance.now();
|
|
482
528
|
progress.step(options.payloadOnly || !host ? "payload" : platform === "macos" ? "app bundle" : "exe");
|
|
@@ -510,6 +556,19 @@ async function build(options: BuildOptions, progress: Progress): Promise<BuildRe
|
|
|
510
556
|
assets: collected.files,
|
|
511
557
|
bundleBytes: script.length,
|
|
512
558
|
aotInputs: options.aotInputs ? join(work, "aot-inputs", "manifest.json") : null,
|
|
559
|
+
effects: effects && {
|
|
560
|
+
names: effects.effects.compiled.map((c) => c.effect.name),
|
|
561
|
+
dir: join(work, "effects"),
|
|
562
|
+
compiler: effects.compiler.path,
|
|
563
|
+
},
|
|
564
|
+
native: native && {
|
|
565
|
+
manifest: native.manifestPath,
|
|
566
|
+
imageBytes: native.imageBytes,
|
|
567
|
+
compressedBytes: native.compressedBytes,
|
|
568
|
+
entry: native.entry,
|
|
569
|
+
compiler: native.compiler.path,
|
|
570
|
+
ms: Math.round(msNative),
|
|
571
|
+
},
|
|
513
572
|
payloadBytes: packaged?.payload.length ?? readFileSync(skpk).length,
|
|
514
573
|
packs: packs.map((p) => ({
|
|
515
574
|
name: p.name,
|
|
@@ -545,7 +604,7 @@ export function summary(r: BuildResult, color = false): string {
|
|
|
545
604
|
row("exe", p.cyan(r.exe)),
|
|
546
605
|
row(
|
|
547
606
|
"",
|
|
548
|
-
`${mib(s.bytes)}, ${r.variant}
|
|
607
|
+
`${mib(s.bytes)}, ${r.variant} workload, subsystem ${s.subsystem === 2 ? "GUI" : "console"}, ` +
|
|
549
608
|
`${s.iconCount ? `${s.iconCount} icon` : "no icon"}, ` +
|
|
550
609
|
bad(s.dataAligned, "data page-aligned", "data NOT aligned"),
|
|
551
610
|
),
|
|
@@ -557,7 +616,7 @@ export function summary(r: BuildResult, color = false): string {
|
|
|
557
616
|
row("exe", p.cyan(e.out)),
|
|
558
617
|
row(
|
|
559
618
|
"",
|
|
560
|
-
`${mib(e.bytes)}, ${r.variant}
|
|
619
|
+
`${mib(e.bytes)}, ${r.variant} workload (${e.machine}), payload appended at ${e.payloadOffset}, ` +
|
|
561
620
|
bad(e.dataAligned, "data page-aligned", "data NOT aligned"),
|
|
562
621
|
),
|
|
563
622
|
);
|
|
@@ -569,7 +628,7 @@ export function summary(r: BuildResult, color = false): string {
|
|
|
569
628
|
b.signed === "-" ? "signed ad hoc" : b.signed ? `signed as ${JSON.stringify(b.signed)}` : p.yellow("NOT signed");
|
|
570
629
|
lines.push(
|
|
571
630
|
row("app", p.cyan(b.app)),
|
|
572
|
-
row("", `${mib(b.bytes)}, ${r.variant}
|
|
631
|
+
row("", `${mib(b.bytes)}, ${r.variant} workload, ${b.bundleId}, ${icon}, ${signed}`),
|
|
573
632
|
);
|
|
574
633
|
if (b.signNote) lines.push(row("", p.dim(b.signNote)));
|
|
575
634
|
}
|
|
@@ -580,6 +639,18 @@ export function summary(r: BuildResult, color = false): string {
|
|
|
580
639
|
),
|
|
581
640
|
row("payload", `${kib(r.payloadBytes)} ${p.dim(r.skpk)}`),
|
|
582
641
|
);
|
|
642
|
+
if (r.effects) {
|
|
643
|
+
lines.push(row("effects", `${r.effects.names.join(", ")} ${p.dim("hlsl · wgsl · metal")}`));
|
|
644
|
+
}
|
|
645
|
+
if (r.native) {
|
|
646
|
+
lines.push(
|
|
647
|
+
row(
|
|
648
|
+
"native",
|
|
649
|
+
`${mib(r.native.imageBytes)} image (${mib(r.native.compressedBytes)} in the payload), entry ${r.native.entry} ` +
|
|
650
|
+
p.dim(r.native.manifest),
|
|
651
|
+
),
|
|
652
|
+
);
|
|
653
|
+
}
|
|
583
654
|
for (const pk of r.packs)
|
|
584
655
|
lines.push(row("pack", `${pk.name}: ${pk.assets} asset(s), ${kib(pk.bytes)} ${p.dim(pk.path)}`));
|
|
585
656
|
lines.push(`${p.green("done")} in ${seconds(r.ms.total)}`);
|