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

Feature request: list custom targets via --list-targets #3573

Closed
mcspr opened this issue Jun 23, 2020 · 4 comments
Closed

Feature request: list custom targets via --list-targets #3573

mcspr opened this issue Jun 23, 2020 · 4 comments

Comments

@mcspr
Copy link
Contributor

mcspr commented Jun 23, 2020

After #3544 it is possible to list IDE targets, but not the custom ones that come from user scripts.

For example, https://github.com/xoseperez/espurna/blob/dev/code/scripts/pio_main.py defines a new release target via env.Alias() call:

# handle `-t release` when CI does a tagged build
env.AlwaysBuild(env.Alias("release", "${BUILD_DIR}/${PROGNAME}.bin", copy_release))

However, --list-targets only lists PIO built-in results, as there are some targets missing:

$ pio run -e esp8266-4m-git-base --list-targets
Environment          Group     Name       Title                 Description
-------------------  --------  ---------  --------------------  -----------------------------------------------------
esp8266-4m-git-base  Advanced  compiledb  Compilation Database  Generate compilation database `compile_commands.json`
esp8266-4m-git-base  Generic   clean      Clean
esp8266-4m-git-base  Platform  upload     Upload

Some observations based on the source:

from SCons.Node.Alias import default_ans
print('- default_ans')
for x in default_ans.keys():
    print(x)
print('- projenv.ans')
for x in projenv.ans.keys():
    print(x)
print('- env.ans')
for x in env.ans.keys():
    print(x)

Which shows a more complete list:

checkprogsize
nobuild
buildprog
size
upload
uploadfs
erase
release
@ivankravets
Copy link
Member

The API has been changed. Please upgrade to PIO Core 4.4 and use https://docs.platformio.org/en/latest/projectconf/advanced_scripting.html#custom-targets

@mcspr
Copy link
Contributor Author

mcspr commented Jun 25, 2020

Thanks! I could've sworn I searched the page...

It also covers another use-case very nicely:

diff --git a/code/scripts/espurna_utils/lwip.py b/code/scripts/espurna_utils/lwip.py
index a742fcd7..2ed1bd6e 100644
--- a/code/scripts/espurna_utils/lwip.py
+++ b/code/scripts/espurna_utils/lwip.py
@@ -48,9 +48,7 @@ def lwip_inject_patcher(env):
         "Rebuilding lwip",
     )

-    patcher = env.Alias("patch-lwip", None, patch_action)
-    builder = env.Alias("build-lwip", patcher, build_action)
+    patcher = env.AddCustomTarget("patch-lwip", None, patch_action, always_build=True)
+    builder = env.AddCustomTarget("build-lwip", patcher, build_action, always_build=True)
     if os.environ.get("ESPURNA_PIO_PATCH_ISSUE_1610"):
         env.Depends("$BUILD_DIR/${PROGNAME}.elf", builder)
-    env.AlwaysBuild(patcher)
-    env.AlwaysBuild(builder)

Can't comment on the IDE extension as it is still in development, but CLI --list-targets works as intended!

@ivankravets
Copy link
Member

You can try the latest beta. It's ery stable https://community.platformio.org/t/platformio-ide-for-vscode-2-0-beta-help-us-with-testing/14097

We don't plan to have more changes and we don't release PlatformIO IDE extension for VSCode because still wait on release of PIO Core 4.4.

@mcspr
Copy link
Contributor Author

mcspr commented Jul 2, 2020

I did try it, and it works! Thanks.

Sorry for the delay though. As I never installed the dev extension on the PC I tested with, I never noticed that pio upgrade --dev does not work with PIO installed through pip install --edit <git-cloned-platformio-core>. I wonder if 'upgrade' cmd know about that method of installation?

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

No branches or pull requests

2 participants