convert-sketch
June 21, 2026 · View on GitHub
Converts a Teensyduino sketch into a self-contained
teensy-cmake-macros project
that cross-compiles with arm-none-eabi-gcc, targeting RT1060-EVKB (default)
or Teensy 4.x.
Usage
node bin/convert-sketch.js <input> [options]
<input> is a .ino file, an Arduino sketch folder, or a folder of sketch
folders (batch mode).
| Option | Default | Meaning |
|---|---|---|
--out <dir> | ./<SketchName>-teensy | output project directory |
--board <42|41|40> | 42 | 42 = RT1060-EVKB, 41 = Teensy 4.1, 40 = Teensy 4.0 |
--csv <file> | — | header→library override/extension map |
--compiler-path <dir> | /Applications/ARM_10/bin/ | arm-none-eabi bin/ dir (trailing slash) |
--no-vscode | (vscode on) | skip .vscode/ generation |
--force | off | overwrite a non-empty output dir |
What it does
- Scans the sketch for
#include <X.h>and maps each header to a git library (built-in PaulStoffregen map; override via--csv), pulling in each library's transitive dependencies (e.g.Audio→ SPI/SD/SerialFlash/Wire/arm_math). - Transforms the
.ino(s) into a compilable.cpp(injectsArduino.h, generates forward prototypes — K&R and Allman brace styles — and concatenates multi-tab sketches). - Emits
CMakeLists.txt(linkingstdc++automatically when the sketch uses the C++ STL), a board toolchain file, optional.vscode/, and a README, and copies any companion files (local headers, extra sources, data) from the sketch folder.
CSV override format
See examples/libraries.sample.csv. Columns:
header,library,git_url,branch,source_path,subdirs (subdirs is ;-separated;
# lines are comments). A row overrides a built-in header or adds a new one —
this is how you point a header at a fork (e.g. git@github.com:newdigate/SPI.git).
Build the generated project
cd <SketchName>-teensy
mkdir -p cmake-build-debug && cd cmake-build-debug
cmake .. -DCMAKE_TOOLCHAIN_FILE:FILEPATH="../cmake/toolchains/teensy42.toolchain.cmake"
make
Develop
node --test # run the suite