@typecad/cuttlefish 0.1.0-alpha.2 → 1.0.0-alpha.11
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 +10 -10
- package/dist/api/board-types.d.ts +1 -1
- package/dist/api/config.d.ts +38 -2
- package/dist/api/index.d.ts +1 -1
- package/dist/api/schema/types.d.ts +15 -0
- package/dist/api/shared/async-runtime-static.d.ts +12 -1
- package/dist/api/shared/async-runtime-static.js +69 -24
- package/dist/api/shared/async-symbol-detector.d.ts +11 -0
- package/dist/api/shared/async-symbol-detector.js +140 -0
- package/dist/api/shared/async-types.d.ts +24 -0
- package/dist/api/shared/coop-scheduler.d.ts +60 -0
- package/dist/api/shared/coop-scheduler.js +149 -0
- package/dist/api/shared/display-adapter.d.ts +4 -3
- package/dist/api/shared/display-adapter.js +15 -118
- package/dist/api/shared/display-adapters/sdl.js +38 -31
- package/dist/api/shared/display-profile.d.ts +47 -25
- package/dist/api/shared/display-profile.js +31 -164
- package/dist/api/shared/framework-manifest-registry.d.ts +9 -0
- package/dist/api/shared/framework-manifest-registry.js +27 -0
- package/dist/api/shared/framework-manifest.d.ts +595 -0
- package/dist/api/shared/framework-manifest.js +193 -0
- package/dist/api/shared/glcdfont.d.ts +12 -0
- package/dist/api/shared/glcdfont.js +124 -0
- package/dist/api/shared/graphics-strategy.d.ts +37 -0
- package/dist/api/shared/hal-op-ir.d.ts +764 -1
- package/dist/api/shared/hal-op-ir.js +129 -1
- package/dist/api/shared/index.d.ts +22 -2
- package/dist/api/shared/index.js +26 -1
- package/dist/api/shared/ir-core.d.ts +4 -0
- package/dist/api/shared/ir-declarations.d.ts +6 -0
- package/dist/api/shared/native-display-op-resolver.d.ts +10 -0
- package/dist/api/shared/native-display-op-resolver.js +64 -0
- package/dist/api/shared/platform-strategy.d.ts +119 -2
- package/dist/api/shared/polyfill-helper-registry.js +18 -1
- package/dist/api/shared/promise-runtime.d.ts +1 -1
- package/dist/api/shared/promise-runtime.js +95 -13
- package/dist/api/shared/spdx-licenses.d.ts +139 -0
- package/dist/api/shared/spdx-licenses.js +385 -0
- package/dist/api/shared/toolchain-types.d.ts +17 -0
- package/dist/api/shared/types.d.ts +8 -0
- package/dist/api/shared/validate-framework-manifest.d.ts +28 -0
- package/dist/api/shared/validate-framework-manifest.js +494 -0
- package/dist/api/shared/worker-runtime-polyfill.d.ts +22 -0
- package/dist/api/shared/worker-runtime-polyfill.js +34 -0
- package/dist/api/shared/worker-runtime.d.ts +69 -0
- package/dist/api/shared/worker-runtime.js +163 -0
- package/dist/cli-utils.d.ts +1 -0
- package/dist/cli-utils.js +3 -1
- package/dist/cli.js +249 -32
- package/dist/config-loader.d.ts +7 -2
- package/dist/config-loader.js +23 -3
- package/dist/config-schema.d.ts +112 -70
- package/dist/config-schema.js +14 -0
- package/dist/contract/board-generator.d.ts +17 -0
- package/dist/contract/board-generator.js +57 -0
- package/dist/contract/contract-parser.d.ts +217 -0
- package/dist/contract/contract-parser.js +224 -0
- package/dist/contract/index.d.ts +22 -0
- package/dist/contract/index.js +68 -0
- package/dist/create/board-codegen.js +4 -4
- package/dist/create/board-generators.js +4 -5
- package/dist/create/board-spec.d.ts +72 -75
- package/dist/create/board-spec.js +0 -1
- package/dist/create/framework-catalog.d.ts +64 -0
- package/dist/create/framework-catalog.js +136 -0
- package/dist/create/index.d.ts +5 -1
- package/dist/create/index.js +3 -1
- package/dist/create/init-scaffold.d.ts +12 -3
- package/dist/create/init-scaffold.js +49 -14
- package/dist/create/init-templates.d.ts +4 -0
- package/dist/create/init-templates.js +271 -17
- package/dist/create/init-wizard.js +41 -27
- package/dist/create/install-deps.d.ts +32 -0
- package/dist/create/install-deps.js +46 -0
- package/dist/debug/preprocessor.js +178 -39
- package/dist/debug/types.d.ts +23 -0
- package/dist/diagnostics/mermaid-builder.d.ts +1 -1
- package/dist/diagnostics/mermaid-builder.js +34 -24
- package/dist/emit/compliance/arxml-writer.d.ts +11 -0
- package/dist/emit/compliance/arxml-writer.js +34 -0
- package/dist/emit/compliance/compliance-context.d.ts +57 -0
- package/dist/emit/compliance/compliance-context.js +113 -0
- package/dist/emit/compliance/deviation-ledger.d.ts +27 -0
- package/dist/emit/compliance/deviation-ledger.js +47 -0
- package/dist/emit/compliance/deviation-writer.d.ts +30 -0
- package/dist/emit/compliance/deviation-writer.js +37 -0
- package/dist/emit/compliance/index.d.ts +7 -0
- package/dist/emit/compliance/index.js +6 -0
- package/dist/emit/compliance/rule-engine.d.ts +13 -0
- package/dist/emit/compliance/rule-engine.js +101 -0
- package/dist/emit/compliance/rules.d.ts +16 -0
- package/dist/emit/compliance/rules.js +191 -0
- package/dist/emit/compliance/types.d.ts +59 -0
- package/dist/emit/compliance/types.js +8 -0
- package/dist/emit/cpp-emitter.js +4 -3
- package/dist/emit/emitters/class-emitter.js +6 -1
- package/dist/emit/emitters/emitter-context.d.ts +28 -1
- package/dist/emit/emitters/function-emitter-impl.js +153 -53
- package/dist/emit/emitters/line-appender.js +19 -0
- package/dist/emit/emitters/line-marker.d.ts +38 -0
- package/dist/emit/emitters/line-marker.js +39 -0
- package/dist/emit/emitters/output-finalizer.d.ts +6 -0
- package/dist/emit/emitters/output-finalizer.js +101 -12
- package/dist/emit/emitters/setup.d.ts +17 -0
- package/dist/emit/emitters/setup.js +372 -30
- package/dist/emit/emitters/top-level-prep.js +8 -0
- package/dist/emit/emitters/type-decl-emitter.js +28 -3
- package/dist/emit/emitters/ui-emitter.js +33 -9
- package/dist/emit/expression-renderer.d.ts +1 -1
- package/dist/emit/expression-renderer.js +91 -6
- package/dist/emit/route-hal-op.js +18 -5
- package/dist/emit/snprintf-helpers.js +15 -4
- package/dist/emit/statement-renderer.d.ts +10 -0
- package/dist/emit/statement-renderer.js +34 -5
- package/dist/emit/utils/async-state-machine.js +221 -125
- package/dist/emit/utils/hal-op-cpp-type.d.ts +6 -0
- package/dist/emit/utils/hal-op-cpp-type.js +40 -0
- package/dist/framework-package.js +2 -0
- package/dist/framework-registry.d.ts +17 -0
- package/dist/install/framework-catalog.d.ts +53 -0
- package/dist/install/framework-catalog.js +107 -0
- package/dist/install/handle-install.d.ts +35 -0
- package/dist/install/handle-install.js +177 -0
- package/dist/install/index.d.ts +4 -0
- package/dist/install/index.js +3 -0
- package/dist/ir/adc-range-validation.js +40 -26
- package/dist/ir/build-ir-state.d.ts +1 -0
- package/dist/ir/build-ir-state.js +14 -0
- package/dist/ir/build-ir.js +9 -5
- package/dist/ir/call-graph.js +16 -0
- package/dist/ir/expression-to-ir.js +207 -6
- package/dist/ir/feature-registry.js +7 -25
- package/dist/ir/function-builder.js +22 -0
- package/dist/ir/hal/hal-emitter.d.ts +5 -2
- package/dist/ir/hal/hal-emitter.js +50 -18
- package/dist/ir/hal/hal-parser.d.ts +6 -0
- package/dist/ir/hal/hal-parser.js +81 -0
- package/dist/ir/hal/hal-plugins.js +733 -1
- package/dist/ir/identifier-collector.js +35 -0
- package/dist/ir/interrupt-analysis.d.ts +5 -1
- package/dist/ir/interrupt-analysis.js +16 -19
- package/dist/ir/memory-budget-validation.js +1 -0
- package/dist/ir/network-validation.d.ts +4 -0
- package/dist/ir/network-validation.js +184 -0
- package/dist/ir/ownership-analysis.js +39 -1
- package/dist/ir/peripheral-ownership.js +5 -0
- package/dist/ir/peripheral-validation.d.ts +1 -1
- package/dist/ir/peripheral-validation.js +6 -3
- package/dist/ir/pin-alias-conflict.d.ts +1 -1
- package/dist/ir/pin-alias-conflict.js +2 -1
- package/dist/ir/pin-capability-validation.js +71 -32
- package/dist/ir/pin-mode-validation.d.ts +2 -2
- package/dist/ir/pin-mode-validation.js +54 -18
- package/dist/ir/pin-safety.d.ts +1 -1
- package/dist/ir/pin-safety.js +2 -1
- package/dist/ir/program-analysis.d.ts +81 -0
- package/dist/ir/program-analysis.js +429 -0
- package/dist/ir/pulldown-validation.d.ts +1 -1
- package/dist/ir/pulldown-validation.js +2 -1
- package/dist/ir/pwm-timer-sharing.d.ts +1 -1
- package/dist/ir/pwm-timer-sharing.js +2 -1
- package/dist/ir/render-expr.js +11 -0
- package/dist/ir/resource-analysis.js +2 -0
- package/dist/ir/timer0-pwm-timing-conflict.d.ts +1 -1
- package/dist/ir/timer0-pwm-timing-conflict.js +2 -1
- package/dist/ir/timing-validation.d.ts +6 -1
- package/dist/ir/timing-validation.js +61 -13
- package/dist/ir/transformers/call-statement.js +105 -0
- package/dist/ir/transformers/expressions.js +62 -0
- package/dist/ir/transformers/hal-call-resolver.js +21 -0
- package/dist/ir/transformers/hal-emit-helpers.js +1 -1
- package/dist/ir/transformers/namespace-methods.js +17 -12
- package/dist/ir/transformers/ui-reactive.js +2 -2
- package/dist/ir/transformers/variables.js +137 -19
- package/dist/ir/try-catch-validation.js +2 -0
- package/dist/ir/type-resolution.js +20 -2
- package/dist/ir/ui-element-auto-wire.js +7 -5
- package/dist/ir/unit-suspicion-validation.js +9 -7
- package/dist/ir/utils/map-statements.d.ts +4 -0
- package/dist/ir/utils/map-statements.js +79 -0
- package/dist/ir/validation-orchestrator.js +15 -8
- package/dist/ir/worker-analysis.d.ts +10 -0
- package/dist/ir/worker-analysis.js +261 -0
- package/dist/libdef/c-to-decl.d.ts +27 -0
- package/dist/libdef/c-to-decl.js +397 -0
- package/dist/libdef/component-decls.d.ts +2 -0
- package/dist/libdef/component-decls.js +6 -0
- package/dist/libdef/component-discovery.d.ts +43 -0
- package/dist/libdef/component-discovery.js +83 -0
- package/dist/libdef/cpp-to-decl.d.ts +9 -0
- package/dist/libdef/cpp-to-decl.js +72 -0
- package/dist/libdef/registry.js +5 -2
- package/dist/lint-cache.d.ts +59 -0
- package/dist/lint-cache.js +257 -0
- package/dist/orchestrator/graph-builder.js +14 -9
- package/dist/platform/coop-scheduler-runtime.d.ts +19 -0
- package/dist/platform/coop-scheduler-runtime.js +41 -0
- package/dist/platform/generic-strategy.d.ts +15 -3
- package/dist/platform/generic-strategy.js +49 -4
- package/dist/safety/safety-bridge.d.ts +11 -0
- package/dist/safety/safety-bridge.js +48 -0
- package/dist/safety/sidecar-bridge.d.ts +5 -0
- package/dist/safety/sidecar-bridge.js +22 -0
- package/dist/safety-hook.d.ts +79 -0
- package/dist/safety-hook.js +35 -0
- package/dist/testing.d.ts +8 -2
- package/dist/testing.js +9 -2
- package/dist/transpile.d.ts +3 -0
- package/dist/transpile.js +191 -49
- package/dist/types.d.ts +22 -3
- package/dist/ui-hook.d.ts +17 -3
- package/dist/utils/cli.js +123 -2
- package/dist/utils/fs.d.ts +13 -0
- package/dist/utils/fs.js +50 -0
- package/dist/utils/ui.js +3 -1
- package/package.json +23 -3
- package/dist/api/shared/display-adapters/eink-mono.d.ts +0 -2
- package/dist/api/shared/display-adapters/eink-mono.js +0 -53
- package/dist/api/shared/display-adapters/ssd1309.d.ts +0 -2
- package/dist/api/shared/display-adapters/ssd1309.js +0 -136
- package/dist/api/shared/display-adapters/st7796.d.ts +0 -2
- package/dist/api/shared/display-adapters/st7796.js +0 -132
- package/dist/ir/heap-array-validation.d.ts +0 -24
- package/dist/ir/heap-array-validation.js +0 -29
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TargetProfile as CoreTargetProfile, PlatformContext as CorePlatformContext, SourceSpan as CoreSourceSpan, Diagnostic as CoreDiagnostic } from "./api/shared/index.js";
|
|
2
2
|
export type EmitMode = "cpp" | "split";
|
|
3
|
+
export type ComplianceMode = "off" | "warn" | "strict";
|
|
3
4
|
export type TargetProfile = CoreTargetProfile;
|
|
4
5
|
export type PlatformContext = CorePlatformContext;
|
|
5
6
|
export type SourceSpan = CoreSourceSpan;
|
|
@@ -95,6 +96,10 @@ export interface TranspileOptions {
|
|
|
95
96
|
diagnostics?: boolean;
|
|
96
97
|
/** Display profile config from cuttlefish.config.ts */
|
|
97
98
|
display?: import("./api/shared/display-profile.js").DisplayConfig;
|
|
99
|
+
/** AUTOSAR C++14 compliance mode for emitted code (default: "off"). */
|
|
100
|
+
autosar?: ComplianceMode;
|
|
101
|
+
/** When true (and autosar is warn/strict), also emit the .autosar-deviations.arxml sidecar. */
|
|
102
|
+
autosarArxml?: boolean;
|
|
98
103
|
}
|
|
99
104
|
export interface LibraryDefinitionCondition {
|
|
100
105
|
target?: TargetProfile;
|
|
@@ -114,7 +119,11 @@ export interface LibraryDefinition {
|
|
|
114
119
|
variants?: LibraryDefinitionVariant[];
|
|
115
120
|
}
|
|
116
121
|
export interface CommandLineOptions {
|
|
117
|
-
command: "default" | "build" | "gen-libdefs" | "gen-decls" | "map-error" | "preview";
|
|
122
|
+
command: "default" | "build" | "gen-libdefs" | "gen-decls" | "map-error" | "preview" | "doctor" | "licenses";
|
|
123
|
+
/** For `licenses`: treat unknown/missing licenses as failures (exit 1). */
|
|
124
|
+
strict?: boolean;
|
|
125
|
+
/** For `licenses`: scan all installed libraries (default: this project's only). */
|
|
126
|
+
all?: boolean;
|
|
118
127
|
inputFile?: string;
|
|
119
128
|
emitMode: EmitMode;
|
|
120
129
|
target: TargetProfile;
|
|
@@ -130,8 +139,10 @@ export interface CommandLineOptions {
|
|
|
130
139
|
monitor: boolean;
|
|
131
140
|
/** Serial port for upload and monitor (e.g. COM4 or /dev/ttyACM0) */
|
|
132
141
|
port?: string;
|
|
133
|
-
/** Baud rate for monitor
|
|
134
|
-
|
|
142
|
+
/** Baud rate for monitor. Undefined when --baud is absent so the consumer
|
|
143
|
+
* can fall back to config.console.baudRate (the framework monitor default
|
|
144
|
+
* applies only when neither is set). */
|
|
145
|
+
baud?: number;
|
|
135
146
|
platformContext?: PlatformContext;
|
|
136
147
|
mapFile?: string;
|
|
137
148
|
cppFile?: string;
|
|
@@ -164,6 +175,10 @@ export interface CommandLineOptions {
|
|
|
164
175
|
expectFile?: string;
|
|
165
176
|
/** Generate diagnostics.md and diagnostics.json reports */
|
|
166
177
|
diagnostics?: boolean;
|
|
178
|
+
/** AUTOSAR C++14 compliance mode for emitted code (default: "off"). */
|
|
179
|
+
autosar?: ComplianceMode;
|
|
180
|
+
/** When true (and autosar is warn/strict), also emit the .autosar-deviations.arxml sidecar. */
|
|
181
|
+
autosarArxml?: boolean;
|
|
167
182
|
/** Config file for preview command */
|
|
168
183
|
configPath?: string;
|
|
169
184
|
/** Project root (dir of cuttlefish.config.ts); passed to transpileFile for the ESLint gate. */
|
|
@@ -181,6 +196,8 @@ export interface GeneratedOutputs {
|
|
|
181
196
|
diagnostics: Diagnostic[];
|
|
182
197
|
asyncTaskNames?: string[];
|
|
183
198
|
usesTimers?: boolean;
|
|
199
|
+
/** Path to the diagnostics.md report, if --diagnostics was passed. */
|
|
200
|
+
diagnosticsReportPath?: string;
|
|
184
201
|
}
|
|
185
202
|
interface CompileErrorEntry {
|
|
186
203
|
filePath: string;
|
|
@@ -208,6 +225,8 @@ export interface CreateCommandOptions {
|
|
|
208
225
|
baud?: number;
|
|
209
226
|
noSketch?: boolean;
|
|
210
227
|
outDir?: string;
|
|
228
|
+
/** Skip the automatic `npm install` in the scaffolded project. */
|
|
229
|
+
noInstall?: boolean;
|
|
211
230
|
}
|
|
212
231
|
export interface BoardAddCommandOptions {
|
|
213
232
|
command: "board-add";
|
package/dist/ui-hook.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export interface LoweredUI {
|
|
|
9
9
|
screenCount: number;
|
|
10
10
|
imageTables: string;
|
|
11
11
|
keyframeTables: string;
|
|
12
|
-
scrollMemoryDiagnostics: Diagnostic[];
|
|
13
12
|
diagnostics: Diagnostic[];
|
|
14
13
|
}
|
|
15
14
|
export interface UIModule {
|
|
@@ -58,7 +57,23 @@ export interface TranspilerUIHook {
|
|
|
58
57
|
lowerOnMount(htmlPath: string, opts: LowerOptions): LoweredUI;
|
|
59
58
|
resolveColor(input: string, format: "rgb565" | "rgb666" | "rgb888" | "mono"): number;
|
|
60
59
|
resolveColorInternal(input: string, format: "rgb565" | "rgb666" | "rgb888" | "mono"): number;
|
|
61
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Emits ONLY the CuttlefishGFX class definition (the shared GFX base for
|
|
62
|
+
* native display paths). Called separately from emitRuntimeHeader so the
|
|
63
|
+
* class can be emitted BEFORE display adapter declarations that
|
|
64
|
+
* instantiate CuttlefishGFX by value. Returns "" when active is false
|
|
65
|
+
* (Arduino path).
|
|
66
|
+
*/
|
|
67
|
+
emitCuttlefishGfx(active: boolean): string;
|
|
68
|
+
/**
|
|
69
|
+
* Options controlling runtime-header emission.
|
|
70
|
+
* - nativeDisplayActive: when true, emit the shared CuttlefishGFX class
|
|
71
|
+
* (used by native display adapters on AVR/ESP32). Arduino paths pass
|
|
72
|
+
* false (default) and use Adafruit_GFX directly.
|
|
73
|
+
*/
|
|
74
|
+
emitRuntimeHeader(opts?: {
|
|
75
|
+
nativeDisplayActive?: boolean;
|
|
76
|
+
}): string;
|
|
62
77
|
splitUiFile(src: string): UiFileParts;
|
|
63
78
|
generateProjectUITypeDeclarations(projectRoot: string): {
|
|
64
79
|
written: string[];
|
|
@@ -67,7 +82,6 @@ export interface TranspilerUIHook {
|
|
|
67
82
|
error: Error;
|
|
68
83
|
}>;
|
|
69
84
|
};
|
|
70
|
-
analyzeScrollMemory(styled: unknown, budget: number): Diagnostic[];
|
|
71
85
|
}
|
|
72
86
|
/** Set the UI hook. Called by transpile.ts after dynamically loading
|
|
73
87
|
* @typecad/ui/engine. Passing null clears it (end of transpile run). */
|
package/dist/utils/cli.js
CHANGED
|
@@ -17,6 +17,8 @@ export function printHelp() {
|
|
|
17
17
|
console.log(` cuttlefish board add <spec.jsonc> [--force] Generate board + MCU packages from a chip spec`);
|
|
18
18
|
console.log(` cuttlefish gen-decls <input.cpp|--all <directory>>`);
|
|
19
19
|
console.log(` cuttlefish map-error <mapFile> [options]`);
|
|
20
|
+
console.log(` cuttlefish doctor Check the active framework's environment (e.g. toolchain + board core)`);
|
|
21
|
+
console.log(` cuttlefish licenses [--all] [--strict] Scan this project's Arduino libraries for SPDX licenses (--all: every installed library)`);
|
|
20
22
|
console.log();
|
|
21
23
|
console.log(chalk.gray(`Transpilation is always performed first. Use --compile, --upload, and`));
|
|
22
24
|
console.log(chalk.gray(`--monitor to chain operations after transpilation.`));
|
|
@@ -37,6 +39,16 @@ export function printHelp() {
|
|
|
37
39
|
console.log(` --emit-maps <bool> Emit source maps: "true" or "false" (default: true)`);
|
|
38
40
|
console.log(` Source maps enable mapping C++ errors back to TypeScript`);
|
|
39
41
|
console.log();
|
|
42
|
+
console.log(` --autosar[=<mode>] AUTOSAR C++14 compliance mode for emitted code:`);
|
|
43
|
+
console.log(` off no enforcement (default)`);
|
|
44
|
+
console.log(` warn emit AUTOSAR_* diagnostics + sidecar, build still succeeds`);
|
|
45
|
+
console.log(` strict abort emit on unrecorded required violations`);
|
|
46
|
+
console.log(` A sidecar <name>.autosar-deviations.json is written next to the`);
|
|
47
|
+
console.log(` emitted artifact in warn/strict modes. See COMPLIANCE.md.`);
|
|
48
|
+
console.log();
|
|
49
|
+
console.log(` --autosar-arxml Also write <name>.autosar-deviations.arxml (Artop/DaVinci).`);
|
|
50
|
+
console.log(` No-op unless --autosar is warn or strict.`);
|
|
51
|
+
console.log();
|
|
40
52
|
console.log(chalk.cyan(`BUILD COMMANDS`) + chalk.gray(` (chain in order: --compile → --upload → --monitor)`));
|
|
41
53
|
console.log();
|
|
42
54
|
console.log(` --compile Compile the generated output using the framework toolchain.`);
|
|
@@ -102,6 +114,12 @@ export function printHelp() {
|
|
|
102
114
|
console.log(` --diagnostics Generate diagnostics.md and diagnostics.json reports`);
|
|
103
115
|
console.log(` Includes IR graph, heap analysis, and task analysis`);
|
|
104
116
|
console.log();
|
|
117
|
+
console.log(` --debug Inject Serial.println instrumentation at breakpoints.`);
|
|
118
|
+
console.log(` Reads .cuttlefish/breakpoints.json (written by the`);
|
|
119
|
+
console.log(` TypeCAD Debug VS Code extension). At each breakpoint the`);
|
|
120
|
+
console.log(` firmware prints the location, original line, and in-scope`);
|
|
121
|
+
console.log(` variables, then halts — press ENTER over serial to continue.`);
|
|
122
|
+
console.log();
|
|
105
123
|
console.log(` --help, -h Show this help message`);
|
|
106
124
|
console.log();
|
|
107
125
|
console.log(chalk.cyan(`PROJECT CREATION`));
|
|
@@ -209,7 +227,11 @@ function parsePipelineCommand(argv, command, inputFile) {
|
|
|
209
227
|
const emitMapsFlag = readFirstFlagValue(argv, ["--emit-maps"]);
|
|
210
228
|
const buildTarget = readFirstFlagValue(argv, ["--build-target"]);
|
|
211
229
|
const port = readFirstFlagValue(argv, ["--port"]);
|
|
212
|
-
|
|
230
|
+
// Default to undefined (NOT 9600) so the build/upload/monitor flow's
|
|
231
|
+
// `options.baud ?? config.console.baudRate` falls through to the configured
|
|
232
|
+
// baud. Hardcoding 9600 here shadowed config.console.baudRate whenever --baud
|
|
233
|
+
// was absent (the monitor then opened the port at 9600, ignoring the config).
|
|
234
|
+
const baud = readNumberFlag(argv, ["--baud"]);
|
|
213
235
|
const frameworkFlag = readFirstFlagValue(argv, ["--framework"]);
|
|
214
236
|
const compile = readBooleanFlag(argv, ["--compile"]);
|
|
215
237
|
const upload = readBooleanFlag(argv, ["--upload"]);
|
|
@@ -229,6 +251,32 @@ function parsePipelineCommand(argv, command, inputFile) {
|
|
|
229
251
|
const keepUnusedTypes = readBooleanFlag(argv, ["--keep-unused-types"]);
|
|
230
252
|
const keepUnusedVariables = readBooleanFlag(argv, ["--keep-unused-variables"]);
|
|
231
253
|
const entryPoints = readRepeatedFlag(argv, "--entry-point");
|
|
254
|
+
// AUTOSAR C++14 compliance mode for emitted code. Accepts both
|
|
255
|
+
// `--autosar=strict` (= syntax) and `--autosar strict` (space syntax),
|
|
256
|
+
// plus the bare `--autosar` (treated as "strict"). Defaults to undefined,
|
|
257
|
+
// which the emitter treats as "off".
|
|
258
|
+
let autosar;
|
|
259
|
+
const autosarFlagIdx = argv.findIndex((a) => a === "--autosar" || a.startsWith("--autosar="));
|
|
260
|
+
if (autosarFlagIdx !== -1) {
|
|
261
|
+
const raw = argv[autosarFlagIdx];
|
|
262
|
+
if (raw === "--autosar") {
|
|
263
|
+
// Bare flag → strict. (No following value consumed.)
|
|
264
|
+
autosar = "strict";
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
// --autosar=<mode>
|
|
268
|
+
const value = raw.slice("--autosar=".length);
|
|
269
|
+
if (value === "strict" || value === "warn" || value === "off") {
|
|
270
|
+
autosar = value;
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
throw new Error(`--autosar must be one of: strict, warn, off (got: ${value})`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// --autosar-arxml: also write the .autosar-deviations.arxml sidecar
|
|
278
|
+
// (Artop/DaVinci tooling). No-op unless --autosar is warn or strict.
|
|
279
|
+
const autosarArxml = readBooleanFlag(argv, ["--autosar-arxml"]);
|
|
232
280
|
const emitMode = emitFlag === "cpp" || emitFlag === "split" ? emitFlag : "split";
|
|
233
281
|
const emitMaps = emitMapsFlag === undefined ? true : emitMapsFlag !== "false";
|
|
234
282
|
// Accept any target string — the framework package registers its own strategy id.
|
|
@@ -279,6 +327,8 @@ function parsePipelineCommand(argv, command, inputFile) {
|
|
|
279
327
|
expect,
|
|
280
328
|
expectFile,
|
|
281
329
|
frameworkPackage: frameworkFlag,
|
|
330
|
+
autosar,
|
|
331
|
+
autosarArxml,
|
|
282
332
|
};
|
|
283
333
|
}
|
|
284
334
|
export function parseCommandLine(argv) {
|
|
@@ -296,6 +346,7 @@ export function parseCommandLine(argv) {
|
|
|
296
346
|
const baudRaw = readFirstFlagValue(argv, ["--baud"]);
|
|
297
347
|
const outDir = readFirstFlagValue(argv, ["--outDir", "--out-dir", "-o"]);
|
|
298
348
|
const noSketch = argv.includes("--no-sketch");
|
|
349
|
+
const noInstall = argv.includes("--no-install");
|
|
299
350
|
const baud = baudRaw && !Number.isNaN(Number(baudRaw)) ? Number(baudRaw) : undefined;
|
|
300
351
|
return {
|
|
301
352
|
command: "create",
|
|
@@ -304,6 +355,7 @@ export function parseCommandLine(argv) {
|
|
|
304
355
|
baud,
|
|
305
356
|
framework,
|
|
306
357
|
noSketch,
|
|
358
|
+
noInstall,
|
|
307
359
|
outDir: outDir ? path.resolve(process.cwd(), outDir) : undefined,
|
|
308
360
|
};
|
|
309
361
|
}
|
|
@@ -337,6 +389,49 @@ export function parseCommandLine(argv) {
|
|
|
337
389
|
port: port ? String(port) : undefined,
|
|
338
390
|
};
|
|
339
391
|
}
|
|
392
|
+
// doctor subcommand — verify the active framework's environment
|
|
393
|
+
if (firstArg === "doctor") {
|
|
394
|
+
return {
|
|
395
|
+
command: "doctor",
|
|
396
|
+
// The remaining pipeline fields are unused by doctor; fill with safe
|
|
397
|
+
// defaults, the same way the preview branch does.
|
|
398
|
+
inputFile: undefined,
|
|
399
|
+
emitMode: "split",
|
|
400
|
+
target: "generic",
|
|
401
|
+
outDir: undefined,
|
|
402
|
+
emitMaps: true,
|
|
403
|
+
noTranspile: false,
|
|
404
|
+
compile: false,
|
|
405
|
+
upload: false,
|
|
406
|
+
monitor: false,
|
|
407
|
+
watch: false,
|
|
408
|
+
baud: 9600,
|
|
409
|
+
platformContext: {},
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
// licenses subcommand — scan the project's dependencies for SPDX licenses.
|
|
413
|
+
// Accept `license` (singular) as an alias so both spellings work.
|
|
414
|
+
if (firstArg === "licenses" || firstArg === "license") {
|
|
415
|
+
return {
|
|
416
|
+
command: "licenses",
|
|
417
|
+
strict: argv.includes("--strict"),
|
|
418
|
+
all: argv.includes("--all"),
|
|
419
|
+
// The remaining pipeline fields are unused by licenses; fill with safe
|
|
420
|
+
// defaults, the same way the doctor branch does.
|
|
421
|
+
inputFile: undefined,
|
|
422
|
+
emitMode: "split",
|
|
423
|
+
target: "generic",
|
|
424
|
+
outDir: undefined,
|
|
425
|
+
emitMaps: true,
|
|
426
|
+
noTranspile: false,
|
|
427
|
+
compile: false,
|
|
428
|
+
upload: false,
|
|
429
|
+
monitor: false,
|
|
430
|
+
watch: false,
|
|
431
|
+
baud: 9600,
|
|
432
|
+
platformContext: {},
|
|
433
|
+
};
|
|
434
|
+
}
|
|
340
435
|
// Named subcommands
|
|
341
436
|
if (firstArg === "gen-libdefs" || firstArg === "gen-decls" || firstArg === "map-error") {
|
|
342
437
|
const command = firstArg;
|
|
@@ -387,12 +482,16 @@ export function parseCommandLine(argv) {
|
|
|
387
482
|
// gen-decls - generate .d.ts from C++ files
|
|
388
483
|
if (command === "gen-decls") {
|
|
389
484
|
const allFlag = argv.includes("--all");
|
|
485
|
+
const componentsFlag = argv.includes("--components");
|
|
486
|
+
if (allFlag && componentsFlag) {
|
|
487
|
+
throw new Error("gen-decls: --components and --all are mutually exclusive. Use one or the other.");
|
|
488
|
+
}
|
|
390
489
|
// The positional path may sit at argv[3] or argv[4] depending on whether
|
|
391
490
|
// --all precedes or follows it. Scan argv starting after the subcommand
|
|
392
491
|
// name (argv[2]) for the first token that is not a flag and not a known
|
|
393
492
|
// flag's value. This mirrors the default-pipeline approach of "first
|
|
394
493
|
// non-flag token wins".
|
|
395
|
-
const booleanFlags = new Set(["--all"]);
|
|
494
|
+
const booleanFlags = new Set(["--all", "--components"]);
|
|
396
495
|
const valueFlags = new Set([
|
|
397
496
|
"--emit", "--target", "--outDir", "--out-dir", "--emit-maps", "--build-target",
|
|
398
497
|
]);
|
|
@@ -413,6 +512,28 @@ export function parseCommandLine(argv) {
|
|
|
413
512
|
inputPath = tok;
|
|
414
513
|
break;
|
|
415
514
|
}
|
|
515
|
+
// --components mode: scan managed_components/ + components/ declared in
|
|
516
|
+
// cuttlefish.config.ts. Falls back to cwd when no path is given.
|
|
517
|
+
if (componentsFlag) {
|
|
518
|
+
const componentsDir = inputPath || process.cwd();
|
|
519
|
+
return {
|
|
520
|
+
command: "gen-decls",
|
|
521
|
+
inputFile: undefined,
|
|
522
|
+
emitMode,
|
|
523
|
+
target,
|
|
524
|
+
outDir: outDir ? path.resolve(process.cwd(), outDir) : undefined,
|
|
525
|
+
emitMaps,
|
|
526
|
+
noTranspile: false,
|
|
527
|
+
compile: false,
|
|
528
|
+
upload: false,
|
|
529
|
+
monitor: false,
|
|
530
|
+
watch: false,
|
|
531
|
+
baud: 9600,
|
|
532
|
+
platformContext,
|
|
533
|
+
scanDir: undefined,
|
|
534
|
+
componentsDir: path.resolve(process.cwd(), componentsDir),
|
|
535
|
+
};
|
|
536
|
+
}
|
|
416
537
|
if (!inputPath && !allFlag) {
|
|
417
538
|
throw new Error("Missing input C++ file path. Use: gen-decls <file.cpp> or gen-decls --all <directory>");
|
|
418
539
|
}
|
package/dist/utils/fs.d.ts
CHANGED
|
@@ -2,3 +2,16 @@ export declare function ensureDir(dirPath: string): void;
|
|
|
2
2
|
export declare function readText(filePath: string): string;
|
|
3
3
|
export declare function writeText(filePath: string, content: string): void;
|
|
4
4
|
export declare function listFiles(dirPath: string, extension: string): string[];
|
|
5
|
+
/**
|
|
6
|
+
* Recursive variant of {@link listFiles}. Walks `dirPath` depth-first and
|
|
7
|
+
* returns every file (in every subdirectory) whose name ends with `extension`.
|
|
8
|
+
*
|
|
9
|
+
* Used by {@link loadLibraryDefinitions} so libdefs under nested cache dirs
|
|
10
|
+
* like `.cuttlefish/component-decls/<component>/` are discovered. Purely
|
|
11
|
+
* additive vs. the non-recursive `listFiles` — single-level layouts keep
|
|
12
|
+
* working, nested layouts now also work.
|
|
13
|
+
*
|
|
14
|
+
* Returns absolute paths. Unreadable directories are silently skipped
|
|
15
|
+
* (matches `listFiles`'s not-exist behavior for non-existent roots).
|
|
16
|
+
*/
|
|
17
|
+
export declare function listFilesRecursive(dirPath: string, extension: string): string[];
|
package/dist/utils/fs.js
CHANGED
|
@@ -10,6 +10,15 @@ export function readText(filePath) {
|
|
|
10
10
|
}
|
|
11
11
|
export function writeText(filePath, content) {
|
|
12
12
|
ensureDir(path.dirname(filePath));
|
|
13
|
+
// Skip writing when content is identical — preserves mtime so downstream
|
|
14
|
+
// build tools (idf.py/ninja, arduino-cli, make) can skip recompilation.
|
|
15
|
+
try {
|
|
16
|
+
if (fs.readFileSync(filePath, "utf8") === content)
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// File doesn't exist yet — fall through to write.
|
|
21
|
+
}
|
|
13
22
|
fs.writeFileSync(filePath, content, "utf8");
|
|
14
23
|
}
|
|
15
24
|
export function listFiles(dirPath, extension) {
|
|
@@ -21,3 +30,44 @@ export function listFiles(dirPath, extension) {
|
|
|
21
30
|
.filter((name) => name.toLowerCase().endsWith(extension.toLowerCase()))
|
|
22
31
|
.map((name) => path.join(dirPath, name));
|
|
23
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Recursive variant of {@link listFiles}. Walks `dirPath` depth-first and
|
|
35
|
+
* returns every file (in every subdirectory) whose name ends with `extension`.
|
|
36
|
+
*
|
|
37
|
+
* Used by {@link loadLibraryDefinitions} so libdefs under nested cache dirs
|
|
38
|
+
* like `.cuttlefish/component-decls/<component>/` are discovered. Purely
|
|
39
|
+
* additive vs. the non-recursive `listFiles` — single-level layouts keep
|
|
40
|
+
* working, nested layouts now also work.
|
|
41
|
+
*
|
|
42
|
+
* Returns absolute paths. Unreadable directories are silently skipped
|
|
43
|
+
* (matches `listFiles`'s not-exist behavior for non-existent roots).
|
|
44
|
+
*/
|
|
45
|
+
export function listFilesRecursive(dirPath, extension) {
|
|
46
|
+
if (!fs.existsSync(dirPath)) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
const ext = extension.toLowerCase();
|
|
50
|
+
const out = [];
|
|
51
|
+
const stack = [dirPath];
|
|
52
|
+
while (stack.length > 0) {
|
|
53
|
+
const cur = stack.pop();
|
|
54
|
+
let entries;
|
|
55
|
+
try {
|
|
56
|
+
entries = fs.readdirSync(cur, { withFileTypes: true });
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Permission error / race / etc. Skip this subtree.
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
for (const entry of entries) {
|
|
63
|
+
const full = path.join(cur, entry.name);
|
|
64
|
+
if (entry.isDirectory()) {
|
|
65
|
+
stack.push(full);
|
|
66
|
+
}
|
|
67
|
+
else if (entry.isFile() && entry.name.toLowerCase().endsWith(ext)) {
|
|
68
|
+
out.push(full);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
package/dist/utils/ui.js
CHANGED
|
@@ -86,7 +86,9 @@ export function printMonitoring(port, baud) {
|
|
|
86
86
|
* Print success message
|
|
87
87
|
*/
|
|
88
88
|
export function printSuccess(message = "Done") {
|
|
89
|
-
|
|
89
|
+
// Cyan (not green) so the completion marker matches the cyan step indicators
|
|
90
|
+
// (⇉ Compiling / Uploading / Transpiling). The ✓ icon conveys success.
|
|
91
|
+
console.log(chalk.cyan(`${ICON_SUCCESS} ${message}`));
|
|
90
92
|
}
|
|
91
93
|
/**
|
|
92
94
|
* Print error message
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typecad/cuttlefish",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0-alpha.11",
|
|
4
4
|
"description": "TypeScript to C++ transpiler — native, Arduino, and bare-metal targets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/transpile.js",
|
|
@@ -29,10 +29,22 @@
|
|
|
29
29
|
"types": "./dist/ui-hook.d.ts",
|
|
30
30
|
"default": "./dist/ui-hook.js"
|
|
31
31
|
},
|
|
32
|
+
"./safety-hook-types": {
|
|
33
|
+
"types": "./dist/safety-hook.d.ts",
|
|
34
|
+
"default": "./dist/safety-hook.js"
|
|
35
|
+
},
|
|
36
|
+
"./build-ir-state": {
|
|
37
|
+
"types": "./dist/ir/build-ir-state.d.ts",
|
|
38
|
+
"default": "./dist/ir/build-ir-state.js"
|
|
39
|
+
},
|
|
32
40
|
"./config-loader": {
|
|
33
41
|
"types": "./dist/config-loader.d.ts",
|
|
34
42
|
"default": "./dist/config-loader.js"
|
|
35
43
|
},
|
|
44
|
+
"./utils/ui": {
|
|
45
|
+
"types": "./dist/utils/ui.d.ts",
|
|
46
|
+
"default": "./dist/utils/ui.js"
|
|
47
|
+
},
|
|
36
48
|
"./stores/display-profile-store": {
|
|
37
49
|
"types": "./dist/stores/display-profile-store.d.ts",
|
|
38
50
|
"default": "./dist/stores/display-profile-store.js"
|
|
@@ -49,6 +61,10 @@
|
|
|
49
61
|
"types": "./dist/emit/route-hal-op.d.ts",
|
|
50
62
|
"default": "./dist/emit/route-hal-op.js"
|
|
51
63
|
},
|
|
64
|
+
"./lib/component-decls": {
|
|
65
|
+
"types": "./dist/libdef/component-decls.d.ts",
|
|
66
|
+
"default": "./dist/libdef/component-decls.js"
|
|
67
|
+
},
|
|
52
68
|
"./ir/transformers/ui-lowering": {
|
|
53
69
|
"types": "./dist/ir/transformers/ui-lowering.d.ts",
|
|
54
70
|
"default": "./dist/ir/transformers/ui-lowering.js"
|
|
@@ -83,15 +99,19 @@
|
|
|
83
99
|
"zod": "^3.24.0"
|
|
84
100
|
},
|
|
85
101
|
"peerDependencies": {
|
|
86
|
-
"@typecad/ui": "
|
|
102
|
+
"@typecad/ui": "1.0.0-alpha.11",
|
|
103
|
+
"@typecad/safety": "1.0.0-alpha.11"
|
|
87
104
|
},
|
|
88
105
|
"peerDependenciesMeta": {
|
|
89
106
|
"@typecad/ui": {
|
|
90
107
|
"optional": true
|
|
108
|
+
},
|
|
109
|
+
"@typecad/safety": {
|
|
110
|
+
"optional": true
|
|
91
111
|
}
|
|
92
112
|
},
|
|
93
113
|
"optionalDependencies": {
|
|
94
|
-
"@typecad/framework-native": "
|
|
114
|
+
"@typecad/framework-native": "1.0.0-alpha.11"
|
|
95
115
|
},
|
|
96
116
|
"devDependencies": {
|
|
97
117
|
"@types/node": "^22.10.7"
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------
|
|
2
|
-
// eink-mono display adapter — 1-bit B&W e-ink panels (SSD1680-class, e.g. the
|
|
3
|
-
// common 296×128 / 250×122 breakouts). Deferred refresh: no fillScreen on init
|
|
4
|
-
// (a full clear flashes), and a partial-refresh entry point the runtime's dirty-
|
|
5
|
-
// rect union calls once per frame.
|
|
6
|
-
//
|
|
7
|
-
// Library note: targets Adafruit_EPD (Adafruit_SSD168x). The exact partial-
|
|
8
|
-
// refresh method name varies by library (Adafruit_EPD: refreshPartial / GxEPD:
|
|
9
|
-
// updateWindow). Verify against the target library before flashing — the shim
|
|
10
|
-
// shape is correct; the method call is library-specific. TODO Phase 5.
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
export const einkMonoAdapter = (display) => {
|
|
13
|
-
const cs = display._mountCs;
|
|
14
|
-
const dc = display._mountDc;
|
|
15
|
-
const rst = display._mountRst;
|
|
16
|
-
const rotation = display.rotation ?? 0;
|
|
17
|
-
const w = display.width;
|
|
18
|
-
const h = display.height;
|
|
19
|
-
return {
|
|
20
|
-
includes: [
|
|
21
|
-
"#include <Adafruit_GFX.h>",
|
|
22
|
-
"#include <Adafruit_EPD.h>",
|
|
23
|
-
].join("\n"),
|
|
24
|
-
// busy pin = -1 (unused); SRCS+D/C+RST+CS wiring. Adafruit_SSD168x(width, height, dc, rst, cs, busy).
|
|
25
|
-
declaration: `Adafruit_SSD168x __tc_display(${w}, ${h}, ${dc}, ${rst}, ${cs}, -1);`,
|
|
26
|
-
functions: [
|
|
27
|
-
"// --- Display adapter: eink-mono (SSD1680-class, 1-bit, deferred refresh) ---",
|
|
28
|
-
"static inline void display_init() {",
|
|
29
|
-
" __tc_display.begin();",
|
|
30
|
-
` __tc_display.setRotation(${rotation});`,
|
|
31
|
-
" // No full-screen clear here — e-ink flashes on a full clear. The runtime",
|
|
32
|
-
" // marks all nodes dirty (UI_REFRESH_DEFERRED) and the first flush repaints",
|
|
33
|
-
" // via partial refresh instead.",
|
|
34
|
-
"}",
|
|
35
|
-
"",
|
|
36
|
-
"static inline CuttlefishDisplayTarget* display_defaultTarget() { return &__tc_display; }",
|
|
37
|
-
"static inline int16_t display_width() { return __tc_display.width(); }",
|
|
38
|
-
"static inline int16_t display_height() { return __tc_display.height(); }",
|
|
39
|
-
"static inline void display_startWrite() {}",
|
|
40
|
-
"static inline void display_endWrite() {}",
|
|
41
|
-
"static inline void display_setAddrWindow(int16_t x, int16_t y, int16_t w, int16_t h) { (void)x; (void)y; (void)w; (void)h; }",
|
|
42
|
-
// Partial refresh: push just the dirty region. The runtime draws into the
|
|
43
|
-
// EPD's built-in GFX buffer (the display IS the backing store for 1-bit),
|
|
44
|
-
// then calls this with the unioned dirty rect. TODO Phase 5: verify the
|
|
45
|
-
// exact partial-refresh API for the target EPD library.
|
|
46
|
-
"static inline void display_partial_refresh(int16_t x, int16_t y, int16_t w, int16_t h) {",
|
|
47
|
-
" __tc_display.refreshPartial(x, y, (uint16_t)w, (uint16_t)h);",
|
|
48
|
-
"}",
|
|
49
|
-
// drawPixel goes through GFX into the EPD buffer; partial_refresh publishes it.
|
|
50
|
-
"static inline void display_fillScreen(uint32_t color) { __tc_display.fillScreen(color ? EPD_WHITE : EPD_BLACK); }",
|
|
51
|
-
].join("\n"),
|
|
52
|
-
};
|
|
53
|
-
};
|