@native-sdk/cli 0.4.4 → 0.5.1
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/build/app.zig +371 -5
- package/build/ts_run.mjs +102 -0
- package/build.zig +255 -1
- package/build.zig.zon +1 -0
- package/package.json +19 -10
- package/packages/core/package-lock.json +44 -0
- package/packages/core/package.json +38 -0
- package/packages/core/rt/rt.zig +1579 -0
- package/packages/core/sdk/bytes_text_methods.d.ts +88 -0
- package/packages/core/sdk/core.ts +694 -0
- package/packages/core/sdk/events.ts +137 -0
- package/packages/core/sdk/text.ts +519 -0
- package/packages/core/src/checker.ts +1869 -0
- package/packages/core/src/cli.ts +68 -0
- package/packages/core/src/devhost.ts +291 -0
- package/packages/core/src/devhost_resolver.mjs +22 -0
- package/packages/core/src/diagnostics.ts +417 -0
- package/packages/core/src/emitter.ts +8815 -0
- package/packages/core/src/infer.ts +1515 -0
- package/packages/core/src/modules.ts +173 -0
- package/packages/core/src/ownership.ts +740 -0
- package/packages/core/src/text_polyfill.ts +337 -0
- package/packages/core/src/text_tables.ts +408 -0
- package/packages/core/src/transpile.ts +146 -0
- package/packages/core/src/typed_ast.ts +546 -0
- package/packages/core/src/types.ts +815 -0
- package/skill-data/native-ui/SKILL.md +14 -0
- package/skill-data/ts-core/SKILL.md +493 -0
- package/skill-data/zig/SKILL.md +10 -0
- package/src/app_runner/root.zig +24 -0
- package/src/app_runner/ts_core_main.zig +231 -0
- package/src/platform/windows/webview2_host.cpp +24 -0
- package/src/primitives/app_manifest/comptime_scene.zig +341 -0
- package/src/primitives/app_manifest/root.zig +5 -0
- package/src/primitives/canvas/commands.zig +14 -7
- package/src/primitives/canvas/layout_audit.zig +5 -5
- package/src/primitives/canvas/lazy_tls.zig +73 -0
- package/src/primitives/canvas/render_generic_resources.zig +22 -15
- package/src/primitives/canvas/root.zig +11 -0
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +40 -32
- package/src/primitives/canvas/text_layout_cache.zig +29 -22
- package/src/primitives/canvas/text_measure_cache.zig +56 -41
- package/src/primitives/canvas/text_spans.zig +39 -26
- package/src/primitives/canvas/tokens.zig +69 -0
- package/src/primitives/canvas/ui.zig +125 -0
- package/src/primitives/canvas/ui_markup.zig +22 -3
- package/src/primitives/canvas/ui_markup_compiled.zig +97 -7
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +275 -0
- package/src/primitives/canvas/ui_markup_contract.zig +68 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +257 -2
- package/src/primitives/canvas/ui_markup_reflect.zig +214 -0
- package/src/primitives/canvas/ui_markup_view.zig +105 -1
- package/src/primitives/canvas/ui_markup_view_tests.zig +336 -0
- package/src/primitives/canvas/ui_schema.zig +8 -0
- package/src/primitives/canvas/ui_schema_tests.zig +5 -4
- package/src/primitives/canvas/widget_builtin_tests.zig +309 -5
- package/src/primitives/canvas/widget_invalidation.zig +14 -7
- package/src/primitives/canvas/widget_layout.zig +138 -2
- package/src/primitives/canvas/widget_metrics.zig +16 -8
- package/src/primitives/canvas/widget_render.zig +25 -15
- package/src/primitives/canvas/widget_render_controls.zig +15 -9
- package/src/primitives/canvas/widget_runtime_tests.zig +44 -0
- package/src/root.zig +7 -0
- package/src/runtime/canvas_frame.zig +57 -36
- package/src/runtime/canvas_images.zig +9 -3
- package/src/runtime/canvas_widget_control_tests.zig +5 -6
- package/src/runtime/canvas_widget_runtime.zig +7 -4
- package/src/runtime/core.zig +16 -0
- package/src/runtime/effects.zig +1525 -133
- package/src/runtime/effects_fetch_tests.zig +42 -0
- package/src/runtime/effects_file_tests.zig +220 -0
- package/src/runtime/effects_host_tests.zig +594 -0
- package/src/runtime/effects_tests.zig +287 -0
- package/src/runtime/root.zig +18 -0
- package/src/runtime/session_replay.zig +7 -1
- package/src/runtime/tests.zig +2 -0
- package/src/runtime/ts_core_host.zig +1505 -0
- package/src/runtime/ts_core_host_tests.zig +1408 -0
- package/src/runtime/ts_ui_app.zig +469 -0
- package/src/runtime/ui_app.zig +189 -38
- package/src/runtime/ui_app_tests.zig +221 -0
- package/src/runtime/ui_app_window_tests.zig +182 -0
- package/src/runtime/view_canvas.zig +24 -17
- package/src/runtime/view_widget_tree.zig +2 -2
- package/src/tooling/codesign.zig +212 -105
- package/src/tooling/doctor.zig +78 -0
- package/src/tooling/manifest.zig +47 -0
- package/src/tooling/package.zig +435 -20
- package/src/tooling/raw_manifest.zig +15 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +777 -34
- package/src/tooling/ts_core.zig +1099 -0
- package/src/tooling/verbs.zig +105 -2
package/src/tooling/package.zig
CHANGED
|
@@ -84,15 +84,39 @@ pub const PackageOptions = struct {
|
|
|
84
84
|
env_map: ?*std.process.Environ.Map = null,
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
+
/// The Windows subsystem verdict the packaging posture check reaches:
|
|
88
|
+
/// `gui` and `console` only when the PE optional header actually said
|
|
89
|
+
/// so, `unknown` when the probe proved nothing — non-PE or truncated
|
|
90
|
+
/// bytes, a headerless image, an `e_lfanew` past the header ceiling, a
|
|
91
|
+
/// benign read error, or some other declared subsystem entirely
|
|
92
|
+
/// (native, EFI, ...). No surface may claim a subsystem the parse
|
|
93
|
+
/// never established.
|
|
94
|
+
pub const WindowsSubsystem = enum { gui, console, unknown };
|
|
95
|
+
|
|
87
96
|
pub const PackageStats = struct {
|
|
88
97
|
path: []const u8,
|
|
89
98
|
artifact_name: []const u8 = "",
|
|
90
99
|
target: PackageTarget = .macos,
|
|
91
100
|
signing_mode: SigningMode = .none,
|
|
101
|
+
/// True when a signing mode that claims to sign (adhoc or identity)
|
|
102
|
+
/// ran AND the result passed `codesign --verify --deep --strict`:
|
|
103
|
+
/// the proof behind the report's "signed, verified" line. A package
|
|
104
|
+
/// whose signing or verification fails never produces stats at all.
|
|
105
|
+
signing_verified: bool = false,
|
|
92
106
|
asset_count: usize = 0,
|
|
93
107
|
web_engine: WebEngine = .system,
|
|
94
108
|
web_layer: ?manifest_tool.WebLayer = null,
|
|
95
109
|
archive_path: ?[]const u8 = null,
|
|
110
|
+
/// The Windows subsystem verdict: `console` when the package
|
|
111
|
+
/// wrapped a CONSOLE-subsystem exe (the app will flash a terminal
|
|
112
|
+
/// window behind itself on every launch), `gui` for a GUI-subsystem
|
|
113
|
+
/// exe, `unknown` when the probe could not establish either, and
|
|
114
|
+
/// null when the check never ran (non-Windows target, or no binary
|
|
115
|
+
/// to probe). Release-shaped `native build` exes are GUI-subsystem,
|
|
116
|
+
/// so console only fires for stale or hand-supplied binaries — the
|
|
117
|
+
/// packager warns and the report carries the truth (pinned by tests
|
|
118
|
+
/// over a synthetic PE header).
|
|
119
|
+
windows_subsystem: ?WindowsSubsystem = null,
|
|
96
120
|
};
|
|
97
121
|
|
|
98
122
|
/// The web-layer verdict for a package, from the same declare-to-use
|
|
@@ -174,6 +198,16 @@ pub fn printDiagnostic(stats: PackageStats) void {
|
|
|
174
198
|
if (stats.web_layer) |layer| {
|
|
175
199
|
std.debug.print(" web layer: {s} ({s})\n", .{ webLayerEngineName(layer, stats.target, stats.web_engine), layer.sourceText() });
|
|
176
200
|
}
|
|
201
|
+
if (stats.signing_verified) {
|
|
202
|
+
std.debug.print(" signing: {s} (signed, verified)\n", .{@tagName(stats.signing_mode)});
|
|
203
|
+
}
|
|
204
|
+
if (stats.windows_subsystem) |subsystem| {
|
|
205
|
+
switch (subsystem) {
|
|
206
|
+
.console => std.debug.print(" subsystem: console (a terminal window opens behind the app - rebuild with `native build`)\n", .{}),
|
|
207
|
+
.gui => std.debug.print(" subsystem: gui\n", .{}),
|
|
208
|
+
.unknown => std.debug.print(" subsystem: unknown (unrecognized executable format)\n", .{}),
|
|
209
|
+
}
|
|
210
|
+
}
|
|
177
211
|
if (stats.archive_path) |archive| {
|
|
178
212
|
std.debug.print(" archive: {s}\n", .{archive});
|
|
179
213
|
}
|
|
@@ -220,18 +254,19 @@ pub fn createMacosApp(allocator: std.mem.Allocator, io: std.Io, options: Package
|
|
|
220
254
|
const bundle_stats = try assets_tool.bundle(allocator, io, options.assets_dir, assets_output);
|
|
221
255
|
try copyMacosIcon(allocator, io, package_dir, options);
|
|
222
256
|
try copyMacosDocumentIcons(allocator, io, package_dir, options.metadata);
|
|
223
|
-
try writeReport(allocator, package_dir, io, "Contents/Resources/package-manifest.zon", options, executable_name, bundle_stats.asset_count);
|
|
257
|
+
try writeReport(allocator, package_dir, io, "Contents/Resources/package-manifest.zon", options, executable_name, bundle_stats.asset_count, null);
|
|
224
258
|
if (options.web_engine == .chromium) {
|
|
225
259
|
try cef.ensureLayout(io, options.cef_dir);
|
|
226
260
|
try copyMacosCefRuntime(allocator, io, package_dir, options.cef_dir);
|
|
227
261
|
}
|
|
228
|
-
try runSigning(allocator, io, package_dir, options);
|
|
262
|
+
const signing_verified = try runSigning(allocator, io, package_dir, options);
|
|
229
263
|
|
|
230
264
|
return .{
|
|
231
265
|
.path = options.output_path,
|
|
232
266
|
.artifact_name = std.fs.path.basename(options.output_path),
|
|
233
267
|
.target = .macos,
|
|
234
268
|
.signing_mode = options.signing.mode,
|
|
269
|
+
.signing_verified = signing_verified,
|
|
235
270
|
.asset_count = bundle_stats.asset_count,
|
|
236
271
|
.web_engine = options.web_engine,
|
|
237
272
|
.web_layer = webLayerFor(options),
|
|
@@ -286,6 +321,21 @@ fn createDesktopArtifact(allocator: std.mem.Allocator, io: std.Io, options: Pack
|
|
|
286
321
|
}
|
|
287
322
|
}
|
|
288
323
|
}
|
|
324
|
+
// The subsystem posture check: `native build` produces GUI-subsystem
|
|
325
|
+
// release exes on Windows, so a console-subsystem exe here is a stale
|
|
326
|
+
// zig-out binary or a hand-supplied --binary — packaged as-is it
|
|
327
|
+
// flashes a terminal window behind the app on every launch. Warn and
|
|
328
|
+
// carry the truth in the stats/report; the package still builds
|
|
329
|
+
// (the app works, it just looks unfinished). Null means the check
|
|
330
|
+
// never ran: a non-Windows target, or no binary to probe.
|
|
331
|
+
const windows_subsystem: ?WindowsSubsystem = if (options.target == .windows)
|
|
332
|
+
if (options.binary_path) |binary_path| try peSubsystemVerdictAtPath(allocator, io, binary_path) else null
|
|
333
|
+
else
|
|
334
|
+
null;
|
|
335
|
+
if (windows_subsystem == .console) {
|
|
336
|
+
std.debug.print("warning[package.console-subsystem]: {s} is a console-subsystem exe, so a terminal window will open behind the app on every launch\n" ++
|
|
337
|
+
" rebuild with `native build` (release exes are GUI-subsystem) or pass a GUI-subsystem --binary\n", .{options.binary_path.?});
|
|
338
|
+
}
|
|
289
339
|
if (options.binary_path) |binary_path| {
|
|
290
340
|
const binary_subpath = try std.fmt.allocPrint(allocator, "bin/{s}", .{executable_name});
|
|
291
341
|
defer allocator.free(binary_subpath);
|
|
@@ -334,8 +384,8 @@ fn createDesktopArtifact(allocator: std.mem.Allocator, io: std.Io, options: Pack
|
|
|
334
384
|
try cef.ensureLayoutFor(io, cef_platform, options.cef_dir);
|
|
335
385
|
try copyDesktopCefRuntime(allocator, io, dir, options.target, options.cef_dir);
|
|
336
386
|
}
|
|
337
|
-
try writeReport(allocator, dir, io, "package-manifest.zon", options, executable_name, bundle_stats.asset_count);
|
|
338
|
-
return .{ .path = options.output_path, .artifact_name = std.fs.path.basename(options.output_path), .target = options.target, .asset_count = bundle_stats.asset_count, .web_engine = options.web_engine, .web_layer = webLayerFor(options) };
|
|
387
|
+
try writeReport(allocator, dir, io, "package-manifest.zon", options, executable_name, bundle_stats.asset_count, windows_subsystem);
|
|
388
|
+
return .{ .path = options.output_path, .artifact_name = std.fs.path.basename(options.output_path), .target = options.target, .asset_count = bundle_stats.asset_count, .web_engine = options.web_engine, .web_layer = webLayerFor(options), .windows_subsystem = windows_subsystem };
|
|
339
389
|
}
|
|
340
390
|
|
|
341
391
|
/// The iOS host tier: a COMPLETE Xcode project the user never edits —
|
|
@@ -406,7 +456,7 @@ fn createIosArtifact(allocator: std.mem.Allocator, io: std.Io, options: PackageO
|
|
|
406
456
|
const readme = try iosProjectReadme(allocator, options.metadata);
|
|
407
457
|
defer allocator.free(readme);
|
|
408
458
|
try writeFile(dir, io, "README.md", readme);
|
|
409
|
-
try writeReport(allocator, dir, io, "package-manifest.zon", options, "libnative-sdk.a", bundle_stats.asset_count);
|
|
459
|
+
try writeReport(allocator, dir, io, "package-manifest.zon", options, "libnative-sdk.a", bundle_stats.asset_count, null);
|
|
410
460
|
return .{ .path = options.output_path, .artifact_name = std.fs.path.basename(options.output_path), .target = .ios, .asset_count = bundle_stats.asset_count, .web_engine = options.web_engine, .web_layer = webLayerFor(options) };
|
|
411
461
|
}
|
|
412
462
|
|
|
@@ -468,7 +518,7 @@ fn createAndroidArtifact(allocator: std.mem.Allocator, io: std.Io, options: Pack
|
|
|
468
518
|
const readme = try androidProjectReadme(allocator, options.metadata);
|
|
469
519
|
defer allocator.free(readme);
|
|
470
520
|
try writeFile(dir, io, "README.md", readme);
|
|
471
|
-
try writeReport(allocator, dir, io, "package-manifest.zon", options, "libnative-sdk.a", bundle_stats.asset_count);
|
|
521
|
+
try writeReport(allocator, dir, io, "package-manifest.zon", options, "libnative-sdk.a", bundle_stats.asset_count, null);
|
|
472
522
|
|
|
473
523
|
var artifact_name: []const u8 = std.fs.path.basename(options.output_path);
|
|
474
524
|
if (try assembleAndroidApk(allocator, io, options)) |apk_name| {
|
|
@@ -1062,6 +1112,84 @@ fn peReferencesWebView2Loader(allocator: std.mem.Allocator, io: std.Io, path: []
|
|
|
1062
1112
|
std.mem.indexOf(u8, bytes, needle_ascii) != null;
|
|
1063
1113
|
}
|
|
1064
1114
|
|
|
1115
|
+
/// The Windows subsystem a PE executable declares (IMAGE_OPTIONAL_HEADER
|
|
1116
|
+
/// Subsystem: 2 = GUI, 3 = console), or null when the file is not a PE
|
|
1117
|
+
/// with an optional header large enough to say. The packaging check
|
|
1118
|
+
/// reads this because a console-subsystem GUI app flashes a terminal
|
|
1119
|
+
/// window behind itself on every launch — `native build` produces
|
|
1120
|
+
/// GUI-subsystem release exes, so a console one here means a stale or
|
|
1121
|
+
/// hand-built binary.
|
|
1122
|
+
pub fn peSubsystem(bytes: []const u8) ?u16 {
|
|
1123
|
+
if (bytes.len < 0x40 or bytes[0] != 'M' or bytes[1] != 'Z') return null;
|
|
1124
|
+
const pe_offset: usize = std.mem.readInt(u32, bytes[0x3c..0x40], .little);
|
|
1125
|
+
if (pe_offset + 24 > bytes.len) return null;
|
|
1126
|
+
if (!std.mem.eql(u8, bytes[pe_offset..][0..4], "PE\x00\x00")) return null;
|
|
1127
|
+
const optional_size = std.mem.readInt(u16, bytes[pe_offset + 20 ..][0..2], .little);
|
|
1128
|
+
// Subsystem sits 68 bytes into the optional header (same offset in
|
|
1129
|
+
// PE32 and PE32+).
|
|
1130
|
+
if (optional_size < 70) return null;
|
|
1131
|
+
const subsystem_offset = pe_offset + 24 + 68;
|
|
1132
|
+
if (subsystem_offset + 2 > bytes.len) return null;
|
|
1133
|
+
return std.mem.readInt(u16, bytes[subsystem_offset..][0..2], .little);
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
const pe_subsystem_gui: u16 = 2;
|
|
1137
|
+
const pe_subsystem_console: u16 = 3;
|
|
1138
|
+
|
|
1139
|
+
/// The farthest into a file a real executable's PE header is allowed to
|
|
1140
|
+
/// start for the subsystem probe: linkers place `e_lfanew` right after
|
|
1141
|
+
/// the DOS stub (well under a page), so an offset past this ceiling is
|
|
1142
|
+
/// not a real Windows exe and proves nothing about the subsystem —
|
|
1143
|
+
/// exactly like non-PE bytes.
|
|
1144
|
+
const max_pe_header_offset: usize = 1024 * 1024;
|
|
1145
|
+
|
|
1146
|
+
/// The Subsystem field's distance past the PE signature: 24 header
|
|
1147
|
+
/// bytes (signature + COFF), then 68 bytes into the optional header,
|
|
1148
|
+
/// plus the field's own 2 bytes.
|
|
1149
|
+
const pe_subsystem_span: usize = 24 + 70;
|
|
1150
|
+
|
|
1151
|
+
/// `peSubsystem` over a file, reading ONLY the headers: the DOS header
|
|
1152
|
+
/// names where the PE header starts (`e_lfanew` at 0x3c), and the
|
|
1153
|
+
/// Subsystem field sits a fixed `pe_subsystem_span` past that — so
|
|
1154
|
+
/// `min(file size, e_lfanew + span)` bytes bound the read no matter how
|
|
1155
|
+
/// large the executable is. The whole-file slurp this replaces
|
|
1156
|
+
/// (`readPath`, capped at 128 MiB) allocated the entire binary to read
|
|
1157
|
+
/// 2 bytes and silently skipped exes over its cap.
|
|
1158
|
+
fn peSubsystemAtPath(allocator: std.mem.Allocator, io: std.Io, path: []const u8) !?u16 {
|
|
1159
|
+
var file = try std.Io.Dir.cwd().openFile(io, path, .{});
|
|
1160
|
+
defer file.close(io);
|
|
1161
|
+
var read_buffer: [4096]u8 = undefined;
|
|
1162
|
+
var reader = file.reader(io, &read_buffer);
|
|
1163
|
+
var dos_header: [0x40]u8 = undefined;
|
|
1164
|
+
if (try reader.interface.readSliceShort(&dos_header) < dos_header.len) return null;
|
|
1165
|
+
if (dos_header[0] != 'M' or dos_header[1] != 'Z') return null;
|
|
1166
|
+
const pe_offset: usize = std.mem.readInt(u32, dos_header[0x3c..0x40], .little);
|
|
1167
|
+
if (pe_offset > max_pe_header_offset) return null;
|
|
1168
|
+
const bytes = try allocator.alloc(u8, pe_offset + pe_subsystem_span);
|
|
1169
|
+
defer allocator.free(bytes);
|
|
1170
|
+
@memcpy(bytes[0..dos_header.len], &dos_header);
|
|
1171
|
+
const rest = try reader.interface.readSliceShort(bytes[dos_header.len..]);
|
|
1172
|
+
return peSubsystem(bytes[0 .. dos_header.len + rest]);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
/// The posture check's verdict over a file: only a parsed Subsystem of
|
|
1176
|
+
/// GUI (2) or console (3) earns a named claim; everything else — a file
|
|
1177
|
+
/// the parse proves non-PE or headerless, an unreadable file, or a
|
|
1178
|
+
/// declared subsystem this check does not model (native, EFI, ...) —
|
|
1179
|
+
/// is honestly `unknown`. OutOfMemory still propagates: an allocation
|
|
1180
|
+
/// failure says nothing about the exe.
|
|
1181
|
+
fn peSubsystemVerdictAtPath(allocator: std.mem.Allocator, io: std.Io, path: []const u8) !WindowsSubsystem {
|
|
1182
|
+
const subsystem = peSubsystemAtPath(allocator, io, path) catch |err| switch (err) {
|
|
1183
|
+
error.OutOfMemory => return err,
|
|
1184
|
+
else => return .unknown,
|
|
1185
|
+
};
|
|
1186
|
+
return switch (subsystem orelse return .unknown) {
|
|
1187
|
+
pe_subsystem_gui => .gui,
|
|
1188
|
+
pe_subsystem_console => .console,
|
|
1189
|
+
else => .unknown,
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1065
1193
|
/// Whether a Linux executable carries the embedded web layer: the GTK
|
|
1066
1194
|
/// host links webkitgtk-6.0 directly, so the honest evidence is a
|
|
1067
1195
|
/// libwebkitgtk/libjavascriptcoregtk DT_NEEDED entry or a webkit_*/jsc_*
|
|
@@ -1177,11 +1305,13 @@ fn readPath(allocator: std.mem.Allocator, io: std.Io, path: []const u8) ![]u8 {
|
|
|
1177
1305
|
return reader.interface.allocRemaining(allocator, .limited(128 * 1024 * 1024));
|
|
1178
1306
|
}
|
|
1179
1307
|
|
|
1180
|
-
fn writeReport(allocator: std.mem.Allocator, dir: std.Io.Dir, io: std.Io, subpath: []const u8, options: PackageOptions, executable_name: []const u8, asset_count: usize) !void {
|
|
1308
|
+
fn writeReport(allocator: std.mem.Allocator, dir: std.Io.Dir, io: std.Io, subpath: []const u8, options: PackageOptions, executable_name: []const u8, asset_count: usize, windows_subsystem: ?WindowsSubsystem) !void {
|
|
1181
1309
|
const capabilities = try capabilityLines(allocator, options.metadata.capabilities);
|
|
1182
1310
|
defer allocator.free(capabilities);
|
|
1183
1311
|
const frontend = try frontendLines(allocator, options.frontend);
|
|
1184
1312
|
defer allocator.free(frontend);
|
|
1313
|
+
const subsystem = try subsystemLine(allocator, windows_subsystem);
|
|
1314
|
+
defer allocator.free(subsystem);
|
|
1185
1315
|
const artifact = try zonStringAlloc(allocator, std.fs.path.basename(options.output_path));
|
|
1186
1316
|
defer allocator.free(artifact);
|
|
1187
1317
|
const target = try zonStringAlloc(allocator, @tagName(options.target));
|
|
@@ -1218,7 +1348,7 @@ fn writeReport(allocator: std.mem.Allocator, dir: std.Io.Dir, io: std.Io, subpat
|
|
|
1218
1348
|
\\ .web_engine = {s},
|
|
1219
1349
|
\\ .web_layer = {s},
|
|
1220
1350
|
\\ .signing = {s},
|
|
1221
|
-
\\ .asset_count = {d},
|
|
1351
|
+
\\{s} .asset_count = {d},
|
|
1222
1352
|
\\{s}
|
|
1223
1353
|
\\ .capabilities = .{{
|
|
1224
1354
|
\\{s}
|
|
@@ -1235,6 +1365,7 @@ fn writeReport(allocator: std.mem.Allocator, dir: std.Io.Dir, io: std.Io, subpat
|
|
|
1235
1365
|
web_engine,
|
|
1236
1366
|
web_layer,
|
|
1237
1367
|
signing,
|
|
1368
|
+
subsystem,
|
|
1238
1369
|
asset_count,
|
|
1239
1370
|
frontend,
|
|
1240
1371
|
capabilities,
|
|
@@ -1256,6 +1387,18 @@ fn capabilityLines(allocator: std.mem.Allocator, capabilities: []const []const u
|
|
|
1256
1387
|
return out.toOwnedSlice(allocator);
|
|
1257
1388
|
}
|
|
1258
1389
|
|
|
1390
|
+
/// The report's subsystem-verdict line, present only when the posture
|
|
1391
|
+
/// check actually ran (a Windows package with a binary to probe): the
|
|
1392
|
+
/// durable twin of the transient warning[package.console-subsystem],
|
|
1393
|
+
/// in the same string style the report's other verdicts use.
|
|
1394
|
+
fn subsystemLine(allocator: std.mem.Allocator, windows_subsystem: ?WindowsSubsystem) ![]const u8 {
|
|
1395
|
+
const subsystem = windows_subsystem orelse return allocator.dupe(u8, "");
|
|
1396
|
+
return std.fmt.allocPrint(allocator,
|
|
1397
|
+
\\ .subsystem = "{s}",
|
|
1398
|
+
\\
|
|
1399
|
+
, .{@tagName(subsystem)});
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1259
1402
|
fn frontendLines(allocator: std.mem.Allocator, frontend: ?manifest_tool.FrontendMetadata) ![]const u8 {
|
|
1260
1403
|
if (frontend) |config| {
|
|
1261
1404
|
const dist = try zonStringAlloc(allocator, config.dist);
|
|
@@ -1359,33 +1502,65 @@ fn copyTree(allocator: std.mem.Allocator, io: std.Io, source_path: []const u8, d
|
|
|
1359
1502
|
/// the signature on the bundle is the proof it happened — and only a
|
|
1360
1503
|
/// FAILED signing rewrites it, which is safe because a failed codesign
|
|
1361
1504
|
/// leaves the bundle without a seal to break.
|
|
1362
|
-
|
|
1505
|
+
/// Returns true when the bundle was signed AND the signature verified —
|
|
1506
|
+
/// the value the report's "signed, verified" line states. A signing mode
|
|
1507
|
+
/// that claims to sign (adhoc or identity) either delivers a verified
|
|
1508
|
+
/// signature or fails the whole package with codesign's own reason:
|
|
1509
|
+
/// exiting 0 while shipping an unsigned bundle is the release-breaking
|
|
1510
|
+
/// failure this pipeline exists to prevent.
|
|
1511
|
+
fn runSigning(allocator: std.mem.Allocator, io: std.Io, dir: std.Io.Dir, options: PackageOptions) !bool {
|
|
1363
1512
|
const plan_path = "Contents/Resources/signing-plan.txt";
|
|
1364
1513
|
switch (options.signing.mode) {
|
|
1365
|
-
.none =>
|
|
1514
|
+
.none => {
|
|
1515
|
+
try writeFile(dir, io, plan_path, "signing=none\nunsigned local package\n");
|
|
1516
|
+
return false;
|
|
1517
|
+
},
|
|
1366
1518
|
.adhoc => {
|
|
1367
1519
|
try writeFile(dir, io, plan_path, "signing=adhoc\nad-hoc signed\n");
|
|
1368
|
-
const result = codesign.signAdHoc(io, options.output_path)
|
|
1520
|
+
const result = try codesign.signAdHoc(allocator, io, options.output_path);
|
|
1521
|
+
defer allocator.free(result.message);
|
|
1522
|
+
if (!result.ok) {
|
|
1369
1523
|
try writeFile(dir, io, plan_path, "signing=adhoc\ncodesign --sign - failed; bundle is unsigned\n");
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1524
|
+
std.debug.print("error: ad-hoc code signing failed for {s}, so this package would ship unsigned - codesign said:\n{s}\n fix what codesign reports above, or package with `--signing none` if an unsigned bundle is what you want\n", .{ options.output_path, trimmedToolOutput(result.message) });
|
|
1525
|
+
return error.SigningFailed;
|
|
1526
|
+
}
|
|
1373
1527
|
},
|
|
1374
1528
|
.identity => {
|
|
1375
1529
|
const identity = options.signing.identity orelse {
|
|
1376
1530
|
try writeFile(dir, io, plan_path, "signing=identity\nno identity provided; bundle is unsigned\n");
|
|
1377
|
-
|
|
1531
|
+
std.debug.print("error: --signing identity needs the identity to sign with, so this package would ship unsigned - pass --identity \"Developer ID Application: Your Name (TEAMID)\"\n `security find-identity -v -p codesigning` lists the identities this machine can sign with\n", .{});
|
|
1532
|
+
return error.SigningFailed;
|
|
1378
1533
|
};
|
|
1379
1534
|
const plan_text = try std.fmt.allocPrint(allocator, "signing=identity\nsigned with {s}\n", .{identity});
|
|
1380
1535
|
defer allocator.free(plan_text);
|
|
1381
1536
|
try writeFile(dir, io, plan_path, plan_text);
|
|
1382
|
-
const result = codesign.signIdentity(io, options.output_path, identity, options.signing.entitlements)
|
|
1537
|
+
const result = try codesign.signIdentity(allocator, io, options.output_path, identity, options.signing.entitlements);
|
|
1538
|
+
defer allocator.free(result.message);
|
|
1539
|
+
if (!result.ok) {
|
|
1383
1540
|
try writeFile(dir, io, plan_path, "signing=identity\ncodesign failed; bundle is unsigned\n");
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1541
|
+
std.debug.print("error: code signing with \"{s}\" failed for {s}, so this package would ship unsigned - codesign said:\n{s}\n `security find-identity -v -p codesigning` lists the identities this machine can sign with\n", .{ identity, options.output_path, trimmedToolOutput(result.message) });
|
|
1542
|
+
return error.SigningFailed;
|
|
1543
|
+
}
|
|
1387
1544
|
},
|
|
1388
1545
|
}
|
|
1546
|
+
// The signature just applied must actually hold — the same strict
|
|
1547
|
+
// deep check an Apple silicon launch effectively runs. A bundle that
|
|
1548
|
+
// signs but does not verify (a stale seal, unsigned nested code) is
|
|
1549
|
+
// a packaging failure, not a report footnote.
|
|
1550
|
+
const verified = try codesign.verify(allocator, io, options.output_path);
|
|
1551
|
+
defer allocator.free(verified.message);
|
|
1552
|
+
if (!verified.ok) {
|
|
1553
|
+
std.debug.print("error: {s} was signed but failed `codesign --verify --deep --strict`, so it would be rejected at launch - codesign said:\n{s}\n fix what codesign reports above and rerun `native package`\n", .{ options.output_path, trimmedToolOutput(verified.message) });
|
|
1554
|
+
return error.SignatureVerificationFailed;
|
|
1555
|
+
}
|
|
1556
|
+
return true;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
/// codesign's output, trimmed of trailing newlines so the teaching
|
|
1560
|
+
/// message's fix line lands directly under it (the output itself stays
|
|
1561
|
+
/// verbatim).
|
|
1562
|
+
fn trimmedToolOutput(output: []const u8) []const u8 {
|
|
1563
|
+
return std.mem.trimEnd(u8, output, "\r\n");
|
|
1389
1564
|
}
|
|
1390
1565
|
|
|
1391
1566
|
fn hasRegistrationMetadata(metadata: manifest_tool.Metadata) bool {
|
|
@@ -2328,13 +2503,86 @@ test "package report records target signing and assets" {
|
|
|
2328
2503
|
.target = .linux,
|
|
2329
2504
|
.output_path = ".zig-cache/test-package-report",
|
|
2330
2505
|
.signing = .{ .mode = .none },
|
|
2331
|
-
}, "demo", 2);
|
|
2506
|
+
}, "demo", 2, null);
|
|
2332
2507
|
var buffer: [512]u8 = undefined;
|
|
2333
2508
|
var file = try dir.openFile(std.testing.io, "package-manifest.zon", .{});
|
|
2334
2509
|
defer file.close(std.testing.io);
|
|
2335
2510
|
const len = try file.readPositionalAll(std.testing.io, &buffer, 0);
|
|
2336
2511
|
try std.testing.expect(std.mem.indexOf(u8, buffer[0..len], ".target = \"linux\"") != null);
|
|
2337
2512
|
try std.testing.expect(std.mem.indexOf(u8, buffer[0..len], ".asset_count = 2") != null);
|
|
2513
|
+
// No subsystem check ran, so the report makes no subsystem claim.
|
|
2514
|
+
try std.testing.expect(std.mem.indexOf(u8, buffer[0..len], ".subsystem") == null);
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
test "adhoc packaging into a spaced output path signs and verifies" {
|
|
2518
|
+
// The reported release-breaker: `--output "<path with spaces>.app"`
|
|
2519
|
+
// packaged, exited 0, and shipped an UNSIGNED bundle because the
|
|
2520
|
+
// codesign command was a shell string the spaces split apart. The
|
|
2521
|
+
// pipeline now execs argv arrays, so the spaced path must sign — and
|
|
2522
|
+
// the strict deep verify (real codesign, darwin hosts only) is the
|
|
2523
|
+
// proof.
|
|
2524
|
+
if (@import("builtin").os.tag != .macos) return error.SkipZigTest;
|
|
2525
|
+
const gpa = std.testing.allocator;
|
|
2526
|
+
var cwd = std.Io.Dir.cwd();
|
|
2527
|
+
const root = ".zig-cache/test-package signed spaced";
|
|
2528
|
+
try cwd.deleteTree(std.testing.io, root);
|
|
2529
|
+
defer cwd.deleteTree(std.testing.io, root) catch {};
|
|
2530
|
+
try cwd.createDirPath(std.testing.io, root ++ "/assets");
|
|
2531
|
+
|
|
2532
|
+
const metadata: manifest_tool.Metadata = .{ .id = "dev.example.spaced-sign", .name = "spaced-demo", .version = "1.0.0" };
|
|
2533
|
+
const app_path = root ++ "/My Spaced Demo.app";
|
|
2534
|
+
const stats = try createMacosApp(gpa, std.testing.io, .{
|
|
2535
|
+
.metadata = metadata,
|
|
2536
|
+
.output_path = app_path,
|
|
2537
|
+
// A real Mach-O executable, so codesign has honest code to sign.
|
|
2538
|
+
.binary_path = "/bin/ls",
|
|
2539
|
+
.assets_dir = root ++ "/assets",
|
|
2540
|
+
.signing = .{ .mode = .adhoc },
|
|
2541
|
+
});
|
|
2542
|
+
try std.testing.expectEqual(SigningMode.adhoc, stats.signing_mode);
|
|
2543
|
+
try std.testing.expect(stats.signing_verified);
|
|
2544
|
+
|
|
2545
|
+
// Pin the claim with an independent codesign run, not just the flag.
|
|
2546
|
+
const verified = try codesign.verify(gpa, std.testing.io, app_path);
|
|
2547
|
+
defer gpa.free(verified.message);
|
|
2548
|
+
try std.testing.expect(verified.ok);
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
test "a codesign failure fails packaging instead of shipping unsigned" {
|
|
2552
|
+
// An identity codesign cannot resolve exits nonzero; packaging must
|
|
2553
|
+
// surface that as an error (with codesign's reason printed), never
|
|
2554
|
+
// as a created artifact. Real codesign run: darwin hosts only.
|
|
2555
|
+
if (@import("builtin").os.tag != .macos) return error.SkipZigTest;
|
|
2556
|
+
var cwd = std.Io.Dir.cwd();
|
|
2557
|
+
const root = ".zig-cache/test-package-signing-failure";
|
|
2558
|
+
try cwd.deleteTree(std.testing.io, root);
|
|
2559
|
+
defer cwd.deleteTree(std.testing.io, root) catch {};
|
|
2560
|
+
try cwd.createDirPath(std.testing.io, root ++ "/assets");
|
|
2561
|
+
|
|
2562
|
+
const metadata: manifest_tool.Metadata = .{ .id = "dev.example.sign-fail", .name = "sign-fail-demo", .version = "1.0.0" };
|
|
2563
|
+
try std.testing.expectError(error.SigningFailed, createMacosApp(std.testing.allocator, std.testing.io, .{
|
|
2564
|
+
.metadata = metadata,
|
|
2565
|
+
.output_path = root ++ "/Sign Fail Demo.app",
|
|
2566
|
+
.binary_path = "/bin/ls",
|
|
2567
|
+
.assets_dir = root ++ "/assets",
|
|
2568
|
+
.signing = .{ .mode = .identity, .identity = "native-sdk-no-such-identity" },
|
|
2569
|
+
}));
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
test "identity signing without an identity is a loud failure, not a silent unsigned bundle" {
|
|
2573
|
+
var cwd = std.Io.Dir.cwd();
|
|
2574
|
+
const root = ".zig-cache/test-package-signing-no-identity";
|
|
2575
|
+
try cwd.deleteTree(std.testing.io, root);
|
|
2576
|
+
defer cwd.deleteTree(std.testing.io, root) catch {};
|
|
2577
|
+
try cwd.createDirPath(std.testing.io, root ++ "/assets");
|
|
2578
|
+
|
|
2579
|
+
const metadata: manifest_tool.Metadata = .{ .id = "dev.example.no-identity", .name = "no-identity-demo", .version = "1.0.0" };
|
|
2580
|
+
try std.testing.expectError(error.SigningFailed, createMacosApp(std.testing.allocator, std.testing.io, .{
|
|
2581
|
+
.metadata = metadata,
|
|
2582
|
+
.output_path = root ++ "/NoIdentity.app",
|
|
2583
|
+
.assets_dir = root ++ "/assets",
|
|
2584
|
+
.signing = .{ .mode = .identity },
|
|
2585
|
+
}));
|
|
2338
2586
|
}
|
|
2339
2587
|
|
|
2340
2588
|
test "native-only windows package ships no WebView2 loader and reports web layer none" {
|
|
@@ -2402,10 +2650,13 @@ test "webview-declaring package reports the web layer as declared" {
|
|
|
2402
2650
|
});
|
|
2403
2651
|
try std.testing.expect(stats.web_layer.?.enabled);
|
|
2404
2652
|
try std.testing.expectEqual(manifest_tool.WebLayerReason.capability, stats.web_layer.?.reason);
|
|
2653
|
+
// No binary means the subsystem check never ran: no verdict to carry.
|
|
2654
|
+
try std.testing.expectEqual(@as(?WindowsSubsystem, null), stats.windows_subsystem);
|
|
2405
2655
|
|
|
2406
2656
|
const report = try readPath(std.testing.allocator, std.testing.io, root ++ "/demo-windows/package-manifest.zon");
|
|
2407
2657
|
defer std.testing.allocator.free(report);
|
|
2408
2658
|
try std.testing.expect(std.mem.indexOf(u8, report, ".web_layer = \"webview2 (declared: capabilities)\"") != null);
|
|
2659
|
+
try std.testing.expect(std.mem.indexOf(u8, report, ".subsystem") == null);
|
|
2409
2660
|
}
|
|
2410
2661
|
|
|
2411
2662
|
test "package refuses a manifest that excludes the web layer while declaring web content" {
|
|
@@ -2487,6 +2738,170 @@ fn testWebLayerPeBytes() [0x80 + "WebView2Loader.dll".len * 2]u8 {
|
|
|
2487
2738
|
return bytes;
|
|
2488
2739
|
}
|
|
2489
2740
|
|
|
2741
|
+
/// A minimal Windows executable with a real optional header for the
|
|
2742
|
+
/// subsystem tests: MZ + PE + a COFF header declaring a 240-byte
|
|
2743
|
+
/// optional header, with the Subsystem field set as asked.
|
|
2744
|
+
fn testSubsystemPeBytes(subsystem: u16) [0x200]u8 {
|
|
2745
|
+
var bytes = [_]u8{0} ** 0x200;
|
|
2746
|
+
bytes[0] = 'M';
|
|
2747
|
+
bytes[1] = 'Z';
|
|
2748
|
+
std.mem.writeInt(u32, bytes[0x3c..0x40], 0x40, .little);
|
|
2749
|
+
bytes[0x40] = 'P';
|
|
2750
|
+
bytes[0x41] = 'E';
|
|
2751
|
+
// COFF SizeOfOptionalHeader (PE32+ is 240 bytes).
|
|
2752
|
+
std.mem.writeInt(u16, bytes[0x54..0x56], 240, .little);
|
|
2753
|
+
// Optional header starts at 0x58; Subsystem sits 68 bytes in.
|
|
2754
|
+
std.mem.writeInt(u16, bytes[0x9c..0x9e], subsystem, .little);
|
|
2755
|
+
return bytes;
|
|
2756
|
+
}
|
|
2757
|
+
|
|
2758
|
+
test "peSubsystem reads the optional header and refuses non-PE bytes" {
|
|
2759
|
+
const gui = testSubsystemPeBytes(2);
|
|
2760
|
+
try std.testing.expectEqual(@as(?u16, 2), peSubsystem(&gui));
|
|
2761
|
+
const console = testSubsystemPeBytes(3);
|
|
2762
|
+
try std.testing.expectEqual(@as(?u16, 3), peSubsystem(&console));
|
|
2763
|
+
// The loader-scan fixture has no optional header: no subsystem claim.
|
|
2764
|
+
const headerless = testWebLayerPeBytes();
|
|
2765
|
+
try std.testing.expectEqual(@as(?u16, null), peSubsystem(&headerless));
|
|
2766
|
+
try std.testing.expectEqual(@as(?u16, null), peSubsystem("not a pe"));
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
test "the subsystem probe reads only the headers, so an exe past the old slurp cap still warns" {
|
|
2770
|
+
// A console-subsystem exe stretched past readPath's 128 MiB cap
|
|
2771
|
+
// (sparse: valid headers, then a hole). The whole-file slurp this
|
|
2772
|
+
// probe replaced hit the cap's StreamTooLong, swallowed it as
|
|
2773
|
+
// false, and packaged the exe WITHOUT the promised console warning
|
|
2774
|
+
// — the bounded header read answers from the first 94-ish bytes and
|
|
2775
|
+
// never sees the far end of the file.
|
|
2776
|
+
var cwd = std.Io.Dir.cwd();
|
|
2777
|
+
const root = ".zig-cache/test-package-subsystem-huge";
|
|
2778
|
+
try cwd.deleteTree(std.testing.io, root);
|
|
2779
|
+
defer cwd.deleteTree(std.testing.io, root) catch {};
|
|
2780
|
+
try cwd.createDirPath(std.testing.io, root);
|
|
2781
|
+
const console_bytes = testSubsystemPeBytes(3);
|
|
2782
|
+
const path = root ++ "/huge-console.exe";
|
|
2783
|
+
try cwd.writeFile(std.testing.io, .{ .sub_path = path, .data = &console_bytes });
|
|
2784
|
+
{
|
|
2785
|
+
var file = try cwd.openFile(std.testing.io, path, .{ .mode = .read_write });
|
|
2786
|
+
defer file.close(std.testing.io);
|
|
2787
|
+
try file.setLength(std.testing.io, 128 * 1024 * 1024 + 4096);
|
|
2788
|
+
}
|
|
2789
|
+
try std.testing.expectEqual(WindowsSubsystem.console, try peSubsystemVerdictAtPath(std.testing.allocator, std.testing.io, path));
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
test "a PE offset past the header ceiling proves nothing and allocates nothing" {
|
|
2793
|
+
// An `e_lfanew` claiming the PE header sits 8 MiB into the file is
|
|
2794
|
+
// not a real Windows exe (linkers put it right after the DOS stub):
|
|
2795
|
+
// the probe answers null before sizing any buffer to the claimed
|
|
2796
|
+
// offset — the failing allocator turns any allocation into a test
|
|
2797
|
+
// failure — and packaging treats it like non-PE bytes: an unknown
|
|
2798
|
+
// verdict, no warning, and never a gui claim.
|
|
2799
|
+
var cwd = std.Io.Dir.cwd();
|
|
2800
|
+
const root = ".zig-cache/test-package-subsystem-offset";
|
|
2801
|
+
try cwd.deleteTree(std.testing.io, root);
|
|
2802
|
+
defer cwd.deleteTree(std.testing.io, root) catch {};
|
|
2803
|
+
try cwd.createDirPath(std.testing.io, root);
|
|
2804
|
+
var bytes = [_]u8{0} ** 0x40;
|
|
2805
|
+
bytes[0] = 'M';
|
|
2806
|
+
bytes[1] = 'Z';
|
|
2807
|
+
std.mem.writeInt(u32, bytes[0x3c..0x40], 8 * 1024 * 1024, .little);
|
|
2808
|
+
const path = root ++ "/bogus-offset.exe";
|
|
2809
|
+
try cwd.writeFile(std.testing.io, .{ .sub_path = path, .data = &bytes });
|
|
2810
|
+
try std.testing.expectEqual(WindowsSubsystem.unknown, try peSubsystemVerdictAtPath(std.testing.failing_allocator, std.testing.io, path));
|
|
2811
|
+
}
|
|
2812
|
+
|
|
2813
|
+
test "windows package pins the exe's subsystem: GUI is quiet, console warns in the stats" {
|
|
2814
|
+
var cwd = std.Io.Dir.cwd();
|
|
2815
|
+
const root = ".zig-cache/test-package-subsystem";
|
|
2816
|
+
try cwd.deleteTree(std.testing.io, root);
|
|
2817
|
+
defer cwd.deleteTree(std.testing.io, root) catch {};
|
|
2818
|
+
try cwd.createDirPath(std.testing.io, root ++ "/assets");
|
|
2819
|
+
const metadata: manifest_tool.Metadata = .{
|
|
2820
|
+
.id = "dev.example.subsystem",
|
|
2821
|
+
.name = "subsystem-demo",
|
|
2822
|
+
.version = "1.0.0",
|
|
2823
|
+
};
|
|
2824
|
+
|
|
2825
|
+
// The exe `native build` installs: GUI subsystem, no console flash —
|
|
2826
|
+
// the package carries no console finding.
|
|
2827
|
+
const gui_bytes = testSubsystemPeBytes(2);
|
|
2828
|
+
try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/gui.exe", .data = &gui_bytes });
|
|
2829
|
+
const gui_stats = try createPackage(std.testing.allocator, std.testing.io, .{
|
|
2830
|
+
.metadata = metadata,
|
|
2831
|
+
.target = .windows,
|
|
2832
|
+
.output_path = root ++ "/gui-package",
|
|
2833
|
+
.binary_path = root ++ "/gui.exe",
|
|
2834
|
+
.assets_dir = root ++ "/assets",
|
|
2835
|
+
});
|
|
2836
|
+
try std.testing.expectEqual(@as(?WindowsSubsystem, .gui), gui_stats.windows_subsystem);
|
|
2837
|
+
const gui_report = try readPath(std.testing.allocator, std.testing.io, root ++ "/gui-package/package-manifest.zon");
|
|
2838
|
+
defer std.testing.allocator.free(gui_report);
|
|
2839
|
+
try std.testing.expect(std.mem.indexOf(u8, gui_report, ".subsystem = \"gui\"") != null);
|
|
2840
|
+
|
|
2841
|
+
// A stale or hand-built console-subsystem exe: packaged (the app
|
|
2842
|
+
// still works), but the stats carry the finding the warning teaches.
|
|
2843
|
+
const console_bytes = testSubsystemPeBytes(3);
|
|
2844
|
+
try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/console.exe", .data = &console_bytes });
|
|
2845
|
+
const console_stats = try createPackage(std.testing.allocator, std.testing.io, .{
|
|
2846
|
+
.metadata = metadata,
|
|
2847
|
+
.target = .windows,
|
|
2848
|
+
.output_path = root ++ "/console-package",
|
|
2849
|
+
.binary_path = root ++ "/console.exe",
|
|
2850
|
+
.assets_dir = root ++ "/assets",
|
|
2851
|
+
});
|
|
2852
|
+
try std.testing.expectEqual(@as(?WindowsSubsystem, .console), console_stats.windows_subsystem);
|
|
2853
|
+
const console_report = try readPath(std.testing.allocator, std.testing.io, root ++ "/console-package/package-manifest.zon");
|
|
2854
|
+
defer std.testing.allocator.free(console_report);
|
|
2855
|
+
try std.testing.expect(std.mem.indexOf(u8, console_report, ".subsystem = \"console\"") != null);
|
|
2856
|
+
}
|
|
2857
|
+
|
|
2858
|
+
test "a binary the probe proves nothing about reports subsystem unknown, never gui" {
|
|
2859
|
+
// The parse failing is not evidence of a GUI exe: non-PE bytes and a
|
|
2860
|
+
// PE truncated before its optional header both earn an honest
|
|
2861
|
+
// "unknown" in the stats and report — the old bool verdict folded
|
|
2862
|
+
// these into false and the report affirmatively claimed "gui".
|
|
2863
|
+
var cwd = std.Io.Dir.cwd();
|
|
2864
|
+
const root = ".zig-cache/test-package-subsystem-unknown";
|
|
2865
|
+
try cwd.deleteTree(std.testing.io, root);
|
|
2866
|
+
defer cwd.deleteTree(std.testing.io, root) catch {};
|
|
2867
|
+
try cwd.createDirPath(std.testing.io, root ++ "/assets");
|
|
2868
|
+
const metadata: manifest_tool.Metadata = .{
|
|
2869
|
+
.id = "dev.example.subsystem-unknown",
|
|
2870
|
+
.name = "subsystem-unknown-demo",
|
|
2871
|
+
.version = "1.0.0",
|
|
2872
|
+
};
|
|
2873
|
+
|
|
2874
|
+
try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/not-a-pe.exe", .data = "not a pe at all" });
|
|
2875
|
+
const full_bytes = testSubsystemPeBytes(3);
|
|
2876
|
+
try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/truncated.exe", .data = full_bytes[0..0x50] });
|
|
2877
|
+
const fixtures = [_]struct { binary: []const u8, output: []const u8 }{
|
|
2878
|
+
.{ .binary = root ++ "/not-a-pe.exe", .output = root ++ "/not-a-pe-package" },
|
|
2879
|
+
.{ .binary = root ++ "/truncated.exe", .output = root ++ "/truncated-package" },
|
|
2880
|
+
};
|
|
2881
|
+
for (fixtures) |fixture| {
|
|
2882
|
+
const stats = try createPackage(std.testing.allocator, std.testing.io, .{
|
|
2883
|
+
.metadata = metadata,
|
|
2884
|
+
.target = .windows,
|
|
2885
|
+
.output_path = fixture.output,
|
|
2886
|
+
.binary_path = fixture.binary,
|
|
2887
|
+
.assets_dir = root ++ "/assets",
|
|
2888
|
+
});
|
|
2889
|
+
try std.testing.expectEqual(@as(?WindowsSubsystem, .unknown), stats.windows_subsystem);
|
|
2890
|
+
const report_path = try std.fmt.allocPrint(std.testing.allocator, "{s}/package-manifest.zon", .{fixture.output});
|
|
2891
|
+
defer std.testing.allocator.free(report_path);
|
|
2892
|
+
const report = try readPath(std.testing.allocator, std.testing.io, report_path);
|
|
2893
|
+
defer std.testing.allocator.free(report);
|
|
2894
|
+
try std.testing.expect(std.mem.indexOf(u8, report, ".subsystem = \"unknown\"") != null);
|
|
2895
|
+
try std.testing.expect(std.mem.indexOf(u8, report, ".subsystem = \"gui\"") == null);
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
// A subsystem the check does not model (1 = native) parses fine but
|
|
2899
|
+
// still proves nothing about console-vs-GUI posture.
|
|
2900
|
+
const native_bytes = testSubsystemPeBytes(1);
|
|
2901
|
+
try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/native.exe", .data = &native_bytes });
|
|
2902
|
+
try std.testing.expectEqual(WindowsSubsystem.unknown, try peSubsystemVerdictAtPath(std.testing.allocator, std.testing.io, root ++ "/native.exe"));
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2490
2905
|
test "package --web-layer include on a canvas manifest stages the loader and names the flag" {
|
|
2491
2906
|
var cwd = std.Io.Dir.cwd();
|
|
2492
2907
|
const root = ".zig-cache/test-package-web-layer-include-flag";
|
|
@@ -14,9 +14,11 @@ pub const RawManifest = struct {
|
|
|
14
14
|
web_engine: []const u8 = @tagName(web_engine.default_engine),
|
|
15
15
|
webview_layer: []const u8 = "auto",
|
|
16
16
|
theme: ?[]const u8 = null,
|
|
17
|
+
theme_accent: ?[]const u8 = null,
|
|
17
18
|
cef: RawCef = .{},
|
|
18
19
|
frontend: ?RawFrontend = null,
|
|
19
20
|
security: RawSecurity = .{},
|
|
21
|
+
assets: RawAssets = .{},
|
|
20
22
|
windows: []const RawWindow = &.{},
|
|
21
23
|
shell: RawShell = .{},
|
|
22
24
|
commands: []const RawCommand = &.{},
|
|
@@ -59,6 +61,19 @@ pub const RawSecurity = struct {
|
|
|
59
61
|
navigation: RawNavigation = .{},
|
|
60
62
|
};
|
|
61
63
|
|
|
64
|
+
/// Launch-registered assets (the TypeScript-core wiring's image channel):
|
|
65
|
+
/// each image is read once at launch and registered on the installing
|
|
66
|
+
/// frame under its declared `ImageId` — the id markup avatar bindings
|
|
67
|
+
/// reference.
|
|
68
|
+
pub const RawAssets = struct {
|
|
69
|
+
images: []const RawImageAsset = &.{},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
pub const RawImageAsset = struct {
|
|
73
|
+
id: u64,
|
|
74
|
+
path: []const u8,
|
|
75
|
+
};
|
|
76
|
+
|
|
62
77
|
pub const RawNavigation = struct {
|
|
63
78
|
allowed_origins: []const []const u8 = &.{},
|
|
64
79
|
external_links: RawExternalLinks = .{},
|
package/src/tooling/root.zig
CHANGED
|
@@ -14,6 +14,7 @@ pub const embedlib = @import("embedlib.zig");
|
|
|
14
14
|
pub const eject_components = @import("eject_components.zig");
|
|
15
15
|
pub const toolchain = @import("toolchain.zig");
|
|
16
16
|
pub const verbs = @import("verbs.zig");
|
|
17
|
+
pub const ts_core = @import("ts_core.zig");
|
|
17
18
|
pub const ios = @import("ios.zig");
|
|
18
19
|
pub const android = @import("android.zig");
|
|
19
20
|
pub const xcodeproj = @import("xcodeproj.zig");
|