@geastack/cli 0.1.104 → 0.1.105
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/docs/SPEC.md +11 -1
- package/package.json +2 -2
- package/src/build-config.mjs +15 -0
- package/src/manifest.mjs +22 -1
- package/src/native-link.mjs +1 -1
- package/src/native-resources.mjs +1 -1
- package/src/windows/adapter.mjs +22 -8
package/docs/SPEC.md
CHANGED
|
@@ -287,9 +287,19 @@ same thing for any native target.
|
|
|
287
287
|
|
|
288
288
|
- `nativeSources` — C/C++/ObjC sources compiled into the board's main component.
|
|
289
289
|
Their directories become include paths.
|
|
290
|
+
- `targets.windows.nativeSources`, `nativeIncludeDirectories`,
|
|
291
|
+
`nativeSystemLibraries`, `nativeResources`, `providers`, `tsconfig`,
|
|
292
|
+
`prebuild` — the Windows target's own native sources (`.mm` included),
|
|
293
|
+
include directories, system import libraries, resource directories staged
|
|
294
|
+
into `Resources/<name>`, runtime providers for capabilities a package
|
|
295
|
+
requires, the TypeScript project the compiler reads the program under, and a
|
|
296
|
+
command run in the app folder before the build. The Windows target documents
|
|
297
|
+
their semantics and its typed `build.native` settings.
|
|
290
298
|
- `compilerPlugins` — the app's own geatsc plugins, e.g. one declaring the native
|
|
291
299
|
host functions its TSX calls. They are passed to the compiler for every native
|
|
292
|
-
target, because the boundary they describe is the app's, not a board's.
|
|
300
|
+
target, because the boundary they describe is the app's, not a board's. On
|
|
301
|
+
Windows they follow the plugins of the app's dependencies and its own
|
|
302
|
+
`geatsc-plugin.mjs`, which compose rather than replace each other.
|
|
293
303
|
- `defines` — preprocessor macros, as an object or as `NAME=value` strings; a
|
|
294
304
|
value of `true` emits a bare define and `false` drops the entry. These apply
|
|
295
305
|
to the **whole** native build: a macro that sizes a framework type changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geastack/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.105",
|
|
4
4
|
"description": "Command-line front door for GeaStack apps, targets, and local toolchains.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@clack/prompts": "^1.8.0",
|
|
40
40
|
"@geastack/simulator": "^0.1.15",
|
|
41
|
-
"@geastack/targets": "^0.1.
|
|
41
|
+
"@geastack/targets": "^0.1.105",
|
|
42
42
|
"picocolors": "^1.1.1",
|
|
43
43
|
"serialport": "^13.0.0"
|
|
44
44
|
},
|
package/src/build-config.mjs
CHANGED
|
@@ -31,6 +31,21 @@ export const buildOptions = {
|
|
|
31
31
|
'diagnostics.performanceCounters': { type: 'boolean', macro: 'GEA_EMBEDDED_PERF' },
|
|
32
32
|
'diagnostics.frameTiming': { type: 'boolean', macro: 'GEA_EMBEDDED_FRAME_SCHEDULER_PERF_LITE' },
|
|
33
33
|
'services.wifi': { values: ['auto', 'disabled'], macro: 'GEA_EMBEDDED_WIFI_DISABLED', encode: v => v === 'disabled' ? 1 : undefined },
|
|
34
|
+
// Native toolchain choices of desktop targets that compile and link the
|
|
35
|
+
// program themselves (see the target's documentation for each one's effect).
|
|
36
|
+
// Paths are relative to the app; patterns are regular expressions matched
|
|
37
|
+
// against a source's path with forward slashes.
|
|
38
|
+
'native.jobs': { type: 'integer', min: 0 },
|
|
39
|
+
'native.arch': { values: ['default', 'AVX2', 'AVX512'] },
|
|
40
|
+
'native.debugInfo': { type: 'boolean' },
|
|
41
|
+
'native.lto': { values: ['off', 'thin'] },
|
|
42
|
+
'native.ltoJobs': { type: 'integer', min: 0 },
|
|
43
|
+
'native.ltoCache': { type: 'string' },
|
|
44
|
+
'native.ltoExcludeSources': { type: 'string' },
|
|
45
|
+
'native.unoptimizedSources': { type: 'string' },
|
|
46
|
+
'native.pgo': { values: ['off', 'generate', 'use'] },
|
|
47
|
+
'native.pgoProfile': { type: 'string' },
|
|
48
|
+
'native.package': { values: ['none', 'zip'] },
|
|
34
49
|
}
|
|
35
50
|
const macros = new Map(Object.entries(buildOptions).filter(([, spec]) => spec.macro).map(([key, spec]) => [spec.macro, key]))
|
|
36
51
|
const removedEnvironment = {
|
package/src/manifest.mjs
CHANGED
|
@@ -90,6 +90,14 @@ export function validateApp(app) {
|
|
|
90
90
|
}
|
|
91
91
|
for (const [target, config] of Object.entries(app.targetConfig)) {
|
|
92
92
|
const where = (field) => `gea.targets.${target}.${field}`
|
|
93
|
+
if (config.nativeSources.length && !TARGET_NATIVE_SOURCE_TARGETS.includes(target)) errors.push(`${where('nativeSources')} is supported only by ${TARGET_NATIVE_SOURCE_TARGETS.join(', ')}; use gea.nativeSources for every target`)
|
|
94
|
+
for (const source of config.nativeSources) {
|
|
95
|
+
if (!resolveAppSourcePath(app.root, source)) errors.push(`${where('nativeSources')} entry does not exist: ${source}`)
|
|
96
|
+
}
|
|
97
|
+
if (config.providers !== null && (typeof config.providers !== 'object' || Array.isArray(config.providers))) errors.push(`${where('providers')} must be an object keyed by capability`)
|
|
98
|
+
else if (Object.keys(config.providers).length && !TARGET_PROVIDER_TARGETS.includes(target)) errors.push(`${where('providers')} is supported only by ${TARGET_PROVIDER_TARGETS.join(', ')}`)
|
|
99
|
+
if (config.tsconfig && !TARGET_NATIVE_SOURCE_TARGETS.includes(target)) errors.push(`${where('tsconfig')} is supported only by ${TARGET_NATIVE_SOURCE_TARGETS.join(', ')}`)
|
|
100
|
+
else if (config.tsconfig && !exists(path.join(app.root, config.tsconfig))) errors.push(`${where('tsconfig')} does not exist: ${config.tsconfig}`)
|
|
93
101
|
try { resolveNativeResources(app.root, target, config.nativeResources); resolveNativeLink(app.root, target, config) } catch (error) { errors.push(`${where('nativeLibraries/frameworks')}: ${error.message}`) }
|
|
94
102
|
for (const fragment of config.ldFragments) {
|
|
95
103
|
if (!exists(path.join(app.root, fragment))) errors.push(`${where('ldFragments')} entry does not exist: ${fragment}`)
|
|
@@ -235,6 +243,8 @@ export function appSummary(ctx, app) {
|
|
|
235
243
|
// Absolute, already resolved: a target consuming these must not re-join
|
|
236
244
|
// them to the app root, because a package entry does not live there.
|
|
237
245
|
nativeSourcePaths: app.nativeSources.map((source) => resolveAppSourcePath(app.root, source)).filter((resolved) => resolved !== null),
|
|
246
|
+
// The same for gea.targets.<target>.nativeSources, keyed by target.
|
|
247
|
+
targetNativeSourcePaths: Object.fromEntries(Object.entries(app.targetConfig).map(([target, config]) => [target, config.nativeSources.map((source) => resolveAppSourcePath(app.root, source)).filter((resolved) => resolved !== null)])),
|
|
238
248
|
compilerPlugins: app.compilerPlugins,
|
|
239
249
|
defines: app.defines,
|
|
240
250
|
cssDevicePixelRatio: app.cssDevicePixelRatio,
|
|
@@ -350,6 +360,14 @@ export function resolveAppSourcePath(root, source) {
|
|
|
350
360
|
}
|
|
351
361
|
}
|
|
352
362
|
|
|
363
|
+
// Targets whose build consumes per-target gea.targets.<target>.nativeSources,
|
|
364
|
+
// gea.targets.<target>.providers (runtime implementations a package requires,
|
|
365
|
+
// staged with the executable) and gea.targets.<target>.tsconfig (the
|
|
366
|
+
// TypeScript project the compiler reads the program under). The other targets
|
|
367
|
+
// take gea.nativeSources only.
|
|
368
|
+
const TARGET_NATIVE_SOURCE_TARGETS = ['windows']
|
|
369
|
+
const TARGET_PROVIDER_TARGETS = ['windows']
|
|
370
|
+
|
|
353
371
|
export function normalizeNativeSources(raw) {
|
|
354
372
|
if (!Array.isArray(raw)) return []
|
|
355
373
|
// Shared native code can live beside an app's directory. These are explicit
|
|
@@ -398,7 +416,7 @@ export function normalizeDefines(raw) {
|
|
|
398
416
|
|
|
399
417
|
|
|
400
418
|
function emptyTargetConfig() {
|
|
401
|
-
return { nativeIncludeDirectories: [], nativeSystemLibraries: [], nativeResources: {}, nativeLibraries: [], frameworks: [], ldFragments: [], componentDirs: [], componentRequires: [], linkOptions: [], embedFiles: {}, partitions: null, partitionsByTarget: {}, sdkconfig: '', prebuild: '', output: '' }
|
|
419
|
+
return { nativeSources: [], providers: {}, tsconfig: '', nativeIncludeDirectories: [], nativeSystemLibraries: [], nativeResources: {}, nativeLibraries: [], frameworks: [], ldFragments: [], componentDirs: [], componentRequires: [], linkOptions: [], embedFiles: {}, partitions: null, partitionsByTarget: {}, sdkconfig: '', prebuild: '', output: '' }
|
|
402
420
|
}
|
|
403
421
|
|
|
404
422
|
function normalizeStringList(raw) {
|
|
@@ -465,6 +483,9 @@ function normalizeTargetConfig(raw) {
|
|
|
465
483
|
for (const [name, value] of Object.entries(raw)) {
|
|
466
484
|
if (!name || !value || typeof value !== 'object' || value.enabled === false) continue
|
|
467
485
|
configs[name] = {
|
|
486
|
+
nativeSources: normalizeNativeSources(value.nativeSources),
|
|
487
|
+
providers: value.providers ?? {},
|
|
488
|
+
tsconfig: typeof value.tsconfig === 'string' && value.tsconfig.trim() ? normalizeManifestRelativePath(value.tsconfig) : '',
|
|
468
489
|
nativeIncludeDirectories: value.nativeIncludeDirectories ?? [],
|
|
469
490
|
nativeSystemLibraries: value.nativeSystemLibraries ?? [],
|
|
470
491
|
nativeResources: value.nativeResources ?? {},
|
package/src/native-link.mjs
CHANGED
|
@@ -12,7 +12,7 @@ export function resolveNativeLink(root, target, config = {}) {
|
|
|
12
12
|
}
|
|
13
13
|
if (libraries.length && !['macos', 'raspberry-pi-os'].includes(target)) throw new Error(`nativeLibraries are not supported by ${target}`)
|
|
14
14
|
if (frameworks.length && target !== 'macos') throw new Error('frameworks are supported only by macos')
|
|
15
|
-
if ((includeDirectories.length || systemLibraries.length) &&
|
|
15
|
+
if ((includeDirectories.length || systemLibraries.length) && !['raspberry-pi-os', 'windows'].includes(target)) throw new Error('Native include/system library extensions are supported only by raspberry-pi-os and windows')
|
|
16
16
|
const includes = includeDirectories.map(value => {
|
|
17
17
|
if (path.isAbsolute(value) || value.split(/[\\/]/).includes('..') || /[\x00-\x1f\x7f]/.test(value)) throw new Error('Invalid nativeIncludeDirectories entry')
|
|
18
18
|
const directory = fs.realpathSync(path.join(realRoot,value)), relative=path.relative(realRoot,directory)
|
package/src/native-resources.mjs
CHANGED
|
@@ -6,7 +6,7 @@ function fileHash(file){const fd=fs.openSync(file,'r'),hash=crypto.createHash('s
|
|
|
6
6
|
const safeName=value=>typeof value==='string' && /^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(value) && !['Fonts','FontLicenses','Frameworks','MacOS'].includes(value)
|
|
7
7
|
export function resolveNativeResources(root, target, raw = {}) {
|
|
8
8
|
if(!raw||typeof raw!=='object'||Array.isArray(raw))throw Error('nativeResources must be a destination-to-directory object')
|
|
9
|
-
if(Object.keys(raw).length && !['macos','raspberry-pi-os'].includes(target))throw Error(`nativeResources are not supported by ${target}`)
|
|
9
|
+
if(Object.keys(raw).length && !['macos','raspberry-pi-os','windows'].includes(target))throw Error(`nativeResources are not supported by ${target}`)
|
|
10
10
|
const base=fs.realpathSync(root),result={};let count=0,total=0
|
|
11
11
|
for(const [name,value]of Object.entries(raw)){
|
|
12
12
|
if(!safeName(name)||typeof value!=='string'||!value||path.isAbsolute(value)||value.split(/[\\/]/).includes('..')||/[\x00-\x1f\x7f]/.test(value))throw Error('Invalid nativeResources destination or source')
|
package/src/windows/adapter.mjs
CHANGED
|
@@ -32,28 +32,39 @@ export function runWindows({ app, env, dryRun = false, stdout, run = false }) {
|
|
|
32
32
|
const plugins = geatscPluginsOf(app, require)
|
|
33
33
|
if (plugins.length > 0) childEnv.GEA_EXTRA_GEATSC_PLUGINS = plugins.join(path.delimiter)
|
|
34
34
|
const scriptArgs = [script, app.id, ...(run ? ['--run'] : [])]
|
|
35
|
+
// gea.targets.windows.prebuild: a command run in the app folder before the
|
|
36
|
+
// build reads anything, e.g. one generating assets the build stages or
|
|
37
|
+
// sources it compiles (the manifest is validated after it).
|
|
38
|
+
const prebuild = app.targetConfig?.windows?.prebuild ?? ''
|
|
35
39
|
if (dryRun) {
|
|
40
|
+
if (prebuild) stdout(prebuild)
|
|
36
41
|
stdout(formatCommand(['node', ...scriptArgs]))
|
|
37
42
|
return 0
|
|
38
43
|
}
|
|
44
|
+
if (prebuild) {
|
|
45
|
+
stdout(`App prebuild: ${prebuild}`)
|
|
46
|
+
const step = spawnSync(prebuild, { cwd: app.root, env, shell: true, stdio: 'inherit' })
|
|
47
|
+
if (step.error) throw new CliError(`App prebuild failed to start: ${step.error.message}`, ExitCode.deployFailed)
|
|
48
|
+
if (step.status !== 0) throw new CliError(`App prebuild exited ${step.status ?? 1}: ${prebuild}`, ExitCode.deployFailed)
|
|
49
|
+
}
|
|
39
50
|
const result = spawnSync(process.execPath, scriptArgs, { cwd: app.root, env: childEnv, stdio: 'inherit' })
|
|
40
51
|
if (result.error) throw result.error
|
|
41
52
|
if (result.status !== 0) throw new CliError(`Windows build failed (${result.status ?? 1}).`, ExitCode.deployFailed)
|
|
42
53
|
return 0
|
|
43
54
|
}
|
|
44
55
|
|
|
45
|
-
// Compiler plugins
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
// Compiler plugins: every package the app depends on that ships a
|
|
57
|
+
// `./geatsc-plugin` export, then the app's own geatsc-plugin.mjs, then its
|
|
58
|
+
// gea.compilerPlugins (as on every native target). They compose: an app plugin
|
|
59
|
+
// declaring the app's own host functions does not displace the plugins of the
|
|
60
|
+
// packages the program uses, whose host functions it calls as well.
|
|
61
|
+
export function geatscPluginsOf(app, require) {
|
|
51
62
|
const plugins = []
|
|
52
63
|
let manifest = {}
|
|
53
64
|
try {
|
|
54
65
|
manifest = JSON.parse(readFileSync(path.join(app.root, 'package.json'), 'utf8'))
|
|
55
66
|
} catch {
|
|
56
|
-
|
|
67
|
+
manifest = {}
|
|
57
68
|
}
|
|
58
69
|
for (const name of Object.keys({ ...manifest.dependencies, ...manifest.devDependencies })) {
|
|
59
70
|
try {
|
|
@@ -62,5 +73,8 @@ function geatscPluginsOf(app, require) {
|
|
|
62
73
|
// The package ships no plugin, which is the normal case.
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
|
-
|
|
76
|
+
const own = path.join(app.root, 'geatsc-plugin.mjs')
|
|
77
|
+
if (existsSync(own)) plugins.push(own)
|
|
78
|
+
plugins.push(...(app.compilerPlugins ?? []).map((plugin) => path.join(app.root, plugin)))
|
|
79
|
+
return [...new Set(plugins)]
|
|
66
80
|
}
|