# .pioc file

## Introduction

<span style="white-space: pre-wrap;">The </span>`<span class="editor-theme-code">platformio.pioc</span>`<span style="white-space: pre-wrap;"> file is the central configurationhere file used to define build environments, dependencies, compiler flags, and project structure. It uses a format with sections and key-value pairs. It is similar to platformio.ini, which is actually used by platformio, but has some changes to use it easily with our project. For more information, read </span>[Simple PIOC](https://bookstack.roboteamtwente.nl/books/embedded-infastructure/page/simple-pioc "https://bookstack.roboteamtwente.nl/books/embedded-infastructure/page/simple-pioc").

## File Structure

<span style="white-space: pre-wrap;">The configuration is divided into sections such as </span>`<span class="editor-theme-code">[platformio]</span>`<span style="white-space: pre-wrap;">, </span>`<span class="editor-theme-code">[env]</span>`<span style="white-space: pre-wrap;">, and environment-specific sections like </span>`<span class="editor-theme-code">[env:network_board]</span>`.

## Core Sections

### \[platformio\]

Defines global project settings.

- `<span class="editor-theme-code">default_envs</span>`: Default environment(s) to build.
- `<span class="editor-theme-code">src_dir</span>`: Source directory.
- `<span class="editor-theme-code">lib_dir</span>`: Library directory.

### \[extra\]

Custom user-defined variables for reuse.

### \[env\]

Base configuration shared across all environments.

## Environment Sections

<span style="white-space: pre-wrap;">Each </span>`<span class="editor-theme-code">[env:<name>]</span>`<span style="white-space: pre-wrap;"> defines a specific build target. These inherit from </span>`<span class="editor-theme-code">[env]</span>`.

## Custom Enhancements

### 1. Glob Patterns in build\_flags

<span style="white-space: pre-wrap;">Unlike standard PlatformIO, this configuration allows glob-style include/exclude patterns directly in </span>`<span class="editor-theme-code">build_flags</span>`<span style="white-space: pre-wrap;"> using </span>`<span class="editor-theme-code">+<...></span>`<span style="white-space: pre-wrap;"> and </span>`<span class="editor-theme-code">-<...></span>`<span style="white-space: pre-wrap;"> syntax.</span>

```
build_flags=
    +<components/network_board/**>
    -<components/network_board/firmware/Drivers/**>
```

This enables fine-grained control over which directories are included in compilation.

### 2. Absolute Path Variable

<span style="white-space: pre-wrap;">The variable </span>`<span class="editor-theme-code">${{project_absolute_path}}$</span>`<span style="white-space: pre-wrap;"> expands to the absolute path of the project root.</span>

```
custom_nanopb_project_dir = ${{project_absolute_path}}$/ERC-Protobufs
```

## Source Filtering

`<span class="editor-theme-code">build_src_filter</span>`<span style="white-space: pre-wrap;"> defines which source files are compiled. It supports inclusion (+) and exclusion (-) rules.</span>

```
+<src/${this.__env__}/**/*.c>
-<components/${this.__env__}/firmware/Drivers/*>
```

## Variable Substitution

- `<span class="editor-theme-code">${extra.common_lib_deps}</span>`: Reference shared variables.
- `<span class="editor-theme-code">${this.__env__}</span>`: Current environment name.

## Library Dependencies

External libraries can be defined using Git URLs or registry references.

```
lib_deps = https://github.com/nanopb/nanopb.git#commit
```

## Compiler and Linker Flags

Standard compiler flags are also supported alongside glob patterns.

```
-mthumb
-mfpu=fpv4-sp-d16
-D CONFIG_LOG_LEVEL=LOG_INFO
```

## Example Configuration

```
[env:network_board]
board = nucleo_h753zi
build_flags=
    +<components/network_board/**>
    -<components/network_board/firmware/Drivers/**>
    -mthumb
    -D CONFIG_LOG_LEVEL=LOG_INFO
```

## Compilation

<span style="white-space: pre-wrap;">To use the file, you have to convert it to a </span>`<span class="editor-theme-code">platformio.ini</span>`<span style="white-space: pre-wrap;"> file. You can do that by running </span>

```
python3 simple_pioc.py
```

## Extra information

<span style="white-space: pre-wrap;">If more information is needed, look at the documentation specifically for platformio.ini files. You can find it </span>[here](https://docs.platformio.org/en/latest/projectconf/index.html).