Skip to content

Commit 39d9681

Browse files
committed
Add doc section and use case for "BuildSources" method in extra scripts
Resolve #209
1 parent d11f318 commit 39d9681

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

projectconf/advanced_scripting.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,3 +938,34 @@ install them into the same virtual environment where :ref:`piocore` is installed
938938
939939
# Install custom packages from the PyPi registry
940940
env.Execute("$PYTHONEXE -m pip install pkg1 pkg2")
941+
942+
Build external sources
943+
^^^^^^^^^^^^^^^^^^^^^^
944+
945+
If your project depends on some arbitrary source files that are located outside of the
946+
usual source directory :ref:`projectconf_pio_src_dir` then you can use a preliminary
947+
extra script to add them to the build process. A typical situation when this approach
948+
may be useful is when a project depends on pregenerated files in a temporary folder.
949+
Here is a typical configuration with an extra_script that instructs PlatformIO to build
950+
all sources in an external folder:
951+
952+
``platformio.ini``:
953+
954+
.. code-block:: ini
955+
956+
[env:my_env]
957+
platform = ...
958+
extra_scripts = pre:extra_script.py
959+
960+
``extra_script.py`` (place it near ``platformio.ini``):
961+
962+
.. code-block:: python
963+
964+
import os
965+
966+
Import("env")
967+
968+
env.BuildSources(
969+
os.path.join("$BUILD_DIR", "external", "build"),
970+
os.path.join("$PROJECT_DIR", "external", "sources")
971+
)

0 commit comments

Comments
 (0)