@geastack/cli 0.1.87 → 0.1.88

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -225,3 +225,5 @@ Compatible component edits and CSS changes update without reloading the page;
225
225
  reactive state is preserved for compatible component edits. Incompatible edits
226
226
  reload. Browser previews use simulated device APIs and browser layout; use the
227
227
  WASM renderer or a physical device to validate embedded rendering.
228
+
229
+ Native compiler, UI, renderer, and display settings belong in the app manifest. See [Native build settings](docs/NATIVE-BUILD-CONFIG.md) for precedence, board overrides, and `gea config --board <alias>`.
@@ -0,0 +1,215 @@
1
+ # Native build settings
2
+
3
+ Applications declare build choices in package.json. An app ID selects an app; it
4
+ never selects compiler flags, a framework slice, renderer shortcuts, or a pixel
5
+ ratio.
6
+
7
+ ## Precedence and inspection
8
+
9
+ Settings merge by leaf, in this order:
10
+
11
+ 1. Platform defaults shipped by @geastack/targets.
12
+ 2. Board defaults shipped by @geastack/targets.
13
+ 3. `gea.build`.
14
+ 4. `gea.targets.<platform>.build`.
15
+ 5. `gea.targets.<platform>.boards.<board-id>.build`.
16
+
17
+ Board keys are stable target IDs, not machine-local aliases. An object target
18
+ enables that target just as `true` does. False and zero are explicit values, not
19
+ requests to inherit. Unknown fields and unsupported explicit board choices are
20
+ errors. Two panel preferences, `renderer.fuseReplayFlush` and
21
+ `display.presentStream`, may also live in a shared base. When the selected
22
+ driver does not support them, they generate no native definitions; `gea config`
23
+ lists their values, source paths and reason under `inapplicable`. Other
24
+ unsupported settings remain errors at every level.
25
+
26
+ Run `gea config --board <alias> --app <id>` to print the resolved settings,
27
+ their individual origins, native definitions, and CSS pixel ratio. Builds use
28
+ the same resolver. The existing build directory contains
29
+ `gea-build-config.json` and `gea-build-config.cmake`; they are generated
30
+ artifacts, never another source of settings. The configuration hash participates
31
+ in the configure signature, and the JSON file is a code-generation dependency.
32
+
33
+ ```json
34
+ {
35
+ "gea": {
36
+ "targets": {
37
+ "esp32": {
38
+ "build": {
39
+ "ui": {
40
+ "styleStorage": "shared"
41
+ },
42
+ "compiler": {
43
+ "numberPrecision": "float32"
44
+ },
45
+ "renderer": {
46
+ "subtreeRevealChecks": false,
47
+ "recordInlinePositions": false,
48
+ "fuseReplayFlush": true
49
+ },
50
+ "diagnostics": {
51
+ "performanceCounters": false,
52
+ "frameTiming": false
53
+ },
54
+ "display": {
55
+ "presentStream": "continuous"
56
+ }
57
+ },
58
+ "boards": {
59
+ "esp32-s3-touch-amoled-1.8": {
60
+ "build": {
61
+ "compiler": {
62
+ "generatedCodeOptimization": "O2"
63
+ },
64
+ "renderer": {
65
+ "adaptiveCoalescing": true,
66
+ "broadDirtyBounds": true
67
+ },
68
+ "display": {
69
+ "framebufferStream": "continuous"
70
+ }
71
+ }
72
+ },
73
+ "esp32-s3-touch-amoled-2.41": {
74
+ "build": {
75
+ "display": {
76
+ "presentStream": "independent"
77
+ }
78
+ }
79
+ },
80
+ "esp32-s3-lilygo-t-display-s3-long": {
81
+ "build": {
82
+ "renderer": {
83
+ "fuseReplayFlush": false
84
+ }
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ `gea.build` is the application base across platforms. Use
95
+ `gea.targets.<platform>.build` for choices shared by every board on one platform;
96
+ board entries contain only differences. Nested groups merge by individual field:
97
+ the 1.8 board's `generatedCodeOptimization` keeps `numberPrecision` from the ESP32
98
+ base. Hardware constraints still apply after inheritance.
99
+
100
+ The example above is the complete bouncing-balls JSX ESP32 configuration. Shared
101
+ numeric precision, style storage, renderer bookkeeping and diagnostics appear
102
+ once. Fused replay and continuous presentation are base preferences; LILYGO
103
+ turns fused replay off, and the 2.41 board requests independent presentation.
104
+ The 2.06 board needs no override. Copying the app under another name leaves its
105
+ effective build choices unchanged.
106
+
107
+ ## Options
108
+
109
+ | Field under build | Values / meaning |
110
+ | --- | --- |
111
+ | compiler.generatedCodeOptimization | O0, O1, O2, O3, Os, Og; native optimization of the generated app archive |
112
+ | compiler.numberPrecision | float64 or float32; selects the existing GEA_NUMBER_FLOAT native storage mode |
113
+ | compiler.staticCssRules | boolean; default true |
114
+ | compiler.staticCssTape | boolean; default true |
115
+ | compiler.staticCssTapeMinChunk | positive integer; default 5 |
116
+ | compiler.translationUnits | default, per-file, balanced |
117
+ | compiler.storeRelowering | boolean; default true |
118
+ | compiler.moduleGraph | auto, compile, only, disabled |
119
+ | compiler.allowAny | boolean; default false |
120
+ | ui.styleStorage | inline or shared; the existing default remains inline |
121
+ | renderer.fuseReplayFlush | boolean |
122
+ | renderer.subtreeRevealChecks | boolean; keep true when content can move into view from outside a recorded clip |
123
+ | renderer.recordInlinePositions | boolean; false requires the app to refresh positions through its reactive updates |
124
+ | renderer.adaptiveCoalescing | boolean |
125
+ | renderer.broadDirtyBounds | boolean |
126
+ | display.framebufferStream | independent or continuous |
127
+ | display.presentStream | independent or continuous |
128
+ | display.flushPoolBytes | non-negative integer |
129
+ | diagnostics.performanceCounters | boolean; master performance instrumentation switch |
130
+ | diagnostics.frameTiming | boolean; scheduler lightweight timing instrumentation |
131
+ | services.wifi | auto or disabled; disabled conflicts with reachable network APIs |
132
+
133
+ Float32 is the existing generated numeric-storage optimization, not a promise
134
+ that every TypeScript expression becomes single-precision arithmetic. It can
135
+ reduce precision. The removed NUMBER_F32 environment setting had no active
136
+ consumer and is not forwarded.
137
+
138
+ Common compiler-pipeline settings also reach script-based native builds. The web
139
+ settings configure the native WASM simulator; the DOM build keeps browser
140
+ semantics. macOS resolves settings separately for each resident app.
141
+
142
+ Availability and defaults are explicit in @geastack/targets/build-config.json.
143
+ The general ESP32 and RP2350 paths support shared-style storage and the common
144
+ compiler-pipeline settings. ESP32 also supports common numeric precision,
145
+ renderer bookkeeping and diagnostic settings independently of board identity. AMOLED boards additionally support the renderer and
146
+ display settings they implement. The 2.06 base implements the optional
147
+ canvas-only framework. Unsupported options fail, except for the explicitly reported inapplicable
148
+ shared panel preferences described above.
149
+
150
+ Canvas-only execution is inferred, not configured. The analyzer must prove a
151
+ complete source graph using direct display drawing without JSX, DOM access,
152
+ unknown globals, or host services. Unknown imports, native extensions, OTA
153
+ services, and older analyzers retain the full runtime. The target must also
154
+ implement the canvas-only path. `gea config` reports the decision and its reason
155
+ under `inferred.runtime`; the same result selects the native frame loop,
156
+ framework sources, and boot services before CMake configures the build.
157
+
158
+ The former `compiler.runtime`, `runtime.directCanvasContext`,
159
+ `runtime.framework`, and `services.boot` settings are rejected. Remove them;
160
+ there is no replacement opt-in. The current compiler already emits native
161
+ canvas calls automatically. Runtime inference does not change browser DOM builds.
162
+
163
+ Panel constraints cannot be overridden by an app. For example, the 2.41 panel
164
+ requires independent framebuffer/present transfers; the LILYGO Long currently
165
+ requires independent framebuffer transfers and an unfused renderer.
166
+
167
+ `cssDevicePixelRatio` keeps its existing root spelling and also accepts
168
+ platform and board overrides alongside `build`. The resolved value reaches both
169
+ font generation and native layout.
170
+
171
+ ## Migration and environment
172
+
173
+ The formerly special-cased examples are bouncing-balls-jsx, bubble-grid,
174
+ canvas-3d, gea3d-cube, sky-hop-jsx, css-3d-cube and three-angle-metal.
175
+ The obsolete canvas switches are removed from both manifests and WASM scripts. The obsolete minimal
176
+ global-object define, like NUMBER_F32, has no active consumer and is removed;
177
+ sky-hop-jsx therefore needs no replacement option. This migration relocates their
178
+ settings; it does not make their renderer shortcuts global defaults.
179
+
180
+ Known raw `gea.defines` remain readable during migration. A raw definition and
181
+ a typed setting for the same choice are an error, even if they agree. Unrelated
182
+ application-native defines remain supported.
183
+
184
+ Former tuning environment variables (NUMBER_F32, direct-canvas context, board
185
+ optimization presets, static CSS generator switches, translation-unit layout,
186
+ store relowering, and the mapped native option macros) are rejected with the
187
+ manifest replacement. Toolchain paths, credentials, build job count and device
188
+ selection are separate concerns. Internally, IDF's requirements subprocess
189
+ receives the path to the CLI-generated configuration; it does not infer options
190
+ from inherited tuning values.
191
+
192
+ CSS reachability, numeric field narrowing, packing, and removal of unused node
193
+ owners remain automatic compiler analysis. They are not manifest feature lists.
194
+
195
+ ## Validation
196
+
197
+ The migration checks option precedence and origins, unknown/unsupported options,
198
+ raw-define conflicts, environment contamination, config-cache invalidation,
199
+ hardware restrictions, and app-rename invariance. Compiler tests verify that
200
+ runtime inference retains UI/services for mixed or unproven applications.
201
+
202
+ A configuration-preserving refactor still needs a native build and a device
203
+ performance check before claiming a new hardware performance result.
204
+
205
+ The CLI unit tests use independent fixtures. To also verify the migrated source
206
+ examples and target glue, run from the CLI checkout:
207
+
208
+ ```sh
209
+ GEA_TEST_TARGETS_ROOT=/path/to/targets \
210
+ GEA_TEST_EXAMPLES_ROOT=/path/to/examples \
211
+ node --test test/build-config.test.mjs
212
+ ```
213
+
214
+ These two variables locate integration-test inputs; they do not set app build
215
+ options. Without them, the source-migration checks are skipped.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/cli",
3
- "version": "0.1.87",
3
+ "version": "0.1.88",
4
4
  "description": "Command-line front door for GeaStack apps, targets, and local toolchains.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -37,19 +37,18 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "@clack/prompts": "^1.8.0",
40
- "@geastack/simulator": "^0.1.11",
41
- "@geastack/targets": "^0.1.84",
40
+ "@geastack/simulator": "^0.1.12",
41
+ "@geastack/targets": "^0.1.85",
42
42
  "picocolors": "^1.1.1",
43
43
  "serialport": "^13.0.0"
44
44
  },
45
45
  "starterDependencies": {
46
- "@geastack/core": "^0.1.30",
47
- "@geastack/targets": "^0.1.84",
46
+ "@geastack/core": "^0.1.31",
47
+ "@geastack/targets": "^0.1.85",
48
48
  "@geastack/apple": "^0.2.9"
49
49
  },
50
50
  "scripts": {
51
51
  "check": "node --check bin/gea.mjs && node --check bin/create-geastack.mjs && find src test packages -name '*.mjs' -print0 | xargs -0 -n1 node --check",
52
52
  "test": "node --test"
53
- },
54
- "gitHead": "8be359ace7733940493c12494abb07db0c727f80"
53
+ }
55
54
  }
@@ -147,6 +147,7 @@ export function resolveBoardSelection({
147
147
 
148
148
  const selection = {
149
149
  boardName,
150
+ targetBase,
150
151
  target,
151
152
  adapter,
152
153
  bootMode: targetInfo.bootMode || '',
@@ -0,0 +1,263 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import { resolveInstalledPackageDir } from './context.mjs'
4
+ import { resolveAppCapabilities } from './esp32/capabilities.mjs'
5
+ import { fileURLToPath } from 'node:url'
6
+ import { createHash } from 'node:crypto'
7
+ import { CliError, ExitCode } from './errors.mjs'
8
+
9
+ // Public, typed build choices. Reachability/packing facts are compiler output,
10
+ // never user options. Keep option names independent of application identity.
11
+ export const buildOptions = {
12
+ 'compiler.moduleGraph': { values: ['auto', 'compile', 'only', 'disabled'] },
13
+ 'compiler.allowAny': { type: 'boolean' },
14
+ 'compiler.staticCssRules': { type: 'boolean' },
15
+ 'compiler.staticCssTape': { type: 'boolean' },
16
+ 'compiler.staticCssTapeMinChunk': { type: 'integer', min: 1 },
17
+ 'compiler.translationUnits': { values: ['default', 'per-file', 'balanced'] },
18
+ 'compiler.storeRelowering': { type: 'boolean' },
19
+ 'compiler.generatedCodeOptimization': { values: ['O0', 'O1', 'O2', 'O3', 'Os', 'Og'] },
20
+ 'compiler.numberPrecision': { values: ['float64', 'float32'], macro: 'GEA_NUMBER_FLOAT', encode: v => v === 'float32' ? 1 : undefined },
21
+ 'ui.styleStorage': { values: ['inline', 'shared'], macro: 'GEA_EMBEDDED_SHARED_STYLES', encode: v => Number(v === 'shared') },
22
+ 'renderer.fuseReplayFlush': { boardScoped: true, type: 'boolean', macro: 'GEA_EMBEDDED_DISPLAY_FUSE_REPLAY_FLUSH' },
23
+ 'renderer.subtreeRevealChecks': { type: 'boolean', macro: 'GEA_EMBEDDED_SUBTREE_REVEAL_CHECK' },
24
+ 'renderer.recordInlinePositions': { type: 'boolean', macro: 'GEA_EMBEDDED_SKIP_POSITION_INLINE_RECORD', encode: v => Number(!v) },
25
+ 'renderer.adaptiveCoalescing': { type: 'boolean', macro: 'GEA_EMBEDDED_FLUSH_ADAPTIVE_COALESCE' },
26
+ 'renderer.broadDirtyBounds': { type: 'boolean', macro: 'GEA_EMBEDDED_BROAD_DIRTY_BBOX' },
27
+ 'display.framebufferStream': { values: ['independent', 'continuous'], macro: 'GEA_EMBEDDED_DISPLAY_CO5300_FRAMEBUFFER_CS_HELD_STREAM', encode: v => Number(v === 'continuous') },
28
+ 'display.presentStream': { boardScoped: true, values: ['independent', 'continuous'], macro: 'GEA_EMBEDDED_DISPLAY_CO5300_PRESENT_CS_HELD_STREAM', encode: v => Number(v === 'continuous') },
29
+ 'display.flushPoolBytes': { type: 'integer', macro: 'GEA_EMBEDDED_DISPLAY_FLUSH_POOL_BYTES' },
30
+ 'diagnostics.performanceCounters': { type: 'boolean', macro: 'GEA_EMBEDDED_PERF' },
31
+ 'diagnostics.frameTiming': { type: 'boolean', macro: 'GEA_EMBEDDED_FRAME_SCHEDULER_PERF_LITE' },
32
+ 'services.wifi': { values: ['auto', 'disabled'], macro: 'GEA_EMBEDDED_WIFI_DISABLED', encode: v => v === 'disabled' ? 1 : undefined },
33
+ }
34
+ const macros = new Map(Object.entries(buildOptions).filter(([, spec]) => spec.macro).map(([key, spec]) => [spec.macro, key]))
35
+ const removedEnvironment = {
36
+ GEA_WEB_DEVICE_PIXEL_RATIO: 'cssDevicePixelRatio',
37
+ GEA_WEB_DIRECT_CANVAS: null,
38
+ GEA_WEB_DIRECT_CANVAS_CODEGEN: null,
39
+ GEA_THREE_MODULE_GRAPH: 'compiler.moduleGraph',
40
+ GEA_THREE_MODULE_GRAPH_ONLY: 'compiler.moduleGraph',
41
+ GEA_THREE_MODULE_GRAPH_COMPILE: 'compiler.moduleGraph',
42
+ GEA_VITE_MODULE_GRAPH: 'compiler.moduleGraph',
43
+ GEA_STATIC_CSS_RULES: 'compiler.staticCssRules',
44
+ GEA_STATIC_CSS_TAPE: 'compiler.staticCssTape',
45
+ GEA_STATIC_CSS_TAPE_MIN_CHUNK: 'compiler.staticCssTapeMinChunk',
46
+ GEA_CPP_TRANSLATION_UNITS: 'compiler.translationUnits',
47
+ GEA_PER_FILE_UNITS: 'compiler.translationUnits',
48
+ GEA_SKIP_STORE_RELOWER: 'compiler.storeRelowering',
49
+ GEA_EMBEDDED_NUMBER_F32: 'compiler.numberPrecision',
50
+ GEA_CPP_MINIMAL_GLOBAL_OBJECT: 'compiler (obsolete: no active consumer)',
51
+ GEA_EMBEDDED_DIRECT_CANVAS_CONTEXT: null,
52
+ GEA_BOARD_OPTIMIZE_BOUNCING_BALLS_JSX: 'renderer / compiler',
53
+ GEA_BOARD_GEATSC_OPTIMIZATION: 'compiler.generatedCodeOptimization',
54
+ GEA_BOARD_FUSE_REPLAY_FLUSH: 'renderer.fuseReplayFlush',
55
+ GEA_BOARD_ADAPTIVE_COALESCE: 'renderer.adaptiveCoalescing',
56
+ GEA_BOARD_BROAD_DIRTY_BBOX: 'renderer.broadDirtyBounds',
57
+ GEA_BOARD_FRAMEBUFFER_CS_HELD_STREAM: 'display.framebufferStream',
58
+ GEA_BOARD_PRESENT_CS_HELD_STREAM: 'display.presentStream',
59
+ }
60
+ for (const [macro, key] of macros) removedEnvironment[macro] ||= key
61
+
62
+ const isObject = value => value !== null && typeof value === 'object' && !Array.isArray(value)
63
+ function fail(message) { throw new CliError(message, ExitCode.usage) }
64
+ export function buildVariable(key) { return 'GEA_BUILD_' + key.replaceAll('.', '_').replace(/([a-z])([A-Z])/g, '$1_$2').toUpperCase() }
65
+ function flatten(raw, where) {
66
+ if (raw === undefined) return {}
67
+ if (!isObject(raw)) fail(`${where} must be an object`)
68
+ const out = {}
69
+ for (const [group, fields] of Object.entries(raw)) {
70
+ if (!Object.keys(buildOptions).some(key => key.startsWith(group + '.'))) fail(`Unknown setting ${where}.${group}`)
71
+ if (!isObject(fields)) fail(`${where}.${group} must be an object`)
72
+ for (const [name, value] of Object.entries(fields)) {
73
+ const key = group + '.' + name
74
+ const spec = buildOptions[key]
75
+ if (!spec) fail(`Unknown setting ${where}.${key}`)
76
+ if (spec.values ? !spec.values.includes(value)
77
+ : spec.type === 'integer' ? !Number.isSafeInteger(value) || value < (spec.min || 0)
78
+ : typeof value !== spec.type) {
79
+ fail(`${where}.${key} must be ${spec.values?.join(' | ') || (spec.type === 'integer' ? 'a non-negative safe integer' : spec.type)}`)
80
+ }
81
+ out[key] = value
82
+ }
83
+ }
84
+ return out
85
+ }
86
+ function ratio(value, where) {
87
+ if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) fail(`${where} must be a positive number`)
88
+ return value
89
+ }
90
+ export function validateBuildManifest(manifest) {
91
+ flatten(manifest.build, 'gea.build')
92
+ for (const [platform, target] of Object.entries(manifest.targets || {})) {
93
+ if (!isObject(target)) continue
94
+ const where = 'gea.targets.' + platform
95
+ flatten(target.build, where + '.build')
96
+ if (target.cssDevicePixelRatio !== undefined) ratio(target.cssDevicePixelRatio, where + '.cssDevicePixelRatio')
97
+ if (target.boards === undefined) continue
98
+ if (!isObject(target.boards)) fail(where + '.boards must be an object')
99
+ for (const [id, board] of Object.entries(target.boards)) {
100
+ if (!/^[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(id) || !isObject(board)) fail(where + '.boards must contain board IDs mapped to objects')
101
+ for (const key of Object.keys(board)) if (!['build', 'cssDevicePixelRatio'].includes(key)) fail(`Unknown setting ${where}.boards.${id}.${key}`)
102
+ flatten(board.build, where + '.boards.' + id + '.build')
103
+ if (board.cssDevicePixelRatio !== undefined) ratio(board.cssDevicePixelRatio, where + '.boards.' + id + '.cssDevicePixelRatio')
104
+ }
105
+ }
106
+ }
107
+ export function assertNoBuildEnvironment(env = {}) {
108
+ for (const [name, key] of Object.entries(removedEnvironment)) {
109
+ if (env[name] !== undefined && key === null) fail(`${name} was removed; canvas runtime selection is inferred from app capabilities. Remove the override.`)
110
+ if (env[name] !== undefined) fail(`${name} is no longer a build override. Remove it from the environment and set gea.build.${key} in package.json (or a target/board override).`)
111
+ }
112
+ }
113
+ function unflatten(flat) {
114
+ const out = {}
115
+ for (const [key, value] of Object.entries(flat)) {
116
+ const [group, name] = key.split('.')
117
+ ;(out[group] ||= {})[name] = value
118
+ }
119
+ return out
120
+ }
121
+ function legacyValue(key, literal) {
122
+ const spec = buildOptions[key]
123
+ // Legacy input remains readable until apps migrate. A typed setting and a
124
+ // raw define for the same choice are always an error, even if they agree.
125
+ for (const value of spec.values || (spec.type === 'boolean' ? [false, true] : [Number(literal)])) {
126
+ if (String(spec.encode ? spec.encode(value) : typeof value === 'boolean' ? Number(value) : value) === literal) return value
127
+ }
128
+ fail(`Invalid legacy define for ${key}; use its typed package.json build setting`)
129
+ }
130
+ export function resolveBuildConfig({ app, platform, board = '', targetsRoot = '', targetBase = '', env = {}, capabilities }) {
131
+ assertNoBuildEnvironment(env)
132
+ const manifest = app?.manifest || {}
133
+ validateBuildManifest(manifest)
134
+ const catalogPath = path.join(targetsRoot, 'build-config.json')
135
+ const catalog = targetsRoot && fs.existsSync(catalogPath) ? JSON.parse(fs.readFileSync(catalogPath, 'utf8')) : {}
136
+ const boardConfig = catalog.boards?.[board] || catalog.boards?.[targetBase] || {}
137
+ const platformConfig = catalog.platforms?.[platform] || {}
138
+ const supported = new Set([...(platformConfig.supported || []), ...(boardConfig.supported || [])])
139
+ const flat = {}, origins = {}, inapplicable = {}, explicit = new Set()
140
+ const apply = (raw, origin, user = false, base = false) => {
141
+ for (const [key, value] of Object.entries(flatten(raw, origin))) {
142
+ if (user && !supported.has(key)) {
143
+ // A shared base may express panel preferences for several drivers.
144
+ // Keep unsupported driver preferences out of native defines, and expose
145
+ // their provenance in `gea config`. A concrete board override must work.
146
+ if (base && buildOptions[key].boardScoped) {
147
+ inapplicable[key] = { value, origin: origin + '.' + key, reason: 'unsupported by selected target' }
148
+ continue
149
+ }
150
+ fail(`${origin}.${key} is not supported by ${board || platform}; it would have no effect`)
151
+ }
152
+ flat[key] = value; origins[key] = origin + '.' + key
153
+ if (user) explicit.add(key)
154
+ }
155
+ }
156
+ apply(platformConfig.defaults, 'platform defaults')
157
+ apply(boardConfig.defaults, 'board defaults')
158
+ const target = isObject(manifest.targets?.[platform]) ? manifest.targets[platform] : {}
159
+ const boardOverride = target.boards?.[board] || {}
160
+ apply(manifest.build, 'gea.build', true, true)
161
+ apply(target.build, 'gea.targets.' + platform + '.build', true, true)
162
+ apply(boardOverride.build, 'gea.targets.' + platform + '.boards.' + board + '.build', true)
163
+ const passthroughDefines = []
164
+ const seenLegacy = new Set()
165
+ for (const define of app?.defines || []) {
166
+ const [name, ...rest] = define.split('=')
167
+ if (name === 'GEA_CPP_MINIMAL_GLOBAL_OBJECT' || name === 'GEA_EMBEDDED_NUMBER_F32') fail(`${name} is obsolete and has no active consumer; remove it from gea.defines`)
168
+ if (['GEA_EMBEDDED_DIRECT_CANVAS_CONTEXT', 'GEA_EMBEDDED_FULL_BOOT_SERVICES'].includes(name)) fail(`${name} is inferred from app capabilities; remove it from gea.defines`)
169
+ const key = macros.get(name)
170
+ if (!key || !supported.has(key)) { passthroughDefines.push(define); continue }
171
+ if (seenLegacy.has(key)) fail(`Conflicting legacy definitions for ${key}`)
172
+ seenLegacy.add(key)
173
+ if (explicit.has(key)) fail(`gea.defines.${name} conflicts with ${origins[key]}; keep only the typed setting`)
174
+ flat[key] = legacyValue(key, rest.length ? rest.join('=') : '1')
175
+ origins[key] = 'gea.defines.' + name + ' (legacy)'
176
+ }
177
+ for (const [key, allowed] of Object.entries(boardConfig.constraints || {})) {
178
+ if (flat[key] !== undefined && !allowed.includes(flat[key])) fail(`${board} requires ${key} to be ${allowed.join(' | ')}`)
179
+ }
180
+ let cssDevicePixelRatio = app?.cssDevicePixelRatio || boardConfig.cssDevicePixelRatio || platformConfig.cssDevicePixelRatio || 0
181
+ let cssOrigin = app?.cssDevicePixelRatio ? 'gea.cssDevicePixelRatio' : boardConfig.cssDevicePixelRatio ? 'board defaults' : platformConfig.cssDevicePixelRatio ? 'platform defaults' : 'target default'
182
+ for (const [value, origin] of [[target.cssDevicePixelRatio, 'gea.targets.' + platform], [boardOverride.cssDevicePixelRatio, 'gea.targets.' + platform + '.boards.' + board]]) {
183
+ if (value !== undefined) { cssDevicePixelRatio = ratio(value, origin + '.cssDevicePixelRatio'); cssOrigin = origin + '.cssDevicePixelRatio' }
184
+ }
185
+ const defines = [...passthroughDefines]
186
+ const managedDefines = []
187
+ for (const [key, value] of Object.entries(flat)) {
188
+ const spec = buildOptions[key]
189
+ if (!spec.macro) continue
190
+ const encoded = spec.encode ? spec.encode(value) : typeof value === 'boolean' ? Number(value) : value
191
+ if (encoded !== undefined) managedDefines.push(`${spec.macro}=${encoded}`)
192
+ }
193
+ const inferred = inferRuntime(app, platform, capabilities, boardConfig.inference || platformConfig.inference)
194
+ if ((boardConfig.inference || platformConfig.inference)?.canvasOnly) {
195
+ managedDefines.push(`GEA_EMBEDDED_DIRECT_CANVAS_CONTEXT=${Number(inferred.runtime.mode === 'canvas')}`)
196
+ if (platform === 'esp32' && inferred.runtime.mode === 'canvas' && !managedDefines.some(d => d.startsWith('GEA_EMBEDDED_WIFI_DISABLED='))) managedDefines.push('GEA_EMBEDDED_WIFI_DISABLED=1')
197
+ }
198
+ defines.push(...managedDefines)
199
+ return { platform, board, inferred, settings: unflatten(flat), origins, inapplicable, defines, managedDefines, cssDevicePixelRatio, cssDevicePixelRatioOrigin: cssOrigin }
200
+ }
201
+
202
+ function inferRuntime(app, platform, capabilities, target) {
203
+ let reason = 'target does not implement the canvas-only runtime'
204
+ if (target?.canvasOnly) {
205
+ const features = capabilities?.features || []
206
+ const proofs = features.filter(f => f.startsWith('runtime-analysis-'))
207
+ const native = app?.manifest || {}
208
+ const platformNative = typeof native.targets?.[platform] === 'object' ? native.targets[platform] : {}
209
+ const extensionKeys = ['nativeSources', 'componentDirs', 'componentRequires', 'linkOptions', 'compilerPlugins']
210
+ if (!proofs.length || proofs.some(p => p !== 'runtime-analysis-v1')) reason = 'no supported complete runtime analysis'
211
+ else if (!features.includes('runtime-canvas-only')) reason = 'app requires the full runtime or source analysis is inconclusive'
212
+ else if (extensionKeys.some(key => native[key]?.length || platformNative[key]?.length)) reason = 'native extensions cannot be proven independent of the UI and services'
213
+ else if (capabilities.network || capabilities.ble || capabilities.audio || (capabilities.bindings || []).some(b => b !== 'display')) reason = 'app requires host services outside the canvas runtime'
214
+ else return { runtime: { mode: 'canvas', reason: 'complete source analysis proves direct display drawing without UI or host services' } }
215
+ }
216
+ return { runtime: { mode: 'full', reason } }
217
+ }
218
+
219
+ // Use the same analyzer for inspection and script targets as ESP32 preparation.
220
+ // Missing/older proof markers retain the full runtime; no app name is involved.
221
+ export function resolveAppBuildConfig(input) {
222
+ const { app, platform, env = {} } = input
223
+ let capabilities = input.capabilities
224
+ if (!capabilities && app?.runtime === 'gea' && ['esp32', 'web'].includes(platform)) {
225
+ capabilities = resolveAppCapabilities({
226
+ compilerPackageDir: env.GEA_COMPILER_DIR || resolveInstalledPackageDir('@geastack/compiler', app.root),
227
+ pluginPackageDir: env.GEA_PLUGIN_DIR || resolveInstalledPackageDir('@geastack/geatsc-plugin-gea', app.root),
228
+ env,
229
+ }, app, { env })
230
+ }
231
+ return resolveBuildConfig({ ...input, capabilities })
232
+ }
233
+
234
+ export function renderBuildCmake(resolved) {
235
+ const lines = ['# Generated by gea from package.json. Do not edit.']
236
+ for (const [key, value] of Object.entries(flatten(resolved.settings, 'resolved build'))) {
237
+ lines.push(`set(${buildVariable(key)} "${typeof value === 'boolean' ? Number(value) : value}")`)
238
+ }
239
+ lines.push(`set(GEA_APP_CANVAS_ONLY "${Number(resolved.inferred?.runtime.mode === 'canvas')}")`)
240
+ return lines.join('\n') + '\n'
241
+ }
242
+ export function writeBuildConfig(buildDir, resolved) {
243
+ fs.mkdirSync(buildDir, { recursive: true })
244
+ const cmake = path.join(buildDir, 'gea-build-config.cmake')
245
+ const json = path.join(buildDir, 'gea-build-config.json')
246
+ const contents = JSON.stringify(resolved, null, 2) + '\n'
247
+ for (const [file, value] of [[cmake, renderBuildCmake(resolved)], [json, contents]]) {
248
+ if (!fs.existsSync(file) || fs.readFileSync(file, 'utf8') !== value) fs.writeFileSync(file, value)
249
+ }
250
+ return { cmake, json, hash: createHash('sha256').update(contents).digest('hex') }
251
+ }
252
+
253
+ // Script-based native targets receive the same resolved file as CMake targets.
254
+ // The path is an internal handoff; option values are never inherited from env.
255
+ export function nativeScriptBuildEnv(app, platform, env, { dryRun = false, buildDir, board = '', targetsRoot = '' } = {}) {
256
+ if (!targetsRoot) {
257
+ targetsRoot = env.GEA_TARGETS_ROOT || resolveInstalledPackageDir('@geastack/targets', app.root)
258
+ }
259
+ const resolved = resolveAppBuildConfig({ app, platform, board, targetsRoot, env })
260
+ const directory = buildDir || path.join(app.root, '.gea', 'build', platform)
261
+ const json = dryRun ? path.join(directory, 'gea-build-config.json') : writeBuildConfig(directory, resolved).json
262
+ return { ...env, GEA_BUILD_CONFIG_JSON: json, GEA_CLI_BIN: fileURLToPath(new URL('../bin/gea.mjs', import.meta.url)) }
263
+ }
@@ -189,7 +189,7 @@ async function flashEsp32(ctx, parsed, rest, options, selection, { monitor }) {
189
189
  }
190
190
 
191
191
  let image = explicitImage ? path.resolve(ctx.cwd, explicitImage) : images.app
192
- if (!explicitImage && !flag(parsed, 'no-build')) {
192
+ if (!explicitImage && option(parsed, 'build') !== false) {
193
193
  await buildEsp32Firmware({ ctx, selection, app, env, bleOta: bleOtaRequested(parsed, app, env), dryRun: base.dryRun, verbose: flag(parsed, 'verbose'), stdout: base.stdout, stderr: base.stderr, output: option(parsed, 'output', '') })
194
194
  }
195
195
  const appLabel = app?.id || 'prebuilt image'
@@ -246,7 +246,7 @@ export async function otaCommand(ctx, parsed, rest, options) {
246
246
  }
247
247
  const base = io(parsed, options)
248
248
  const env = createChildEnv(ctx, base.env)
249
- if (flag(parsed, 'no-build')) env.W87_NO_BUILD = '1'
249
+ if (option(parsed, 'build') === false) env.W87_NO_BUILD = '1'
250
250
  if (option(parsed, 'image')) env.W87_APP_IMAGE = path.resolve(ctx.cwd, option(parsed, 'image'))
251
251
  return runGeaos({ ctx, selection, action: 'ota', positionals: rest, env, dryRun: base.dryRun, stdout: base.stdout })
252
252
  }
@@ -267,7 +267,7 @@ export async function otaCommand(ctx, parsed, rest, options) {
267
267
 
268
268
  let image = explicitImage ? path.resolve(ctx.cwd, explicitImage) : ''
269
269
  if (!explicitImage) {
270
- const prepared = flag(parsed, 'no-build')
270
+ const prepared = option(parsed, 'build') === false
271
271
  ? { images: buildImages(buildDir) }
272
272
  : await buildEsp32Firmware({ ctx, selection, app, env, bleOta: transport === 'ble' || bleOtaRequested(parsed, app, env), dryRun: base.dryRun, verbose: flag(parsed, 'verbose'), stdout: base.stdout, stderr: base.stderr, output: option(parsed, 'output', '') })
273
273
  image = prepared.images.app
@@ -0,0 +1,16 @@
1
+ import { option } from '../args.mjs'
2
+ import { selectBoard } from './board.mjs'
3
+ import { assertValidApp, assertTargetEnabled, resolveRequestedApp, knownPlatforms } from '../manifest.mjs'
4
+ import { resolveAppBuildConfig } from '../build-config.mjs'
5
+
6
+ export function configCommand(ctx, parsed, rest, { stdout, env }) {
7
+ const app = resolveRequestedApp(ctx, parsed, rest)
8
+ assertValidApp(app)
9
+ const requested = option(parsed, 'target', '')
10
+ const selection = knownPlatforms.includes(requested) ? { target: '', appPlatform: requested } : selectBoard(ctx, parsed)
11
+ const platform = selection.appPlatform || (selection.adapter === 'rp2350-pico' ? 'rp2350' : 'esp32')
12
+ assertTargetEnabled(ctx, app, selection.boardName || selection.target || platform)
13
+ const resolved = resolveAppBuildConfig({ app, platform, board: selection.target, targetBase: selection.targetBase, targetsRoot: ctx.targetsRoot, env })
14
+ stdout(JSON.stringify(resolved, null, 2))
15
+ return 0
16
+ }
@@ -1,10 +1,11 @@
1
1
  import { spawnSync } from 'node:child_process'
2
+ import { resolveBuildConfig, writeBuildConfig } from '../build-config.mjs'
2
3
  import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs'
3
4
  import path from 'node:path'
4
5
 
5
6
  import { loadChipCatalogFromDir, writeCustomTarget } from '../boards/custom-target.mjs'
6
7
  import { CliError, ExitCode, fail } from '../errors.mjs'
7
- import { appCmakeMeta, appCmakeDefines, appCmakeLdFragments, appTargetConfig, appTargetPaths } from '../manifest.mjs'
8
+ import { appCmakeMeta, appCmakeLdFragments, appTargetConfig, appTargetPaths } from '../manifest.mjs'
8
9
  import { quietSteps, runQuiet } from '../run.mjs'
9
10
  import { resolveAppCapabilities, withRendererFeatureDefines } from './capabilities.mjs'
10
11
  import { activateEspIdf, idfPyCommand } from './idf-env.mjs'
@@ -317,6 +318,9 @@ export function prepareEsp32Build({ ctx, selection, app = null, env = ctx.env ||
317
318
  if (!selection.targetDir || !existsSync(path.join(selection.targetDir, 'CMakeLists.txt'))) {
318
319
  fail(`ESP32 target '${selection.target}' has no project directory (${selection.targetDir || 'unset'}). Is @geastack/targets installed?`, ExitCode.missingDependency)
319
320
  }
321
+ const capabilities = app ? resolveAppCapabilities(ctx, app, { env }) : { network: false, ble: false, bleApi: false, audio: false, bindings: [], features: [] }
322
+ if (bleOta) capabilities.ble = true
323
+ const resolvedBuild = resolveBuildConfig({ app, platform: 'esp32', board: selection.target, targetBase: selection.targetBase, targetsRoot: ctx.targetsRoot, env, capabilities })
320
324
  const idfTarget = selection.idfTarget || 'esp32s3'
321
325
  const buildDir = esp32BuildDir(ctx, selection, app?.id, env)
322
326
  // gea.targets.esp32.sdkconfig: the app's own Kconfig defaults, layered over
@@ -329,7 +333,10 @@ export function prepareEsp32Build({ ctx, selection, app = null, env = ctx.env ||
329
333
  log(`Using ESP32 target '${selection.target}' at ${selection.targetDir} (idf=${idfTarget} chip=${selection.esptoolChip || idfTarget} flash=${selection.flashSize})`)
330
334
 
331
335
  const childEnv = { ...env }
332
- const idfArgs = [`-DIDF_TARGET=${idfTarget}`]
336
+ const buildConfig = writeBuildConfig(buildDir, resolvedBuild)
337
+ const idfArgs = [`-DIDF_TARGET=${idfTarget}`, `-DGEA_BUILD_CONFIG_FILE=${cmakeValue(buildConfig.cmake)}`, `-DGEA_BUILD_CONFIG_JSON=${cmakeValue(buildConfig.json)}`, `-DGEA_BUILD_CONFIG_HASH=${buildConfig.hash}`]
338
+ childEnv.GEA_BUILD_CONFIG_FILE = cmakeValue(buildConfig.cmake)
339
+ childEnv.GEA_BUILD_CONFIG_JSON = cmakeValue(buildConfig.json)
333
340
  let boardPartitionCsv = ''
334
341
  let boardConsole = null
335
342
  let boardPsram = null
@@ -404,10 +411,11 @@ function preparePartitions(app, config, buildDir, targetId) {
404
411
  }
405
412
 
406
413
  let appPartitionCsv = ''
407
- let capabilities = { network: false, ble: false, bleApi: false, audio: false, bindings: [], features: [] }
408
414
  if (app) {
409
- capabilities = resolveAppCapabilities(ctx, app, { env })
410
- if (bleOta) capabilities.ble = true
415
+ if (resolvedBuild.settings.services?.wifi === 'disabled') {
416
+ if (capabilities.network) fail('services.wifi=disabled conflicts with the app network capabilities', ExitCode.usage)
417
+ capabilities.network = false
418
+ }
411
419
  const meta = appCmakeMeta(ctx, app)
412
420
  // gea.cssDevicePixelRatio lands in two places that have to agree. The
413
421
  // layout ratio travels with the app's own defines, because those go on the
@@ -415,8 +423,8 @@ function preparePartitions(app, config, buildDir, targetId) {
415
423
  // font ratio is a cache variable each board declares with a plain
416
424
  // `set(... CACHE STRING ...)`, so a -D of the same name, which exists before
417
425
  // the board's CMakeLists runs, wins without the board knowing about apps.
418
- const cssDpr = cssDevicePixelRatioLiteral(app.cssDevicePixelRatio)
419
- const appDefines = [withRendererFeatureDefines(appCmakeDefines(app), capabilities.features, { devicePixelRatio: cssDpr ? Number(cssDpr) : undefined }), cssDpr && `GEA_EMBEDDED_CSS_LAYOUT_DEVICE_PIXEL_RATIO=${cssDpr}`]
426
+ const cssDpr = cssDevicePixelRatioLiteral(resolvedBuild.cssDevicePixelRatio)
427
+ const appDefines = [withRendererFeatureDefines(resolvedBuild.defines.join(';'), capabilities.features, { devicePixelRatio: cssDpr ? Number(cssDpr) : undefined }), cssDpr && `GEA_EMBEDDED_CSS_LAYOUT_DEVICE_PIXEL_RATIO=${cssDpr}`]
420
428
  .filter(Boolean)
421
429
  .join(';')
422
430
  const esp32Config = appEsp32Config
@@ -82,6 +82,7 @@ export async function runEsptoolOverUsb({ idf, selection, options, args, port =
82
82
  const { command, args: fullArgs } = esptoolCommand(idf, ['-p', flashPort, ...args])
83
83
  // Retries append to one log; the summary reads the last attempt only.
84
84
  const logFile = path.join(logDir, 'gea-flash.log')
85
+ const attemptLogOffset = attempt > 1 && existsSync(logFile) ? statSync(logFile).size : 0
85
86
  const step = await runStep(command, fullArgs, {
86
87
  cwd: selection.targetDir,
87
88
  env,
@@ -104,7 +105,7 @@ export async function runEsptoolOverUsb({ idf, selection, options, args, port =
104
105
  // A completed write that only failed on esptool's own teardown is a
105
106
  // success: the images are on the board and it has been reset. Report it
106
107
  // as one, so the retry loop does not re-flash and re-reboot for minutes.
107
- if (flashCompleted(logFile)) {
108
+ if (flashCompleted(logFile, args, attemptLogOffset)) {
108
109
  warn(stderr, `esptool exited ${status} after resetting the board; the flash itself completed.`)
109
110
  if (step.quiet) stdout(flashSummary(logFile))
110
111
  return 0
@@ -118,25 +119,52 @@ export async function runEsptoolOverUsb({ idf, selection, options, args, port =
118
119
  }
119
120
  }
120
121
 
121
- // esptool resets the board as its LAST act, and on a USB-Serial/JTAG chip that
122
- // reset detaches the device from USB. esptool then tries to restore the port it
123
- // no longer has and dies with pySerial's "Cannot configure port" -- after every
124
- // image has already been written and verified. Retrying that re-flashes a board
125
- // that was already flashed, and resets it again, for the whole retrySeconds
126
- // window: 300 seconds and thirteen reboots for a flash that succeeded the first
127
- // time, which is what "the board keeps restarting" turned out to be. esptool
128
- // prints the reset banner only once every write has been verified, so finding
129
- // it in the last attempt means the flash is done and there is nothing to retry.
130
- function flashCompleted(logFile) {
122
+ // esptool also prints its reset banner from error cleanup after an incomplete
123
+ // write. Accept a teardown failure only when every requested image was written
124
+ // in full and verified during the last attempt, before the reset banner.
125
+ export function flashCompleted(logFile, args = [], logOffset = 0) {
131
126
  let text
127
+ const expected = new Map()
132
128
  try {
133
- text = readFileSync(logFile, 'utf8')
129
+ text = readFileSync(logFile).subarray(logOffset).toString('utf8').replace(/\x1b\[[0-9;?]*[A-Za-z]/g, '').replace(/\r\n?/g, '\n')
130
+ const command = args.findIndex((arg) => arg === 'write-flash' || arg === 'write_flash')
131
+ if (command < 0) return false
132
+ for (let i = command + 1; i < args.length - 1; i += 1) {
133
+ if (!/^(?:0x[\da-f]+|\d+)$/i.test(args[i])) continue
134
+ expected.set(Number(args[i]), statSync(args[++i]).size)
135
+ }
134
136
  } catch {
135
137
  return false
136
138
  }
139
+ if (!expected.size) return false
137
140
  const attempts = text.split(/^(?=esptool v)/m)
138
- const last = attempts[attempts.length - 1].replace(/\x1b\[[0-9;?]*[A-Za-z]/g, '')
139
- return /^(Hard resetting|Staying in bootloader|Resetting with a watchdog)/m.test(last)
141
+ const lines = attempts.at(-1).split('\n')
142
+ const verified = new Set()
143
+ let pending = null
144
+ for (const line of lines) {
145
+ const writing = line.match(/^Writing .+ at (0x[\da-f]+)\.\.\./i)
146
+ if (writing) {
147
+ verified.delete(Number(writing[1]))
148
+ pending = null
149
+ }
150
+ const wrote = line.match(/^Wrote (\d+) bytes .* at (0x[\da-f]+)\b/i)
151
+ if (wrote) {
152
+ const offset = Number(wrote[2])
153
+ pending = expected.has(offset) && Number(wrote[1]) >= expected.get(offset) ? offset : null
154
+ }
155
+ if (/^Hash of data verified\.?$/.test(line) && pending !== null) {
156
+ verified.add(pending)
157
+ pending = null
158
+ }
159
+ if (/^Lost connection/.test(line)) {
160
+ verified.clear()
161
+ pending = null
162
+ }
163
+ if (/^(Hard resetting|Staying in bootloader|Resetting with a watchdog)/.test(line)) {
164
+ return verified.size === expected.size
165
+ }
166
+ }
167
+ return false
140
168
  }
141
169
 
142
170
  // esptool prints one "Wrote N bytes ... at 0x... in T seconds" line per
package/src/gea.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import fs from 'node:fs'
2
+ import { configCommand } from './commands/config.mjs'
2
3
 
3
4
  import { flag, option, parseArgs } from './args.mjs'
4
5
  import { runChips } from './chips.mjs'
@@ -170,6 +171,8 @@ export async function runGea(argv, io = {}) {
170
171
  }
171
172
 
172
173
  switch (command) {
174
+ case 'config':
175
+ return configCommand(ctx, parsed, rest, options)
173
176
  case 'doctor':
174
177
  return doctorCommand(ctx, parsed, rest, options)
175
178
  case 'setup':
@@ -257,6 +260,7 @@ ${heading('Native desktop, mobile and watch apps (scripts ship in @geastack/appl
257
260
  gea run --target pebble [app] [--phone <ip>] build, then install on the emery emulator or a watch via its phone
258
261
 
259
262
  ${heading('Build and deploy (device commands take --board <alias>, see gea boards list; with one registered board it can be left out):')}
263
+ gea config --board <alias> [--app <id>] effective build settings and their origins (JSON)
260
264
  gea build --board <alias> [--app <id>] build firmware (ESP-IDF / Pico SDK / geaos) [--verbose] [--output file.bin]
261
265
  gea flash --board <alias> [--app <id>] build + flash over USB [--monitor] [--manual-boot] [--no-reset] [--flash-baud N]
262
266
  --slot ota_N [--image file] stage an app image into an OTA slot only
@@ -1,4 +1,5 @@
1
1
  import { spawnSync } from 'node:child_process'
2
+ import { nativeScriptBuildEnv } from '../build-config.mjs'
2
3
  import { existsSync } from 'node:fs'
3
4
  import path from 'node:path'
4
5
 
@@ -74,6 +75,7 @@ function run(command, args, { cwd, env, dryRun, stdout, failureCode }) {
74
75
  }
75
76
 
76
77
  export function runGeaos({ ctx, selection, action, app = null, positionals = [], env, dryRun = false, stdout }) {
78
+ if (app && ['build', 'flash', 'flash-monitor'].includes(action)) env = nativeScriptBuildEnv(app, 'geaos', env, { dryRun, board: selection.target, targetsRoot: ctx.targetsRoot })
77
79
  const childEnv = geaosEnv(ctx, selection, env)
78
80
  const targetDir = selection.targetDir
79
81
  const appId = app?.id || positionals[0] || ''
@@ -1,3 +1,4 @@
1
+ import { nativeScriptBuildEnv } from '../build-config.mjs'
1
2
  import { spawnSync } from 'node:child_process'
2
3
 
3
4
  import { CliError, ExitCode, fail } from '../errors.mjs'
@@ -17,7 +18,7 @@ export function runIos({ app, env, dryRun = false, stdout, mode = '', run = fals
17
18
  fail(`--mode ${mode} is not an iOS destination; expected simulator or device.`, ExitCode.usage)
18
19
  }
19
20
  const { script, require } = appleTargetScript(app, 'ios', 'build-ios.sh')
20
- const childEnv = appleChildEnv(app, env, require)
21
+ const childEnv = appleChildEnv(app, nativeScriptBuildEnv(app, 'ios', env, { dryRun }), require)
21
22
  if (!run && childEnv.GEA_IOS_SKIP_LAUNCH === undefined) childEnv.GEA_IOS_SKIP_LAUNCH = '1'
22
23
  if (dryRun) {
23
24
  stdout(formatCommand(['bash', script, app.id, destination]))
@@ -1,3 +1,4 @@
1
+ import { nativeScriptBuildEnv } from '../build-config.mjs'
1
2
  import path from 'node:path'
2
3
  import { spawnSync } from 'node:child_process'
3
4
  import { existsSync, readFileSync } from 'node:fs'
@@ -14,7 +15,7 @@ import { formatCommand } from '../run.mjs'
14
15
  // and nothing else; the script reads the rest from the same manifest.
15
16
  export function runMacos({ app, env, dryRun = false, stdout }) {
16
17
  const { script, require } = appleTargetScript(app, 'macos', 'build-macos.sh')
17
- const childEnv = appleChildEnv(app, env, require)
18
+ const childEnv = appleChildEnv(app, nativeScriptBuildEnv(app, 'macos', env, { dryRun }), require)
18
19
  if (dryRun) {
19
20
  stdout(formatCommand(['bash', script, app.id]))
20
21
  return 0
package/src/manifest.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import path from 'node:path'
2
+ import { validateBuildManifest } from './build-config.mjs'
2
3
  import { createRequire } from 'node:module'
3
4
 
4
5
  import { loadBoardConfig, normalizeBoardConfig } from './boards/config.mjs'
@@ -73,6 +74,7 @@ export function findCurrentApp(cwd) {
73
74
 
74
75
  export function validateApp(app) {
75
76
  const errors = []
77
+ try { validateBuildManifest(app.manifest || {}) } catch (error) { errors.push(error.message) }
76
78
  if (!app.id) errors.push('gea.id is required')
77
79
  if (!app.entry) errors.push('gea.entry is required')
78
80
  if (app.entry && !exists(path.join(app.root, app.entry))) errors.push(`gea.entry does not exist: ${app.entry}`)
@@ -1,3 +1,4 @@
1
+ import { nativeScriptBuildEnv } from '../build-config.mjs'
1
2
  import path from 'node:path'
2
3
  import { spawnSync } from 'node:child_process'
3
4
  import { existsSync } from 'node:fs'
@@ -29,6 +30,7 @@ export function runPebble({ app, env, dryRun = false, stdout, phone = '', run =
29
30
  }
30
31
  const script = path.join(pebbleRoot, 'targets', 'pebble', 'build-pebble.sh')
31
32
  if (!existsSync(script)) fail(`Pebble build script not found: ${script}`, ExitCode.missingDependency)
33
+ env = nativeScriptBuildEnv(app, 'pebble', env, { dryRun })
32
34
  const args = pebbleBuildArgs(script, { app, phone, run })
33
35
  if (dryRun) {
34
36
  stdout(formatCommand(['bash', ...args]))
@@ -1,4 +1,5 @@
1
1
  import { spawnSync } from 'node:child_process'
2
+ import { resolveBuildConfig, writeBuildConfig } from '../build-config.mjs'
2
3
  import { existsSync, readdirSync } from 'node:fs'
3
4
  import os from 'node:os'
4
5
  import path from 'node:path'
@@ -102,10 +103,13 @@ export function rp2350BuildDir(ctx, selection) {
102
103
  }
103
104
 
104
105
  export function buildRp2350({ ctx, selection, app = null, env, dryRun = false, stdout, stderr, configureOnly = false }) {
106
+ const resolvedBuild = resolveBuildConfig({ app, platform: 'rp2350', board: selection.target, targetBase: selection.targetBase, targetsRoot: ctx.targetsRoot, env })
105
107
  const toolEnv = prepareArmToolchain(env, stderr)
106
108
  const cmake = cmakeBinary(toolEnv)
107
109
  const buildDir = rp2350BuildDir(ctx, selection)
108
- const configure = ['-S', selection.targetDir, '-B', buildDir]
110
+ const buildConfig = writeBuildConfig(buildDir, resolvedBuild)
111
+ const configure = ['-S', selection.targetDir, '-B', buildDir, `-DGEA_BUILD_CONFIG_FILE=${buildConfig.cmake}`, `-DGEA_BUILD_CONFIG_JSON=${buildConfig.json}`, `-DGEA_BUILD_CONFIG_HASH=${buildConfig.hash}`, `-DGEA_EMBEDDED_APP_DEFINES=${resolvedBuild.defines.join(';')}`]
112
+ if (resolvedBuild.cssDevicePixelRatio) configure.push(`-DGEA_EMBEDDED_CSS_DEVICE_PIXEL_RATIO=${resolvedBuild.cssDevicePixelRatio}`)
109
113
  const buildEnv = { ...toolEnv }
110
114
  if (app) {
111
115
  const meta = appCmakeMeta(ctx, app)
@@ -1,3 +1,4 @@
1
+ import { nativeScriptBuildEnv } from '../build-config.mjs'
1
2
  import path from 'node:path'
2
3
  import os from 'node:os'
3
4
  import { spawnSync } from 'node:child_process'
@@ -122,7 +123,7 @@ export function buildSimulatorApp({ app, env, dryRun = false, stdout }) {
122
123
  const paths = webPaths(app, env)
123
124
  runScript('bash', [script, app.id], {
124
125
  cwd: app.root,
125
- env: buildEnv(app, env, paths),
126
+ env: buildEnv(app, nativeScriptBuildEnv(app, 'web', env, { dryRun, buildDir: paths.root }), paths),
126
127
  dryRun,
127
128
  stdout,
128
129
  failureMessage: `Web build failed for '${app.id}'`
@@ -1,3 +1,4 @@
1
+ import { nativeScriptBuildEnv } from '../build-config.mjs'
1
2
  import path from 'node:path'
2
3
  import { spawnSync } from 'node:child_process'
3
4
  import { existsSync, readFileSync } from 'node:fs'
@@ -27,7 +28,7 @@ export function runWindows({ app, env, dryRun = false, stdout, run = false }) {
27
28
  // The script resolves the app through this CLI again; it is spawned with the
28
29
  // app's own folder as cwd, which is what createContext resolves a project
29
30
  // from, so an app outside a workspace resolves like any other.
30
- const childEnv = { ...env }
31
+ const childEnv = nativeScriptBuildEnv(app, 'windows', env, { dryRun })
31
32
  const plugins = geatscPluginsOf(app, require)
32
33
  if (plugins.length > 0) childEnv.GEA_EXTRA_GEATSC_PLUGINS = plugins.join(path.delimiter)
33
34
  const scriptArgs = [script, app.id, ...(run ? ['--run'] : [])]
@@ -1,3 +1,4 @@
1
+ import { nativeScriptBuildEnv } from '../build-config.mjs'
1
2
  import path from 'node:path'
2
3
  import { spawnSync } from 'node:child_process'
3
4
  import { existsSync } from 'node:fs'
@@ -7,6 +8,7 @@ import { formatCommand } from '../run.mjs'
7
8
  export function runXbox({ app, action, env, host = '', noBuild = false, dryRun = false, stdout }) {
8
9
  const configuration = app?.packageJson?.gea?.xbox
9
10
  if (!app || !configuration) fail('This app must declare gea.xbox buildScript and deployScript.', ExitCode.usage)
11
+ if (action === 'build' || !noBuild) env = nativeScriptBuildEnv(app, 'xbox', env, { dryRun })
10
12
  const commands = []
11
13
  const script = key => {
12
14
  const entry = configuration[key]