Comment out build environment - generates lots of errors

I had 3 build environments (nanoatmega328, megaatmega2560, due) but for now I don’t want to build for the due. So, I commented out that environment section in platformio.ini

e.g.
> [env:nanoatmega328]
> build_flags = -D DEBUG_MODE=1 -D USE_NEOPIXEL_LEDS -D USE_U8GLIB_GRAPHICS -Wno-unknown-pragmas
> lib_ldf_mode = chain+
> platform = atmelavr
> board = nanoatmega328
> framework = arduino
> upload_port = /dev/tty.usbserial-A6YHB9OW

[env:megaatmega2560]
build_flags = -D DEBUG_MODE=1 -D USE_NEOPIXEL_LEDS -D USE_U8GLIB_GRAPHICS -Wno-unknown-pragmas
lib_ldf_mode = chain+
platform = atmelavr
board = megaatmega2560
framework = arduino
upload_port = /dev/tty.usbmodem14141

;[env:due]
;build_flags = -D DEBUG_MODE=1 -D USE_NEOPIXEL_LEDS -D USE_U8GLIB_GRAPHICS -Wno-unknown-pragmas
;lib_ldf_mode = chain+
;platform = atmelsam
;board = due
;framework = arduino
;upload_port = /dev/cu.usbmodem1421
;lib_ignore = EEPROM

When I go to build, I get the success on the first two

========================= [SUCCESS] Took 6.41 seconds =========================
================================== [SUMMARY] ==================================
Environment nanoatmega328 	[SUCCESS]
Environment megaatmega2560	[SUCCESS]
========================= [SUCCESS] Took 13.05 seconds =========================
Built target PLATFORMIO_BUILD

But then the build keeps going and generates a hundred warnings that look like:

Scanning dependencies of target PixelPacerController_v0.6
[ 12%] Building CXX object CMakeFiles/PixelPacerController_v0.6.dir/src/PPC_ColorUtilities.cpp.o
[ 25%] Building CXX object CMakeFiles/PixelPacerController_v0.6.dir/src/PPC_Displays_u8glib.cpp.o
[ 37%] Building CXX object CMakeFiles/PixelPacerController_v0.6.dir/src/PPC_FreeRAM.cpp.o
[ 50%] Building CXX object CMakeFiles/PixelPacerController_v0.6.dir/src/PPC_GeneralUtilities.cpp.o
[ 62%] Building CXX object CMakeFiles/PixelPacerController_v0.6.dir/src/PPC_Modes.cpp.o
[ 75%] Building CXX object CMakeFiles/PixelPacerController_v0.6.dir/src/PPC_Settings.cpp.o
[ 87%] Building CXX object CMakeFiles/PixelPacerController_v0.6.dir/src/PixelPacerController.cpp.o
In file included from /Users/red/.platformio/packages/framework-arduinoavr/cores/arduino/USBAPI.h:27:0,
                 from /Users/red/.platformio/packages/framework-arduinoavr/cores/arduino/Arduino.h:233,
                 from /Users/red/Documents/Computer_Science/ARDUINO_DEVELOPMENT/PixelPacer/PixelPacerController_v0.6/src/PPC_ColorUtilities.h:11,
                 from /Users/red/Documents/Computer_Science/ARDUINO_DEVELOPMENT/PixelPacer/PixelPacerController_v0.6/src/PPC_ColorUtilities.cpp:8:
/Users/red/.platformio/packages/toolchain-atmelavr/avr/include/util/delay.h:112:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed" [-Wcpp]
 # warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"

Uncommenting that section stops all the errors. This is repeatable in my environment (CLion).

Note, I also tried:

[platformio]
env_default = nanoatmega328, megaatmega2560

Which generates the following:

========================= [SUCCESS] Took 6.54 seconds =========================
================================== [SUMMARY] ==================================
Environment nanoatmega328 	[SUCCESS]
Environment megaatmega2560	[SUCCESS]
Environment due           	[SKIP]
========================= [SUCCESS] Took 12.87 seconds =========================
Built target PLATFORMIO_BUILD

But immediately after, it still puts out hundreds of lines of errors and warnings.

Try to remove these lines. Also, try to Rebuild C/C++ index (separate target.)

Tried:

  • commented out the [env:due] section – issue still remained.
  • rebuilt project index (separate target) – issue still remained.
  • commented out the env_default = … line – issue still remained.
  • reloaded project entirely with both [env:due] and env_default commented out – issue still remained.

Note that the “Rebuild Project Index” works, e.g:

Project has been successfully initialized!
Useful commands:
`platformio run` - process/build project from the current directory
`platformio run --target upload` or `platformio run -t upload` - upload firmware to embedded board
`platformio run --target clean` - clean project (remove compiled files)
`platformio run --help` - additional information
Built target PLATFORMIO_REBUILD_PROJECT_INDEX

But then it goes and dumps all the errors afterwards, even though I’ve got the [env:due] commented out.

Does this project work with PlatformIO IDE for VSCode? Could you try?

Sorry for the delay – had to shelve the project for a month+.
On a Mac, so not really using the PlatformIO IDE for VSCode.

I DID MANAGE A WORKAROUND:

  1. Duplicated my project directory.
  2. Manually edited the platformio.ini file to remove the offending build environments.
  3. Re-ran platformio --board megaatmega2560 (the only board I want to build with).

Then opened the project and ran a build. All good – it no longer attempts to build the other environments. No longer generates tons of error messages.