platformio / platformio-core

Your Gateway to Embedded Software Development Excellence :alien:

Home Page:https://platformio.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AddPreAction doesn't work as expected

briandilley opened this issue · comments

Using AddPreAction("buildprog", ...) does not result in the action being beformed BEFORE compilation as expected. In fact, it seems impossible to have something happen before compilation (ie: generating code, etc.). Here's a sample script that generates a website that is built into the program:

import shutil

Import("env")

def build_web_progmem(source, target, env):
    print("running build_web_progmem")
    PROJECT_DIR = env.subst("$PROJECT_DIR")
    env.Execute(f"npm --prefix={PROJECT_DIR}/../web install")
    env.Execute(f"npm --prefix={PROJECT_DIR}/../web run awot-static")

env.AddCustomTarget(
    name="build_web",
    dependencies=None,
    actions=[build_web_progmem],
    title="Build Web",
    description="Build the web interface"
)
env.AddPreAction("buildprog", build_web_progmem)

For the "pregeneration" before building stage, please use PRE script https://docs.platformio.org/en/latest/scripting/actions.html