PlatformIO
The platformio macro builds PlatformIO projects and collects build and compiler
metadata.
Dependencies
PlatformIO Core and its pio executable are required.
Platforms, frameworks, libraries, and toolchains configured through platformio.ini
are managed by PlatformIO and are project requirements rather than direct cikit
dependencies.
Features
compiler metadata collection
PlatformIO build execution
compile_commands.jsongeneration without artifact registrationoptional clean builds
build time metrics
compiled file counts
compiler warning and error counts
memory usage metrics
build command logs
cikit data updates
artifact registration
RST build reports
Typical usage
from pathlib import Path
from cikit.macros import platformio
platformio.gather_compiler_meta(env, project_dir=Path("."))
platformio.build(env, project_dir=Path("."), clean=True)
compile_commands = platformio.generate_compile_commands(env, project_dir=Path("."))
platformio.write_rst(env)
When project_dir is omitted, the project root from the environment is used.
generate_compile_commands() returns the path to the JSON file in the project
directory without registering a metadata artifact.
gather_compiler_meta() asks PlatformIO for the resolved build environment and, when
exactly one environment can be determined, stores available compiler information in the
current run data:
compilercompiler_versioncompiler_type
The compiler executable is taken from PlatformIO metadata and queried for its version.
Environment selection
All four helpers below accept an explicit PlatformIO environment name:
project_dir = Path("firmware")
platformio.gather_compiler_meta(env, project_dir, environment="release")
build_dir = platformio.get_build_dir(env, project_dir, environment="release")
platformio.build(env, project_dir, clean=True, environment="release")
compile_commands = platformio.generate_compile_commands(
env, project_dir, environment="release")
get_build_dir() resolves the build directory from PlatformIO metadata.
When no environment is specified, metadata resolution requires an unambiguous
environment. Unavailable compiler metadata is omitted; the compiler metadata
helper does not require it to be present.