Repository navigation
Expand file tree
/
Copy pathBuild.sh
More file actions
executable file
·518 lines (498 loc) · 19.3 KB
/
Copy pathBuild.sh
File metadata and controls
executable file
·518 lines (498 loc) · 19.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
#!/usr/bin/env sh
#===============================================================================
# Debug/Build.sh - Debug Build Script with Profile Support
#===============================================================================
#
# This script runs the debug build with configurable profiles.
# It reads configuration from .vscode/land-config.json.
#
# Usage:
# sh Maintain/Debug/Build.sh # Default debug profile
# sh Maintain/Debug/Build.sh --profile mountain # Debug with Mountain workbench
# sh Maintain/Debug/Build.sh --profile electron # Debug with Electron workbench
#
# Available profiles:
# debug - Default Browser workbench (70-80% features)
# debug-mountain - Mountain workbench (80-90% features) [RECOMMENDED]
# debug-electron - Electron workbench (95%+ features)
# debug-electron-rest - Electron workbench + Rest OXC compiler (fastest TS)
# debug-electron-minimal - Electron without built-in extensions (Atom J1)
# debug-mountain-only - Mountain without Cocoon subprocess (Atom N3)
# debug-electron-compiled - Electron + resources embedded in single binary
# (Compile=true on a debug build). Use when you want
# one-file-deploy parity with production while
# keeping debug asserts, dev-log tags and symbols.
# Removes the Mountain `set_static_application_root`
# dev-only fallback: Sky assets are shipped inside
# the binary bundle, so `file:read` on
# `/Static/Application/**` lands on the embedded
# resource table rather than a host file path.
# debug-mountain-compiled - Same embedded-resources layout on the Mountain
# workbench. Chosen when you want the slim
# Mountain workbench plus single-binary deploy.
# debug-electron-bundled - Electron workbench compiled through Vite/Astro.
# Sky reads Pack, fed Rollup
# receives the workbench module as an entry,
# CSS goes through Vite's native pipeline. Output
# under Sky/Target/Static/Bundled/Electron/.
# /Static/Application/ tree still produced.
# debug-browser-bundled - Browser workbench compiled through Vite/Astro.
# debug-sessions-bundled - Sessions workbench compiled through Vite/Astro.
# debug-workbench-bundled - Base workbench compiled through Vite/Astro.
# debug-bundled-all - All four workbenches bundled in one Rollup pass.
#
#===============================================================================
set -e
PROFILE="debug"
FLAVOR=""
while [ $# -gt 0 ]; do
case $1 in
--profile | -p)
PROFILE="$2"
shift 2
;;
--flavor | -f)
FLAVOR="$2"
shift 2
;;
--help | -h)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --profile, -p <name> Build profile to use (default: debug)"
echo " --help, -h Show this help message"
echo ""
echo "Available profiles:"
echo " debug - Browser workbench (70-80% features)"
echo " debug-mountain - Mountain workbench (80-90% features) [RECOMMENDED]"
echo " debug-electron - Electron workbench (95%+ features)"
echo " debug-electron-rest - Electron + Rest OXC compiler (fastest TS)"
echo " debug-electron-minimal - Electron without built-in extensions (Atom J1)"
echo " debug-mountain-only - Mountain without Cocoon subprocess (Atom N3)"
echo " debug-cocoon-headless - Mountain + Cocoon, Wind preload disabled (Atom N3b)"
echo " debug-kernel - Pure Mountain: no built-ins, no Cocoon, no Wind (Atom N3c)"
echo " debug-electron-compiled - Electron + single-binary embedded resources (debug symbols + Compile=true)"
echo " debug-mountain-compiled - Mountain + single-binary embedded resources (debug symbols + Compile=true)"
echo " debug-electron-bundled - Electron workbench compiled through Vite/Astro"
echo " debug-browser-bundled - Browser workbench compiled through Vite/Astro"
echo " debug-sessions-bundled - Sessions workbench compiled through Vite/Astro"
echo " debug-workbench-bundled - Base workbench compiled through Vite/Astro"
echo " debug-bundled-all - All four workbenches bundled in one Rollup pass"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
echo "========================================"
echo "Land Debug Build"
echo "========================================"
echo "Profile: $PROFILE"
if [ -n "$FLAVOR" ]; then
echo "Flavor: $FLAVOR"
fi
echo "========================================"
# Flavor overlay: source `.env.Land.<flavor>` BEFORE TierEnvironment.sh so
# per-subsystem Tier* values are exported into the shell environment that
# the rest of the build sees (Mountain's build.rs reads via env::var first,
# falling back to the file). Valid flavors: RustOnly, NodeFirst, Full.
if [ -n "$FLAVOR" ]; then
FLAVOR_FILE=".env.Land.$FLAVOR"
if [ ! -f "$FLAVOR_FILE" ]; then
echo "Unknown flavor: $FLAVOR (no such file: $FLAVOR_FILE)"
echo "Available flavors: RustOnly, NodeFirst, Full"
exit 1
fi
echo "Sourcing flavor overlay: $FLAVOR_FILE"
set -a
# shellcheck disable=SC1090
. "./$FLAVOR_FILE"
set +a
fi
# Tier-gating fan-out (Plan A Wave 1.5) - shared helper.
# shellcheck disable=SC1091
. Maintain/Script/TierEnvironment.sh
# Telemetry fan-out: dual PostHog + OTLP emit. Honors `Disable=true` as a
# master kill switch, otherwise reads `.env.Land.PostHog`. The helpers
# defined here (LandCapture / LandCapturePhaseBegin / LandCapturePhaseEnd)
# stay in scope for every step below, including the trailing
# `Maintain -- pnpm tauri build --debug` invocation.
# shellcheck disable=SC1091
. Maintain/Script/PostHogCapture.sh
# Mark the build start. Each downstream phase (route manifest, profile
# marker, clean, tauri build) wraps its body with PhaseBegin / PhaseEnd
# so dashboards see per-phase duration and the OTLP trace shows a
# parent / child waterfall.
LandCapture "land:build:start" \
"profile" "$PROFILE" \
"trace_filter" "${Trace:-all}" \
"record" "${Record:-0}" \
"capture" "${Capture:-true}"
# Route manifest: scan Mountain Rust tracks + Cocoon StockLift + Node
# Fallbacks, emit a typed TypeScript set the runtime consults to skip
# Mountain RTTs for methods no Rust handler exists for. Also writes a
# human-readable coverage report under Element/Cocoon/Source/Generated/.
# Idempotent - safe to run on every build, fast (<500 ms).
LandCapturePhaseBegin "route-manifest"
# shellcheck disable=SC1091
bash Maintain/Script/GenerateRouteManifest.sh
LandCapturePhaseEnd "route-manifest" "profile" "$PROFILE"
# Product identity fan-out: read Element/Sky/Public/product.json
# (generated by ResolveProductConfig.sh inside TierEnvironment.sh)
# and write typed constants + copies to every Element that needs them.
# Idempotent - safe to run on every build, fast (<1 s).
LandCapturePhaseBegin "resolve-identity"
# shellcheck disable=SC1091
bash Maintain/Script/ResolveIdentity.sh
LandCapturePhaseEnd "resolve-identity"
# ===========================================================================
# TEMP: Rest compiler disabled for every profile - we're testing the Output
# Element consuming VS Code's `out/` (dev) and `out-build/` (prod) directly,
# without the OXC transform layer. `unset` wipes any inherited `Compiler=Rest`
# from the caller's shell; the per-profile `Compiler=Rest` lines below are
# swapped to `Compiler=esbuild` with matching TEMP markers. Restore by
# deleting this block and reverting those two line changes.
# ===========================================================================
unset Compiler
case $PROFILE in
debug)
echo "Using Browser workbench (default debug)"
export Browser=true
export Bundle=false
export Clean=true
export Compile=false
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
;;
debug-mountain)
echo "Using Mountain workbench (RECOMMENDED)"
export Mountain=true
export Bundle=true
export Clean=true
export Compile=false
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
;;
debug-electron)
echo "Using Electron workbench"
export Electron=true
export Bundle=true
export Clean=true
export Compile=false
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
;;
debug-electron-rest)
echo "Using Electron workbench + Rest OXC compiler"
export Electron=true
export Bundle=true
export Clean=true
export Compile=false
# TEMP: Rest compiler disabled (see kill-switch above). Restore with
# `export Compiler=Rest` to re-enable the OXC transform.
export Compiler=esbuild
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
# Build Rest compiler if binary is missing - only needed when the
# Rest path is actually active. With `Compiler=esbuild` this is a
# no-op; gate the cargo build so the temporary kill-switch doesn't
# pay for an unused compiler.
if [ "$Compiler" = "Rest" ] && [ ! -f "Element/Rest/Target/release/Rest" ]; then
echo ""
echo "Building Rest OXC compiler (first time only)..."
cargo build -p Rest --release 2>&1 | tail -5
echo ""
fi
;;
debug-electron-minimal)
# Atom J1: ship without any bundled built-in extensions.
# Sky's astro.config.ts Step 13 and Mountain's Scanner fallback
# paths both observe `Skip=true` and skip
# the copy + scan. Useful when embedding Land inside a host app
# that wants a kernel editor.
echo "Using Electron workbench (minimal - no built-in extensions)"
export Electron=true
export Bundle=true
export Clean=true
export Compile=false
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
export Skip=true
;;
debug-mountain-only)
# Atom N3: Mountain without Cocoon. Extension host is never
# spawned; extension-related IPC calls return the empty-state
# envelope. Useful for integration tests that exercise the
# native layer in isolation.
echo "Using Mountain workbench without Cocoon"
export Mountain=true
export Bundle=true
export Clean=true
export Compile=false
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
export Spawn=false
;;
debug-cocoon-headless)
# Atom N3b: Mountain + Cocoon, but the webview's Wind preload
# is disabled - the workbench loads native VS Code services only.
# Verifies Mountain↔Cocoon works without a Wind consumer; useful
# for isolating regressions in the Effect-TS service layer.
echo "Using Mountain + Cocoon, Wind preload disabled"
export Electron=true
export Bundle=true
export Clean=true
export Compile=false
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
export Render=false
;;
debug-kernel)
# Atom J4b / N3c: smallest viable shippable surface. No built-in
# extensions, no Cocoon, no Wind. Pure Mountain + bare VS Code
# workbench. Use for the lowest-footprint embedded Land binary.
echo "Using Mountain kernel (no built-ins, no Cocoon, no Wind)"
export Electron=true
export Bundle=true
export Clean=true
export Compile=false
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
export Skip=true
export Spawn=false
export Render=false
;;
debug-electron-compiled)
# Debug-symbols-and-tags binary with every Sky/Output asset embedded
# via Tauri's resource table. `Compile=true` flips the three
# downstream pipelines (Wind ESBuild target, Output plugin set,
# Mountain Scheme fallback) into their production-parity layout so
# the running binary serves `/Static/Application/**` from the bundled
# resource map. No `set_static_application_root` fallback is taken.
#
# Matches `release-electron` output shape but preserves:
# Debug=true → debug_assertions on, dev-log sinks wired,
# Level=debug → verbose LandFix + DEV:* tag emission,
# NODE_ENV=development on the JS side for readable source maps.
#
# Use when you need one-file-deploy validation (e.g. verifying
# resource-path resolution outside a dev workspace) without losing
# the debug diagnostic surface.
echo "Using Electron workbench + single-binary embedded resources (debug)"
export Electron=true
export Bundle=true
export Clean=true
export Compile=true
export Compiler=esbuild
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
;;
debug-mountain-compiled)
# Mountain-workbench variant of `debug-electron-compiled`. Same
# embedded-resource layout, lighter workbench surface (~80-90%
# features instead of 95%+). Use for the smallest single-binary
# debug artifact that still ships the full Sky asset tree.
echo "Using Mountain workbench + single-binary embedded resources (debug)"
export Mountain=true
export Bundle=true
export Clean=true
export Compile=true
export Compiler=esbuild
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
;;
debug-electron-bundled)
# Vite/Astro-native bundle of vs/code/electron-browser/workbench/.
# Sky reads Pack, wires the workbench module as a
# Rollup input, and lets Vite handle CSS extraction + chunk dedup.
# Output lands under Sky/Target/Static/Bundled/Electron/. The
# existing /Static/Application/ tree is still produced unchanged so
# both layouts can be benchmarked side-by-side.
echo "Using Electron workbench bundled through Vite/Astro (debug)"
export Electron=true
export Bundle=true
export Clean=true
export Compile=false
export Compiler=esbuild
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
export Pack="electron"
export Boot=true
;;
debug-browser-bundled)
# Vite/Astro-native bundle of vs/code/browser/workbench/.
echo "Using Browser workbench bundled through Vite/Astro (debug)"
export Browser=true
export Bundle=true
export Clean=true
export Compile=false
export Compiler=esbuild
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
export Pack="browser"
export Boot=true
;;
debug-sessions-bundled)
# Vite/Astro-native bundle of vs/sessions/browser/.
echo "Using Sessions workbench bundled through Vite/Astro (debug)"
export Mountain=true
export Bundle=true
export Clean=true
export Compile=false
export Compiler=esbuild
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
export Pack="sessions"
export Boot=true
;;
debug-workbench-bundled)
# Vite/Astro-native bundle of the base vs/workbench module.
echo "Using base workbench bundled through Vite/Astro (debug)"
export Mountain=true
export Bundle=true
export Clean=true
export Compile=false
export Compiler=esbuild
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
export Pack="workbench"
export Boot=true
;;
debug-bundled-all)
# Bundle all four workbench entry shapes in one Rollup pass.
echo "Bundling all four workbenches through Vite/Astro (debug)"
export Electron=true
export Bundle=true
export Clean=true
export Compile=false
export Compiler=esbuild
export Debug=true
export Level=debug
export Dependency=Microsoft/VSCode
export NODE_ENV=development
export NODE_VERSION=24
export NODE_OPTIONS="--max-old-space-size=16384"
export Pack="electron browser sessions workbench"
export Boot=true
;;
*)
echo "Unknown profile: $PROFILE"
echo "Available profiles: debug, debug-mountain, debug-electron, debug-electron-rest, debug-electron-minimal, debug-mountain-only, debug-cocoon-headless, debug-kernel, debug-electron-compiled, debug-mountain-compiled, debug-electron-bundled, debug-browser-bundled, debug-sessions-bundled, debug-workbench-bundled, debug-bundled-all"
exit 1
;;
esac
# Profile-flip Output-cache cleanup - shared helper.
LandCapturePhaseBegin "profile-marker"
# shellcheck disable=SC1091
. Maintain/Script/ProfileMarker.sh
LandCapturePhaseEnd "profile-marker"
# Generated-artefact cleanup. Sourced unconditionally; the helper
# is a no-op when Clean is unset / false. When Clean=true the
# helper wipes:
# - Wind/Source/Effect/Generated/ (Wind codegen)
# - Wind/Source/Effect/<X>BridgeShapeGenerated.ts
# - Cocoon/Source/Generated/ (Cocoon codegen)
# - Sky/Source/Function/Generated/ (Sky channel codegen)
# - Mountain/Source/Vine/Generated/ (tonic-prost output)
# - Mountain/Source/IPC/Generated/
# - Air/Source/Vine/Generated/
# - Grove/Source/Protocol/Generated/
# and bumps the mtime of every `.proto` under `Element/` so
# `cargo:rerun-if-changed=Proto/<X>.proto` triggers each crate's
# build.rs (which re-emits Generated/ via tonic-prost-build).
LandCapturePhaseBegin "clean-generated" "clean" "${Clean:-false}"
# shellcheck disable=SC1091
. Maintain/Script/CleanGenerated.sh
LandCapturePhaseEnd "clean-generated"
# Air daemon sidecar - separate crate with its own Target dir
# (Element/Air/.cargo/config.toml). Built here so SignBundle.sh can copy
# it into the .app Resources and AirStart.rs finds it in dev runs.
# Tolerant: AirStart degrades gracefully without the binary, so an Air
# build failure must not fail the workbench build.
LandCapturePhaseBegin "air-build"
if (cd Element/Air && cargo build 2>&1 | tail -3); then
LandCapturePhaseEnd "air-build" "ok" "true"
else
LandCapturePhaseEnd "air-build" "ok" "false"
echo "warn: Air build failed - workbench will run without the Air daemon"
fi
echo ""
echo "Starting build..."
echo ""
LandCapturePhaseBegin "tauri-build" "profile" "$PROFILE"
if ./Target/release/Maintain -- cargo tauri build --debug; then
LandCapturePhaseEnd "tauri-build" "profile" "$PROFILE" "ok" "true"
LandCapture "land:build:complete" \
"profile" "$PROFILE" \
"ok" "true"
else
BUILD_EXIT=$?
LandCapturePhaseEnd "tauri-build" "profile" "$PROFILE" "ok" "false" "exit_code" "$BUILD_EXIT"
LandCapture "land:build:error" \
"profile" "$PROFILE" \
"exit_code" "$BUILD_EXIT"
exit "$BUILD_EXIT"
fi
# Re-sign the debug .app with the correct entitlements so file pickers,
# Cocoon JIT, and extension helper spawns work when launching from Finder.
# shellcheck disable=SC1091
BundleLevel=debug bash Maintain/Script/SignBundle.sh