Simple PIOC
Introduction
This Python script processes a custom PlatformIO configuration file (platformio.pioc) and generates a standard platformio.ini file.
It extends PlatformIO’s configuration capabilities by:
- Supporting dynamic include paths using glob patterns
- Extracting C preprocessor defines from board-specific Makefiles
- Expanding custom syntax into valid
build_flags - Resolving absolute paths.
Key Features
Custom build_flags Processing
Supports two types of entries:
- +<pattern>: Include directories
- -<pattern>: Exclude directories
- Other entries are treated as standard compiler flags
Include Path Resolution
Glob patterns are expanded into directory paths using recursive search.
Board-specific C Defines
Defines are extracted from:
components/<board>/firmware/Makefile
The script looks for a C_DEFS section and includes all compiler defines.
This is done, because cubeMX generates important definitions in the auto-generated makefile. These are not used if we don't copy them to the .ini file.
Environment Detection
[env:my_board]
This determines which board folder is used.
Get Absolute Path
For some functions, like nanopb, you might need the absolute path. There is no way to get in the default platformio.ini file, so that would mean that you would have to hard code it. We do not want that, so we have a placeholder for an absolute path.
The placeholder:
${{project_absolute_path}}$
is replaced with the absolute path of the project.
Workflow
- Read
platformio.pioc - Detect environment
- Parse
build_flags - Resolve glob patterns
- Extract C defines
- Write
platformio.ini - Replace placeholders
Example Input
[env:my_board]
build_flags =
+<lib/**>
-<lib/exclude/**>
-DDEBUG
Example Output
[env:my_board]
build_flags =
-I lib/module1
-I lib/module2
-DDEBUG
-DDEFINE_FROM_MAKEFILE
No comments to display
No comments to display