@geastack/cli 0.1.78 → 0.1.79
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/package.json +4 -4
- package/src/env-path.mjs +22 -0
- package/src/esp32/build.mjs +21 -8
- package/src/esp32/idf-env.mjs +14 -9
- package/src/rp2350/adapter.mjs +2 -1
- package/src/toolchain.mjs +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geastack/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.79",
|
|
4
4
|
"description": "Command-line front door for GeaStack apps, targets, and local toolchains.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@clack/prompts": "^1.8.0",
|
|
40
|
-
"@geastack/simulator": "^0.1.
|
|
40
|
+
"@geastack/simulator": "^0.1.6",
|
|
41
41
|
"picocolors": "^1.1.1",
|
|
42
42
|
"serialport": "^13.0.0"
|
|
43
43
|
},
|
|
44
44
|
"starterDependencies": {
|
|
45
|
-
"@geastack/core": "^0.1.
|
|
46
|
-
"@geastack/targets": "^0.1.
|
|
45
|
+
"@geastack/core": "^0.1.23",
|
|
46
|
+
"@geastack/targets": "^0.1.77"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"check": "node --check bin/gea.mjs && node --check bin/create-geastack.mjs && find src test packages -name '*.mjs' -print0 | xargs -0 -n1 node --check",
|
package/src/env-path.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// PATH is spelled `Path` in a Windows environment. process.env answers
|
|
2
|
+
// `env.PATH` regardless because Node makes it case-insensitive there, but a
|
|
3
|
+
// plain object copied from it (`{ ...process.env, GEA_X: ... }`, which is how
|
|
4
|
+
// every child environment in this CLI is built) keeps the original key only,
|
|
5
|
+
// and `env.PATH` on that copy is undefined. Writing `PATH` next to `Path`
|
|
6
|
+
// then leaves two keys, and the child process picks one of them: on Windows
|
|
7
|
+
// it took the freshly written one, which held only the ESP-IDF tool dirs, so
|
|
8
|
+
// cmake could not find node or git and no ESP32 target could configure.
|
|
9
|
+
// Every read and write of PATH goes through here so there is only ever one
|
|
10
|
+
// key, whatever it is called.
|
|
11
|
+
export function envPathKey(env = process.env) {
|
|
12
|
+
if (Object.prototype.hasOwnProperty.call(env, 'PATH')) return 'PATH'
|
|
13
|
+
return Object.keys(env).find((key) => key.toUpperCase() === 'PATH') || 'PATH'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function envPath(env = process.env) {
|
|
17
|
+
return String(env[envPathKey(env)] || '')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function withEnvPath(env, value) {
|
|
21
|
+
return { ...env, [envPathKey(env)]: value }
|
|
22
|
+
}
|
package/src/esp32/build.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { listAppSources } from './source-set.mjs'
|
|
|
14
14
|
import { writeFlashPlan } from './partitions.mjs'
|
|
15
15
|
import { generateWifiConfig } from './wifi-config.mjs'
|
|
16
16
|
import { hint, warn } from '../report.mjs'
|
|
17
|
+
import { envPath } from '../env-path.mjs'
|
|
17
18
|
|
|
18
19
|
// The ESP-IDF build. Everything the old bash board script decided about a
|
|
19
20
|
// build lives here: where the build directory is, what the app-local
|
|
@@ -80,7 +81,9 @@ export function applySdkconfigPolicy(sdkconfig, { selection, app, capabilities,
|
|
|
80
81
|
unset('CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE')
|
|
81
82
|
unset('CONFIG_PARTITION_TABLE_TWO_OTA')
|
|
82
83
|
set('CONFIG_PARTITION_TABLE_CUSTOM', 'y')
|
|
83
|
-
|
|
84
|
+
// sdkconfig is read by Kconfig and CMake, both of which treat a backslash
|
|
85
|
+
// as an escape; a Windows path loses every separator on the way through.
|
|
86
|
+
set('CONFIG_PARTITION_TABLE_CUSTOM_FILENAME', `"${cmakeValue(partitionCsv)}"`)
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
// The console transport follows the board's wiring. A module reached over a
|
|
@@ -341,7 +344,7 @@ export function prepareEsp32Build({ ctx, selection, app = null, env = ctx.env ||
|
|
|
341
344
|
catalog: loadChipCatalogFromDir(ctx.chipsPackageDir),
|
|
342
345
|
appDefines: new Set((app?.defines || []).map((define) => define.split('=')[0]))
|
|
343
346
|
})
|
|
344
|
-
idfArgs.push(`-DGEA_BOARD_DEFINITION=${selection.targetDefinition}`, `-DGEA_CUSTOM_TARGET_DIR=${outDir}`)
|
|
347
|
+
idfArgs.push(`-DGEA_BOARD_DEFINITION=${cmakeValue(selection.targetDefinition)}`, `-DGEA_CUSTOM_TARGET_DIR=${cmakeValue(outDir)}`)
|
|
345
348
|
childEnv.GEA_BOARD_DEFINITION = selection.targetDefinition
|
|
346
349
|
childEnv.GEA_CUSTOM_TARGET_DIR = outDir
|
|
347
350
|
boardPartitionCsv = generated.partitionCsv
|
|
@@ -438,9 +441,9 @@ function preparePartitions(app, config, buildDir, targetId) {
|
|
|
438
441
|
// the native host functions its TSX calls.
|
|
439
442
|
GEA_EMBEDDED_APP_GEATSC_PLUGINS: app.compilerPlugins.map((plugin) => path.join(app.root, plugin)).join(';')
|
|
440
443
|
}
|
|
441
|
-
idfArgs.push(`-DGEA_EMBEDDED_APP=${app.id}`, `-DGEA_EMBEDDED_APP_META=${meta}`)
|
|
444
|
+
idfArgs.push(`-DGEA_EMBEDDED_APP=${app.id}`, `-DGEA_EMBEDDED_APP_META=${cmakeValue(meta)}`)
|
|
442
445
|
if (cssDpr) idfArgs.push(`-DGEA_EMBEDDED_CSS_DEVICE_PIXEL_RATIO=${cssDpr}`)
|
|
443
|
-
for (const [name, value] of Object.entries(appNative)) if (value) idfArgs.push(`-D${name}=${value}`)
|
|
446
|
+
for (const [name, value] of Object.entries(appNative)) if (value) idfArgs.push(`-D${name}=${cmakeValue(value)}`)
|
|
444
447
|
idfArgs.push(
|
|
445
448
|
`-DGEA_EMBEDDED_CAPABILITY_NETWORK=${capabilities.network ? 1 : 0}`,
|
|
446
449
|
`-DGEA_EMBEDDED_CAPABILITY_BLE=${capabilities.ble ? 1 : 0}`,
|
|
@@ -450,8 +453,8 @@ function preparePartitions(app, config, buildDir, targetId) {
|
|
|
450
453
|
// CMake cache propagation; environment values stay visible there, so
|
|
451
454
|
// conditional components such as bt enter the dependency graph.
|
|
452
455
|
childEnv.GEA_EMBEDDED_APP = app.id
|
|
453
|
-
childEnv.GEA_EMBEDDED_APP_META = meta
|
|
454
|
-
for (const [name, value] of Object.entries(appNative)) if (value) childEnv[name] = value
|
|
456
|
+
childEnv.GEA_EMBEDDED_APP_META = cmakeValue(meta)
|
|
457
|
+
for (const [name, value] of Object.entries(appNative)) if (value) childEnv[name] = cmakeValue(value)
|
|
455
458
|
childEnv.GEA_EMBEDDED_CAPABILITY_NETWORK = capabilities.network ? '1' : '0'
|
|
456
459
|
childEnv.GEA_EMBEDDED_CAPABILITY_BLE = capabilities.ble ? '1' : '0'
|
|
457
460
|
childEnv.GEA_EMBEDDED_CAPABILITY_AUDIO = capabilities.audio ? '1' : '0'
|
|
@@ -486,8 +489,18 @@ function executableNames(name, env) {
|
|
|
486
489
|
return [name, ...extensions.map((extension) => name + extension)]
|
|
487
490
|
}
|
|
488
491
|
|
|
492
|
+
// A path handed to CMake on its command line, or through the environment
|
|
493
|
+
// the component-requirements pass reads. Windows paths carry backslashes,
|
|
494
|
+
// and ESP-IDF re-parses the registered sources as CMake code during that
|
|
495
|
+
// pass, where `C:\Users` is an invalid character escape and configure
|
|
496
|
+
// dies. CMake accepts forward slashes on every platform, so the CLI never
|
|
497
|
+
// hands it a backslash.
|
|
498
|
+
export function cmakeValue(value, platform = process.platform) {
|
|
499
|
+
return platform === 'win32' ? String(value).replace(/\\/g, '/') : String(value)
|
|
500
|
+
}
|
|
501
|
+
|
|
489
502
|
function commandExists(name, env) {
|
|
490
|
-
const dirs =
|
|
503
|
+
const dirs = envPath(env).split(path.delimiter).filter(Boolean)
|
|
491
504
|
const names = executableNames(name, env)
|
|
492
505
|
return dirs.some((dir) => names.some((candidate) => existsSync(path.join(dir, candidate))))
|
|
493
506
|
}
|
|
@@ -511,7 +524,7 @@ export function configureArguments(prepared, env) {
|
|
|
511
524
|
}
|
|
512
525
|
args.push('-G', generator)
|
|
513
526
|
}
|
|
514
|
-
args.push('-B', prepared.buildDir, `-DSDKCONFIG=${prepared.sdkconfigFile}`, `-DSDKCONFIG_DEFAULTS=${prepared.defaultsArg || prepared.defaultsFile}`)
|
|
527
|
+
args.push('-B', cmakeValue(prepared.buildDir), `-DSDKCONFIG=${cmakeValue(prepared.sdkconfigFile)}`, `-DSDKCONFIG_DEFAULTS=${cmakeValue(prepared.defaultsArg || prepared.defaultsFile)}`)
|
|
515
528
|
return args
|
|
516
529
|
}
|
|
517
530
|
|
package/src/esp32/idf-env.mjs
CHANGED
|
@@ -3,6 +3,8 @@ import { existsSync, readdirSync, readFileSync } from 'node:fs'
|
|
|
3
3
|
import os from 'node:os'
|
|
4
4
|
import path from 'node:path'
|
|
5
5
|
|
|
6
|
+
import { envPath, withEnvPath } from '../env-path.mjs'
|
|
7
|
+
|
|
6
8
|
// ESP-IDF activation without `source export.sh`. export.sh re-checks Python,
|
|
7
9
|
// dependencies, outdated tools and shell completion on every invocation; the
|
|
8
10
|
// installation itself already knows the exact tool paths (idf_tools.py
|
|
@@ -157,21 +159,24 @@ export function activateEspIdf({ env = process.env, home = os.homedir(), log = (
|
|
|
157
159
|
activationCache.set(cacheKey, exported)
|
|
158
160
|
log(`Using ESP-IDF ${espIdfVersion(idfDir)?.full || ''} at ${idfDir} (python env ${pythonEnv})`)
|
|
159
161
|
}
|
|
160
|
-
const
|
|
162
|
+
const callerPath = envPath(env)
|
|
163
|
+
const exportedPath = (exported.PATH || '').replace(/\$PATH|%PATH%/g, callerPath)
|
|
161
164
|
return {
|
|
162
165
|
idfDir,
|
|
163
166
|
version: espIdfVersion(idfDir),
|
|
164
167
|
pythonEnv,
|
|
165
168
|
python,
|
|
166
169
|
idfPy: path.join(idfDir, 'tools', 'idf.py'),
|
|
167
|
-
env:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
env: withEnvPath(
|
|
171
|
+
{
|
|
172
|
+
...env,
|
|
173
|
+
...Object.fromEntries(Object.entries(exported).filter(([key]) => key !== 'PATH' && key !== 'IDF_DEACTIVATE_FILE_PATH')),
|
|
174
|
+
IDF_PATH: idfDir,
|
|
175
|
+
IDF_PYTHON_ENV_PATH: pythonEnv,
|
|
176
|
+
VIRTUAL_ENV: pythonEnv
|
|
177
|
+
},
|
|
178
|
+
[path.join(pythonEnv, venvBin), exportedPath || callerPath].filter(Boolean).join(path.delimiter)
|
|
179
|
+
)
|
|
175
180
|
}
|
|
176
181
|
}
|
|
177
182
|
|
package/src/rp2350/adapter.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import path from 'node:path'
|
|
|
5
5
|
|
|
6
6
|
import { resolvePicotoolSelection } from '../boards/usb.mjs'
|
|
7
7
|
import { CliError, ExitCode, fail } from '../errors.mjs'
|
|
8
|
+
import { envPath } from '../env-path.mjs'
|
|
8
9
|
import { appCmakeMeta } from '../manifest.mjs'
|
|
9
10
|
import { formatCommand } from '../run.mjs'
|
|
10
11
|
|
|
@@ -71,7 +72,7 @@ export function prepareArmToolchain(env, stderr = () => {}) {
|
|
|
71
72
|
|
|
72
73
|
export function cmakeBinary(env) {
|
|
73
74
|
if (env.CMAKE) return env.CMAKE
|
|
74
|
-
for (const dir of
|
|
75
|
+
for (const dir of envPath(env).split(path.delimiter)) {
|
|
75
76
|
if (dir && existsSync(path.join(dir, 'cmake'))) return path.join(dir, 'cmake')
|
|
76
77
|
}
|
|
77
78
|
for (const candidate of ['/opt/homebrew/bin/cmake', '/usr/local/bin/cmake', '/Applications/CMake.app/Contents/bin/cmake']) {
|
package/src/toolchain.mjs
CHANGED
|
@@ -2,6 +2,8 @@ import path from 'node:path'
|
|
|
2
2
|
import { execFileSync } from 'node:child_process'
|
|
3
3
|
import { existsSync } from 'node:fs'
|
|
4
4
|
|
|
5
|
+
import { envPath } from './env-path.mjs'
|
|
6
|
+
|
|
5
7
|
export function nodeAtLeast(major, minor) {
|
|
6
8
|
const [actualMajor, actualMinor] = process.versions.node.split('.').map((value) => Number.parseInt(value, 10))
|
|
7
9
|
return actualMajor > major || (actualMajor === major && actualMinor >= minor)
|
|
@@ -21,7 +23,7 @@ export function commandVersion(command, args, env = process.env) {
|
|
|
21
23
|
// it -- a toolchain a build needs is worth failing on before the build starts,
|
|
22
24
|
// with the same answer doctor would have given.
|
|
23
25
|
export function onPath(name, env = process.env) {
|
|
24
|
-
return
|
|
26
|
+
return envPath(env)
|
|
25
27
|
.split(path.delimiter)
|
|
26
28
|
.some((dir) => dir && existsSync(path.join(dir, name)))
|
|
27
29
|
}
|