1

On Visual Studio Code with PlatformIO when I click on [v] button (PlatformIO:Build) the IDE run following task:

> Executing task: C:\Users\Mary\.platformio\penv\Scripts\platformio.exe run <

Processing d1_mini (platform: espressif8266; board: d1_mini; framework: arduino)
...
...

when I click on [=>] button (PlatformIO:Upload) the IDE run following task:

> Executing task: ~\.platformio\penv\Scripts\platformio.exe run --target upload <

Processing d1_mini (platform: espressif8266; board: d1_mini; framework: arduino)
...
...

Explanation:

https://docs.platformio.org/en/latest/userguide/cmd_run.html

I need to discriminate when the target is run (compile) or target is upload (--target upload) for setting different environmental variable. Something like

[env:specific_defines]
build_flags =
  -D MY_VAR=true

because when i compile the project i don't want debug information (for example Serial.println()) that i want when i upload the program via usb with board attached.

I look Build options and Advanced Scripting but i don't find anything that was right for me.

Thanks in advance.

1 Answer 1

1

Late answer: Build flags do not apply to UPLOAD - because at this time the sources are already built.

If you have two environments, say production and debug, you also have to upload variants.

pio run -e prod -> compiles prod environment
pio run -e prod -t upload -> uploads prod environment

pio run -e debug -> compiles debug environment
pio run -e debug -t upload -> uploads debug environment
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.