Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BuildSources() not work from post : script.py #4385

Closed
Wiz-IO opened this issue Aug 6, 2022 · 7 comments
Closed

BuildSources() not work from post : script.py #4385

Wiz-IO opened this issue Aug 6, 2022 · 7 comments

Comments

@Wiz-IO
Copy link

Wiz-IO commented Aug 6, 2022

I want to add and compile code from not compiled framework folder
but BuildSources() not work from POST:SCRIPT.PY

as example:
https://github.com/Wiz-IO/TEST/blob/main/PICO-LWIP-APP/extra_script.py

pre:scrypt.py
BuildSources() work
BuildLibrary() work

post:scrypt.py
BuildLibrary() work
BuildSources() not work … Is it a BUG? or I make any wrong...

@ivankravets
Copy link
Member

Hi Georgi,

This is a feature, not a bug. The inline source files are handled at the BuildProgram step which you call in your platformio/main.py

So, any calling of BuildSourceslater does not have any effect. We will inform the user about this issue.

@Wiz-IO
Copy link
Author

Wiz-IO commented Aug 8, 2022

Hi Ivan, thanks for the answer

my thought was: add_module( src folder ) from ini file ... CMAKE uses similar practices
some code is not compiled by main builder, but exist in framework
example:
lwip is compiled as basic, without apps ... http, tftp etc
and I wanted to add them from INI with POST script
for now I found a way with PRE script - I had uninitialized variables

...
Building in release mode
-- EXECUTE POST-SCRIPT.PY --
-- FROM PRE-SCRIPT - BuildSources() -- Compiling WORK
-- FROM MAIN BUILDER --
Compiling .pio\build\...any code...
Compiling .pio\build\any-src\main.o
-- FROM POST-SCRIPT - BuildSources() -- Would be great feature <<<----------
-- FROM POST-SCRIPT - BuildLibrary() -- Compiling WORK
Linking .pio\build\raspberry-pi-pico\APPLICATION.elf
...

you can close issue if not important

@ivankravets
Copy link
Member

I've just added a warning message. Please use BuildLibrary in this case.

@Wiz-IO
Copy link
Author

Wiz-IO commented Aug 8, 2022

BTW in doc
https://docs.platformio.org/en/latest/scripting/actions.html

need more info about action target( trigers )
env.AddPreAction(TRIGER", before)
env.AddPostAction(TRIGER, after)

maybe exist: before_main_build, after_main_build

@ivankravets
Copy link
Member

Pre/Post action accepts a taget (or list of targets) as a first argument. Target can be a physical path, a SCons node, or virtual alias.

@Wiz-IO
Copy link
Author

Wiz-IO commented Aug 8, 2022

I understood

@Wiz-IO
Copy link
Author

Wiz-IO commented Aug 13, 2022

as idea / info

I make experiment with add "modules" ( not compiled codes, existing in framework ) - makefile style

as example:
https://github.com/Wiz-IO/framework-wizio-pico/tree/main/SDK/lib/at_tok

at_tok is not compiled from my builder by default and I add this module with project ini
board_build.modules = $FRAMEWORK_DIR/SDK/lib/at_tok

the "module" can be existing code in framework or
can be internal or external library ... lib_deps etc
can be compiled "on request"

my add modules function ...
https://github.com/Wiz-IO/wizio-pico/blob/e2ca0e87724e0fd8cd90b09563aa3aea5e6af232/builder/frameworks/common.py#L348-L364

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants