mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Update docs with "buildprog" target, add/post actions // Resolve #812
This commit is contained in:
@ -904,11 +904,12 @@ Before/Pre and After/Post actions
|
|||||||
'''''''''''''''''''''''''''''''''
|
'''''''''''''''''''''''''''''''''
|
||||||
|
|
||||||
PlatformIO Build System has rich API that allows to attach different pre-/post
|
PlatformIO Build System has rich API that allows to attach different pre-/post
|
||||||
actions (hooks) using ``env.AddPreAction(target, callback)`` function. A first
|
actions (hooks) using ``env.AddPreAction(target, callback)`` or
|
||||||
|
``env.AddPreAction(target, [callback1, callback2, ...])`` function. A first
|
||||||
argument ``target`` can be a name of target that is passed using
|
argument ``target`` can be a name of target that is passed using
|
||||||
:option:`platformio run --target` command or path to file which PlatformIO
|
:option:`platformio run --target` command, a name of built-in targets
|
||||||
processes (ELF, HEX, BIN, etc.). For example, to call function before HEX file
|
(buildprog, size, upload, program, buildfs, uploadfs, uploadfsota) or path
|
||||||
will be created, need to use as a ``$BUILD_DIR/firmware.hex`` target value.
|
to file which PlatformIO processes (ELF, HEX, BIN, OBJ, etc.).
|
||||||
|
|
||||||
The example below demonstrates how to call different functions
|
The example below demonstrates how to call different functions
|
||||||
when :option:`platformio run --target` is called with ``upload`` value.
|
when :option:`platformio run --target` is called with ``upload`` value.
|
||||||
@ -927,6 +928,10 @@ when :option:`platformio run --target` is called with ``upload`` value.
|
|||||||
|
|
||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
|
#
|
||||||
|
# Upload actions
|
||||||
|
#
|
||||||
|
|
||||||
def before_upload(source, target, env):
|
def before_upload(source, target, env):
|
||||||
print "before_upload"
|
print "before_upload"
|
||||||
# do some actions
|
# do some actions
|
||||||
@ -938,12 +943,25 @@ when :option:`platformio run --target` is called with ``upload`` value.
|
|||||||
|
|
||||||
print "Current build targets", map(str, BUILD_TARGETS)
|
print "Current build targets", map(str, BUILD_TARGETS)
|
||||||
|
|
||||||
# env.AddPreAction("$BUILD_DIR/firmware.elf", callback...)
|
|
||||||
# env.AddPostAction("$BUILD_DIR/firmware.hex", callback...)
|
|
||||||
|
|
||||||
env.AddPreAction("upload", before_upload)
|
env.AddPreAction("upload", before_upload)
|
||||||
env.AddPostAction("upload", after_upload)
|
env.AddPostAction("upload", after_upload)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Custom actions when building program/firmware
|
||||||
|
#
|
||||||
|
|
||||||
|
env.AddPreAction("buildprog", callback...)
|
||||||
|
env.AddPostAction("buildprog", callback...)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Custom actions for specific files/objects
|
||||||
|
#
|
||||||
|
|
||||||
|
env.AddPreAction("$BUILD_DIR/firmware.elf", [callback1, callback2,...])
|
||||||
|
env.AddPostAction("$BUILD_DIR/firmware.hex", callback...)
|
||||||
|
|
||||||
|
# custom action for project's main.cpp
|
||||||
|
env.AddPostAction("$BUILD_DIR/src/main.cpp.o", callback...)
|
||||||
|
|
||||||
|
|
||||||
-----------
|
-----------
|
||||||
|
Reference in New Issue
Block a user